libjfreechart-java-1.0.13.orig/0000755000175000017500000000000011216245561016157 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/ant/0000755000175000017500000000000011216245561016741 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/ant/build-swt.xml0000644000175000017500000000610511173030414021366 0ustar vincentvincent libjfreechart-java-1.0.13.orig/ant/build.xml0000644000175000017500000004040111173030414020550 0ustar vincentvincent
Header
And More]]>
Footer
And More]]>
Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.]]>
libjfreechart-java-1.0.13.orig/checkstyle/0000755000175000017500000000000011216245561020315 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/checkstyle/javadocs.xml0000644000175000017500000000134111173030414022617 0ustar vincentvincent libjfreechart-java-1.0.13.orig/checkstyle/lines.xml0000644000175000017500000000132111173030414022135 0ustar vincentvincent libjfreechart-java-1.0.13.orig/checkstyle/properties.txt0000644000175000017500000000027211173030414023242 0ustar vincentvincentcheckstyle.allow.tabs no checkstyle.maxlinelen 100 checkstyle.maxparameters 20 checkstyle.rcurly alone checkstyle.ignore.public.in.interface yes checkstyle.javadoc.checkUnusedThrows yes libjfreechart-java-1.0.13.orig/checkstyle/style.xml0000644000175000017500000001466311173030414022200 0ustar vincentvincent libjfreechart-java-1.0.13.orig/checkstyle/whitespace.xml0000644000175000017500000000167411173030414023172 0ustar vincentvincent libjfreechart-java-1.0.13.orig/docfiles/0000755000175000017500000000000011216245561017747 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/docfiles/AreaRendererSample.png0000644000175000017500000005723311173030414024157 0ustar vincentvincentPNG  IHDRXr5^bIDATx l׽=\ꪺRUUUUUT]UU"~J/&61ob?1666&8`qII.i"k13g9X tYϞ5oMAAk        "}k  [055Hh97ϫ*~򓟈__7M?YTTT/  , EB#''ǕDzsN//G)( g?٢/~ GQQQHaHP`AE"iޓÁZdo~`w)""??CE˖-[ď~#).\ 򗿈oo322_O P~ z))ݯ_ݻ^w _:ܼyS7d$&&. k3#6 (p 0.PÄ~Eb6 B֭[A?Sa㷿8pX'.p~4k3 ,"# 908w܂픔)))YVAuᗜ(Ȑiߣ)hF`zQjf# ~x0Th É,G{}}@F;eVl;FGGer`[_ǢAE0==BzO)L& '0; {655l>la&sb6*{=%TSʹO~KXAAAAAAAAAEAAEAAEAAEAAP`AAP`AAP`>y^njk+s:_[|֭[XNosVE"?Dwb_Fpw._;_o|_~ _W_|,**2u\VC=`8y|??''7ǏsgwǍ9ryw+㷿(-- Aso`gq > ?s?矛FۻT|sbqC3TWm_7Fڒfpm OF/fyQZOZׂ}2WSOc]='FPO~ŋM6>plu+2W'?֞`uh1!D@bL 4 463]jhc=&WRR"׿\=;/}w\VsbbB>NA]ϡz{{yAǃcN ф @ p,- mtaFmfVsbqCGךX/-AazS٩pg6n'}vx2226.쓙J\p>!BHΉ>H˿k *]VV&!H0p,h999r;/// Ds;44\P |^ݽo]C}޹s ]80.]臬o8Nc`[LuLMMBыs pjqW#%lٲ/rR{7"0Bg}94Ozz˗eXV do2΍.؆DF%M} W:tEzNFseA߉Ͽ/ߑy:?XPxpU0کJ#N>T'aJ{jB}n t!7:b86`}o8NtZ ^}Vck v̌ȹq?O Hw.pAܹcZiΉ3{pDP*mY>õq3V~hơ9JѨa`pkcцǭI<֍7P4{q6rn*;$a5aCKΌw+m691}v pDP*T#l{3g6n'}SvnxK;Y>YX9K`+W'$''aC``BA w(jFkǏ|0PoHF2b8‰;tx 2#'V:-zP#ŮOo9_F^5vَ+%%E^e!Ԑgn%ꜘ>o#P; kU8 ipYX=#}@đIBõq333#שZYF^z2/,>SjXR-uJKKZTHU .mT6UǠ⳾: `QY}ȑpmEhL--F0jc`m0rBjkFG^cW=ssEߴ X׿ - , krGX ߣc_jx_nXI tȁH|6t6:sl~I o1/.j Ic WkzZ@oJD`K{;Pm,~+qafeP9?څa55Fx1ϡ~f&Zx><XCzC%3hZk*X]}Z辪UV*BX{ ߥjacd6wq z ㇿ#ࢠ]^}sXXjN;^C(6l~VmYp VϏ]9Xfy5ssGߴ5$}2M䉠"|&I#MtEXC0kp! 7+lwE]-d`>; 7_q ȰiЪ P4X?3kT`kcF;iˁPA9XFs Qd*}Ox"( ,uҹsCu`-Tg*v7kd_1dn*CʇrJ86tߎc1=[.fV/F4\3L[Gs e|DK`9X~VOs ׁtRïzUq!PCoaqUau'2vBvvEe԰`0Do~#{Y>Pp"폙P 9?Fڅap1rCA6Ү}'<1EEP`?lAKΝ; 0+k`bUw"N辢c{5i0hQ>0\Fߎc 0*` a`Vbʫ{3Ldn`7sfC6fpc-P 9?Fڅ׿'kg-"9@b-oHNVP}f_B,i7V ܇^L0)>#{WB/1R!-µ13|m9w:/1.=\# wͶIB#oHVodD[y"EbΝì탺kg_ ( , %Z{{~AfO0*AAX󑾆x*Q(ƍU  ,          " " "  (  (!;;{7kcݺurA> \ XqYG \ A.S`+c \ rA><`0 3X \ rA>9 \ A8 \r3GL|r>`0 U ]ܿ_Fkkx \rAe˖-JK҃1sA. *D]]~۷ogw\ rA>U@T\R'xB>䓀JR᪓Gnsccv1533W W^yEpk0;3* AcQ1(ٝ;S`YE =X3'މ1wM9+1'N]] U bR\UQ ,@Y 0ٳG&fxE>RQRrC`\>qn~qx ,}MM+u DoZ *8u +X  Q\|%Bl} l[rIIXQ{P`q-Bzhk;#\_Z:BNȅjk|SJ*ѢbA.| &f믟e` q_iko[UڸQR"{z(, F Q]=RX d" b[L44XV 0bA.|bVQA`!jj&.!n#D;NE;r>TP3+K, FC_4Z*9,o[`=x;v|vtQV`EEyEC9f0P
f X`1ȅU<kcwB.J,鲲* qIH;rA>lpC`6'I|쌨 h3XcX`1 #Cw3VIl5@q,p?0WV^]<`!P킿lUW8_WlU ֥J ,z|oex,?\Ē_.-u B- ,fxE.\DMALԆfŗe&킿Yʉ*,D<}b0cs1[<7 of,[.`ħbw_5|Dxh$,bo|[%Uq[ ֙V ,z Î`̋;!vgVe=V,DC,Y$`0ŻQ:izxddo||Xp2k:!5)"͛7?Ohixh,"/8zt@Vwvw1ŻQJV3Xjc]doė|/ydpXʇ>/҃E?B fx~킿_1o6[ȃm۶J1*ŏxl_r%홙)iL&ƍqߟS&Y$IvEŭ_U\zCؾvolWxC~޾q萸'7*YX\ګbŊ,."ײr.먫cm,/30&eLgƆ,+\igVrgSVhm=#NWIƳ6Vw0;V fXR`q-BR@F Jƪm[Rt8YٙBTV^bpߊf"BkzoZt}6L S|8],mvpեJz)*Y UÇlNfX |wv36`EE<}bD-PA;ka 3>CU gv_.ˆ~LUVR`1}U)~5Yh pR}+' NfbƆ|Dŕb ,z﷊&P_EW׈o6cnhˮJbaoEX/LŻј \aZILVNo唶0 Vؐ;X [L\VfPY-nmcgb4()`Y-',iۀ6JKݱW ~+flȇ\Q`у劀rjVBf Zm8'N\O my(`_pq,orJVJ'L^‹Uۀvzm,7!vpE)[9sp2:[1\b~+ef '\Yʩm踱ϰoŌ  ,z:oh<ٝ26 *+b+nܸ!y111 V~`j*mb}+7 b=GfbƆ|E}v*S###`VuE1՛Y򆵱b0 ~Z~XB0ݾ}4pbV m[m+036` P`C=$Ž{D]]HMM (Th! c<1coػ]sQ2|ސߋkZ˖-c˂ f)!38㾒lxkb@V)aƆ|X"V>R`=s͛ @@ 3qMtuů6V:sv? 4oB&+jK}WgϞwfuuu癥`ֆ\Xi XV%7JE7:fl X93 ][\14u]2Pʩ^|xX:|Ȼ'EU?z}+fd'b%w[gk1cC>fp()U pPF廇{zRߊ .b3u fxf0l5m߉>Qry owvt^sS`1Y45uEJflȇ۸fm,KĔ>fƶ>$=*0e.&kj(,"ՓwD.36ՓփȊ';Y]M=Xb,vzY fmȅ kc5k *e"5=*ٵf|E,}XNyaf0b֒4(ΰ`5_tuK^lxaf-0K,c7][<V.B_߉oFDռ*TKŮwvAc7tmPflG\`2=Xa~ sD>Eccd7K(P|8x FTet&5z1XSEe%f)!q=-0'.3$dTĥJfl= X`_2/ b2:5j,{Eۙŋ5;x(˘ѠbC!^ࢥeLf2Xrfռyӻ׊2cC>"+P`уp1ך9"^7=jc:}A\)ÇN&\E, ?^`Yr@߰3Ovɒ fŒ k;Įtԓ,fv0cì X. -+pym 8G+rg3kEHCxe0tqÇO+R0kC.\|-\Ned4fQqzͼRqbzfl!ol}5sD>ȅ~E-l퍢d"q%c8Ao,re\c \<o.jhx/\B $4Q3Z\*ʌ 3X"ʋ>S`90FuE^\ Gi鴜2]캐J{ŕ3|(XdIBgXm,6\i?!"elVᢵ+U\eƆ,r1CX^`:tSC9"~b[ѴX3X+",*N6-TmΠ,sqkKjk{fvflȇ_ؑ?#{DHXw VTNp3x:f|E}vZt'xBTTT/µ13~uoHqbվ5n8-03|jk)͛R`V*Ȑs*xl_|E.;t ;u?n|6#^}Wɿ.ʶ^E.Gookk*D1k"nQp1G]*\ϗE6FT͉o/}Wxtdxw?XT۷}7/Ԙz͖\=1bٲe`MN^>=G#غ~EEҨ؛JqM?;lQ]w7-CBfΝ;s~b# L<)K͚ӮWE;E Q2bYX-h&:sD/ƢϮXbllLf \'ߦ`0t+}U+" utIP$nE8u7g}& ?`F+"Z[[þC$$$zHO{q,BSVZyAeƆ||ۯ)c2X)Ef[iXqb@#3X*ުȌ 3Xb+777`I)Pɽc>zǗ(O~3xqrXeX\!ҺsEpn՗;϶FDXjf-3<CXBZ6`y3rJ Q?$2c jnn;s|( Vf Ɓq[N# .ޚ!5ŐŬ 3X^C ֊}qW*JSR:fl v.UZZ}gW /F˦:~jcvk.xagx"*+YhmKbֆ,/Q3⡱`lɌA#?x,dƆ|D+Xj_yEp;%6ٝ*i]Wjc9̓hуz.Z+N+fmȅkqM쎡U 8g*qBdnuEKj1]f\ͅ]>~'(sᅰx79N\= /ZJ,d7δW`ݼyS$$$KFx @+fmȅWXdƠ֓+ʆ,ˌ 3Xbѽ 衇,_.Eg}xEpEcⷊ+JŦc zr%+y*._\ܻwO>/***¾^yq֭yVC86`(uJ+Vk fxIwB 3X®E"04q< IIIի -22fg#Hc4d$Er{[w]j[w?mW{U߲x(HJxe<{@1v@d+r8ۙGw,T|?t1k&ƶ'7Gʋ)2-f}{vo߮=*+?11! Htb+ nR$T#-bCI3IJ.<5wA/pIfN"kF;w&s5:Z};.iܗYxƪ6TY"#)2kmy==`uwwK,I/N" BlKE҉Z#NJLJ_䳁zWƄ\,"iPuBE.}ȕ@v1,|#.l2b֩=$zZ2k_Ν;Rdah333XWk>DjgX5ӡ0VRƷ}ՊW+VCT[J }CQkY\fFkrUkaܝ"Eݚc ,?cka9Y`UV^ x!۲B`qz/y/Sw׬VTcU{YշZs> /ubfGg]UVBe&Ko .݈J`A!S)FGG^]0*cbC" 8T-+=ՒMM%3Y 91iڳYXf\[E3UU3R9bruk/4!?*&jɬVm Vx] J[\,E%ܻ_װ޻aؑ7lngfЊ C(kVIǭ1'>P#fxkcU]mr!+*+5TV MNσ矋N / 80_ +  dipCiH_\f`;o >F'2X8.K@~g0@ׁʿf U,Ejrjnn+VZF4E`_w""a(Rzpp<E{מyPު U kr`LFy񨷁1#Q`|sD٪hg jX… g5Vl`3DS|詌a#itn4G+Ś Xn(JKņ*3 ʹ#qXcd D2Xc--X|X0\ V0)YbȪP"MG 5c0ͩRV4EI7USO !]H}jGrVVKVIY-#~7C^-3 #a1!l=VE#Yчun~ ,`#ejceh^Xff`G//pmë32:0}FWz3&w-wpcݔ B0u`MP`9E`_!#/`2`A7yՊfVˌh+[6 60Z}mlзU"'x 2#vz("72Z|VS¬֜Јdv⣐2DeXOƤjwf.J]%ܐ "۹H} 1QHj8KO,ZV.[ڵEf[)J>,DhU["]O(:>E@oʒe/ ? ֢RqDz&R|VV+T~+#mk4TRl-5?lH ZOuEH"3X֙*ƪ6ZjٙBvtP`[`_%m (L\ vHGůhSY@n`"̃>VzfsZ0fAbϘ{o~٪p&Qp&рJ;=X#Z[[ŪUIJeEjj~zV ֒Kg<8T!Rzd#(5'M䀯RtUj7neI`,>R`%&&1M>.Ic۝:ȭTALNw'n%ѫH*oԓ .umj-4-ۘFmHlj#r ZņʸէJq2HxvXJ\ j mgAwJʕ+*.^<̓)U҉Q/*b(C}]!QEIw?A¥vgZZŒx Ej{;!Z=1 NoZ5r]у*.`~/:JCP_LBW d111!g~҃/2xqѰ- 3m iO؝OVewel}G-\~`|[jY3}QQXX(ܹ7US3xxJwMrZ^`;%)6`yM6`9{ Vu!y3"q+[f ݱv+,R%emhE$1o_kyygR`ES3jH8=NUY-0Tkܠdž*fm ŢZH[X#XXWi; '{V(sB-˳{]?=X 9,r+_=Xߛly@q+KWgVԞ|ލbQXd+>*,"v-Q¬ p;Xǰ<2 F X ,js91щeyJbTb ]qIHe*˸itݨ,PSKZn`Ţ (6+\<Xцl[z+V+jMaA4VC _e5s}QgﯔeV!A Y_b>a=no Zsl2X^cMwbX',p.PYre.e1[ֹ)-SM=XN14?*` _FTWksumY-;2X2b\6C,fsqrsDf h , ;'U`J9fY- Ho-_V f7d&!VQ^fn4Y-T/i gm ryb?pTղjkk bٲe7n}QLvӲ艕kM.w^SdʬVYm,\,zqIɆ+XbllLܿ_ܻwOݻWX"&KGgnIq$_4Tj`q&  v.};`%fl8!¥KD`iW+9wepAj}& Y`җa`Y`:|ٳ2m_uE6t \M|geVK`ye&  e1e>w{e5}544$^z饀,+ZdddY1>>.I힞i)JJny?LFWpvV7Zj嗶n|ᐾb_v[g>.xsp;1/.AR"Ï'2 \*qD '<ٞ9t(~pڳgFݾ};&㑛ϣJv28%\9Æ&y,e.VW{7u{,4hWYM](eg`0>СՅC'\RM5::6ke S( \ćd O#`,Z^^ؙXK, XW[lDv28=1>\ r=>P/Y-5ĵ\Ä#ݬnγ-U)r9ޝ rA.GWʌњt{;KJ9(ߕM ҭ-cI1-OM*dܰ F |l" N x55X ,jCI2Ozlj| rA.GzNc`=7,]mtYVKJlBġrWy7J> cѭ"xZV3XXLɆB H_(2'lr28 po ZFcx z{) ,H2Xk=( \8xr2Eje }kLl*uo*xK\ rA.GZwcg Z`hX`LeU`)Վۇf F |8mb$,D[ga5@eU`)ƪVa0 sE^O֟~pTbdTe%_af,ij)F |Z2zvȺZ\1R*0gdCE) 6Wʰ _( \xM6TWd'6D3Uz[W\|W^63 ß5w d9@ZCL[_oy+n}nA.,sQ2 \kˌRQP`%Ԟ΁~ A./ٽ-cK Xf_e5Go0PkRw\ rA>zҗQS;3X(0]ҢXaWk틩jOL `)`ZMY!ֵ< ,KOEĮ`Ż/ \]3Lm`E@R {z%fgg#v%K̇KR$8epyN| rA.G`!ZRM/!h,M{28( T!VLCOx_ Jrxq||\G UI wpb>ÄG ٽ2V'+w_>;mgG"߷|vn#U8^=># i7JJ?#~~`+*Ã\R;\ rA>ly fz(QS=`kCW; ġꨉ'DJO=SrA.=;2lxbzË>S`_m; pyXowlMВ  &TuoDA\Uq| rA.G xl K+0I2 5X_ț}x~E3| rA.GXtml8ѝ܃6VEo;}rA.#vl-L_ߊ`0 ŋ>R`X_axp`MTV \ rA>EIb&u> P`_m<j\-9\ rA>Et(ٲ:YaQk+*+"qtbH |\xܝrg ,jMC~]l `ȗ5Ye:?|ܚNJy/A. .Š/--LB /WYMVoUhp̜\rA.pf}Y{ŕoQ`Wk3:{dw_\ rA><ąY_PC™X_ [1 0j[>`o/_w"~+q A. ¨/y5LB ,R/y3V6` A. ˆ/+uѢϾX5 o;rA> Ý\u l8_WGt~+`0ac[I ([O8UQAUჁK0 WQN\rA.p|Y5)<-DJO+ \qyt5v`}> CQo;rA> \ɲd}:WbM?V `0澜CoUngZ[)߿/ƍxBܾ}۔9:$V|鷪hq A. bml8I 7։w ?pvSS(,,4%zz[ũar̜\rA.=;E`Ng)^~eq>H<Ӧcm1[\rA.>y3DX˗/_4dN +ZXB??)bӏsGns6HQ>dCAA`AAP`+"nݺ5 ֓O>ɳCAU466ʙ AAkY `0 ,u  " "  (  (  (   , g… b% ,Bw/± N|ǾsDIIɂ~Ԕxp,.]D.C$d^x\Y]]-JKK]R`و~Z^<13?I(rrrɓ'}ǝ;w$eff rJߊ@jffF>}5;C1022"|ɅV\r4@[D{=A,MEؘl~4===|| ,G?BlwuuI1m6_GyDߜZJ"55UERRx๡JX!ݍ @ #wAL`x[W 🞞 ,0RO6C~W2z~ gf@O|m/+/ ,L. ȇ \rA.(,33 8 \ A.ERh1qxX| rA. X4,emfy_> \ ,P;|| !\ A.I`( a,k cj,sU!M> \ , @\g, 0"6֖C~$\ A. 1amY~+{A. \P`YÚGK,nZwj'.A. rARSSP4,ƎFuƅ0 36%LMM5\ rA.gm ЖZ52*3 ݞ#~m\ l0S6ԉGQDQ[[+ܹ#fffޅy6p\x rA.gm K cWZ%䢓!P\x rA.gm , G!_744$ w G A. rAeBepE7A. 36ab,J]b## # #| r>m\P`^-!r>`A.("ц@> | rAņ@> \ 7VA> \ ,   ,   ,        " " "  (  (  (  (   ,   ,   , W$&&˗e˖GyD$''vßdAXA7n¨Vܽ{Wܿ_twwLXAP`A̡C;w.[RR tR7o\ 088(^|E~X>lgϞ+WG=Ђ8s| 2lӋݥK+"? ߲ehll\p\6"/&ƭ[lC\ Wkk|Ӌ- \zz|_[[.((<>{566&&sgV q)J}'o ( lća=?Zj|62YJiRRqҾ~jjjpɑ#۷AD|A+tzAH`a/z>}M}s؏` WJJưf AGAmx饗eJAe+._,ݻgH`!`qē x'~ܾ}[~֟'x"8Eaa,LEMp +VȿA?[ bXPC# %%%<AE](!_0CO+Z{BQٰFGGsQRx]]]Ҁ,fi?y5Ȫu { ܸqc$fAEutvvJùVafAD O?` ޏ!:BT8txg+赥?>W!\ .Qߟz)l"B,$?sϞ=$ (  ?H#<=v2  , GRU1]gaxEU "  (  (  (   ,   ,   ,      OAXElAP`/@MX A}ADlAE/@MX Pvvvx>f ,"G,A#ЅO>˖-+Wcɒ%xG cnkk r_O7n}Qc *VZ%e"55U\~ (+%%E444{ . \UDC`9ؘ޽{Ŋ+lXN>fD>KEX tRy :#6o,ygzjQf#{FFFv ȖXXN>f>)zXAEX.xo۷_hPyG0CDXN>fٳ2cr1#v!XAEX:?Afߞ|IqΝ₩|QzC8}cr1 ^zvSY c?c ,"o,-uxO.399)?.&z{Cmv ,'wLXAEX ΨLD0N o(|rSp0}AiY?XAEXf#a& AIzdNzs]xCLv ,hج׎.?`" ,pvi./`^q!Wkzϖ-[w qɐ*Г]p1n1H#? S|aaOAP`A}AlAP`/@MX A}ADlAP` AAA#;viIENDB`libjfreechart-java-1.0.13.orig/docfiles/BarRenderer3DSample.png0000644000175000017500000006354211173030414024202 0ustar vincentvincentPNG  IHDRXr5g)IDATx PTg?U[[[[[[[[ofjNef6Lvv߼Ą $2v b B2"Ƞh A 4("` Kl~9}8n>k>s>{~9!  ȯ6AA  AA  XxA &N:EK,O~&MDk >~)S{F"ύfMMM4|ۿ[+PVV  `" (;ب%T|~q^6l35\C Pww㶭lHk!`AP멧4yP9cyG{ZjG}uz#6(ucc#EGGKu?C=J>__qΝ;ݿM>U˿~_pɓ'%*ۑ!`AИ!w\ty~w#,ީ1}6 M_#=~9У}L %X@YcZƠ\@{֮]+V9@QJJ: hl:Ύw >t}P?ϮH6VZ5}%pwÜ&_xHL:U?a@uV]j;jCۼT?^\\NA,Zh?e}7uSD_}U0M~xOU?g$Tڿ ekXF5k.jׅOcǎ ~N|嗇msg}8. AXe9|u5#ݑsӂ ~',͎!Kܟٟǹ'HK[mN,\[fU#w{m +R!AXf|Վ_?+VZ?U| ďN,\k]$m52{ hŗvZύķjMgvwwӯ~+}3"3Mۍua|__z]:i]Uݻwg38*5Xny|Mؑ3H;}A ki' .L)`rm^raߏE ٺb,`AИϟ/kxfq>E;M`>L1ʌke_!\ֽ7`mgͧޔ.Z=ufTr՗;wȿɿ/P߀8Y|pɝۘXAA,  AA  `AA   AA  AA  XAA,  AA/ ҩS1ʸz*@cPkE7oޔ}ܹsyD 15ƮUss3ݺuK~˗/c; <&k @ O G[9D ,]+#r@X,?V,m!G<X~vhkkFyy6h6hۿ -߿OUUU|m!G<`??MQ/@C` kyD# '##=J*KD (,B X 1ӦMx =ZoS*Bm{T (d:90E/#9D">Mp8 ?_[c }8D `1h>EEGE bYARFF Z[[?@mɵR9D,xzs皾w2"""(++KNUZZ;`!Z#@ ,ڵkګa'+==o4peg*ЀfX h a[2rk5XrP@lXj10`{^ǔ, hG[vkt/M^oBKLoXiV."ӈ/C_޷,"v#M$%*OĘ 8Raaas0;X+Poxf:i 믟ŋKyJWnY,]81z{{=jf̘ ֑֘f2sOү]n `b_dʛڹx*1`%%%Q]]txl+Wfdd1,;?+;"vz{rԏ `MtJv,r+Vaa!%AnҤIN999@yX8`2ry!^Y6El!`i]`P#uB0l}gXR\++%Kϵ F{_k*1Bh -KZk+\+8X B 8kXVjϵB n:ZfilڴiDUڛ4㬈30^ `>mB[FՄp,jXrڶm%''ӢE cɒ%;6iG5[o]%`ٱ/MK͛01Bh _\+w ˜ `!gJbFҊUxflݔ8YB/SRu X]є5 QMfҵHԶ\.hr1@Ҭ}R,EFSN~ڛGG[]h͖k 1No}QllgEڹsW \P,Ą;E $M<9V혦G[qvX,1zj#""hpp':Ṽ`I  B X4Ot,Ӈ= hG[,8XpXSXrrr$}}}^mqq-,,8XZ+233);;` ,`!0Mz/,,sfM4iEG[^v[l``m#](-]I!`uϞM]jGs:2e p=o z'Oի-w˖-;sj*+<&[殸8ސj;y:^y?L@|Y:6}:j,8b#[ըʭZXp24n(W rm+QQA>yg?3_|:L"&``qԏP5k~ 矧m?4 ,b\FZ``ĵrGKqԏBX B ѸVV0]+uhKZMTB  ѺV,8XXul`VzZBX wXkke,#J XFD,րFҊUxvsC;M̎޽r9cnnn={vE۶m{O.6OHˮ;\|;&2j{jMɏ%D2u Ùp:(M7^`&]더Km;]aھtr=,kRm6@j*=g^E7p]D3X&D^N}[h\2Dq~=M5+i954ȥظJKx?^^޾ ΋1~I\^9pţՍp񣏨^sX<"bXAt^x:dR}'?C>K'^~ٝOWt\/UUr<v`` fU^(H T<>4qBz|0l|B VC'j ZʒJrsrX)/-7$lذ~=,~t9P2&cPG11O@+6,`O'fGE1Eptp j0XnZ|qNFE1V,֓8Q: _Ԯ1Ŷi<7sʕ+)--M͟}y-E#q<  KOsާ;kȵ*[:9TKF,n~~'S=Zo~H]P,` R\++%KZkX`)B-`Sszzz(22R ު=4ֵr KSk`BL 2eʰӀFZ#b@kmm xEkOг҉_O}^[ 7}Oy`ݞq,!Jt@8X$`VZKϵ,8X5Q ajn ,jX, 5X,Z+m<\PB k[(r]YF.˨(G1B'u$+ s7t㳸8:.vpF0N~yh~,6oRʧbS`)V9y`Gz7Vy:;; WSq|˝rqqؑ+kݻ^qX|:Ďl|g?Ct?E ;\*+wZm9X.$')w4Xz `w^ؾ]E>i螡,O9CV혦Aǵ*-]#(ӝqQQJJe` f!$"h 2`mR]~냲M*J 4hl`YɣnE6 Q͕!i(bkmmeq!jSX}"GVqa^iX/["VK9 m~U,2̲LZqӃtD```?`9X;)z fus,kdvԡZ]{v 5X`٧ eZC X TUXֵ,k8X,8XpXp`,2ru XB  5X,suX,̵RQu```صzSlqq~`,׊c~|.1 ,`j[\Lo^E`+`QccV9Ko}ii''@j\j XN\rެ̀{{RrM2ŹdeBUG;*]raAz#eRmy:,S劖Kve2rxi/h+N&vrʁfUUiڱcm۶Mvz^ҥKҬͷ`%ߣi-Gy:fE5)m,+Ϋ)KEGv,` ,(ŷ1>ί@$?!ኧa;!SAU\5V5J8,, >Mŋ)>>^+vjkkXʮ .15X,`P&w_`umrT0Q ,,8L `R  5X` 5&puA ,,,ܵ7PUjkkFs]|Y&޴x~.}Lrm3`9rEG%wx6%?NԁT䎯N<N輼IMfʝ0/;^er@w׻\ri֮\5WX28VMMr/뫪<ӴCжmdQ;zJJC/|?L,)OV*JqݦS Xhof?̀ry?}/Σ3NHWX6 켼&W~XT$sgFn,ӕU!p^jۜOu?wwv3PNj// wk_c>PE? HeBaٷ%`9DG!ʬ̀ XE^D~y0׾uk;?gsWPo5QMC04ŢvJ*^=8o$4 `zyy2G,q{ƍU^o""LʧOMzY:^KUq_))G׮ʗ^K=~j/kEҾ)+^SYd?}u>}G=@;`a,̃58{l VN.Zxx<= ,jP jGM[````ix;B  5X` 5BPO.[n   壾+љOʂrDs̡|`P,jX`T ST@+4````Mț=766RTTԘ܋,jX`+d/S#O`Q_5D@kt/3`ޥO?m7ne]p._nݗN_,JeJ ⷆRAsRsdô]~D TU4-.˅45iX;$JFΡ%r8t78̔mw}&ݹB//_߬}l{?9 9߿H)!-H6hyS-/߯L|?~Nörպw س2ŠeڼnX&m>;J۞שoy08v$+ƜEݯ͢n1(ߏhWt+,?TW'}{ %Wgs1%^(7Wl7f7{Q\q^T_An>Siu];_E_x>S\)wJt85_վ-vjKdS932<3~i*b޼nmݺ#_ĎSOё~W.PڅQ3PNj//p C}1,'tD,YH 3Q& ׆)G 9̝+~li{ǎʹFmGbM}s=7ul M&A| u{a٧0U.~Jb^G:1(pGlN.墎 hw?9'Wy >g'մuGo"" q{ߣ>}SڇDۿQq䫖iOΉF{_Pt<$-{{<_r~Y uwl{zzvk߾}ҝ+UW&-1~n'c])8O"sF1ny?r{׮==t'._'PABc^ĺߎ8L(ߓ;`ݽ! sj<9z-G F[oQ~e%Tuӧr~bixzF<6WPvڸ5~8=ZH=VtƋ/ۙ3TL|b:u7P­^Z(Se,*-L9}rr@&> 10pd3/5kPQQ;M6Q(Qr_>iw;(켼*zW?^oG!r~w%Jp汭w.=Ly,-}Ë<Φ-w;Ĕ<1W.<7D~\smGt)Clw}3lwmPs=*LcbG],p7L Y7)q~7-\~Y*,pRAm[~-9\vfi_:56.qG`ބfz#ƖGTR' U˖љ3њNZmjԍ6}sX;D?3 m}sNNzqpb\ۿ$/{ǣSW_5SgϦ'GcbȒ4þ՜  1U/^/~~U5ԯ_M}}o~i|SGb#ۙTQ!\0So>Y%X=n3\u_4O79ھh|za5MENҮw_hM?/g,26VKI}]re `픕0),N[XS6, "yfhA*.`Qj `%rk׮wJLtC|*OaXflX^; `Y +*)a.`7,?4?;eA] oNY r׌tc"w+qn%%=p-`K\Ow7o/SJ,%tj)uzO•`t+RYC+boZ &Jxt<-yE \, `-,]HE5OJs)Xq|zxX_}JzLT㩷uG<֫Vڵ}Q/57Ss'eOd VE.w? jjjD<=>ͷƙ3wtH׊J,`)vp0,`NYnz씽,#Jkȵ,wL;aDHh@:_YԀ-`i(. Z ԮWq,k-`̙C4Z \+uhKqԏY z VV;:vy X|)[ڵfΤ rL5, JVO `]+uEk `ƵR?$]0PbR$4--MQ/صjjj,ovZ)[N \eSX(+\+]ҸVV|*kCukȵR?X7efU*0rhXz`VVZYV`%iapeXf`]+o]I}+VzZY7ld#s,K܏Q\+=ҺVVG\+]r`i]+oKϵѺV,ŵ iqۻIJuX`Sv:`Yɩ^݀u0 qkeX\kW j]+uhKZ/  ˵.`9[t)s#XVFzkeX{^c Xݠ{`eX޸VZs릻(:-k,# $ gdP XF`k?lL,/]+LukvlzrZyVm(uQ{&9sZת/˵ `kU]}6 bbbvOOEFFV|]iWc X9;e=j';^98Q`XVشlj\XkRVZK/ oQBsm0͡8PU9TVIɛy Ȳ:IV1͡oZ*۵v]]=o;LwZ ՀULJ X޺V;s JfӅVVeUk|ŋX/,)&nZy T|qZE5`;V樂 }Q X+ wUՀf^_kOb׊=& L24:;Ӎ`5V5*:E3P XS.f̀d|r篝WjW׊ùm ӫ5ŵVV\+-`9)Is攘^E,H5KzSoPOͯ"T֛" w8^VɩGð{nJ@<;bZi7e_,+h W `Zq9d]E,ZO6k+j矓KUG^ViV<8<.ƛ2`);fVV%rkB{UjzSRk Jtי^EXqs`KY{!G \+Nk&@Iofx}R9q!l㺈['9^ n_=t>5GWs?ky?ӲҚ(5,LU17/ܹ WN*6d)b=sfӁT}]*5}>ߧqnO 򯖯?_y޹A7(}KP:]F.Eθprr mr 5~OWQc vxv-Eߣ6ЁuEu"k-<sI~ ɗ_6 E*|av'~2 }H*X>^8Oڋ*YKOioɣN_~4͟ҮGOoc).C';gģѥkT?=]CgQE_mTvc ȑ#bG}Rpn)MYmiM[mT^nqnn~{L}D5 mzZ~ъ+(!U4,%W픳)4!@AeQk"fPb?4T{Ζ7ߨۮ?)y3.ҡ74'?kv}+tZ\3, ee|TU]TT/OXۗvO]]X>n=6Hvn<}Ccץ<*={tr< ?O]d<1wq䪩uofvV*O2;cxzp@H X#9s^{gwPqb&Dbbe,^ѱE^gRVq>]lEWG7zw.=;|8!Àe52A޽Oy{_ZxmToϏߋ˗k,?k߿/o  ,8Xp``!jXB  5X,[V,8X,8XpXpXÇz"ԩS}{zzt_% E;)`\ `0 `GIIITWW'o7о}?NUpF X?K(+PLyy.|78Xqd@[c`r^zJp6jX -:IkזRY~`륫eX _E>Yb,8X#,v ;?՟  +t] 78XqQuu3RA+==}siiiPk``@NFQ5RyEj"jP5QkzV`srrhҥgqc&w8X+eѶeoZwSqBw_OӧO`+ŝ䣏,jX'`q{εB k\T[[kZ. W Z#k:paI]+8Xq?ewPB9&MD"n,(q<.ӶB  5XUZel  5o Q+   `M,jP9` ``B ,`!lX`Xp``!`X,`P,jX,,,,8X,]e͂2(2Pm&'?k/YM.r;^^G6ޥs>zm,\t~]S%1`=..2dk:~OI,][/=:&޽mS V{?}ąQ?,)aSڜGm~lkJɔ:*zM)MC/>|pk}i})S%??ngX̀C,w6/ XcXX|ChtUUm ,8Xpp`FX---?Eڲ*+PB j`F Xҵ3`˵   `Y۵  tEFaaarX`sWyj`J4}t⨷ףkƌ,8X12VppXvQRRI7ኧa=+v|*Œ jX,B efbb"M4)''ǰ``K]k ` 5JBj`XpX~,+~B`A,`FXe.C ;B ``JK48X8X,,[VLL`!X`XpX<8X8X, 5X,vv*wP@  5`Qcc>^Nƻ8Hm3`Qw|Ji-hK@Y\2Lo?NΌ'$[Mwo,/ VKr-/W.<^Jɔ:*zM)MC/vuu!KOm4R  Qu X;rh!ʬ̀55!o<]UU 5XuصڻVpP 5XpBZZZp5XcX|`Y}&Dj`A>VwwtX 4`%'WsP,jX6kP/FZ_USD}j**Obp?NYǮ˙ʒB,`!P ZeddPYYY1M9Xҵ2)````H|ܹsMO'N∈, !kmm鳾[ LAXFV, 5X,`P˗/zOӧO``Z1['%%Q]]t233);;$eZySB  5X,`,WZV&&&ҤI(<}h59 G[}|g@ `p@X!"By` <Xm!1̲L<X-\W.-`!p<XKWSYer@X,Ghk\+}wjkkFCVxflhs=kHJ~Lr^޴]p:$Tۛ7Ij,oWWm%=F`` ߿OUUU| V X---8Ezp tr` `uwwK z(o 9D_D(`bڴi>|),,N*3 7)`wC;ȣQV]F;qqCED%%%Q]]7|CX)>q!@ ,["&OpzvLӀ-"GVV}}tAYYY488`qUkk+ByD#kbVuu5͛7ϰK-%aϥC97p駟8O yD ΐ`(t#ɡKR__붸8ޟ`ݸqjkkܹsПO#9D 7oޔq$瓹WXZЀ(B;yD 1dT,v\+W2\effRvv Bo>1@ȣ]+MӠ>}h5rάI&Qxx<8ډFZ7C <ѵL#,V #9D vtX>\+X'@!ykR\?|b"@ X!{AѣGCl "Ǡ (G,  AA  `AAA,  AA  `AA  XAA, Q~-cCzƆ~g{졥KRzz:ݾ}Ŧyiɒ%2W^Fbcc)77Mdy07o6 u jkkѣ+#h~yܱc]xJJJGbbb(22MdM>6l@QQQԄ b#}W4m4jhhx<))icP믿cbbt!{ӂ MtuuuؔY,+N֊+}g@!9|VVrh<|ryyς7jVEdc]|YƪԹ8j~lr~#PTTՑ5|9SIϗ'!#%;B,9s`.jfljq8îVagSHr.,}`A6Tcc>+W&Һ֊k89C hS??zWͧ OrȧyD_XP`Yy9 (,l[{;*g=z4=rkGEY|W0ym9()%o6ZlU+GMKY|e 4tb(#"q_˷TЊ;֭[i2>>^οU~y7/B,hh"y7v|K_.Wp}foY#"1_ђ%[v r!r  XAA  AA  XAA,  AA  `AA  XAA,  AA  `A*++$2e Ѵiht1?瞓A hkʕC_5}TRR30 `A J(ڰað-Z$CCWbb"My&}7^rt<X3f̐ߣO~Vxx8A,)??ߣ&J͛7˩ G 5zs~k+wg+">wPO|uR˭["  `zjh={(UTT  ~Z?@ԕ+W$x˗/2~ykUqj. ApxYϧVX!ao/C AGJO'rğŧ'yRUXAA  AA  `AAA,  AA   Zw@ 42AA        `yHw7ѕ+χ&*Sw?k-2jXe=Oc|ZZZ 5 zUV? f'0~^/6nHSN0Z`={9ם;whڴi*:>|wrJ1au.((x]LBt]L0 YNs}_[g*eo߾M)))a&#Gי˗sxb0|};)6 ~>o[eF<߿_noc)o:h+9))wo>+`:s0dFEE6ͺ|2-Y$ l> u"A ޽amEߗlG. _} QtǬ=D iC gaH-"d_NvPO*{fTh|E1Wqf̵le4#=p:QmVsu/e ߛ50#q2f RڨhƊ;)ߕxPqƜP}<(ՁkaEx>N4Q1s/R\IQ*8=iBڄYuaj=f`;{<Eyu\WZܛ6>0*V9KokJ5X"""" h4X"""", h4X"""`)RJ& ?qnX6 IENDB`libjfreechart-java-1.0.13.orig/docfiles/BarRendererSample.png0000644000175000017500000003404011173030414024002 0ustar vincentvincentPNG  IHDRXr57IDATxPTqv:vLLo&6Mz;#_ Fr@ A8`I`j jMjd Tc0A12j geg=~gώSB!$* BXB!B!`B!Eqb8"5Xo|C};Q3gTovD3gΨlܾJMMU{k$$$25ӧfB!w>vToի׾Ao#Xܖ`z"ܾ}~| "$`26dnog4˪`LX/b/Rm۶|7ͮ1ys; ~i`YyURReTGG",B"X.Tn* Vg6/_.%%%>\ 9ٕt}^WַLNܧPpկ~sΩSCs_of} JGя~d~O^]]큷쪕2chG9e9`j`UUUo'{AvyB}Q}r XRSS3|5իW^\w{9@  zp ,B"X"g2!Fr=vp/Hܧp""rYOw}whTTTPzn=OF ?EzGԭ[l6g/]Uv 577M e^Y=A_d^ٵk9.dWP %`*`YyN999>Ɉ$EUv4 6k(/ },$  .?'-[`:`Y9_&|//H{N:'lޗO4ɜcnX!e6EȘ֍70>/Ydφ Xi?/~S)A*ONBLB4h] Q]!rO?T7Lf '%_rcǎe^| ؝}UN_8X@G~_+ GY,9TD2EHkc IȋpK"b בw>Y!}ٿdWerV#ɒCyn`ﶔOJBP{NXq+/pr**Ovdžn_lݺuGb`5`,B!cXe|,;2"sqE?zn`Icru9\zddƚ Op7uknJ_.6Mqu24+or/Y֑ ,k$+%%H#,B!B"BXB!`B!,B!E!B!B"BXB!`B!,B!E!!Bzg|srr󣺲~8Uyyyŋz+-} StRē} XEQE,Ż ?N,Ż BzC((X>LSҥKw//+̝;WڵKSsX/}7}X&>>;'OX/}7}X^m޼YݻW]|Y:tH\`QEQBJOPP5sL3aewJJJ%l9l&U|Xմרk׮Zjs)Gnart+_]*p;w/+ \vs[[[~}ܑRΝ,o߾}/Ud/w^tƨ'?RoU ]uzAr]O隧k8]%Se}0Lͷb E_bXÈAvJd{uuA(XX!ӠI>M(%sX/}XkvQ555:x m`q$w+MTǓ ]ze\r^^9sXa^v X---_[[[>3G}vrڲE]INV>=OwWi^ޠO\O[7wZ`Q`Q!}!uVWukueJKqj|x%#XCukxzq˸qꊮV]'tU]u=kt:ﵵ` 9Z>M:``Q `1F(zUTTx]vző)"X=]Xu Vy=.(b `,`,5`,F(Xl#X `,X9XX5`,]P `,E1X9X `11 `X `,9X `1(#X `Q `, `Q `X `,,(sb `,1 `QX `QXXX `,,1 `QX `QX,X `1(s0#X `,XX `QX ɓ'9sT,E,XHGGVYYY@XY坒zXZ.\Z\^|%Y3**o#Wr^ޠ/_/^L\?\ZY\vXVS뫼#eKJN[vJM/ҧZ}A//ק%t^~C3A_Sjii3^;R'$&%-/U/iiL_z`5448֟1)¾>V\*M IHW8:#X`1MM늮V]'tU]u=kt#X|^YۤkH/S`1507nP))) `, `,b |hFW֭S/XX `1BݻU^I&MR3f0sPaЛo^}U^XC 9`+qEaV8bMM / `a+.nw+ku=G|ڵkX `,/X+Q͛7UyyJLL9hhVVX `,#XkY CPM"sX `,u9X,7X `,F#_q#^˗/zPX `1 `d޼y9.\0l577 sX `1Ç.9(X `,Bȉ'Tnn%(ǎ0 `,#X`, `,s"XvX `,FXX `19XPzX `1•/|X `1 `+r<,4 X `1ˆ;v,X9X+ܓ1X `,FVENX `1 `qQE,bkuc_q,X9X `, `,#X"X `Q `,`Y`utt<}''O<wXX1,SI& X@!X bVkʔ)\4!!A:*++.\0`7oX `~X`,5(L6M}>.r,uUzbVTKFdPR\\lblv.?NII~Kr:nGU[[k{ϝ ෫B݊U&LPĨF}zD/O7\//ѧ9zy>}^/O׏0K=]]n嘘mԧ&\O˹t^^OwA__Uk#ӏXvXVSnwXbwNe<~ZmMkyPbՄKT{1jB{$VM3Qlr|}[okzy>]ѧ gr>=4bjuXׯkyv˝tX 1srrb,jsz䑐Rk& zt "]{;FF1_Zv:A^ֵFӺ2uo/^<~<#X`9XBX `,b Uss_|a` X `,Vٿ9T|r0))<nܸrX!ۙUrhHO7x`։Wކ H `a2 HwGX `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,XNV}}~-S*11Qo g}X `,BM~~jllT}}}WmٲEnX `,L<`,X `+'O4Z `,X+ 9r8{%zD&t,-ݎz[˩쮯`UWW_uA&t9,vVZe{}nؠSRԭ[Tʕe*yV4CzNVr}[OGnwXbwN%95Z?N`_9,-w`5448S`13uX"DFbFt(9LX `,VrرێZ,X `!$...`,V4gǪM6,GrX `/1?X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,jkkSSLX `,XH\\X `,VX `,X `,֝ ,*󷚚JS7l8?n5~-1\VwݪO_i^ѧzTyt^.ѧUR?~w`Y@+61`9ew}UU::L6]ZjuȫCrj{q<]Sjii x}NkSKUU#Z~]s Xv[jhhp,K]+d?w`,Fb,FX `,X `,X4umZaX `<{u=X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `E2Ժu6̳:;;X `,Vٺuھ}gY"X `,b233UGGg>S `,X+$$$ eX `,B:{%z'%%[=b5{v*,,4N-Ulb(TO"}@?i=O^v\OキH\s{]>bbTb[r\*q[ܯr^O/?/˓Ss=7qb5keJ@-\WEJKt\?C,O'$}/OקOxONSIJ'4qbI}Zߟ|e˕ar^oVB^ViOf?\OL_b&晾]/13}peL_b_֗'\̙WfYR0oD/O/}^><Y{Em?Ӧ}2e^Ŧ//11 4{5y;>߇.,0ۍ<~l/iz}?#2o{s}iiO_Ol/ܻ`ۋ\wl{IM}Zeg2ujQ%,W/g,_χۋ<],5#}Wׯ2w\辸^R[/'?M_آ*=)G=oO~/z}Ӝn{i~ z˳f=&LXoOCLZwEjzzg{,^t_\.<~,X`{ӓsB}/ҟq^ߩgҗld}ҧ/]~~Sy֠X"BDիW}`͚5B!`m۶}VtB!+ 8XLQEQE!!BXB!B!`B!E!!xpDN`EU٣.]Ċ.ZH3gΰR"/r`cNlJDzA6_ޝs0p )33ӼUFFzgͷ~ы˩SѣGM_]dhzܹȡCW֭^ZuttBVtEpv՜9sTss3+$"/999]w/^l^@E󴺺z@_v"#wVGQjΝQɓ'U\\'+*bvQENUQF@"/mmm;O}VNdf… jڴiˬQJnnڻw'_e7e5sL3 ̈]v""0/^4}Hdf` Pc?2(秊QxuAV(Eހ.3f7n󭹥`EMw}F@"'+V0}HDFGGd7lCdt"v裏e˖vy'y^%$$rɱcn3 dÆ II&&ʆ@F/;vyWHo"/ޑ0z}=*tis"l.y3O֘C9\LL ~_dr|b?7Ml/d?dtrܹvV\l3<�uFϟ,o޼yO544w//X4N]] ̽JJJ2,dD12B"7wDFe' c"Bd$JYrT}}ɻ<8|oΞ=;7oŧ:#/$2_cbF`ݱ&de:vȧ50I&~ }/C# yZ'b B_}5 N,H]Vmڴ)>S"#]oKdn3^cV͛*==s=.|TnL"2n }/e2B3I&E|֭QĮ7%2B_ 1+ " 務Hrb9ؤwd? ~$D$D42}S@/B_xXc8Q<rh-└ô\6h?ʋH }/Q<333=G)|o>2PG"G^r%+zC_}X?_5 pzgϞ=i\.3l+G=}7&rt\9mܹĉf?d޼y樹zC_}X&2L[\\lg A1|;d B ":A>Ǐ{>y!|<$2\+eҡ7|]xJ_/yw ZZZ̃ZNleeefHV>!CfCqGw(r8Зh닄s">#zo9Cy2qP>aLӊ|%3cֲ2KTs"] Y$2+}|ڣg!%Bo `Ea_dPUiiϽ!%/25# J>C5{lWOnAYqBB Xc>/O(N2M=zB}/􅾐EBo֘svZs;&Ȅs9OZ6_|o[ehal޼3KN+**h獖9s@СCPc;fΓ,DxIk./--5eI>ew32&?'4=P}vMʧ !BϞ={̄skn|N>''I|캓<(2J~_vɧܹS=c\K.=PRVnw .9\>{lM",9vVR[[kfuu5+E!c?ѣf"[d|}O"#d!Bl2:JN9^I^vOAU !B!,B!E!!B"BXB!B!,B!EHlQTX!^"! #qDXHxB!0Eᅑ8"`B"񣏔zMG3oO.7ȝ 3aE"ؼ0.]ګmK.b_K{qlK.՚5kTbbW999j۶mޥKU]"؞ _E%`]:?ζr[^קN:e΋t`]Ӏ:{cWv,B!dTuQ/c[ry/ޣ&7oTg6GU3g4Ieeem X-?'O6͛xg3<:;; 3򕐐JKK/n:su?8̙c7##C;ws]3f7}]] XvϮ_nE"^~ݶP9?))I]pnH+Kj`>ζrj2ZÇʕ+w*++=x"ر-;w7zæMTGGY̛7Ο??}>] XvϮ_nE"Q/h[ry'O 5`5j`8ζrȈiԩffҥKYf7nx~V4e|otN oҤI2"䏵sԋ7v]޷Ϯ_nE"-\f[ry0{nnn6M;4`U6ζ"#g[l1px 5CT]9Xq`!zC/gٖ\>\`Y|4$`5ζ`"s$2e7?KF]&` ooT]1B v,B!Rےˇ ,$e.Lvb,/zYŕٖ\ĠYsdޕ&wEmmm9X2߱ed2giooW+VX^~YJ. `{!ơkfIFrfeenI=#j? `9R{nuʕ?f`,kimmXE׮]_|1z(o}[A766/_Redd8wq' ?e[[@XBIX_8V6̟:>#C{ /_aǩXF+d3BT.ȑ#AKw *F|pp0$Jw]`xWˢo@HO̙3} X}|M8w,,} os0ƻȲnիuw'eΜ9AG?r~`\e TPPK}}v{9=IQXXǴDӈK;8綁=/_}>۷qE }ꋜfu;rʺ!~.̤V yO>#pm`! 4[:6p! ^F(oe3]iO;~^5kv҈oܸ1;F~4V߯ߗ@d=oٍhԬy}c$K/J/;̍cgOXrYm(o޳/~ v Ѵ~Ȱ" XE-N\ի5oc k1Fe$jz˖-2PS@d@iĥ˕dKHO0} ѣufZl#`uvv?X)2F yq[^,p0wߗ78FnXB,_^_%nfHY4NcŬۑjdξ'NԈ_~=([ *+IqDzݧP yR?_/]K 淃Wƴv즵N}zڧɺ+Eu;[/DޓX XeH(-b%v|άnp 8i[ǚpGf;-F\k׮tqsfq6m>6X##2ˬ$cV+cƹD2bބڎӱ ^,+2 DY2f5%d ;)n7qdǁ׬DOޓXÇX2۬rsk7g#n{,f3tҨvɘFnXB,閲k&#%M$3HyXz˿u]u4X"T0lS5P[ rul$Cjd 9n{,zyj@4޸ Xd/aȜU"X"X [$*qK!, > M2wI߱6Ĭ:… !jA-Ͳq³1Y=rǨU2,ck=ydH~&SsBgS4z+|jدHqm7,`!_S9nDzNwYg5H"`b7ag,0bz@#dbiĥ}ɶe@ &#ۭ6/y~HHӬJyԒKyƢqnh$Cgwyz{"Mp `!O\1+yK!X'ԤΜ9C!'nI=&,. `UUUi*++݃LCCCb\EەC,+ဵtRեFGGȈ:xڶm-XŬ=G e9C=qݞv}x+~l7&`=KAz$U *))!,2XdhR2Xdb5k֨ז-[`Q!,?, ')X90[ r1xX`OR`t /.][Wx, b b&w,  , x`X`XO,) , s<, ,`'x`X`X O, ,`N0 , x'q,&, x`M`O, `Xs<, ,`'x`X`QOx`O, ` x`O, `Xs< , Xx`X`Xsy@ `]'`X YEIV__*//UQQE,9'I G 8N===j,9XV4eեKT]]qE,eʔ) I АU! B"E0' `EX7oV/^tp`e.b$,g[sBR!t,7~u헱lkz? Ou l-OޞKī> ĽeylD`qő [wD|Il X2X9 !qjll(VXf̩5/o*( А-w,9 Np9Gt7-8{ml,+eKW^,O5R/.Zn zO`̳;!.$3u`= <F0?6{e.7;p+sۿj0QSCwQ '&UR$s}v544`Xim߁CH"oޑk YjM0''F,'&L{2TQ婜32ԫ JOdʺ9Kd,=kxB=+|uhgCpxJ`ܓ~JϲJKOcRyv}Gk``@թb2Xd"pH&K BiP m O<rgt $%;( tҘOOk߾}jϞ=[2LxB0'pDde8VZF'ԓ@Q{{R522_?yڿc:|jkk ,gXs<x_t \***|^ͪ]UUUE0''k%㯤{Om6u!^m `IFeh}+Р[OO>@w nϭ dVX'ĜKUYY~9T5{#uF*u&Iz?$[D=< {{w=qWAƔ v'Sŋ;TZZYԢE/ OdBOŔ[xOz7'rsXjXxٳg?"|q"uDB\̮л>,Uxn{"iYÀj' rr XcudONE`X`XŤs , 5i<, ,kJ, , r'f 23,_N, , ԓ7,Qߛ1CC-YYyԥ$pX`X`8,,`QO, ,A0'`X`X, "pX, "p, `XE,z`X`8,<X`X X`X9E=, ,GN `QO8ŋj֭T ,,z`Š+W'xB,`X 5553gE`X'[ҐUVVl(f544>ӣe7[OVXc2+b#cβ#Uݞ[#^剛OVI2œH~mWsģ`-]TuuuQ522m`'x` `Q!`N0. 4TxB0<,`` Ov O, 's< xB0' XE0`'x`XE9 'E9O,9's< 4Rx`- ` `Q!O, "pP Xx`X`'x`X<3`utt:URRԞ={T?E'1ƨ' &MKu!USS`Q!֓><Xx`XSqq1EHZOzzzz` `yK:`Q! '>}Z_v y~t5\34ۓ JOp s{W\ēdC#nS:nOVaԓdivxeVKKF q!W ,2Xd`*G4 T` X 0k`Q!'ԓXxbUTTd[,*,< '3HP1z' `XT2XxB= 4T `X O,X1XxB=z`bG\d'`X^C` POX Xx`X`8E0+pq `X88. Od`z`X <ďX. <_` xB ,1Xs X)vX)X J$`?h,>xx%Iť'j500XWUUU,< PV X( P( %(׌YVzꩧ~3]l?,2,ruuuB!J<Xjpp0h ֪Up!BV:r䈾sАB!`EH<6BP( %+B!"B!`!B! !BB!B!zwڵkUqqT;vbFO&OrHѡQRRt] $qjooW6mҞȓAmۦ.]'ǓX|~aDrT^x!+ÇU[[[`Y&mjj“K~Q#U}}####СCO<O< ٧۷X(2ܹS;v,r"W#ø@i>lϽ;$TSN{KѣD]p!}I!+^{MKmWC"YwwwB*a~$~;: 'Da EHNJ{ׯA1 TyUhxx8Pې$W%"j|>%S' X~jI5Ϟ|x@O6oެ.^m偫?=9dv%d>'5kN+v'{oƍ?'ɞ---jǎIwdkIbpD;Z'洪rqF'ߗ2o.3ͥon?裐tNCFP###ae; ,ѪUz1! !&OmmmAcjjjS5+}Fk2N555W\E(݂ѮNrw1K677c{,,<X2d ׮]S?*++S%%%jƍȑ#"WgttT۷Oٳ' CCCIφTyyyXU/C"I`mݺU>|Xh9{~-QXnmmUMMML`ymUWW-:jjj,,X:ȅݻճ>MqZzF9sfgTꬅoj500XFUU}4C `yyͿBBi&/qX2,:uJݻ7h{zzƁw/_.]n?AYk9}uww/K-[3۶mS/_ZJ]~=v1BV0#w}7bphk>>}Z_1XX̒`gSxs9eUQQ; 9}niiQ;vy#P!;cd"B xcի!V %!ْ,/s+,]2=!`!0t~$#EHFA$.>K$^Ș0- h;}CFGH}};;; `EG2.G229I aݽxsmHwޱ=΃}6e}vbJzB! !DB! !BXFB7BBD ,B!OU=]IENDB`libjfreechart-java-1.0.13.orig/docfiles/CandleStickRendererSample.png0000644000175000017500000004356011173030414025471 0ustar vincentvincentPNG  IHDRXr5G7IDATxhg~PJ)B)\)DQ`9`U1QwHrH'CPOg!%]j#;Y+]>&TQR{;ޝ3ϾB!B JB!`!BX!BB!B'4yi^~_{Nɟ ~3<U8jHW}}}jmm-3XWwկگy^M= SNr7T8XW.q% Կ{,-}! ??m"'TnR?KX),;wGۿjccBXP*WnkkSo)IVK Գ>ЅM.~7SnXPs?3]I߿Ν;\/'KVI`Μ9kn^CnkooN2?#BBnFD!sCNX 3b˗/؋%NZX/~q,} Vڑ#GBf^󖗗+WywU5555??`ZnW*(}tΗ}z'<:w:~BBUn"#=g?oL x`l@|",jR_2#qEWR[?@uCs&.4S!n=7([ob`o[ʷE~0IXP pԫI]vPʑmR^GrSƝTi Zђ1ߺ!J >f֯ o1`XXU\;HrGr1[_r[DX82\vJ,p u~}%C&z퓾eL/nN&P frYNFүB G}(7-L8X/x!m2o{,+#YRjC.8X,2X4FX u6ԅX޽{WMMM{r^__C~٫GPBm `'OC󺻻U.SjooO]tI. u6ԅX588nܸa|mm-EFh4+H---\viiIZ~%%+Ӝ6!myLڴ(533^XX`ũ>+++1-u/aM_)USSs6ŋUOOϡZ[[}3XNmllh#E>PjC]M,,$h%~`QBm `8qB;NN9r$yc mH h4-{511.\w$g/V`WCCCjdd %u.ԆPl+萻ݵi=frljjҷ-+d^P#@6PBm,Fr*x»UtI] .bJ*`h4`X8X|.ԅPj`Xd X# u6ԅX u6ԅX,2X4F#```Ѩ u6ԅXV2X["A] upB>X|.ԅPj`X`h4F,,>AQBm gX# u6ԅdݻyU__RmmmyfY,,u.ԆPTښ:yZ^^>4ollLMNN'&&g?a%EFhT@Ѝ7<絵jii)yY,,u.ԆPT@@VCC=(cn9oۀl5݀۫A6駟G577‚ oXf f})%#uI%nGsyhy.R`Uv) )_]F`US]]],2X85jAqĉS#Gǎy WOeqp8FPj>jo]p!ZZZR/\v```e+ۀqXteBmWqW^yE֠VNb,,,Bmpg,Fr'E.Fq,   OԆ``X!E< u6dg,+V@MZ9,, V cc !©.8X8X3 VO,dP֦,2XSC]ppg, yF`X8X8X8X|68XE ,u!E}&E%' DZv} +e uɒ!E "OCg`5;; ```F`q,`XVcwashSN,2XyBb!E+U!w(`wh\XToo icҦ̌< X酅Ͽ_6jLf}66˛ʹ>R+8/q6-I_9:6)"Wuuu moo/2XdpPg2XLӰC}&35==TMMjjjRP?8XVPέԦT"d$e"E'[} zʠUA`e`!T`pp,,,,,, "EF ,```````X8XVuKȯ]r 7ݧA2Xd`H I7,ե}    b Xd}#- VR4`a`f`Tq'p$ 8XR1vXq`H`.IRf"|,Xd,,,     +%? sk_ ~ OҶ`X`U`J>X E+.U_jll =Cmnn`577`.i,2X`%`,n$%C-8>>9=V]]]F555QynbʌTbʾw8X媟?~իU8ŸZ#`````  `"E V ,   ,2X: dZRýrd`¾n{F 2`^͕HWJ"```f%, V+`U&D"E,,    ,2Xi`%"M UZ++E pppp, ,2Xd`"`X8X8X8X8X8X8X8XE ,2X,2XdX^M455칮N544r^__-`Uw@Rd8X<`ڧ۟&+F 8XU,?uww\.ޞtjoo,I8*}:kD+U/T|PVjwjttT;L[[[%C ,2Xd`0 ۪1?-(AR!E "E ,2X,7Ȉ7??Z9A`"E L몦F555ہc[9FTy/,ru`1;g Vv3X2Xd`XV+`[V3 d3`"E pppppp, ,2Xd`"`X8X8X8X8X8XE E ,2Xd,$+wr, ,r֥}5jć,,, V +#  VԮb ,2Xs+U`Xdb+`UjJ"`"E pppppp XA?輿T"i[[[Y , ,2Xd`466&''jppeqp,,,,,V[[O%E "E ,2XZݎ=~cΎW__690``X8X8X8X8X8X %n9^˚|z{{}b#c033szqqѺO?T?E酅k;OQZ,lf9Rԥ[?7򳳳;wJ_)%Lޓt1ǓhQ6utߜB5,u}ο6e_1c\oa8N[<````j&*rppp;::\Uss߅Y ,+92XdXd`EX>T-9}PwwrqFFFqm@7嵼nZ  J `KƯ}ᇪOOO.USSz8X5Vq1Vq+rjjjJ;T.H8X8X8X8X8X8X8XVH WnGO>ɇdgz-oz6 ,2Xd``SNi8Y]]Հ%Z[[?+믿~_8X8X8X8X8X8X8X;{^XA,2X6cQe9u]zO**2F!Sܕ|p~~^Yi,, X%1t8XI,)U V"lv)U}+ U%|"Uo 5        ` `e:`Y,2Xd`U/ ````````XQW ,2Xd`"`E$Fqpppppp^",۱{h3X VоJ V%c3,**؅SHrvÆ XAVy4V8V6Rͬ:X?%չs֖u?AƆ:yzd9td`f+*hT~P~Ç400fgg,,,,,,,VŒ%.f (ݿ_t:vqN ,2Xd```9sFݻwuy577g~r+QLsW7ojM."^\\//'}蜖l5oޜ̴nmfOz9?ۮߛoyfZQ[YYϽ>шj餸MRbol"Y^'?Ν;e{? %le[?I{ojLsoG!:_oe!s>*kX/eǓ(d3gy-3}ʕ_/mL6=a"*`:SdJD&~J V3XRKcD2Xdr}O':%n\?7/ZZZ jll`e5eXd`e9%`" V&K@E,u]YpY5>iJjhhHd ,2Xd`C+SO W{{{y*9RKN^SSmOaNU^?7`9km}WNvߏr9ۋQWjU{`ɭA+O?><{\˕\?"Iv[Q QVW r`{ΪkXH~yu%e&Xq,8Xqr9Xi,oe `p|=V K$"8WV˙`ʗJ`c W+΀U^&=,5x Pppppppp,KF|X4`jii!`"E ,2XamYnLڱV;;;e~΀iN| Ra9_^yo 3-yo.[[[vjd[n͛7 `1ʹ,>6lON2yfڵkַAo$N'Ž>6MR0f,B ~I]Wh;i?Qq#n `=_@t[o9_WPZb+v:uu޽SXei;XQoe*m[۷% V9 VA,2X,2XdXI`U`U6"No+zyd`Xd"`e`l+ E+%r9F \0 ###ˎo:E800```````XNhۅ2"|SS]q`"E ,2X#```````X,2Xd`"E ```````Xgl G{,4y_5E= \Z+ʺyXVb/pK`Q9aV9,k9`(%JJҀX`g`X^ `````X8X8X8X,+ VF+)JVƏJ`+C+, pppp, ,2Xd`"`X8X8X8X8X8X8X8XE+=j V5LB+K`Uz#wecu*}8=թC? XQ|`EVFN{w+k#G}U-&Ua,Fr/ 8w(V\N﫽=u% XYrȍd F`XY-¨,V2XQV VWWSÂT[[ ````````XARjss (---iW{\a V9۫)XܜɟӋeZaeon]7oY3LrQ=]h;XyfڵkկЁ[mW~←^YYȘ mʕ+< daG6տߝ;]J9__[^G1Q_Ӊ3gΨ{timm`9       +{M8}ttT]ܖX)^իW Z?G V3XcD#dttٜ/. VvoJ0 n{XmooT֏~#_OZuK`o9 ,;XC`X{99_].sroG+5??Z}PjhhHd =Vn `U{̶T8XqrwVU555IVL۷qpVt``e8Xe<X(v+΀ AL2Xr[J`%%Ui*%lϫ}T*`X8X8Xr9XI,,J:Xi,, V2XI,2Xd*J;`ppp,,,,, "E ,2Xd`X`"E E ,+e;V"Ie0jE```%< `,H2X`/Zh)eV\., Ve3Xm)``E`e ~ `č``U\ XaVRU2XdBJNnm@$ǟ,ژ&9q ~ي[;1`Ν;Xcccjrr2?=11=>̲d`e -G+83bOG XD ,+PK=|`jii#̲8X8Xe,OVbKnuttM=C,,2Xe2X^ܲXd`J`9sFݻw/?, gWۘ鹹9533?pӋmHY͛Gg jmm+0>,w-2''jiY~ׯ_]Badvoeeųח^r%`sq ӟ\DW;,gefL/GJjcʆP",~ٟ˴??9r=G?e,ۜ/Oݹsw{<%p`~"u`~!Uz+#w}  H2r:4fϿ l3X, V), V2XVk||\R "6`*G&KE * mUY8X8X#3;,2Xd`"E pppppp,, ,2X,2Xd`X`"Eh*4Xe3X6GlkH ` `e -I:UmA `ٷ XA*E q~m]d9b.nid* XڧX'ǒe`EN~o`X8Xqt킃`{w,+e NU ,rb3X,"U ``````X8X8X,2X,2Xd,2X pppppppK٩T}}Qsj~?m,,2X,2Xdo V [r9Ԕ:~ɓh``X8XA"\?"|~``@Xd"`Xd`U6fJJE+Ӆ[nݿ_:uo̤{ ,      +e2S><84jnnΪ/( V9۫AK6;,wˣ駟dr7Ӳ֭[k_oiiɷׯ\O|9y8_O3׮]˯۷oLmra?m<:^yR{}ߛ5+++i<_ژ~+W ["Ӳ?qן?fy9'ǣOs7 !r|;/⵾^lh{{{$%y,,,,,,,,2X_|Q mH "E ,2XdXgϞUqz.ݻw=3Y`ۈWCCCjdd ` BHGU$ٙB5==TMMjjjRŸ$8XV<>llWs%`EXŜ/Bv}ի,b$VT-,J:XArΎe NI,d*&a}*``d+̀-m -Xd,,,      `S+̀6%v+6%"````X8X8X8X8XE ,2Xd`,,,,,,,, "E , ,2XifJ,:X `"E+1e,2X`d,   +sU``Xd`X`EXd``N׫1g}5445<84_)>߿y܀۫w)DK.49 ey!đfzqq1͛7fzaaAdr7Ӳ֭[k߯?YC?ПL_v-͸3+++۾'.ON~kܜ0-Lrqv.﷽(.|Pz6I_f}ӪWѸҟ,ߝ;wIO/ӟ,絿ȣlL~~e^@e91qן?Y!Ƿ|yod,/mL;O)|)˹ϗ?e!01_ҽ~K8^'ks,u<ٞ෽r0?Y.;X8O K> V@4{E Vz3Xj8X1DmooFyjss@9S VE+8`" V5Z/Ξ=#]7 d[o d ,2Xd`"UFJ HIѣzh)R555If6Hd``"E ppppppp, ,2Xd`"`X8X8XVqgpp XQ8X8X8X,+,Ŝ` XXQd`X8XV8V6($:X,,, , V2XQI`U`pXS]^_V,`X:XW^-`%=ڶ}F`Xd*XŞ0Ҟ -GH/QI,ۋ >u pR XIpXYu Yul.Z8XvX8XV2Xf Y`\`%;U "````X8X8X8X8X,)FggSGySSSǞe^CC!u~䇟ZUrp?2XE,2Xd`"V\N&PuCԥKT{{/` #V)-,{v_`8Xw*``ammmyV3X\`g,2XI` `5`K%[^ZZZҮ` |I;xV;;;8XVvd|}󣣣aڲKr["XN07Fa`Xd`"E VٳjyyY;N=҅V`WCCCjdd `I$~Q588fl+Y555IVڷ>V.ZY b'b,b$V)' l:X^ppp`{lfJ,2Xd`/dmeoM ppppp`X,2X`Xd`*_ "````X8X8X8X8XE ,2Xd`%`X8X8X8X`"E ,2Xd,   +pppp, ,2Xd`"`X8X8X8X8X8X8X8XE ,U2Xd`XeSթzӣVWW}5445I'̲8X8XV[r9 HҦ1599_vbbB zfY2Xd,2Xd`"[Mmll___W---fY,,     +3 # Er}Qe`k`"E V&'M编{L> X]]]_Tiy浼4ӟ<ןܟ[^\GqOj8_F_9Q\υ`j<}t,Br(,FCmnnU577{MeB!R XgϞUqz葾w*h||\H?00v,,B!PfKo2T|sѣzhm=VN ;[lFh4_n;S B] u6)u;1.ԅPj`!B! !BB!B'_@)+ubsy5*5zw QhV) 20oCCD S4&.(?! M~BNsQ/ANJq:ym{(+Pmll'OfPS~]~{vR'?.1/]K4&._ʁ Z[[ݻwutkuuU>, V'YRNViZrA(T, wEקoY^ӵC~>K98Js8`%Lb:uûᆱhGL$fwr9AY:---i&*JKmuۇrRO~>u|'su sSj~wRFCUO%Xi{GYjnnCMM|qͼ$֙3gԽ{BD$& Vڸ"ӧO|:'%̱㗡innfq9zJk8`%H.tfj;A ֿ{j$VЗTQmfP\ku799oem smG>ܲ$R8`%H@no|b~g U춤NR@wuISmu9qg38iwZ'z9X |:^^ [b'myb`NU1랖EN.7Dm |G2_$`Nm sei" ޾}rr—O;w$`+I0qT%u*4^mVxɷ[P±U*XH $K#uz4|5:+ i1QZ(,?B!B!`!BX!BB!B!,B!`!BX!BBKAr#B>9BBa !,*3`yYKKKUl{{O{ァs2 wQNK/>|HBr?nnn>ӧ‚~! !,eJ٩%%d!,By.0DB X555\!"eBV5??/,o>C ^! !"KTWWc-æ&ueB!,B! !BB!BB!B!`!B! !BB!B!B!`!ux5Be,!,",","8^8^J;p|mn}g꥗^R N>}Z~'|2SO=`!,P|K;vy?ޞW|~X3 BXVmm+?]xQo}[ﷶC ͍71|BB(q٩~C%֫~ww<{`(o=VWW\|BXtK@GnVOOܬ \~t<3?6X! !HrJܥK.@PJ)RJ)PRJ)RJYdeAb ZVk]Dh"IDFBDV*E5Dhh|8;;z7wf3<T , = ,3gӃ>>OKc=6lܹؐ!DGGG/~࿩)-X :t@`}O}W'WX_җ8C'|_⬖9lϢX~;ViS)i%m ?$wY~_$7z>uvvf_rկ~uTpZi",{t$wݻw{˗9sY&r5ѡ~+_I'O:ҁ:Rɓ' Rx|3[VS.DF'1ݻ7M0}؎z!~}-kv?CB4Zp]_N_W 3fL6U׮]Kկg?٬z=\^?{t ;v=jϞ=6m72)%KqG?Q⩽ݏO~\}!rH/9{/aJNQ|[N!|M)mժUUm)@`Thv )o;,^k1P{/ϻ~h֭:q5¡*=x]x;+ٳ?OaJBŠ \ri:p@I¡6U`Qx?p4,QEtp[:uj9cR|=n%?zӅ}=׶mz ~+vXo|!3CL N{6UElv5vXwJ`X#`E~&+!\b*ys܋,~TzzLq7NXOm_,^@)3f =W1Gp8X^{l;,W8X}!BƅIw1"<jK V@r^?We7{ Q%n`pp ;C`xEM}^I;$,aAU"/… e x̙3}>٠bVC8}rT6U+Xe#\L'{BgJuJŧ1S@)2LqXUGy+v9+XԳ#|]N)So\,Z(?ci 0PFx@QF QlQ5y[n`}TpN[Nywoر߫V`et pR&%5Jd?1jF,CL"qL4q ­}Gq8Xƍh "%%y#w ܍'p8XRF8QJ`X,Mpkpb ?%y#p"%E`Y[wp"d7‰R2X2X,#+>w܈~.&jZj؎v2\`ʭZ;3V|sZK.\ DF '2X5+V'NXK.^p"[#… %CDF)j->}JF,m',:N8XE ^p"%o,'x + %%CDK),N/8`qkp"dHp`i'8 2`i+8`qjB``ɐ/8RJ2 ^p/ \ ^``sXpddHp`)%E`/8 SKKDK[ ‰ 'x [%CDK)E`q9X N8X! Ndp"E`/8`qkpKK/8R`sp58`X2$8 Ndp"E`s%ũ %%CRJk{%K8XF,m',}iƌCKDK[ j`ݺuѣ2XF,m''jaʔ)7n\6=ƍ%U^X|ybswnGQϟD.cg?ڋm=G3fL:~xJK7oNK.`YdľvB`"رcedHdpR3Xĉ}/u-O]㶇~2 p۷oOׯ]8q"KRu/jqFD__B15bݻ,N8X,k`)``wp"E`q`q;x!ddRJ2R,}',KK6/2X2X^,'N8X,^,,,,,d,^8X,N8X l^p"%e `YᄃE`wp"RJ`Yᅃ`wB```DK˾,KᅃE``)%%%22 e KKK6@``wp"E`q`w;x!dR2X2XJX,N8X,N8X l^dd;8"8XFVx eKc %% R2X!8X,#+p,N8X *dd"%e ֨XYMaÆt ', vZ&VZURXUz*;p6JE ՞7,۶j_nKA9)8ٶs."Jcǎ`A+qk8X'xie:;;#<"e/u&dF^D`ǏgU^x!+,#p8X,VسgOjmmMcƌI>hڸqk*U:X'(US2 R8`9p<```9Diڵiܸq= 7o^joo`A`qSp,{C/aW!z?Y #hoȥVϝ;7lR|FK6i]hI3Oɟ>qv^oD3XjUٳ|E{c ]FKE'zId ٙ>}z:|kj5zk,Y#DVO;`͛7 XFx7‰v"UEB(+VcǎuY`q85x1 K;` aU#<֯_,zX2XFx#  G}ݛz,4:s̴cǎ3`(',턃UBLkiܹBe\PKKK'2Xډ V8yd6mkr8Xx1 K;`nݺc,,Y#ȑDK` {n:x`v {db0Vi`q8Xx1 K;`|AY\TKKKK',DuB=zj`q8X,'vҰݻK 7dd^Hp"uk$`qk8Xp9 ^Hp"`X,N ^8Xp8X ^HpB`i'2X,!pp%%k9``X,M[v5‹ Nd,ũQ8Np`X2X2XF2XF8"8X,K'v"dd"G,D;!8XN58`q,,,,,y#`i'2XUG{{{Zpa;vljiiIK.M/^`q8X,n N,턃U)SWWWV;wLӦM5‹ N,Dhnn`q8X,n N,턃U ܻw/ڵ+27 `' u͒*B,_<#9W{;́?QUGs΍"JVGOFu,`,(URu3 ejddkp2:2Xډ2*ŋSGGGvG}eB4`{dtdmeT dK5ę&LH֭K,eK;` !d ('8`i+ Nd ‹Q8N8X 5‹R2XJX,#+',mR8Nd,/F8`i',KKxQJKX,e8X K5‹ Nd,ũ N?8`i+ H/J`),Q8N8X 5‹ Np"X,#+',m%%%kd (',h+ l Nd`qqN8X ^R2XS',m! `U;wLiرiܸqiի,eK;`UtՕݻlْΝ+%%k,%UM477s8X,8N,턃U-8q"sJ |l6':~v|\` U}{3p?eG1)ϨXGIgϖ`Y'8Q\=V5qL,ݸq:X2XJ)dB#n,'Npc(pmDX{̙(:ξ_,5HL2%$wK/eM6-[ '7 6dܹsӄ /l!JҥK8C\'K,I>R Xq޽{hD,~ܜ&NHdܾ};=YCϱjժo6,''NmŊxӞ={҂ ^dWϟOoVMuÍp|wڕ3GMGiXN U`lA#F?}OSj"$c?~x0SڴiSfСC8)@\)Nn˄ygy&iʕ+iرc݃ YfKӧ7l;y'YSŋ'x"͘18vR(1%6w܆{b߉#fMYf P.EֻМlٲ"yǁb$kΜ9 o\>Ԕ9NBP]p!M<9&k}qFDd?gSaZ;vFG<'jK>\3Y>P("9F捎l,O:?aV1"}'Dg8YhԶ)D'MԐ\|9˺F(FY21^fAL6r1Ӄ1u;d!\q|Ì'Ȏ!£ N`r,Z(Bl*l7@)1'! ݋r?1 C,Өo)ta-[V3k S#.9'@`8 Wk*$ݫV>gD2Cfp'8 NA" ,Xu…,q/8'8qʼnʾǧݻw?Gɂs/bb-F?^pq'XeBek(X_/9XN'8Xe"V/3!E}qR#Fy Np85H+K//Q ' NpYD_j#'8 NXT'8 NpB`ޮu'8 ^p   , , ,   ,aS[[[jiiIcǎMǏO/Nw.9 zLmڴ)ݽ{7uuuZ0X@`|={dguߢE5577gʕ+ӵkzq4k֬qƍK=\}v'NH ,lƌi̘1='%N>͛=WOm۶\jv5 3gN&LJׯqu…jooB0ۖ-[=nΝڵk;::Svx:~xO< ;n qVڹ0̄VT.nݺ1XUGJB'.\vv8Yh+J+w9p ̙3=ӪU} 8p ^f/YnPK'ftł)RӇI{}ځZdIӚXUٳ{C*Gmٲ%={6ݻw,O5ןx /:رG&֭˖jKR-V0w+WaL )RSgG~z_<0ȅG;wdze=ҡCz {wo;vXv[ܗSNe+o߾+Vdp UKK=&B {y*β3B Iy}Æ DM)S D*;Vsڵ+M6-{J]t){}RQwVsss͛7UVwiʕƍ"iɽsяƤ̵T"j3j , `T yWSGGG8M6uo>|8Y}wz3a„l(^'FJ`g8q"sx)j3k׮=X@]pc|3!0.]{SgggF碊Oc{[oنJ`g>rH={vJV~|*87oX@}B ;1NJ/N'NL1UyƍiٲeSmX=߽{7s"xO`X'^=+ Dv&w"W\Gp.4} jK`U8,DE&\@oߞedtBa6Tc"-BX;6kUo9|GY+?0ݻpqrA5 ;#oϟ?{:OgǛoٯ*5T-go^? <6B֭",Q-o t@}о, @`o )U@MgKIENDB`libjfreechart-java-1.0.13.orig/docfiles/ClusteredXYBarRendererSample.png0000644000175000017500000001331711173030414026142 0ustar vincentvincentPNG  IHDR,RUIDATx{pTeƻʲ,peY㬳eҵX/lX2"H aA `@]z(d"L $@b %RL.:qtHo=St}slQ `@p͋a=7lp:^}J<, D.\SSS/['%%k}MV?Ɨ_~jioow/:$"wWܲe{Yii2=o`!X oxuI&ce^=qL@'SNݦm?>c*a* "2URRRaaPVx)ܓcXzк2ypٲedXaeee}reȑu kpXԃb;a[BzpXdX aHEEEC=dX8,V9f=ԙ@̾K7cp 1(=ؿZWC^[7cDz:f2 aa}<(Qn]Pu7ElBl"M_! v>HG?ۿ ${ `aE`aa!X8, E2'Ê84yewLa,2,2,2, aȰȰ-XdXdX aaaaa!X8, `aaaa| ր2~֚X+MH-%>\_,w%\oKOJa_7K|325aa`_y%$=T$""aE`pX8,2,2,2,2,VD *?]\n "ÊL5a 鬑Ld^gR?I'a_pX8P  ׂEE*"apX8h$''ǽӛȰȰȰ X )^LIdXذaщ"wtZWpX8,VdSNw^ƎKEE!E!C\v9P艬,u} ]]\=#Co'|a]ZƛLU<.4 in1J5"7KssfmZ{TI;%.XS%bϝ'qMb9XGlRI[*K.:i&9uznYxR=.v}k-pi?ks\UɴwG k<~.{owR=Ğ\!q kbϛ%qO"Y$μ}gU}T|߫C^kzpznsq=+νo7ve{4ϱc~<e w8%#Žon3νo7IܳƾY۔7ځ#˛ogW~_ؼYo9sFxT_/G]rd[|rҴkL{ivi7eG~j,+?4_&Ʌ dѢVv[{JܬƾqUƽo8ۓ(f}F6īb'Ο?Ps}aA*6Nj̚{6iJyV}L=QO ӥ+JKK Y~E=QO  +W -[‘pX +jGHÊP GB=8, aap$ԃaaPapXdXaap$8,EE=dXdX8, pXdX aQ EEC=ѣ);ۺIӲe/)w ڇ 3n8p [ ?1,rEY~L6-*k\Ry„ Q[ ^z)T ^~릦JRR1Bv^ߢ'NM2EN>oJ-P:Du? V v-V=p9ҽ|ڵ`g i=G\J,Ԣ:Ezأ-ѿTYj MLL\Oi\Bj_-NuaKKK3{lꫯz|EQqQk-^e[k2 F~~u3BFZ\hooB3gFm=h?*,zq$cƌ`םH] {H\" oFC=Z. *t(~[b rU\bΜ9rqk{.\`eX+Z\:$`ž`=hN;wu3QFx ps<<^ks@"XV HovQ;LWxL-Zd8}΋:z Qfvj'VmD'X3l :G'ԍ{%K;NVY\FoQ^4'VEWs@"XV "ov:dz_lv7o={Zus|\tfݽfԨQ駟=+-z'Vs@"XV V7@(q:gIՉ?fiŷo<ʟR9 , V7k>u ]e>]ubqo& `UOFC`!X/Xm z̕(5qۧ鴮`)tg{=^sHM哑^ks@"XV VsovBiiFknCyv"Ԛ3fXR:,^LtBLBȼdط[ pP-A ط[ \A  X~G;IENDB`libjfreechart-java-1.0.13.orig/docfiles/DeviationRendererSample.png0000644000175000017500000006136611173030414025233 0ustar vincentvincentPNG  IHDRXr5bIDATx}_SUUUUJ*@ (m#8ņ೉!'NbH8}('1\ q&qwq?aw>l0z2;;3;;xI/sEAA&  `AA@  XAA ?Y$A <.X-X@m޼Y]r/$ N_wwP=vS??9N-H555"YH,~O!''|Q}?o<'Xo``%gr?566*zݾ}[=sy&''A@ oxH۫x~o׿uf_9g?纭YF.w tR W_,x>unذ!Osmkۿxꩧ__ϗcqSz nο^(?3'!2ߪ]ve1yN^#Au"/rr>/3~ӟꋕT. v5F fs=9ϙ'u+TzyC!X7n|<=r1?f}zGs;wn{lbož]aDq=9=gyF?s/B:J'"Org줢tuu址Ny۶m'fgxrϗeq,%'Qv%NBQz7x73/~ɟ}wttdt~#o=X(>3 ^BcE@"y!@˗/+QHZR0A;v1Z=9ۿ\R}xyww~ɓWn~. [ZZrW~gs{뭷 n0k߾}9(>3o"9(=t$^ϙbu"ŗ!!]?znk ((⧑ D(#(vnc}v500tܶ kZo"L{s,E%,};wtEº,Bq1[b`Y˖^sQR6缯qwٞaWY)ؾna,E%`1: y=cݺu>qF*X|w2{\FYt"zEq=IPA }{>Kcc;ÇgCϖ~Nv\H=[F;Z[˲N, { +/f}]2jȑ#;*g6 zCAA  `AA@  XAA  EA"  XAA,  AA" `AA@3o,K_R<@8p!X~ O<9t4U,1X?(5B18P`$PTu˅~˘'G$, 8QN%N"*R)M8hCp`p/y| 3- 3iSN63NW=n==^sYpy(qU ,sǃpC?y 8d!):WI)J9Jnթ_jՐ,}^Q1ظ1g>]\}:H8H ,K=""'QzL䎸\@!tNJSPf#=9N> Z5r(/:eVЌm=]kUL!j<  %W~1.*L(XʂVND)׺_ ^ȳ矏*Om_fڦn$YߓSaWBB8I K)?C,~a׋b\t@ $ ̞Fy楗|p#Ŗ 0(:mJ\EZ=8{Ohs` IXy\ ޥőipȉ̈Ad^F{\p24tQ.N=>EK)/>a,_1?FbPx[sO{y㦒3eYKi}Xb'Ѳƚ5kXvyttT-[,|E~zuM,p-7B~aȄwDD.'[VCE"ot-*&..|lU J0G^ KQ!&~i "?fx9Χ{Ab(syo!_y8zuW[ !r4t.1ŨV c ɹvJ]Є( =|߀ɪ8G#]Zٓt>cU/cV)XVߖ V6VJ.JNea^ t->;sK L;mac)̅tMF(WFǁ Ŏ^ C&UjV.;dk}\FzY:,n:HV!ZwRwiVBj@/”SϧjYG& ~ IΧ}>IjWs\nRJbJx X#C!Xx:SZU-qMzt&[[\IB..Ӻ[Q՚sr>$RqRZ y^,HtPSh{u1?Yxh۾h->pZ_\!eޥr(WhW&SF9ZU%BG5&iMj*   Vp T,X3޼4 =WoM( w=Bmd+Gy(X(X,yu}fOoKȨÛ_j܁<󌺺gn]^hיH,NA\Ys }<&ZDQg[)7 %pBB_UdIٮrw3vʁ_̝moY3=._wRS\Ip\~W:Ψ'.Ύ_PPIGGןrY`ڵKQVm.2v>Zu6{M+=䵅zce:pwy4G<V^`&9To0TRSʌ%ʀxPV]]`-Y$,Rmy&KKg%LՑݖC=?$=NOϸ $UCK|cxep `۷O"T`͎~W2qyӛ6<4Hl/!bfY4S՚F <^$`ߦڮ{Y(Xő0tJf~ıAg#ڤwŖ]ʮS:8Bib,:3,`ɈS>&qt(Auq4PtJ1W%I;?3ϡ gZ=&ly@y.]yxQ*Cz] WeOVK*.wھ$YBUQnF]tf:k%ç|(LWۺ=~X \Q~ƒUf(ɤsbhQ³xBsO NLeU-y|ߛI[JGyLrt~لLH}Or)6.n(gvHsQz bgD!JT'Q+й> b9F&' )O,cI|G_'sLcl)]&<.EH # y1'/3́@B0G /'PK?^" VKv1dNGx!yyS&]|: B\ $W,\-E"%I1FKm㠊t%/F!uBCd*<ݔ!rF#,ru<=kȀr]E  =XSňwIq @9!#ZH3mdu2r*eĠ+'K/0M~$'`Yrq&m=bU+b" iUD,8*cNl?8DedhUԲ7\!(?LK !2%=3bI kV{g͛5"+IʎA^/j ]Uy#oޛ-):,BJzb%e4$➰sE¸Yɉ[9 EM6COƒU m9#Qty=軈SԬDrՑw'u>uBzdK+~f6x R b!Z]AQʔ,G=(!.a;Y(G%+9wtٺɍyB`JVLGMMXC岺:)yo͏5Cc.r=Gձ1gwߝԇ7z x4=>\^77;UbTQR8sr>tƒVSZ2hܹ<=t(tre7uk)gXM~>2vP7襤iMOP%ׂͲz7֭Ww޹Py6ns/_zU2ujP*1 Q BB;D|Q0zP{8KT>)ߖ? Pw,(A.7L섓ͨIW)o_ׇ,W!/Sk~⊽z"5齳LmQ}䷮yxN Ũq~S&2#eD!2॒^-2 $連``UK)f_JRaN [\I+򫯪oׯ1ɔ/Y E +g4O\ΙONLɔwVvOn>땢T3JC!r喲-]1яʕSy~w3|o_+U;˄{4h;כmIT>ưq)~ ͸'Y[;XЕcTVdj#9:u* Y(Xx\ |F÷SI)=w&ZV24j~ViYzKɮM'Y7})uG=eu)p#Ddα{e옞zjR55]V۶GZqK"Y%GB}g]Ӝ׈+ڑ*!JȖVdU-#,V Tx# Bk75g=Sv$W/~,BZMZ.nu1H[mvĄ. Z2LgA'!g6I*Q}NCZU9) URSF i3G̩j᷵ L0UT8*04[y`侀g/GҌe~JKAMDkCJny ɓ+˃*Hw˄ɦukg7ԥL}/|f<7>"g=.]yJnOmneoOG>?*\/{Sw_+_I~ Ν;~kx`x]kC_(+~{3ݧ>RO>ɺ֭QEZ߰cWbٺ?W槦ysXuwWq F祄x:$%˹U˗uDXpW ,όj9tݜqNXnl?{<ߒ; ϘY”DYU_H[Ϟҷʾ^(Yw;*T$ؗ.CyXW(\GU2Ҵ=j΃b MΝ~۷oNxjɒ%Cwww]Uw{j?p go:~l:Qz˾ոU]jNjz['Ɠ/zv0ɒ-KIQJg|vc}]G\4MW ӏ$WvC!^O!5vq&ID&J`_Wl̀ ky],7?)!g/3əT5n$uzĵ)%pD9_2GC;y$ v9(FҤFC%Xӣ# >`}?ն{;řT*2U׿{ԓKzU]1]:6-,S.׾ۭ./}ju}*MIJ֫3$KUb32m9M(iZ 4,d^srebN3*1؊d%YnӰXGykiŇdL^$kWzӵ᧨JW_CE-8=!{~JOF^}s~6݂S?mƇl^P/~WZrwk֨-ϩKK]U?Z|zqş6C~9l%[@R$+H7Hucz)ix͖@#sF6)8iZ b/u!YNӰ|+7  k{<)Ԝ&r9AF-]u8BmPL-i#=˜$WZQRܽ{nZ,\{v̞|EUhÏE6ϊea碑?uJ)ő(YDz^+b 5<*؟<p%WBnZTAKjra?OK Bk3_zZ ϫ؉u$I 5_W%Baq l0yWu¡C;R->};saIJ d'Vyfz"=^ޖ w ^2ˊ95stcQ/o%??5ta?fe3sl1ho%6 K!*1L.m%Y{;冁 e~&e\wiꢚ` |aie[oceg_MusBg#G.k7F*!.*x~Z@$k0ݟg>a>U O+ưY. ӏÝmaf?߂4 F8TLfA8E1s~I_T<_H>%sԥ;z9L>3r҉dvEL>kGo:Q aY5l:J2>zVFZi܌KF%W5[Qy1$KDL^ IZKwW}NuJXs)M#wRͭ%w WvU>]^dtF]\}}v"Zl\1`U.eثKxHyT>Y?#q؏rt7r^dLŦ(ѳ>N3H;+pTslZWʙRf >%ȇe%Y|&I2G ͌3?!8*Ťh_c/NbVѳNeJ>E`ЃUL&K6ɒ h>WY%^SV:rvf#y#;3am!Y: /81^É +:I1dmݮL Tpŝ8HR?Ym:EǕ93l7ٿa`AbfJ ZC/TsR͇ՂHbTbɱN$0ICPb%)&aN}\9eJ+ VƏu B:U;y}nԣ#G537(ɲA_ } 9*QZ1HiRYrWn8KQ`Abra(xgIGbNŔRʑi dm$KNﲚ^:%,Aa'sWƜx XPVZf֐;N0D02̱!8*GfG~OK;8{鴘d],o:ډ kzłeDqUN0R2>Rwayd2gcoFu_ąl^Z_ȥT17.ղ?-AFCn"_Qm}Q9@HU)"B` s)zPF\N^6Q.YV_uMIQ{ja@F?:5$-DCFL-J/T5@Xb VUv81k԰<(#*EhVTQiɄ}PBiNB8/5^>0zR۶mS .T-R;v>7::| ,cK.J?b滑\9R`;%}ASB&)9y-&ꌝd4J2 vrU ;? EJʱ gPm$ k;wNqoWw˫VRT:o)us.U O&4) TrK)]8Blzo@XiVR]2GVB6т'ARʋų;ǃzje `XYc޼yZʔ:*D) N?*gٸ?1A}{Y8(4_!! 5 ܹsH+h5СCիӳփK$zj}Wۊ6%-:LDL!Sv B!jo}]VO>a`25[x&6mڤKV{{{` Zn&UUJ~ׯ_w$VfK"+WqyppuԨ.gTD6XY7?>CyF+`^_a cWW+ȶɓzx5 /G?ʹ7p׫$G%}oʅcz)M<}l^?!!UbtW˗/k_~{U)܈j%jxJ:Ñi0d{x%4j-;LWfݒ6L9/i/ɏ٧ΘZ*G)m ,rZ_Ju/eGc9$+H-+GHIݾOȀwI3-w#.hdsqdmfNbՈnJ0ʇxM&/mo!%;1uʕY5s=`#=e2wڥ}Uxx: + IM*Ny&s!C L9ԙu}2k:SJ(S<{՗bJV]yKtp#xf pNPHx 8^B!dI_82e_6C>!FG5fùTCⷪwnL?TQގ4[E,`Zps?IiZ,ûa^ĽFVߪí#ʛ㲘e!ٞ }28ră\58&@GఓB**peq)mCX*CHӔOa@b.BlEOA^ :|)koULB8d9MHno*X2 8Vyɕ F;pT7P-~J!R['] 4Ik9jl%kHJUY'|(.n6| *P`]GAs}9Un+y=',p! BFDՒQ{\!ȔI)J^oYJ(q> 8bҬ&'5-u ʈK,pÛdI[iN d`"*!VCOZ"vwy`d/[av'8Ը{Y>Э̷mx<~_2QJ2QʐA>  8bC|Z~k֍L3٩OWnZ鏺\{~%dzSeu16c 8f nOo|(K%(Xx.#$EMhrSTEH(T&uߟt,/8  ͮ1r5ܒwK(&Gq~y~6,qbKPLPcܹjzz:˖-$KʇREJ,p8IxBM6&ޞ%XB:::NL;b2_X,8r)vt/.垞X۲?s竚#XH R%JU}}Z|y`YCI`$Yؓ5$`ѦAU544W\r{`CRxe%e? 6W6R:lݹs G D@;s$꼅xYHQLq$(  aHʀx X(X(&G8Uو@ƒEd{dŧ}IxPPH$P,,paH$U2g䩊 xPPQv(& ,$kgVOHa]F1M̔eyȑ6g|a̝HxPPƑJ.\9G-,p`+p#SEa(~D"]܉#x~u#XB̴EV4`\GW!%S3^eYpykmQsKT*!BB^__/_%TN 8ӏw x4Z[[UCCsxp\ŽF]*>j*5:: ƒE$Y jdiăU r*xP8pDfUBƒE$I5{  8q1ڕɳOO` p)BՈǻ؝ wR8pIVgHͺ) ,$I$ʖɓ[?5kye+عsONN۷ݻw{k֭[`8SdrVjŊ5k֨sjٲe(X8p̧q̝;W1|w9"I$ɸe2Bj*M$ۧGZG…$I$k'' V!A 6a`q'pe8fW\xp(d%y`1!wR8pBdSRP$I$8&  8p@`8pq@Pp I$IxP8p  8p@P8p I$Ix X(X8p:8pxP8p I$I$~zMH$I$R8  " `AA@6ēE$I$'!X8p 8p`AA̮`AA@  XAAZiРlْv911+ 2kEbzʁ竅 u/}Kǂ ԦMŋc}jΜ9;d2bxxXmܸQSqO<=tRpLMMm۶\;v*up:w^Ԕ]nllT[nOVqĵaѡ߳gZvmqH q\bEl39{oʕ+S5uӸcժU߸T\2v8vܩ:;;jjݱQup:fcޡ,[,v8Zq͛7 QDUyfα^+NB.t][!ʏ(9`pUYGxő`Yg%øᐓm]];CY.|/V/}v\dI)Gk_Z߆r,UJs!uUuaOܹs󈢐Ǹrݫ\`9zG\qR)z+8LZ." ǣ>}?N!wB6o; r!.޾8ƿy)!U֭ӤJ_;r IL)9۳+N8\  Vb׮]9wq?w 9͐!;t!X )=8E. IRzp9Vȡ9^-_<* V~0f)DB%KĞ` Ny13W7nPgcA V߈=}!u\c[9=xkka7A{Հk}fNK~neClh/3u`"zluD+x?ݾuCrb1%ʏIo\ʄbqё-#N8\}bzJ%vg>rqq>X.H0yR/eQClI98s Ib8(zA,   AA  EA"  XAA,  AA" `AA@ oZq HA@ |'s?y\&_x6A, ! jiiˇ8A sZnZ`/~>Cl XAZlV.]&&&(A@ J !T, XA!Y"?6S"$EQb|o[JD)H{i??ԡCB!Xa[&d,/BED ͓F*cիWՂ `U˶ңݫ E,!DM" )!QK$ĠبGIHȉTxGHb?6xWmZAEDjsxD^K֋ =.y }e-Z$(""B!CE֭zTLLlrԊFEgϥMR\\8û)6 i9#R矅 "3f b'H'N%dr%ܪJ uJzL 0rσ^Buԡre@ee ݻP@`gus?RN!AƐAr˗/A ˌ-J*TF jѢ[) 1aD,СCGQ$fiPwm5VA szT)ďE^F!6Vy1*H]vjժ# 5j$T +W 53#/s)Ck+u,7{(>>nݺCm>}ݧfZl9͜!ďgʌ2 rrG`5 ߒĎvرM06$ΰX/ZH~-6@̐gϞ-T ϧaÆ ỉBiHںuB aVDJ9@޹sL ߚ5kt퇍UkjU6`Ryxz``sr&qnN.[B|MKܐƏ/jb>w2ez"ii\=tVKu(Fv ^ZB/]4u]Gggx9 PիMv8` .ohˀ p~구"b TXX^ޜ_1bcڗ3^Ie@0&H[ JAzai˖mbD[z+4tE?˗6.PhM?1N0^0nx03<2%:SKŵeܫWoڼyݾ}عs*La tY>ø01~0X$pZ4Z0@-nX[P~ͱ:(ХKW e˖MEVyWoкu(8"qҩRq E;Wjag0СuX"eܹsJXfϘ1S wij;w^D<t5Έq'.vL #K*)&fظJݐ6lDoym;ĸК,b`H՛VՂwLL '"^a7 O+A!&ĉԩtŋWjoij4yr.%6e8iɼG^g>L [o`߫a6uW$_|RSӘО}YC^lFe‘K9 zs@XToLL6,W7$ XK8uh7ZM!5^EZ|xL _xe?P{[3 ^_ơA$и#6F &4d%oHG;wZB@bo{0-l\f^Ғ96AIo&֢cǎ"ԙSƍ1ZijV_u$s ر9-Cl=NWܠ^xΝKsw{3̑VRZjqIܯHAu@QK׬Y[OR9#oĝ}"Ri%s +),B9KM8yB; 6 mL?cʘ)Okq,Л'*lLb\2nܸCo8ç {JʊmϪUu^0'tԪX"#}dPi ,E3).$d&8w=̳te&RBulWץKhj-l~J w{08(OQՉVuzY,.W/҄ IP1eDRJ"{[B$XȺ d\R9XfՉ5t* a* 5VީSgd^ &XZ"ʠ:]3Yq oի7)"b*c>hthHÜIk,O ]o`R+dȑt}@nދ)SQɒ{ǎSǎu+R /7n܄vea|VƂ u Ft؁n|(~_O\S/KW{CÆ u T,Lwүo% @ֳgo቉bZB?, %j̙>T8}Ӆ成չңە3/I_Ye|o)]@:_"+&0^WSWЕR R9tGrDGfaw#.a 8UI˓޽)RpݼyilݺS phMԕvJH'SD#鵌yp7LGn^"̂"#hQa'0=TN=&ǀq3 42LXA5Vo%1Ə+cbw5dm۪꓁+īg(4 P'Q_z`02CѢ1hZ[kiP` WP_ C>B%jx[ʼrs1#"#ҍ\ӧuDӦE|ЯNgϦRr''|Rꔐa=*3g:|2;veJ&Gʕ+Xk$ ٯ9IU-ZLg}5\axh'Rԉ7o^A\Lʕ[ huI)ISS 벷|Vi{_{جwoŝ PP#G <=Cf$n|ADXH&rC}⯓w?(/x$]tmXT 벷|VKnА!t+)DZI u*7o!]vp)SF璺*@?M?#=cK*<>+Kn^wTra`N0Aj߲ #Aw`ҤIUz 'L3gRy3))oÑ#. X}+<>yV-ݩ  |33 7mۭ ZYȳeEt^>|'c)\]c^gE"ϖ\Sjջ $|9SJD-xÆ`6ΉU/I2+#?s;V_IIiDsb`hZPZc1ڶ-V=NK!U;xj/{bRS)Dޭ[w&qo1a<# ;Ç;b˯u[¤^x+93|襗^򹱂yVk7hKPI;rkD.1Iܓ7:8q.!wԥ l9hyꏎXe>UZ]?״O2!x"<<\1s6'$jHфN@xt̰a,YJ9hhg&:X ]p/JWPɡ7n!x||!MOݜ^A&tXlNVK[kKd{3|PT^KrÙVZ 2g-ۙeRV-۷%JϏ [xIJNE|oXyo!..5 ;X9v4(!ä׹pU9;b1ӭ+>Eڴj'6)*V(΍;.]ҥuއn NV;Xj#.\Ir` w}ΟaX&aizk6>E!Gia)[^tMo&RR|| g&r~]L O o秤KFϞ}Ԙ*R awc  %$'_`8`T8%?߁׼yK5;qkjge76mU-QrnԬa~uE*\T(؟c(=x]< Dxl>ɟ??}ŗt٫md soxU$kg,.]Fg>`5;i< D.=W_ ~_~+NEW2[>}ُ#x l.*00PDDD=xiCtmCHINM4!T"$^9MG$z}}D쿁x-Ss& +T&6Ec6mOpe*UPKuz$K/P6k5$Mf^AXHsBxcjClZlz\p`NL1aML8|Æ>[JE-=dzy1 çxR0>-[b7*RkeE^|EAO>$M:ۧĉ$駊:|qӦ"𒌨 'KzGH9g'KsD]>1肕Bx36?\>Eo'qPO?EKBQu4hs2d8卧rszć0aM#ZԳiJM8j{_+ 3-%]c)sx!O/;ѣJҞ~^۷< ҹexlZ qZyNF۠AyduO4IȬ܍;m !q[‹Һ-/Gl BI@ 0-w(ޏiȐjnN^y"IxX8@\sLd~NжEʶEzč GEBA08l\С~=/RѦtkժjGlf޲Zj܂KSOH(?m~eoI˼ԇqje$} ?{|>^9s"EVP^c:pDM8xϿtp˗s~Il $^xʴktMV:]}r/f3'.oAZ_Ck1g$3KxoMNvsܸ Ex+IBN1l%\[%UkR;IG BVB*TԳg/A@ ϲ>8Z}rɡ[H|0nܹs8b}A{&i\HNJ&q[u[7 Eror,['K/D} cs49ϙGrQ,F>dQ N))7m1ErYtŕ1SNђrղ.e\wJ+zsO|9s Aޒ017/1&f+:hsaB5 h& <#I|!(;`ZX9ksC5jT_A^\:RΝLK3x^{ujܸJ0 1{G5kq׫ׄ{qQR\6(x+-X@xҤv 9r|2C ~*yt J2?eZ$/ʪr[=:xnU)T@ζ\p pDJ0DtQÝPo +._GϨس%x~L(.%~}=RNJK74) …D-_7-s"gJ䙮xm遲G徆)+(\jc~%r(ޙ>S>|VYꔣr|*UOȰ{˻ <*ݬ^i"!eL%O5/ hOk/D;:fW;v{˖m)W\b>!v.LH΋3p JGB#e:ӑ#=,;NĆw:tv킅0j$Mr3$pj"B DnOҩSt*%rx WuuF$pħVu7tupYA%A=z:2H?S'/Ќ갷qD*(OR[Q+?Fw{/>+T&RƗ0A̓,P̭P`>}_{O $^`9dڷ/:LP 2$4@LHHmۊ8FxF$͔NzWm,e9HZU<왕`I|SD!681G O*5_4Z8)U.zFYxf$>I:GWڧ'r l9bHP⫯JGD麲 ю 0ip(3%ĥm86TD iDIt+6D 4H ?0㧟#(12')+O2nfРA{a^KνuaOo)#zGqCQ>_wyy[x}8CJxa7oyLZU T(q:r7Ў}ŸܩW:"?HvӾ;]TzO]1QdtR /ѕVMF ,믿I]'pҷ%|(&fy/B|ej %.Z>L_~rpG9.'Ͼ3"p-ÑFGX9Iw-exG Q'>\%YpT ,{ !82r: A,bw>TQ,p5j\ÝzL$ ZDm(`xJT˖I#pl\?t:p/B f<㊉XnqQME ԬYS8tLF-TNr=0"O6a"7'uCq:?y׼-e7Wl!"V2F<pݻE %1\MO P)֩c:^$tvU2O߀!p&0M)ˆIZ&b"w=($B}HP/B!v+OVe%=DwYu*coldK>Ν'x2"t֭Gx0x ZyLnׯ:wj& aF_Ӈ~b$prXp*+<2RM&~AzFc6H)Wwχ͠=Dbkcz2#$@WΝ 6m?hhV@&bWM@]C?MLL!=t5oW\ HZ[;ulz_W_r@ٲE^d(gBJW^+}Mye~_2Ggo?ZN7}:$Eޘ 2R'31Id8nժ$ÀW2GҌp!J1ĺ]E%?v *j@i>آ̼oLI&GƏ7-4hF`RA/N_9[~~tTPN8T,yvv&8R]X0s+6m!t̘1_M$ZZW{oߡ $oHtoL]בC6)R~}wߣ:u\#0I (r2dN/.]iKW{k_zN ICb%r&r)uA c.eT  A{J%ia xq~UT5a -ʕ+>`.waI"O\%66Q-S' `y1п_XX|VI|?tY|&O,>w 8gD]%lEG17n о}{IЮ]^`!,,L ?s$.CBʡ3 A. {n~_ STBdg[qsX"+ V$r'&MZ+F:u͔BNf@?8MGI OƻL& FaR|usٔ m47%J8WHd8牜IzͯLF8d!E2T}Գu ܚejq~+y"V]}L1<^ժ1.p<}LIg^NKd֡8'Xr_gKJ'ߗ*L}sZb25|whN튷o?g^&si$\#AAwG3MhenMJDI"vܴ0Qu.?쳙8,G 6{+7F\#Kfpߍ7qehQi96nٞ˔gA :u[m1#TRu:z4o4%Mo?{Rh| q\L 3$={!Q!*Tc.rϹ3 b&ҰRI\FfT̳bkpZ{G'Â̜>GS,6)SRP/̤DmF?kۗ@_fʕw۷ﲟė-[Ԕu66Apw>.7i%&[~QJsXDK/Sv8<1PE){+@X\lсnFw09c HbXeY LT6rHqܹs/nlKӽ$$E{u ֻʘnꫯZ%pȓ'uV:<2+|:~'.F To35pNMgKX#=OZV#>}DH]U{|O8ԅ3Ʋ𜙅J$޲E ;85kc nc=$r︿ I(Q^Z@QfP^?】!YfPifP M'M94,X *U8ް 76p"O:y1ϔq^zi^bL4VL~"1xޛbg(fJ1SSI?Csc3] r&N,]*Y&zs3BXX#p/$1~Z^$uvq(*Ab /3 ~;tD1o*h_V$6V[JojeK׮6C*UVeI\s #qbg3~cFDඪP:wv ШQ[%Ql'ɓu;!!!Ss"Z ;Խ{/%p[T(AWÇ/d>=c tߢeql'@,CF6ao{2p &q$rABS.V4:16ׯ?$կߜy}ҥn|M!"~OP]/Q^70o" efM)ZaKHO80w$ci19m#!e3(K6TG#G!Ax^ D[\rD؄ʗ/?Pş> щ'y^ɓ `Eoժõ Of'wP#[yjˎA~naoiΐgϞ)RԖE}H=IaaK.ԟVޗ% Dcx9s@'$s$nVf^^xw#=A N,L6nH'k} —uϟ_8? 6 pE~eh"Q/".̍pӂ:);J䡔RѣҤI*#=̹ՁשSG\B}pk֘"V\E3#$.}*UJe?ujeٳ E ./_D,rU'MZ}0Y-#l"EalР@Vp%í8 СCmR7n8uc@6M e1W CQccUߵ3V)E+s2b*U6c$XU΍kMvKH #F;g=SBڶDȍYZ:x<vv0[u2#բ0tڌ> p@భFAtf.lYYFՁB ~?NNLJLI;1|15oO~&rZ"ÚH۶": ìP7% pGwSӅtsӠ9n=zjBh&=ҦHx_ ؔ,?GbJQb:]dmWL#un(X Qt{~ajhÆ?"v0uAdMKAґsEa8:PqܱcOn\0gNj ?xBR޼iժ? K>\[qI,Rn\мy{AI]{$޹s:t|c.2UU& 볷<3XƆ+znkL4WoMO0V8?[%#F!C”/u6Sn~8pAqߨtJZu-;8eX"?9yߦӓcf?O=m:;Z[xӦEIh臸 {8P;8pW/!_YZaOO?+Pߟ*$ry\EwߕȰ>{{+@ܧf,A_|Y|w:S|>;x<]S$ km)i1LLB?Xj~p_N+>Wr8p~[-ۑ}+\F^ ւKZlsW?#ྼ9(>?]=\1B])8xA}{y~KX4oA=Ρ,X:hy_ KU~ɮg8ȓI( [wڷ@ޣ%o 볷<3ذWډ|+h':qNz#^y%ŷ !h ;Ӗ G}UWŇI׸|kcsΒx4kNL ҠAKېvQzp2Agob~ax_'޴iKڿ?pIA[Ѭ>x&Ml'Qf&qc`ɦ2L+2Ldz[u8OF964eeTDȱYTEu8fFV΍p;6l8F/G? Jnov/IbŊ⨨Ǖi߾41beϞCI\JSNa¹ABC1*8/ +VL\ ex p~]7n8[+.8w͚5K(!=aā+*UJovQ"?l!|I03< , KA_[$k -Z$*[p9d wxHϰv.Pϼ>ԋbǎ$]rn_RVj;4 h2jڻظ$FEzlIz/C_*9sδsNȑ#4p@Մ(X[Zd/il~Vϋ Z}yr}Hȼe0X%BtWavQ7vAtE?_Pl`u6 0U$uvҥKqٲ幑 Å(_'t/L *n1Nnhpұǜ{-ykfHZ jժ%k/76`Wl53pɔah LI{\`0 g]qIwo;v!nJv`xv:t2Pڈwn>be6O[@)MOL o%p7,)kIqfѾ'm D}u5qhI\"6 90{LʤP& nM,m 4/D.r,U'={˕+'*V wLݻ3 @3.`NɐwAGvwı5aH7<(]-Tu+/v)/~iV[B 3X%q &{E8*8*j7ltܵ/S]gKkqбrr~+LYʔ)#q26ׅ O_n䷷[}yNG8_oDГ=ژ)#69WD;N*˗/WRf!("Oy-C\K'L:Sg$7/Y{p\/B< ޥS=C_\ի<̫YE,Sd̔;N@ u">T+80a!7 ﯃tRtp1ڿ|/ d@xI*Y;q_5J&!Rʱɉ.]s H=& [&9a0zpYd1Ÿ8MܔYj֬K;w2  Ş5ǹ\:uLH mР8q$kD?RWnIp6+#x|c$:E#wML;ػca_ǐ1}ɧz8Uăt\YkA ЕJ?>FWۄ0,X*FC"M<>}Lb[T١}GH\8;v2܀])aIF =ȞC7&%){аa1c›L08ߴiyߐ8zqq֯v%!?@8˹vcMB4$Vo,p[7%J> , 4vH\p⇠1py/F*L')j}` :-ĸD~(Krf͊y_U*rE.tġA ?ֹsgqܳp ]iF ר;<17T2dUkm&qS.L"۷2\~džGЎ-I. 9tHI!H\knA@mՇEC;F-ʕzugÓcqcSGGG>njժ{kHc)7u.^?!׭!ۅ G >&< >E^MgeH|Q:aÆ~ v_`0| nx"%DOU^Y/^re-z_6m:C۶6<2v:p|v0klG4-?Suk]e5k>4=\Ýf5n9aSIn|)]{"~cJ^NehZ/Cvܟ;MؽlM196t:ivؑ2؅ /[}6_hW;4a%|UMKW{[B:MHd E[SRT*mْ w|pھWՂE੦AtH)[v>֞͗:!Zy麞a^$RJ6D-s=YzL ۶%tGb^GCkI'GЪUynX< DgF񢅑#q2 \3~",/_CGz^G*gl.G_R(-[^9ɺu ބJZ8Jqf7:pgyC wSn3S22':gl.l'| vL֭[ҶըQ6m:F6-ֈٺ֭KG5Q>ԪU_m۶S$g>JTRrJNB CG0$ 9sc=O|A:JE=DNeSY9-N"p8y{2WScժJ'n {ް84@66:vG78=ot1Z졼ƍI/7iґ7n~߽hjРM[7@u"(}\q!Cfʨf܌9IyC]tv,x}'CCM}7nBr$.3Ԯ][g3qv?lT>ے7Ei= ܹ*;##/fZopFbgoyov^ 6p;kNw U6} krڵT2I6|lOCǨdɒ$Pxiv }wd"?GDNJְpyU WCP{:3\97x7iCv]7jԬt t&$7٦MqPܛ2Twh~B_6}jRyf- ءHEӠ# n";[ /,T q(5lk#] MT 7ĥ8a/ NXuowzd- R gV8 Zm!";%FkPA vg<>/._\8$@Ao2K5Լy{ڴ)-0ΨgDc,X:hyoU'bcWMUްu;_f]i8G̜-nH"F}%{ =B8]{Zē_S׬9E}V8-Kض_{ vDpkDΤj ooXm5`%> )[͚b>ɹԼyWjn_MYk 'Oڊ/diMvaan KOM7`#zGf-tg@%hŊ#2&} Y-wt51%w%r5A]uM.J1{[ UDyhs$y1&N&BV{2,J!MƃLσƍ /$M3-wDR N kϣYFl]y_yNxL#qe;u&xe8z^KACtK/W'p}}BcYmK_V GHVHamzi{3-o&m]q%b9zi)aDaaiOvz *-E6h5!.]FnQ.#z _EKA8[+sx%Ȇa_~`Wsr{v/qY}9p1Z w kF V7S` ʕѣ>Fe`Rp(,վ޵elj =z O8)SN 6Թ-$}.[h!KaCX6QpچĐb"0_l^<=cOgϡO9TAaCMXUP oϞ=nu1%Uɐ+K(XĉǏm Օ.  M *ꀐzlK#Er8?+HAeLf'5Z숰<`8Bn*^[W).V t[#R6xXΐ'q`0 4Й1J*ѣ'āɓMWfMo<::*Vh5rI `4kvU%ovp UBg q$ǹq&m$@58h #GǕ+4B  DG'QwU)1 $猌5$,ZA"a<1aBB'ws^BoիWOrgʼ9w[Ihx0N@k}I6W] Ƃ;U C?ZVݜvߴih<0601n֮Mb0vb4ROƍmQ͘1C'v'q`69+W61bg X0>_7xEm )eHB ^zaz#M  ",,Lrbq}ɒ<~fͮiz<˗3.R O3FNB q 22J}&yC=N@``s],WZ%,,}Mpt<'.W3Ipi4@x3?LZaÆ*yV>"o3?^x\y,9Z@+\dJ|$`Y"`ٸqkTLL yjmQbbbԠ}-5$U\2`dXLL `Ȑ TȜ)oM"];cn/ P%i֬MJax#qWހyICCCu<5+3[nQi2\ =7gr=lׯ뒓RR$Ʒall|"5N^o,N ϋ{Nu]'gΜGo N:%x岫Hʕ+bZy)&qzvR\U-I@IG ;b3em65s+)i>H}9mmm"&&f}#?777 ___8K~̙3DZ$>)x-(s1O8A?`upaW-Gx31O>}!~;T ĭOb޼y3¶-Z$fΜ)z)qeg͚%~W>SpRv}0l܂G(#y:{$Q;daBn!?nJFC(0884?X~$͘1d[$n=LI0CpL+׌_^Sde5H ڷ$mYv=㔌 $?J6o~cD5 q}N>&rcg{OL̿ݬ}쓩MG}%SZ>ŏSgi")gϞ*sIc_na+q`ҥK& kLzAQf!ݰw#Uh}7 ܁݂ĵ#C,:$q `zi6e(#gϖ*xtnz駟:>ħge1մúz.6$ Nۡ~ޖE߇ dfKRЮ*^y Ôq=j]V61[=25D?/**θD *lP_nK7qKW!G'XF}rQSC`׮< 71yyy^GOc6p10pO?<ڴ'%"+H|,"?|"mEM ·Pyp?|ti8 ۩Jnא9#^]G5&25eׂldLLLTQܝ:3; ]ggllz#7PϺs.'N\Uh`AC$tmf|?(?khh8/6kbADh%{ХKǎ L@=ĆGwSjy-fͺO:*+ ?-rzDvZlcG,}+S JM>ijRulo" + =篬˖P`[G-'Jgh۷oWS8\aFqv2$Sgm#|y@z)w¥r=Hsa$n~\^w%w99JDx qH9!t׮LXn6NLE䰓~NAkFs 6r}nn\.*j-hu9Ϡ Pͷ, _{λrV\[WAcu"lo"J>sڹ0Ó5v1d  RLN}VWWWmnt r4i3gβط֘76~*.e?9o}޻[Z!緗7ku%̕W^yS:u穮yd&p_xJJ ;0ħ>EذQ|*k7,E_߈;;FyJI)EРw[8k9/!22__6F1&z(G?+k4|p˖-2OPdI~\e'Ǵ4 ;;[! GiA0GȾ D%AR[ypNhXsG~~ww_]]_1L"&&\@3B;j6qiS&#StC$Ġ4%tiiiJU%ofÀ!)235OI9bU|Wm;esdfVM鼄9sZ5 =e;؋_y]􀎎/t[UɊ+ /Z= (EyPfj'O^$uo6"';vPߡ7V dw1UiX<"}}0B-].$ ) |$2uz"Ba+VNΚୢj:cx@A}cվn&͓#L@{[]{vqdV,VR O{U fJaA"o v^2[ffEEQN8pTʩ'ÝM'yy_5.˓PJܡ8K0_0_+PW {vSa0 %(ZEJ rwAf~`wBZizz5D $; 090t ?)$0Pڼ1#3 W1/d0 4)m&- Cw\fUBn (Z5&qω`AX3n2o ::[\b`7(IMIUQ'd] (}3{d1ĝJ놉E? =!>A3X"qL&i.->&I3Iʇy٧6.A<ޙ= X񩵗9IDs [ SrY]R2"BJ#͛(E$UkE(Jp@[[̓Kde=&jy$ r$쐂J8$uX`/D9%WY`%|QU!cʨH$$ TD;;i$'본D-G$SZm}`"?@_[ U<سQ hgN$hhqFNζdgLssUfc͕p- ]8s8A15Is ,Hqސl CX&o&qP3?8֊ l!N\Aknyy5{֍JmMd"oؿQGKސ;2$p 3qp6L/1hvu QV &Q&0Dxz#Rh;ɛIDh]mԦb4oF`Z}|Ebb8v}yӰ-COXhiݐȋ drK&q4ƙZ&$mTHNCUBDRR Q[{Q0qRR6H$КL R78Å8_Rx"61anAd˲ +D|@?k F:De尜Iΰ-[&վM& rI3S#LL-on;3Q  ۷vrӅ8qط[DEeq# ϑ) ^͵nM&L 703BP8;>ivCsCV(ʈ6! Zɓ_qC;w&$l41и,=C9zj9 u$2LngLLI"ȑ#&N6"bA"t { )zw hk&ii% 4xjM%xnx~QuRt8-IA@wU"ts SV(YTe/ۥںm-sSjօY%m___iFbM@0~fM"QI2 !j$ EV#Gb]fnt-F"'F>hnuѣCQ lmm}7eQ9gZou6IܨUr$b Sot":Šo۶&@Se޽"..N\o(F}Ӧh# RCuWnj$_RFP >k/7 CxG4״$ }+L NQE,,,ssBsgF"2ԉPi7la8vFСwEUy6|553wny=GEdIK-;22RIJii%6"_6n8cr84 !00Ђ` E( )Z Eg܆ w,rFJ@ ""],"&`m2&Ƕf˗K&hиO[AmQLIB mfs, &qc+vtt PMh 5[ 5B{̔h %t_5&h>pȀ 3d+v"QGؚ`^Ћ}ћ&*XLi-Ai4Ya2 )ۚI.`_J$a'ŁY-܈q\ =9k t΍G4l"l{"It8~$)ÇH ڐFk&< ADƀhaG4l ĎHf x]"6aG툖pZ[dx0n8PE0 `g0 8`0 I`0<IENDB`libjfreechart-java-1.0.13.orig/docfiles/GanttRendererSample.png0000644000175000017500000004442711173030414024365 0ustar vincentvincentPNG  IHDRXr5HIDATxoL]Wz=RUUUUURUUUU~UUE B -9@]3vR(.Ğ:0Ď3$fďcIq!Ox͘ (͵}6?9%]9{}9uﵿbB!PRBB!`!BX!BB!B!,PD5۶m3ۿm~~/_eGGXݻwMMM1)--5'N0YX:__3yyy|g3 `!7n??y[h0w}89r/BʹDWpy)BkoT\|7 ,RX7>X@BB(A og="1/BOS;4s=g~ۡREY XN3EEEA~OW7.;PrCN/˿K;%AMu\hx]oʯu]]]\YXև׿YZZZ>#ڿ >l~wg&ẕ@__WMWo߶x:O\}x JGmݾo4TJ_]S!`!VR{!|뭷֔EҥK/h/_SXpXKГJ^MɓѺPinnjn0pxZJk={uwAYe)۷*3lq`pw (C?1Jc]8I~*񴷷xj}j]ooC#`!PK n"Y]#msrrGL*+q(-1T=m;v c^\p.?w\4*_ժK\Å! `E uaVtpY]Dj2X?1J֚RXN'R­S5iڊp{RMmMPϔw%u?Jdh=Kl999vy¢ՈچPbͲF",M*Ȏ.P?? Zv!3???w.A'dh=_PLCeBj-i,,2N~m>Xwks/d(ޘX<44:g3Y$i"Z7C?l%"DB( nKt 7R?h(0='3F$QzzzV~5XyJ{2 i8H-Y36G3x+kS~e/T.RgXڗ`Ep͚ <5ۺfױ $d(ޘ XWClQ=q4l}LwC*V:6 X.u֠B!,B! !BX!BB!B!,B! !BB!BB!B!`!BX!BB!B!,B!`!P 877ݻwB@9{]XX! XN˽+W@K633LUU\~~9zYXX X!޽{v/X&zYYY1Ν,Ҷ>W_﷯;FBhs`HB~NsrrlV*ҶcMOOmW,BMCCٿ).. -[>V ! !6`}v(Wz}inyy9&RKl! !65`577W^5޳k.lrr`#`!,k ***@idddgk;MLLeZcΝ;BBe5`FU|;5%WSSS\a'Vkoܸaz,}ޅB!,B! !BX!BB!B!,B! !BB +FXeE=\׫]jkFuz o[[][F]SPPlXܜ9zs]I)k ?8LoӲd}1GKnyyٜ>}ڼv]OO9sL}}}5x$: :NE}]LiO>I`k G^SgggNeeeypftt.۳gO`ԳUږ/rFlhRрX"#s3qihh0MMMAY %۶m8|Wm6G>Q mIVFI$=[$5 ӧOEd~~^JKKls.sM[B>}@5,:"uaCa1pcǎan\>{=N󦣣î{7:I?^b `!v})*m씻ɱ?l/T{Luuun"^uf,,eM6ӱ~#N(EYXs6s];۱cy2VR6pB(+.% 7RnIš&T% P NC-RzML:U?:f7E#Έvn؋,tmݺ ,K޺*N!HRΝ:<SڵkyIz,D[m_.+~ƛ"KwJP,ؾK+[`ycZ8h90#BYX> s44wڞ>NnvR&.UzU;<<~(`rMGuW|HE_[o ]CǏ8KPKr5XȈu7k pt 3UUUQn(f-sׄfH!Js=LC2Y?G,^.\YYY+u>+ʸUn%eV%p{"*~WIp;,,,]`!4Pw" ,Pʥ^aA2QN !`!BX!BB(akb5KX#bN,B2c1hX!BdB!,B!`L[W)wM{ĚcbNPv2`SZ~ݬN9&^{ BV֭[|kb51EkbN1,&0&XXX:5&Bc,`Ěcb `!`Q7A9q BNb9,`a1BNbM1 ֘k BNL9X?|<\c Xx%cVYE>q XJ._6Vٮ]MPB9=s XƼ*?I8sbtԎ;ÇݻgѣGe?6۷o #hsrr֭[M[[YXX֮5;v/1V: ^;w΅ FFF<HZfggMGG9|0(zU=pY#z11'JCaѣ}.Yڶm[l Swwihh0MMMO@ҒٲeK}.//volYЙk׮2OIrssMqqqP 70`W%`Q7A9&֦ࣴ4z׮]guuYYY \WaOO Xk~~BM}8qœ={ֶO>xk`KCg>WTTdre7%%%XW\ p&Esb4Ree'VgΝaA(`[qD,E%v.]Gs9~z8> c `$Ѱ>>3fbb"ÆpE?9sLLt0Zݹs۷f\M2Z>0áNbM1PD{FJY+TeKrÌk)Sɟ'3Xn]yLIGuX@Ù|E&QĜXc+]_XM(]tٳ'h/`:&o{___jk Vuv]-ꪼ5X I ǏGjTH6*c%ihe 6 ._|{^'=|@̉5Y*nW=x_ zBwbi(&,5uǟߕrﭫe~NSBhn*h4lZXXh(ti"ԓr,d1B)ZZR/Nzāk `͝M500I9.= bM1J{:~,ԓr޽?OG$k zR9p`y0XJăC_nuf,zāk `!k3L4J&XXX:cbN, X<c15yttBV4 뤇9Ěcb `!`$Ĝ8k ! c1`!^'&k+QHΦx`]ztuuC5*k JݻgL^^~cXl-;rssi{zĚcb `e>|hJJJȈYYYŶwLZÊlc `eW-ײÇٳfsssu^;8 Ԕ}~ ***{T6 njLaa}텙~m۶mnaaM{{Ϸnkk$XIcb `mRUZ}^M%5>>n3d~4333𰩪 7oܸq#hjkʵ-:s:8qB 0;::7|ӮS8,&Q!XXTʾD[Iu0''g`3T=j!L[Y'/ƺ4rI ~{}}8,z9&&@I٪hH`_?==mkܐBm/i;nhovv־p`i] ,ti2.B1&4t旖>+\+䨮Ipyw R=T딭g{% QF[d8ukL̉5R,a $Tt4'Emtww'O쎲9޺.vuOkSN:*T.9L9~xLR]U___ r5XTruĚcb `mbylbwޠT[$T<E\Ѻ`DZkΝsR*++smeZ\\i?;] XN*אw85qX:51BH[4=1B#eYK7e!5J>&PƉiFcb `!`뤇9,`e `a1uĜXXĚk `!k]яʡI9&BYX?wͭN+x]0B(sO?M8a|'XXe.`X9G7|/AjT9&V5X}}}ɓAY/py#:PYhi_V<ۈXN?^UE{n}<}Զ9T\taP .~µ9y[ #%}|a'X/*wuD PH4iM^|n+Ҿbx_ꗜT"|mÛԩS̫ӧO㍶O ]z)VԮFln+RyTNcv0 fT8& Dr q)[t~HZϛi_VTg9OI9krm-Ek `\Rhn߾rx0jl4ݞ&k5*ĜXc+R%Of#`55}nOY_ysCk `ͤt^(ݞ&'S<`1em>1'B2I)5*k ! 9,1Q9oƺ'Xnkb5^̳ʴwޡ9#+=9<~ ru~ki[}}11'sMF+ك9<ΜFsb `)rnn)..6G5O3Q~8^ݞb`Exm۶Ovms,`|tիWcbN,zR-ӕ+WEp-///wI[Ҕ ZLw{^p.Zu, Z+-H`o;42ޗ/oLXyB̓"p).Ƃt72@*$ F@VVV۷orT^XXhutzN¾ti>7&JEY(&+뻕NOIؗ/OX(5RFH"e4Djn)^gJ$2XߘXXXiR7}-XMK 7&Bֆ:ztzN~)*t=|oL, skkXc `!^皬yrDMk !k&,jT "BN 7&BVz[ Fͣ}1BNbM1 ֘k BNL9&,1Bijjر>71k+;{/_6]]]sb `sYbsQɓ5m/mϷ`{nۛ}/;w} `egD___T sb `ā̙3fffҢ},//sml=$^g=|bN1!ti5r6 ^pfggk׮2YzF53999 -v-=} mvLnkk˼pיXc `e`iX(.Cq3---wgzzйs炶.\ƭ@lxxTUUlߞ={{'''WZu sY9Yb.6$,2XĚk  n8 D 便!bp@ߧ2N~)[&+,,mڿyQRdJJJ,jĜXX(%riLCsA L'ւue4|ad+:o9{ʆ kL̉5X6ey@y򂶧XJIX `c `۷ U.r Rm‚]bwZ[[M?x`B;]0L2,۶걨I11'J `fۺuky5YMM>lIrAKVVVYXE5*t׾u_F9]Y, b9PK١U ukb5]z)3l\)`tp<c `!`_x Q95EN^ `q~k `!^'&5<3c `!^'&5EDz͛EM1,z]l&.]J[?LE27&B&g8S$/,M|VYinoL,MZ7l.c^xߘXX)Stm;E3ӽPWgK/ʕ+A[&77׌m`iXd޽;q ֤B@cc9vQdQ6,z<8SL,*b`˞>}jz!^YY1[n5KKKо_l۶ً\`АYj355FYY]^\\l3e~ooo*))1㦷׶\~=v9uwwX655/ٸmߛ'TLB9v[΋hnyԘ,ۋj~~ܿ߂DAAI`i"@޸q#$` <F/æj~/XKDLNNZp޾}{LzzzNmiik?Ѷ#?&O8aΞ=kQֹ2^'`U!V;wZڱcNБuQ'j '''-X>^Үr `k{ij G6Fz{l7lX`e, c+A Iqaa!9rjh%)n[K0\$؈X^.[!X6K8rXTV~7Һ} pp޽{!}ݨ,EkHSvSf%Հ]xk/mD;H1 eX`Q7.~睛ouYR3889w N:ek:}j9~x єqQhRqz___P᭟e?lÿLCaH1[,cyk,zky裏8.aD.WRlbbmQ/y Zbi:*  &ij 2յ^]sP)we,)|w2u!>s{.0z m.'ڕundwzw2'OX|d)` ~ߏ9ID$KGk,&ppkkyN񛶣}s,w@VcufJ9O08p>h ՁrN]&&&,T ܼKRp//س8| g'`n8ﰠkΝ;fϞ=ufL5 `]5BZ{].fXMdJ,i@NL X|l*{kkkm+U" cc&8\YX T`!^'ĜXXI>_C]yo^JmmpmsCZ^S bM̓?)A۷5a凐lEXxiO Z徾[3fCp)s!Bu0ƛ͟U>s$ukbOO Z円ޠ]xXc XM`bM?)A|PzW%7EXgC͛8,,q\HxU X518,,&5N~,o !^'Iߚcz*0c !^'ĜXXXMkL̉5Ekb5Akjjر>S1k !.oȹܹs'm(ܶm...6G5Ob7 `I+++fddl߾=3X?6gΜ533e۷oe!Aguzs7byyyA뻻MCCijj_vyEE=]v͔ >m{~6&r:}EOvy6ִ344dSR]]mAbKncr[[]3EXڀ 2A^fill̴|MsY~8q"h{EEEfzznܹsQ}`Çqh .=pB5n~vvvdvH5c;99 ֺ/YdMڧ&\ ,7`a `mp hr3??*((Lx/襥Am۶*!Pa]n{*D}}.䗲eB&ѣGIٗҒX:5E94` :vtя4Ԥ) ֭[WmOC`zBxK@@#~µK L+e4|ad+:oEN/+,Ĝo, ѝ"8KRQ7޺(ѹetסFGGWmO5P 3**=kKg4z,:%u+dPrkmm5 Z :)Մ `/`ܶUE 8@[RALE[3`Ep& C!/ﰜ X;|(4>>T8j{چ2b:g{ィ`|+~BGmxhvz+xQ ݵoK>ϵK(ve,EXLo2ʵg'`rA$`Q7AFٹX?K12C&i;OW& Iyd~lo+|(!@k B+ cQ~+c4S`!>&#ao ! 4KL1::b !^'NC|٘^Ht$07V+C, b^륗2ҷ_mq}iok`"Ν;)dBQV<7`$PS[>@t |7v@bCS 5l,2Xg8`?o0?tV*@LSwwihh0MMMnvvvUʻ2khL&//ϔqk Mii~z}f۶mUۋXmCCCguu;&~.//v[e`$?S 637 ӧɓ'랞;1ؘiii)#x XA۷o~~޶UuرEjsN333c_+WUUPL 8qœ={Y;::b?E,o+jey]B bR]Ws}#.RcO<:vI8R6eE?EXX7,e4 C_illCbu) O6dzXX"d- 0fEٮKAWUmӧs,eyqgµ9ijh)&l??N^'ƙoxcV‵hkŸƟ5XEEE6Ca4vTٶsDjsge^o jT 8Sb.(1HV5XGsߪIUMMM ts׺#OZlMԝvBgµ9ij xb.B9XYb3-dӃ|7bvgneӃ|O+{坟 XdU5N;+S|{իvyddB5X|kb1z?SCZ`Fٌk3`!`aN˖, ! &`!`QDq6cbM̓/o}hhB5Xc,,*{lm-Go9`! .X~uy*OSӷLsssxBO6,-rp]kAAh !01J_4fR^G B=|Lŋ7dBS ! c֚`'Q!֘޽!|B=|)gu4IϢ,`a1Ϟ=Kw`!>&|Yee@8q`!L[cvL'._se,zXo^cYI+WXX .>G6V<7`aqj/O|/#[fR(e`O11OX_߻|{wRơCf,o&KO0LMMWVVfѸKm{u'~ن?ц"׽V6e`aqj `XI`[7==mPb)X^ڞPZi?G:pYqFX51ǩF4JktlM>}j3*XɟQk/mD;pe,qXԨkL̳7{9 4|LJ%`ݿ?04600`?EX6ˊl,&{5XڿR= O11XGrԝx ģZ̖-[unqqqgQiX&1'm PE;u~W ᎎ4PZu kb37G~OHXJ`QB11X8q+O iyd !>ĜXCCf%kNmE&gdNtk3,zXs~pHY8BcV:v̘^B1hjjر# k>&xs~[1/dʕ+_zB髹9sQofݦ׮K_~esΝ,jT51Ǜ;ַA0,MOOY^^6+++vz(777k>&xs7xPHP# %oKV\\l\uuu&'''𞡡!SQQaU]]m$A[{{͎mmmv\$XcQ&PZkϞ=LNN-:ΝŹ(N?zxxTUUO8aΞ=k?'?N " IX51Ǜ3XΚSXXh3P7= /?}.UZZXIKKKFXcbN,y4==mN>m)[g`'֘k miŜ.SʟR1x==4tiB{U.OkkV>x`L,=Em[X`'֘,nR 5tUcc‚ VVVکWsPەX5*sb>r}VDT O9&kcw,v*//Y(e4D\tw[}vd mjX51z-nneBE &X'&X,`a1BNbM1 ֘k BNL9,1BNb9,`Q751'BNL9&Bc ={~c񆹶B!HX!BB!B!`!B! !BB!B!B!`!"~+x!`!RX?BBqEB\`X!`!"XgܹZ=sIk,Jt>NJBJ5`9cLYYxkOsssѣ&??lٲ޽f=`%FGGMnn(BX,//sm Fs1BXX>L*]6g< j355\wwihh0MMM_7u- @C(x.m'[%SXXH:Je_6B-..3 ! !Agi&''W֩S̉',8A@MUUUr0ZKKmÇDLy3܋/zm,v(%*[cB?5R"rt{u,- ! !.\` U̕ܝy\4Lu޻"A MRfMMM,l7F{.Dk?oBE"Nvi+2b$kB9 T'x,,PB\`,X!`!GXqEBB(XB!6V +QIENDB`libjfreechart-java-1.0.13.orig/docfiles/GroupedStackedBarRendererSample.png0000644000175000017500000004552411173030414026640 0ustar vincentvincentPNG  IHDRXr5KIDATx pTeڪ-o3# 5`0pK &@0 &1(2 H ˋ3 B"*" Wq$4}'u+眧9O~$B!U#f!B"BXB!B!,B>]!,g}Vn;ۿ[GIJJlٶmaqJ??ɠA?z!4i~-e߷`Z&)))2g9sMX`p&̙3B fIjM`WEE^}UXm\7:`?!#"`~`}^ r#^?3%f͚eW7䚫WJyyyuwǏ]cEw … `ڮÒvHKK>}:"֊nH; 7ʑ)>͢xЍСC;PjkkeԩҩS'{<-o~v]߃c:t3fXDgx4}>Gi }#X?( _eqh}󾩩i{NO2qD[׼F[)hPߗt&?E_[zۯ~fxZ z>Fq͛7[:Qu=8x3!$t0+iӦɦM#R`=$%S֭[3V^"0n'zy,LِFUVE<?,>`L%mѦbNO =\>ݍD?ڬG}vӧXf򂮬u%K2~f7W?)q``˿KkjjG!^Y'O=p5 }Oڦ@ 6\aic}Ν{L'XtڥmjE?u>ҟ9+|G{ջ{]EH(P?Qm|` 6}.';e˖ǎ1" ߏ8ǣz^={{ccchu}?"Yi Q/{2gZ#Xq=}"6݈,` 5o?yE!]YpߕFJP+hGQBDpvrCOw2XDztڲMm,{ҟbm_B}NF*"63xf=v=!27X`jvc|}[n3,:wpqhz<^j6ӗҟZX`H"uN/PƎkjwpǺFyFH[ib߾}:#^`i=&9) Isx-6QFO`)B8boF^l6uv3M[دhSk,=UDe1XUB!|g'|bo?NE7Z@>sp~9mB+ԓ{m=LG/yM8=@e]19b^۲Mak-?d_ ՟ZX-ۃXE"!k vNP~@]yQASVVё`6-##Nb׻a?hcV[)X?(?7W5 `EHFw _z=f]zfu*ѿu霬93ޮ8!@+#Gq@u@?٥=KWmQߟTgQ3u?Vsn?2k ~_煞I\휄R}$oTd[)X?vot41Կlj?6,퟾gr뱜`E!B!B"BXB!B!,B!E!!B"BXB!B!,B!E!'fjq=;;[}Y(k7/|EQEQ1/ EQEQ `QEQEQEQ `QEQE,EQEQXEQE,EQEQNuY),,[yyyri{R)**xjhhXEQEP;vSZ6lѣGʤRRR((XҳgO +$''۟RWWb+==`QEQBeƍfyモm۶… }7 1X93fHmmTUU?us\:ףRT?eVT 4uy{_RR5t#XE%b]QSϛZeSLfjLTGSwbnJqƛTSy Lmj빦2O3/F1(ʒz̕_#XE%b\w5æM4w˔oDbvS?53Sw>fq]cc*@SM 35Jv5ajwZ^0c45u]?~Z( r t⫾1XXE,EQ+T Zj~s[(( `Ja&cc8EQN|RSLm6vz*SZo-RZZZuުzomzk_}%,Xɝ6u 02T_*ň`QXE,( `,X `QXE,EQ `QX((X( `,X(E,EQXV_ʩSZojS>6UfT&2myzT MljM-0t:ŦJMnjeVZi-R㋼owX. `,EQ `w;`MShSzx'+E,E,E,EXXXXXX(X `QX `Q `QXXX `,X `, `vbGS妪MM2n3;Mk~SJ2S}LhjaFk*TlS,457/05ƻtw[n}}ܹ>, XIIIK JQQœVCCX `,&uuu2f{YYTVV6WQQ!%%% `,X+˖-[\NΞ=+ `,X+Ҝ>}Zƍ|=%%6VNfƌR[[+UUUvOG~Ԅ˯^w:$µՎ ,cUB4'q=ၵ`ٱcG#X`1#X`1VQ)N0m`-/XbjͦvSZeUSU%ZS˼[[k[ZכֿZ+Ĩ|9Xj*,,-++K[5x֕+]9V"ZQ, `,VMM\s{yy xX `,&_^s{" `, `,Vܞz+Uۦ,[.ٻze7ܻ]'FӼxXֱcɩSMnS{L22SE25TlSϛ55ԋSheSsϝojWTR4Zfj^/>/i `,uCKZx`=jl{7{7Lwr+n#h}|k{mt3Ӧ8^o zX `[`y6^^M )759!0}MuX `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X:uMzSL3zSLMmҹshjtS#M65TL=o*TiimȔN{ŦM-1{}SV]PՎN.xD+Žuk>5-v{S;VqOC)ĝYS v^|I.L^.+Ľiq2<Gti[y~@ ⮜' =W_L^y~;,Xe~͙yg<*dNӦ6YizLJLMn1mݴ駦M?3m۴^Ӧ<1ӦMRL66 4ml4̴iiXӦ Ӧ=5mz)ߴi ]y&6-X>ٴg=O5] :2X `,X `,X `,X `,X `,X `,X `,X `,X `,X+L=*ӦM3[NƥRTTdX `,B̙32f澲2l^QQa9% `,X+TL;w x_ff5_?{,X `PQ0)zew*݀ ],X `,Cgrd͚53oKJJns *;g[]OD`kŋ pʕ~ Xc"+\\ pK+ ׾DŋiaWzlXT={d,Fb,Fb+֌=qV>0ʒ` ֕X `, f%Kڿ,]^^^n}lqq1X `, e˖كuנby X `,X `,X `,X `,%nӏomUU Nx`,X `,X `,X `,X `,X `,XF;Ԋlqo])OR_q/NwxS9w;֋qOOwagwQ_q'O!]`,X `,X `, XIfe4n[JKKI`(`<7 틟6ub>;,XXRVV&+**2.X+v`ĭ>޽?^kueD3X `VVuuuϞ=ko:X `, d[ ˗oKeX `, R`͙3'Vۜ5,ZG ҟmu=} pJ~ Xc"+\\:$-f&b鏉pK4`]4"J4`}o7"Qb,Fb,Fj\t,4{VV׷8k.$X `,X `,Vlڴ̻fC  VjK`,X `q&wX `,X `,X `,ժzK8=WeOd7%xodnU&nCzlKr?,S?*/~xD$;+Z^;D&şcjΖUs4@*_5[*ϓ _/W_7uP:)+SOX `֭b./R%.s)1ts\n7ns\71sy\uK 42\FXs0m.72\sYsb.:{+|}zjqP=† X `,VYhSN>s@X `,etjƍv?S/,X `(YqyX `,ȸq,dN8aت6 {QX `,eo,lX `,Vtk6R999vw ܽ{7iX `SwKCGBAy*i7w\^^"{oGgWi}܀d974Ƒ' 9c”Lbօ)r#X ޽{ˆ SJr۷m&˗/5N8aG._XgϚuh:X `,VT\i'Giq_.,o>މ ,X `;`Smm=tk߫np:u=z76,`0*}oQglpO0`[^WXc"+\\:$-W;&b鏉pK4`]L  X! Xo-4siqUbIٱ Uv_> U<>e/ɾ_MӪZ3Ug `E|~|azg~`u]a+ief#X`1#X`%i.]dG-5551cˉC"C`uvDXQv3HV `,[\V*7>X `,'B:RUh:ݻtoM`%yX `,X +ߓՒ%KZ|f:;X `,VuټyY8X?q:S97 r-M{VٻK.//IJ}wHCwJwICг4z@>"Js^ҘWGg矟4J.䌕 S2‹Yr G.NӼXT ^(^%~1W../ȕ r>3ݾN{Im\~AMɕ rqtiԵGix4~PRs{>}nhoq ۗO)糟} B~kAₙrU' mt;`9]1~z= HNj}`ͮ\uEhW+qn}/~̥\SC`$\\2O1=9lڴBFX `,LSSlٲf,] `,X/ EEEX `,y1;wl`,X `ݴzwƉ֖iRM> ջ^ae˴ˡA䫡]3ȑq=&IN^xZ0m ccqr|N%'ȩES/Ti| vl9byk~rQ}Nfr|lgN `,V!jzܓrMs'Mx{ώX `,X `,X `,X `,X `,X `,n$5u\}{^X `bDjs9 M}%\t#X `,X `,X `,X `,X `,X `,X `,X `,X `,X ` X6l))))f/'NR)**xjhhX `,Xk6,ڸq9WVV&͏c `,թ!'%{eee|zM,%$}rKZ=4q; džGgNIS6 | V~+31;8;;y~~V*}^,'-N?5tqR?!X `%.d3lpo?{?tX `0uj+W|i|jvo;vt,X.KyP }#\,X ` IJJHjlll-)0kZ3HDV^LM8`[^WK8`X!nyux5KLD`k_+bZhz پ&{{b,Fb,Fj7 5YYYR__X `,X'vtʕ+,l",..X `,XS57S'YOp%΃X+n$&[ Nʺ_m֮ɰ|˾/ӤáArWrף#c#7OsT2Tde䱗c3%lx|d\ 'Iީ_i 2{f,K2ϑ$Br*Az]Ճv ^}MNy `,JT`i>약?^kueD3)mnrՕoTU׆[7 :{эX `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X~%-,_%w;y]exFx%Kˤmٯ_Hk5oY_dPE o~?2W2IȔN"*[?|(>! v|l}x~u[kdX `,V`=yN~M}g寏?HbgǎX `,X `XKA o_ZN}qX `,V`G2$X `,X `,X `,X `,ڸqyM')z"9{O+--)X `,V9lS.K֮]k:{_YYTVV6?,X `,mLk]Gu ,X `ȳ~;I%-^;${EZ+4x՟d7xܚEE|nܕM:~ ]~(9!0)2||PS'Xݻw=B7}EX\\ X `,BE T w,X `,X `,X `,X `,X `,X `,X `,X `,X `,XXw8_r/̐M-ڮ앒erkrG}rgCrWҹtm)4G ~=%Hsock)O7>#Ϗu~#Hօ%BLP(y_ERx2+2/dR{]Oƅ\I?)å~ҭ @X `82zȁצ}ɞh..X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X+Xti&꛲igR~2U(O-MwMWMWMWMWMMW$2r']W~ex"C]ekqg]25IsdTy^Wgʬsd+ztMa ɮaJWX `82meDWz]۬+{':t}Ao,X `hN{΃X `,řX `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `,X `R)**xjhhX `,XL*++WTT\X `,bMuuuϞ=kp:X `,5)vX `,H"9>X{m5Ǎ{|( g t LȗY`>2rdȠA<8T}Vzz[ÆiI#==֘13NKkX| ledhyx}NoĈ8q}>|!(iS}_m=Cx^ȐӦ|ۮ|M_۔o6v9m69 &NO} xڔ/YYf9z^}gyuYygpQ<5Ӟ}}møqx}M4b~:x:]kߘ1=~-/]6ri?j{<7?k?޳=O?s>F}vz?O;3ߧ/z/4^tZ: {lϗO?pڔoᖗ~?z7d'n,B!:q,oq `g$BX~sЉ^\\̒#B5ў?fQEQEZ XB!`6 zǎvvA?ufȑ2n89xuw}je„ a_3ۡ_oj?1m4ۆ={ƍ/鏬/?֫Wz^/STzףGiN>sݻw·}g_?Y7G_X /ʼnɪ%77ޮW5۷oH?SN#cǎgdd]|}˖-_%NZ޽{CЕիwޡ/H?n4[nO>-999S?9"GCډG!cǎǽ`|;1b}cz~LKvl۶ͮ`|Sx}Hd}`%h)tY;v M65?nҥ-+꫶-"Ⱥ1>"JݻޮM;vZ{z ާѿ tV7sLٰaC_z@ޮw^wZ;w Onvֿ\. 8q؎"Ⱥ1>"JФo];oo3Foo׎JoסSݷӡ[} =oɒ%ͷ_j_O>@'B;|ې4i}e˖-vG֍!B"BXB!`B!,B!E!B!B"BX.B"qr6A,Z 6ķF7GKHiӦ]w?,ˆ@)++V0V $>s$O_}z#"7FnРAF*~JCާǪ&keffJ]]]uW]S|2+YF̙#k>gK/$ϟ?VhѢV\iod]}iСGEH'|" h_W0ΊAYG@ otHܹM7YYYR__9^e…Yv\t/IFO>Xd]#PBXM=ޯ+H^˹mԩrшF/ctz455I>}菤Uׇv݅S]Wab|zqnR/@SV"H?#i>A设\y]IX&חL6nh |5zFDq%Kwh9::#i>&ɹh֕GEnzFw_fЕG,atX݉V $Xܵ\.{]G|rcWXA$';f׉E?,rEW[eرra{DzhAƱ+!A^I7t:⚟/={xٲe?}Ѭ+B!,B!E!!B!BXB!B!`B!E!!B!BXB!B!`BHk%))V<$##CN<<#,BHnJNNq{wPXeڴiA_W^+WHzzz'P{!`rr :umXRUU5{)˗/xҥK =EiGҜ={ޖ1_~deeQ.'{lIIIٳ}2yd}LQQQ|ݝ?7lqI:ZjެXN}:jժkn~8?|ŝBihhٞHKX8sAZ˶wm1 1b+O>iVSS9sƢ-\;B$P}K޽7h]w *4۷o%nBQoS4jO%,BHرcyxbI7NtKo:rqv7:4HLȑ#QA1XChOԬY"ᄈKKKeAc}*ݑ+s !g:zIMMBE FJ~hubڵkm70`,Z8}N7h,B!$NLKK 6\/B=&`{X8ѫ`FGt <=,B!&V,qvn0':KLF癊dt1&LfZ`/P})..hLq#{d~D@X,BM,=Joo]tse˖m xM@p%R(t73gڃ[ʁ~.\ X̛HGH E"rP3:⢥|t8p`;t5k͵Ow۶mNz(礟@EC,B8B a@!B!qqؽ;t݈sib MRRRB=`-H7ϟEI^gϞ-!-a.:ho>INN۷_\¼0uttgڴi՚"!,Ȗ-6.1H6|sQkrȑ۾;{[$˦-ZX,B X:ڢnz tF2tP{]d;ڦUZZjosqFؔy饗蜓5kȜ9sd޼y2k,ihhhu`|LKK&ӧOsN4h%vOE~(XkKG%uʕ+m0`}'O>D:+< 6C,B!7X999vc[]]1n$o_|_޾OwyG-[.])t$Aի_Gw-\Ձ捾o߾}ʉ'{۰aCж'0 F Og 8Jhc"ͼtw`;`nuEG ӭ`ڄo]#EΆ޽{uWbwɹ5URR"[l{{߳gOD˦G,SA>絎Hs~F39˙'#"`rÁlc ]V222f+cv/ꃩcrvK*\?\.ŗ{lu)NlH͕ڀ:P 6OGE"kȑ-Er6#F:M=F+muK7Ft#̢чCx\`]Og[K&C?"ͼpw>,B! e5sLϞ=koݺ^o :_i14zPD!lޭM ,=Kwq9U=ѣwoozеC:z(gU9j{4z\vF.4"EEx`_i~q@rY`AD9?סl,E"$&`z+d*r ݝ#W[&7LF^ƍgGtMa X֍O-]G/]a6pヴ&M 15cƌiD6vX{}o:£mOilZDsŋC;"P"< 45v)"`rCu3$!ϵE a w3DXq !6"`Ɓ>C,BnލEQWE!&IENDB`libjfreechart-java-1.0.13.orig/docfiles/HighLowRendererSample.png0000644000175000017500000003545211173030414024647 0ustar vincentvincentPNG  IHDRXr5:IDATxh c3c c1cQLBqb!yu#2e6!$^WuC^JW,SPJt5YC5Դ(lZ<~8q>Nwҝ^o`to^y>s)B!B! !BB!B!P'} 8B iV]v~a/Y}!g>z!5;;[?g?YDZ__G ! X:qE'O 1V}p/| ,kTfY~P ?Gd/\%dݰ2BBO=_תZd]yMS7W?G?Pv->677CBazO/}KVS0n%ӟ^zI_̤)ƨio7]\[_6m_#p#k#G#ZG^SσߺIMG8Y[oJ=~TSSSnZo[[VI]w]W߹W3gΨo}[ze}b{2H^jX蘩t#k~uR?Q+ +M_2YG! u-`mq HA~|ŗ//u)+Ake&e=OS9{ޮ]re:׮]۵p|_3O@挈Sݓ\jfz߹weeEg^jXW3nkɤ>Iǂf|EBVN\-Y/۪wh`Y/^}wkzWv͗^|"Y3emu0N>U1#˗mM2"h@KsQ+?T~jګ 3Xǀ\.z4-7+BZnS붬Yf Km !1KHj͌&:NKDRc/E&eNFi4J͑]& Y`gp{dZ X~~2Xwuq@2_8rzdP?{6ʈX|f@5H v,=V9'`BBXly _2mNH6x/Mv}:iKX.23CF (&)PlHdkVu"ƨ~2/~r{~J6MNqf,|MM :F! H"Rg$YbusGBX5qA0B! !I )uR"!]w].jB!B!`!BX!BB!B!,B!`!BX!BVON$G U<裡'fcbb:hz+xwCO'''Ư~+ 曜'''EA`qWxxx`!j ??,OOO,   "]'Ah<<<Z XkkkԩS*0kvw:w:{$;w4\F<<< ,` 522)E=}}]9rDݸqc_ٮt:lm:ɨ˨" "%piccCgD:ھܬM{ 7\F<<< ,`Jtu|'Rj{{vEYИ紌,???$訆bXӣVVV4 .ӧOyd]gyNˬ`eYSSS 1H\}Zf?d͛7?7-MP>oKD"ke.I^!{ed:? " 2X-EXVk$Y-s}öRU\UgF. vOOO XdRz=3ׯg}V?99Yk>l=STe`XN ~ ~I`+鬑@ꓱ =s]Z[--- ݌888Q1,<??𤫛ɝ, |"#''{],j'?,2Xy ~ ~ `QEA],<O?`!,j'??pWdeqxx`X` ,2X]Xy ~ ~j`Q;''A `q'''3`ɃO:"C^Þ[妈, YBAhbjqqQ___WGQ7nt:lm:ɨ;e;d`xxdXW666t6I$kپ&ڴnxx^C 5X5X>UT4 dA\h4YrZv`"??`ՀU,k{zzʊuuZu> XSSSEv˴@Qe73_fOȽT*iI$jyyXd`u]g< F| ^jQ2G>rv*ni]/ۡ;]uxB- X#־L&5H `IXG3~O_7o Ek؞]o 1訆bhd=-2ryɎQ}=qc`uzNR&H̏ 5X X`u1B Vkp5X܋Z-500y*˻ꬢhe`X`qPw `d2}llLϟT+++:$%)5\fm[XXн=STed,2X#d`Xd X\NgWښ&&&TOOT8-`u_}M;J`1;#0;vjJ#E ,f,;,j,j,L "E E B`mjm]5`kKsUrX,N^"ս0<:M V5X5X"`"E "`XuЀՎqd:jo V;6b,, "E ,2X,  ,j,/ "```;~Q::Ĩ `ɴ]<=w'`"E}, VP( OXL-..6hifkәLFx^v, +5XA?,j&%pjccCgV<Wiyul,2Xd`XdX}}}R6 UzY$ hgi]/,N,,˕@U,mב,tVӺncgYkjjJ$ߠOf}c|n7Ni7凹n޼8~ܞ~4sv`C'v{n/;|_9or} t{T`H$rbuv"E,j qN "V5jkkK U\U;Fm_紮XE 5X[`Q`YL&ujeeEgd89laaA3KR|N6`X`Q,,ˢ\.FEҫommM_ZZRG yWc[YqoivC``c@ҠXd9,Fr,j‹'`QAW{`X5X`X,=X5X`XE Ժnq''nZZ[ # "``XcX`"`X`X`Xm, Xi`Xd`q>Xd,+L@w1| 4epS4Z/?C>4s,u{XV[2Xwd/kq޽`X?Z/ 5X9bQ9ŏ6,.uu]SPܩm񭨱fڿZ KtA] XBAh@bjqqqr;u` \jh$CnRR4 Xx\mnn֦=., gcV__IS*{J1j{{vHdO1i`X\x>`T,kO8f$%5==˘ VF555{Eׯi9`ܬoשcv}7wvf{A<~l=;=+ 6;"R&H %F ,2X,KZ%-500`hYEц, >+L&u35I3NW2ܜ w`*j ,.<} X\NgW`---ޅ===jppP]Z{j|~?:9z\P`uιo!2;EkF8a,5X`X|}{, {N2X,'}G :`Zn,/m1;jq(Պc9i`c,2Xd'l5X`X\xb, , ,+ Nu>$, VC g 1KD , l@ X`|6M` EغqdqDh`x,gj+˻߻wO;wN={VCĝ;wl_봮:q`YKX`uwBFFF4@b1kP3gvV:Vl6ď V߉1,7 \j$CnRRx<677ka;e;`XGg[u׷DT7>>&H$:ͺ^`XE` `y5::X,8qBhkիrZv,+`MMMvd@~MAf}c=???AN[ ݬPw3c{8w}}wz{)~vM|~2-獟W+]^*4$ \ `"՝YvqD+NP"VɰQ&thNEQ9e;`X`usp`XP2ԅPR>66t?sT*yF, "E "Hr:k$P$uWUne, `sF~c7`X ]JGC8]<)MkdBXj,,+ 5XXaքx3, "E "`X XV'|N?gZ`̱΍, "w" n A72Aqw E V+ ?x5X3C駟3ʺP(A , , "UtO:BOOu@?^Ɗzꌱjm uDnv/j^ Wqn߾a`"2XC Pߛ7o|kA]|9&(ח_ˮ#&I${z$`QE ,j"EիWkرcE( TUo֖]&FHM*6\F ?`X`Q`Qaɤnbw^tI=*d>#]%@ca(p%C-6-,,ށ枂T2j,j,j:029Uyi\*$k$K5=$+DKKKzx)Tu V2X/"u3`u`1;$xG5X?q,2X`Xd`.',j,j `I/<,c ,kq`"c2X,2X,'o6euDRE/5X-,?θP!?:)I `Q:Nnӣ"NpE ,֮^zI?"g'Tn%! X_jU>(߾}?Bd`;m `O8,z O=E8~oJ FM  E *f{I{A]q,] X$ks.gF"uZLF?w:{;wni]/!]?#d8F`j9` 7* jddD⢞?99VVV4I\tI'J*ֶďj8F@H` Јt?sT*en0AA0V K$k$P$dDx˗P sPs('lmm Xŝ~ ~ ~IW72;'''5XUX]&j , N ???h<<<,*<2XEA`qWxxx`XA <<<,  ,]~ ~ ~d X.]R:uNWŢ::zh,@ `MOO.79-fMMMvd@AB?:~/~uZΛ|@J% 6DB-//Z6??3ENyL,OOO`Y2Gju( lr*6\F AAd2}llLϿvZݬ 077g̷{{ R`'''\.FEҫommXWKKKz588Q1tu!#sWxxx`<\EAÞ. O?`X''']~ ~ ~ `AA <<<,OOO,  `!j , N ???Q9XX.]tG2olle^Þ<<<:* jddDV,SzZYY.^;ifkd2jffvNz5XAA V`KjuuUd$TOo<Wa8e;d"??` R4~j"Ȟf@ XSSS 1H\}z}}=TO߼y?qzrȽT*iI$jyyyײy)2"  ^jU7rBwU\U;Fm봮PE''A V`+LBs,)v]VwȄ/J69h;`''A V +鬑@[[[A] Xŝ~ ~ ~IW72;AA5XUXFGG54EvZc22X~ ~ ~IKD"=0̓dZ:OO"VqU.wYEц`'''d2}ll!`MNNql_XXн=STeEAD`+鬑@[[[sJ&&&TOOTuq<<<&BFr]???y =sA5Xŝ~ ~ ~ `.xxx`XU~BAA]~ ~ ~ `.xx5X xxd,  GpWxxx`СCyyH3{V???P( XXL-...#J*֦3ݾӺ^C,OO V`KjuuUCƆ&5nqY ni]/ۡ  `JXe]D4ZYv`qE ~ ~ `y5::!X,,;hNݎQe)ݎl(7|A?^__pNy"R&He2XUaZMk||\]ShvNz5XAA V`+LBs()vkX ǟ_*]iF!E@V.Y#"շf;LyFWq???𤫛ɝ ,  ,]wYx'A <<<,*OOO,  jŝ~ ~ ~ `.xxx`XUA QEA`XwZ'''E8~ ~ ~ &us `qE ~ ~ -`ɴ]޽{ܹsٳ$ܹp5XAA V:Vl6dLedP i Xx\mnn֦e; QETRm"144fgg6"Ȟ&Cc2+XaԔ>H A^__7op6?޴7A|>FGG5PEu$%5==@ޘ紌,  B[^*4$ \]]`QE''A V({Vպlr*6\F xxxJJ& PKI3NW2ܜm3‚h)J.#Er( 0I5=iiIMLL588Q1AA#sWxxx`p '''{??2X" <<<,OOOBd<<2XEA`qWxxx`X`Q''~ ~P`XiX<*  Cy3wZ'''IBAhbjqqQO*d2jffvNz5X xx`VWW5`mllL(zlxxvNz,<<2X>UT4F"=̀ynj PV>WŢc{BxunǨϲĄ/4l_fif:k0gyH2?0P!nϙ0c'/K؏$iZ1C\zU ֖?:#&hsN1,du/ bD>ϫ۷o?S]㉗s޲t:Ο?_rJCyd Y]ɏ*k`>y9_~X]$y㫯r˂X'N=ziDx̉ bD.DB]ԗc'^Αz553 ըݱnZÇy9_~X]")F4Xz'4 H5;&H zn:yޘ٬n.O#>mX 6 X?% %ip+N:ݻw]D}?R,E~x㥞'v?n~л졇SS5 k+lX?% Ǐ^_D^;p9"`ߟk׮Z5yp8y"̥C$ed8/L&{h$n)JY.u`>y9_~X] )]]]m\NCE=O o}[B zqp;ފ>şFc*LNj'^ҋIzGI}0C w}Q ">}Z{+=s kP~C} ?~/a>^,B! !BB!B!B!`!BX!BB!B!, FF! !#r,B-Bŀeͺ~:z~c۷՛o'ˌҊ\~OJX!`Kh4g^"o~Խ{ԥKt*t,֩7OUǏi#%%ӒBX!`y,c^__c=BB!#`%sB7nd,k׮g6  ^! !&K&&&t=4\.X!BB!B!,B!`!BX!BB!B!,B! !BB!BB8!,PE! !p! !p! !p!`!!`!!`!O`!,Pm/B;IH2Nk ݾ}[E" !`!X^$=+ z2)Vd2HN0`k6K eX! !Jzu_Iٳ^".>nFt,7!YW:]#B,!`!`!,",",BB8-BB!jJoLIENDB`libjfreechart-java-1.0.13.orig/docfiles/IntervalBarRendererSample.png0000644000175000017500000003637011173030414025517 0ustar vincentvincentPNG  IHDRXr5s$=虘8v. <ώwkk^o3μ<B!J&@!B!,B! !BX_J]!`!4뉕mj oʯo\R>]O?T6m$h': yyyk.Xtq/5;<.w}}믿.K.;)l] XYYɅ0Ѽw݄g1sCe`!A+ӗ逥_t999v},o,Ϗ2<< `!`!埮'^xA~~z۶m) \"֭߷RVVfa ly {쑯~9//b{??㋋m~IQQV4kݼOT>|8c9A7HW3]kJ4ߣj??Ӻz+ $V< ~>}B^:BB'NG HO~'1l>yKOGIx%m)5{,w8%oAӂ>kYP 78m߾=)O$r;;;g`4p'پE T߹sfp4cmsMG'bA@[%%%32@V_}gfdT"7l60(Nu=#xKk> ww{`! m[5kA@O<oYZoF?'1tx7͵k_RJ@F;0~+2wBl)nNi>~'=PXt6y/Y$xKueXBJs;R=hNMrusNw^˿Lw"M;~gmM S],oR`!`!+8ZR~ [pJ$򺣣#:_B:K MzIGa{{_zw&Ǻ3a~1=ջd-Ү"5XBhU'D|E;^K}fܹs[S9h~+], JSHWk5tZIv;={6d-oԻUE>DB1xjkkg:ǹAk.rw+xL||_G\I;}p%o,{Xk\k"S}gv]h<'A6iO9rr7i͒;: s,c6y^LIm=w6PP썫Je纇LmK4;xD-݀2YzW'wN'w X!BB!B!,B!`!BX!BB!B!,B! !BB!BB!B!` +1Û7ou4yӦMlLlbLl>2oݺڱcN?3&61&6 Ę, c1ŕ&&61`QK11 `X+1LlbLlXc1`q%11 `XZLlbLlXi&ׯ.|M{]~k}=yrzsimf>n_r5ܾO>\>𚴴W+:}-_o!gVViimZ,K.E+''gAf7l][qYrLLLĭ"ŕ&^s9ZM LnŜ/EVӒ}Mdmz)gyYYN[Du^ٸQd&-w޲EdVmD^zI7[ߚ:~禿C Vi`yy*-t4;g͂ejll4SZ`a1^Y7 ;TZ{2@a&;W`%dW U]]{fm9Nzנ=T`џ &~b3[̙31|Emf*$R+JrgXd 0&61, gj1cj,`%d, cb`aĘ ,1`XEcb`QKv&`XE1Xŕ&d, S炉MEcb, c1 0YLlbL Bu., Ø&`Xc15X`%&d, cb`q%11, c\KJJ֭[vԔTUUIEEEtÍ.'lްiRXX(SOO, }J'Nnll~Nr6m;&hnHQQQt6:ML }tR V^b'c] DA 7l.ADHcbرcbܹsw^;M ̀qNaMӬU___Lڮ1Ƙ,++KJkV=Xw޵rrrf4nyæiU~~111> V^WSe{0sYoB3ҥ/oL.\-?9>ɫޖ;ݻocoߖ]0nˁcomٳ 3:4&~ 3TU6v[19|X?7#G szXݻ^;,\53+kš=rZ(րhgtֹH]'dILNb`6@)|N=͛r֘ЬZ,:]`ajKep@#GX@Qՙ#2Y0lٖw ݃NAY8u. J?* z7Zk\ l`y+~Z0_`q`=]{o'`ѓ;=SK15Xs9kj, J c2X `XƘ, S`X,LlX `X`aL ElXŕd,L 0`X"1,,Z05X`abd,`a,+1`X&`X,L E c2X `Xcj, `X&`X `X`ab`XE c2X `XƘ, S`X &6,L B5XS``q%1, bhԔTUUIEEEtÍ.'lްiRXX(SOO,15X5XVgyƾz9p@ ~47(:X[[E c2X,+b',)lްiqki" cj,j[n|t8//oF3\"MӬU___LZ+glp+}e89/ sP2^|%ӟȻ\}=~@NKN5?Q>+?ـJCC}pa@{WyKΜ?]rl\8`N VvbIʕt& A駧փ >P?v+.~ Z S`=.E Uyy\|9fFGFFbjV Pؼ,g W`eo- vl-3י#Om9Nzנ=T`/Z477G`X!` zN"`mf^v-j?X^iW> k>;, Q`ѓ;E "6,, `X`XV, d,2XE B5X  ,&`, S`Q`X`XE "6, `X`X,, X `,L ElX5X`X E , `aj,, d,b`X `X`XEd,2X`aj,j,, Xd,L "`Xu.ؤ ,LO `XE ,, `X E Zg6v˳v*ne6U w1;}3E xjkkM7Dm)lްi7AsC(Xd,L "`e`ib'CCC7lZnnnt{?88hvZ05X5XVvϲel‰k6>8yæiJ(jijj`X E NZdtttX虜cǎZj̘?hlMӺ|k}?>>nfLLLĭ򂕳Weee26#uyۗ<(? jx;lQ̆y`vΘ8fCx`~Xycf=xUQ~B؞=2kxCel~yXeN߻W̼=,f^k*[n"kvz  4sJ7SA;jS]]|Y>lי#NΫٲfyg[݃NAY, "`4p٤ j:Ç}{_9,`4[oE?X`XXϛ@qM < 3ڧzsڪ[1,,`fv5X^݁ RХKbJy!&`,2X,j,b<x@`Xd , xOa|9 S`Q`X`Xx:ٳGnݺeb"`,2XVZ+^_Wv2Fwލh S`Q`X`XjO~)T˄=d,2XE \ߧq=k/ǯ>F,L E `Q`% xv}>d,E JPh-bz,m`~05X5XE ,2XE "6 aUP3!s,jBA*^&`%,2XVZ|466Fb uPXX(ׯ_`a2XY "`%)RRV=q蝅l`aj,\,,+I9s&]v_׳`Xd , ݻg!KsѠGX,:  B, "`ºbXx,j,jCޝXUU% 7::yæڻ {냬,2XE "`-`#W/C|CtZMubEEEy,j,,,+3KnGRb'Q?`5ˤ]=ăx@6o4ϷgeJ3$6j>C Y2Xd/6L`itҴ)}~ UR_N3G{_eee``ؼ-IԻCQ:u~,,M>l%ӽK(UP b 9rHB}[+~~+'},?SE$*=X`X`XVv`X X X,,`ܣ;`eJ `QElR, "`,2X+`!,,  J3`ݿvylٲ=7X,,`>*I Xvs,j$+}05对Ҿ, E`XIJ!:>n=Ss,j$ 27oZR6'v "`%,2XVNFuѠ,j,\,,+]t$uWza{{;4Xd,2XE B5XE El ,*j GX,,` ?22]5X5XE >|8c, E `X)f^6GׯG7N,j,\,,+I?>n7 Ν,2XY "`/FiО7`Q.B,,  B, "`83E3`QI,  v ¹ٳ1ˬh~6lްiB)((zzzd3E `Xdk׮>9-GAFVmmp}} 6m]7(:X[[E `Q`Q`-<`Ż9ݼy Y RؼaӴܩ44,2X,Mų=9hKdްi`UWWKSSE `Q`Q.—L)x-}ظ uW~||VD,/X9{UVVf]A| g+`%{{{{缽f`۷o^g>:u:}䣏^ik21CyͣRYyT9jXਔ5?KoKK5_;v|鲲/]^>m]4W?˚b*Xzџf?2q6UVVʲeb@FR T3` K׹F/C`QE |Yw2d"W2AMWMX"&G/CW;J?݌Mf9kLpk V,, :  ̕+iVÞ˨wylYζ'kPt s,jhfsX載^iWN, `wwߕ挶#E gzv:6'zrs `%)+T,2XY `V*t钉-IP뮴gX`X`aE X&~ĀuiҎ9wm,,, `VjiiQsw۹>, E X&݃S=k޽{,,, `V_SN}n``aRP.{;`Q`Q,b x, EX&`%b  X&`Xd,,Elb:,\0, "`% `!, "6, "`Xd 0, `X5Xu."6,``qM ,\,j0`Xd,"6,   X&hp,]T򤴴Tn޼iMMMIUUTTTDmtt4p9aMkmmB)((zzzd3E X&}_GG uSSvZmm6Ђ6oش/7nܐ< cmmm5XE ElX077׾@yæBE X&Հ599)ͶPMf@8yæi֪/&U]]m3i5X,bg5`Xk0ݹs':.hx7.l][qZ)q볼`UYYMϺ+}ldooo|46's9>"~lYi?lli[1d_zlio1?u[D PEϏ_M1$"%%"f3E4b6U@N2ts%f[۷o^g>:uζ8xp<)/K$%bb3b_ğ6q1q1q1q111WV&"/8m]Je\anb7b.Km#|olEW g}Ç/D+辦&> V`!ze`Qߙ~ 6`UzGj9N҃rMf9ḱWkgXY`XԹ MKJJJfyNkPTuuu?͂aζ'kPt  s`aKΞ=kj Ai ݻw/~j?X^iӤOv]2ٺ,<"6,zr X`lb,,2X&`X c `! ML ,j0E  XŕE c2X`QXE X&&,, `Q1 `X, d,`Q,1,2X"1 `X5XS`! ML ,j0E ,,2XE ML `Xd0E `a,1`Xd0,`XE ML ,2X"1 `ͪ&s*K.e˖IEE iSSSRUUeǹhr *RPP`;f, `ama!hrrR?nZsoCf#G̏}!2X~566JMMMh},2X89{c SMlb2Xxe4ݯ$?22S;J!@a&5 +^}E ML 녺:{ǟfyg[5w:gXd0Elb2XVBR X{_9,©̙3}1'wzr'1YM sԹ`LlX"1M `X`a1`q%`LlX cb`˜,&61`Xc1`Xd0YM ˜:Llb "1YM c `! &&61`Q1u.`d 0&6,`Q1,2X%&,j 0u.`aLlbb,j0c d 0&69Jۋ/_3njjJ"z |ؼaZ[[P {,j0&61 `e'`DUmmap}}=A)lްi xˍ7(:X[[E cbVv7؜CCC6oشx~pp0Zc`hKdްi`UWWKSSE cbx8޸ uW~||pJ[+gl p}ۯ*_}挌Kggt:%t`\^: 4Yp4iSND $Y|E40iੳD: PYN嗧m`4_?wh~J ,ddl3eXl J!WccԄgeJo/d`ad1`mܸQFFFbjViWMf9k֬5X,1J#`;wUVV6lqһA, &&6]l`y+~~+'}VgП !M e]\aLlbLlXc,`q%1M %& `X+1LlbLlXc, J cb0Ę,+1LlbLlX1c J cbcb0Ęŕ&&61`a10WbĘE-&&6, J cbl c1,0&61 `X&&`Xc1255%UUURQQa!F=::aZ[[P {ټy3ŕ&&6X$=oشիWKܸqC(X`LlbbZ\U\\,ᡡ! D6-777:޽kDȕ&&6̀q6MV}}}1jijj0c+'''q6M\R&&&gy٫^xAoZD30 307uV2Xfjll,B7HLԪU7Y`ūB!jw9谷/lٖw ݃NAY!BY XTJY[1,B!2X!BB!B!,B! !BXhs=g;^G ^F$}fHXt,[v3$#bQKxeTRy&;Bb v>猈LѶmۤ799)Ǐ 6͌M^ ] `TU^^.---q땙^ϟ??^cǎɮ]d3:~Ы##/YĎדռZ;q{߿q_ȃ:,b3ScӉGv& m|||.^h⁋=^kkĉϭkZwމ^5577Kuuu;Je^ "656U=q"b3bSaM3`$ 郶ݻsa O>R=|0z@`JMXf d`.æٴ;w,4+iG"\Mwkѣ4|Ёʥ%U/R\@mft]|ȉ'^FNN5BX^=*>)9sL`!,2:y򤅢_}ƴ^zIk֭k3\ N-[L/ߏN|l޼N3<#K,YƥK3jllq~JHر~WVVvx͚5u.þ-S8~3{,hݽ{NS@AX!v)|Ҭp0-[q7oތ~N5 JArPs4O?]v}S={ݻB4RZZ*TAM~A͇n>7ݟMouGV6kBBi3C^rrǏerr2!rMv)Zj]Q+VBhSՁlW 5AhZ mذNlD͂ND$;pX!4r 211az^hyc@ܹs3ezzz8 իT---vzyy-@,]6y4" 4M݅! !]O箶J;TzB+l5 _WiSi.[Dw!:577ڵkrV֭[vzoWj}u.DUB,;+]˗'4o?9~sSSlݺծSEE XXl۷KmmLNNԔ\rŎ{Rpqʴ߼m6tqٰaV͵'x:vڵKv-򊌎F!RTT3mmmfVLNO27{BBe)`mٲE~m9zhtU0|yGXU/_Y- ! !'xfMJKK֭[vڪU޽{y\]~pg|ImX/\ ׯ ! !̀fZGO azHaa<2|ٱcGyBB-rz!f_*Ń8 J^^^FVfmzB5BB-`J}һ\-Z4z{gJN#FgNIu'QJ'gonooBXIĉ[k4}0yO Zc7md`#3{ߡ/UPs[i9BBe!`!5BBqe_#,']ľFBqEk']ľFXtcB!6IENDB`libjfreechart-java-1.0.13.orig/docfiles/LayeredBarRendererSample.png0000644000175000017500000006743411173030414025325 0ustar vincentvincentPNG  IHDRXr5nIDATx Nuw}$;$2% T2d)Ӭhx$2d(C)=JS_q:kl{ݟz]{~]@ qBá@ ,@ @  @ B ^; @ ,˓P쿓$ (lժUrŊoǎ^z%˔)o2-Z$nj?fh=iРArСΛ}M73B X+;SN==SD,L^rڴii=Y"G ``]x'-g}6'$]%+7}F XĆSL9|:dW_}^ԩ\n]>@>O7>g Lݻ@@@u=yUWOX x\Xd6mr֨YQOEdK/tfG}ڵkx2˗Xbr_{,>hD)T&%K9?~X|,u߫Zjw|*/rw$O=Ԁ~mNJBؿ]Q?g܎oe-mܸqGěOXas $0_!XaTN̙3ȿ .;믿pqL0A7b?~oS|.KQǧ\!+R:}y,=ٿ]J",ΌcO9,yge}ݧ?( B Nkʕ !mr$3gg}syӦMXryq#>ֿ9cƌlX ɫk}Ws)'띂ǛD9#qX cv#l B VxZ">1{۷-ic}|Dz|mSS476mz.\xB7ڵ 3:A ;>lL7q,וBv)rf͚k?S٧Rsl۶B@,>=~$gQ &-Z[872uCޏo,ٯɋ 9_Իw~GtRsu+'>*(`He÷gT|"6|?ׂgesX2X(Mn̫osoof6tSl|4Q{ίOL, 0g ) `!)FNR@@㮻d@@kcL}Y@ ,@ @  @ B `!@@@ ,@ @  @ aTz衣^yv5z @_}O \d޽/}AoW<,ټy3>7}`A`a/ @o /,.7}`A`a/ q/ @_ X?crȐ!  0 7@w +ܹsr֬YÇ̘1#ٱcG XFՃ`a} zV1sĉK~E%x*1xp௾_?E}Xy=o5S+^?tyW} W^wä`T;VZco8 /' gXgVϞ=;w}0AuyC,p/!X M_~۷Cw`a}`}uƋi X8?~k; A ,/, {7$~`a}9N" &X:oH)X_9` {,֗/W@@ X8?`m#yCW  (?@`v^u  },p `Aw`a}{uTk+ ~ !XX_ X,3,.;oH`a`A@^ G$X;o`+2C  K^ + XXg X,OU~sސ ru,3,.]>$yC   X,/y @ XػHU9oH|r  S7$`a}9NyEZ {.X[H~rސ:` Kv8` { ^ o XX_S;`a`Ap~<L֗m+2@@ XػHM~pސ  u,`mu^,.R7$`a}9NyEj Ǐ]6`}!:صkWK6h .X:oH|r ֙.٩S-[p @ X#GL\wė,/)X[W@Τ`m6 Y'XIvސ8kU,3i(XuMnذ!yC'NLfdd(Vd4lk>sa5+*Z9+&ɖ 6a$[h^umr^1tXǛo&o2S&o6 o-Zd޺$ɬ`e 8qG>H=f*}lg#XG-dԩ8Eǎ{={7p O`}!ː`v^aF6:`&qS@?6nܘ5j O`}!Ӑ`r^aF>p^2\ѣ !X8`A X,L kFk5 A "Nu,`@pސ̐`yZ"cE|$ w@ X+yCSC 3yE\k# ֟$ w@ X8`I +L q'[֓`tސĐ`yZ"N; X,`}!!: $ w@ Xd :Ϝ7+!X`'q,K;0#XWIMr  X:oH0"XH~w^9C X`Nr* GN`%yCb uy `,Vz ֯+J!XH~%q8 fk8 /$ w@ X yC# `A X8ׂkćk 3yE>; X,\`I 3yE\k= O$ w@ X8!:NZ`A@*# k +L8`VC Fk% ֏+8gyEƒ֏$ w`Ap  %+bqH@`Ap+yCb!yZ".{; X,pk f ;,V`}Gr #XqMoW@ Xa-,`A$yzyE7$ w@ X8!`yzyE\k- ֿH@`A$X8oH7$X_;0#X Wd,`}Mr+$ԩ#,:yCb `A XLAp $X7$X_9Mֻ+$X_8ܱ: Kfk/I@`BիЪU1c' @ X%XWd`E{ kС9U&Yc)̣8d~uݫqKNnju摑H=Om(~dky΋¯U!y-tOֱŋԜo7.!>qKNuȗj̇[.Ç'ׯoVoRQ5qkyFҭqސXm.f`dm-,Vs]Sa+a/Dc'6mjS!:켁5#X7$VA X)XL?öH)}9 XyKnذ!8rrs%ǎkSEuy ``t^aF:~ixWsx/k'C*, 9Rw'+<̙۷onݺ͛'Ǐo.BVkJC +L>'qH%F+|?`5{ïI뼁5!XHV:oH0"XI>s^9L[i_[T^'!H5_f9#C׌`pސXnH>u^>- ֧$8?͑jB<?7@ X-X80#XsLaUsXZEI0±(?̑j@<H㼁5!XKI;o0%X;0#X],XEjNqIR@cT`}IuykF9oH,`AZآ|O9 XJ8p 9bĈdÆ z`Ϟ=3fO;o0%XK7$+,'ӧ=mۢ|58 vTX~svkXe[n ]Jv`5!XKH8oH,1$XۜWL[h-*Ssx7kC* j|,>r5s`Ьs[A X!X7Lo`RիGVg `"ykF9oH,2$X[W`jJsVTX֯H5߭>V.]ٳgO X,[[lIv-;y u\C dlG_lQm58 և$0?_̑j̲te˖u VV^ N}8_} !XN&}8G)cA>s@Bb>}+p͚5M9 8_3{k 3ł-*Vs` B 9Rw/yO"L f!Xmi- fTOH5>tz0 ^g$X{7p,q &fk k-*RsʘD skTL>%ykFuސXhH6:0#XӜL6aTs`m$qHyBFOc+yC]C 3à`UxS).8j,X_u_~~ '$X9o|M$X7$@ Xy)Xi-*D3+hco7p,Vʂk 9=[[TaF֓8@5G2K},ӧ'X;Hqw7$u+T'7S;u$0+ȏj|,2`y)! uq3me ,%uGܷo_k zk"דfO7p'޹}=|鼡bݏׁ`-q^1oد/:\>EIjNC E7\SltRkdq :믺uOڵ) zk3]Јcxg,HN/4:b>7 ZWLh ~lr9bZ%80rj=4MS;vLܹ39*X> VX Nl-#擘iH9`Ak}vJTqtX`Q:,A#m/l_O4 q>!jDGhPlW-!XN&(7A)cz!ϋ sHΩ 2dHr͚5G.tOw:HMk?pZ=VE`Mw2g`CWW`51Fk1mcޣN< n}H[b:hӦM?Qw`m'5UֿӠVX 4's_l-J'1È`-&Z輂s6!X/;,X[mq+jNq)QџO9CZ| ;wn_~GM4ڹsiӎ.3`AM?pZ=b%X;>[` $ހ`AS9ۚWs2#XC"!aǂ5XOѣ4 5U0#6 T'sZ| o0<Œ`u2`}h _Vsʘz>;%Χ{@`G{}a9uz,a}QCi,h罹JJb?pZ=b%X9brOb! G`mZDۘ)Q~E/~S`o9su0ݎ``*aG5ɜ[I``tjBcp-.dFޡomES  . !wO,&XSS%nL8_L H G1NA*;V)N}vJTGw-Z EEE RS%nyj`ɜ[j|S o0<Œ`v2e1+>5>;%̥GEUZ> ʕ+OY+Cn1eFh3>;%*Iε96ZV :SS% A8_I&8hEW$&,#ն(z>;%^`ù|/Ăf-5U aGZom. 0#X/8,XlQ58 ֛)Qio֝k/̷rNqj= Xi&XPS%ZA8_WLaOb ui߈ [y^)M#o֞k/7rNC4J`qZ=b#XsH;|k[{OUC5yzbT$X3Stz_ 6*X_9۩``J2|z`dc ,!DC{u=e( ZHۘ7S4z{V'#tN+k /2hP,WGk)V/m1218Y'ӎk-J?dF^ʄ0_9`JdZVlNm{.1#X`)MH'Ӯ!%(=R)cf|k:}vJTJw0Zuj=އ``}AMhy j#XiE"X|#'Ӗk-JPs`MNB`y^_/Xz@LvQS%ZKb?pZ=b%Xp2Z]OCŧ<<"}k-J?cBޥm)Qa ]sjySJ#ZMsjD +d mR1xCŧ<<Œ`=d61-X2fGgD\`I^_Zqj= Xi&XQS%A8_"XHF;@>ݗ$^6$X|#Nu4ڢp58 k)Qa2c/grN-84U4?J(XZ=wLSaF;FK)N5>;%*L"SN+cjMiP,WG%'SUl~5| ( Z@ۘgDW~,9|,Nf*||zF"d v[)kHGL4ۢԓjNoG&gDy~v ]Ωy/3fH'Y~d ={RVFMhv7 w+zzVm{OF=,> ẑ-J='D`mx{}a9˩xG~6lH>|8`̙:VRS%A18_vUo uRk-J=t*{}a9u£^zMYcY'SUh.I1$XW'Lz4ڢjNqHy ?^_圚z@!:|뭷Sq4PS%A?pZ=b#Xo`=dC[lѧ)S>-J>fF&gD X[9^_-rN,XZ= X:u@9U&Ycݻw'7okMT&,Xs5U ˎzv9's&ImEb>??j=81%u`"1.];9[7;믆v;Vc9nQBǿ7?+ƍI`lsjCu[:x`p{޽c{k#5U]4(f##Xiy/™',XB>%tj=>Ȉ,Dx->#X_tꤎBKٶ(ZH$"= -S?kg QΩN`|Gak9 РV(-O~G*{R΋|J'ƈ{DA`؋Z`B i furNM94} TA18_Q VB`%~Q8-ZڢEb>vj=b#X I]+PlxFwP3lqP51ɵ`B@ u0kwsj=BKVSS%nE |zD)Xk%F`=pLZWۂKAN8 _S"qh߶h2#T|zD)X?|j8yE_j۫ߩ'd.{r7ܧAB)ש( Z|`ey2e/R9nsj= Xi&XKXA18_Q ֏zl`KJ\:r-9ǡ`ic=Ju-J TsQU9ZD=ɅyO[Zw!X%X ٚFU|z,p͇(j`-Eתb> pj=3׶n! 6F&,X՜*8 OŲP WP `-*q]W`}I˓~Qȳ ]ǩ NwEI\:r 9E`ic$\&"DWk3Bz1uy*fSN+k>5U> |zD)XP@ Xڳ >]zl`]Q5Yvۢa_5f,m kSlq~ T#|ݨ@ie̗sjީ``ͣJB|zD)XhyOVyЊ>`i`]Q5\w٢]jNqM$XqzߧdF,X#Q|# H`lz\ Ez;$X3"/~rdk{9E֐`ic P2u-p%D,X9%2`t9kovj= Xi&XӨu:Рx8_Q A(P`H+4[Vq,=D~`koWs`&H`hz\ ֣L|4 3MVN+]SS%괧A?pZ= gz9=PIkmc;.ԯ rj=Ip_4r]c]՜"X+H1+X,%!ZXN˔ROx֨`Ms©`D~6lH>|8yСI=z`-?*qU;#`⋷U Z'b>tj=b#Xψ>r]ek9qqr,mԤ\G;՜Uk2bS\G' 8^_rN4wj=C=ի[DM-r|z_V:IhW^;Zeq,R+lqMg52,m~ ױ`E^jN+ʵX` e.ԓaIrN,XZ= X7n jQHM|zD)XX2qbiEh|=Zq,\٢mjNq$X[tEePޢm<@ >J=Q3(T&u |dnr*1xݻ7o_5 jD68o߾EȂ 5Uvkj"9^J!3SxVWlѦOvcIG~V-yyQ{)E,㛆 #N1Rς5PsD|AZFD"ԙ¼"tu3Grl|{ܧi`OMł?pZ=z@ 蛗9S1?BA-3'aROu-h9K(BKC`)9PŌkmc5c#rNW4tj= Xi&XPS%.i4`MIQ>{M|κթx'BF9!K L[u-h9K`MwB(rʵ`C˔8{F`<#tEF5pj%MBfN38_Q ZDPh7RKǼ#O89 `+\jNTM ,m `  Sr-^X'Sa/p9˯sj=A<Ƽo\k2-O{f|XzD)X[HvcqrC&؝rl˛9qR=6F(XI1.XmQSr-^XO `{VV ֓TCfpZ=D8'$n;?Oڢi)1Z &̜Xpzd`Me՜8g",mn WW\jN,XR-7hӏ>!POi>)p{}asSJ#M jDCfN38_Q ZDr!wEϰԦ%| wj=ގP> ;OV+:5Ss✥zP"ƈp @[{Sײr-&G,X}`=!Q^_'Xz@LJ\|Ci#Jz'%T`#ȧrCϨЅr}6Ss✥zX1(u-Xk1)b>!P=&po{}asSJ3z*qQ WG2-O!`MJũ`%r`v`u\_ťM՜8g#7I1 Ve>[Vͩs$X|QyTk!X,J(XZ=<. <{j|OvNk5 ZZfNłGmX[\D͉s2BIYJt[">Lb]7*Xn/z@LQS%_2qbjC˓X6䮨@= | uj=$Xxqz;RclQ,cy5K#6ڕ(HQsXFk:mc{ <6Pw[SJ#zT C&NL38_Q hZD`a[XB,"e$XYr`zk-jި9KX`AI!{lhԱ\$X, +`/rN5`y%XQS%5 81|zD)X/$: <_{`)Ʃx+BZJ\E[\r,cI5K#`U\"qSr-` <(cS1^ 5UZ WG-O}ِE+ONGkڞSOV=-.i9KX`M#H`mD+5ZXzSv: u09`i``I5Uu!'V(9Z-eB:K4:_NǛ {$X i919n\E՜8gG(X`icuTł,XJNk1:BFۘ;EnU_t{}aDZոک`` J8_Q HZDP%BK]<r`b3.lGEjNT T,m[jU\"Rͩ])"T"Ǘy0j\z@LRS%'|zDghym˄uZ/{_ϙZ |ALqa[[\@͉s BzK#,XwjNmKɵx!b)QNFyZW:44罹J8_Q ֥C)9ُ9(k. l"lk{:5'Y; ,mUrcs9.%⹈;??U ,=OF{ZȕN+>jDkCn;O38_Q C*R 7?β7{E՜8gs#`icĵWN[sͥZ<`NۘnLs*?8^_m2N ӭJ\kQ)Bw5k5ˁYp`)9qR=ގX1nQ*XJNJʵ`u (XZ= Xݻw'5jkA5URݐ WG=evOno)\FMix񴐛ʴת9qR=fG(XH1)\Vris9,) ?^65F{ZH-mVxԩSq{ <|zD)X$Z nf?f)xS` zυ V [,㭈K#u-BEI$Xkto/+ X'T.XwSS%*^ryj13 VW{)uM3"_P`M9r`i!wwin9qR=fF(X`icĵUBʵ-nԼ\"P/hL50d֗;$X,Vd7ok~y?jD:-S*a~BNVG3 h.&_Lf3"><%)Q#*-3'9-=#5jNT$XQ/衎F!mqvc5fȵxX֗ǍKveJ%M%0d,XZ=͛G$XwQS%*Qn9oKۣPaWGTӴdEfoz|XzLkժ%_eS#Qs✥zLքN1Z+,Kv795@cR27mQZv.X8fՇ*Qj6`8_Q Ȟ&%C)9c-&sFSFE(X$s^㧅YGUZ͉sz 6F-Br-X:2%͕ ;FkN+y'5UU`8_Q ZDPޭ)ԩ`M"s^\W1:URs✥z`'ƈYfʵ-nԸ\G(X6-S✛sn=^_e**5Z+`d#=ƒ!Z,!MGE)XI^9ruGUR͉s1%BzK# ֍%Z `AeN`J<Lڃ߷#I O]rSOP^!zrAF&R[͉s19BGJlqjNJȵx(bjO˔827aQZrSJ9QwPS%.pmYW-jRI]Srj{{s\SḐNegq#9!7dk9qR=^Pƒ`icĵTQrd9`Ix0b)47aQZ|S1^=PiE8߸<\a`wks`iRƒ`9r`ȩ!ƕlhoW9qR=&F(X ƈoհ\! V;Z9*pj= Xi&XړRҼ( -Iڄ J8[9>k p ;rm\&t,k 6F\ ([mqujN Ηk18BBۘLoԦ:^_rN.vj= Xi$Xa,{rMAtڃ߷qj^W"d֔kW[\}F)X/`I85ڸ 7, ,K#,Xltr-E,Xmhgߠ<i(GtSJ3ҞTrf,X[ȉs OJy"XZ=^P^ ;ԐSԷ7lԜ8g"$Xq7)9/.5-SFڝ ,XZ=&F(Xϑ`Ix*X(޶x, K$X$z- SsW\}q,Z]gOS,o+1/S.mJ1hyמr㔖. 2!擿S1!BI}O 6ĵk/[T9K`"ƈkp V;[Vr-PIۘVLj7Rj/h ՜ZV 6mK vCi=} 9c ")G~J ʵ-X|7ЧψR!AԐS%7}FKԜ8g"I1*Tgjk ,%'jqOĂՒ)qVR-NFy VV V,j*;ndk~BNb4ˮ6]DPޅW VW"H{ V{gT9Kx!BzK#B (ֶ(|SZ'NT{}a'T JYeu:[V\fզK;qJ3{>G'u#'I2㔐kίco9qR=P'ƈ%բ_ĂՂ)qV}F*<|c6+K%$΢48߸LxUS4wBs|Nr8 c0rdU,w,9,m JPlQUɵ+BLۘhծ=^_ebrZV V$p%k(;g=} 9qqNBOibﺅ+9~wg 4cPݝ媫9qR=FD(Xϒ`icݨP- ]ğR-M|OF`i^PC9q}aL؃߷k ֍Vq 0,i~N 9u[;USs✥z<`$ƈAk [Jͩv1wF,Xh.C9^_eZrZOu2@B4a~BNo\VZDBNyX,!Ӯuj=F(XCI:rx-{,cx5K#TsULEψ)-S"\C +949JJ\h=} 9qqDBNyu %sZ](AʁY\R`I׶*X흺-]N͉s@8 6F\}E)mQR5'j!Nuv$05B,|p4z؃߷ڑjEB6ǂ%sJm ]$Xҵ- "Y,u,cp 6F- TsD,X2%μT;K^_ReZV VEJiN\5߷ HZPއR3|֏,`&N4җ"UY,YV͉s1(BzK#B(xFHh`MmL}ZDN|>{}a#%K;4a(ZQXf`~BNV(v!d"!|WPL1| CPz`I7A *Nw,9K?BzK#Z E((XCͩʹr-I.v \ :8|pK6,'f߾}_DSr|2#i ` `iRz`IG "Y,YZ͉sq_w,m FHh`5mQRvHJrj= X!1yiӎJI,5He#^s} 9qqU<7d7~p=[T/( ]|P`Iҗs+X\PJ͉s1 BF]Υ\EԜ3BEˈ.|X!7{}a J:oA޽{r޽G^ɶmVf[^P%8߸ ~M* k][V(+ *X%՜8g#$Xq(el}9S\q6o(@+4hSٿgJr[)N Uz_P:`]K̉Z K@͉sqw0 6FtJP"D3BEkmceJ*XC8SNy}Vv;{o^_do?Bݏz[nm:=}ɛ7O6h|wNWWGY_ݻvgnѲ~dnwK1۫q¯%;uV֗mnwt&֣ϝwFGmҲUK1~ݽKgmLKSq|ҾjKΝzs=mG@ ={&磮@ Tcʔ)?bt@ +8yGks@ #X@ @  @ @ `!@@lڵk;wN֫W/٪U1cB'G-vޝlԨz9sf'6lLu/'7f̘ӧO~*EFFFrϞ=Kbfk[N@Gg}<[ikP5jt؛~%7l%wСI=z@_bECKLs8pϳtK:+2dHr޼yyo:5k\xq'NL:4#eɓ'ünݺy#G3$۴i=@ndiyEHd瀾/KB?߷y}`!r| ?wV Bƃ{„ G^/[,Oϧf͚ X;w}>T<}#{oVrGƍGxeKgJp!Ƈf֍ rrٷ?ұ/{,YOy,DGîg^Ծ}#?hdٗ+ }p\#bYҽ7˗/Ov5Xܗ#|t_E_Nr_ܵkϳtۻwo X|d ޅd<"d6t5`>04?/DN?ݻr7fA3<їhC_N^_bt__2eOMBGo|^/v=Y@罄{Ѹqcq$]ytiőSP+]{Çj%LfX`g>􅏬5m8:n -[٣sݙ{:󮢬tç<Nzd  G>>_8^q>WxرcG/2+{fGҽ/ u*aD_Yf,[+>8vXv%8 … 7pCY#dޕok^|_B裏e0~ J9Jҭ72LX޸+.,Kt˜9s; yy|,3E!XOu }A_{DTODZRG7 /  @ @ B @@@ X@ ,@ @ @ B `!@ X@ ,@ @Xpa_~Ce᲍5J0 9k֬\:u  @xÆ h„ Ƀ&>?1  @@bΜ9=SY2o߾zGz޽{dƲe˒]t ~aÆÇ'8p7nL;9=ԩSnݺG1k׮m߾=ٳgo?)S/|Ν @ N|t=d>5ݻ#\3f~]roРA͜93x=bĈ[l ^o{f[6l1=3fh1Bo?cA@ Xqƒ#z,',3`'ޞ={#YҖUr[.3{|$+߱cQ4t|c'xG Xqrddd$5k.To{wq400{>!'aׅR Iia RJ|`D$(A30˺Z۝so3߽Җ|r6)9j#g:;;ݶ5nv(|`jZBqYᩈ%-?NOOBx-]xх!=E Y  v,}jk9Q5^EѱG # ` s00|F9X1ϞOYƏO2l#~8, 00V*5] 6 ɶ<+)UKo߾ׯ}={ӧOlUTL^PSk4rX @Ckn/H]ZklO47Z˼{k{mBm-%`mtlf`SA;>k涧͑#GlRWWWlKjZu)ԟ{nBݻҥKfuuW q3_{5rn͛7>>&&&L{{{ݎZZZ{?{l{]굽6ɀ:{, H3͛7/_ѣfW*6`MIgΜ1w1o߾ Z wލ?n](|ؼz*wP[fm] 6'iFJinfii߿GU`jnnϟuxs4t]vǚJl݀孬ڦ֨ X'K}Zw<`wT =^Les̀5oʶ?'V&`,+W$D\+Ǐ]ѝZ,:u* yjՅ Ͳwj鱯 0 [Q5Oz/^(k2`=o@>G # ` s00|F9@HvEHGIENDB`libjfreechart-java-1.0.13.orig/docfiles/LevelRendererSample.png0000644000175000017500000003351411173030414024352 0ustar vincentvincentPNG  IHDRXr57IDATxUu~Mii4M4M4M4ii@1anu",,P\\Wbh|ً:"c K\\e/ gpgq3s{s?:s3""""XDDDDF@gUFDh^KSNM~~-;ۚ<ݿ34eʔgϞA|4cƌ''rjtuץիWs΍830aBZdIcsǎi޼yV/Ǽ?Kpܹs{ ` *kÆ -_<ʯJ{{9DJ=>o&:uʗ,ʯ X=Gi×;NӌUHZcl(,aÇ_ls=y}1o(v_N*1cƤ̗'m *_nov:qĈ~n=#"5x7_v[oV__w߻WW]sƤRKKe8*'Ѐ{7Q{Mv[|QN믿>L?O,w5ׯ?PP` t+?Lo \S*Q|K_Jל9s.{z/Z@zu`k]+_'j\:%>zs@*>Z*,U Iw>UarSp ]uUn+&{,PLn}Q[${)[l "ޗk=WLׯYu+?ۿn z/{=+`5 e]v[w}v[ ͟?עLjPlWWDŽu?˷#+'xUV85=MO8DH͹^6A{ g٠Z.seUHVOeX b9}]U } ky+؇cF`ѨT9i7De{^~On:R~}Ri ӕv#שܝRy&O8\?O>={n\+ցO_vG tX=}]+_*v[2 i*?ȕ/ ` r)\jHn}BAoU>u-OL -vqUZ&gwo̙=[`U[*_+ٟu3鶞֩ZMoVn4"E4LTz/O\W~˿ q w~w}ȕTO˗e_5>z.s*@ڏF,{=+v>v~87W0|"`"ER9EX(nM-jGer>xwӧOy2.;2Xš=ѣJzoLȑۉ#1хQY XDD@cPsPdx3yXc7Qqtez.s5EQkM-GHvtd=;֗x3,v]lqj] XUr,""""XDDDD`""""XDDDD""""XDDDD""""XͣŋwH-J&Lk޼ywX@C~(XԩSS[[[xb^馛nXJ)Xs*׸q-PJ?ViӦ㏧[?ڵ+-[*XU|?rtsTpY??+WСCG?jO/p(-iC}翟~=t֭iϞC'?9^zPzw\1JV@̙3s2eJO8X@C(ԩg72]_*lH)}.甾n9&)zkJ_bJ_RJ3fl^Ii씾򕔾Ք3Ki.=~ŊjNӑ#G.Q4;FRJQ[KZJ~(`,` @qZM5krhXcJ?Fo? #m۶vܩ9ɓ94фQŒJ?8XXw|{1XRJ `)lXX+ռ X2X `,e|,RJK,e D~( `,e~(XX@C~,`,R2X `,[J?~p}C?-8XXJ)dX~(`,`,Е~臒2>C?RJ),J?X>td`,e ]?~pRJ)C?XKA,e|,e D?~2>RJ)%0֘1cJ?8XXu҉'s3]?~`,`KڱcJ?8XXлロn,uzbiVz>wdb`UTZZZr =.wttsU2?z/i˖sWΥ}CVز=~K/Z $)_P2X,c:X-JX~,C?#GYf95X `5\sIX@8X y͛7`,3,Л Xwe!^P2XK `,[ ,e|pRK),-2>] `2XX~,XXJ`)%E8X`,`,eX`e|, X `,[ ,e|p}JP2XX@K?R2XK`,-XƇ` `هd% `,[,e|pRK)8XƇ` `4(,e|`,`,[ ,e|2>RJK),-`)2>] `2XXoϟ&LX `k,%X `C+WL/]@8Xe|zsH Ț8qb{0ɓDZ~tU}2XKd$|_5Z3X5kرi޽ŋ… O , VE%_I ߍsU2?z,_GGǠ׵/ph]?\^轴~N?0m^ZoJƇ_/-[aAx*-_a}N|ôb{?L>z*=ЇKW_=^}_OLPVl<*\ZǏ``),V}*>o;"P =_fkM7ݔN8J>t,5㣙KK҆ ҪUrWK=1X:>`9j`=y=v l?``t/~.+M?`9R2X2X9s֏p}K,e Dq8XeX>t%%d`,[ ,`,XJ``,,-`,CX2X2X-X,2, ,8X,`,XXl( `q `)%ddX `q`?]``,,X@8XX2X2XK,e Dq8XeX>t%KK `,e 8X,eXK)%dX@8X X2X2X-`q`,dd X#HcƌZ `q8XX,e ~,X@8X5kܸqyMFիӹsX2X2XKzĉ9`-Y*XU,H<~5ݿq3ב~#ՙ6oHϮי~#}֭i3m&δ}{Gڴizَgϥ[tG CCXQPΝ;lߞ:y&u<wN}:Աysڿ~}ز%u~xۺ5߸IsomM>:c۶K{!* Fcw|G\.w?;ŋi:CJ6>ϙt-)pC 0p?ĥM֍2XW k`q.ӧɓV,,,5Ԁ53Xddu޽spG}`չ jX2XMX[nvŒ;6]{i͚5"VL܀U` Π#9?]N/(X2X Xye2eah, `-``,52XddV}jܸq9\ ,,,%%dV%`9ǎ+`;-?C;``, `Qw*Kd ~Yf#wG;M8XX΃%dd 6,~, `qX2X2XKK ` ]+WLo&``, `KǏ%K ```z)·D,`, `6ndd XW``q `¹뮻ɓ' ~,,%%h8X,`!+ydd X8X,`, X2XM X'N=;7`q8XXco~,,,%%d&MZ[[N0!]p!~׮]i5?Ot`q8XXQXk0*t5פzmرcn3gdL"'2*R|Uey)J)*K'K(_c)ͥ Js)֭m[)m^J>[J;vΝ16ל}I͓X2XKK `WFѤЂ ڵk86dg>:B'*\---$G厎+x4 jdҏ/¡!vrykΝ yC XPVH#1@ь=`m۶-В%K實|͝;7Nnt[(V~beAӧ_#/dQev[:*%ٳO=kmR=q9dŮOȑ#>%%d1"7$,%%d1©ZMr(X,`~*䢓'ONVv!rfe+?+WX2X2X /~n ֧~MOg؜n'. t&wh, `q8X ڸqcaNZNd dd j^7_,`, ` D|I6il鶻%%d Ο?vؑ{dbwa`q8X8X,UVEXE X2X`༔}#{/iӦl`q8XX,UO7```,,,% .+B2X,`Nk'R[ JwJэt`)I)mXJO>YJlݷ6o.e㪔R=WJ[Ҷm}{)=l)QJ;w^[.Ϡj `5/`3&@?`UTZZZŊGΚ1dը?T~xCCX OԷξb:uT:gO:fM:`A:5o^:9wn:}өlܞTwH.M'e;uԲe7Ne]쾧z=TsΆc(k\-A矟 FяX:> ֭[װsT9XϟC3c%`q8X#:|yJD`q8X~((X2X2Xk%%%%5jk޼y~i"4, `qE8Xڞ}ǩ:N> yVՕqуz!r,M81-]4}KK ```,,_>{/ .kf 8X,`,ƍdd XҾ}rW `qڿtٗ^)f)tX)J)DJiRzRjm-eť~mmys)R6_>֭m[)RzRڱvt9no/&y 'KSie?5^JϦғJק>JOs*ݐJoL-_HޔJOߜJ[O*m<;-vܖJ;x麸={+{?,jY۶}/~;g.}gU~_mqx-tXuҋH2X+KZZZr /V:  bdG23Xչ*{Q~VXQ3TsΆz,PVH#1@3C}nݺ͏֬YQ'Ot!`q8X,@M4`````,,U+V(B(Br!ƌS`9r,X΃ɝ8X,`,%dd XX,`,%%d X,`, `,,%dd X,`q `,,%%dd`,`q `,,,%%d`, `q8X ``,,,%d`q8X ```,,%% `q8XX ```,,,%8XXK ```,,,8X8X,XKK ```,,8XX,X2XKK ``,,8X,`,X2XKK ```,X,`,X2X2XKK ``~)=i$`, `qV=4f̘X2X2XKK ``:`q`:X?]MlK?/t,mXJO>YJ_+RڼK)Wuk)mV~)=l)QJ;w^۶-&y,X?r%~7[CZu#:t(B:ޞZ:xvݞ}ʾ8nٓ'P3rv}{F?h̘15]WKيwg֩yu݈wΚgkl?~JvyNl2UVl /o.;\<6{/g3+{l wfc_Zܙ}v3s߷6;u鿼~ys\,s7ыcnv!ֱ3'G?;(?sn_,GK߭Q֓}]~fgS~̞=?̘ͥј~qG~|5mҏC6! GVǗcǜ#\sϫȾ~d֏u@֬5+8܏r-tK` F`ݞG}-~V'`Wׯ3_'`W}=V*ÕJ)RTS`""""XDDDD׫NƍLV^}T@M'MCM6aiĉMļ14jmmG#Ă ұcnja۷em~IJU+E}[o_V#uP4c? ݻ7?w܅ ڵkO1 112t]wfH)5hѢuo*ks{<-Y$}߸ī֭˟# ~ر1Z*w6q]:gΜI_}~9 P?iQ(ރ~臞R&q{<~$}o5c?E O?^~|+0V{ݻӲecD[[[B97nص5SO~5P<}b06`5{?BԏGLD ~O$Hj~ wy;w`Qb]>}AF㯻akĠP%72/iӦ V3p)㏍!ܹso=";ĉ9`[=y|H0lZ ,T68n9sfR~4k֬I .ԏƎ('Cӓn1R^X'ńoغ[[>bKr#48"<BF`5k?Ž`1G4yЏp&O oz7][/2őF+kj6lZ +W描#Y<W?}+o;4%`5c?Gk7o^~";$dx|gfGW;GXwE[nmrB;vHW]uU^1`Wb)(LJ=;cƌGqD#?Εvq(SHo_2|As4[?F9eq@b9bɫ<'C57 [lɏ0 x?b`׮]`b`u~hjrVIqw(Nb~~~,""""EDDD,""""EDDD`,""""EDDDD`,"iǎiΜ9?4;iҤ4o޼Vs3&/""ED^K.KϟO/^L۶m30,"XDDlْC/mܹy ={v7n\p-^88q\Wݻw[n%ĉӊ+ҙ3gn߷o_9sf~{g7|s;vl'W_ :n{7_w_+""nLG}rѣGs5\\W 9 0.\?nӦM?nku˟k޽wuWfQw\pVE>}:>X"XDDuWGv{Yf;vqq9AspWwɯ 'of7pZdI~}o۷痗-[Dhh+ܠ k&MW T+vU}XܯM*OOrڡ?~~9vkV:"XDDuӴi.sʡP]6[… 5VˮqS=+~6_'Ouj<""jJRLTV\'ȩjy\Yj>}z~sc`Xma5ёE+~ZJQcUGȹsrh馛Ү]. ;|puuq[QoF^[/Z(G?w+Z/rn&B"XDD O?΋lUeG"ؾzˠ&s\]wAsG*(BO=T獬Իロ?GyTQw`"EDݏ/Rw}wC{p*s\DVqTgi݉bdT,""""EDDD`,""""EDDD`(5lш,"&""Y7`ĈD$Fd$XDd#&,9F` "XDԀIlʔޫB|IZbE8qb?~|9sfZ~}=z4M46mJgίۗ.]>^_=Vƌرcɓ<Μ9S9~R_>Ç#J{OzK|^j "XDϟ֭[.\.^^ɻ։ϙ3'ݻ7>n_vm>}kJjUɓ ކʕ_K?ɦc.2Rk_"5nܸ|X~ XLq[8@_}LZ*wm)=#,킫7=EF-`͚5+}MtX~h߾}{:}tknۿe]zuڸqcQO=TU{L=WEs=EF-`.e˖*w!,X}AZ__LӦM)W ^]w]S8E^{m>GVqf` {/`Z*ױco匊EF-`Y7ȺID$FM"XD&1"&"2Y7uSj,"""ClTm8IENDB`libjfreechart-java-1.0.13.orig/docfiles/LineAndShapeRendererSample.png0000644000175000017500000057172411173030414025610 0ustar vincentvincentPNG  IHDRXr5IDATxwdU5W5+`$ ^PTk3C9## 9wu圫r ٿ{}RUwW}~sN:^k>_]5O7^ֿPC(6D!4 0P 0uu1,fr*  s)zǧO z'sUϳm8Q܈ɸbM:Vd@1(ə0XB qE(YtD2TqJ.PI`ޟXEE`6RTtXg`̿χ9s0jj`2Tˉb& 1R1>EBg*gb.U|6&:32)~xDݏ N\ w#4Źm ΂le'"[\!5E ̢½<_ K 71%uH+Hd:kb٪H&gь"j`!Q`RS-҄MMH'r:jB8)??^@@~=$m?T`*(C@}4MЯ۞ٶuck۶?,nPXay\!$da9z L>eDQɒ<(`njh(XƒgS7jN ׇ?0W\ K Pǂ )(`:f#5)9XI٧O8A'A͂? I)c&| X#cu0,Ōb+j`*R,C,O0"+"4b;1KX0d3`,-4`Q'>OВ?e]Oe?6 VW!}(Xo&o7fP/a4n5M}6RP>XoBZ 9ɺW>w„Qv37ݳ5Gu0YU+ 梋fS,XL'X(щ\o4S|uk+bV4:kz\5Bƹ:CFśkHò2Fk _go_oz/fc9)sȑf_Z ~ЏcpzGzz-\)h|N8GqW)V0͒U9/3OF b:hPBù,X,3ųG ^Ê1z%QO#cᰕ?eJx9W-$W4Y6Qe&Zs3Sjb*nBa VW!KՐRafz[8ΣnlRl?x` "hρb>RSs+U] VW qͅWW-]B{<@TO=CQzS& YB/`M+Xz Γ,X]Y&8zܴ kC6W=c+xɹF3\U~艡8st8Q,z\_*dr\9w֝z 䅮!N="ǺW$ -񍣏ztq~ >{W]l2xx&׃r&"]lp,//U@5$>JL_ɕsЦ#uo+?\e)8^ y۷Re 9nY<ox[oh.[RQ<q>$vEz GnmjnܪAiڱl\q׿ksu)= 'W,Y M^{PJ;NJzo—v@;?8CE/8/Q Tl}YōbF^g sqbM^!Dt-x8!r.8{?"n2O(_~O7&+K/b;2w ӟ<>gl#<9zL:߰dRA.:L6uxmk^\o:X!<RVqvV~XL8 9b]x)ʿǸeuu?l$VbOU,Xdru!)WCWtVd,'3#<( ٗJ0XP> S}p*tEem8X》E+, zK[*1+X]B<_'#Xpc݇? #XԡN8\jM ֫_}H~_pXHՂڱ]qݟVWx}:sG~iM4`ͷܹ`x]]M5ʂtl-XN&Xϵn7u_'"qU{k_&ϲW+ŖPGg{Fܜw͝+ {96Cw~%+X]  rCpa.Y\}&]vH\ xCw6m9`Tݓn1ҳBsطqS-,-T,Zv)sY08yW,n X?J a;]!W -SY{c\ ÝfއF~|3r" THPCrj*JLlE*jV:`C}=+o}'=?̥ItH>r!YD?={)tfOD$'3=EkOrmKē~bBǰϺX ;-O<ܮnK'j:{H/> "(ͨ_uXw12/XNw!6|Ht'ys/[puIæ?yOw!uT"E u. r̮ɏzpu)[5`‹&h$$}т8{FHਖܞ{orCO}, {k,/U1չ +vQ5?ٖýKcˎIRw!Εn!:?o^+ ' ⅮG'o!eVSs&N^hL^X LE-b)2򹢺K4cQT1#{;sGB^qP߶Zտvcw]{op UnmdDxPl OeMlxfaT pX5Gb|.Lu{jJ`)F`&&ɄY[`K]12 KҒXY3/[wz[{'KGBMS`k* /aƌ$Rtqu,W9]FXx.WF/(X\A*Gr8爥Uo˲z{SKp_H-m=z߶N\yd?+跽',RBuҥ5s{Q~-8eNN)-zc\*FDzC=\*-X[|,VIX˚"'G?ꅂdH XQI ]"o*`xبB~_}#|7_Cuȡum[D,[A.'+k/3.@cfTgu†8pq~]x{${THRK.TD,/g>Q5П0^A]~'z|ĴC"a3_DPZu1#z&5Z\,Bp z{S/H+_}>7}8k89']rca_8+SA 'K3rj柙eiB3ɘVΖ)l Y#eFt+P ًfԌNq9s'^/<3.Tg:uHp`QSFjkٰo@Kq`{;-c2 b[r/u~%WGr}: W8秈}ȣj]IڕrwC<ʱ?+X] ͙U~*Bz\(`t͹Y!,Y s{!MXYխe`g@B1!N>1~o-Ew9{_j'50e;Ih1Vƒ5Sռb\Y˩9{QUDT@ V:DSqaFvGT颳g\֖GctdQv {5qx6 gs܌hF!5)JA1*_zXH/+R`Z1=S_%fK`:hP΁6=rdDK1Y,1K`uI :N4s_Ic;@s:/~)3=S }\#dZk&Ϫ`g*Xy\?"(/|&X$g>^ -XcqZQ~~e'7b2(X }َۛ*`?8 o]wnS/:l {\3;du֏O> VW1˄6!+UM5X8p{{M};1kp(LXo" : VBӓP-Xcvb_Sa^KoS]Wo#Xf  9x^|7$>q'׽aWsėbN@t[x"޶}@;EC ;W-D͝ 8;DX`E13"֤wMPc+U ݥ "l-y q~c=c5L \s\\S];ͼ,U ?Ym`\ E58Y%}>Žlq)S 8Kk^:-RU澏?^|MM\-eS yF(/}];l3ўDҥ`no+EŋgN]k_N#ek,zzS>ժFVK5C6kLMɊUyڭj&4YrTŠFWw ';h&NFK>s79`:Gzp(sWY0<#(7: I+Gp`Ǵ f[[`)g FhA[Jr}%&tV~,KaS\9rȸf2LF0ڤjóM 3dF" Hf  q{QQfrQ|O^Ļ/ 2`&VK;vljl\1sr9Mdj 0X^r0cR*r{bn6E'E}MKxF`|hLC%le7E$Q0]hl2FiNMw+X]f XΏti'XXggkjEyUF=Bȕ]~򓟶G?B/Cͮ< ?&Kxk,]p`=W`ud{4v`!:ɐ$C'Z-OhSW$X>o|&Y!*Ej#Cx+ ,z;9E5^ˊu'd\sMz}a~9p&XQd{ܹEd P s_׶Q`qn.R|NUi/~8ࠃů{i3@Q|''T;6{sKVST 133H4.ZelQTCtI&5~ؼ5+].WĦM7|bw73__G?S3N9[r?D|X)B*N8G^o+XI.:O\tz֭ >g^7iW;jdxOnŬ&X\Hvu-i+Xŭ "5MC<oyqB} ҫ6ZX'I9<;sWF\no¹-#*6XuŃ~s\J¡o}~Sdg¬UX"X/~KfPukZ`,.QǞd^W?l~f}[םsGH!"Mf 6cDK1U@S#6pZuL0uL%gw(q L$v'k.9MqީEg} @J'4 #Y0(j|O. bFpݺdQBs "&(]E+ Q)3W$"Zd L O@Y0TD-ML'>) E@37 GWw~[ v"|/PBA9HDX|,R,VK a,!%r^OyY %1zK!oE)gDI) 2¥ Bʕ]@X.B .X20S5IP7Arł'?+H~ K.XVtMA&%`&1:k,}T5x,j\|J&YWfP#GF}%M˝\nTJ~vY,Ek]}u`acNT$4ϖX)Wu'snnӮUODzIGg`dwPgƭ" yGa8$-'H?P=)МEh YM`Ǡ`Y}mao ״ ;DYtuZ42`N~`n$wbuuP.UA4h6w#<-e)emvjl˒2EhZB3 k,}{\eF #\]09sRB qT].Rg2M3o,Ҹ]bhrPCjgybr:\]XhxQb̴!3 uIT_;0V:v^3SZ8Ū\ZυFu{2} &WQ8S ' Hd+;A4GԤ<J 4hvv#Xnb@`*sfYQoJxq b ePRm`J8,*X<8Gq⹚xdfpb=ʻ8G`+.3GjņG}=2eâGH|LBX25<K#g(H)#2)$UjL/{uiuQf9 _!GulA]zL`8G=e^2&4R9~<eݿ$nM Cg=8eɪYmƌPq[ޔ]ZXMo<FdcrlpBsNQ\s`l* Dr"\TʊHwӶD0g0X| b5@J~  "(("kXVˈP(" QL &|KB+QAT8%e)eRZe}!VV"L #hl t+X] VWO#X*OSnS. VWj'joY!"wΒ,XVL<kd2B9E2]!@ܠg" @}+-X+ܯB ` t>~eTPWzwo;$_S@é0+f*8|Lڲ.4\j +C1"i KrRKۘm<kvE{νb9bѪךkX>kt5m)*r \,X;rrNAfeTˢ^p<^j< N?M@P"C2 V~Lg5CRH[&XL4vp@l4)~X7-.*ʍa5 BuNdma@;@lҵBK0+]DX,Vny+!IC \\25&) 6r}c3>f+Z[Q̡v#;Zڔ)h;$XN"mDFBօcYQ#ULQ^,onfIr\ $*yt ȐsT-X1O5*8Z8ڽEkm\.=%Zlp).l 2EODbhDJo5PDr,:( \[Ey# bm <{,:1:MOD< R0 &%3 GA"; LQe] VW`u+X]-XkF;ThU(XYE{If3xંLUy뀭i˼79NNLkb`2 5S8mRóxR#ú[لj8Phpqx4CX:V;7LPAP fiRZ,UsX,^|j x6%TFtgqx[pH(%0ϥҀC*s^"Ls)Xe+)fofF7pW:{:4 f#X4gl'>sE/z1_>|u7oC 4M3hD-TΥp,˓9)h8‡Vu1jgC6 H`4=bO mU?.K1ySZF^ote^:t Cͭj/Q^ w%dꇡys`8.?+r;)c\Դ2x׵rhSS(ijy >t"ԳϖǷ("Ss GW,`굯}w,o?cmbK/ے]vE|w?` ZszK_fwo˽_j^.Nj$` sg!8!Du6QPM&;{}tN^)",,(h)tltaT ֹ7'C)0jpjn 2SĚ`,FUE<ゅE&eh a}YQ 8V.޳*+h TDY␝/z|IV7@PAޟCt^\i|&mBmTu V, Ȥs 'O^D HF(ѝxWqfW\xD Y8V18QT _6?"B3Uq%WCd% rf8<;Pfd::>Rd.ϳ WS#ܰn7m#N4IG>=;BqN9r ]%ON׏UM?Crbf)̌@JZT&-NThczp[*=cX"Iג`!.w6WwM.gZ"-ln>̍'i+}M7%'ğ.<\(%+;?80 GNwr$YoTpX/+Hr ʂZ_-^ 2\n5,ωDQa- YXKEYޟ|\+-ʫ\W.:Rz>,Afӽ|iix&£3`[ˑNܲ%E0r3Bt#˹LCd,~0yUz 裙})0s[%MDz4BLU1;/ WUHQ,(gzKɒ)`f-"EAS JȡLO>U)GO~f$VΒ$4BeLm=FjݻA }'&2Z748*f{^qæ,B-e7ac=q%[G#4ą_?P)<-Юy0Bzd.:R,?l>΋JIA:LDK]|:M]_$R;;Q_%'ũg/)M8{'9m83buU|^_&?yIUXp6fb%BVHQCd;⇿cO5|`,GaF3ξsQlj"WYnG+cl< ?K_a_ qb*/~܏Ŀׅ򔋌%vǾ[q%WTssЭ X[ŏ%t&P10+Ȳ%3,q]`ICGXĚ+Rp))Wv 2?{:`tff} UE,)摭t2 ق"&-H 甲\`H0-=Mp&')PbA~,Xi})徖l?nyDD?)JHR`fۮ`u+Xm+J~$|$,ry׽׽NlaͲ젃>o|bn>$"]yuقۇzHʓiQo`Nwaz8s?ew󐒬m`Uk}l\Ȕzp S=#sr ֧>snpRjH`}3cn w >)$Wݼ>ϊPM<7}/n$os+db-;_8ѲcN%.Od!V))$P 5 VeMO~|7֥fϡ׫m5Aru"2z;##p ^6.$;lbwڷ<`u+Xm̴ ٭2˰5<8h>\+Fh2wr-$0")8D!W Yso ҆|:ςCWAG,R#J<m %aːSP]tFqJEKڤaqщ,s1t}zE*xF]_RǨÏH)pY.4J#WO:sz{- <胪~-}Ή54DUp)W,Hi_$Qχ67:E&Uhp6Z!q)T=P)P!}#L;-o&3Uu\eϻ?r̢cY4<;__ q9>`<gVK}l1"FEvSgqgqH6vAOW8lS": ֢ # #a]reIx{`J#eO*_$X{WѢwtnݶa?;6$XwM}{C/}{-%>yp\QPcg%:]Gr?&^Ez)X4Ze]>±`u+XZKl/;T&fӱD"pC66 z4SU`rGNK!FGеmQ(.TA?5\L;ڃgrp&RW,d/&/r_͖#F# tprm>qgIז*ˠ&mu zY7a*\$k+/A>w_NQ8=(uЇEFT8ȓNt V!Xk,JTїf,g; z/z1bJ+ x_hr.,T֯ XRy5k@P=6b2:D/~7CpҚAJxH|YKw,Ϟ;{\7kF:y8\4#Ca,Q=iSiən я/|oc?2h+_aZrȧq_nt̼BshfTF¶ϩQqWMZRb_sT6K#R^Ȑ]NX>NŪao8k[H$乑z!0:᝞הvbʼn,VCQpDI~oy+^j;>wibSfH|:g (TcN f|sa+cLK"rR :FĞ5])D&Kl < # "/f 4%# k9 8|쑙!LJCD֏pu+ '加IF&Dg9Fb_i4Hw|'ݚg4\ )%Br"/:{.`eW/¢@/iC?e'cw}2{meΜ)Bkkx?`| 3IJHdU _,ev4LMvXoZV5uq1Nj|ShY|tbO JQ6e\{tĬ{^o{ I""Jn{xS.Xo+uOeѹLGsbGp4D"s=Lў\}cmJ45Ӕ-.T\lZ1<_ppY2f.R2gDNvmF\BenĠb$fCtŞXc墠,bFb*DlrRFD@2/7\؊CT9`9ďi.SSX9z PVw+X]Z`qg?o \wa*Y3IgxdR|;{+@FŻxumw=LHN8wKlͯ՗]&o?s׃k,/Rnz>.zߩgÐK,ʥ X|I\'º`]wwx $t[!,'- N_,.w>rXwˮIv+X] w^I븝c!`:X+Hǜ&#G Ỗ Aj =GNCpΟj/Y2P=GBL`-Spp iu*<'V&A)NxYJV , _tpLvpXH5$,3U[cjUFumBw"dBD\(~V/z{He!ziqaգVMđ_x _>G:‚Ft2 lfOp #<$ۭ]|P. ^_׈S6R&gJ$x{Im?8ͻ*\moytP,B%'*dU?KŁ8SQS!"V,Pl?DQ&DGE)1m'"KpoXIɺ⋁?sV=j HD q[~`)}䊘(LS\h- XHa.Ⱥ7O TFP:FU›ɪ\w~teVz+ۑӃOK , "dBx ] VW`ګtw͞9׉φ`qsw%f[IiJچ&1,ӫ "wS5LF#ԪC PaXpN'զ/!zf II/AP0HŮ ,dn<JP$1æ qL%V%Pw^outt##>Nn ORm6SS"WRɀڼ8[t*1T:p'b򗾐/&JXθf V&_\A`k<'᧞H"x68O 2E,HQ"|1Ȓq˟A&]+-U5~&NT8Hh1=iPDNI)UD"SrPֳ^u J*悀f5A#xpÊ|4Hz.+jNxR b:# hv$򜶣?ke e 3LYi_&'i: *`qOXb;jB OI-Ot׿BZ98d|_"I8m[!"EP2Y,URX|*GZl|(XY.FGrh=w~YاR-/^RŗlXJxhQ]Tp/&]ʓ$0==LpE{L ض}:'Jc!Z &{iec<ڌm;c 8ib)3gJ>{zF:p4#XhDLnGhq0$a1lW3-`VL,08` kA!W"LK}`u+Xϒ`9 w+X] jgy{)|3!BfkS[zxkCs$!/J2&_J)7BZ x:/XqTK^|يM:ʋ1XQn(J\WT2T懭EXW8gIKYM-*j L+ѹUeyK\g4i[3I%`1'S,5}X H 9-|ދ+,eT,3ÇGiB"Lȓ!q՗sOY?uBHw<FgN0ẼPLG08jjS(W3BPﭡqVNm(wσ<|Fpfx|' F-s Vm:w?FNcXLK"fQZYA00>&.I&X9#lf"iE"Q H$ *l S%@P~:rE\ Xz}F`5}1򴚠4 [f}A6HU.+<*+ OA޶+X] VW`u+X϶`sa0_{rxZ 3YEMIvaLgkoks+g|&I>CI(2rEP@Ȕ!t <ծ,S N+@0s+RErm(QTwjiPt+tITleZ-05t5L"8KRYCܜ-ցƖ_Z$N+ e `!a$* k &_QbxCVrqhqzW <g_X$od\&sn" Ձ%Jjv8Iz&2&4d[6&TgV!ެx];n[H:UB II,b%Y\dIV%NA!o\Y`0nCV|tWvV?I< :Rxn5|RxݍTzWV>pUR$rXVr%xņf+[p3EPVՕ+sJZkWnTהt> HqZ9+;(X%WM2 *duNF(/f%)H"%{K6Y[,6ZRd!\'D ݂e>U5Y*A\,k\(j0_X] ]yd\3aOf2&:pWtF%?:atUYȃ => 9289,:a|R{%k{sy'M' ּ+z,Y-+\fb <Q%W;c5GwO.Lhi"5MV,Y :W DN@: ADPj&-jRVWEs(mR DVS`ufH+:sR`-/Oɕg+ܾ'l#*fTN.66@5` k X`];0:u V05낒+\}E>'N35] >/OAXKbPzdΨҰRI ` clD^Fm:`]&Wp@&ĨiX ~ew781T/VF b xҧEpR$&33"" fy5|+:.?\al/X1+DFVZ $g+ZlWC*X5@MWDu27 &d#W ]jd^C6g.=BM4C4{7ϼQ T}+B쒱'!i8"u**oT:4_x pn>6 ^?K086\͓N7+o4^{?w7~N85xMA}?+W^'_x;['i> ~|}b`JJƕ\ r}zRgT'< m!¹Wӆ٤f.GRu CX?梻`dXAkLX_M4Jvp0魃:W xx+L٠,ɵKHsAN`U{x["(JQ6Vf h⋋ 3B02~ /"pl.2" Ka֎?@5` k Xֿ`6]u=B& >< VC)TN\0MPIa=k*tő {}IVj=H۪w#Ov^JiJ@U^C/ RŦppm)x?;o`e L.C~/Q ($X≂&YI`eVRN ggu`8ٝ#LV^ n+MVnـ`Q3Nᚐ` AdS8W V&e?F=[hr^uƾ<1]np]kv{{}?o{Api7l{}`۶{+S m6?_/%I}o~ sC"x-[nn6k7oؿȭ1?R "Hx?Mn׸7ly!tO!7-7-_?E_ //oK[>nK%/+o~K_|K'Z}+o1>/k6n/߽ٿe]γ`ˍ^ ^%<߲5:F{}mq׉[ w</߲eb ٺ m~.u=@Ρ8p:;s+ϻ[nܡłwo'$2 ϵ[nm+?u^~0^U[/` V]i#4>CurYifR-\y9W4CaMhtt`/zR}'w>9yl/@=^8}Lscn|{j{'4GLJI|aVN텓k+W!Al J"}un^2C^ߛmH<ЬdM$4ꘀp}e'{a. >:{|! ?{(RT1$`)ΫѢ!`.YcN@ܚHd=2pMt.>}YIh/_5*$vbe+e:љYQ@AZ8p媸62"YKR/;^&eKn[qk F&S༒_Ge0R%zP#XweRl>Wm A:paF5l,ǡ|K#{+h]U|($KXtHQBB 2~ ɩH[:cAÁԱX^NX " FEMjRJ Wka$%(0DI?D Cf g(U JQDA( XaʺDLpd(˄yzU~X Y_?R$Mp#9#`\^ /.nsVYQF~)X}zWQވˣ'X7%̈́>\pQn>'< cO<F ;GiNNӜU>R}d}#C}:>lD: ‚uQh_ȮWhX][Bě K}h}˅etTQKw΀glO/`)Q(d Njb DH剂T2$H i<Wr`c&=#징 r[cWqo&*kV8ee_,fK=+|`r&fsc+U@5` k X@wzPWY ݏ}q3R is WX!E[5ܮuiV%_4\,CLS&pD wb64\rk&*5mb,]m_T`* Holbqp.W:s` 5o#T$`tYvIh VW Z!Ę{ĥӰB: P'Oz"(KYvimq՗aY%TـTr%ܯ+;ˊVk"И>+5nP2]*.)~> V ^ ٹU!+TC񂆕X̴Z7e`d,7ATPk JTPXr=8t8ܥ)) Ev%ۄ ׫b9.cۧ:DFNg'O0q}%*)%N;?٧90=}eq"`{,pNɔ'Kr|a;S^SrA+ l~"5>p-WQ`CL, 5@R$}&Kb[W\X[',OSHT$\ )RކY|9{2LQP+M#4`dtZՁT vI J/\vJ6 XvX,{g݈P =%;ʕ)嵂*BJV ֫M;e'YrF`1W>pT]`˘=J ['0pEJK jZIuIA^Yld-+iԧn ,&Ct(0U+Xה}蹏@5Axk[pL]zWɕY9g'xrn𶒫!YFf>'PG!?P+Xg sJQ;cxlV"H zk ֍H׍C`6X>^xzPzM϶4DUɁUDh4X=Nf+ ~XM+2̰ͫZ[V\! +FS YKq!V*R$(9Q[Mչ[޹/iuh ZP' k X@5` `H(q4sӄ!C[!!mㅙ,`C2f1dF4-,'eMq rhv8VFM4s)0DZE= [r)+\$Z!XX 3y7P7=߆LRKo9/c&GTgظ2sK@J*; pͫrL[%pcgVDT*TR'***`M S(EU,JX XVR%:q³+7Q g`RE vyu EqV<\R!:J +lܫ@ϭ;fpq_y[M+oT`u\Ѧw x~F`SN`XwpR*DRv'(e_Tu0l%Q(O g"džc\us2'ԒjIJm7\ڡބ~;!}d{4%L'`>DxgqEzw+JÞ=] 7*kjL ̨s V Yu҉4`zmdƆp18%KBqnHj %И8 ^<pQ~#G?;xA&Fm#py7QC _8<SG`!C|ٟLoq{:2A9]ak b+͔a:,B^~8:$aSX "Jh$ (UTT`A< [I}W=~%+X\4Yt VS",.^VCibE2!I:!b+1Oo5X/_0#'a]ۅFyShzt_r=/cřVއWC鉬]z`Au~⬺Buɢ]9v}!]عvi: j$+Nk`z.fni=n~]gZyY\=mgL8<:2,"E:E+˯Aq7Yu.FXBY,]["dJMUV' +)+J`jo\Sڝ`m`U*5VZ]kM(lRVtnWqll| >zMp`vBxA`GAKC᪶4urEԚΦl*𾪁-oo W@$S1#8+1 )V-/V/}f}[pu^;ŪUuJvQ.(=< Pt#=ߟ?N2 >Lj=͹4dZf5sy:w9scGV3{? ,p$ꃩy@#7ߢ{}Ç}?z_^rJUCL~i@UL2ܵ-L;!:&ms myÒcvVADI)T5%s 71qKq> odVBso~bZ6(zE_QIDAT,;C r%y㿲?zG'~u@5` k X-W=ժ;qûp}*8%<ȇ_]Gz/݄}w ROĕlSi5l?5c<=㹂մ¤˄/MK.$<uP|j[*XVjٺ}3PR87Ge|r@VװGeK5?ޘ~.XP-_Xl Tւ7&GK!E''?rpLvɣ~M(cV.p_+u_,yVk"[FxP(@y>(7|)0DŽnj|95%WB9_@Y֢GY*ck/0X,-p?JL{*XF_m'=qBsSRb-n͖ɓ kQ>fVm*fW@&{BjV96 (߰}9U0 ||Cpna@Ҝz&OlB9P}Za!$^I,;*'As3vymYVyar!~u`/82{<`EPW%$3 %@^)>‚}{$'eV SJR _l*Ti+Q%X0lb:4y[A6fHVSgf$!fM49-[GR`Ir$//'+tua?KRD?qK‰kVdr<7ǨA6` k X@ZMgO…js/9 Vg]8,x]ݶ&:g<@i閵ͯmS q]fVI_R'Kr+^m+}Ϸ?7T@^%5#ҕ U7iej iVsmMˍѰzXt\:e$_~ FrR%}FBۈr$%0ϯVom's3DVYzFj(mu:`t+gȱ#6-K0ɉ\!57.8yTA2h*HY\ 9;W7 P}-kPey x [:c}Pl Rx=1T=@<W>"C4$ L*92,esX, l_HT\ކ&0xw:Y͊a3Jvgt>"e@8ڀS+QpbgX; ׭HLȷ(LJzTs2P#pry:N7Ο!t'tDh" C(cf3OJb@||NK rDSl Q}9ʖy섁ITj&> +M0:>~n  P"%1c{sx&SH*txg-Xj<맕 lKm`弯GV =/ܥt ,*!Xi'avj+!")4k&U54_(XXIN/D \^2rq* 8\X#?qqYM7݄>`يE%8\;n3NwP,#X6= Z*'ae5X7x2rŸ0LT9YERdP Qؑ.B/A:h^ "+#KRaBhWtr%`dAs*-K5dĬ.;rpR@κV Lv+^q `i՛bU@'XFˬ4:y[.R*%+n .06-5R:S#ozKahbeJcokh[(UAre&9\ WߥSN7^GSwљ?yJ&jFDrX`)2H%W ̥5 ^,e7fS- W/݌TqFVl\] ֛G4/`jf5mnPjKFtWƅoHl6F΂N&iR.)>zUpF<0xn 5]VVBbq[?z ٍ H){ Z^΍< jp & ͚3뀹X~Kn`kmSд+sEWn0`)nh,L΁r刂dGXVrlEY O4\fP ~Ns*Qr\,P G* { ֹofhnwj,*;߿T c,o X@5`}>M-}}Z`-076+X"!XkVa %".N2oJ$qnq?soGC}?z >+GG_۞UthKsx,ř,uE7&X4//' *"Ai= ;yCOvRɧH'2j|&;< 6h NN4CbnۅD)?҈̀2\,4W&H[a dL֜z.aVg1 \1-U`R~4WuCRf` C'W{P w&2Lu$ sd)44[2֯/T@(A 2O, _> {?^ MH%MkDI͔Syg,->81!ς?%J\ TIcBkXsQ1ߕ]_woة@*S^!W ~".8p4O|,G`~j$$Fɍ@bz k&Gg+a!%s5&??陨f)O}l?u⹷V"%_dJr_OC JPҴs%Le,B1'?@5` k Xbүy{W:Ctձcv-%>ւuaw]7㮳y%ˠiύ V'J ukSŚknG``6$d@3y@Yfdg./@LH0+*HD -j(XRy[Y)5@6@;%Dh+,c@`wgXz 9$zKط!BS\PeJJI0M0x UQRl6ePBP* E#GUhsEɕ@I+BaHgv^,vrwmto&ظy 3KdKxٟzmvTgȯ3%V0,Nc/20ViV_ͧ4sLoA&.E\r$Jwg!)z 2@CdwSSl:q&`sd0'Ɋ)3*h2 0}Ma^9%xJ ,K{1>CAdv+qMGry0y\Ai:}p%%W¹6T2 ]u#I {_G{W![c;``YɕH4R?1+O?ovU#~shNC~n1aǞy<a54l{r0];Vd`\ t k X@5?SZ 6W?y#%GiU/ZdA\D @(X{NL*Jܶ[lMɕ0[ :K94,Wێ v-X~%K? gz`,a Pg 2D.VqjB{}p$ @p,3+`RYk3E i( ?têԁL|/@+;M PtUl TxםTs l7ݰ~(I"2ʻ~UTbTD I#Pڳ}}Ti |$i~GnK] \X_aNhk2$?}x|x}ZR-ad Y7p{ !ͦ?Fn 2!2+W3B40+'|q"Y>Q5&iZXn>b@uDpL~U@QHxJH~R칞bո?y悿+d ĺFSĊ`Uu) )M4A$]ss1z jTmږ[xІ'\ c"X *d@5` k X3Y%>_%VosJ\D' V˿z w{g{0DxQ `&/+Q.ԁ0]Oz׈`<^Ik #U Je.K @bu,%U%Q:`!CLv˭kRP!, OVLg\*•HX7)6W.Wt@~BCݰgӏ${ וql ,As,s's m[nEmkJ .ن!9ˍ!7 UPcwVCn4`& *ku"ՌZ0k~V{])Z,oF|y &2v>)(6!L^2.ԑ=ُ@nL6Od[`IDysb*C>a`Q}&`yKӟ=t@s!MWn HY}}("gL^8a?i?{սle%Ru0+yi}V>,$r4Ral[Qa) D|X7L/'+Cu]5 Fg@BS>LCZ&S+X2KŒ 0ub>fB+'8hsF<]^50sY2tY䊂յbmC ^ḵPc?|ZkPXLV5 d[jПb)X۰:tb ^>q jId58%+YFtN\ T9pGp X@5`w;//~k_)Vӗf XN%:+J3@0[Pladm(\MYP!DpTZ2!zJ_LnWSR`Y-iWÜEAysaaU`35X.wb©Lϗj? z59 !*J"`.k8lzuv?oߵݰ<!UP$~ۊK Sa][ףIw#My̚ z`46:7۠^5 Ze%og9V2,U张'ɭo @zﰒc{qB >4UNJM'`hp& WӁРNF.,XF4FcG`Q>>?DLpÖu'~Ir W"~ K^}B۲إE?}׻*߹M2T$P& cu0\ ܆Tr%L-e5>!X0dNef{dBd)e`R^s  V^3i,$Ŵiٹ'X)"5gKi Sz.1ޮ`~xNlBD"=<&#'nMѷQh(kv{ަH@F2s̬XVU1ރUI,UD5 e2Ip54(ՉbԲ%+/A:t5WXʒÕ#/[d4"{B >eEX2άd<+eyW+f//R^t+v:HS8/-ܖ"FH(OT,Qa$k+/*+{Τ4Pb[֛MRdձ UgA{3XlZ@\$ E`i ZG1_yE((Xn)|<ժNq]\cn,#RX߉]3RB+m$$RV(C5|&?N̾c{8*WW8҄IжYQ%\,Ŧ9X49Xi}@3'NvN.~WdLՂX^)HVhc1Ԧo}K*8'Vb,4f$3)a&: &D |mRШ,4%e,Z-Ιf[tMY+5ab({d2Fg`&CmC X,eV V@5` k X"XSx귾jhv퐫` h@^ij@VT턮> Kd9C=,}Qx eB.4Scae4r.'`n! U`3uʉx4,=X fslL=(}*5 ٱ'AXj~cF'}nʵ꒘^>TZ Z3 U{ o1ˆPu_*СBf ۲: mohLHdXscE%W/Bvg1@){9HN[~_#~a`(7҈3,%J8~:3a\wX_OΫjʯ"T!V{~pg{v0%Y9@љ rI2O.d5ѺFkMF*%Qք4V&ޙtL,PYao?;xU}FZ$_J])jFLgt& yy|ִDʅ1n`iѓcFWt(` k X@TX%X{b-<#O> _HF%_6<ˆHo,u`1}F)Y} ۃU,vQr%8j T>Q_ ҷCXJ&z`IX,IB֜tAUcˆM]q'o0=L-/L/*J 륲 T@"QD4`Wyݞ!ȔTSJT mX]MIM7 vJBI2a~bia{yα++VFJ,ϒO"f`2eoX=x`apPɖkJWŎ]%ZֵCM`dt6hvŸ`5e 2Gz+k2%MZ*sGwSGGq\){Fl\ pcd MLO!M=J± +v|bC6AކRK}Lפ/9kXl_?ϥ6'?Oo.Ko)rIcXUȄqukVjIcFŌ%6ȱ bkRN`ؚ Dl ä$+V+E0&s$MFWHpRWX`TR8aBޠxL8yK]KB+X|fmsgV̱`a?ȭj7+?|~o` g~ͨ7ݬz smX%M*="H &ba )X^2 J+Ӑ~ҵxYE2RmuͷcsBe&_k+*,$((XY4,I \K{e`sB\AR%!T([HfȣKs#tWTtp)`X2+XlNz,)*I8/4\k?36~ذڵ'@RN WMh+X)Vyn%IV¤4 w!,VBcvjvW[VtujVoRɉ,5KRFayLL NȮ] J)⹋XV:~Hh`JyJ,O5LTqK+i`;*THn0bh:EiJ'Xqk삍&;`V]\:.2fA YQ*O&R l- wHդb)!K1WUwV/]"Aن2[} _\A*mcһQ82R"$xZj!&d(ڞ`ePnkL(vMf?FM@*;Ab WO9bJ{eK+\F஠,Q$hCfs"W fWp{,1dMyP*+Yz/}m\Sw3džl'wŤ[jX!HZȨXx@nռͳcQ4e1d!dqь)`r4ƕ6J#XC\(LQ~{ rY_;:21b-_Wr%+6BJY?x )zӹZэ򔀀)a*xv@d;ǀ$$7N@\]4PL}Rɔ`+}B2l.k]DyM.S3C#Xl c>"dRE(y`@P_9sXEϗT*{U؎`Ӡ r+X-q4XKWAYis 6a`{\QM"jm hM˵i0F̶Ƭ.ڱWw&kY9-6WYw)c'gw$   :X@:YuZ@ޕ^,ۆ@Wv&iJd HbtElFs=+Xo ^%\ Jkk&]ptTpUF{>[[b5ĪCR=Z \*xU#q0]+M &,J5]Bel Z]bL8AV%qcY}hI1%W=4^i >9y&4Rv~/JEf*\LD.,@5` k Xw,YjܵŪkj X=;HT`Cڜ(+Y.qb.29pp1kH 20A7NOI u0Ѩ͐Z ?TFZJĞOSRTzKʌAoDl?,S`yEF&3w/H2dNcaq:TT?<)&d'.h<Y%MNb^D`%tPH֏2h:`QѨCdRC̎)hJ̡4wm^+c2&#uDM,VV|* _o F?$Co/=0\ܭX V"Æʮst'b|tyd涮c嶝nÂX(1 >0l+U#+w i^{`.RXͶa%#K2m(œ+(sM PCVo=o3٫ \eM^P/x %V}*\Fkw=DIx@bR*sZY* D@&ED8>(X.Gs0&CedbNx "01R\8fv|-a#@%I4XSy(9^?A%WM0dP%X|` k X@o(X>c7>CKrխ (n~^:c+ tr'`񾛷*5bE$}p(TkVDuQ9bMbGJTX^0Bٯ5%p|npXà[ 5k{hţ=؁"@Jn;TptH1 }BX)zvwաR>6}2=/ÝפiX8͵@?}hx8+!S{wau^y)p)pYpK#TT3I"҄bK꾋db[W 3Gg5~4xN)%| 'vo_x50&S*T/Pp඿zfԯm.OȱM=u\#si˃ѝgTH/d4dXOHܙuIK90DLPr%>Y2Z1RnjB `2YYqy!J ֈ+aޖPfl& R&SFM09DmEڏ-X!S{1Dj ,Xˉb[(puQ#sY,J}7:1 kk + s5|m&:kur x_ Ed4lmB2[.Lf*tnhijt)I>45끕>sV!Xv'귒[16`9Tˁs'nC {8Ǖw\ުUe[NlK-i9ss$Ha9hg[wwl ;7OMUPD.UΕ0s& (!qbiWB݅͂P ˶5 B,XRo$XقU)\+ɗ62ĴZВ\[Bj:jĘJ^YTο"jզ&b3'ׯR{Ld@!p.bMRdb܀s #-_^=[\]{EIc2UnI\iUjYR[C"6 =OE\-(7`b)ؽصb8e-ضn8u{kbFpܷ  o265>IM ]&OFVz %^iǣtsU%ՇˮXr|q[jtJ_ptzgm衃$)^5|(=ȑ,0+XELƪD,%`0q3,~ ثF"X4e):V^NC1`bzp "X|/݂hJ/X} V_`;+>:nYzo#Ô%X?KDV!rCP_Leݯ#XzD[z`]|V[,L} ӗ/Xa`Ȩw+Mꋦ_"TIY}T݈46ܴ/\`f"ђ>I:Tf84 cWE)T9@ ^aڙ0@™WHü3 Hre !xVF:o++\UH^z#|EߘWFDyX4W"8w@\"Xr>WeP'ɛ{侷Ξ;׬d_sLhȽZtYސB=y^-[\܂[MwMN9Wu|s\yަBB͒)'*iqE 0s-{%ȇ=63J'p|+N^Tε%`uUu?&P~>2oZٺZq)˟&DG؂HСgLɽL*-!24T"ܹJr/)OYgu&xBPsq{q7rG?~5/X} V_`;+xW8yWXq},`9+tB׭`ɀf>#{=\Y:X"XniXN\#=DXCDZ(tTzNA; J(/.XRHHwTLvJΝ!*t%b2tFDBi%Xi)5h%dUYAE03Ѝ$j;XI(7<HP+Wn ݏG~ht?,%XP e¹Y#X 9KsCd6@"ss ApݫLɯH`;γ0,3[-U܅~VCD+F[T,qfLUJhm}Œj{n֜֒ߗ9a tov#]ꥇWtŮu1="nܣ{39`鐴Ts̕K׬ Y*k TTv 1!@yo3*"EH+-p&]$NrWxH 1^!zErLL%%l).,de p㷖[uRW122s^|G.Z?Y?_ZJ=vNg/ƞ@W]ٯXB3cSe ;n{+ *XxUsX~M_( d$i*(rcPl,3/[>иgQ7Re.̀dASlSGsea|]j~ M un<ɔuQ&Ab5r{6]f,cTM0r FeO&&xSMṏ^V力Yb|9^C#YE tb$_.,QG"{jGEKVt[  Vp T]X@hFrDzst ^ ,UPIsf v,45sǏD6Ms#D8K** )s1 V*{Lq =q%[+Irٓl 8+y=q^"<$Gb-XY`Dٺp e%OW߶'ϙXں.mmWw9sێCgo V_` ֍;ھݲN={,WmVYJP_`2Te 98qTp !?߷Fy?^OY&==t۟|kzc~\~msu 7Ԣ}d7Aq \&a"pTHfK MMy$ %Lr 8.++>P;bvغPơfzv7JHjjz{-="<+˾/M%KI,*/Og7)ŧm]R4 zT!!_oAٰ01Rq(/6Cy..nђ-ۭÅtZ^T/GO&/`Kp=l`7v[mwlX <7DH䊙J2rxÄIb7&ZL_*W-X|ȑ75wb*=?7e#XРƮ˛`BIDw"XZ&E]E(6Ņo<*2[,6Nܳ (YMkg*D$t2#G`~$=,_V``U*8N*=y\ggNR?oƓ,pP  9XUmPVYrZ^wz9h&(Ai.W6WLI^\".1ףqxLN^ !(PPTO7 ccO@XMn(ܕu&BWD*XEܨW*HT<Kl/m[~'N_ΞUuW6e[zk9e]@z qF;ډ,͖M`^)"eu7S!"GrK,%U=?QN$b<߅Q9jJ2Pȸ+׋`yRb`&z,ɛ~n]C_faB~O_|\EUϘ W~@6<8rxcsNcHPU 6iCj E`vsK`TO"ݱ فW9熐BrV2RuVPP2QJ cСbi Q@+"R @oO4M~L Z2n]$,5d $g܂B7)lrtT$r%R/v'H@zy3U1ev*Zn,MP̀JuT{#w$%UB(TۦZ$ =x\]`l92iHf5#׮V@:ïS0D.L7Ɍ$A"q!V$,VF `|$7ɕަҷCv%=ڌt{֪ϫpf%*z%,Xq|&RTIP/ƞ+ Iu`y9a 8wyUuwh zw|58T9G랁{*F k/7,e7$U죿*Mpw`DBBV+sIG;=XZA^}vg)Αr`9cp&0iLqT=1S:JLO\1_K<,Gk+%r,X,d`a$SpK7B>=ޏh40+jv߂al49ov_~;0/֏6{+/X} V_~OV„|`Yv\m`aI V_=utHwy&\'H[^xL eGSF_cFjTdTa9{` ;%_~[+AJ&/b} S9=x~L|̴;=G,1;AXӎ0 wƱH"1p @S) -RXR(X"X AɌTqOOrD WJNNyU"w(ZW'Rjl҈`я2<,>ga1'πXN$\qîIhȕfA^!׺wV&_BCh0iV̤K * z ^{v#YHvFpXfDI@*n\ HR G I81xDcX< Q)bdœ"K([DM3`8 o ˀsɌBxOv#M0*SHRmT d[p>EU~71O'`$pЫϟKCs a[֮v/KK*t/+w"P~ $w/A܋ط] Z(-<|gG rR=ѓ|mX֮]*j~r} GzNʞ*8g i}sn6 KC@Ɯpz?)aГ9X*`uI!B,s~U*}"\S=N-#X"$,VғSWZ3@7n.]~P~ /ǽ#֭pypUd>sKrŨ2pzyjp"ab₂ wc)$]m \ !}\-zFߐܽ/MYjF`=@Ma~mtr_ \\Q=U+ V4-n\SK;HKoH3V_uY0.ڳuOi +XfUJpM\IR動J9X"X~d٢#tX˫\:ES> +V.G,^yb9r6u0[T#yYIן=/X} V_ZFmRw]CSƭd_cUg[IJ!`%XjuZHhiFD>[$!A,SuV4=D`e+ t7_e2PY`ce[?xu2LTIOU`y#Ur Џct,H?EDND$2&IHtD$TNW@*W"XY2Rǡ?&*X,4H@F)P'|hB$L$հ&5t'7"VKo>9dܾ{1R(tȗ *CBr" &!TNB&#R_a +K7#ձ$V_KKJENx#۷os΁O`|\o+/O?= .U\ݵ H!5txgVԟ[0+ UL9"N!n#ByYC:4wes 9i/o`eG]TK#:~Tu}Yp?F"^L#[ւ$W`*pM%$+ߓW22G'Vh@,`R!•GlZ}9 XҜ'Dif;k2${N /X} V_^¿Y\M}/X Y>L;J'g˓*E &yfnyVâ8y:2r0q_$N&bEE:ܳi,2GN:տ~dĩ/M[fsgހ@4JDj!X eKcJ'*B"}SmB Xҭۙ.Umf8oE/g ME^tXqxR(HH)�v8O 6c*qz(I&,o&I&]%'U!)?ps;/sKx^UL2? 20U#"3LQ`UAX?FC+*+$)Y  'aHdf53 ԄiqP@=={w첶Y>ݱ 7Sg΂?eU&WFt,Iz_()N  [wF@>SFMBtu&wWjU!'(  $<{l#{+'G}33e.^9 .+>ٸ ܷxm  噮ȸ u4J4ǽtD-&܈+LX/_ojݯwF?uE#X*p4|*prz}}Õ/أbFB;֮>\'XG2Ɯ0qXN jq TrPBeStH,_`yQxh#$X2Zzz^AKc8^R߻q9Z4â ,\MiQ9!zMFosJN n DyVp3 ܘ[M"αD2Q^1ɼ*w@Vty<Ky%G aӪQ/+3BV)yT\ ؅:U_RA.Vv4(\1j<Gt%/a19ܢa2P,cEKDOKV$9f݃} V_`gVwU:7``cGTΒ ,Z|9ZƓ*B%LU2\.B*EyrE6 u494|$K-Ќ!UAM8}r`;K \XFVcrrpcDiv*y 庢B): Vɖf:p0+ FZEC`v$e6pH"1s&5 a>Ar8τME d.7Ԅ5I F RftbBrgX X "v3=Ú XbrÈV ;i6-ŢG@z 4mN| G*V䕑q"Kl8w8}uqU0vwT|Q04t5#nW@'' }3rtWytϬXHX1I1H|A0spk`b*}σ<~-,CpsRxPn쁻KD73fa+fݿ6rf sS3J,o+7Lа>~1F7 96Bbp_/f@Î /[eg/US*c;#-cĸO^jB/ȨXQ]}!bH3LȌ֡[;y2Ds5]tV&|i */ooVak[`}(3aJگ2"/X} V_`:%W ZE_[KCB_czQťhe'[d[)}*gWaF*\t?a%јw|"X29)l@T,T7ӜT`ɠwl'LϫIPo>X9 Zk)t8j\ܥOl}#]eTJe\$Yj+Q%%&' NBz,a> /{P.JL+` gf¼.b59$' C$QLHAQ@+Sd?wȝF*2"He*;C~+T DX*IN.AH4UCN@(Lo EP]9џ2 O)_<&)a?V ?O7Gv10p et/+ -Z"`rm,_Kiik|V8/ [^2)]T 7NDxa >}?~T9k``cΞ=m g(#!³g/9}ݰp{CpΙ U-W>#sdj#XvVyX05k/i FJ0S#\ 4E`?}_km960CtCif2VVJ!Y B9oշ~Y9`7^~>^IBt}oAoҹc=3!mnAv =#=e}{D|w-X*DȂ%{KFjtY2dV$)A]zftpHټTyf`E՘\"ݦA.BW:|lARŴf6 ]htff{ʖ1yFo3 ,f 3/mFՑL $Yh}e,=ŹlE{`uSszF14JΥ]3yv #"S21/rt&@D9VX 917Ђ%+ZI މ`5r-Xl H#V4gZy;,4M\UWڎ>ihdf4xX ΋ Y"#MRi.? | It/^ϟ^R<} OǎG"&W(.sXє R,h* b X 'ǁ? RH S:=lJG7w#MA+ڵk@V> d޽{@Lsyp|Vpo&0h4z`*pM*+(}`-*q[%xH1>jVŕ_~ ;+tNU8"-1r҇v&DgڱO^׮v^(/ml9ztȓ?Hw_!NJ1߷O`[O9X N?e<@WeߒbCUcW==tɈ`ʋ`-[f|} V_`]rُ\/Xti4εEKB+dՄSK>~ȝ!9XƓ`̨d`ׅ>@x-_ *:C+rōSE #c_3RH(Ob-iqôA%_3@Z$[Xʘ:Z+ gQVlk뉜mP KW;I|6R!,ueC8:*dhrcJW6$?䮜*r HeyrD$?] (UA13TH* q#M&U)&H0I4UVH.Ne"4KrL+3&ՂY>p ]EA<^R覢ILߣ{Xx ;d{[ Ӱ`FA;˩CP#Gp'!={E0 _Μ= 8 ;.\ pJgl /[J #.,p;y ټ{ܽs =y' N;OFrT%g5B.6_<cܽ{8q, () *ׯ_ϟ.]<0!;wy̅ C]{{74$Dxu& Cϻz_.ҊUwJ9~ը%*r巿m[h%Xǖ,`f#MH1W0ɲ"N,PS tpCr|Zq!=GtActx xUO72_e96b& [D$=$W̊+9X$WL%C^! +X!`i,'X!7`/X}.X_ } 7N[ fܳݘ>@^=.A"${%dc'?O&]v%$udذ{ %!C%X*)8D(ݛS)yCHk6W$5E{10Ģ]yA2907,g++3gρ]O6n']|5oo=@WqȊǙX qu=pYo>p-kxxHWv7n .O>Ha o޼ ._zݵ8EB$Dx $>&sW,f>&Nߵ8篬]kͰg# >e﫯/2PdAc*d-)}jK H]-`'}_ՊKg_<@"XB!=,jIc09"T~Y?/C$G&\{kx@zYrאaϡ]hJW: $X XtBʄe͌ʱj|胥[̊WjǟȊ:0-I4YT!0R )j\>+v΄-}`d,3vF*C9dFa\`,-@18=C%l4UvoI%V(o)$G0ܰ5XALוOZ+d֥`9˛W8y5=kEdlVWzKssDIT$ #ҔYz*)h)3ד0D7$X2JL2p*#& \S$L a2X3nG#]IpU7TE{ %Y&!BPw[ti[3 I\ms-pep5WW&q/S *RXB!-h@ƀ &2`]Ӂ!ųօT߿lZ.H16Tw\xs_%U(ɊѣG}Kb1Ƙ\,DFr Fo22rpjp0JHJГdϙnk Ur?_IYv ǫ8☳(TOm^e?IwXJUvrHbFVC"ZX$19>vmXDn|v$*_]%+XIVD"Qd]Ar83&@aȅ>$`;FftUXmi jWiy&b^?Zh "-i+ s˖kZ/X} V_N ܊6ξ`#XyBЛhL U]]أMFz;R}&r͂p 8ρ p2r>^tWL,̂X^wbE V*~+[l2t0=zB 2]ah71m "c?͈ %:$S obw#beWHz[9[PxyC@UEz@3GSDХBPBgZGE m/Le#\ &&عPY nDDH5Ye/zhe5 L7QWfz0v1T d:MzjQU+f3eP(4l҄V.sePOƻ<=pLdYP^[0p ؼjszp0XUr9MT)Ns^%F`t!xyk7^>8wep D J_3ƌr@jT+&ipk#0445*;w~P@nEBˆ`]E~ѽ׬tƞ%`]k|*n "XgpLM-a .,~Ť"DYSj;s gjK_LO6{H-V@d `m$abLSPƟ0tӮԹU"i=Mh`9)n_ ,I3 jr 34,i4:ƟJ\a>)Hx9XZl)ca@ˌ V_`?`O_jP6 V_e'@ zx@/ݧ>.XBh|,R&yXwՎ9B8"@ #2&}b8Q%JpӨ`TC0?7Vt H}@5!rzKQ,tI$q  3Eҗ] }J'j +2@C&J\I1#ɕ>K@#M=j9S-&b!cc&' sMsu HO΂ebWg%1  IDATPnl*6(V9j+W ydJ?ئPQEnBF!ɐogWbn-itEo ePo}Zc`W~ ?\ڶVeb#A0@`8j‡h-e,cP4ոA'@ 1IL!d2/{( U楃sdT1<yI?t 2pzdK%̙3`׮]eKKP[7g];5s}f𲽝odi  E0^;NfVD꟞r|2 FlH/fm]m:uK=R9iC$\heg{>]%!fQ` D#c $].Uk҇Q9,*ŽBB:@ FK@MbJ]s{H: \/ eAW,`Iv8˼WC'@`IΊ^Q&f劫=+Y]ɩ\O <0g5zVXiEE퍕.Fч^0m2xɭ2%4.3,0y@3`)*B3KN,US׍= e5Ё)gsTD9Wx2+PJ,13l-#ytTKecz9is fg`a;@Muϣl0xBG!+LlKcj`yMGQ/jl ЏR#߿TЅibUK a홌B|7*U@D*yP)L&"r+ӠXJ}G\#EZy`L35rȽk5F24ma^@%'831p`:3c熵@VDl d)-HTe̴Dyb `0 <> cp^zFFF7yHҁ3_8osd}pxU;vtzI'4ypȪ4v {2ttpQ-p\}b=ڿܼܰ= H Ƶ97´e0&h{$lii$'|Mȧ^-XN: PAՌEcĪHR"bGy}W55*,1mFJ1ORh xMDB4iNۂ受@N`+XjΫ("lY%*@ڀg+*,BurWeܾsF#Z)+&y$O+"GΕ(JIMru//X} V_o`ż.V84 } 7V|h.LԼF}"TrY7냱/11z3LH߂L}64Hp> !Rci Szhc,&__IՆXxiBd9 J +Ew+-XV\RB]#s$'G&hϿq hk$4(բ+57!>N/jKBd!=`zOzy#e 'XTE|xG@0!]%(?no/,3p3m nS?$Fw/XEu5 #C6`bDZ]aJҡ|3fkiԦADא0*n6!5!R p(ynqV&1-Ri3v[7ټz= #a)DLVaŨB&L^?HOiymOһݻCY!B?$'}p98r5GcOHTJeŋÕryrΝpyw^pif$Do*p=Q:1dcG?1r" $(\y5Z =1(EU#Z~ߚ|:Ղ 8KТeBDsk.I +XoI`-(PIcp֒'!JsH_$aL$S\<*(]+Tu ȥpܠw(d  {Ǩ0e(DAȽZ]DwB/4*NgJVYv&ߧ| .B5Oe1F;o@9Z90h`h'Fx}]qVdxnajTAʹf6yolHo69am8wڼz طm3 ʂD2 $[L:IE{aqOXp&aawo >tDy _ONtb`llw<FB=cR|`ከt <"XgWwfρ0C g&dr?K@*"O !W[w@x 'pmpo>0)HX0RHAqC2y8Mv;? +G혢I㝌$QL`).n[m=}rǠe'RulW QT"K9YޟV}2*,VBϞ;׭"X{lA ǴOnci` Ag&=U 8XF;zIy{eEU5(chL" FnQPPuL@/ F_5a0Z*l?OL Ab//-FVL6E M1x`NI|5QM(<,kbʑ-2H Mv{UpI *i 93"  W N?"L4Xbe\=OEއfr@BrQrs[3U4j]Qυ S R>#WQLW$T<9S7 ()Hr> H4ZV.WQdPS 7mEd5$;<3 hl^9"ZiОhNds`;s_ٵp~A&a$>{FFF#`0>q8d+ ҁ˾@:t0dD錕}[N$rٚ㧯ū7DjسӺ+"=O%%RGӎjitR]M(cpDu^KVΤ-'?wnIFlҦޝAH1ţ^Q1K}`Ͼ fiYfeHK Ӈuc(ܷ{y~f/TKJ4\xuqEdf9ӣmܶ0cl4f.9?VU`cQ$V(upD&]lG?;HݚO>_,96P|=1md+h4Om^7KfT-`\L!i6 ,W f%m!GUS+@c d10< j^O'p Q0 `/X}Vݮv ӗ W} 8ΈҎ'ph = pp=>sܺ}AJf[9 |} IO< S{MC}~FBr@xI'<"M.\._p4,IXQ~ΰǏ<KnIXq7.s{ǡUg/TUʠj;';͛c'TJH Dh9A+<9N/۹O[E;KrՏTX3ʤ4se+Or$p5ɫ*1cP+ 'ڹVq r@/clI7@  \,&n*$WF"X|$W]H% )7&g`3}֌|gF& ]ZvN1嶢:vRx +MxK[ ZĪotU l|5O&` `/X} qJ?"Jj~:+mRU)->`3VQxZtb p8I?&ڵ`s!0Hۭ괝!<V0cٙ,h))Оρ2,Bjw 0U^9P#abX8Y2 V6J2frpT `gy̌St!FtZEyװiyuK[> ̶&%Z T<3ohXJ<;L tSBϭE W2(ց2>% bd0lυj  ﵢgg5ULi䐩&D&: 噙y` p Ȓ" CÈ`ι RZ$JtlZ5THhRI.K5Dָ=ƍ[@ĉ48N: NT9v\|Hx1O =oU(c% R zBwHЮ6SUf3*XhI؞LTȒ($ÄW?>c#܃g+*.͉HF} H}3XcG6ϟ{wO< _f2 I9#1cL8=/cTY"r>Nw]('7A*& `qwu'"X!:9g$ \gYw'+\׿:YG;910vXF'wIy_e褈!'[2&R G_,S}geU0ps1W ^2W'"JA`$6#g<)ӛc%#zwXa} w\7g:J򌚳 ,ɭ D9W ȕ1-X ]ȪWy[so znP2GrHiIj_<ɱƛ5a3_X&]"QPFӬD K&^Ab R/,jZNfgH4R$,(f[6!r>Fi%j-X uDy+joiV@ ֢FG䯒ˀ{ב]wVk|{\4`YVmusH09fh6I9ɺk^-K,$TUoekXYy|^ .ofJScc(,EIcd:x)-1Z Ā8'3]4.)g3<Iϩ4㓴PɊ]ew꿴|)_ ܾ}`9WHAA0ߒU//Ptuwn'OCj|>$O 9r_cڽ8)VBVԉtۜx"/~icxgVd1[A>/[x1bW.: V3}n# *1E3Qn|A9pIQtq%WD!jxJ@?]7JȜٻ V[k'*iTJBĚb"&Wms;fI>V,R܄1Q͘? L#Pb8Knċv%dNPIH,]kk`Y׵ [zuZJ"7 S}bMp8 a|1>8E֩[_a}k~irww""UWmI:\a֦Oj}O>Ě_U"XVER+V>իߊLH`U뿴`ehC`$̽}uP=|/3#OW{X1 \EHX _l۽_["/O~#,Aڪzpܻ˿K!as~jn~*F3gjbDft0blR?1Ac)-E~ GcxYX{oY,ht8SA*"aB"{q|1-X8ȑ&QID"$kr$%Ϯn,b$yc8fŒ+ ٭?" %#%Ȃh4z)2d`b)`BKU2,,,C y,K!lct|DDI38t,ŀȕ~ޛOtP 4LzIRLz`[_!sQQV1$VIBLL j` nN~vV ZaCo* C/AY=wIڋ)/]""K[o}`'U73 Oo+akvn]`U"X bʵtjVEJKv+Az8Q"cW US$i8Z,]a -DeІƄ8ӎnc뗿9o:vVq޼o|ӛz 2~UccGA"~m[$i\`a}@ C%0C!wqRy#b"tܞѽ8%"kd(p$:ʺ\F"t-FWxI7c8wOf;*5\#C%[1ztW',yɌ"Ҥf"F1#rX&XH9'Z1 vxOI #1yds!4p$D "=:+MrvVL+@*j$RLCTwv"`蹈e3yc㠭?Qsɺ@2\tȁ-MH9nkwLC}>k DFk } $;D'x^1$H,?MH`=<>f*BP&k8yrJ idD$4(xmyxw8H-AܾuKf>P]lB=1Ie}%Aɱi0px<*BZo?f"@YBv)-$s!DK̒~ϟ&fY0K.WE;͠f&Ps+0=0 #_̅ ZZZ|OOH,k"*d]6Yc,d\IP'PK—ao3P!ZM '-_*~[I, {0FGI>O,6/˗LNLs@_rTi jR8.V8^dy9h_ZqFEDb{$X[~Ţe~,jUT ٫@X J|h4'sy.%9]f9 }HSJ G[ ;_KN܂OMJ(-K2%LgwăaP*:CR(h .D>yPLW}AvIh$8/NVmU*w+R(yݶ` 2H V9`HF$0/;FW$f)C-Xr`}$KV1%* L:K'3/lAz֭fEp% B%,ν:GƜuHܬsӧmP?>G@"Wuss~tNprhU1$g,"F,I"%l$VriZ߿`I%o5, wz{zWc'}@UU}6ɿql$]-k, ߱,G=H$i#OT1Df Y0-;Gvi4ڶuğ&YFPESM($} JWm%OFL F=4q_H!T"kV_{7f"X;s@Z0("fdK̏Ҧ-f\}{+˚bE*W%X2k[C@vRCvޙ\Qmf92)uc`a FG2$3EփI+?b z3Y?{VwZ7 xhxS[kbgo~,_H(OFr>IG0Așm@7/rFdG%#&D0v0EMyr8JC]%)fàdE+f"嵲fp< !D)R*H,$Y(U1&FpwP2O+XdC/ƟZD20gq -"I8nיNeER&["aeҧÈX didJOϙT d P\Yr[yO7j"bt!FI@5P?Ki: /(aT0^{̬3h]*lW^y+2a|T s 488kկ)͹79Wn}GqmppDIze]v?qW;Aq%1Lv•:ٽ^WV*StD`x Ï=\mQp3;UL5նu;T{`XM :t4CULkir՛px0(%[Iwh|>&`7ځZjmm7nR{ 0p5MB-79` ʫj±ЛK`m$Xs!k>;C&T OV) =Ki:.2g#06=x9|\H0ZGJYp> x!f)%!X<~.@b/V"R:`mw|o`?V͞@6:k#XgtV`U"XY9Vng7OVEvvIXZLJrs6Ϗ ,]c$?K,ZL102OֳUΥ|:8ORe'Mg/(HM,HI|Z$`e})"9t.9EQe*PEToDL9>\Y÷>B]׫p;D&A2[@B8R}y p`~ +AGۗ_m-IKӵG+?2Aq~WTT2K`<^&ėA(c9>Z>\ mnwn۱U*XT]R}e˚.ǟ=dZA~:b45͛@ñc@&ܺtt6v "Z-7o 9 :z q+fÃGK*G8Ir7}PV7U&DHS':!$ #G yt_-Ӆ]䙎҅ٓQ;hݚ[۠ޓX]=C{|zt afy|wY@iV22tar`^:qRVyfo [÷0W ޶.Ў5x$x@(B"K( UߒE60j UpY~K dBx#EDD)6\!' s>08L<H=PIi0Pp[;(2MLYPY2+X$JIVrg iI1:&甬>#Nz%KT^œHj2XvuT6Z2Ȫ*]E`ʼxr`I.`lB~?BO+X",q!FXIM<'s ITL[_Wns$N@KDIx,<*AS! JrH[f`٭,VKWJ9|>Jԯ+wũDt}JB#+:gS$x| twwնa$ݖ͛-Zwfp@ \b?qȊv*(y:a$_1[pR) aђm Zvn }w+C[V뵛u`U"XVE,|F\-wv"X,3Vx nV(F` ܻtl7\ZN`rz,,\L\КDA 1 B(GmS+2?4Xo FPσgƀO $@: y !"ĸt)$YT3bO}D0ݎ U+D!!<,# ~G֌' &`I9zCYNfs! 3C_FC`x`DyN(NDNy ,9 .CU17"XIY9΅"[i+tԋ).̸˝y +;^OFdK%D bi`D8$uKn2{^^P,81S (MG'3c^81#g3QTz0O;@{Cu\kW5mAEGhCڍϖByLCcQT-eV%gVdbUaʜDv`uRM[X)ȄUfԪFm,.#X},WLoxShp#6TӾ9zٷڻ쫮5;[63ǀfD~OMO; E)3Xtl,g+ ,rB/81q:\ pH zU},X;7`—2-Vo,[6O rl[Y76vl*,IlouT \1o\vh|Ssxw\fB=5s tXdJֺ@Ñ>8f~C䌛Bi`d@ϔ~^b$3df2iЋdXHs @@#`z)b8)x:1G_K'ȣ/~=1%,5yݽ&Hťxc c*ri4@@WVH\<{:?OA[#FpiT뚖AoLm}C=zVp p5+4mlOMs̙FpĉS#9Xnx BH%c$ML:$+_Woe[XOsu"b˖BFMOL$E5'kWp!w>=։5X.wfPMqq60p o\C= #^կ[X K7h ,z䃻skgZ{hY;< U߹YA# +(RV"MhܷC\cHT2qA=f2es%b֪hm57jٳLp9|N)odL(0Մ~BLy`6dɩEkjZMe#`W,,OH"gf(G99|`ibp̏ բi`H,s`~Ghx,Y '#*U`U"X+45ko+ Wߤ`Iّde5ADp G, ˁPR.P xa @yH'"A2Y|䇙7|ވdJQd/#hJ=.ʉ'ff<)0:zqt: $'U{#s)b6G>s| Zkm%h'!Ttɴv6&vk`.x93 Վ34W,:ISMV,]76v#a2ti5?$UMRk@v^<I:=tsa>P03@5Vkec%p>l,WĜ/nL%@"XVE*U?J~o%orU`M TAh-H; d'bفpu(]Ä<`  KX SDSRTXX)f ID {"4X)&+` `97%2Q.}p"I"Tˀm Xps"M:Ƅh$T+2ɪZDRL$}K, ZQHxMBTXnPo[tq|I}'dW.%5R&5eN?zDTTi0@ H)SD!pd z8zo?}M$O+NPpXk[ApCųQ 5~+`:c`y%eg#yWW(ș[ݛm`e_W`ye q / W{WYhdwpw/)ѕr DwEd12 ڵ *'N{}U>8YHhPh$bIXsD>vhvw w(6C~#fUUL$%X,avoGjk ڿ3ҵ\*آ+.rMo'Gʙ~ ZZڀHRWW'Vtr]Ggpb+.x}CCO\0 & RƄdwn^?3IgC`z1 IVŘ"X $ˮ)JR&NB,<{T} Y:f0:Yc3Hjb&VA>Uk"VA |Mv L3ܩ"%d5C0PA.N:;%^ #-3;$NY|+ν╬/]r\`Er.]bE"XUUմzr$&fJZ)H%"ibf0= KA'qC` @t'\/V@Nνt,<}2"'ֲ,R UD$)+z,F9g9cezOwn3+ z~%Xto}"XVE*W&XOv|d-W5thgE*U,#XR\x:X"U\}L>}~X[#kv`qxmV,=C, @֙Z!5nr6_(jگD<K~g1zOQo lq *A(OFtDv[(E %VT_ "r.)K#"rP mp>:s!Ȯ,ݼӮ[%PϚ4L XKJS\G*?W@ru$+A-&Fi CGf-U|G.q4.(ɕ{,OZ$w϶{A3061 |HkB͑8 O*''W1gg~( pp ctV-a|޼H=GHZϐQL_K+A1桮[[(1#Tfrl>w7}OƲ`t| [KLGg\p>~=nWY*N\1{yv;Dذgwl!avm־#W~nv?Xテ@kNܬ e8ޤ1.߆0BEjB]E4 g14JƸhyy-V6W y7XtLWQV%@<8Jcɹr]Ih"1{,:v(` b>S4(#JS @KJXO1ƹ `Y}S#X">rZ+,bW/ $Y/K=`"e3/wI83~lUhYs  euxH'[踭Kj²W<m 0JRĨs>( i$ϗG =7:m4C@FHV[.]} t.5]=݇`v B8G@;-db$"-/H+ >U-`DjPٵ_?2}[7\ۿ}+V,`"}cVio?}ǒQ%sֱVN#zrW`y5Et9J'@]]=ػw/S ZH'I۶=n}$C+^B{p'hS3tQ"T~c$R AIZvwHЍtx%kDƹ!1= X*4(I)*PIuqwaL]P K9<$VР$`;wC<>ap:%/0Y$W̜'xK0HaH83-H>LUL6|c#pI(ݎ orJ*u^\Ԣѧf z Sj<^LT{v^ 炌_߾׿uÅ>ZDav E0WqB4+=C=`l:&E`EVRfVX;[W"k12",j+t*JieA0Q &7X"ϜɗBV6 ɒT12oO͢T5R6LuF./ +<#NfFn 3'}͛y6 eVX8пxc~p0` HTK}p6Y|R7nhZL9A!A7p| x` ҹ"+ "G"KI3gH+ inM rlWfmftQA"Vf$[w+f&pd EνzTU{3u-\^&r> 96;l-SidMJ?CC@͗.ZNjeسCGL։ꭠFKP=^ '?(Y N;#%%-vbo5@ϛWhWt߹-@r<)0]SFZIi+ɭsǣh!bgWWT*A4`};;:mmES*X"UjH[ɽ6+X Sѣ7'/1KXeb|,,?||GEy6'@?i+']]D3Q-vd12mc\*|ɉnR,/qg#i^cv'}*U`U"X+wK1<["XFrŜ:|`*б8Oa5Ü]/ xpf҈k'[Pш$DtXO7t?*,sUZ7nX!B%X/0=;G`D sXBp'AcHT%c}$R&)q̀\G̈W;d.+,IUAFJr?VN1`&XK;k =`^}54tp 5#Cy46(ϟd]XʅKK5W@3]\wnSJϟ$sI02ϖi{9h}w&5nt((!`ХOWa]C`g`fz x}tΏp^\Q#lD]~^wN`<98;#mA{vT TjѺEǿg ltM`l>hÓID]bB 8.m b%aA,t_xl$X'OǏTWgOAOyOB*$"t: "HàL4\i%iadd!T F90I}Dq}uҏ@p90(D~g:h"iX`6Fff/ \n^S,iE@ǵy֗usVE*U`͟XwvYVE*kbA$'#$H$"V!͗ ֬'n<Ά -XܫI]1b&E:3IB6Yҗji"XoUEkl! 7:JFIF5T̒\͊`@*-}oٻ^X Tڣ/읝s;G* :sk0j ¦·2& wv*m0T^JClx*g,~88|08JrŘ4ܤClGJr7Y3rc=ڻ ՆGwx8\05rγbq }5o3G/TjQ%Ln+O3c9g8Y_|rH~Ȍ VPuMW?!W_Er%bQՠ[!& u9r8P[k$bݾ3TӶ$ '$y@1`g*CmeTO*!BN;_) kc> z-X!B ~1"ᦨL<@$T^ןD?X@x"XVE*/X,W?+οΡ"X Xt0YI2.9 HRV0_ 9 F%[tR&Ec<0 DdMxL}YQ5r2( ܲ'R8>3`ib{ܮ`E H(cX9{c@潠H()GυȓVCChl< 3gOcR$beŒgNtم+m@L:4ktt+U|흽E!?w ߾<3s^+J 'bLM#݈P4Q(*eJ pJ͂pDMǀ7 B Ty8ʄI <%^DR *l t=H+.:jl{6o._8 ["FUTST v_C˄/%Tzn~XJ+{.ls.hmi7nIS[H_#|&ro%n}uzym*pVs@1;sߧV7P4Ab.`p$!dXtTpG%R R@I ~zX}YrW&p :|0 $WLoO/>`ٔ2K[+X\ zuKZKl$XfbX@(U0h<Ҩ ԂeGZY:<)p/сm]`ќT);udBBtݸl=xX\%z,x‚W1Q,8z[휳Ugq7<\̬B=r]5hxȌ@3F*{AwwƱb%+WP}ʕ3WSdDN`JS`Y;w͗45ΐ\1&ϊpIgLN-XA,[yTK#-d,S.w%TKN+uWA-%Xk@7sSpR>MK<Aض|P`U"X ߽grcxO[+U`1,&YQ+B;U:1Ub5<n n݄;366su@stMr$I5c~B_A̮d}M%&3FVO6 D$T8tHXۑVf "%>"Uț DOsB"V 4uy:s #G:Hڠ4,xLʚX0ұ8(e`%K`I֪ -X: hc>XqPP lRTŸ\$<^ OYkd᭷ުVE*U` փ۬G#W}:SUE*U?R$SZ a r/&C{FE`5k*Pk%$P3s!`' VyN7.T$\?2*,Ta@Y0h#%%D(bk'L[dJ9vвW]hB|vP UNbQ:3RUPhk7#`|rx@Nܟq2DnN2)Yr_ydC {b 'd[ ./ߎ$ђ"O@ÅH-xI"y8#;Ǐ='f3`f>}Ip,Gr`$r'S`^r -`EDŽB I#Y %߻ Ɲ7>P8ea7,J:25;R i8$a?= DtD}E*Qk칳CppvwF$ZG6آ`%E!&zk*i yߑ\5xp8j0jǃU@tt)lSaAw }y";$ ~`qh="-X"b\_W1LL=ų砘H I$@*bDlPĻIć{dҷ)[ˌgt`7'SKD@ z]Ed!X+$XX++@+OXI wsw!%ݠ4R$̛\'Aad֓YƛըvZHQ5f ;KsLuHXyNVy__"X1`Mgd%ˌad+ #E3*Ǭ$@J.{^M̂,RST*iȵ:ӸnQ]Jm'43=x)Bd/A,!&^JHS6 p, -#UoH  <"uL`jR~1DyY| N? 0UrdKKDW`wKW䊘'b̒\1rB$ρן>z~Y$ZtHW.b%!L|ouh< .:ldUk.1+=_2v&^~Y@Ezl;EKZ$Vin)ϛrW@ sDb)Dn\s qOlڽ5VV?*uu}fTξ[-'Ã@2^),*($w}h U{Xn }Z0pp'0qh>wHsLzFTuTB'r^9]=([Ca\sNO-H1#"$Qa$ Te,wQb05k^%X:QVuzI<P,Uc`dJex\&XouWzlKhe'KoXMtekK~\>@֖̈́T"X߼`M3#W-ߕ"VE*'^ it<j<B@( 4Il*L?b OHd6?}W֍p1z}GX?ןBZm@ay[u'Zߺ u@ӏUwꜵiW5A&9u'[v۰P Cyn 窛 Q yD!,uEh`H91"#hrn'#ᾦsh4j΂s@DL˄QJOڑ TD,KHf#OU"eAcTޔT$w%MsM:3yE51H'K(=2bUȘx&)do@"6bZ'Γ̛\!<"H2 2{EEO˷4X댄S PU$07=[2W6 9q6 L+GV.XTmF e㩴hUeءFlt,׆oA28uv ޷NVo5۶hh"bzz,Z SrF*R^)MZ GxFEnęjŗ  j/,n1#9Gk7:+ ~׫C-{?p*`q~[GIyo~rgA\W`U"X5m[I;nVE*,SDuIq e@=FŮ0ZǠ54!7fu!靵`U1˪%% #B#' ?''$],` ׉`}m*|汒0I=4Eޛ YCÓ4&ɂ%-@?ShKQ#O&p^`<8kFDL;lQ r._*j4f&ʃML6)W 0j8N?6oϜfl~Nז,{) KCb9ŒiSuXD6_(}rUiΕ}s X<($C %)WիW@[{+z?e~#W8gEX~& '.nhrg.XFy:N&L@=Gcpͽ[ǭ`U0~pK1!<FΟOܹrH"]w!Zo)0AUC<`544/taPX)LyDBFX pHO,X 37)Xa)WD"}Ń e0<5 Xж(]K=VIDe{+/~#n Mx7KV삵)}Mŧ}Kێ~mvʟ7m VUU+}o~St56BU`ք< MD rcP2qwbծ1)WcE|rkbIդ-w9+g,ʙ])~Om!B%XԿ+V]wYT8G7"U\!WoŸ&+ByEp5(zIO~W'Mi`%wn|]*C!Y)OKLnM*\y!BG}]UIq!8Ae}8u=+=y_.>X}64fczH2ܟ?Ód}UrIs;AI~UC$$qOKWA*HJ+:yuO'xC@Vn7(9EDs I}$w{o>X{nGH.,+xT3Yn* \E{ergmbe%,$ߊ&=@νtXNcoWzv wI<k> h;m.++C0ɫxpUyUX}Hz k Kޞ>LyW7`/nٳ`t Xk9 VO+O'c -?[# qEˠC6؈ֶ뢭$R~_"|ry~SB7}ھ};qk,Ox qMX8!)>專g 3ܙΒdJ_ 0_(6T,~ohM=]' ^qɟ)?A{*n?3i劭r1MN霩I4˜y&w,x,XS1%WJ7bY,X1%_cU:U`8gsb&6B`"4&s`*<8*ؿ?8n59Wܖ)V}58'6IA$,K^浺-{6+X{ƣ< ʳ"X0X}' 1-OpRW͒TŬg\BJ4Aϗk8A+XC+W5ˀ?":Q5M*珆Q@@yJ`%M7R,Y )O4R %Ōm{ W _E*m`U V*HC667ը Wp )urQU:mŜ.Kω[p}p8Iu ͛k]}`,U^2b8+øjY:*bEIpYƟ7uC~ K ֤h43@XoQӧNS'<UyRJĎ#Y흦ƍ"PIDATDXqED*q p9s}dd\LF,IY" l2 rKB<0|9+8>([GTl9X149htIMbp V:PK眽uR`U*XU ` mVԎy\`UT6JiP?y`_`[*ĦkJ i6+]q7 sJ ǔ]~ Z)RgTx* TÀCV8)a.S(fTxc-D{`߾@QK,XN`w{>i8t\| LR ܨְ`dBd|2 HoUA&9+UykӡNGyR. t އC# R֎Q@fമ"䀩!Do cyEIEPۣpICx< b 0Cj"K*`()mIa_o?WǣQ=4irQ%+T΁s  &WaK СSbpĉr"<u/ݱ%J\5ۈQ?I=*(/ %`f`x$uo6fQ|{[qR?9{|Dϲŷ/@3)~ ?$XxN g+r2|86}S;-NV>2I,AW DӀÇY2Lb|] U'?yyR b9Rh KS| e2pJG;1t'w-XHP7;9A֣b旊т5g)V'Gbb}={bN!ϔB+Ļ˿M1;+êfr 8{ݻ[A@2ܵ+BL`v7G 29p=!.lQ)څ`]!4ERrKy&c9NO (nj0oZWϜ&5,}Cѝm $O'q7Va 8,X3%e>ks@˂Uc9!E+ZTd`p&]>t0JZIY Vq_!DG owU,WbTrg`ɛ~J2Ŀ#+n]fIJmrW獱Z Rpp%ˉY'O>@x pFhʀ0XүW¨Vh$J~-x5,n3 $Ji]aH~y;|:j>o|ܠ u`6R*Myνf|A[t`]Ul j*WXKJYrn _!rEBr[Tr{MK4y%N~%j6}l9̊=GY)| g-ApVy$ @4E_Rƾ/q+Zg()Y&kY~Έ,aYY,B8WVV̾zٜykJ84Ap3ǟ+)R 0ok Sۀ 5빁U VUU#Xs \Ӣ?,5 OU VU$Vr DCcsEAj8,~ޏU? SN4Xt_qopLjX.p-R6/T}I(DˍRZeݾ,gl\ !I,b+Tm)2k9`66csJ/>2'jz'Orr2USi~*ęs_{OG^%WG1.eq\K#KxXxPq8/n_ O/ըO͂pVxCs`Z )HFg`nq숈s ^@cȃH$ B.[|4B-o_/'cˋWA9xj[%z^ODd&W72܏l0ä92l Vd<?'=pA-a_hWWee Nh`*K}:ФW}~^0Y{\~0m,Gz۽9JO3Z>Y< ˃#urF56>0_XAVOuG ?’"#kJˈUqO+s[2@9^h ‚KRV ,)No5SԻMbu+ⲔNǤ(\Uܩ9c'w.s['HN#$kHHQeZ$K YI OI,ÇKj=aQWԀKvR"4(X+ yLW,l ]pCfسK 2%ŌpS8Q=Ф rшhIUe>X<(%EPÞg@.Q) *HsWww]4;mcRc UNU┈*Y|D^(Z-'d0UIbHxnR8AUTIJ`u AAȴ]8*lFʂ߈x.[W[n灇d:{OG/܌+,* !u͚F+tzKsX`qp(i"DRgE `$%e `uJ~&.^Ma3K1|YM-hTYDn'80jt?"F<0&-SЊr^ˠM5')Sf9jC*Ū$PD9rV+jEfW,=/>yV _4ݞ{6qsN-%COG '}铀pQxWmm$*ljp_5U|.Dp9V^jCn j)#됬RZ7"s9 )Wē}{ݠ}gch߀L+Uk9k*|.eQJb&+X<ٮQ8W+q>~ORb`n*} Ue泥n߿|I҂lbnKG,BKF`}}KRUU`Uk C/V 2b[1|gR l/l VU(XRi* Fd/e`l& Xʅ) 0`)':N$3*`r(k"QOl$G&,Cu1-li=-Tb\R+~+I|8!U4lRLQ) GBi)" ]7̃P0R@(y3%[ 0u$|:&TUÝ3`nW/>#5GQ8i)QXdJOB̃D(b%YM4ҁUܞ7-CA$ k.VN4`d2}}JkSX{b>DѢ>X򄇜+y䕫s^x)UVP< 'NwgZkx[$|!K6UXZ.bѮСWmȄ &֯\|yh]* p,bbe: h`eaJ 5{D7ԃKuuXm ؿ{h0*r\,+:9X\MXNXհO쐢HR0 k Ο`>Lu-KqP3L,E`q* H] ,"u{T[S삕zwi%XT`Uy]T%n)ðlt[|QWߏ}Ϥ`M\40+A$`5N*Ƃ`~ȴ`*1O>sLy>le.[}6)!߱/Ti:HwWi1*`ԛ&"^RcQ8u7E,!tCLΙ 6q% J`q, &9FԘU"SDx ,*'SB}Ĥ)y'VA*lJqNI}0X 궲I$#17B-ɃlZa|RP-Xt -d$.hmVlZ@A~[& t\gb)Xvx͈sXZ7R}乘'2RqK߅rPΟ7yu\l> ^haU]p O_P'Mb^XWV,XF~{}y ]=FHF8)RW!% `-iE_UM.19XРk^E(# tD#sFil=*;%jٚ+b/!(v64>JF+XLr#sXՄ<^igNm"ffbiepۂt, Fx dFp.cyd= 29k5Ռd*.##X:XEUoŋ`UU`I 2R~?[,}R;]U۪`U*XU1뤊V.\VI}UU`Mc]/܃T\_9`,0l%we!cF\~QrS4*Uwa^q"<`&A__#K#&)A{w:NrwבEEo-peOX`xT r jۉ/{zܼB <,X=  =+1{:2#'C`*^:* I%)EIW$$M6+_ &* uUH@,dNMJ0,j\XpRaD4 Rbj%q*X2aI%L*g%k,s!W u2+/'3{ || pvz.IH72`%q3g/҉bmU_E~I:TA;W*8~qqT %/4Gťu0q N60LU{bxtL 8/ZMbC`jWm'"*#C*:{@+b 7.Vr8*dZ'"Pt.E{%aqWr\y| <\kpc] pY0:ҀgIx*%怙ɁY)WW#)S-hcv8*O+yE, 2قjcYA[k+8whkpȃ$uܩ`ZEdznZd ;M$@*'?7:n}`rX {9Su)?Re(t|,]$J*_KR+xVbD6?Q Ff"8{xtOܿ Xփ+R,PkWo3 l@HgvuunMbF+0cmʵgWlvMAFtw^#ba%<9`7`0W+R<qyL$fRB})X@zpPQ4UVKbW-bՙu\ 1-,>W`9s"v vJa$Ind")'n} MT(ZVާ:^d2c[/ɟt2 fG^|3ChԈ rf"' +oEFg_BrGqh>u*XU VU+7/}bm,U`U*X%U^\dbI$x3DXLQI'-hU .Y0DX1{^SyMV((吥@LE}eLmOF=f?8K`A+ß[{hP-*kY:Qy #|HLhϥ54E8dՅ{j,ybǡCerê$X*,'XV.~W~n)}vq%rD( [O¹Iy'Rt"-">?y j_1@5%Kh'CK[cZ}vsI-i9o?-`%ߊ`mDt*l4ǧU`UCrs[ljTU?DpٰC;"U`U kcp#;?٦a.n %`*(ʪC\EVTa<^HJ9J"&fc`22ʉTZ /v8\ .hm}\]7A[=@kOۉDopvݷA Tq 躭h{XRhuMh}o)p z))dpo+劸Q_Ky"LP ΢u׉r,!Be"/IvGX/!0;1 ұ/bR¢R.1r&zyR8b8K`rV6˘(n7\$@B"iH!}><'ʽb6 w_EkCiMJPVp,X&I %Keb g o% _ 8senR.,)W(n$Xy_7^ny]Nܺ {BɃ` V.KU-FG?h:[A-c)^Fp랢Sq]v`dAt*ë_ӑij'Rh*<@dĔXZb9jD+Uk| Ϟn_Qi⡸sYkZRiJ/fIx#bŭqJ2-Q  !#Xժ++~zҼD9,f 7́UFe4:0!rOf,i]H8OF x~M;|Rdj`u nߡ:'}H~ @Eeq>Yw޷K^8*?!t?,KlŒĽJ8G匮&0}Hʄץ\ { jE@b!0tw ✔u{V9Xx܍3sՄ\^9.)WDNj4^>|3~>Mg"L{HwA$жX) ~9Riܞ~~_~%SBhD lZ|`objp`U*XU*#;Ċ<\. ւ< S WV׈b>Չߎ9U VU,3td`6́7īPihk:*< ߕ!B7TܧłSIH0)X<*$SmT A5`dRִ܇pSHaEg܆+orc}22Sk& eE0?4<]7} zMXDSLO{ZpEý8ɾ0ht@CԓLQő1GD<\rE^sJN_1=`Rzt:y)L{c;и{rEP%(egmm+XFtyV\}O#TwᆱPeb3QسWjYJ{?פX8P'"x I,y+7Φ}fRyA3>QeY:)a[si([\co]Aoc |SMQ: S+[,Tju~wwFߞ,^zΝ$0+YRa耥L1cp6r;S s Ǐf*|}z}=8_[ΐ\)Zf&am*Ao"b}X+Y$Y͹UV*kWi4 ^=n7(|D4 =5Ppev? 8fp|HQRH4/A8Լph/3Ap_( 򾉷"Xw)Jh VUUr+O?"EآVn;"kʓ|-b~&P`U*X4U)g~c^jȩ ?_yB[ b{n]ENnHlp DrF{8Q[-mNXjUa \Ӣ?,U'SXz!HрUə@g@ݖOWX + .!VF6ł fCI Qˆ'iy7,<9)+$WSfyN$:q30=V`KH"<8q9\ کd%޳q(Ղe%[2H_@|A΂@f%<#.>= /*<:߱t<R֞+zJ]y ``{_x`?wۏF3XpC D`}]x24ܢ`j8WĉN`.ʭj:% %X298:;@ݦMVz(,geG CY&!=ɖJBxrpF,ذtu@C{jċg@B:vzoU;;3Dh%%896g#\,m^3ǬdχXp-x!\࡜mOʔ/bլNc`s0-E', +`-(ҋ IIńƲ%\+"\ W( ̀`$ "RȈ"XvFk)Y$D-w02`W`Ѿv"Q!EvX涋Ċ VU_@`}; ,]e8? VUU $79ZEI[×S(hSzxOwE=綢떢]J~8ho}90}lìAr'cbh9'p¤Dba I RX"!Xk? B͕_ܫMV6KGpU>7N546~f0>6VA`-fl9OW7pZDu!b>ԗApjw΀h,ҙ}tJ"8DؽO:8\xpE OP* )cKl-SzX?Ӣ0t;c~6cnl9V%TV1PRU(#VQ_`r+K IA!X;Zq8sL!Q u9sp37ʍGaX若o: poLxY92ec:/=t.3"'Ij&h߽`uS5'5-fB=3b帠eS`T@ʼnFte{+J*%ԡKq UT XY>H]%!,#A {JqhtE@VQAt[%*'f{?Ո!v;lVCDyˏ6GQmt2ޖ`_+\,,^YqMۛv ,Z,:|)B孜`nɭRbpFe0\Sfmy @-f2kH`y凈DL+VJC~j_S ^!"¡̧*L: V&'˸撔."O3$<&&M@0*&<ç :{@w}ŭA@3̈́Uz!u\T*]׎/GcVFpSTh9x$*ƃ-b裏Ń?v1v!pPF́C88}Gߒ`? xj,P2PtwK*Uzeι<À7E6ҹe! \:.8*"Q6.,X7\K8p4 س ЬA9"`mmm*6u+X&w-,KcӊuEWm'* eaE rfŪIAVbAjp¡Y5%wKRZjի-/+nPW +UsV=u+YNJB4Kׅ>\ Fn {84q Q @qE`Z/`8 H<'`HH~eP(4h$2eЏ~%m'N_x#rޯL"[ʄ;jXʅJCp$*XU B^"O'@"ȑ*XU VUu'ɇ:IIX #h*(%F$uU.Yj|{˪@++i&f{ʓ ԧ]NE+|ʹ`e"inSVpC \ E ,iRhعT)WD@Ka (wt;P3U@i ডZwq-׹\][Y-'ZíI" 4b# `I9gnͷjz ,Vh YR!KGӃ+=jƹ/&zM$c 7QR+8`yO~b6GN)]T>^561 #095O/NއGyS0>F.nu]zSg0{;e5io?Z[ZbfAs(pAMMD?H]m-i&hS">0 &]^5d`ʩ@˦zhR/S̡4$E鉘E4v#0-U4M()5/BռipX1"T}B^ XNS!7 Xoڐ44@? X'i5VgYLL?ՀuUuK|];H4%˞Mve1},KR |py(KM/"o>p@DpC+)`A@9;pB EH]h_Z*~]T_"\;SK. >:}%A4m<>l/?9xx;'$ "`Yѩt".D" OO9al|&I)8;=} ,Nɹ{0C[,z㳏,*H 3+;UUj4}(U]]=Ԛ•V M(.x5My-SyrMGo!v|>'?OK/^uu8 OX7tU7' `'`DLfdY*…lhʽ iA_oXKeE/8{gBND!砏Fynp\N!bzӛ1QSݏiUC$.j bg<7LTDP$o1#}#>^0&3b "\G[^q /y6Wd^ k+r`qr}!Nj}!D0"qUTEዖ '\Ǐ8RGgp@M5OuT#T"z%@Ɨ'988=`P kch87nv)K'F`G/anOZ86K0(q]jqቶQVZDj,cUkk;4T⑩Z WlJMpN) >pIS]ҟ{tζ_۟m%pZ0-Bt15[y[_Eؔw r~u*E 77/ڭA{х=g74G6i_WT*}Jm{^Q/ʥeȒyĪ a0/8XT[U"G-,^Q.[@FDh$n0TڧF80]ז8q2Ien`6'+= (Vg&5<}HA+LMgdp{E:E*DZR|&%$]J%e h}9`o~/U_?gV&`eyz]X6-Ejh X X˨CI%=6ӴL` >/읲)dLʸkW]5XKqހ>E;O57͋M5Uݑ6?q6$K7xT ?2e^=a@C]x Ƕ/z_1}x)hQWT JCӂ` XAqz@6 B °d*B8= 7@KxpB 8 ԀɩW栕P\Kt@0M(=`%S+qO+>E(B9>8JÉG#Fatt ffazfU hC8>} 22:Ǟ6vDZ{MQy"5D}UTZ_gKW"B#[ětT.Ub֩Aq 5\j* &<|%iC H)^i{ʶO;m>*{rQp*kf*`t A֟>+%^! O&`LI㥷aF;"\A >C}`zx^bd!J!ZS7$V ^V vD !R 7S\M,d /:sASuVz﫜,#dӆJ~؛%|!Ǝ׎]*%58kZ7uUġK<XW˴n !!sՄŴQx>7n)u3RSg'<6w!@[>I+jej?|#%j b#-^vX |gt} j>p}o谟W6O~ftL?VR6-Ᏽ;LL?et9`_QsP=6x&Ӫ:5U+.ʿ`w5nX*4#p?d)rzDUjTVDi2Ӕ7~>x} 8S?|t8n_*y$'B7Z@-#`ɢm :upFΌ}3&O$ &B: IHF>Xpwj*rǁd Erظ ćp%BKG…<ǵ}}d"lӼvG®_[XOfg(6_;}q7xL|X0] ceaBh oJ~~޾lk0'>|O௩ֆxD&Ɗ mKY-+geS\νxV#R_n>td灵pݘ3bZERK"liZ鬁ꪠe=ksyy+++p}!Dዧ-뇕#(][|#vdZI˟z[;)L4W$!qdH_H^w?z/p8 A.Jēp(qFZtn\Zyw͖.iሷ ]xx̫觱 uJnMKxO:?:\&ׯauu>} ӦڀGx"(!6;y;( z{Jx*}ɲd\/W :ҿ4sSeɀG Zz- X XkdZ:gڣ{V2+2+2OLÕVήeF,J8Dʳ{> j|+֎W;X^,#D] R[%4xM+jY;SkDI+yߏ5dauCC E+Amd+YݩIP[{ h "c { q!$N_zDo0rYR?!+).DNjh4Hy6  ,Y o~^B Io{-i O&14.~c-,^#<5㇩9ě%:)q$M664V+aŒ"T%GhzQ߂x oa} k}X;[JNiT^Fv}G*H5'$c U оF#^_R8`Md`͔|e16x=^xEz%6!y=3KoIVJJaLVgɽbS$T<2'v7996hz*#PqoՃY5{~>+RR;O Z2p}D"`0N'O!z ^x4IU8hqM%ʁ_[;p$IJ}ŵKQ7%Ø,MyK3 J@Le _|*J7kLLR+5:>rvG2+2+2INӴ>(p wǮ8`$<7peR",Y}&ÙO>* nfE:@Fu8yA$q KS*X}; A>!xh/{u[*3˼:!|=܉V,qLI蝾 IJ& ,Q\FԪA^ h,*Bi@[uh'TNh;/IV2G-U0^UÃp_Qچ%q<Ā 19hcVC^HϦӟDsk#z/' k&̢o֒>ioi:@Q; ݛ#$quu +?O;ywVTo#>ܓ! Қs_IX.i#mzER@+ bw5ՎՃ@V 90>4 ed-0a^|y*34; z>ee K%X_\ E\4SP0/BgnHbu74-HӃxٮ A8{}fÓ]Nڿu4\!iXpUxX048P[W M"fU2P9WA;_@ rik+kԖcW,/~xoPD =~6.׃ȕ!f@|_>e X=wgF8-\F|QM9dx%"qM7r r?(>I"NJO7"Das*k %~BԌ1rd`$Frh&'[-$% *9/2:8x4"#hJ@_J#Uz^n4pI39>aP+^ U0$us+sUէ}Q#ѿ0;sw|#?9VErmDDQ[ų5mk/\tS>h71jդ,Y֚,}K[C!\gቂ+G )'\s:+VԢAnFZx܄4@MJ%75. /CܦA `׷%]xʜmGLOt-eYzКxa*kB6hC(Rk geØFG(H`~>ExKm-Ճ*Hqj͓*+Qo_JkR2QNxdjH2 B#XvvvG˗@uXjT:-w XGo KAB /+2+2ڀpo+ϖ*2+2+>x?\$饰e"!麩CPw=GrݗQfݒCڮ'\.ZK|?)`A"=xIЛPS+Q}oL}hbv%$8Q"&KP/BOGrw]QsK6[x3IWPoM*> ^s5,ý̅9HLOSYBDg+R@x"R7XPECy[;9}#] *Հ8. `7~Smjy062 0p,LWߎ*OK],>I Woo͡x+~ `ÑO_W>  Mv}N>ox{"466iյ0 %%'^㤴 r6M NT+ J{Z+<Eɮb+ V9i(dL?zxso[ k;$p <!o\y6L|_zՠ^e VL{X]yCtd݆۷ Ց ֞Umj VvچP+Z%_m@=M+&-z|(H},Xq!y!,^M3mii *U[Xk+A7+@3ҺRR͖ݫ/~6`MQ@>2+2Rkpp2+2+2K,mf?קujK ^%:3kXB`O|B,S J*`ƽ^sO O/,UOʩ4Z ~E"<+x@L Sp\`v]>X@ Ro7QDØzmC#L-SGիuX{ +ڋkkXؖ^mmkIڔ7w`cc;px\0t߿ s,?~ Եoj6v`*c#}lljt_-*܁mJ;;7}#"#NSr{=  z@Ps {`iѣGvA?lomV(=kL~^^^Ӭm&l`sWZg[ګ<[݃| Sw:W 56YÛ87P2*GVl+X|}u4ބ^x~I\wsWv^MSjkmjgl?,SwU?i+rst a9MGV_$̊Jf*a\{[ih󮇧/뱜۷+^dY[ZjOq+ Ry`/-ha66v`]=ӦtE2wg7[FM~好xzsbe X>7M Ռaz.ؒz2hp8JmP'sgT?]<,1xpt_^5zA˼|(DU UI9^ czHRb0yy K]JnZ-G"g@ֈQ~X"āx4R&*9W8\~چֿ OK<^=@|%wއ;wann^{!H"|W يseKxIYU^׻9rž;;lnn!xlx\=z*=D O>eg^Hc򂂬r ^*/_+w$x}l+{'q:]9=V;|6ln-|Anؔ%~<_!y1mH W?b\ԟNXzPmuu^ڄ ^U R JIoJZ[U5u+BeT\\WKɃ'C%XX ssws74 @ $]@6apAkk;uӮv@kk[BN\:i)_[&iv :;{zz˸eo7 4өi1dC2ϰ48l`РQitLߕaѱqP&a|L~#p W>-\_kݽ̕y`BgfYzN s9MR@.ΡpKʠZ*\*W((,/RȹqJ`u"`•TFglTܺcp#1 QYyJMi;o^,j婸?en9,-=FkZ_7@]+Uty\SoE&<5h XWM^x5!2'OmCfgga||,k~xBQq-B3+H]_ X"\X18eV&`e֟xx~i2+2+2?E"8^HVDn >z; UcN+~8`ZE,u>Oo3G}*4r +BE`mnUx [z/=-}, S?mm@F``p::VWf$Qۍ>"jXK+eŗ|q9>q\t7iZŢδM jEy7oլY? ~mtbVַO8 Dzk>b0NAץkA*=T8ɰhN9Z j *^"SLk?6/[:ӔSzM9XS Ŗvܴw_ Mv6xSV4=ДvIUHU#=@W KcSC!>HϠ( xb[v5Nޔ^# =޷Ѫ\ix3v_˜ ėj@/x"n "`9|qpas0YLWdAS0$p?iDKUy~0XO+ sӚffnfkA͍=KIDAT"k'w7mAF F;,qkml\Q54 Piְ8=N_fP <022WMNMPgWx/`y),=|={] ;p,.ޅK`yp/(KZӭWo( /gOXzݻwރE^/`p ,={%2}2[XX^F+ J?iTF4|C|<mdo|s؛ FW]~{F+~WCWVopREE5WTI^Q)21]V8]yq]E 嗔VB)Z;g\UƠooP.p7.>?.zvISYdדO%yo YX GKB-zз'O!._\$<e2U<p,[i[8:*&ܭrw2=2)ϟOъ>u6.`Y?hg ẀeN_ѝaᱳEeeewuu t! -..^mE"\`9wa?B2zhd'wO3'E_ᦙ:&\LGx +}.8}``ɀ7nrCQ-gFT K*#Pq >qJQkZ2B5UcSzxa8`OΊִ2fTqxG=ޡЅE=}^ 4|ex1pXlB!>8|ݻ{ޓxUsxۨW/.[Ɔ^l܄nkk3~ܫui P8\J=Wxv^4xP X?~=~)<|8px;%,0 dff(.pcW&mlnJl *s ?Vo#U?xҪъ1R#Mմ±FQoC]}l vښY5.x䪫o\H;0]z`| .!8i:Uyi}% 8vK )=@PR`HHʩ=ďނ{M "A;~o\W m}0oG Eq2:a+qxhjz&$nx:gnS;ܠF7ɥ-9|VۤR55J 5R}6TC`Fn[mQpo=]mi:[jF:`LkGu6A8@&hmnꡭYjm]O}ݭ0#0>ҧI39646<#0ߣ J3{xM un W57XյP"oj:z}xw :>u7*'w iU0 AG`E ?=S? }S@uW (Cc?!t/2KZTG @_%+ aOH!" AKJWCd}ϟB!FjCyt>$ޛ9X͇#` EO$LwD),f UK:7~X˺4Or%@__*Hyyuo^{ x\(2%8m'DS"K171??әVyF܁,Z\%~~3 :7w=j m]sSxM)LS XS5ٷV vQLLaPA8hӋ9.^S*BT!yBLF+)hQr<٦Kvf+}_~ ^^k8/ %%*(Mz/ Po~Kqԃ(.p!};NF:(zUXL+[wEeTVePZ*CYI!kP[/KuyRYJs, oiER4ނR R[MLviwasǖ }M90Q0Y€8tڲB`3ݎƊ[ZeCOcCtHg]. `NӐ UR|Ulh΂lh,{Әh9aڥlh4K͕9"5Aw]T@aq)ݺ|#Wͭ!| mmzE坽qe6 Y {YqxvSz&Jz$Z=V] N`}e9YuR\nFjk>OT.{? 'T6}MKK#P} vw=!A$z#!D">x`*'fXEx]'w Xẖ7}r2ѝ4_Fyθ^_.y]}4MD|~Ǐ񤑅"D,<hAOW+vx4׮ <0pJL 8(UVQj몑,i_CmO|#W*.3T=bF'8'n ƙ&ԃGO?Sx9nByZRmup.+)"(.>zH[Z}IM Nq~2]s%0[c-aLv`)̊R(.ҲDVZd\&[< ZA R-3>ԵJQSGL~IU +`(HdO*s`em⽊E") ś>_D !?GA(< 8 ՔB[]5pU@\@Gŷq!D{p!+29zq`qJR@?xk{{ XZ̙^=#Xh, V,2=`5k+Njdt"2+2++OF(d %  zRaEԝp J_6`+GT,ZAm|iKR#XGk*Tb0O+ ؏~sgx.H @WMj:ʡV %\ M9`+ zl/,joAUT'Brx/X. UERmaEa|eYzPkd/кE"C''S P0&S4]G:겁x4@SDvm5ْ 6B]l0/aS|4hσ{>Lu(5!NLO)!B%fi⾐~8ɴqΠ47Pc%P̃)R*b0G7o~S))ӷtV{;5Ny"li?D"DoF?@Cy' Y߂_7Nj1P<;;p.>`)f5`}U~:{]e·ZՄCCމݩ 0XW)rX+*,㋏ XpN,x| ppaoXنS_/I{Uz_i/ kUq X {F7_ٯ42+2+2!`ũJ^B.2-_T`CENqW49`Ōr*lv6uگBU7SYu-z=z?T" % :?#pF?j;u0,<_um4_}inUR+RS|PО M"T5a'[n/n5y +)2fWgCGm Spx BC*nT"7Ud$n%xo)O"{)9 Ә 8<o/"Q>w)7S}%0)Bl㋀l@[. mƯRəyoS^V eP]۠5ٻ<&T{xN*I_:cJP^FW8tJ|Sm#<[u÷C+ pV5d%yJAOX=HU=~\Űf_"@+߼{P-݀ǏW WCӒL7 p~~Wq2홀 X9`YXB:!}g /נ.T?  {"76@$!gt!zo_|.lS8ţ^u`#ax.Gەi~ h[ C ]~)p6-Mh/Ij"S`B8=`FkƖ.hnQK*Tx2zM&@ei !8o{U@ʽ C08D9!XvwjkW,_ K>jPv/ uPwV`? \Yse.$3$j~uNFxޓpzz2Ze뀋wM>?ht6Z%PS] ⳝJ\1g?տ~{ONW,?OG8$u`C((Q"\{=|}|m"qSI)wI-JظTw1,ڨ|ަBσBišr5/͊0S=(2 ~_iE"zӷe^>Xu:(Qkn醖~N rx_GƘ4>:Lkd~eb[M p X XnsVZzi7ohLLߗEUT S?lDzk?,c N-vvv}o0!oo߇]g8x*0v JěYSwrO lQ ux"\h$KvXՖ&lh` &MLa4_]BRCm YBsA6H[ Lti3}i&*aa x@Kt7d({6ҍi!plNNBã<*Pv]7,|8muHn/k8n`Z"tN\uQxe$ %?쒸9PN`H8hQ@Z.ZQHYjw4@Pp-XwcvGŃ^ս_`Txw(`O8BKs+>"\bHIoӠ,5uAk 5#V^ڬW&*ETv>R{0GB%oj !ZaDi^p\e趷@W,?|(ځ[ڦvpxV 8)8}#pR)\sB 25?ON}ue+?2~7^0p, euGhޓ[pQ.^ XM000 ށp 9 F^˪¢Bp[#W D9`پ@.BqC[keV&`e@%o~C[*>m X X{.4?Sa"u3,^MȡEo<98p;L>X.qečz+:W@JrP4VG5T x+0AO5W)~Q2C8<7:P0ƛ`D=<` jGXcr&Xj'}MIaI9`&p\hʦ-K|O@<0WwK)n@[^!ǡk^Ue`֩p.aΞUmx <~%W ^*lVI.(ܾq榧!@y!lolk͙{jra88~'oakuM+K-olG͒؅p2~>", . >_?~ MyʣEFj85](6D!|!o]PPPnC ?PDN 7\j X X즖IW72+2+/~$]w!OD!֭s8p9q@_׆*YȮPTE{ a!5\  áEBC X2o C!GSphtV4c)l- #cqd~1: MSF{(n>Sd?bFmiGS5x^D}u]gߗ|*Kcˎ7Ȳ$`A1+z/E`ػ(Jwwuf0)ɖ֙=P8{`+`ɬ e"S$B0@AB/TW;N͍:؆d8݋Vyqh4Q; hK_d ',V\\V8hM*G'\u.>UH;;[+p-T\"Ar-V; 8q[Q!_7[<Q|P'aH ip'pDJh 20)Gp(vi \sfAƁj dryHg uטM: @ P=A0 ɰ3 C_]CIy?;Z| }20QrN~ Pdawʀ8 OC_d = sxHi)0? y^pr.?]uY?T7}QzLX5 rϟKGZwyiF*8`.FԈqGZkQ97T_ pzcaGOa}c !O?I\{aRަY%<N+ـ|1H˒05$As)zp`6炅N_G.' `dQTRdP#ni»xHh/pM7 [$գp]dMt^ ia><`h$et[.@5l@"&@5n۵ٿ{; oy]%RPAPd 2de"}+ jTX>@ˊhd5Ua)?V/o+ƣxx@{{;,,?eRר׿ݛn?뫗ōkq e)\--:XF2NF+ Xw)\8\G5{KßWeK-h+{TqGBvCkuV+z)cv85"\Pv>m%k~p s:JP.a|rf`bJUgLM)Ӛq)a.5G.^"w.n)(S9/pi` Ii'L]PYXҮwDmPדѤ /d흐kJ]^X} FwcB@ x2&h}#CEanZqQ{A_^); УK^yKbyB˕gm:is^G!wBiĐt  E}a:!A AU _] UB>1$ćF + $W(C>_B\CutGG!Lo !JkZ;~Ɯ9x}1<|FkU~ƽ]0V?^^|1H9XmYwǫpWNryka}B_ɓ;'۷oKQKLndyȜp$ <'7BPX:)+-̐p7w~?,W#?^H;Jjʯ׭ ; ѣdk #NbN^HȞN}N#׼%i˰8}l\\Goy7ڭ㩮/uw=,yawo) I?x !; N.½{ WxrDqgNQdM_bG 1(m`D\.Xőz{gO^Y+kpQ]~ qS4ܽ{ XW^ X'NfȜ9BƢ\Ez/-VaLe0-%Ĕj2pʈ Q'- b\::b3v }=`$W.ex_[s)ǻh/l H2=K^'\8~3#pvscQ{cT`?_Z[[֡'`X }Xa탃 p]QõOG G! ",?{7L8-=ܾ>!O!&w>Gè Xe"}w=T<v4̄P;c6 p)eSc2\_saz( kWc-ÜeZܟXqLAK`"eyFifRޞa"fd`Y`f:Rl9xWX%7[?xyS[ιaZ 5y9e/Q/ qT#ט5"Fts+#v:VNEa^_''cJ} &a~<|B:9xN[֔wOB#xyCQ6~7_d{ c@G. Ɲ'p8{$,p)z.,< S32V e2@P3a!.^GJ!tK2qn X5X,mq9/p1rCX9t8`e2  M&?U(9Y\%л>xĥuY>XF X~l Ww3e7nSP!Q2=Py }}eDMFP=xxpr:wriy |_^V-YtO4@}*~7Ņ۰pd!^^)(LѣL0Ԧ O P')=tRyf'8 &k+H4n|6(_eljka8媲_(r@ ˽0Wp8Z]EˈSfYLΡ8Mxr恱&41j1iKnX&d"|=/!NGG&"i +jIH2?Ѧpub篱9*pƔ -JAӁn8y]qE~n(T:p|PׄBn=S.R\GÕ P=+ϴJ,d?=`]~]/_crah XCKP6ܳjKb% Yq[L6L8j_>Gp]s]#\rCA\%t@\<*5=#`XU3pM׉XF2NF Xz8/ժ)l\Y]Z[B e>p|rari.\!\ f3o_\9cr}^ xa*’|d^y>T}]3=]beT^Kn=`Uza {A8xsH \(?_!VޟL4hT_'pAb/9g;"n^^0x vyKΛd2!`%:w*zJ׎!ر2N}K'4|y{v,x. !r<̆mp~qqBEҕ[b-Õ{ꭇPD|$7aqN_G Hh>az!|̙3]ϋ>eh̼5`BoOz˻4 @ʺO AN\gX}p:m(S0_.(+zy3ř%h9Nc@i`Cj>+k婢wq\x\VÉ ıKt8,_Ҳ-ZiFX@>WT* X(` |~K_|l@4 l%;"Ð=9<e08dV+R<$ SˎA4Ǎ-mPqTZ+ x K;vjG8Z%n|=.h =MR0}L'.W*vy+튜u}#`XE/^Vj^#`XXr !AeJ +2ju 8yH2^Ga_! n38L`'60Ƈ-`x[yyY@۰Gm,LwE}8.DYW xa be=`)YW Aˇx~keu-A: Hjzz!d aOy`2+(<_EϻއCSaɦт&-L@FC;xkxN_:CYrXҦPcӄEv+Nd xw]qȮfLPz]?U*Yzz+^VL9KYa*g^l W~ﰜ믍CZ[ۀho %{̐^J:`"mӃlJ13C%j~ϨgᚴY,ͪp6^aY wR2 |ֽ`Xw)v˟obRzW_۾=`ٻ{wEcڽSmCBۮsbֽ gh~K'CD|PAEx,"ϯ{5g3$Þ?̀u%\T =7`KZWXi\Vǔ\b$ lB<OܲAֺr_H^>Qnf;XF2֧Usszh`,#`83..LZH }!?`wi|V7|8? ?-=WB^[b8oc/` !T.ejP.!^Re(.@ K6yJA2D8<> 2~ЄGS>1hڣ$|KiŻ܊C6`պ$)^BԗvR:Axʌ| d ѯJ80[tBy%7Lei}*Z@U9KT<l" 2({"-dҁ7d)a~ $zMp0g.Z\~`]& IǘفF5eLe\o@v|"{&Pk/X;4%+hjw 2sS(je?s3;Bipsjt~NK;@_ܥϣ=^ڮJ~#v $F09: 3C=pyXvoin+#`}̀X"uq8rYC<>o? V}=s?eH: W{p`|^1y? T$kk<,nտ|g}gϮOVFPP?򱶱BPm>|_0oPzvS^(^I)҃VR <]<.A"[,Sja %hM!1C@8`MJ>5T)ᦞL(ݧdd -X҈*1eLB( 7}K3y7ޤa0d~M~*)I)4g<Ɍx'd"+2QF= '\ڞŅ߉CxnfsoLLS˪s;| Fc j`{IMIA_[(5odKޛ NAjG.e#u"c,V=;-!\:GZpjD܁L{w+y_ҮP@S&bi`2;կ8¬1Cmk`GCV38!0K]q&ݬtg(sGy1!89`ݸq8`]rVWW,I x&asq9$l↣|dKm#X@d* CCd2a[ Mc, PQ{k-y#`X3`ĝ_DYttj L96-0Dr֪0l⠢d+a #ZALaY$*^;:;8,Pyyq肩^+cLM:C;'/gB a }.31= *Y=I'JYާ r:X:5p}7+ˬs=\?Ž88M#q7Ie3~O8(s3~G%;wBghkS{tv ,VjQp(J',"p,"iCޏ8u):%k⌤LS|կX|lrf#`šr-؀C?Nj]"<{,Pyknn8`j5C9`Ez{7G`0k`i 3=~ Ng`hxfo yABE-;~ Ky6Ŷiquŷ{7U7;ۃ대eOnO7B~mD{X;p㗾-FVXF2q2g5`}#CrVIX!5iZ蕗O~}}W_78?xˌJo,GDiK8H'KC:EQ10Ld+!)@Ju(ǎB4; F> a2燙\^-a LT{p=I 2dށ8`ez-T8Ļ8xpQy! /{·aɰ5QVVS9'prz\Tz N`N, ~ɳW_E:a@+b yMKz_Fҗl\%O QJID5PN_Eۛ/WuY"zݎm|9}P*Wkb8=*m\iuU e0VQ5\P@!8<;^u Nޒa1N*jS{E%{MxzуV{F8z+>*G-0_p F,]G&\p#|s%p F.[Q885|#2%"KZ F*4oTlox1Mmy&a q˯ͯtːEzGJC/ X 85`=?eakp|sm H{me-! >na*>RqP(_E?K;D?se迪M .3>A:,ZpşlCnw_XF2NF,}cYm5}0ֵۭ8=/`qUkWE}ׁlWUס9``恁݂T_Gm0>*0:Zqk#zҩPd?7"ܴ{)`,vD5`mXeM+#`}֩I\x+[Z0ݭ5X?!n0ee]c>}-+'vAXʗvj!ꬾuzCvwXbh}u*Kb0QGXׯ~[_JpJ"wX\ ߏYuȤbP!>K 0  a!N>~I|^=!W CՂKf&(^k>O]20.z\aJ7b_<fcqإ S=&(',0_q/юCXv|ɋ]xd8)xwM%՛o 5\{D!8$C9< I;J˄N\΁h%j1*{`FD]y7.(u?9^~.ds Qxtk4R\ci.ɂM~mkZn7-3֥m):̧߯&D-%ʖuM6/nsvg~ƩDɧȽ5`h XRI_k X=.F͙lǠR)C&p¡\.a6w}nH:^/Ms*ߌ?cgضu]kG ]W`w ?k~_ojiK?Xf_ XŒv$*k`ުk}"BPqϲ] 6T3 L}? gp>bX~c ̗\  .Cn6e[/]TG6:#>M5@/b X0x"(5jã^2X;TbzMKC]M/ Uweq͟)Nܫţ~K]Btw+C?rFhtiҿ'|_Y(aQ"e:>cλmzZ򽨍tCy UD 5]%z8BD 9j>F^?i \od *րbk[E: ?v_{}6Z'5,şxzhC(m޵Vj tsB8rW=:"=  055@+Ak 2t}W ]~A$@ Nf<7uvaP" +_x`k9m"X@{O{IJG^W~70g,`mZ+/ T#qb2܉ד76:OcNth[$o,#`8X2l8-m0xM뵴=_[5a'#fk@K5-#׾Ӵ@LÁgR]QTrC0[ @-e/:wB~/xDq2G!*駐^/MK z෴Aa ,UuW49|dj U+`wa,y!DCZMX CߥK<lƦ! `ל6Ԙey;K<^X;JKkR]c'ApR}ZWF\~CL5,5Re%BZY;p=1POx 7!ƣsX O4bG2^.,`JxD\OU.Bo,Z +9-]g_^VM뙸&wzn+q}:/ojY~~e_x,?P#Ʒ.Z=_Z2zgdV"4֡CV<X\{g2 A*BV)[$J6.¡|+%ɞ^P/0J F2_}?b,o{?]-8ui ru|܀E1b,#`8X/ Xs,΋:w5+X65y͗ޥ-Bs>t]XٜmA,S٣ Q,W=(`ڵ%Ĩ; Sc0tIL{`z:! <}vBf!1Vqf@>-yE2 nB*p\Q>Xͣq2.X(An]!7yG424p$8x po.:}@l)]UzBqe:T=p({|Ȋ| .8>57ROi(ټ.ڿNK]l|+aoUTq3:IC13]ҝ;PRLsM#P]]yT&\.m}ާs{p/9X"4 ?\,4V4|ƀ狥R>@Kdbr8ЍON@Rl./$AFː%I*o˘|}6ˬx]gp'CѾ=J^cttC|ggk|tl ψYΝy:t 3'Su̘(N9(̟֜͞16 ʘ:.ԦN؜2,(PדaeT'B8}1W ..(Ȁ@V!X\qh#FS~rzCʢV>_kA/9/ټ2EGYh\Fh3>09vD#lrvqzSo}ㅡk=Cm2TޮEPȕ{p4r |T8ѵҐxG`%nS1ķ|$C>B(Pυ179'p]+FӜ FJ.L(GN}>7 n_X_H7KP>թPTJ7I'ni,@hmol}g6_6a*VhrG!8T />L+řP"Hy^$Յ PB`(+gg:sL:/B6} fEgN(hfl4 j2PTVY(a +X VK%~Sܻ2-'fFc]n۟/}Gmqǯc, gh4onpʻ&VJ`3M-߼nn#%ӋwQrp5h6{it Ҹ(F}B>W3k2킉 8L3-=d %~-'Vbs*vW@qb>趺 W$C)O2d.@fϐ -Qŧr#[4v[7nyhnb8^q8us`)a-^^*.7- m<p`0(/K\׼4H P5`-GT}U^s}zЩm`,#`8XQsЗ:^T}xYm;^xA_hkF] (~yaH~U&^>!@x%dUDs|Q_ ̨2 ا /)ȐGSJ~ a\^2(EH8D3u?`FN>X5XtA5!-R7w2CJEYDK/|/pB܄ yI-ť_=)7Ŵ GtH{KR}&Ki꛿j\]6Dhq/{߿^sx&~"=j}188Q˛Ӓw/.0_/p#ݐb {w"RPüyDF=Kܥ@#2TAK`eqx,C8aX N.xqRyMEY/+xDFj.m@)nҸ>Bt.?7I|-$"8zv>eo;P݃Y?G;"cIC`p{j}1IS"tpp#Wp(# ZgpXbaƭHz C( B<!uVγ& yR1r נ6V dfayRP Q׿CX0t%W Y9AHJz;Х1\CԁUQ]a !4wpz2D<]PK`&J |wF~]x)d_ځ=s9.NW\nXrTKUv5J|$7ЭH)<:U)et‹#GA;c#]#sF~Oi*c}"39{& zdD+hu]j5e=ƬP|L22CDy:jク{OĻ7Ō?[px ĒZ%C$a!FNfԒj@p1;V܀ (ק5byrͭh|{^J3oIOz'8YuRNѤCJ ZƣpcaJpE2A0k^e^z<~rل 55gX겸٦lNE)—w[\eCG  S+g!YXnxU 2[ 4(iNlϟh[L݆/l:i7`j4-zՊv].`qk׮_JlI~_|M97`X`@Պʓ/96#m7!NXF\K)ncћG=mb"aG`i#`XF2NF X4 ߐ~8L I> N;mp;s!iNh$:o6p(0DjD !E[KC0v"l%©#0~HVݎk ER#+9Z.fmk+bl](.C6g Qd^ 0낑R}6u#moS8b.f A@o,"FĤ}8uqǯ7~#Glx 4.g&U N<|{;{͐ Zxa2.+CI`2", ;O`*bršh="6+!/rpv7qڭ@K~n|Kc8lN+K]\m2H!Uhvc'^=s;ܼ#jݵغciG!_臅ٳX*.T^jR5X݃iQ9/*roc5pQgBaplB۸]oi X_KS*zfP.8v!i/XyN.)omuƧuZG, 3"@jh+.Hfx !(׿C1wdFe`#\+.BB-R> / ok&߅Wa|"L\ ǡ<ű%_.,dJ0*6ߌ8NB&8ڏŇ_ݺkҏ_#vz 1bںO\xg7_|+/?Jq_sQLjR!MѠBPH)ّؠ_P0xA<.GQ+'eFVA >|" D5&)tR!% Cl(с|0qPرI ~;dn 'WBb 2M>z.y0քlwBN~_$甏n_H& n:zEGNɋ#$`l*)MC<[oX\`vk\n&bvX|nl\z}0,왲]j8e: jy?g#X333qVkjEfH{{;,-C߮2 z--п/Gz@#s3B&mUK/ 7a ꫸w#jVI>bG?|k/ U~7P$& a1+#`XF2>K_G0S6h4sx]om;ބW0,p{!_DۄWp=憡ph+L#2_4 $Ӑ; \ߵ|BN+3.N@0B$2>CvwD Dř Wo^ȟ͟Q؁ʫï>?TQ:6{#[0%MZl-nE=fcQ/nv2tnބ/6\A C|4+VGS,6Fb(hp48LRbDP\w <"_/k,M; Id ! AKt$̀ONQE[v{8kןྯp{8-ǖ%+GKerM$&`r93L )Q9XW{zflKw[W]{Ϛh)m.CgaQs/7Nj'?h+س(X3M93ο*%nWL8GVr x"Hp3qXebL+u1^>k16hcm5$@Qqeܨ29@aY`}V6\?Yf$o_- ,):u "bD!&XqaR,{\}_},= :1+q<v\pv;Wv.)#932T$P4EU$$S9y7:M+IG2?T3fZ =wT8c_l 0%:F& (Hx{ 5q^&-hbĤ< Ix8]*S@ -t mHدWA9g %f l4ߓ#X52NʵF @L ()b oP؄*3񨲭`h\``D3d-} ٘SWP@- VWB:^dCDU'BّFqmuj@6dӘQ9e:5,eK^Po((zԶ" ΅XkiR6">hZ *A1 RP݌bXNU*U:Cg NLL5 iu8kJpnplӒLSfnI\54(F]9rfV{sUpo}VNw\/7fA`!dį%L+~ c%ɗ`E08sX}P`]{Cŷ4b>1nԩF.( 埽ESSof;OTSqj3C jMk겚jj_>7jɃuF]$֛R_ֳlI]fԫ,%qPq덩sy#4kTҭw.gCgY!X+cR8LjHTWT@"1%@JljQ`=)6j3m`db hҴ T`4Us7ێVk׿]qUXeUXeUXeUXA`鿝OOFU3u>ze2ƻGP͛Acs?y z*}M&H 7X=}z@շ4OsG4`rYь8 V8.VAs$A! &EeMF8CC:{}xk(d{6&vO~'5ZTy`fm6jXG{xs_&tNiTBm&As,:M 3 DZucdAuT-O#3SYODi5eѦlix@JE5/|hPf܉`הJx#>x'bz[m>yMLE[W7 {5 j"X*#qoP 0.^ J5LH)(DcIoML̤\tL&]ΨBcI>ĚA4jSW@;5L'j`YZž,Nf(ZO4e[K555 t@WZUU5U8wEg(YcD`h3l o PXq%g:Foy3ckpOcsaLL3tgp΁c2V,^ &nmu`yG'>W[>TX94:t }  a:oF]c"š@Y]!e`kBIPK9f@gvήX3#E?JSĕ@LKkMJx +,9Ya,J&Gw^:u,q* bfE Iw: {Ϳu/N^>i`E,_/FCz"+A~b&:?H" mT~a](رcFMLGSbm -$2 i07;ffAjAMv} iD`+4{GH FhPBisVlZ *Vkhڼ-(lWBj6o'IB[j&@s(Hz@ '3@Vm4w;~}`Ȫ.s_IDAT^<2#z (q%q:sE7Zz@:'1$ I:oAO8" o]61PSyE#)2`gL_yB 5xiΪv\ _qCm W8NOP}'0+jFAL+ *PhEDAԡ;Xċ-:W Dc@hރv_(xݞg [X3Σ`6hBu(mgr;ô4ܗN5`Cumܧ Mf!Q"pneThQbbiYw~"f-(p?~QZkXXbIDgutt2C.P-gra?Vѱq+62< ZA uUۀ[ݫְ;r}ҟ,Xh d*~,g_;YuCzPXeUXeUXeUXr8*H] J1l۲lᤨVl6xD#5(VQ-&P]Lqh3A[7 :@c`V?=7w:]]ohrO׌{A.g`b$h˓d(fǝ\(hjtK6H<M0hچ@*۩1u$Lg T4 _8 mF+?gaPPTĥzgrѲ 떱G24X%H$ 2DWDPg}ݻ$PDq ŒP[[ !`0jjj@uʆcAMG  9v" *\&ѭ* * * * m!'0TVMw4&L 30۬Y%n/^3JճzpgnsefwyP0 1؀Jx+ק\KAy FgfA=}CNwϠwPMt9> GGNXVգO>>=`t[}Q Ч0a#3!02TC$x L2dlB=1zi|: Xe41eTLLN:vryFc6f?Mx]ЉCCÀL Vt:O:@}2g4-[St WA'::>G'T>1`sfMC0r6w2K]nɃ5cr] 1 76Zl|7%|a춞 tnjL6/_ߔBaF–F©?;́d4~+3(8(D( "Ef ֕ĉB@8c>E%^Ak_~sb1o^,{(:x ػw/صkbO)@Ӆ`0MU`J`|;x*ngǻ˹q;CJ MwQ\69+ af{ƭcc g,.K_7^};w ?~ c'N5G TҵW~YQB^}w?qPqY8<X;=8 5K4;u{ރ`~سڳO=Xf_XZܽ,2K(ڳf®}`~^0C7Kw9 `VʴhWlk)yXglhC>n;Ij'$FR( 3ؔE&@T*!095 '_h33J/lh-ԔI0==(3 [VpV{ TڀGQ:6¡CGC3}a:4Š*'R H ϶u$`ճ,9 ?sr *)Oz?.Sg7K~*ҭ Lnx\_0ϙU2AWWWGJTGJ66~/G)oP Ʌ83)%(Ql+F6"X kqXLwS,E39' #i'H:2SPu,OxC;Hfz4>{+׿u ~z= >K_ūV`hueUXeUXeUXeUXJ9Bip G҃"2)pje%.cOx39N;d89}Fs`epοۿzrN QqT`eq%Vm%}L(=Y_ss!g=jp׽o@5G'qwۿ}g mη-p=e= OO=4(v{ksd ||;ܡ~spEӠwzris׽wn]7w<{?xO~ {9?>lgO?-)O'x"%wS<(w #xx= 317~g[w5{#<N{}ݠ{[GyX(xHރ'fXӆY/}9O`9z#X~uI1 Ufg_WNNKΩ/'΂SN'5ϼ<NO1cY9ߙ>{NΨs8.!jsBN ݀ 6'o@.{2 ~ U~ltڍpK Q `u`GGFGA3#}V8ZBd4Vv`I;l]`IN=- LȨ,EgܫO|F{Y`9s>3\}̨4`'T=}53Y[ܹ$ݠ>3b$ q0 |˹uiL ;E?݋/>bE-N GM8P soZ8bq U:NIZπ,qx|ϗG^^.HGFa( \VӍ`ܽ9B5۹s'PFp`D뇘iԺ>0==&&g5S90i]&fcDö[X,B~ɸ `TbA)<Vd@b(y=pHdOiOq pJȾs \ROU՗GϗsEi%>z5>{xp pT1ps1uu~3)h31&uXk2L~qW;p K6HcSXO5QكlDٸiXaAy']HmJ@C!ŎgnBбǤ1&B;`KAnzfL yiw$B XTH5ė08<z&8m}AW`MDS+ @6 v&Aދ9v ;n0,P;D7;; 2 E!DZi6pIyN(wq30M} cA->(|(t(VYFU$ JD!gT3;}HsbGC?TgC#Ϟx~XAFΜl3bf,=np_u,O˱hPόH |ݠ.ս]/ z$fbZ} ɁbKzr-[^ő."9(BGņz[ * (fggs OX{C8U'G]xN#"\ODQG(@8Ea"׋|~E^g , Gx^+A tD`Uyϵiچ@m0`,I2`7e֙-Z X|jBί_?Xڨf)SL2eܔ*w'JlXUj.; <7u˯:/\\\ .^d@;vKWXoedekz03|v)z޲󗿽ŋWѣ'l&w?QL',S`5~T:=n(B_3kR1PorzMqJ{"vШ鱳҃%MFڶQcG?Ub#T.%pHX0FFLhm G&N,ˆ*#MAuD2''5>9G0w3y& i)h"lHZZŽ%g}5}~G)Q«МH3ފھ)م[ 9pQO]/sO`mE} sݱkh쀆f$sTI?C`-ͧK>7:u3ro#<X+Ċ#<G68 "3ъ!A,YV>{Ŀ]D?]GhV䈖ߏ#|^!G&C #XI"7%l=J^7lV- 2JQ&YÜfFCYS.uY~۹N ףY-cVY`VY`VY`VY`//qK'?Wl1ve= 8{Eo;_8~7E /2޵{\T7WW^@.^Qe8kཿ WK׍îu5ߏm4l I1dceיS:FqSpju KtdFֵ1%"ˮC(֯ ŖecDbSo+MkR>8 r2IyV( 񰺺A  "[Yuj< 9l |I>XV@kn"8cuEpw%S>3~L9N:xѧ싗g# >`_? #VYv8k8ӰWYL}aY4e2{^{EQ.$;[/] _y pd˯Q}};_|sUpNЅ h.^UAE;/BOwk#u,K1Ⱥ^Ms/^; pFSxQG̫gU}p$+K7mIWqh0UNk֡ӏi(`##uQY9 )hj8uq.3נC(hw ^ @ <:00d!g%l tw a #Ӡkt٦a \'+ w.;s K^TpK7~|e2^zpg ;Y `.}./ΩgJ$0sbMrA!B?>E"zA`}\:O T1$^'&8i9C"b#v<>Łw;Z&߇o~Gy .^ -80H? -Yh%G8=(xo&t>h5[Fcmϯ/* * * * V$ ,cjĕ$6J3]Sԙ4/C=%CwKa1`p%[M'O`:ع{ J?n*[@^ Rx֯57^y8uxU:4M^W !Yj+C\_ t;P=5D +fR&$~AeMH¼V"RJmX}6$P$P5ZƾJY Ӱ'3B9fV@Sa{{V9A$c~rMu|,k*aVlIgatt lD} zdbNtZ@kԠM Bk6LC,6d18 ^0 1iPϽpEaIu -zW_REա[\ջC{.tt!sdΒ$Z((g$vC =kUB:b2IgӀa2X|>KQ((V(^) DR.>;o$0\0:ϹW=s}NEE3`*8z؈BV/G&w&xi,X\txm0 6\uҸϞ!i.ʔ7bq돖,,,,,>nU]Tշԕr. uBMmSn셫ฤPxoĩ|v~ss`lb \9 Ӷb߁C@^45~Ӏ _?hܻ-\=vRc^?P<2w6.$l vZt_ +^% _o~P Wsjc!u|U[:UXٲU.16 osz̹@ʩۄCPתSk/B}MPΏ?;_W5ФDT:.=+.֌j +/kϟ]ިI#)3bP!GO<.Zpp ́= &ac(~ۜ'?& G!8icx ;_m}tZG|_5OBpnL32PqFyFOd@u$Kj|Զг+>|I"%:x 2 T gy-_y_Tp"'2/$R@sK6k(݇Jx,nY:/MlQ6r 3iIz%zl.g7^ `]`#?Y,գH9+(h6"k(C~{8lS:X 3EP,:{;{E+n|x;&:4٬.>jԶx&WoD\0./$jbwov|v'^; \{|!^"] ; 8}sUU M+}}`q.042v[ v?pˀco.Ai8ư\l>6&1(g}٘':ƓWBLHcD~#qΑub9lщiP%aUgԧE̓yǿt8U__oqK׿.2: EFL|PD `Mo r:>9 SӀ/y6#1,flY0݂jŝ܌jӇKm@ynsF]F2<`JMz<14_m*q%ru](鶾}uyP;zhҗDf3W]! x-eH}*D j1_5sf֩V`}ߪ6Q \ӡ2~_BWH6 sg vZf5F8NQָ;khlŽerQboV`P~ ez095 z{UuM;Dyᇝ]oLNhX:0H= ̀t: )<4%cZpM .eE}( ^YJ][ rzMs7#D򗿄żf977S1%)^ ӵyu͚6_S:$ P`P۝w~ljŒQ`ٺ]8hi΁@,~|k3:B x]Rj֥wע·9NY`}Z^<~sջXDO`u % <? &.܇X TL؟ Gjۊς>z豧OD`ь#&.1 }V9.Y'q {ϩϚYӪS`yG}/n+ئ^! ]T:@s =s, v箿 `e`jj0`י7♿wͷ|12>h߾ `upwm7^~LN̓Y§S0^NCc`zv.sS3BKn֡mS4c;Kس?kuD+a%?dEkqڮW/|ዶ qPVն8_hdh=mX10l'H$3&x,? l{GM3 Mz]gZe ,q3Jd `73{{p30Ac*4tZ6at|DtBiᏞsZZ۝@a׋(gB󗙝]XR7'tGuZ}.yø /:;AUP`rta3}*k|嫶h=o2DT?VFOX"j0NAS컊=L8=S]]7PRϖSIm(c@\!݂+F<M9r9Ws.1*%F[8So-E)ƪ*&Dyz:/O1aEgp +WX1'&iBS1 {$hu획+ڷ">IWL`R( us_R7nWT)箾 ^xݿyπ>(8@v8v^S/9oxGƦQڽwsŗwWu@ދ|F3?LS3||ӼL4e߱^nZ)/O0`OÏ<:똞]=֟GF\-H /x7r*i綯*ewTe6r u[ή>ldE'Qҳ 0wG(:{ޡ7 Z:ǁ,2E=aG kF %|a,eU,a9(HEe?[f` 9p$v{N#Ե\_|@}hϟlK]"dۜdc3&W*֨7?#oɌr5Z+TF :O?)ut=9H 'Z@P=BQi<)8Z΂@>׶;"fPߠI5f@c: ((D$0RQLLy@?'z .]4,P\\2l? <ap "X&(xױؤ ZAh&[)V-UGG'f-Le)Xu1;,X`o~󛪱XB[GeGzz~<>5ms_*X[U tPB*'M {eQψRY|; V*aso}K=_yk`xZؿ%(HX _V߇~Uht~?bVy ,A\wR ,ٶm>ϋ`"6mڄw_`I1 x<'ʚzeu%aA/dwq ,AO O$`=S~6Jowkjt6w ᣏ=D |~ŸG{4qbP7fgO+(\jVgr(M_BCSufDƔ)ћnfD"/2B$U{/Q潆l /`6#GdM^b?HGf zF_WٖG?*ri6lku=ls*k QRSQeg˶!l6l1ln,ʦg٪uBY`}J׹=t֯Y+:H "(D;p cʂѱ;:QJ`ESm1D\Q` 0'u7 n}z' }nX L%3RK>!~XV,.c UUl_:)X??')0B,ĕبI4@]P`ZF(_cw5rXG~A ,ً ,xO*EK &D/Q[*, ^ ;w ̪4հPؙpJ \|;:t)pl|0ڱs9ww:]8 vL.祗^b 4j8P:1;!2cؔc'M`]I?(^NaNvv 7#;zbk47V4ii报_%Uέ"ǺeIi4A)` P#:[~ + #HMff2MyTp0F,Ǵ;4yg"RtќH((ƘD~AEGv* @}nEtˆuOU`j?mQ0pfSEڨ2_ϟ k_jygQj}2d7O$E`i#WGrKio<{]X8kؿ7gXrecFǶg~%<@]뇀ih8#P^l;f~76SBOo?UBQ3npt"R ؆8}tt qaUȔ 6rG$7(n(,c뎻!6:/Pd*ŊpGXn \( "XHPDse38:6˦l:d#``p4BGK.\]"ExQ72!5z'._ Qڡ+bG}C2ْ{_,eFFƀ-cHc]#czUEq)F 2UH,3W 5U\|uF l ` 0M8ٳ]!JJltKHZfPTA\Bpڠӵm5*`JH`kMp֩g!G@=H lȦՠ: u1@Q $?K+˸"OCLp$G$pFLl@Xfy ŷאk/hf]4~Y-VY`VY`VY`VY`/@{6 .ۆS2xy<}0^gݚ]{d0򕫯 ! V|1)y42_q׿ǠV+[䩳/I+d& h4GPqy||kEˈ& *~?6Ĭk3&'Ǥ]5XO>\8kt#t]@ ᶮ(|j}p>;l>~ōAs'4R|K5DjE>E{uzF@TJس޽H=%zV:| ,,sћu{_g:9hғF S0ݍ6gQy^\26Dh4HVYv)8[; vS&qJ)axRܜ91hgFSc" +jA&&'4jp=  ;3;d@vqgz$NT4Ix`pYL ˗zم=k4fځ_\2#XIg+ͽƖ2;ܗ ;/gaVquձ :~xش= Tj*G@(b3S5'"J-4P='lbqK:t7cc̪&0X7 |㠲:6p\]ߘ.&淪 22*q/D|Q!TFg(ǝ=l/y(-!%z5F}an>ʛi@=`cˆPJYVYC 0p9T WJ\ 9QP@~(#G=QhuɈ@x" lx7CvDw^fgw{׎Ó݊=ֆ(ТTOj`;Df-g˰.kRM;w*p+?^VF^GTFpXV @1 Հ [+ UmUa]/5QPlm[kؘьR{k FX553beʿ-gfLj8[ѯ P$8&SE5TĬD5@PR)9Дit[%0 ـ>v[4 &诧}R`{,,,,X!%npp[]WCKcOW}`~q5cE!}΀({+ξxI? [yǮ@L+&}pK``aa򶍇I×;wE+/Ts9O}Yߛoa.@3kKרÊ)ѧ)a+&t M%ffz/_Aka C3U7/^;W0b z;Sj eYT4Z \A (AǗH#]> ;7dZu gypIudV]ˀ`%I>ٹ{ SˬQ X U==uwvvsz{Z "0&bA~Q_2APT( } j5~tyXS{]rdGul?5^{-EK4泖+,4=Uf@Mm3`,/o*ߏ|&b4 ]N]c>  p6UhDmU6mUD1(k$ lmk MMSvKl簸Yy,,,,XI~Tl]m ) ,o::= wN6:q٩^/?q9 &&'5cBI:cz長iz8C>8,UC"8xܹޫ٥^,`Y/؆4=KjP6 lr݉4;)-ޟ 6B 0٢eTI[s*C y%`l 4Ac`ku- q@O$gQ, Dբ.+E盝J'` l-uܶ`SOك~7yΉٰ&5$(=@Adl`qQ0SN:4ՙ΄8@LmHsob:vZZ;MZm1˘-> Z|a9g=qJm_GIgm9@_Uu| ߫w6kQi%I/ ęxV54M;LuDy? ?$n_}kkoaOgծ1"T^ P|f(ƚ3,sd)@3+| ;16QcPKPh**@f]S ^B#+S̢0p+܋WvD/WTG4"|[+ocJ ۵g/[,,8 ;}CwO<,.g@Z_y;lV}űtٙ9pWnw06mF0D~|=ܠ !QH0bع=l^g _Fe`{Ƈn7[>_z=UI$@4eA6 Д$~ @> l hLgA], $@F!(s6|G" 05d?OL k/)gfGXp=˱5efff'2#{\8OPw1-,qS7?/-6\*"n*JyցJ E+/^5jmҬ{"vƣ+ 7+Lk4~hG3,Tw4PuA:Yki~TNpbF0-Ƀ\X exc~B %dghPXeUXeUXeUXeUX4:E93].$l`PC/ ,nIj5 2ݠɶt\k/ȴv\7hvc@?9/ʔ2̹ +oKW^+6snRifԋ}M=korzƃqKߝUƿr-CM$g N]fjzJcC52<l feɷi1=FPPUFMtoOpPFWQux)|x<>Z>յ9O2hu9oQ`i)uP1_-*@W}$@1DP$ǗgdțAOS@;h(p7`gS{svhs;;uHv%'C@U(`>2T_û2.A缲ؖ)*:t+}B9_o~9o[Wޱkin,ǰ}X:6~9{M gMWh=^8R7&Mooyr~fV}ZPڦ3 >l >m0s߇̍0$VKԒ=?lF/7{/+%aĎ~FWeee]]|efY{}lٌH6riu\.ߍzꩧQ h2C)ijH3ih~ȼ1d 6mtI,X] 3ϲ?}7E/+oX:ܞ> `5Ν;߬A"RWVc4q?`ݼ}gW~w6BžU VMx9 jl}lsٔ)Ofϙ>XΘ^*•~g[`e5޿8`Wy]X Xjl5Qƺ9O2'ŹB%Evc{q,綾^sYXsk9U@|PPPnɇC ,WT&MxN r3R#)?5<@z1X{ZRN2~jv5˗zm~0zۏ* \JSXд'V QEVP^m)SrLD*1dP/Sk6ys+ *ƸwOql\<_X0^ΣZGґgӤzuIxds@H뺬HU3!Dc{~^+peS()<n\KXMջQ wΦ0W]P+VBB`'FTZrmH)MoT9CN(*e]OrD)+XL6}EtpC"R~Tcx Dp= ԘSM~anAN3K˘d"?UF"* ƀB8gw?h޵o^H*5ޏB=l[XXT^CVvR[(Yk3np*9\6oBl}8o_gGO)9oPѓO? ۰i++*cM(*pF2U8rKEg٪5鬠c5kӵ.5i{њ07IUr5sée]z-]P/(5b %[4a#2=Ke yg rkE֒ ōeAz.X(}x{:XzwiӦ]²3j"YFFOݴi3ko ,7.[?а|GcEV6Ew}:u gye-?P<~ML{^+RW{̃t~u:5kי[6_̱xEH|L\O'U.wcmOe8ys:>tދWYں ǟJsVeu1}Yu uQ+q;{e;yv8=t?ߓi\m`XYT*c m rx6`˃G8p,VjZVp_G{=;,7IU~Q9橩s׻o/SS\|M}:fzant73o<=~%/Ax37-<+0VO jfnU yn{;|$kdCc/Yg0Whox>`PlG2GORwfMa=P\_XL{s0X6ao+ACaǬA9 iI,ke .]3 2`Y˥3.wWE%U(X4% q==g\ `Dѻ36"VXT G8T| 7XS X׮`ܹ`l={w:tzxN,9>ſ)`\0[^O3v$%e,zw٧l\­;J˪UXK75B咥LK_CA@]%7o~V}͛@.;`ݕKzFs\OX f֎~;e`6 AfB)%Eefa:B5B>MjߠN2IOn5`j(H`CDcQ܊X~dXZ*riPlNE~!PJWhQBdb[z7f)͂Iu#WΓED}aE-aj 嶜RU/ ,k[3F@eLVG8j ϛ[k?IXF(:CAUxsiFMMqeX>T@oaڎ?k2LP`aȿ_-(NĀ m #.Z{ KP 6>@Z"Q~$$@yAm6C^)U%L ݭY\jTuntUФ2ҶDitV‡4dQTVi.+N+m8<(pjAUaڛsg]Ft'α&;;qJ-o1Os u2#@KP&<Ѽ>t \❜i򸗳p|M4 פ3O:ز婸|#']B.\,=pk'"\h 9ڤ ?w qh:8bzzGY\X! Jt蓠 }T7*7lPj`:oM|ǂ!^>z;D|wJ#\ߣkRa):[ /LeՎaw?p}2?r nZł-#{wp[엟bwn:qϨ?I%%-mm> X*ܣ'pZd, X&UE(`Uq` @e,f',3DU¡aMZd/L}ݟ*F=uVץo@x_UTVVM S-jbm*:pAZ\\;,x6 +~QoXT:|l**ԜO.^bopX/%o*?L-XV+d5b~%`;LDp<0kYrL?s¸mQB+ouw7~ `~7ne׬ގyA6Ѧۥk4' } VZzM6l܂.L,`5sڸy._|\}`9`-[{a,)J,h)S,8~"]=s#/`9A~z ښڸQ JXV7eƬۇbd㖊|z1|q5pQ1GcU-#z ATiCۄg#@BB-=l nIpObޑ(N (ȏ|d@*j =](r'c|eAS 'ǹ1دq/;h| ] ri5 ZIz7"8ơOc~I:0;>$i=ح*V7>=؋ó>ờ=_ el Y&[jC1ƕh10eriDF;KKb<ݸ]j]aMC=lee@%3\Un 2=&W,zҲwA[a ƅv@;|W6a 0S&iNLR\V31f<sVn ζ qE4C Σ=/P}R c& R \|[6 6F ʫ3C|4eH)dr tg-g&eM#Ru"k?A[oq@.\(k\E=%:|߲4wi1MFn|eGoTcl ̛9S[#N>O~Dm aw -HcIKd0x3;2R'% 1_hي hU˰ *9RM!'Gn y.%͡dJlS u^1[tctMJ^&be :pBAP^+j0h7QjpHE ټbۅ9h"i bZG-I` ,L@ZnEcCK/чت! B4ޓQNYX]sSqEHe]V,i-BQ[Q>)/Wm"#UFLzM^(x;(C2uqQ|Z|c10RJ 2[VW᣹?*^&o.P=hݡTKVIڵr BLPP+.4[),bUѺN/!ԮPsƩM-^":A5g7|AVT!닓Sh5 ) X P9Ku 2CkZ>f{}|!-wXK_:~/ELh"ow ,J`T1 un#nsmH $FL˺t*,_|B0/QƈҞQ26}!s@=| <;>_ARC8um$*m,y2ZoqRPzWJjh1_/(<ºU.I>RYĕa+;tr]zM: j/[Z.\|?/ @VnaXN~%_4%te_Koc/ĉ!$^lNɢh_U5YrXGOf p^VcHrL}qkx fFre\#*Cn=w|Xs$(߹_k+.]ֶUi,rΞ=+Axkp""5 .^s-xpO.^W@hɾg#ϪbŕNty%9sx%uf3ZoF#E` 5b Ҋ+}kU^A=p2I[ClܫʺXʝUl q[0ׁc.VEǿWܚ0`QwyK2٬k26.[dcejA,ؾbUt۪Frt], @ I^en E/CԹ9>eeCv&wyxt#tmۣGK'W tY6zai50__fwoʾS’QI)"<߫ך>Į=h8H\ݺWyP|yiH~ek,]&}Y'_Se J{Pikv/Js ܼIZpܶͳ2ʼ-#dYa)v5-RB(|;2`;, oUXyM yXP-ա[*EZo* ж x?ƏE'u7W;lۡ}}S p?:v1yi\ NrreOMT$`MD<2fˉRmM%m)Pr,;z5PT͓E#9:`Q::veN/Mp剘PY+`"o<)7_*yHkqޱe(ȩ8 TV\T:XPR|YU{ p% PBUԽ{Pr]HԢa ڱSk!)XQdm"Pǯ'MAig Ddoy}ʰ+q{gLGd9WSMY$u~AޛTZޜ`FQ,ꥪf7OZVcmSUǗAؑV=$1pVx1f%@<rp;M)`]Q$FŬkizO]2Y쬕*Yb+PhTipծV,V*}V9;e]_pә-{:\Yۖaň4c_fQ>, +G?'fV7б6 q{ Ƒo|&k+2XʠE|+j;OHr[J Ju_DRmEZFYw@;$`M$`M`5 XOX3+&Xsa5>_'`'B/e3L6dIENDB`libjfreechart-java-1.0.13.orig/docfiles/LineRenderer3DSample.png0000644000175000017500000004632711173030414024367 0ustar vincentvincentPNG  IHDRXr5LIDATx{lWz+UUUUUR?*P""vu0j 6/3_Wlal؀c!eeadib ,ڿlDa.+=13|{?RAAG AAEA`AA XAAEG  ,xfb']vROD_ՃBF~m~ /˿}P ;AkךsΝ;V|Q?cwy;~z#t_QQ3iY^{pg=.sg\~Jy4N><32e1lx׍)~ ,H޾`ݔ\h ,Z?-V_E"E =C\K="޿Jϝӗ?cs#s=& ܑFE֒k ;>ç.hyB'Jsj$J~OygU幞[%11ѧ,'elWz_j;'Kym7x" K._}Y4;6n8yOqB!Ϲ \zktww9i`4__ǗJ:%?Gn ^◿e" JXzXA XP%q5#/R$dL.sJ:!}o<<\e:J# bKfEB ]ޙ <`!XrV.-SQED(>2՞Μ9x`!XdڰaF}㳒|HPb*UGhR >UZZ*ؼry[22LF70 X&Xׯ_WW\Q׮]SfP}IWm;v"uհ_nsvpFl[n{vYW]] 5bDr*Ն|[2X*Xccci𠯯OƬ,5iawZѢ%3``ݽ{d9t*SomK6K"$$\u"x@BEdF344*TUNiS7}T~cw@"5֭7|SZjǏUmmr:055l}s}/ܩJd58fu#C\!"DwuuޙǏW.kY%V7oޤM2)UOK6OmؠN%%" Uƍ*I_\Y苹IcbbBEFF$XeR^t&=7m%ٶm>3SU}``qk9%S~jrr׮];ge> YYYF'&6u?kiQW^Μ9ø`/bv7H'w"S47W}m-,ɒ^; XK,,:fgGOO*WG222}kh}m૜N588ȸkqϩCw VLI!XW/=eJ8[Ek VwwY9蹊PtAHIMƷlQ 27W3@,`!XU9:dS<{5^;u+7{FGVUT.onK6/zRR̖;` ((?_uۧq-YB§Ai :kCE].|x2Hv@Ufg[;9#C7`om,+SÌ XtttN犀زdd\UW\L'xiبŪBXjY4Rr~ BN**ʖljOK3Sm1cZDڽ{t͛UKzfojjbB/Z*|VNFHo> WVY;*;[#f, "xiME;{4H^'TTZFcbTRrs;k4UM}B`fhhHo5 vJO7Eǎc!dURd5q)ՒTHj/&o?|P`3r)AK/"Z\]Ŧ)*lOUUUeUlΝ3'JL4ufY~:M**=, iC/߾,ݻLnnf!hKHaWSRL}^KJjZyT3T; XEyKFƬ|m盌,p\f%d~;͉lޭeʮE#33U#G8>`!XV"$t&! m2|3VJ>VXj+%ϺաnoWUEE]/v,qseBnǏ`!XZ_/4QZ/qrF! UʩEZ7+[57ϹX ?Myc0S! Xtvv=R?%uTCեJ9'* /ec:HIE,,/oMdAOMdcY@,+XWWT e"xVDD$[%GIܮ]UZDVTI jWIv c6e +ud`A4U,C!-d~5]ltT$#T?wuYDd ; eUDAJKKi(.dC\XvJ6[vjY)Q)9w)Ld`!;5-+3={ltݳ^L(vY ~FLWJ}aXier)d61[%׈P޶m&[tmU}&[զ[RWAr"j+HJ`@,Y"@iiĮe(/*b;gڋ8\ycϞY?%[%- VU2bD%Y"ř-,pׯ+Wk׮Q3'vsmf>۱rJU!2s%ƟF$[%}GZ=?nr4󳿧/2{5\/rj3f?~ַ,֭[޽{jdd1Tu~o6o*֯Ǹil_tql YS-5tqo\\P`ZxfJ$YϵҀV-eaMYɼ]/Ӓ"o!֭u1ڳgZfZvP7n0=~vNSSS.'"YtL<,{lcbjZbVәPB{|l[W{cժU3xFwE#S‰'&A%!=SdE;(p۷o;w̅d~bS,"xKc@,YGHw/޲*4D<6LUI X0o_UUɯٽPzrc`A0۽۶"wL&F6fi>yLz^%[%-nXu1nt쪦[;\عӶwy u`Am`AY.nWLwMKSμ<6ViQl\ .eU6[ bk.+c?o,p8L_r#[HQQB H.{m-/RSR=Jmեuߣ!LNj-:"ҀW27l, ,n `HE)MErqNL4٬NU/-KJl)Z͖C=;iw2ec!{CYq\Uep , @ {Hy)/r:MSPVɊb?6WJ6[,D5٪\+w0)iVҎda6H?`!X66 Ц7 \<,)1EU'3vK/%V5蟣sw-+-5Ohj*~w8D, h*(Pٶm --Zӕ3?ԱɴVʅ3c!:VIAc?K*^e%&cM#ϕ2\_', ( =WYmf2;B uHrѬNHs1l}]#BCgeqޑPV =, GZH6K:1m()[H0bmMKKٟNسgpߥXUFaEj.N;8i|RTĊC B 1H :o٢84w͖ݵUٲddeBUd֡KڸG[jD, @LAHGl};7owmdvF2S_zdf˻v+Vlh`e[Vʂ Ud_e `A/G?tZ/;7#G%[UYVfNZUHQClg۶NLwX1T6cײ.[&ٹVSFi. X ..-Y2MfWsOL_B7y|3 8no4+[%EJ.dDإ?,*Bx;O>wu1`AQUek'xiy"%Eɖ$55+0bXYiVvXpg#dE^0=$jCM@%`!X5%[vݴIo-=Bb9٪Roǫłw"[Ϭ޽1q(usB,YfA60֦B"$YK/]٪͖=WndIJyšNOW#XKV#DEVdZqx>6B 5A,*&''g`Eȉ`@8,UEGۺl[U;Buy[/tww,XTá33͛mzG Eh6 5u1;`!X`'MMMʑgdx;>dzu\i+P7{FjΞ=k eaoj%[]ɊC١bD B VF&$/dhobV;?`@h߯̊÷mP VB w,7WFG&Z{>Epo/`!X9rDʜu}[WXLI0!כ-ݍ-_e(-# c`!X>ȆB$Ky7.lNB eppl7YV}l}$#C9qE,MOO*,,TŲa\ܒEk4&fV00{_TԂY&}ݣ BX/[H!|MvۺW[KZ!Xj4ՖNVTYYk A 88 X X X``uuuu55::j[6mns֪ۡU}lڵA/XnRS###X<g+X~566!WD#222(ݻ&k`@իUtt|O;׭[?~jkk4Z SSSEpS˕>եz{{gn?~\\e ۷՝;wXEp!Y~,&&Lcbb§)IOz7oҦCdZ.##CYfB{LjQKm||>XX`=]5tw2-h4 'X5W=,:@ ȍk _ʊ앯mVz"F K:62VZ1;`!XLkn3`!X`k X@  Ґ? ,B6ONNNF*Ol`e\ XVKwu , K2W"0l]`EQ@K.vZ]CZF\pa/"X`Yƍ*''<`cȔ7|ի,@#X`dڵk3t!S`-3>yy%!ݦAV ٳL w4Ey~r劙5-r6пW0Ӏ)))O=fzu떺w`+XnzrDzVƘ" ֺuӧ.?u]BfFX(X2J9w% F>|8<0?x*ө SSS>}s}$'gȌ}sa Vrrjooqy,))iI;3TooǏU͛is*=Uv_蓯@5616`Dz-#DF@<3Q_ݧS 厉 cK,u>XgXED|~#nHV}}3cJB.kx L [1pO !+Fڰ+#Vlt[( Jbppd]ܣgMݭD*w߷ctrOj.DrrJTU,@"`!XfbÆ)-YZjych?YEDD,߬\l8+TEE oN@I@ϕR@cVs:UR ֳ+o z™3gX9k5def֫J`Ogg>*&ҊKX[-YoV@SN]vA*BFG Vp"S8d]L22*L Xl.MG=|鬎`ǎ3;/X"Y/@צRuY޴`XI7/_| rLsJV/g:*+ {9+8ydcK$+"ڻW"Y` KKKW^U{AB}jɲ&%Jżb5<<,ϐBv*z,wO+p"XА2YBrI$ ,47O6{Y$+15S%ES4#$+v@d6 iK8=?B%'L6u^HЦ6 av {jdI{h@,4 VHVL/LMtg6 i[*,,3%DKHЦ6 PRRi6u^%h@-Odutt0>u=d2XSn𣬬Foڶ3$ KHIA;n\z]aY& ,Y5߯?~֮]=zd?wjnnF˜zk-dmZZ_>X"W }ٜ=𤡡EegW ,Mnk*RMMM/`IPG5|2}j$kdhyC DKɒp8d_Pׯ+W5-r{;:',,r-o_ns涭y%%S[l1ru-Rrdd_!R.'BdQ}AƘ"UnX(YU,` hkv u]BA:䔪[?D֯Vef֫2$ ECZ>թ޴hllyLV.*izq SSS̽Rn/]]]f5Rˑ,`p.]2ꫯ2$!ޙM].ײΝ;"#rlcd525c A'X&Cciii汕n,Y+ϐ զMcbb4;&&&TddKn޼Ig&Yj-^zkSe̙31`%JkrrrJB$cYYY+,nb5k֘?kg;"X"hz KHVDC}~v(شa hKKr/.\TאƥZ,>`F>w}"҂F*RqqZ$YiUG#X":٥/!S999浤нZmܸѲ  vL֮]?Dn_hcxyἏ?x'YJ?ެ55)5XVL8`d%'0544@` Vrrjooqy̽qUeDJ۬\E(.+)rp2JLRyyN$ [z-3X^^>kK!%#++D BC(Ӓ~SY!Y+0S1l,V9VHVJvdN<@` HO*Y *d[&Y?P1`fV ]TZZqed\4ӅR`-Ng}/a]b|B\:̖8VHֶm8N% Ԩf~}K$k&d`5EE*32z*Pmmm/ XVRZڨ%2ڴ鶙.lnnf|B—CX֩ ,[Td`7.WήP7~id&,+|ih*ג5ad}e$@,+|9xCKQڼ7HVd*'\3`/--]ZJ֭["Yl`~9B혙۲e2ήR/`!XKgg)4%U^^N& B𥷷˞VIVVK3g0`'Pj***&`!XV200` wldFәMT={1@,+\3YFbb>D""jjQEL X eޮ2Y`/OV*6gHc$kxx1@Օ+WԵklydը]Y&Y))'d7mnmu떺wCڿQ%$VY"Yɯ)éc2X\1EHݔHVR)$kϞ7T~{1ݻwM }Ur Snd,'`fLLLvZCZZxUNS,,{=2YYY4=Oj/ںsSd X4Vs'5999+""Kq8zTVKm0edm6d X6-L3TfjO{"Fr ڲLͿoVjnnf|,)YM(H->XxSXث+ƍJVjjjb|)L6nd X@Eq[nD6l[l/`ARSӯ-I-2;0aud%"YM}}m>HJU^^nv-`, ’-Ee*&HVDC|Uf,`!XnV|`tavv*))A, —7L؟YNeeTٳ1`Ax햬,,a&$ BɊ{ddefv:}4c `!XWJH8md paB <ɪW{ [6]~LK@,@DdT500 Xdef6SIVJ)-YH`A"&+94B2~B <9slRiiI֞=#*//_?~1[9zzz@, eqXv^z`d.D $#ت>Lq76`!XdfÖIV\e:v >M]sXegWi*&}G7ğ5mfgTUU'MoB,䚬#Y m`aNdQDsso}֚;w^P[뿟Џ}5=eȴvtFdMv!`!Xj&\֯oQ&kd92Tyy>'IvjWU|O֭c26QYY.o_ڰϳ;./8Unnc5+ XFFFqٰaɊ"٩fUTTcSfO$0LN>a^++9ɱ M_\]FGG`˟32^TU^C=z ےzRެsLv*)餙ړRV>ZU/)kك3+Aqr,֭[޽{jddTmn$ Taa-5-5qlYLBМV+ݘ=}(WZ@ z1f`^~\6oВD!S;UUU?+4}^{Tƍ+Kʲv-EƮ`!XO{Z!Xo ͷ͛cɅn{Fjkk,DN22d:շ"Q;v\5R2(+M[-\-|}oMZV@ĪUDt:g>4,,{'d[,Y}S}2٩r OPrgV:=,-?|׮}:L/+iPPPd>+;;;ի\.ήV۷zR!;V54v%`HHVi֭FyL:YrΝ;"d [%Y6"U]]ͅ͏mDl$;u@)FOK4;sI%% Qac\YYib S)=~%*!eoLO?dd:-@![orĄ\`I͛7iEEŀ(K=_\h.=ee3)Ypڒ֭zd5Jĉ-úd ̢~jC$SL4?\Y۾}kz\ [LDKui%뫙,e$ctdRS/~?$;%#+LQT~~>n.bI=XqqiVyXm|/%W&dQRRyYYsly>K,#m4@a\%b-2~(QH٩rtgv~kmkD1҆bUXXa̙3~]N+_Nj괾U !E籱"E'wZZN]ŒUjp{M$NEG_Zq'SS8JqL痪jӁߎrڨ:R3=:-+iecK.ͺ/>>^MNNΪ@ dijzHVL/,wZ d3Cmd 4;;eT_dy]SJ^C^O^W,vʟ'%N X X"7{yn乊P,eiɪ2S)Ve rskTQQQgm)lLvʊBtiNIEd(1B@A+ejY2{iiPV0 Vrr㏟>Xv6>kUl{J( zM;;%Yv˲S"d;v\NIl&;%ڿ:-@`AhuԨuβWnnY.BTVVeUv]N9զqh(dL-?UǤL3Ӫ8`def6HdeujipF&Anξ}]*6ge8葝Pee!Z.)*={Nڷݬt:Pr6ERbdf/-i)k+~?IR"ST6m i1YfD, `qzMwUwkZގ Z&-k V@OS-Sutts #d%gaaL?-itVQQ}) P}MP7mc32}}a˝kWuu}d`YUUYYv,`O?/ r^8Ps! XaDJв3Y}|׮/e;)5٩U\|\Fv m!HAiq/%*U_sB,$ 3sٕЦMwoDbb>0S3+rr&|YCQϫR-?𡊊tzjr=9&`xL5% ]T_3r}۶tR;դ/ر^:h-jRmRRҀe5鸡Cj%% |a@, MRkLJ6hdIN%']eF_lZUCC TOrN)ThI˗ #B,S#RCa#MH ⣢>QwUNgJMUGLA@i555BSkcG~>׈ B,w22B^Y/甴b?>`pV|&䏬*o_Ӫ7]s<, 0en#VBffr:{TW׫GᖕU/2:-J0yݢi!XX(,!لPEtlW,ٽiM_jsx XRm*UL%{ގGϔdN25Օ+WԵkl6\W^QNgGg̢&&>'Hn#X6֭[Խ{BH{ S|ouZ7N0-y}``1E6\FY%Y?YpQ``ݽ{d,:p@ڔNK(w siO IW%f೩*R.V"X_|OtvZ;?~jkk355l}s:- )锟=N 'Dxnݪ._c2W;s[z\e [ݼy6 hlEԂ%{XLLrĄIߏ |lN Naz`VV4t{> \҂F:-8=.n:-+xS/^4#ѡ222cVz纏N`'2mWTTn_{nIIuZo坥ZfO, ]rouZ"t gB[lUg% /? yU;S%{N:-kuuu3uW.]2Ņqϟ,:rO+.]_v츢[f괆9&hjj2E25(C[`!X`(,2}dgOK9V`l`U S:-ɜudҜrh`!XR={V6L{Xv:*&rڅF9sc`!XZ:bOKN)"Z.588@,-dJnAim0-[gjB,ITUUjm>lYjQ] `@i=D_jM픕sS藅`!X~Ȫ #Do۽{_Rl`!XjڸKj_jUQq`x"++khum>[4k%}rrjB,봚h:=mshee Y+ Nڽڼ7*5ή#k`!XViI_d, CBBB,@,@,@Gq!V/e`׿V.\P//^亿o>[*;CFGG9ˆSN 6?pY` VE J"k@ʂ%XdZYa-XdZYa+X=RׯWqqq*11ˆh˳VdAA XAAAAEAA XAAAAEAA XAAAAEAA XAAakfQQQjG?jnnkԺu?'NPIIIj͚5WNSMLL0`!z՞={^vP7n`B\7TVb,Qs[>`g7"wrrxz٣ѣ*66A -`oڴA s yl|#Xݑ9ތu!߂ 7[K| aw{T\td9?ޒ,Ÿx|h=ޞ"XB.`q!RLg:EW^U˗m)dxeH \<3"ھ}zTDD"|RBxo$d/\.>ŸEA`AAAAEA`AA XAAEA`AA XAAEAv'K2IENDB`libjfreechart-java-1.0.13.orig/docfiles/MinMaxCategoryRendererSample.png0000644000175000017500000002663111173030414026174 0ustar vincentvincentPNG  IHDRXr5-`IDATxUg~@)R ZZ,RR(:Ȉ21ni\uVhj6lnlw3&tI\c`vŎ!Eq3Eh}Kޙ;fy]۾e˖~;-;^oon%'"ETB;w0`(߷ Xqr]O>MƱO+Cs=7?z1i4׮];scHÖcٟUVmK#ͭXJXՀOTTXNލR<+_ʤf5kVXfMKڻwz1j\t>HW\уT{örO`ϯ[q:uTϛno~IPFhԚU3({j_~^U_m?j!%Aw>.ε4k{Cw=l]j?~aXZB1zʕ+G= 4 XN܍N(Jzc&2Cs1>qK#3zm~7~viV{ƳHsB˶G\V7u,tzՎ;zV䯞 ''"E"%fO(cUl'3C 1^&!{e\Yj/)]kͿU7#5yk:`ѤV̙3YǓ`"j xXsvVoo䓙1JVlMqe8z=uoe_]jSبm.9@ Ѝ;=׬$yqg\}wՅrH1-df<9G*"E&ۿۤg`qMVb,}O/j4?S(o(ћi7;?H;k_̷Ɠs!XDk_'3&C_(mذ!͟??{͚5ٳy g͚fϞ;Ҝ9sҌ3@6 n|ttƍ{%K,)zzO4d͛7/U:::u\BOܹ3_Z>1kko߾ϧW^y%?>=z4m޼.X`oXl[C;erJ^~Y=7iӦ`ڴ4$]p!W\U΃ҬYٳS^ޱcG3gN1cr0fmZfm`Mlْ9J8(}r0fmZfm`MΞ=.]j VI޶;wnv1k2kkSO_!X`oX\F9Sv,eWr~o9v3 9Wrh^`M<-Xz"lO՟`ڴڴIІ ɓ'V רn`96-6 &XONV2V q4s7H_E`ڴ4Hw}`М9q *Yx1r0fmZfm`ɝ5RVάeX5RVάe`,3+keXX9+keX5RVάeX `iYY,3XYfX#eZfFʙ2,Nʙ2,)+gV2,)+gV2 1+gV2 kl kYY,3X)+gV2 ;0rV2 kYY HY9Yf؁I9YfX#eZfX#eZfb'^Zfb3+kb3+kenYڵkFZ&:t(ӧӦMK===yrVZf֤ܹst)=Xi)OfJgNyyǎiΜ9iƌ-qm%V`Cf֭[ӱc\"Xt|xnmq 嬬2 ߟ!k`HKTܹ3_BRZY,3p͝;78q"ݸq#]~==iݺuup֯_@~婱y#cgPNٱ\<꺒^E9B}LݟJWV;J^.ki Vּy`T^z5Yf=X%K . [ww,r32IݻӶm*N`ضft̙|K#Y),*޹sg\e`5xݺui׮]SeX"}Ǖ;Uj_>7,~ORfSw0Gue[o929_ y#ggP:6㮮+Lk̅V^ y0CVhƍ_-[lԿӇ~8l =X>,T,eփuKtR4dɒtqϩ4Recm 2?ITF*S.™3gV"|WsUU[[e`5BSaÆt@w,sσ@Ũxb`,3j^VՓ.Z(m۶m]K#YVɽ~ &H~izS__߰F|gϞʝfrHe2q(`꥗^J˗/V34,TfYY,3jBoVz|F*KY,3]x1:0)gVڴku|`q !>˼s|iI9֦eXO>.X`oXErdLݟrJW^.[=̑v]ʻr.{}ofʺG+r.~bvZrJ=X-i>*gVڴz&YqG!*xjYYk2 Ԛ5kҩS~iy̙3+wSnqYYk2ÇT q=ܓnݚ.]J>gN|9s/^lZ`]e `,33k2,L̬M ʙY`,33k `,V̬M FʙY`,33k `,V̬M F`ڴ `YXKeڴ `9:016-3X*,+gfmZfTXV̬M ;016-3X)+gfmZfTXV̬M,X936-3X)+gfmZfTXV̬M,²rffmZf4Rcf֦eXKe `,33k2$`۷/^:͛7/-X mڴ)}GKC4}\ӦMK===yYvXtĉtƍtk׮|rť9Ϛ5+͞=;rޱcG3gN1cb֦SGGR8>Ɓ^99>zi+5:ydX\%[wܙ/-xi+5zӲe *\ק400߰= ;Ur(ΡO,teeSg9ΡݝsqWו\,竖۷ި!wri?V[6|kR4MU6YvXǏkx*q4sGjⶶ6w2kWkr^6gN|9s/^ i+e&w`, `, Ra`,233;_,|bff bffvX `13X*,333X*,33XRa`,233;_,| `,`,|bff bffvX `13X*,333X*,33ji:tPMӧOvڴi'׈ `ݲ… [RΚ5+͞=; cǎ4gΜ4c W^qV|Z5*m|2а `Mh `E7k|Wawܙ_5lffvX XV~|yq`` a{*,GL;;W*xlٲe\QgPq㮮+S|ZzJk6]3gάܕꫯOQYEW `ʼ"QAyE/^ `M4 MP֙ܙ`ɝbfffXbfff`, `1333X `1333X 3333X 333, 333, `1333Xbfff`,ffff`,fffXƍgI6mX ƫ^x!ٳ{uVkz衇҅ *}Q333j7]2]`AM+g׾k֬ac^%IDDDkz󝃅-[$j`ժzl333s.5`""""XDDDD"""""UL;>88.\ۗ`޼yiyhݛVZsǷ[.9s%wul#c=?ôv\X#c *_=sYEwF|AJy9N+8GחN8B~zڵkWZ|yKh>ߡ#LΝKԩS-uօ {P]%K+>Lf3OIr3s˥#e.+`y֭رc-{79r>o5>Ӗf3N<{wZ)w߿?_2,sv-K)sdNW:ߟ!+.eG}tL1s\"[tiKvtѴyfEwF͞TXfyӲeJ3O>ԙ~<6luq(kƍ78J.S)sݢWn߾}yy˖-yS>~'NǏzB˛7oVDV[.uvvt@U_ˇIi._k׮qY""0-[ޡj*Tڵ+}MVqɮ帑i"+tʯեiϞ=DUk֭yFS 5c]˗ϟo%¸,X(.9ֻDXOqwd1+~o۶M,"U"W^jhYd0P:zMPSuǏb[Qov+oذ!@^ïr^Uzܹs.M݅D&]/rp^οPT l jaB1*^;[% <_7J={6F8^hsp$SDTV̝5Qڽ{w~۷{Q;{,P|}D)zjq""*bSUcD)^+.OƤD`,""""EDDDD`,""""EDDDD 󮻘d"XD`/D0I}!"EI ,"'L"`&/D0[LM='?m?y`oz'Z|7=ēi۶owy.^~`4o޼r/N~=4hg,M`nt\?oM=y|Lzɭu!kڵ^Hׯ_O7nHoV^7U=ԃEdU݋rt}cǎ}RݹWiƍӶm {n}+gҖ-zs;::2X5?7khh( ۶m[?~ڰaM/"XDtk``{IgΜw1lTJOOUVԩS7Vs=WY~͛۷ <u/R~ӳ>[_.\GIK.͏ٓv]yW5Z?b5Fը|_Ehk?'/}K7lԪM7`m|sVH4}ݹfݺuٳy۽ޛ.]Tyn… +wڵ^/WCW<'zy{ܹsWɀja~5*f`,"d_Nk֬IW^`ǶV +*l׮]Y#(m`xnXFU^?b5Ff_`,"`.±V1NcЩS1tSިF㳢W޶X_ۃ8,Zk?}lljv"1X4VO1zpp0v/T͚(pzG^=(׋1X7x1X`sܹSOM}X/"XD'|2$E/oQY ;&B2^M6U pXwW^͐kwwXX@&`2VO_BV M"`BD0I}!XDI ,"'LR_`&/D&<""""*z-RCIENDB`libjfreechart-java-1.0.13.orig/docfiles/PiePlotSample.png0000644000175000017500000005757411173030414023204 0ustar vincentvincentPNG  IHDRXr5_CIDATx tו98?IbŀX$v[ԒZoHBZ!$'Ƅ ۉLf2/dWtz;juKեI1 `a````````@000p4 Ljg?YzGiƍsWUO<ا }FokF0EEEʕ+k|{Æ ׿X w 9|O\&3999XܧiӦy`Md_l\vtt^?b`@00|Gd^yId|Ql}'N}6y7;v<Ʃ:g_W"=d{_~evHqlԩ>-X{.N9zY;COY]]mQ100 X^!Xz kb\9dip h"TXؓ^2W7iOgfq7=gϞ9sT1qm9]85X\of03s^XJ2`|!-WD$\\kX8hVqrEKN{~cyMjM Y000 X^-Xr37H5ֳVu㟵PtsK{՝i6Ǘ.]:>קhsQ%*T( kk1f(el?<3Y\?QzMOLL>c˼'r)XΈ`H#q _ /_c|_ccpO+K1>?G_"f飉 ZeUG͏-wk=,,n7gr{ y[S, ,N7loohZX@ISnnEGht??>Y˔K$Zt5SM ȥKD˥T9$}3G"T"X$[CBjk먻)E X,ijjB N=#dʳkp]NIj3`AGjڰ!{JwƟKC55` :˧H7 l_Quu$[ ֆ4",07|;H)7H':n2lݡ.Q Xob`` *С,3'ƫʗHD",222"Py|yKRAw_WZ47{M_I*_{ÿP]eӧQ )56ni2792;,x=-]H'GX`QYYBD  F˓<:U[<#R<3 X~+V.XD__N,D׵bz$+h:  ` rNN_+}ޔ8MgϞg@ .b./;fV 1E:% XOᚚWNB XL$g2s@y{Lz*rrzzzRZZG7cv ѬT^^h,|Y(G J,74uQ__?>@~i4 `yW%jچ@N)!!fFgQ]T^JΝgתKC˃9JK >@ ͋/;Դ"e τgh(d`y[RII#]pe XxVolzA!Xޚ2y>|`~h&-f B|$exꭲK!V?je VII䓨`rc6ny XUtt=i`G]ŋ, X[l`UvEK/WvoG˗G@\/ 9#<<>_q1EEߥ8O ut, X,P ߢn/`5֭?:]jl@5k@`ڵ⸍?UWZ[{p֭[顇ɓ's=GQQQI&- 7oޤSM~axJc%%%c=&n2t\]&^/?QRrCډs`AMIwޥ{N>-~,ϖvC x o}¨sh022Bs+&63OZ,fڴiBo;w$~!M :oܸ!^?/((H<;4NArH~, /-[Fhh(]rE|ϲ%?Kb#@<~v5jiA ``Dcc+bA8bv"rpB!8dkjam,,>oߺuKH Z}ł$׀M>] Ν;o6xup,Fd vڰ!Iu4<~HiX䨌KsIHH0ȝZ}%z[Әl>ow' @ X9{6mJ1,&lM|7ŋH%I∓qdqTJ鱙3g Sϲ%Q/9*eL'PY{a`!E}t ,KiT\ Xڄ,0\[$")ï~6G,`q,?sXh544rsN:tиxR}⟑#cgCqS uUB¸~x;,o6c hpEGnnhs `Aq%:v,>󙣊hD;G8r"c<NEȳ6&X\L.tߟ*8ȑ".(W& g  &3zHu/X -0E +bb{ xu?(#Ns`%Ukhdk4<2POO[{ɤ3VЦM 4yr$<k@ŋq,ڥJYj !X 66֬YAk׊f~`` uuu9@ϒRAVW iΜH Voo/-ZL"N7oԩS-Qz!e e R$_YHxq{&Əbf-:e.< Gd[x(%`ayG|֭[4m4}j}4 ߖ^Ν;o6%bV  X/Jyb ./} F{`qDļpZ)&()-Ԗ-Űpѻ\n϶yITeX(~Ǟm,ع3/ʘZ}3)o,RJ}\;dM8[ 9⤔$̙3E Z}-,zY{M J?k6l, %%mh$`1 &h Sx gqM<Вp!S 5HK5X\n<;i>4=ك곔%wgddО={&}ຯq۷g*t' ^35kgOBG}2%hMk8Z`E90 n~.Ŏ;T#\j)E~ jYjے_3䙀\e5?gΝb!ox0/33S6 7iVʕ1k$ɓQN3=ה3*9F<>;3Ϭ9sӫWI| !X~T\.<>^qqqX*@g"2…C3``A @ @|WЖ-qCٴimذ֯_/ep'y.^ Xx&zHq !p1UUרZ̤dLdi"< Xz?M)ܻ}Vm׾`,EEm\`C x`ٳ#qA=nx)hܿGi 5#/(Wzίx9 O Q^^<`~rXpc@.D5,ntqhli 5wRjruunRNN#iZAGGhH:Qp,ూ%?{lR!,<24+W5- Gqf͚&?npl3,KeQ$YꌣlԖKq}7oz/Fnn%'' jjjp,ۂũ;>/s*kӃ<0nXjRZWmߣR#;y<3~Z[[ +fmҕ+W,[sε{[7Z,^&7@`pl m^[x41Q)fɒ%BX^V,5xiӦ,wfi͟5cw}{Lڒ5vV+jjL(V__|7łrRcI,Ƀ`qJSn"a9ss VeIy=U6oFfP@ 99]@ õF7nE%XҌ>tΝxq Z}-,zYoJ?k6l,ڵ(<g`͜D_2ŋ!X'˻hJKKC, KfժDIb?>]uy @kדh;7|+= XMMM8oxM@.k."f6Ғ%뤋>p/*X26KBC  YY*,,y@w3Y>1%bDڶ-N=>.Y` @։:H $I?O/pY,`Takp' ys,M^Ii]JMC?,hi YY-i_OYJ[hΜH…?2`UUU\ X9r-JbGPP-_~&O`/+to4%,ۗKO? q&-J7ވc,5dgH;|SE7qw1kVR  | !,^̊ eK}s,kX29@o3Dv~:Qs9 x͒95558M{izys<-Yx?RZZAJKKq,hM_(((,0+ 0` hAXwo͝ .`U`$TuV_/;NlȠG3(,,BCӤR)$D#=~NC[ЪU)dI2=\Cd< hzp4`| X'XBn]9m^(m29i-k(((6nL+RNwo&ԩ!XEF@MA233q>,[_o^ ʄݛeRXG(44UO+"d{jh۶IRWS驧 E΀yhp:Vot ].Xti-S``1F8KGdexxABCiDS6E/2Ԑҥ9? JjjI|ITejDr۶"ڵc!;v,]& =!۽[#~ 3'I̚= 8"t|I֭E>#XbEbر1! OLK,w+_6.MOs}S֭MNXD.\s2`!36m*[mR$R!!%Q !ۻ7Ed HW_}{$kDڿ?A3ׇs2`!9֯/1j))PcIؑ#i?)TVv[;qN,CUG+WVA&]][AQQtDi٤ӝ  X VtD \޽i7P.zB @@  %*={. bBBz)--222Hɒ.TY;H`_͛|)|*..K^g.7ddB .m,`[(:jx\1{Ht***Φ֭׿EuuTK@ @EH(ʕLXXPvuu$UuhHͥ*5@ z}hT JQdd$PJ&>>hddD.^(ؚse `!!X|곴ukdcbъVb觤$͸ٳg)''Ӵa$@2^MdCSS? 7J)2f2&:Z/T ?oVCf1<KYIJ) {wɄjQJLL܅ fNwjk?tuuɆ`Y.\O>ĉ1i51ȨO\1<d>޽ @-W2qqٔN.]R}qڰHɤv6s`q|Ç !~tDٿ@skAu(6kRz },= X뉈@GthCJBQ~9ދbX[**!A'X"@Wrd DO ϓht\1b]}vkmiìf?M$ŷz@LkT@>Kkĉ\XjنZmhRZQ[ȊVj"X\ws1`6mB?UDDTd"#,ska*++3Ieh9&q.,{ \D7wgٲZIpr&W:tLeePw H]Q+K0Ҍs1`d>4嚫,:|Ír5FXXrO}9(EvSff-UV+éq33`%<|k(22W.˕q;RtMZ$j:2J#m=:::p,DG\:xcٷ(xTYsX%n 56Sdz ;-B-A &M%Z5VC11Yt@Gɕ /Vܮ~=#=~EHVrI룪zQnlT =EC[hJȉjU:E!!g=Rd#Nj)z!Wc!i)/[ 2Rnn҆q @q&vX9roߠG˕qwI %Vٔ6Ch2Le`HW^g\Wҁrr%g=?Utdqd+',UU54۰ =?H9@B|^{m}U@@%:+9{޵/Pjj`rW6ljjQ =qW8`_/lڻWս ]?PŻZu5 CVV8ٟ8`_/LIRdҭtx-Jֽm ӆHd B8>f8`rNZGhϞK^-WÝ ޻ ޕjPAA3566O`Y Zf"W\g@_ Vll,Ydk׮_2XcUn-Stx\wxUjEz}JZ24ٔ2M#m?*,,@ ֤IlQy&M:_nr V}^nn?N=-ϋ>s^-SJk׮om[1EG\.N,X26iڰr Ώz x`Z8­"̅’qgҥ&?䓢c``f̘a驨9b6o,DkKB2Sr%sxJh4lJ~64m1$>IO'X24*XQQQt yAAAH 7IGrH5% mҕ+W,[sεwa|G{,iWeཻ{PXLHنTYYkSҎOӆZ 'HUUvv6kΝ;O$X8dM/^,$JqG}ToݺEӦM۷ogY]zӧ c3+>>۷g<`Sv6 ց\H:]ԟنm( 5,Iz67 Z,,e1r`) HHH06,{^UGۺ !Xѱc~%WLp(x/--U|_PYYWZ[_,%,*Gqe"'Ȏ-b3g5XjYDQ)*<>VJ?k6l,[S!!Qwr%sXBj.x!iCن6i w uu%&}`c xm ֩S 5X\%`=Sfoۢ"pY~,T-9ȯ1##c(N/K&Ѝ만Dž oߞmE?NkE(s Bޖ,B[a~_ffa=mbb%j{bϟ 3҆z VFdg @:hTi<QHFM!< 2ԩ|:vd1TVVmS;afff~V;=Ù3gp,Tr>{|8UTV[(])<|beR~bedt9E[5JeSڐk4'=oӆ&-_`Â.> R "Ji$IOS__M azz /+'`ukA XdgـΔ,~f$t66Ti4ZKRCԄs8`υ 6k.ڱcCپ};^- D@zU`YܬDfɂ5VuQwY҆Նن6T x ܪ斛p!<22 ()D X:Y,x*xWN^g3ohR:6wAn`k>,UQQ-]+!E$,J*2{ K-UP\8" X^7~j>O4JIIzM*5@CɈb9G+?\(˖b}rzйrJNg:lJ,:ӴO KKWLW (΃O #VI@@-g)$*@n{vv ҆oSYYMKp{k XYY XXI*~^{"#s$yBt:tRE=s4ֽن=TSbSGf= ``EGC&ȊU\Rpȑ.$V+ޟ[ O(Yܤӵ۔6"mGyyx`T;~NK{C T*++S-xOKt`ɤJJZlJr SR4J.mQ9Nx!uG O;w@`J:y"A}ĭKRUUM )==ӵ y{\UWQDK-  ~tTo dWJ'I ֝=Ctxr{ ޕh~BMj}mCdRUUlyt0/8}Gz@@UU-ZyƆ Yrvw^dY}{A#X҆E5fޤT5)OZS* QV***OB~\Z.eXz^,IXڰ۬mȳ (+E?=Fw۹O d DJ-[JIȕ{ އ()I%-lü&jk)]_[[+Rͦ^hR'WX@3gБ#*3K(**rFnss$2XbRSOz}Mg򌚔č*F[=ΛZ6L8ruDϢ,Yz},IiUUմ!fmQ%I*T,nWK@rsg-Jb",xP{rz{_9j/x`i[?3 jS]'.(fPO 8: ;v҉ԩ|]gQQX$^ڰΝ (z^4)نs~c`__Ηb6\ޭc*!4\^ZZkk}>#҆4){f6RM͟"Wi˖8 ,kΚ5kp^,EGG<裑+$Xm7nq GRZZKKV$ȑ\:t4dl$$$C츸+^:,,Go,TUk\J  ixx؀Z Xedxw-VDDt@ Ɗm)k׮>4e@p:۷7yX-]Z+~ȍ ֤ITqDܼyNJׯ_߿۴|r2e;Iˏ?N=-o{9)|5zA 'i:*xZ:v,Cl l2{=3gXz$$$ٳcO>ő3fDz***|N͛7c,\wr>uk"W'NdѾ}/,{&#Ls޽+m{7=CŊ+ɓX̃>h˗i֬Y6KLRR3-[}]"Un:Zr (,uƯ7[,ϛ7ORx1`.+x5"-w0+<<222m^ zNSXXa[\\!.VNA%8dy"ÏPGx[+**nܸ!$QYNAʿjx_+NsqPreKRK,Gy X=?s ޗ-' W"X.\0sdD{ڰam/cs=c#R]iӦebayG|֭[gn߾Zeu~>Ӆxɏɏ?_#.۳ ~)-Q=`BV+qȕ`y篜Kwȩ3y… YITeuɿRԎ=0 Xx`oի='UjU$},W!1>&X)69c!@02`qdIM8eQ15A9sxgR_jרlVB@p|-(etVct{ヂū ž^| +gΜ14εYr cY @n K?띸y=(TT&okc(NSS>|l>My1D;`&YkזӉ+oQ#9J_{dbRqQ,!r'Ϗ:-e,"YjkѢEb<grq:Qql1?~]njj`23[kWEDT@F XV[-3>ZJU]$= @^^;ROO/w6Uppt@BVVh+%k$LYeg7PMiѪ<*hkB{w>9R q.ȑjӨJ44wӻ)F>%'C995y@p|*/&(WZ'*Dt)m޻ŭ<ܒ؀V;BM3s` KKirjϞ|I!IPRVB(7C}줚  W 5+&W{亯&I R]eJIy d7(?>>}vZIJ\߯p ٔA###ۜF4Nzz =E477VnA$: ?pQRR(xW6$g{ N6s["T#@p(!ar:!!: ES DQ~J$v<};l}hn\[ػ"%&RAA ~ ` 8.U[[KG4ù`9?r [L־ͼyz=(D}"ܕQ2 WQ^O].1N|](xϤtO Eh4W X81Ņ11g!X킵o %%iv1(Q,.@pS$z XŜ$ ͘1$SQQsl޼Y?G ց":QUE?.xgԩeHii5gψ={6=4o{:|T%D䆣nw}@.KhUWj:sSg%, *Xc5݃C>Pv L}}==?eEp`1'O P^V&=~KGrUZZ `o /Y&//EPX*0?i5=  &IH~erub+.@GTYc4p`IGZEjo?KE/;*;;[ ~7h4Y#"jQ|n^ W\S+nv 0EIIzr(jkk/SjIUZZjsU X9 7hܜ4$"#!Xc{kppPW]%u\Yl$ߏs`,䈈CDD"xeϞ:~BH^^1-X~Ǣ\(`&TN( qpXXJsVny >q,Yz^\LPGB-wbcsNbLV)xEt3gp,iiiXFGJAHP)h'\fb(G Wpq(//Q[ O*$b% JMM{>{Mruɢ\?+8 JbRGJcUnKz7Jb `ϽVEEܖÍF;::Tg/x$fąrhQn r X˦&hhFS\cek*=='6XN$J,Ў&ph544Ybcs)$R#2&Fgx8=:::X3;ߴ􍼶9,xOEGP啌JzϴY8bU__O.]r{S5'o3ktX@АXwnŊSJ'O/\ q7XM$h-:]b a P8=dZ5GDOYҧѪ, e+gwxj9@j4E_xE 5M/f)C|xxRnZ#ȑ6Q/gT1lkk+ ޛV8ى,`:-9EԡhhaTqٲ2Ņ Cr)t8a,)%.H;umDA#GZԩ|IR*V <Qx#Qa5%+֦(kc|HYDl^ly,rLV* h YY6vxȱ:}h,kF)hJ˖䡂L}QG11Rk'I1]]~^ Vw%j$4,@)NzUKKUBʹw_tS?tKH&DJ*,,VmEoR>d]N ڲ",70YRK#JWKpotwZD'$&OX7EEE,zy{medt?Zk*555H  VōL9a)5>ҕ)+&&N(!DfEbfUϰѧ--WWWE TU:H!}͵ٳg,TbWWUTTkhj\ە!m;nesxhKv>_HH$~.4g.M6BڛH-4ΐJQM~oxjM,פY@,: $5Gȟ`---ɳ , pGr8Eɛe Y 0}ppc2-n翵/B`aQ%/ck]"tNHqxSO;Ck)&0d΋1<Lk8-%EƏ3ܼ<&i=^S{Y]! `A X, `  X, `@ X, @O=rud9@C/_~{qxqZ[G'ۅ #xzz\o, }ZZnS}=hn#6޽Kǎ^{M}e*)y?4PTtEmU)Qcd6Hwi@K.Oh_)Xߥi ;,wm~-,V̙Iv.Yk?,V7QkfK$('ͥ+VЫJaaa4ڽ, 7_\_Kr3J+K? 2+1 ~оK8rh\:T'=b_y?wԛȕL`έ_2MJWR?o?8??u-q#p`OEHKKq} 0ڵ-[F履gmhh F#LT̙Kr%1dݻא(~őǿ˿Ppp"M` }jr%20!R;֭[m:>EY\,GKRG]Ey?X,'r ++;Jmsobeibccƍ~#I X, O ҸZ>q/555^|ς K w^t|ߧ, >U_?h{G6nHK.Qmm]QQAHKdyy直(X,cɏZk^TjQ lKњ`>YzT11㯼9+5zs'?8ђ7=_{ ÃrsT?l!?f~ ҥK@Ad1S B(DwwuQ6qO>Q8hQjkNHԎcǽǢ`w*RmhMvUXb~_YN8!nGEEя Â09ci[z)SyD~|b'nmMX1sl2d_Xei|>&l66hti-/vvW qΝիC׾޾+[,vG$؃}2,Vt,@`SJ8KDMo* hA^-Y}E$.ZHUkE_-o{(Q[<⃡;E`)J~>n"hR[EA!1{ @` 8@`0XL8@`/0X6ho,Oc }~fIENDB`libjfreechart-java-1.0.13.orig/docfiles/ScatterRendererSample.png0000644000175000017500000002662311173030414024713 0ustar vincentvincentPNG  IHDRXr5-ZIDATxh}?c1c111FHxe*R϶B&1I"a#5UkAIk&UZ}UyqvZw^Skj߼>멧Gd=~ߝNOߟP ͇lKDDDDQDDDDD GCZBDD9|ڷo_s?sgg//m۶s)*ELG?u}G~)֦p˽/R9Kd3瓟dAݯm5'jw`m?Q>%ۻ`Nuum^?K}ww#|&eϧ~ȑ#77"/g?e[g;w.̌%`|5De-tdb֯گ{'?ZZZҟgq1Q@~7~#{׿5ȬC^֔E1~Rggg߲?qzGooegϿ/Waя~4/BE>5x>6iN{Gl^ϟDymIw~?(q_<&va{kvKD-(Dzz\gggK~rׯ_Jf}UUUK%ve,0bF{wnb3vzweK/-x=Qhc-\mVWW侳g~ vmHn۬~gyh-w_n])0o}kPQd 'v?T@޽;{l(MV.1jC'vw ]^X会2_P^J3l),3c +`X)}mR;)||*X`l@,<֑V.\l5 x{6]#W~-fy%_gj;ݮm_Vl Z_O4{`%_/z_,aPܮb?%i nU*|mkY|+_Yv{|=n/Pbn)uɟUYknv>3fskz6`SED?3`(XR!kbAo$v^&?)"`Cpv8]Dʪ/b}Y^A;~#>9 NJzJ^x8X&sy3X@`\1>|8MNN}\S+XLϟfnܸ0?.]*F+h(W'NH}}} Py̙3Y9;wL===YA*U/^\<*T__tl]# `)X` MgΜ`)X~?}=}coӟ`:w2|O2\M&''Y\RoooW-X5SQ|_RssdhOgggNSSSƌ_7 ͛7E/lڵk%b1,3]>Lnٳc#>_'Ν{v3XKbM2TWW`jm /}^,PV7ndk:e||UQN8,P6ǧm48x|Μ9XsӓbܹFGGsdUUUl7Ab` mPP!T&w3ϼj` z=Kg?], (nK_J~evgofYf@RKRK, P,@R,@Rkcsԩޞ]๶6:t(]|c:qGf)MX> 022vUixxxq|څ+W [O>Ycg/|[b:{v6rvƅ%,^V ;{FڳWu#} [`-,,ӧOg %v!2V>Gǯ/D[ [`m۶-%Srtvv455mu3+Z.܊q͓}ˍ7 ͛7E7ekM6T8XuV+ާ`O=Z/n~7}sl^:x`:|6tƍl Vb^J(X_/ /(X3 ?YΜ9!ܹsgvjy˙KP,@RK,K, P,@R,@RkIoߞ]&.\,qٜbVO*`u'&&k .,,ںIw^vB3X] ?&ٳ `d6R\ݻdaАz{{TvK%`رcK:UX䧳3MOOlcƯƛ`gH׮][_iV銅fv WÇgenn.)X@V/]ĉO*`t‚Eŋ˞gtt4;VUUUv9:p3 (X (X `)X`)X` (X ` {.qSSSoߞ=^5QBk*X-Xi^XXHuU~`^vccF6 566KOVE*9U‚ٙT1WcccccccM]Yr T8 ` cZ377߷%k, xY|GF2e eGEݭ`Wʝ۪`f̪Jn]΃(X&ϧk'Л>h(X zа;{> ```)X(X(X   ```)X^/}i駗lKRK, P>ЌdI۷o.uj^cW䎂TLʿBHk~l2`z͏UD&''>6 VАz{{TvK%`333Y*ZrٙT1WcccccccM]Yk׮mccV,7w8A`k0ocR]]w(S.;>>3>>^v&*zaĉO J*}ǎfȪJnDG(BgrK, PKRQ (X `۩;m߾}mmmԩS `5=X+\p!;](XkL\d'/X8'(XkLuuuV O o(X%wެ\|9+XQΟ?3+XƼK%/a 8+XUo|=%¸0jb+6s=z4]zccv,.r.w_%/|!;Ace? Ɂ(H i`` }`^Ttfv.m+,V9Lijj*ۘfW`]|M166666Sw.=믯kƲK*Vr }XLTg%RM[D1S:щKY566x_%7|0]X[`Es(7kohh(;:0HJ9e|}Z`ܽ{k6eׯ_Ђ֒ݝΞ=`[`EÇŅ`]r%ݻw EUN~:;;ݔSSSƌ_okbrѺ/9Vcǎ`J3XZuƍsϥ,9={p%+ekkkČZMMlEQ/f'Wz=\q}̪)X>0^{-ڵk ϋ=82}bmbb"ruĉק``[ittt`;UaxY__Elu4 >+v^v͙kɝP(՞\Tb/oy, 3<-&߬QMu(X (X `)X`(X `4iǎkNR:qѣGʝI^t*v ^ :4<<8>ydQE~ VKKKY_z5555)X󄆆ۛjkk<6vޖ+V9vSNMMe3~56666666+?1[+.:]k=, V,UMM͚f,@*t]]]4;;d Vcc(Xn;p@f\i#"Vi(<]CGGGSGGGJ.AV3ie>co==;`9 ?aw}\Jw&ڷ_S,P#T~9r?, xb(ut\S,P_I²O]V,P߰KRp, P,@R, Pdzz:رcFFFKԤ۷gʼn:NG+X.X)D{^XXH䅢`p%)R]]` FlV+QBCCCMEUN~:;;ݔSSSƌ_+`5X VWW,CY~zYjtt<ۙ3_= ֭+XY!vZ:X `)΀]#qS?ˎ{w +enn.)X`mZQ 7QgyKZaĉOk~&JOۍ(BP6G.Z>}@r&w@Z^x9wM?ܹmP,`o?DѱLnԳ~-Uq-?>Ξ]@RKP,@RK,K, P,@ tڱcGuG R]} Pq5epp0 /O p`(R/^\<#UUU(B2 3 (X (X `)X`)X` (X 7`)XK'.SZGtLK.S`m(X.X---ifffq|Դ悵Q-]jkk2,-`UWWgRooo_(X.XfTUQv-ϣ`[` %{Yc<  VKKKY_z5555ky vnVص<l邵m۶UݶcW9x+{ak3X"""""wDjkkKKN566ky-]#rwww/w{J#"""R1kW<VafZ) ,QDDDD,KDDDD,K6C^}մgϞT]]Rooӎ;l(߳###1jjj۳S ESR{{{+:t(]|Sd7Hijj*.4߳H9@jmmdSgC'a׮]6%=N?SdgsYQ&vݸqC-LNNf3"=Ov%<-N lXjnnK6{6#.ruM?yK{?=Ck͛7E,!kd+gc!q,lG%<.\HwuW:|6[,ٔqV޳n#cVB& l+i޽*566fWU!;=[=+w{̙3فqΝ;SOOO,KDDDD,KDDDDQDDDDDQDDDD,QDDDD,KDDDD,KDDDD9{l:p@M555iǎgYsl۶-#"`HѣY1zꩧ͛7ӻロ^x5&KD,2::Ǐ/#UWWg3\GI333KU\^z饴woߞ{o/?99ߟgwNUUUKFa W_}uYxbjkk˞+~#%'|2ҥK" Ƨ%+&qlԩSm%'?Qⶇz(lݝl|.511̊YmQwh\{뭷 KDdc=D/W۳._u1\i/JŞ+Qr3Yח}9s&?E,`lPC+MWXWlaq gS5m:J}HnƱ[XKDdܼlv(T咛 HoFZXXXU+;\yڈill^ǵkײ窯/`ܺ /YT JNa)XpZbimm7K>wna%v9EX,qtdn WQDDnmr#|v[_Z%EܹsJMn6;mmq_D]p!+^>e#;vj}Epɮ8PD,[{.[p[[GőQ"q_e&WSSӒ]wXc]ӧӮ]獵RW\ɞ#}B>7'Q" H%WY'Ofo(X""[?_O~YlTbp(X""[6qXS;K{N5^x='UKDDDD,KDDDDKDDDDQDDDD,QD>%%",X""  ?6QKćxoxo(X"CT7D,!*"`T ŭz+=ci&߿? m۶mCiǎ9ݔSZXXm122:::ѣի %"`54Bx488^ YHnzײ>DAYO]K JG?Jn[8p MLLd%^@jmmUD, Vuuu^*?9^yX~t=,W_~Ԑ)Zg>|3;6 %"wxjooOO>d:r9O=^J>bZV}Ν;˗sԩ[VcS"299j)X" +fTC//ّC+Wd566Fȭ*,?q?^}U[b/ZfhnNz[ghKDP3*Χ'm$-TẨR\p!ydv[$NX(5)m ]S?lm1>>^rJQD.XD{CD!" QKD! %"""R1ܤV0飸IENDB`libjfreechart-java-1.0.13.orig/docfiles/StackedAreaRendererSample.png0000644000175000017500000004230211173030414025445 0ustar vincentvincentPNG  IHDRXr5DIDATx lSzǯ4M4MӤii&]M4MӤi)B UծSt+$vB;?UP> -J@J|B % ɅQ |&MHx^gq۱}}~9c?>/ BgB! !BB!B!F8gPuuuɬYoo%''Gd߾}{GCTk/,,#be͚5?XX9W/# 0tܹsyyed,]T~~ox [Pʥ# 5#3Z1`!`!(݈d+АN|gf 7|zPG~G2i… f:084_~)+n2BBU4ϕ+WJR +//O?hm&_&GSww??i&?x#ұcL>>??HuuH-\ԣcwt*o"9|zPW=4a^5y_|& ]Yݻwi˿˨璘On}9}xFhBB K&<_پ}{Tƛ:Wcc###L7Eп' 6Y/@?O?tBScICk0r_3;7oNzƫGr,,"7j .(X JA"Tc~t#$1lųgʤI:=ߛ=zt5{_HI4!G^= Sc]M8\LFNxa1>b[PRT!˚]3`EJdcu'~{*)茶_ ޻wc_Fףv'xbJ41G^=uVlڴiĈb+d4c9GZxwc`!`!v?H s=s/39??q7 ??i$'g9|z0TSwc]M8޾}_~&Lx> ! K/_܌~'"-F%QGBXS6񎊌Zz5E7Mњi3MZ;v$ XɌ! ! ![IGNFkSLɄk#Sm0#GV+6ZusG% WdDs梣9|p}LF^o[D+ `!`!d/7Bp+ؚEoDjĦK_שub=Odd5qk/'տۿxӧ'#ǫsu_x?xFtzJ6իQcOF)BBIXW؅+DCA )͑AWjPۄ^DSGF{n7QիC=T>%n9^ӥ &xWX,+F?{-nBBISd]^)mc~-_~B}/^<>}.mڸqz*1z xTx?iXJ3K GY D^oeEX%M:%#*ACWjN jgDJGK4ssꄒ\KhgΜ1u=ס:^Lyt+ȐKV}O tZNG;먙k~}O?4}"DJ}N+g2ՂC[}ȓN_ O^F[B!`!BX!BB!B!,B! !BX!BB!B!,B! !BB!Bs.**Yfa1'l`J>S1=g c1`a10c `Xc11c c1`a1Xcx-ӧOq_ooԩS}>\t c15rrr^ZZZMMM2sL c1V<)S ɓ,1XVssΝ;իo>YdIT 9\f걳 emٶރ{ׇbcv%>ضvBUQQ~cݼy,qX/J\K]tנ` ٳۛ7o`a[j&~gנKZZ `[Q1o:Iܷ* xdg ` -N},q&X k/+Jfv jBbQ1d>ZF i f0E'w1oxFNnoN` ֫F kt6,1ei1!ۯ}X1?Hq;7S0NC{JUL`u, cT+MVl<3Ja ;څ4.pb3+3 `Xc'Y.B|x1vu] ~(u,q++1/:1Vs XA `Xlsu.0Yb-Y`,}_THh݀, chtᥤ514-0`a3tbmJJR:ڇX1뺂s.IXɱ.Mb gw~S|<:1m{]Az#/,=o,[7.q, cl#7Z4. y#1ӧ?rs$ԩS,q*kㄗNELcgVNNΰuy礫,q]>p`u^@lcOF֊+)BqʭXW+U'?!13fȚ6mT`0Io[ Vj{)qpM4Ir}`0BWuu4HofmCɪKLο/nsm,+AOGg>"Nx;++\ ZSLa cW+%x-h #Xоf>ffΜ)}}}#{,ki$M3t0FUVX"pX7N;MCdիW"wTغw1N#,g^)]>`:co:)j+YZJg|/0`a'u׍ r`,ແ, cf3Ko1uԍd,\wX8p`917KĚ`,gzٹe|w0`aG.$I֫La GXRwbP=֮]|0`aCĘ(XR:k3) `X;;?) 'U b) `X0' \JH3/ `X;d/>g0v9)JNF2HPfZ}]c։\Xzk#9 `Xӝ XAK` 8Owv J`+UкXٝ}Aς%S  +Ϭ`XtgdNXq{)+ к,3~*]`XzE|?, 83ZRX,`Xmgd `X`%XX2}Q{n0RARTlX N!GSggTVVXgc6u"XV^r~ ]+sTOOx<}6qzuI]X,`e4` HAA `! 9\fQG-lm]GFq;6ܮ^cRrku;hǿ29wܘ#\`a9Wn:tV[G }ŵ_J^ސ.ZwnW,`5u`e`fW`al??4ڕVTt@Wrso?ʋܼK|GWJ񥇯s0`[wʼx~`alzTN,B)(:*`EU'e>gw `P\`X㤍Ni2J @V`VNVgoHſI|,~e`Kvs~ۦai@ ckG,Hj#P'ViOnM9;)o#5R|/teZ1ƣN{ÃyR0%"=wU<,ޑo_eo8XƌN}bjG+F\~hJ%`=},z`%1.X,)FDWQuEs;%xp]ciL,3_*{`Xgw2Sz z d"b hGVF, ld5fOH+xrYT#`[=KqϕR:,`Xg+u'y\Txб,HmZׁz)+\V nwr,3oKJMXz=)_jtZ1Tf,y`s,myyLKs>,'X?*3YNlVW}dn*Rۨp,c(˾[S)UqGmG!kg~He\\گs'`a󵬉KZf) { R XӋ&ֽJW֗ofM\\/1(r~n>}Ȕ)Sdڴi2|=d>MU,/cU\=T ;\^Wr}ihh`9T嚤TV՞'5!{TȲ2.uxO'O۶ʫg_5~,],Imi~__mg-`_ތF pa^SX,F*k^&k'*;;|!l6~h;m2wm?mEu, H*X)x?sk`EqG,Z 5C,+[+xr X`w/6 ?Vek!{d{ tҫJj%.S=E'𦣛ZLƔ@bȚ= ,, \;nek,+{9Wuw-, }}:rJ?'5AARLs&|OCx1Z&u+vjƍyFYb5o(AmtS.^tr `XIIץY X: Bmz00\˓^1c_ԥo,+І'N JfR}f"-3RXSN}d0Xj3iCo7o.quKyަszڡZKAvdL ?]ݔGRSs}Ķަ{[&AKomMl5ESy'O`E^r-WV`4}/SFJŨ1\W?@լ,7-#XK߼t%- `XVVٙQO^޸g¹Jaw)[q `EPF#KFQ3X1՜s취.`YXyR8 `=m۞mk^`l2aڴir0*B]X;;`9|o `XN,s漭"Q <<}^WnEu,˂,X1fwi JGRԢRUʥ꣭fD\X֑1aNwK[˨,˩yȘ'N JWR/`\եl_W&%S6k[`XN,ӓh'`3:ri)vȸt`*>XVbttom`Y1MXVvBV:Wj]˥d7eǴ `9 7 `XV$u;(*]Κd)BK։bnd`XN,n'N 2M\~/kXxdɌ`+ϬoeE\j_z^Xz J.$ڸt4`)(HM4 Jv/]11`|:qXz2k(soiKGӥix'k֬R `X uK*7.GťKTO>9sf,}`XV=,IaYZ'tr*ѕR#рW`P̴!o, lW%t,%u]RZ/Ł+KG֮] d͛7*77+UWlY`XvK*+,ˎI1`٨MА,9s={x X$|, `ia7胕"|gR,Љ,VS:RUSS#mmmÅĽ6)/u11`!.UK, ›>RWW7*B+6Xy}o'N ,`ݹsGv!^wD^6o,V~qm,{^ nX`ewԖ-[r mb;I\XVvN`XVF/|1ygY*'6Xx+ 7oGL25뾩5,ˊԞWeW, ݻ'{ZӅVm,Dz^X`B E#"LwsL,]WpAς^ o_J,˖}bZ[[S״:uK.e4`7j3~Q] Jw\' ,bItQOV2,V2z^X`eUҔ)SQLd/}`XN,ՀnX`XPssΝ;իo>YdIV*,G_ `X8R***2POz,m B/ImT]2Vln~Z7Nm5Yݮ^cvwkyx\Yw0r, yCyRz{Z`X=g>e ,+ qruړ`X?NJk.(, x*]!S/ J`Uqjn5O,+Rt_|꫗W0WZ`%\.Z)]$2 fKLE܂ :QZS( `|ZJt,+KR{OfGrlqʚyXeK ͕h-kU8P,7D-\'XVڕKuK}P"p`XNW6$4VT|8f: 2@|h6 !G6CR,˂W떹R{.B*þ IdeѩU P}W4'#:`\Ν{x ԩSa)vWXG7j 2|pٛ -5`XYXW\{NϘXF-k̓`ʄ , t_&u JVX!LƳ/]0JA<< 2dtj]5> hƌMfd``_o.F^x^#XM2}`EѤI]aF.x][֤E۾^]mv`¥5eF'wB#GK]1Pqx`,eq%S`1C͜9SFcXLdzԒyh'% O1`Xǥ.5wZ;DI;XFUVXIJd%u˕UGr,Y| (.ˋSߕ>`9իMN *lݻwJr"s{)>;3WR2`XP1zCp){# N&2]'Qg`y$3`XKS[mW?`XeDr JO$pր`:u j],+uqYd*, 2"|)eg& >YWm , -. \7GVdd`XVF%2ϒ OBWz+=~*ۦ, 2"]ޑ.e5w) , ,+_žcIB`X`XYXZ+*u/!X`X` [ru`X`XV^4vȉ5`X%`Xey<nV'wrD`X%`XH3wˑ7nK ,+..e9HdE\X`Xx֐H]y|*)Y&s HdE\X`XL/;+~xIdE\X`Xݷl4ϝM",, f IevsJ``XVDF"K,+\]Ra\}$2E\`XKyzV\pWHdqI\X`P3uV $2$., qiQ蒏QrDwtDF\`XqN)P}W4DF"#%`XVS9\fkHd$2Ⓒ,р]BS`*YH"#ȈK,+R^/S_\sHd$2Ⓒ, t1RsHd$2Ⓒ$.,+3LYy~Ke3ODF\`mE"#ȈK,DF"#%`XE"#%q `XE"#%q `XE"#ȈK, "ȈKⒸ, "ȈKⒸ$&, "Hd%q `XE"#ĈKⒸ, "ȈKⒸ, "Hd%q `XVT=x@V\)7Hd$2qI\X6n(7onll+VX$2$., JTyyy7+3fHd$2qI\XNȔa}DF"#.K PNNNL"rI?l6lmmM^qB!ղ=`HgyO!BVڴir0$B!`%x`E*6 c18Qg`!B1B!`!B! !BB!B!e>|Xy쳎ng~8.c9W\{N7gBWKKR@9s&)]ܹseI4±c1ql޾}'XaŊJވbw^G Wʤ%Dߝ;wXUGGqѼm۶)C]!|Q'?kwf̘a Kt:*<a/c:___oիo>Yd Ś=:$Y]˱M2 7npq(++36|?FJ͛0iҤXFxbstwC@]7o"Xt_g_Ľ{LM@vVkL0tjiAҋV5cgϞ޼y)+"j?Z*[H<ߏp O<:{̱5ZNez+jǏ˓O>9|nܸq d֖V X׿ε@kӿW*\\R֮](uuu ѮdkmfK&T#4 `9H)D!gyAxp4h}]F;I㏛^MNn8 :۷o7z^>1rBL^먮–N;89ĉϡ ZZ,jB!& !BB!B!,B!`!BX!BB!B!,B! !BX!BB!B!`!w^z2uT2eL>]|>999!`!0ڰaܻwOS8Q }===ÿ:pP\P > ɓ'GӼy:ڽ{^d >BBY X: '4t@ t/aqG&?fרmߪW 0: BB%MCUH9sܿ?& Mٍ67<%Tx,J6o<&*\+V0FH-8*\.իWG}N SѦI pm]]}z6s,QǏ7ڹsyMM)@Q&/u:/UGӕ+WFLMՅ! !R;vPm^eW) ?Pa5k3fSi>[^Ҷmg5ϫR.]2^@A i\DU_! !`id<9X!VS/!]'Y:.BY+m>5U.:5^ɒ>NOjSUB!,B! !BB!BB!B!`!B! !BB%eϰ BYX!`!H|! !DrG|! !;3@X!;BB2ϝ;w\RN?r`OHy,[LM&SL"ٴiӈtwwc1vϗ?ƿx$SJ0 ! !` X@@6n(ߗȱc}! ;5^ r X_XX!klwFw#uuuQ<&"`$vG]7zd;XeҤIҹsg9sR5ofăR.]ݯ??۷o7UWSN_8f֬Y|4\o, _Q 9wԩ&ō7رҮ]; z[X`ƼCKeʔ)RVVVwNw㛣s;)vNO覛nj/v~uy4L@`fŖ~<0-S[11ଈTC\V1ycVǴ]Xy HN'G~q7u "$\7wX$]*?`•>0ԋyѝwcS(~_==b~Ͻ" ;׿/9^:Ds@ ~dgg^YƔ`jf؝Wcݮʕ+AchK)sٹsgt!"$}:t坡v|tQ`ǏG]l8# O`Ѩ닙?h~ vpe3D˿5V"IIc]F5t򲕝~} E :ڜHk;~ϏukYh~Xlt]"b&p-&iHGO?XA1n},5+cX3SSvNBC8R%|P;\2s''X/S믿>H|h1+tɓXA1n,CS >kټ& ԑ Էb1ꫯ69݀ ,s< J|͍>_#JsOb90)-hWեV~]x)\1TtyBPԉ0yt \+s}Lu<8K-1,Z:A_6m2 ЁO.׫&={loUV_ \AnӉ䮥kElh u"j;b^jsY^^vx+^=*hIEvKZ 'vT,`=W<^uBv$(p`ӣV"j;y+J]yszL;u<w:X,)AW !+zJP/WC%0ײ8Wun7?6N,`3pK) ]%^V>Q>]*J5ӃշT'+_`4xr{] wwşn#V wdj; 퐎7 -x&_ۚv Miu7,}Wr\`E!!B"BXB!B!`B!E!!B!BXB!B!`B!E!}7~ȑ#)(xDԩS2}t4ilٲEJ}]6mns{_Dv/ׯ:4~EQEyVV/䣏>={GQEQ `е0V~\,(XVyy6XVFJŚq(( `yX:lڴiMϮ[o%j+EQEQs:pq' ,sԄ((`;vLѣMPNOO7jpB9yu.o߾XEQ<,]O>ص &1cFCݫZKXEQ<,;O>-[tY((eͻEQEQX:9]߾F;WbYh(( `E 2´4͕ŋz,'b];B֬sd[7EQX=*/@VWW^xEQXvVr8]ee(XrG `QEQ `XnZ,( `,m]+EQE,X`k[oF֭zv#E5>%zk1.ܵXZ'k vs~,vL8}߮X6\virl~~cGewsE5Oת,< ;|m#@ `QTswܳOX `,VZ,]+EQtX `yk(X `ѵXE `, /UU*ƣoXՌUY:gcp{~X `9nGkE5cmT}" `,(X `QX `,E,ۥZ_>)`oڵSzケz~E`ڿ XRWW't`(:Xt`Xw^N,EQ `,/`>|Z,( `,i`KjjjӧOKqq̜9Sf̘aԱc,=$w( `,i`3X%%%t҆ۥ2o޼uA9tW,EQ `,RPP 'NhѣG9r 2$*`|iX,=嗟/G5nsa}@۷o`,EQX&MO>X??K˜ӧK0(XE,*` V`;XE,*i0w̧s bHQ `hdAUsX `s(VJ:X `,X `{WrXNuYA `QX `,͖NXX `ūƎJJJ~( `,GK:w6s( `,W z-X `xΝrM*BX `,RQ `QTԩ2qҮ]i߾Lt X `hj۶ҵ녬EQK&OV]]^#EEX `٭dѵ2>|t`,+SZ>[z@ڶmX `Q.lRhwX `,( `RzJP/zQTDw]|꫿X `QWYEƏX `QGmڔ&]wX `,( `RzzPK0޾`,(J `yX+멘Wo: `,EQ `,eN wMKXr'/۷oj2~+?lpL/`ڽ^(_|ѯفewNkGL+m땲.ٞz~E`ڿ XRWW'-2+P7O 0:XZ)J,:XE,'k޽ltE Jn`3Xr4>lt,ܬHweZ,X `ɲed„ !2uT9pԠ`X, OtX]+EQ `,[),,-[ӧZ|5+ʡCXVX1'===V555]!i@ ׵X:_}X8ebKkpB9y-`<};rlmkX,X `َ~Ռ3M>PR`5~̙>}o_H5h?[ky/2E,lԩSƤ^Y`5O:pm `QX+ zX `s(VL̴֥]^~`,ֻׁxkF*wг\?.I{z뭗et??)aOt^ݾH `,XڵZ_u?3+ҮY?p'3֭w `=ng^C `, ,t,wtXnZyXڵ'5X+rS յJN`kv`MOV `, ,7v"}]VnR_ X `,g`k XZ%ڵr#V̵X `,``k XZyXnZ XK̵X `,``=<#kκ[#v ݻ{ڨ}]ыzE/h=UΑdKޖ?7UiV `,,'bXN~ $=v|f9ze >ԧ,X `,X `,X `,VUQQb\ҫX `,\?=}X `,u ]}X `, ,7tX `,\,tX `,,uX `, ,7v~پ}TWWKUU[g=,wx Xsߛ)` +)`{X>OY+R7j`vuRYYI,:Xt`X۩Zjݺ[`%)BX։ߟ X6V `,Xֲed„ !2uT9pӧOKqq̜9Sf̘aԱc,=$wX `yXeSZ˗/~uXɽ_Į XnZ, c,3zE&??_=h֠AVeZYۺVVLiӾM\zjJڴk#y P{Ν,ɓ'˶mیԗ_~iS{%KW";w.XVƮUe+b22?MX `YC7޸`,ȔK5蕃2 _+k XnZa V `sgcrqֿk XnZ57Ut3Zeu8ji׮oF&M`9X}_*|K;W9"Sms `8Oӵ-39>?z:+b*X۷O4*kϏ[޸E}ՂX˭̼X*+o3 5`\lZ諌3cX `|',[7Ws镃7dܸrx߄ߵ2 `E^85r+]Fb%w2wVrVX `, ֵX `%/uVڹ3Sڷo>ޡp睗Wk[R,XV `V Y3@{S= ۥZ_ '8XVZk5ְaVYYnXV+2̷o;R[p[z+5cv`m}|~"WסekEMq>ks[79exgΜ9ώ;$77ڻw/+X+zp烎溽>`EVPF;W˗/ӧO7&--ͱ:|ѵX `,,+== O?T222"~⬠\̙3ȑ# ,=$wX)n{rP9X_93b>}8pbk۶m2j(NRXX([l1^{Mƌl`@&L`yWz͛z[]-?[Z ɓ'mKY۷uX `Ww;,\KJdu:XaԢ9 %VQQQ͘1S , }uۙ,p`-w죒(Q`:=hwBŋ ;v,<-+Y`,ZX+z~ѵ `UתjQ`<ӵd< `%XotmԵXI|p޼yk׮sBuW*eѢE `,bҹVXqK}% `%!=dh:`2c8iDUX-_?gZϊ[?ZXZղvhY=8֭ Z X}ʟV+IewTK!X`.)}_Yf3WZ`_?w@js殮5 HXI,믿V ;S/Oӵ-39>?^Vv]5k;V2חHKӿT}ƣ%X$lX&t;S/ɯ[,wt 9,cS+#CK;WpK.,+k,7uX[h`,k ,uX-Hk_E(XI0]+7G}l=?w-Y`kX `yXV`=9Bʓrs* Z `,N,Rɮ$+ ,U?7öv4IO^ d}bՎ=ʮ͖: }f] 4==r&lu6&!)ݖ7NjDZz> jU򳒟,BEbPHj `,XVמ^fXҫW/Ylhff|WpBjҵX +^!q X+\ԠJӷo_} `, ѵX ̝ݛUI>F_UWW:ukƿmf6X `%)tV/*,:XAkFgݺu4EEE_5 `YkM6 `yXqգbpĮJN`C.z!`]+_M?aS{em]`,gݶX]$7wXQ*$=tbY+X+ٖiXܵJXWsNC=$7onV2ΕM+`,~~!ʼhNN̟?U+:`v,XvDx~˗_~)k֬F >\.]*Gu /۷o72~+68a|=@ZmlP=SZ`5w{ְaVzY:X+tUGemLrWL2f̘heZ-*+++m/hK,:X `֡y?Yl=?+ Xt;X6VNY\Í o S/[-߼U `,VԩS~z2 :KO;v,c,_X4##÷c)3gΔ#G+M<`XVrX `9X۷oX=Q `$A..-[7ַy\c?2o޼uA9tor`,*`]ye;Yڵ1N\*Xv|XMyx͙`,w^Em6l`AV矟evt /4 Xպٲ~}Wr)*$YYhUr |aX+xbDI`a%w ,mV۶`VX+i+D7Z ^;[ XVLiӾMȏM15X9]CN׏岁pWkϓF9*V `%C-dAUsXVz^*f_ V܀jnu 2'a\Wkg8yWdҤkV$`Z,t/X^ `%a0@X<)m;7~xt5ݕ\IzjPudXaV `%$|g8`驙=>` `sk}n& c%w/-ӐkX#l `xnsh;U~wol}~յ_m`,<` w:z-J9X$,eu2`,X `E]uƕ{X `,eX+49/TXX+;UV ̝ҦMFȅvVJ%dX `,VE}k2eFR]]6KX `,t>Њ9ZX `dke.eXnX`2X `,V+ke:X `%BuVlO/ X `, XV+^s,X+^ڰe?Wj8>ɎصXuřrqann1KsX `,/`sOc~m=?+2 nUcrt0N=X `,X`,X `,X `, X۷KuuTUU|ۃ?)`M)`-XS;=OkذrO+,`,#c XRWW't`E `%2wfJml Y{!X `V!m| `:|ѵX `,a8D,Kύի}A+$wX `yXdSVuA9tW,X+yN&X:ߪ&ib WrXpr>Ӎ.\('O,go>T+n);Sո23wJ6#]7u=`-&)-ݻXAjSr}^;cI `9 %VQQQ͘1̙>} Fؠ_+)=4LVpxZ9NVD)u׍ձd*U(:,ZXӧO6 Vrk5&;S&>~Ucg?+q)B'`URl4};,-$C,OL]+z#vgW V1s/h `ֳ%%}iu٭eתU[J%UXX([l1:WbYhX+HJCawbrVN~0`v&*xV,)c.BkrVs.`^L $--t,^7{X%$%Ո;Se$:a߽uWF:%h~svVS~?c҉zZ[ߺ`,7{XgZMy`Y0w}K۶,?V\G-`Y.]HX+t x9,g,[Kz]+Hz&^Օ`碋|zsߵNk6`_4߱|%"WZ&9w s:OLV(}j<7޸ЇTc"7y7U~ vBNY `,XɝVK;z usLUVrX `, 7VNQXukxg l,⿭땞 `,nz5noT2urs,XB+^ +H `,Keӄ.ҵ.4`,V4&=Я*Btr;.l`:9X[k\X+T\dg^qI]+X`%C+/Y=`,?uDKk솇$K(+]+2RS)dUJ8`,e=:XtxXkҮnXQN,r]+s,X b`,/+kX `%XYYry|J:XS յX5ڿl߾]<3ǾP_;.)+e|2aB`.Ok<acV|V3Wj3+]p]+WkoZMϲ|6j`J]]TVV&[d^O(e]VvWjӦqzPԥO`jG ux$%?_W}߉صdkaI(vWr;{jtʬr#> 8%:%d,eTNo$l3G<32,ZURX.ÇU2{dAF/T ,m~X]RV_4 rtsh^wi)..3gʌ3:vX\ɓ3H `,7Fs+5 yY$ Z%55)))K6.--yE ʡC\qav)gS|,F`''6̻֭BfJB`uMyCM$kZ=8ϑ#GdȐ!QK[ԸfDLCu:X;N6&AV'V҉v?e_ʋR'kXMN X }%t!wq4R^7BX`my eO6J`,5jr`,OQ `,jn`[{<GkX `5'FX*~W&5 ٵX `,Xc{ `dB+B `,j.`Q*z:Xbycy6„ dڨm~~5eV `,Vs++k VVKy乼@T`95콆X `,VrXay 䱼M9X `, mԵX `,Jh fX^` {VϛvX `,j֤WKZ=746X `,"od-os `VjjjX `,KVK ,'8rm`,e9`,,s\ `,h`wuW1X `y X]+j.`\z9X `,+T `, X}G,`\R?Ȋ+xVn=32eG<V^}1OłowpX˭1b~]-~vuuTUUxG XeeevZyW`y/:^wO<[.Fq5f Vt`,k#-1rソex NzX˄u~V_:sj9`017kĈR^Xk͚5F `yX殕X+ާ!ʭ&ÆdV,=wIz 7WH~>FV(`5Z,D+(εZzc" N9h̺㎆ۏ=ٷ3XMkjy`5>`,VVr2 /!={J W/#`5VX9X `E t( .'Oγ v:J& 9{Y ]+}5%7W2ҌSl`s1uuu|lƌ eȑC+,SO5cRVu}=uZW2DRYpl>?֚ܘҘD3~[ybddz橶hc1Y![_eIc.oE0dX1?n4Z}֓7'̍>!X[ylo۾[ny֍Q_|q 6O ˟?m4ٳg岫_qQYg[7MZɪUֵT,It9s=go'gwϞƳxDV]Nm{w瞘o6m>ܧtl>Ǎfz[7[c>AXV>f>gĉ2` KJ*էꨏ+Kogu`ɡ5{ `~qʼbӫ xk۪'}\s9 `PlbtWŲh"뮓?ImثX `?_$ZryXY\"Ou,Ό ⹏X `E]V@$77W/^lPdݙArxeFVRxv{ΉFZX׮]6@ַ\,+7{-` rzJd,e|'kKQNKgeI7 5](qc+5e`|a۟ Ht?O"&zXo%}JO#=}g;7Ϳ_{ v.rsos*f?-3t' |SdCr6vj߿T~?PzMތkKI]. >GJo|%G5X?vGo!;vد>8XkU_[xϾVmE~9w| =ְyѲ!7}o98l =zիs wޜ9xvyNaak(s6;M:۩@f:uJv)7n[dXN*;X:T q;n/kok^C_/q^VozfXk23XyR{mK/m`)~7-XpX2ayw2,Z{tXڵx ,=pooǵ rv;]+/+~ ,=eכǭ27eZXtT^9o|Cu`ah`5Gת1Hf~vʳ:}̙3}F;v,&`/ZV۶mۓF`v?hv:nV[kj`[/~5F`F`ZXͽ{suVX!wqvE&JJJdҥ KKKe޼yQKVv}=.]+kuABu+tv<VkV`E¯ۀe|3x\[o~:xP]+VO<1GVhߎ#GdnKߕ'-)ҋMZ?rdVnk:`Yįeu`+LsH]+V֭Gq5۸O.SLslaܻV>;ygWu*k;#vM+իU]w9XvkkpGNӁol[U;YZ5֠AVstRTfƭkY`Z??K˟J.<(S>(>]䑣QdQ=yd6?_wx&xܹݞ2[RPjx~&O,}}Y[ܑ?Xrssʸg춝Nʖ-[uEkɘ1c<3&-Ed^^9~lڴi-9t :x3[̩31)RV\ٰO?^׎矗[>~,X@^yEKgڵ?- GZbL\x WlwF`ϼydƍi:֯_1i7[a}B]D,Ұ~嗞h"yeLڕ[bqЭѝ?ݰ݅zp38yk3dYzFO?M>jaFvã`OBx ׎'-- 8>V`n՟sÆ 2j(W2&i\}'mu<&M2i3'VQQkǣ;iv=?/]_n`Eŋ]ԩS| ݹumPq7ƤkEA\B6& ۜaj3g4`/˩SӲn:`XE!(={vM4(]ntf̘!uuupe.*++eĈS̙#'Nh֭[eǵ{6tPIKKk|9aMpGI~~XYfɒ%K륗^2߳g!BѣG0 G66:\˖-3N D9 #o-_ܸ=w\۶m3n} ?~_cmٲi i>ř{aU__o@K?QB"Gi=ʼnbF>&L`w ` ŝ?3NwNEEE}Ӕx |B!,X:u8M`S~N?nsBz2eq[Ok!`BH2jԨ&!3w^{5嫯,)P) 49;fG'}:*Xƌc|O? SzZ=aՑ9\!$C!rI>Bό{キ*** ۽{w}7o6ӏc^k衇 e+̏]5sDcI]T!B"BXB!B!,B!E!!B!BX$7΢(cE""&`Θk,BBxM;cBiB! ! "ę;;—C"`+ ̙3Gz)2~xYd#555㪮^zY\Cvܘ/_.Ϣ?̙3ȑ#?yٲe2ag̔Sʁ"=۶<,L"%%%W_ӧe}-=+rژ e˖-Ϣ?k&cƌ+WyQp_ӿy--Qr7l F,*XAǏ+6I&'|qX``=~ kv!'O}ڵk[ XNŋe ,'?ϧN2>: =rژ}="G<Pp_ϧ~j\9`9ezJJ'}[M,r$XN3,qf_ѫsTtvQ4:Ԙ#ѥT,}_ɽz@ ,Cvܘ7olkhsyKc 7m`Eۀe3+W4&^`2sOƍkX(A(̚5 شiSO(^SG^kuyoX$! X3&4!vƄ^`ΘkEBxMΘ(o!B!4+|#UIENDB`libjfreechart-java-1.0.13.orig/docfiles/StackedBarRendererSample.png0000644000175000017500000004362511173030414025312 0ustar vincentvincentPNG  IHDRXr5G\IDATx xTq*Pjտ"ZChrJLJ@e  B"d+%n-KV)KLdF#Db hʋ@3^\!s?3LLoJf39眴B!RiW@!!B!B"B!F@jU}iBX@&L ݺuvI۶m .2eZs /!C(O>D'?%͛']tXuБk%##v|fטnos5я~Ԭeg߾}rz׾}{9~8"`RVҧOExΝeb6m|rn)}[oUeثW/3ٻwcP׿eyx4}>GeG{~8iڵi@w>OJ?iSLH걾󒶿3՝|Ghײ-/{୻ju^1[l޼ ^X4(`+p>}lڴ/l5|gÆ ~!>ݲ=~皏?v]"DwٷuرcR->:^F;}以x=Ze̙^݁xq?ё+btNm j ?d@7}oVE!(zn+ܹY)}lOM{MDLUv}_gGrާFkM;k>>ٜVO>[NTE!ug%X]8vtv=!}2j+bjdώ;ߚ~gA~uwt<^mUTP/Tb !4(qqqv7:E;#mjT+V9-^wɲ3U絵s?izx=/R}tѣG{ݧ;Rq\.~z]ZRӭu1M:ִ]}=U.;KO E!X-|ڵk.s8|@>= \GڧMu{Q7-h:=݃Iz|gA;Wm t{}NSe֭A`S]w=Q,BNנ&9y!Њ[u6yxФW ߣ.ZXqϺ.duui]&Y!aex%ֺ.V\FU\3.*.qe|euXqEQXEQX `U"ˊɊjѫ]-6;EȎ򷢿IAQz]o)ʑ7ޔ,(ʐ?LuCET/W^TˋW*}_theZUSVWtZSS:Sok~\giO[UbOQX7M~mO![1ȺX7_;_ϮӢӦӪӮE+?EQ `V$C'X( `,:XE,X `5`%|`ܮl:XkctE,E hEQX `,EQX `,EQ,EQ `,EQ `,EQX `,EQX `,EQX `,EQX `QX `QX `QE,(X`(X(4gΜKJjjg%rX `QjǏرc钙O;P],( ` -{||cǎIll,X `,Vusa?~zTT6XE ygeǎ^+={K~~g}]Xƍ}^Ys\oכ4tB&Mu[`قE(`E̙#{-!!AJJJ` :`,EQ߿_NZ i:"A `,(XU$99YT`ڷI zX:9Qe~ۿג^'\Zkmu@Wo4( `q&wZ&Zj)g;dBS/].") (剦LS_`QX-{/tk^NsXEQX `,GEQ `,?+̠XcJm{WUC(XQ}yڿ=%<"|jYG{,X `9_PM`.EQX `,Gib5߭Ex[kLWOEol tb-( `,8M]]<:Rrcck]9ծ};)&T: `QXɝ3SE,E hEQX `,EQX `,EQV;i=$,"zk#FtaNg-l,(X+,2Lι[F[l-riKv#׷V;8XE,.B\0{uju7LAN`,EQX+:7Z:Fv?\:ܡZ咛/a XE,"߈;x`9;ث^-WڱJ7,(Xe7K.{4RqY`c?z\Q `QVVh3=PupW;ZldP EQ `\`ݵ.vtXvp` 淃08;a$O8X(Z6`#e`jSd'y EQ `3,EQ,EQ `,EQ `,EQXtXE,XE>LO.QQQ9sF.]*X `,EQ #Gرc}钙鹮DX `QDW;w{_||?~sرc X(, &]1FGG݃"{7sw6Vv93{l)..|B76X{^X /:׹޼7I`EFFݻ N>-+W3f"""*=mlXlXނǯ岦h^l*$9E9h|PKQQ|T|X,)Ev۲h+ZgRK^hPc+E/{ꕢW*oOZQ«VTVyjuJ^U:mveezx}}]=s?NN=]a `Jկ_mX `P+84..[dui]1).nc]2E'yֺ `,8cǬ&`p:ر\X_k=BXMX}55U-[&N2EEEy=VwXd;qn,~/{^}O2wwܻWrʖw˫//fLX+cbV+ +MM\5: IX5z w555yUw%}Mfz5uXR2_5}]f%OmjfVN]sϫ_EOY.jH YcJH3=r͏X;j5xpr4XMmnR`͟??-9`gfϞ-Œo Y_.,6v8_xANW䭷D>@OEN4YV?NNN~$%j76X{^o̧iK;X&;F?a^V)fTl%&jzZBz}© +*,, YIX!}Q_~Mn  =؂řق,`-Xr 1'Xk1XCX `,Xl]wmN) }tEH{.l5]z)X `,D;MJ:I"##˗{l2XlX `,8;X `,X `,UE#EIvymۈn20;T_ `,X-Xaarw2jF-O"vX`,X ``i{X `,:XE`scdG[Zu>On~f|@`ُ=r[$X ` 7"C1XvXWvqXW`,X7K.{46`;| _6<<`,XE+z[^U;tT/s/9`,XwɰvrO=2|S3{:Xwew";P`puӔ֙, X'O4$::Z"""<X `,Հ t*`Xvt(k=a喹xuN`E,NXE+_a5>nX `CYdX `,UWaq+&ci5(׿sHu,mڜkK(,X+TR\[`XN<_G<,_F[}lKK⋯X `,V`5lZnDF_[ng,_9-X `,B,r5,\.j>|tpsw4cVDE@X `,N4 W_=ւѣ{ɵw6KX `,U_W=֭[c.]*/0V1U=`=r=]zOګҩSX `,nEs%33s];P]V׮eܠ_X `5]IrI/`[+vdرcV XHXX>_ݧewzm͕nbX `5b`H!aaҺ]kis^6 ;4̴qr#כ^VnvStZՀR)[-X/ZxىtV4e2p`^7\ys4pg X `5n`E9wrkN(-k߃={ݏ~uz`mܸ: =^P^pj 1 CiG.sڞc_Z9Qr55`_7$߿deey.>}ܞ+˖-x.`ѿ-X-Xgѹ1iĕyJ ,ϗ[" $!>AY uhX `,ҡ{I\5O{XwxïX ,43իf+##tΣiX `ܛKL=iGG/ nurO.V''Њ,|K|uy X `f+$.\(| $sHQȱcѳ-#)lȳϺmffZ X `,X `,X `,j9g}Zy `,_3XlX `,X `VQV][ X `,E hX `,X `,X `t`eeeY TׯDEEY 9x̙3tRIMM|. `vX ` X `Kd4)lk!eKOOV>j+Q`,X5L߾}xk?nwJ+cւ X,X,ӧO.C2tFpX `,$""”~I=rfR\\,NY_V聵qko+zZBz}„S+*,, YIX!nm[̠)+[h`zXڶ,z->Һu;i\u؂,`51XzD&Z1kmX `Zj)Yy_YSH80ǚ ʭf)>}Ҥ}kXMX)VPP`N}fHa:MQX `U= = T,9X `5`mݺ՜A{Jĉ`+!LwҩSgrX `,uw'^uX `,V]l<{,X `G,X `Kog.]d(IN1Xݺ,X `q.UT z`vǔ,X `rW9 `,E hX `,X `,X `,`,*`,X `,X `,X]X `,X `5_`=_&N&Ȍ3ٓUᫍ򗯶KWɁRZZ*ť%$7䕯s,ItMؒM(ejdhydQ%cet8ScJd]\MŹ&xDS\2x$y5S\ &M%6kLq=bj+S%d4yiStO=aj i ,m~q\}=}}}}|4]ɩOkScO*Ng5Y3m\ݺ<^gy<3Y?N5}:;gX `,.ZէjKz>aaҮuk9MХi{KDNm+#Z,~N6a5:`X `,.ՠ-:Z񏽀.9#3q),XVZϞѱi##JkXۥO}Z r٧ljf=`,.VH' Un}2Vq"%痿r{J["X `,Uy@CyX `,?`\e[} `5~u] `p,`Xo';tr?R!W^) ` `,z۽\~N^Wǎ `b߿mgΜKJjj t\ `,Uy`ۀf{u=`,ā)gtj|*D Xfx?@Tβ}@s >s `沋XV;%1{X,\ `*[_HdNI 7HN Xy+**.ClXٳͮ|w'h+ڸqcuz``-sj~JWR`(VH~zkf,nc b b b [؂U[X `,V5`5ncXX `,U;`eddNy`p,X,jp8 grX `,X `,X `p,X, X `||rA۶^ۥOǎOۦ r٧X `,׿HrdxQj-\tX `,n_X `,Xu2-}X `,}8+>`,X `S:W/ձ#X `,1XzD!X `,%:w#OX X `,U4xN`_B";u2GoNoAJuX `,X`,.E,X,X `,X `,bX?XX `,X `,X `,bhX `,X `,X,\ `, `,XuX `,X `,X `U3gҥK%55\.bmӭuOvX,\ `, `Z&jv$~:f} `,:`,UDEEUe{X `,A"""u vfH[ b5{\f1ݚ[34dUIcIz5㒬Ϛlئ=*ldU^*{ۿUuݪ$պn^1]{}OGZk}Nko{O>)ھXgw{>ӣڶZv[y=h[nm,o_I׫jziןv֞1{*Iwt^_ߞh귿8}-y !BH聕`D7;` ͥB!v0jtl !B]jz,8fQEQEն!B؂E!!B"BXB!B!>@o߾2dYA-ҿvvhsʕc#-b2DO3f̐-lݺ|V駟}'溮^|&p糋{nsNӧOիe3Y"-E(3g,̙3Gl~kF4h{qW\)ϗz Zk_򋌌4kf4hI^6}N<)HJ:`@HiޯX$$]h~m۵k+'\tYbew\a@hyn^n/K/y*={< h:ivΙ4W90"!IMfg}kESVVY}CJF?3`߱cL81X-t֔Ri>kqj:u}:aDE3 ععP>ߌoowߔ)S< P]ļXhcU RRR"ף -X$Ǐ7qu?ZȀLI/;}nMLL,|zsݻln¨K-] Pg6۞oYHlϡvA_(faMtBB,,gUõ݅d0 !BXB!B!`B!E!!B!BXB!B!`B!,B!!B!HNN$''@"6lkDDD"EiIMM50Zbə3g߮1!`BM6-\}ӦM3eGѕ$}5[͛'Ǐ•l߾]Əo-=j[OqԩSm\ݚ@GXRg8qbCNTٱ^Z>S9}te ;.XCrkw}4_wQv֯_/F2c>l^9y*-]_NUғÇ XbKϝUWYvy˗!Gw?ܹ s5SW-d!Bm:>KN1^u}-='U%,B!!B!B"B!B!`B!,B!!B!mjՊuB!!!߄E!߄,Ba&`BD7!BD7!=*RXf8rԺCH]u@"C.'_}ZΜ9#{52ډUjlӜ,w6E?իeҤIu B﯋%VcfgK`5iX,B$t7+":`b ۷˂ <m~~~% {νkv.P1OfϞ=f O]1OnU[~EHnuЎqf 9|oСr côEǾ9|՞Vc;vĉ| Vcf{Wn+--X,Bѭ:G;xg[:`),,4hlٲ%djӼ|r5kgW[]1sYYҥ!f,;:vhN7s|ȱ2ͺN}W'g ξ`i\z=y=ckt+F1]֌csucvtަXF7yyyUnf2/EoӬ[ߚ1XX,Bj 6:.G 9v:FOLL(P9O?yk׮멮ئ9:[n5:(~^c!& ,B X: MXM"oB!t@0B!uQTs.B"BilqIENDB`libjfreechart-java-1.0.13.orig/docfiles/StackedXYAreaRenderer2Sample.png0000644000175000017500000004054011173030414026012 0ustar vincentvincentPNG  IHDRXr5A'IDATx lzTUUUUU*]UUUUUB̥B\]|  `K&& !Ǝ) B %p ! Lpy8zgwvwfHgg9?RV` vh`Kݭ.\/Rm*--M-_\utt`,ovv_VW51:aoo&NcfΜK.M!ًԏ OSuV{`?P4Tժϳ}ԑ#GTYYO~5-n H:V^)Ւ${M>G~ TUUMO{ߚpΝ;ǟgϞ c/_{?aÆIߕ'Hgs?>:`C"0Xѽ+2)qC$ɋx͛sVX1vIg3ss%gV`N^ߦ2E+Wұ H>?ؿ/АOWNFT 1`ie>āޏ郤/>idd$viw0X 0DZ1UbPPP??uIC ===牉S˿˄3pႮ1NZ^W^_ꛞ}٠C ?Gsd-?8P' /01ݙͰxEA& ?^/Bhh 3u?/n d_zĀ,]Tfiiװy#άVLy7id~9ђ2IT_NJ>}SLj5㭷FlBN2?>,t1Y?3-l-T?ShjjJX1 I;v58#3000>/!S+ /]~B='a=y|1E^h[E0?sTa3U=w/%fS=GNOWҟ,9V_O,tH OdE~6m4!GRrc`GGW-^zUM6-4Dp sM3`}&HI!iH,ÇA } 3TX| w5TwkuI^ Kk6~xփM|1`kl$1&V!i.,1HJepRTC3P+Cr9s161?Yf|XkxfK|8UQg ՃJz#5`~ hGXy>TY< 1gNimm z>I2};ȐxSBj,PW p$-N'|2_=VRsxTSn37#sqy:H%\59VeLb̵v2$nq*V[E`&#>Kh)Bx2?V Aq\ 8Inmm$C t|i 7\b5RI2(W"RE8\4 z_߭"u?J[&`0[LGN v_c;tID I-B]/CVC %LeP7NH Ul~`d0atNlrP &}~VPA[j礆0ZM2K]4dG%Ǔ`vg:st\MҞPg:gY$`c.<,p<זMGI`yX9q2σh6Xj"}_߭J"'!;*6c(ZTK~ -`j;i5X2UD6KJOI|C`@ VB@;}\!?bbP*@\4M%01쵥L,Z3.C{yqRё)ԎiYX |a2ߜ2Tk_Cyɢr/|H:v:Vۣn'; yR Ma4*`0’KUWnPc<1L hllב~Uvj-`ñf͚ ϕ s*`|Hw~ #ZTKc'V%0\bVNNyN $٬L EURWefuè!g#dLVj,Kѡ3`:<1>I 7pAf*4!1IgLB0>kyRY0E{ڀ P,?Rb6 |[NomE8e2 ]\h>oZB;V U\\222Tff*//W$BГ jT7W⫪ruűJJKKUWWliiQyyy,фT$i0VIXc M"LOO`` MqM.c"L$sKűJ FGGՁal }[ʠ`6_6l;}[Z; E?TwTX=e*1Iwޝt MhB5mAZߡK022ޗ/_~ђbxjЄ&xUS{IW9$Ι3VFjut~&jB!5k,,4 =DzNH80X CYYԣGt _ePU}}3zWjA V\ޮϜ9Si3%hkkS%%%jڴijj\EYMWO80XEX7D^TsGqO80XEșD%uuW1;I$I턞dj"v6,kTVg /Hd Eř”ܹ#ۇ`y[rvOjjjT/---(r`~Ô/˻H`RזU}Г ԕtNU14,L* 4O!5k,j64ȫ#ae-Ȃc؜9QOWVMW^#Lxq7 } Z^a(檾^544`9;lxzlJht:$X5XjkksdM6M͞=[#aCr˖Oi'Ĭ EXނ%}xӕJJb&?Sy`sd%댐;^^p%*RR|@m\|e#e_`aso\aIaj^u14N?3Ц+s0,,)ӸӒM7cUS+1VrşTK 񥦫8W/Fe?`aʙ.I&=jJdzU\*>z5]RW7}$W FBL $Xהn E-\T]Ѩ >?`J-2=}J̼k)mLQݼ3$! gݸK8C )^ ~9W2O}&ZXR2Nl۶I+aճ Xa<35X$X$ )<4hfnz.H^d:Z`Q`Z[ߧꂫ QemWE  䊻ŋ=a`AQ匎ˎjKL19M}&ZtԗݡQ>MW+oO+6h%&tˣg --gZ~ҿ>tsd`OS]U$5X}b^HD,EI uh$yya`ɒFr+UakʅE,,)`d0l|O:|X][ _ʂXnY&%sT2_wm=;k:{[&K```IrUQQJXjL'"ˎO0VFb9}gjRpTKdD]5{0 W,gyӎZZ9=*AQ5W̃ 弘+ c:]1J Rb&d)l8޷ަs:qHP1Vusϓ`1DZ떡AY /ǹ\6<˦s<\shsm:uvޘ W$5+Ó:GO@ Mǝhzz 4Ќ3"JH&V^u܏;c+oVԆ룝;-);CXA祹om;Ju%&FLδil3XoRk1W0*uX_u ڴ}B~yjn$eڷo\433S;::֭[cNSb-kTs ߉UYwab8A'A1W'xB]|y}v,yM&nxxozLNbRhҥhŽڕ++L9+2j׮]n=lh2~j |V]_o6Xҩ$\99+}󳟩 }2ۤÇk%X?hѢHN,Y*v+!t7R# 4 i%CxSW^5kVJ`=ۭa 00?R$5X.7XR~ݸce6XK'WbUCCCJ`54܉۱[s!,N Qp.s=^ H pv͞=[m߾="ln0nC+!tet'X$X1,1VPݦM&\E贙ܽT% a :.`ňGzKN4kƉ]\A!ԼWTD"w1SoZdɸъu" Ν;?1Z=Ig!.@ {pˋi-BC >KrBR%w.B.tZUH ::`ňuUQQ1]jdpppFnW T|tLB~{LreL(j0E ΃S?\A! IYJ `ɰ۩Slk2~s!pJJr@j}e6u'+5Xz+!pF"$w!缼l;n)o z=ד`a ǒAێBט+!L̝NS" ͛?5WH!bm@Fu,7`mJ+!$ł.Pő(^vt/6sEr!˛6``Kl jxx,~}-s!) w;:ry:QgΜ!{U|\- b Ol!rcjnnVO<`Q=[՗2:!II0X6@#ljjR3gδ`I8cƌIY}}InC%X=w3cI߷t*BΝ$Xn2Xmmm7>DeKʠ566̀:O`$B%%``͛7o}۶m:ɲfUPP~v6vnO>\A!M4 Vff!Cmn+B߬\I=[{7+XMWی`Cb w-_}BfgKǎ͠~ocR9v'XN:t贚;w$c%WA!0"J 5X.4Xj```B +)䫤ÀB1QﷶRh٣ ֕5X/ÂBkQW+|Z^};Gj: !Q1ދ@` Z JrEXٳa5X,oEq$WBb?z 卵|+|1WBme``m!ŋ\Q!nkh,j z U|k &Ţ+aܻ兜%b+!eH0X:zA+!b``ʪ,'W]8!&%%$X,w`}Р$W}UB]bQEWT [aA! , ;j*+oY\A!L4+f64|b)bQ!-hH :Р+ !:%zAj0XL"]ș+!N@`Qe;l Bk)@lo S͝;B) 5X \A!t:͟"``_s!3eh,Lf L94(3c .)``9)xwʅ\sB!t?ih `%kÆ!z.M K VzzqoݺU '%ڻl؅%b+!nf4@`kU]]X4,qFh 2(B/SO{픻pllLedd$6 $X`i>|J--B#GssvjjT}}I888UOa Bسa [ VccjnnnjjRuuuk6B;W8r,7ǷUNN:;gBh3?{e,7IC ce0WVʛՕJuy՟vS%O?fSay O鑿wJ+Tg[ݮvSzfl<>D=X?:zO^{l;vk_׶ VZZZDE3/jzK'ҥUsK&cP`%8f-B zgpzRM lm}3=,PXX&`eee`U$^'NE%UQ c|4_w9ГҚ˿v\]}ݰ!ɦ)8`HA+ M.״y*7wCd3{eCܟb%#`Q&hڿx#(fU`Ѓ)dW,,4yD-]c:(Cmmw$Xh ÒAW2 3Sa̔(^KWBC'1n9Q'1X$XѡMҡ0C{e#BSdW,jaM[|0R'= )V+  <wb>Hk/a)@3 G!kAUqǹԡ:aP  RDSK˙A& 7#; #~0X`)4tR{JiV~ø~TKN"M є*9PzR]Rdڎ =;#ΝP51X$Xѡ)t^ZPΨތMQbpG;k8E Ф3,.Q~4M}ƼW,,]D%rR+ٳcpJ1n!ޅBgXNLR`% ~:374|~&(S,'W)c&MQě?ʕ8j!;g sdz"B")e҉'=h=\Ѓ\Q+1X`A! ڵcō'f,,4 =hbCc(ܱ+ E Є4ߡ)\7%j0X$XhBz~QdWbB`:nz E&4MwhJ(|/Mc&MAbq.,,4 =hbCR_?P 5XBajU_HsUTt#f,,4 =hbCS)KhJ1X`1~&4FhBauI檬+&1X$XhBz~S}3gsW4Xg̘1ᶱ1U__jjjyR!&UIɠy`3y|IՑ` MA7O?`9fUPP~vɡ MhB+ zϬǭms[m0Xy|Iչ`y<7Y(MnmRե;Qk.d׶S8=^h#ȼ6J ̑zLU՞i#/Y6;qZhф%7Yڐwzirk;\R}AN;F$XhbP,/&Xno۷UVM(ts;jddD/_3ǒY[)\J![?7 VF9[ơ!5k,,/TMm&ERpc+/WƏP?nm>}[(s[m0X{ZWk Fvt3 mf6 򸱝qkn=z$sNW>k}[(F̃R+7MfϞ;jo fv t=nm#H~0w̙qqpN?/Nqk̃d`0X, ``0X""^luӦMA%T~y\ Z[[)J}}0X  empx r֭['=G֭u###Ń޽` YXULӧvGGޖCaժU1Gp[ooÇ"bf̘_O2X̖Ǐ כ>}ڸqz  I/_233Ձߢ"5<<9NҦb\1=l(m3g뵴Z 8 2Jvv x17R%)ҽ{mjڴiv?1h Vqqwd[, 1TV @mmmz[d;h^굤\=: e"1Xf0XCb^$E2D(z662,(Xd޾|c\mvҷd$C%d 8W֦رczĉz[n \pA?G!CfT<>PMg˜Ae1'񸼼SMM`8`mۦTvR>FG'=gQUccc… dBHaA4.Y3ڵK-Y Otuk{(Vk׮UUUUjppp=x౩ߞ9Nz1|:#1ZdGk,0XsBI/..V۶mSݓL<;v>~Z~8$393gT}g(њgϞթ )W 6|IZ ۿNM͛7}YYYjhhhb(1=?z#(њO8-ZD , ֖-F}}גE0l{ŋUYYz'ԡCl3X1Hv۷UV/b`b**B^SU e6=۷UffmI,C]31X`0X/TUUp}&sF-P$EHvSSM S'#3#uJR$.I]ˢdi Za``,U}K-82S1Z89?~I|N>Xn Nn Bhk .m `5,?`G ]:`RK*)*GIENDB`libjfreechart-java-1.0.13.orig/docfiles/StackedXYAreaRendererSample.png0000644000175000017500000004154011173030414025731 0ustar vincentvincentPNG  IHDRXr5C'IDATxlםT[uJUjߪZiV]vWUeYGu4,B v\;ȉeJ@vhkDIq' uC8 &%]{1B!PB)!BB!B!`!B! B?O}j(ss!  Ճ>/Bg>>ϩ,zju! .]t7>'''__yΟι|eXxy9{v}a1*&SU^^SW^M1O" G---10X"b$$[۶m~79_l񒨎Q.A@a7XBNN˧2!BI@e5117|SGIsy_>yQ1>.nܸ1ӃFĂ:Mև[7Ϥb$R(Ǿ/' ! SiXs0 ``|.9XٟW:~{^pAYFǑ׉׼Q_W/m0u)c&FQW_oo[s52m>?|kcs^жو϶_h3W̊=N9FN.1䚒(Ҷ=0X(ܞHS[n5+\rs$JeJ`<{6 }eܷzk`,m4H޽{AF"ًe}a<$1nMՃbdz7ՄL׾ci5z5888xXތg']xXl?x]O"z5B,I40y/}G9(l2ea7tS{ \+k%$ >_ek-n_=gmt"Eg/^(׾c=>|xi}KN[hW"C7^c}9Hw E2  aP $QdPu;-_mlD+sd)k{lhE"EJ1X|.)A/= ~5r)rɬ'{㹊0SqQ7ӄk_ynmO~2~Zm!m`ųٮdg,ϱ'KN_h L0K,L4[,\΂*=2r܃yI2nZjU٣}C%##n /Ӷ\!~oF(׾#Anp{yh^g']|OnO" }RE0)`~0vڒKr7Tmpkkk[P,{Ny/) Yh푵m-B O>H+OmU<9c/^gmF#-϶Od|/{2I4DB,dJPFT$W_⏦QK` k&)U~mLiphf!fD"X֊N#i/$i6*VNb}2& kq%f}LًS<cN(_JM2kQzp`_&Ȟe;cFnD+v埘*WzqbmO ɒb.B,B! B! !BaB!0X!B,B!B!`!BaB!0XJ֬P*//OԨK.zzzTee~,??_׫1˵B!qKT1UR`!Ba\1 B!0X(޽{tT`dAݖp.B!P,3gjÆ ƍW%%%9XV*b=&obG}TZJ=_MɁ?䶴a}>l?nK[B{Nz_zڵkx%y[&ZnO~.\@[mO>% mY~} )1:yNt UPPַ )ߙ'lB}h +nUWWaqshh`` bʚnPUssjmm`geCO0X 9ŋ&myYn9lUXX#gx>aA[2j0"B}h -$,"XC[ڂJ" 0XD8ã-lB}h ,mOh }B,\;gx>a,H>u0XD8O4XNm`}h }B E9 nHYb, ,"mۻ E[m`P}/Ǵ2 nt, , 蓅K?ʊܿslB}h ,/tt GPWo}h }-,"XA'9?r-mO>%C ݻUEEUyyyF]tI?6==U}}6Dxy.9X69VRU5}aJ j$̜:::TwwsTSSxy.,Ԗ\Hƍfm)œT?22_`H.ժU76WVxڱl-f޽{H ӀLyy.,8%\Ybl-`4b|nܸ1{^}f~lnPmnu{hhx7y+ʤhZϡmns;G޽W^MdtvBJzzzfJU}}яeee9$/%dsvBDUUUA5==T{{*++s|Z|"^PP; mO`X999766Μ%` l Im H`!ղʕ+jʕ%L0fF599I3EJ`_@>a Md6˪x,D1XuuuĪ'xBTu\zҎ oQ˗cG?TǏ'C'G`iyurtI<,ݖ={0J HK0}h DH:Q$WԡMLLr HQ:-xz 8FL?^UTTDMl^(檹Y /imɄNgiC[0X1ԯt̙WVzʑ`RtSyOӆ? ۇ`DdppxaRtwS>ZTWbz|Lci  E3$7e;~Z;>a V 9X(Dc18b͚8&0}h g!iST%&0}h ,x3*I\@` /\u>PǎfaLa 9X́vT7q zJ7 H, ,@O  9RV#c ۇ`1bmLJz_~~"_`4DIDHh }B,r2>GDҜ׎m`-hL!xsfpwu -,r fRyI. ``JU}}яeee9iܬ_/I'^TsU[{ ÑH|&BB["XJ j455UYY٬U3gݳTSS9X(Dś\@NaNNgUZZFGGgoKgx<%̡r\_IC[ڒvkhhHGL%fK0fF599ySLceb7X *jR GozU;+nso V*))JSb_#gx>{!*?[\mOhK V[[/RbD$~!,r2;Gś!YR#'``KDhP99XK,!,ļtǘs="$>!500^a(J0:Nvvv+W666R 4/.0Y#7/OP++R^]#+;;[iD+`q? @޸bLk9 {\Ajg=)r|h }BVfIbC}", mO`aJdF.@7m^09X,"Xyׯoa"$>!"+r$ ˝p?YkG- 9X,"X?;tTu(xRd΋Ǵ>!Ea#GE`µ oÆ_s0@ziS` 9X́{nsPbSh 9XD8>nnSh ,rWv|[ a^@Z.` ghZcz ,FΘF[`ś\A!jIJ4c 9XzzzTeeU^D}̮,G`+ot^@ c ,Bk᪪RjzzZMMMvUVV1'EVz;xbȈ)=+B `u8B 9/ϘB`А\y}L /ZZZ$9XiK7'9BFC]N2E[0X񫿿_8YEz̮Qm`4Is9_?ժU79BƳq7Oǵ?~#Cmt$y[OVxE m{YDbCIfX$MLLrBܖQ< O H3E[2` F"=fOl^q(檹YҶ @zW1,ڂV*Zm+fVvv*,,ӊ\Eζlt("*Ap!kf8, @,rX3}/K"*A`X0Cw|sYɫ!``e̛#@r&*A`0RsoH2N,  9`fb|Oh ecr|F +kgɅ%oDh 4 rS[{M06``-d[@|ʒ'Db9mY*4'ww1``-O>y@XƘO[0X`/rRN3~`JU}}яMOOf}"a||}<V8`IDH"X)RUUijjJ2XGG}nWWjjjr|/%+5mYRᯝy K'LJ>!G迥jttt~l9s`%-?ś҈Un&$  }B' 騖(//o4>S^KVrٱ, @<9XAQ*))ʚ}Z&ͬ/2Xr&9rlUOOCe_/;;VAx3,`a}wŤ`і@m?]rss ѣWtM*N9X%s ʕ+ڥK5<xK(uexKhAAںu뜫dšs`2Wׯi7][{LdGY};wW^yE/l-4b ݭƈ`%ѵKaU!+\ɺ|4K߾)M'$w1S/*++5Z^4\-eQi'essIO,ś3?ߪҸ5jxW}Ҵԃ\!n&œ=:uj_R9nR;:jfK555eKx2r>ސ=lϫFj2T HHG*+Uk뙤% ýwtB 1XziS###(r\xsQlV{]QTWٙq֬ҷ yovj}ft4XwU}}}vN»`ta)X `dmI:)C}a`} K%SYGj(eϘs_PO+uss̕jGW4B v:I+] YP~BFXItJ |nuϲ'xBTuWV55D2mQ7Ϫ:mmkN%W~<6oRK֎9:XѦ3rss3.%s=6!3ΪsFMJ>L%oKy[$ @k߾}ziD*ϓH甅%KEDaHdEMK}iG}괱AOIJ2= }Y0M"LAs%eZ[[٩^EW$IBhXQn]SOJS"Xdj]UjBjұƍ\+'$Lں83xYPVq*@4`QśXIdCcy( c/r:{ R֭iI&Wr!HޖےE@HǦ߭R`%*BYGBxDxsQ4;}!ўiE73ϼ`KH~$ BVG07$We◗->O@XlRW9AV $8p@B%Ҝ8qVr;vzq1cy[WN'mC"X.ҋ,s=W)W\A']J.ÕA*3FPZ:/5qJŋCm`xs\(a+oHI-p!d,S%0SR9xM}FJ o ZuSz9X 2X˖-Mr߱cdqa2J o wߔR< ,Ӑ~%c$1gjÔ/L%"WL;!% ~.zjxxrRUSw mTF-X]= iZIś)ɟJ|h@@YVd`x3%=mB߭3r- .Zh}===R|U__FFF\JeKu);U1>% < }/%J QUU%Hv}{1 *ȔWRC{_͖z +F+rrrbb` j:""JHR\m{khhHG^+K---jrrҷ^x s`~J.eKU낲t IR)~cd~URR⚃e6Xuuu>E(HsW{7q#Ash b⦱BxV(6X3x9~]N.5Xmmm:4>>{Iޖ$ǧ:KojB.o<w*ѬV75|m{7)fTKcJH=\(`-^]3+;;[iT]E(7K~7F Rq-wNuX98H"2% hSouS jkx VH"|~>ScSgut,#St@B1X)^'/I.>fl:mRR_|q7L+HoMz&Yl.H.nb|/ϕ;XlI RSaƋ%ֳϞ\qe @J󶤖y[M ֬>IJrΝo`׍r:`$okq-$!%)^lDX9HEQ:*ئOB0[GlRMu}`%)Ko..fK댳: o oeJBk߾xs xԸ@mU VrX95%dc@+"X,ޜ\֏a˺mty[A4X\E,YyժTrA y[ouq2c.@ օ ԢE7==U}}6D<7RKVUJc5@]ޖt @YPݳTSS{xyZSs~Pr <4VDw4R5:::{{ddD9s"X_ 3V\ْ?cU%J7o~_ mɺ|"`L\CVV:XPrȇݒ1D?3eKG%%5d,+*c"#% .}afͲ *J]kƍD/e-E|hjZ`aB]r+`A4|Us%W&'RFh$, % LD>'+/H4]h`0X\H% nk#&01bf4LrOň `a0Xq](gt+%1b, k20Pr FL%%BĒ`e{!Ւb`aBve@;@øZ eƨ^cY0`ateb)DìѰƫI2Qlܦ0XHNBt{ߨFv}<^-)Wc0XgA 1Y[^bq, 9cF2mĎe+$6baZx_pٙ ÂTM? VVV# }n:,IH"W@_-hXCC:w?5::/_j2)%W؉jI01Wׯi/Qeb1fE䂰:]'\hr+ynm`]rE\2tbNNƘ鴖599hLfꦱ |`544`եE+R̹/̘6X.\Peee^3==rssCm@ [CHutJ]6Yik֭[X`0X 0VRcŘ0X deK~, N`0X Ec~ƕ, Bռ1V, %%W + k , V %0X,J.`0X 2X\`adb0X7XYYY8izzZ577zm,J.@ZXѡgowuu ڵS]j˖(,Qii=22q׭-{ڑq7Ҹu``Ɇ:rH I*s,B~V3+9sI2liigEEE?~@)í-=3[ntm>q7Zrܵůގ :bf6t`jiiQE6hʕ+}l9ۗk׮C~ڗdggpd{Ps0,9 S?!g{S~'5[6X~v9FT5k7$[$Tv:Ф%_o544~_>[vիW[a y/mm!a6N86M[RRH0?$oC:5k|#?QJtk܍'wmk쵷q>nxk1X6iAi)I:LfJ4goˎ&~Hje1%|n`ED%޽sYh`5㮽-~NQW?]q511 |lI 6 Ӝ_9Xv +J6X)m-Y>IDU~F>+Uc~n}Ǹko_coI*]qXzŀZ[[}i\ Yv0?JT劸I. Py`UӧOlR1mԿH2`@G+{p _c~N׸cLŸi:faO KR% *g˔̙3%gEC|rȃ }ceI4GHLrTO}ԛߋ/^X'Tk`%co>I-wڒ7Rr܍4nP !BgaB!0X!B,B! B!`!BaB!0X!BB!B($#0X!t?֋˒&NhqyUӦu<{n B=ܣ80֦֮];;B uw551 $▫f6"ԵkT^^^ VY31XaB0X Jmu8WGB! B!,B! !BB!BJ|],曉=쳫Vc=m# ,Q>8!R㫯j bN;4sGۤڧcqɓАsN8^s׮]Vu BBVرc3Ǹqʾ.}饗"?,^`eɔtnwIܧSFBeX ;ե=W<,Xp'ǟ0޳g=z2N?..v͛8|){&kd.PpE],ABp߉'h zE {SO=z gA9m,+ v|c_5k֤} `?ZiʕvW4JYd#B207'{6GIwH󽣣#QտlkڵIG^(y%o Jߧ Sj,Z0ʥm#`X֕W^e&o~ek=.HzqvpB3`_|>[uJ7:ׅ+VD X쏪e XNSAJEUrLeg;ly. Fֻu2|*dFB Xa^y\tװAG+N'xN0kӦM}9ssl:rsUWE^4?^SSi QkV.yQ`e _z+)/l X-l,[oS2u"1cFYxRy֢QV'Nhڃ`KFB` ^Ŗхÿ/Y'AK `M6[d`?uJRzOu& fwDۇUyߓO>9Z./R\~GX<}ayײͧriX(V[URoqiÿ3innvՁoܸa]g`o]xyٟ- ;"C>Зm^gw e |_~@i)~xGgR0J|(o/am! !Rl&? a;$xXRp0L^zOu&ivw}W0Rjʥ%[HN5\y= -w LX{FB,I߿L;v찝(̚Go^WfyݺuË/`I3hȐ!-/٥ z*{ י?FX]ӧOO/Hu'h ƿpvyE;2[PG_A]3ΰLӋ/hibΰb+BB(km6I[k[keAXLvz?V~yg>kƍ,]TyǯP 9O!C$> K ;$0bt^:tä/h'\mEXRwmyy‚7G҂ڞ1cF^w>^z饌aޣ2I7&رÂdC~(Bi!l+LiOJ \mEX AЙnR G)@~g{ZXJ1Yf=92%ϕgڴiv]wݕңa4ʕ+0s5`ek+BB()P|クtkm@\%J7, qs'lS37Am*X.LbӦMgRưj+BB(NK+^Oa uauih)i\lRϞ=3'sǎuޮ%S2 oÜ! @7:Ou<ƙ_Zsb!G6^p$ i{4W_K+iM-,Tկ_. f{-RAT+e](Z}2YZJ~j-S aE^FVjskeگeG[Ly0[}[nzoԩS[G_Z'9ls\Y~}&˷Tec]kI s_ZNs;8}1 vu\I5{Yfe/E G۩vS^S !+u㏷I#[CԵ3})˵._=s0LJgjy$]=}泒֐~=v[CCHO~b@+A 0u\k}vZW;>N0YXQ ܗ[̙3n>wVG~6&ر#u6b S^S-ڹa0y_lr W!m Ӯ2`RSSdJg_mNgy&!F+-p@[[9C*/Dwޘ=z:ߙ%ˇ.Lz7tpKely1d ]R^;ajcK}~'S^ x9ec@bXᢷlJ_oը';/(]3Y'渋RRhѢľ`Aۨ[}V~;GyA~0Y/~!;4Cqml+7SνJ wBws/KUrfݻt:r/L۾\BUh<ôLv ӧmv}}}JNe_&`X(&%W9Uu/l8)]lu&(A'MeMONTLzSNI tJ=We'FA򓟴olcKR՟}V{&MsݗNrMal}ՅN.bڗk]HW m{`vΎT4a2¨&u n/*EJn%Wes s=ixeʕ6V/ )4}_Sn4s%We &*//8J*Tfq_' YrpB!,B! !BX"%|eUs٢D_l"X6nJ|˾r|v9T[[krA555f͚5]ӜEZc;Q0ou,WP)}|v7I&oQ˥h{;R蹥Jt\IK9iF {_z+P c;`! U4KPlZR:jw}:uZ`r@Ǵ(lkxk׮׿;_8k 7۹:2y>},hRٗ~WǬ{hC}v?._җKnq\-$iam_nkpI_~Dr{sWu^|Eϭ3'呼rn A:al6z)[U>eikkSveS=h>M[tٴ[ XҲZ "HzjN;l[W_~k ׾T(ݚ^W\q9ٚpNCRٗ~=թ5tM͏mXn!l,QZE:5x-Ѷ:QMܩ$MIgќTֺN}'xbsC c{ "I&BaZ%x)L;LW粩{BWϦXB%;.-+8ɸR]Gk{=%Mڊ{u[J2O;ݯm1˓U( ;dֺm_ѣGN!0y`Zas;oZ-u2ٞd" RJ`} չ1}%[(`! LQA闶M+TC܃9C8uPɛpM7wydedWl8$Swrlz ѣ_whkuQ{MMMiˮ c{v!dqm\ɾ\?> X$R'+<>gu vJ X0:2wb/Je_Iv}ׁa'Sgܿa9Җ7[sɤaDnڴ)_ jMo='￘ c{ CaZԀ΅PUI1.'YtqCprPSb(}'+8Dخ`tt.[L_ERQp?00Td=S.^o000LKu,.R ޽{Xpq;TH>unz[uJ/eUůГު*^e۶m8,}:^7znJ +^G*?<9aʳX c{i cL0]Ts`! J1f*ɾTo!P)B[n$Sťl5ĴrJ<-gIC!,iӦ`0*4bl, BX!BB!B!,B!`!BX!BB!B!К4iR1cƘ;#!6Z6`6`eL 'eUCڱcGlml;!Xq-[ľT ؁ AY`6XX$D"Ȥb%СCffʔ)`avPLJ-2/Nl7773g AllrCݻ`avPLիW/h͛g:::>}t9WC}`H$DH*ɓSzsYArA:Jrv).lߎmصkWMyĿ}W[Rݻ.Iۻw6& :`Xo J' 1ٳnO>]Րap+jhhБKqdovmˎ8%Ǯ]V|5w܂sm"I3ϷrJwb&ӾXX/7oߞs}`5Jg}9ꨣ좻^xYp=69{cok8-tjRxjkb;3`*r ,lV;;<3c s=v$mذ o4ݻw,b X; LX<*A ؑ&y)p(ʉre `Ѐd-F `yHpۨ<䓇:u֭1XX{ٲejjj,`1;#n:ݣG.v\=.bOP w0)FK) b-Bb#:U1k,MYTn V*Zj9,S_TؑmWbG19V؏~Xz`tPp5`sX<,D%iy)u l>͕W^i;|E"/`+o)y>O}SvhI v` Y*, b<,b2[AK|[߲=X , ؁x,T䏫 Ơ!`mϚcWhC`XD" "eZl`Xx#˴vf͚6͛7{j7{G?J/fժfꏒWIuL=/(2{IVyRx1eyL`X`/;m?vnx֜@4lQ8j;v=g Wޥ,M%~T>hs foT 4wͶ)4KUM>j ƒ nG)+]W_]8j`U*`딒:A7SJg^ ~ܹýLӔ~W{9s饗&SOJ*F}"Ux*`5*_JW=VQ_zn<&rJN ôiӬ׌!' 6ʺmhx>\w+z {J X*hFz doZ6h\m$/L4Zq}38ls/%`>X`a1XYwjܹsCǁ(֡q `EX:?JXnu(i9S}+:̆d+&䲊Bdښᡇy Yb Xr5nj?ܹs+BlJQāX`aCVKIS=2ַ(c~mʃUT~AվuJZ =XOZ巴Cٴ|r,b ,t(rq mU^bLJOQǁn 'dٶVGyo>\leE(n AJ02L^QbX~ :l)y晎br ,t(1X X@C88 UU__o:?NajժP-`NLgC!*sʟiڕ:-6'N4}-;*F}5`Jۻwa,`M<9)XWCC\]z??츂=Z|4.n[v X/} U]vv\cʷ Xuu-aZXP?}Z{=fʔ~LX/ÌuK^}9A3~R<ǃ޳Ã^᠙9̏_sϵP!NI?W UbO=XAM&h)/ #hkv",eŃU1X<;ƻs,?K&ưY*'1X jv/ #tXzK sPu8VHoU1XV jkfS_,= o v{ueG+u% 98rޗ G^2bXkB `+̜9”RТ Tloxu(h^8(71٬^[Oo0Դ<L?δdtlYgZs[t՛r, Yo֏Ϋujݺ)'WTuJ)X֮}A}iÆh9˖F7 Q.2KkEb_.5`}S#d֯N-^ 33)n)XFm5sFΛ pՙu_ER:gܸV)<ԅ,}V^,_]> hGTXE`E X)  ؎dXE`rS`†2#]mVc+6åg=b`/vSׯvwV[w)`8U1X=@lիf„V3qbfʔV3ujV3mZVnjfj5stnΝ;-b Aq`[_pL^g'Owj~Ïvә3[=pު^+^n}A&=`~::)4`%+Bք 7:Zg47{.*`͝65kkjd`bw",RhQ,u,[w*Ծ+l`UDO9V2X᝵, , VU{ ;, , "dU[Bc(Vx`~Odzzj ?|JQޓ&=%~?`J By~Nju떈Ti>)Aէ?ifvb̓<~a:\%br|0n+,b"B.E{1`X+WxǃU., "+Tދ `1},n"D`Xy {=X_ߵя"'`ciC jjj,  Xz5ǫ\Ν;C٥FL0*SYXXbI^dkFX` jbaJicVxZ=5lfΜ"KYX XbIp `X7DWmmmw6& bt1}7 W 0^{-`XViK0!lڇ <\鮉 ,+`]P||c3ԧ0"oXU[odQa{MydWCCqvo_5Pk׮{83:}{kHcL]]0a:JW֬Lc:,h%K6\L^Im%Mbx1XtI&GÃGVeWdIt!, X&LH`%ogÆ ^t/XV`b, ",է74kf,@ph , ,KR,}RZ+:ˬX"11"1X,bT3$C`XU8RU9xXSN5ݺuK`?~x`XX,`۟y+8.KyE `XU`>)]&x`X`X"Rub, h!)0 ,D|M, ;E,6e^xˌ1X~Yy^+ٳg{2,b, ,% Xz{ri3`;Xoƒ`X`UV4\a9>s9uQcpt.,X{UXJu`ƍr! , |zSzryTuy3fX@ذaWn4ݻwO?#+U^@G8ww+`X`e+I5*1g> 1DxGJW_ܲ~yN9b, ,+ X.9裻+`X`ʕ+0Xi@бիWNjuvX >,1X`X(֞={=8sL{L7+/8eg `+ȥz J ׻Uy|Asg3`Xz[.+R;3ůpC>.`dnMk̘FXdk]?l:~yt'rM,7UUWRp6*RyԾ}=k?8*6`ՃU b&wڽom7uu5ĉn&On7Sj\>s{„, , ZRԵ.-g`X`X`X`X`X`X`U4`imL~`X`XV `X`X`X`X`X`X`X`X`X`X`X`X`X`X`X`X`X`X`X`XUcӷo.z4X`X`X `X`X, , V^lb; 2թ8oXa`XVٽEklطoq}fN; ԩ,OXٴ= ok9Ăw^?uo~w,+ [Xtm, *9`|rMb={i#N1{g^/4W;8}O_helTV;`, JX^8σvc=كEx]8{N[l/h Skmw?`Z7l2ӟ̶ͯ3/0޼tcyiߝlZFM1i6n^auL.uJh}\U3i,T*F X_,sI-k -B+: 6뤈]XzƔL=@ BOP-kWs%s͙VLӐ+`X`XiB`XeXzi{Zё\򫡡رlٲf+ƌ-U&U[os)eXuu-aZ2G2fΜ9'?w}=Ӆ*:Ƚɓ+ƃusl@agq[k<)W;JX/@Ą{ GMXOx(rŘ| ,kԃ,nXyjߕ0{1EXa*`RX\~W 71X XFg^rmeZFMM0`?~žEػ sg>EXa*<`Zv.3[b'l|uu7fF61fmK̒ۗ㗙ew:p袬1l|џ4_^-`}kywլ35o:򒖜csx"iR%$7,̯yOcZNkLX3|l9 Xf Xa)_;r: *\ygA\X:N4~Ai}g|w R ^Dʇ]X3<[ʧo*.g^ZWy/`ͧ|+y` W_̓UNXQLXXVfM4Z(rQ(&r\#!B+5`EQX<3/Dw!B+9`evUVkWeXQM`XQwK64iҒV`EվX;שBL4Z)<.M{0-`EѷX,SU3XɽM4dgճf߾}f'f]7lVQfͣͶ[jͶ#o7G7k f?)f0oͼ8l)a1grǃU=1Xx{ _Ɯq@; !X`}F v`XX{Wf$ G[, , \͠A& ~q`X`X+`}R@Ws䑟Ȫýa6>/16yیmݰݸön7Fn7?{3{7w{3n^Li~ӿ5MC |ip) Yhͧ5Kˣm9哶'nWOarWm9ۇlk0 X*'ςw\9{o"Mh'׵ۼz[A^?t}>ؼՙOw:6&r!dSw4 ꕿ˧,Y? ``%/1K>r˻,y?H3fX<V1Olli9+ni`ԃbƠnL_´zj^ݓvl]B^mO?Cٳg)S$nooLU]XzqX؅AlyGj  X؅ X}`X Xbe̜9, , UC=ۻw6, , rU>}2 x PB~s#gz%}`9`%m1, K `U `3Ծ.Ux9a`aK.On\zteWly{eaۼ0Cy-ρoо+ھoo/>kx=X!BVž={` 4C!웃NH!BU΃?6D"H$)TQUMʶ;S؁ ؁ x; !BX!BB!B!Riǎo߾]}fΜ9/~3jZ~T4n8vݵk&].(.vl߾%͆Tv;(b{e(N6ĩ}g#;pJWӵ\ɎRo_ȯsW^y~޻w?l bV\i+ҲeuZҧ-[=c׮]7Zl"L9-Z,%MmfGmmiiies…fv qjť}Zpv8Q ` [~{իW;wZ 7J;h~_ĺ,2S9ّСCM[[[_T҆tҾyK;ӵ\ɎRo+fUSSsXUvPZzyƍwߝxe,8W;hWwP^alHwHw GeGPLWolSNw,.;׶_,pv8Q ` Əo]ruˉ$V !`!~zP\i{…؇~ >BXiӦׯ d1{lN}MMMv J7n<ofy͛7}:{}o/B XnQ@M׶m,$yXbx,[!`!BX!BB!E BX!BB!B!,B! !BB/IT*c*_F*4lU! !TDQ! !D(_,0|BBtEX:77Oڏ BBCx1?KٳJUY`!,N=sW^矏fV<BBՔ)Sd `Ty`!,,s!ӿsAӯ_? ,Y]fӧ;̟y/o7MqOn|`j9s/ܦٳg}/~ {޽{ɓ''=v;4&M2i&Մ O ! !CzW%)`-\߿DSSS[6md plْ؞7o7]S'0sεǮ sNٲe)-Z,X qM })Ϗ]rO ! !C9sYnzj rdI X~]uU]@Ducկ;?oРA)}My~.#\BB444dL%iHPEqHnn&Jw7xÌ7; bR E$`ɳrO ! !3z뭷vofZA⩖/_nk2UA ï{ς[}c)5rLy&O `!`!bXR<_zwH0h!,*577'bb;v$`.>݋@M\lSLy_~a}XXr,7i믷_۶m3C D?~}M@%pX$c))Qro&,]CoJ.Oϧ'{[o5u*,˘gysO ! !T(_F/BBQ! !:`D",0|BWUsG*8B[}nIENDB`libjfreechart-java-1.0.13.orig/docfiles/StatisticalBarRendererSample.png0000644000175000017500000004771311173030414026222 0ustar vincentvincentPNG  IHDRXr5OIDATxtU՝{v晙53k3yguάeW;gau3<)O:Pi( Bh1A"$ @ AЂ ixsdv~]Ͻه{>sgR  H'@A`! @AA X   A$=Qw ,$ܬn6}MOD &7fIX$L 6L9?߿_?U_׻O7tZ`xbV:S%%%ĉYs,aF X;сOV__Jbݟ~a{{ ?UW]`Y˪>DΞ== A8ܛ[RNQ^l{챔l*Y7dEd}0|GԹs2_r1ckco-[u'?4Y;_:˿hkޟSNAdzb/$;VرcտۿF'ޯ|+oOԩS7Mc_߉-Hw5i$_W_=m69'2\,Gp.]ҥK=oWRTTu6+ =vydEgG7Rݿ_x]0@M2E^Tb VCCC#ed3ʤo$ T_///Oo//i]Xzb_ئ,;ŋ'Ƣũ> lxH@$m3 =ɓ=Os΍@=J|oM;ލt{h"ŞDVZΗf@x'輛СCjРA]֓6{sL?W{^b{XL{?e6%HE'o9OtR1Vǐmzt- `!H ^($Oh}QR>x4N(UuDw.ex?ZK$,ѽns_ r'1^z3#tO,ޕo<>'r0Y?~̙3 nso]"dʢ[{I6qN.o YwNUwg#@0|A< s>Pd\>VNL}KO4~eҥC(lsorgɊ~/g\^MvtrB2[ciTn}TBuy, Ϻ/|I0K\-X z"V]D=2lso V++/??w ؾt//+v@=Oo2mB X;=:'%آ <tn}ݕwbǏ aǺD~3Gz#,a[DǷ\ǖyy\w&Y{/)>jߵ1XE&+&ͯxȉߏ`;Ipo ,wqGdH<n)}x5`Erͽ%XOl//<6qosݰd`6%GR.=ܛ87+6HO_e&w^͙!X AA  @AA X  ,AA  BA`! @AA   AA  @AA X3ftY0aҦiӦ7| m~_@ X`A``A``AJ&+VP'NTVyyy*u𽎎5gUZZ+QTCCC(SLuu9rdҥKUUUUVVV2 X&7779vXuԩ[[[Ո# X`%vr!/F{b_`Q X3gtU'e,cY~e ,~߃uҥp Ѓޫ@u.cDle_ VyyzXâŃу=X)y(RX/zzz"TfԨQԩS]^:t( c X R__J5wy|ּy X`V%燃 ֥K X -XH`a&wڢρ,d`}D@ ,`A$$ @ XYuā` 2K>$q X @ Xq X,,ā` 2K8,`  X,V$`ujUXX>̙\ZZZ[[?{555] ?Q@?I`%HQQjhhP]UTTqu&5uTVIc:B@+vѣGC X @IcccثikkS2 pDZH`%Z5f̘1X&MR|;bb^b?IJ,X{`s9H:,k*//{*Z,`{8!l<н! `Vk``"q XՃ4%{8"X8,L@V$`A  @ XF~I@  Xd` q X,2K!q X, X,` `#q X,2K8,`,`A @8,`#X`&qs>  Xd`"q Xd ^Huu*,,TVR{,>ā`VѡUEE7n\Apr`58,J1i`m X)1J=N`Z5f̘b!:ŪE555 Ytrpqʥ?䪔jR~aG?^} V#Swe+ZC iOQYyMN@zA@VaC쩾R!X,B}Vw3=`}҇Ȭ|; Dā`Vĥ X‚uJ %J"` Dk$`a&V-XRā`+3"Y,`A i >Df5^ v XZ>!2+  Dā`+>DfC X@T8,`e`!2+ @ X,V& ևZ~CCdV7,$ @ X'Xǵ`҇Ȭ& `1B@ y>DfB X@TH`A2SP?` @ X&XǴ`҇Ȭ&`zS V-ß XZ(}ʷA X@T68,JjUXX|W5|C͙3'|ikk` Xk:MCdV4 Dk)**R L 5nܸK߭Teee,WcJ",`%رcթS:_瞭#F@\#ZNQ?`Qzā`V ill {8yyy]^ XB(}k& $ @Lmm3fLN"bX?;.V/KPx=r(XIwPXܯ}ÇC\CZ>!2+ ކ`A`m q X NlٲgϞ `A X@Z^'q X <*qzW qJJ`!zC z?d`?>UIB+V`&LZ(A#  X5k֬]LKՄ B6lX8ٳq*Btñ]MMMbwF-XI撌|W.P_U\2oIyG{Zĩe;+'XLCu.WUUB`Ѓ]$J =XR俗 imQk,p0M7 cf%(X`dV%*X/8,2ZN:*vO #S?r@`5(V`]"3Ȭw `xRb4hРr|"&dx,V1X,کm%(X`}JfYy%&X`-'qs>pXAy~*a@ `&LZI`]$3Ȭ<KXHw-X|i02W 7ܠDf5ȮufUTTeѣG <}4+SWn\[I`ׂu ,QZJ@{bY1ȝejjܸqi2\(f`}LfYy`ρ:zOr`x㬹0ݻw#G,BV?j\qՑ(,Aڧ ^  ,'90Y#XիWw\ n\u%QM,1ګ#2{ADk <|(}k+X.]RׯWSN2`B~Xs9|2eJCHڤf%,X' 2+$Kp}OHL({a:F'N;rP6(,AڣC2{ X,`!2+.+2K̖-[zeX*++ ׍K67uzD ބ` n-X 2+ gH9'$(jժ8X1bD(YY]v`Yl\o]ZdV;r%x}OȺ{Kx|CCC;ޮ,Y +VS\\jjj @˽mԍk#R$|/@GeW:ԇE()Xa<̟` kn\kI`5hz . %vxW> Q,Vf %xB['I9g>ٰ!<1 yUݸ^!Q XS >2{M^dqV8,s|aCx>>+ZݸV(zwkymFtVk/Af`w %,X `efZ$KUV֤O: -X 2+5B X,s~|aCxc+3k`O톐: v-X 2+I9`g>ٰ!< ykn\/(k ֧: V3Af!X${9]`A X/Xy2^5ׂ6Af彝,QC@{<Ɇ `A2qW5`}bÚ`mӂHfYyo ;'6'<`A2qҍE%qI's: [d` c$K3 DZZZԐ!C}F@ X ֯ !uXZ 2+m` V<4s~DX"KSS:u*˥ƵR7$J5:kÚ`mт 6`&q X&|.>V GBuyK%ݸ^ Q}!d ,K>!Qx>>V֦ ӧXENqqqx{?;.Vg!d[ۛ_kAfnQ(Sc3@84i:|p.` }{ւUIԃS ?6aK=X瀷< Ѓ`EirzQ7e$J5j5aMj`m!3ȬWY$K3 e0+!X,Y2^5ڬ ^- ;3`A2q-׍k)`' !uXMZ6dV-X89p<,ӹ `8MCˀ,Wn\$J5:nê`mHr,azā` {sA0;+k>A3aMԂ& $K3 .ʼn\KH!dk$` \x@ Xٸ*uZL$Xy2^U@@A%xObO`AB3aM6jzD6@D%x瀭$ O`e^ZW9vMB*XIu`O@T-t1,+k>A4aM6h!Qn ּyz?hJLuVsج$  DqO~iÚ`k`]u'dX^ xǞ`G@Ԧjx+Rݸ&Q]!d*ո&Xunoׂߞ`K@ozSt1,++k!dk^ [`ZaO`#X`89p<:lħjộ!Xk\q=E%X[ n!dkWHU댮 a ZB=n\I`k2^5т2qMt7 ˟+X%$Kf`A XY!X !uXU${@k=ā` ^ħj`%5dȐ.UWWB5x`*--U!X<ƵX7y$J%udÚ`ӂD^qMN:8k?k=A@=ZxV$:EEEAuttvUQQƍ=XiP QFCxV%[`}Wa_ivySDB X V !uXW` Q]u|lX V=<瀵$ %jll { X4rݸ(K NCxkIoku\AdXU V=9,Z X$Xj̘1q`XENqqq8AyEq!QJjJ{\:lmo(XI t} =X@?Rf`M'q{-|m$JBkۛU^^Fe]rkm:`тZ>4 m{=XzkȰ>wxхo`A2O ,wI:Cx%-X$5ڥ`dX~z{u7H+3 ݸ QW !uXj-X I9I.Ȱ.-X d%xotm Xu㺟D \ B*XO(RQASP 4%Ml'Xw8,s ,7@ X)X( jCxkH5ju(  X;Tz7XP+kn\( ˆ: ֋Z(޳ ] ;V $?dG'~  5G7R%x%z]K)%kU$Q% v];D :{u'<,otm Xt*!Qjq r-XO(bkzQ֞`8,aZD@ X+X(n O8,Iڢ`(,`хo`%5dȐ.utt9sP6 L7$JP`-ǚ`UiKx V:Q`=*$q X OFCrrr:ҥKUUUUree>A\h\u`L/cM^Ђ5D&Xt $K'~ ` Z;v:uTrkk1b˅n\?'Q]ű&XZHokmX xx7@ +//s c_U?W^SkSuuŸ)/`=ֶ7$JɪkeZ& k62?/QYXP&8uꜩl[t8ֶ7+v\o8e}{yD V1VVXߟׂ(=ZI^ hk<,g9qǂ{n5YqM#Qe ֳXߗiEx \,Ŭy0y,(+M*((PO2k ֻw2*G5uJ%Xt,Ǫ`=Lx]uo3`Z$Ȏ`=F@ kٲeᝃwΞ=Q:p !Į`DqOHIkm/<ی xݞ`8,AzcA!X)L=]C+?>5{Cq$JkU.UI'Xkzfz{u;`A`&w2*k\3uB%X|iqK`=@xO&X,9D`k瀧9o`e`VCȨ׸ԍn%X`=%B $k*~>A=G@k'~ `e`Qy?`q=]$[ocmV ֽ$75e"q X'>*@BvQyyXRś`>2$KXaBF!dTk\5D *\,8%ZJH1EgQBs8L z[BF}un\E${5Wkb-X3H5zAQIA֞`!q X'>ǂBB!dT!X5G ś`=/$u8L jw !un\$JKXߟтs8`-TR#Xh98LVN}k5Rݸ QGű*XIksxL!Qx,(++k>2N{D7$J%I&gcm/7?p-zV|& XmOF8,A*aPVV6}k4~]@'Xcm_/o~[ŽH E*X?!q X5 ڪp; !^G7$[X,}'Xψ/|%(Xzx+ʹӧɓ'Ǐ;*XuWo- ݸ~J]ı/%?-Z$>`;G9D 43zhj*b 5j(Gk>BF} ݸ H~qO?`=->'XH,X`=tVZhO~H@>O{!Xi-&X`!XQɭ_` Tq L ֣r ʴƱ\_mq[Œcm/>??M-tUkRO|U`e`J{+gq&Xwcm"_|Y-A/I`h pO:++g^*WCkı*Xͺ'X<Q H`9,X& :UO/zzR{k'>[Se%)X<)@?!dTZi(,KT ı?'$ `M4|ɪ|Y M$w뀮3Qy &/z,QQ|u'>N%űOS%Xź%* ֍$[WGQy{/&/z(_nqyh'X%}(|[ E g IkcQy;hW{!XY#XKşC !X5V%|{K Xbը]CȨͪɦ'׸ =[. UkZn!Qɮ 79XHkQyk;Up/6у`jʔ)*///]Z" ߟoqA`HM|[5Y& XlO'qm !#B`ĉzWY}KL ű*X#HW4N xƞ`]G%XuBF=oKVͅ=4SVVlO..׸&xwO&Xı"1xAP,2*ygrw`J3#F% S[[[\bҢ._}P|뮛om{CZ\Vt` <Й͚u-SXLEA!dT;ߩ(>UOBkۛq5h Р:::T{{Zd8ڃ$_fxO|k0ϥ,cm8_&­c` qby2*ykNr,z/׸~puO~(|1x<-/>/LRJ P?;VrCȨ̪;+͌5J:ukCuT׸ <. 2]7cm/>/S%X_"!XbŽHQyϫʪ+TVVsvjllTsTHvkΞb׮v5g7s}]UUmȕW$uCv+1zc '{= _vI~TkUR/wDRgw}[IUד:2&qɯ=k>{mājӦT.\Ο=+Wk^gMj8@]^߰TnwCƏ';z G646>Uׯ/6;mn\~o{^~p{Zo/=a̗|ڳi)eO{_ւd=VV>G෥g ;z:tO^oqRz<`ݔt?%pW뻾i{^TRr'O?"{SZm]/{`T-7薴zi%+yѣɯABRz2_^Q{-_^J]\V{pKYOuOѣ|ץN-\>O#՟CO~} 7,%.SjӦ+^_wZ;wm\yO_~]5Y̟GMVMM_N=8/Y|m,éC)H|p~׺K RοT㻤%#`]6{_r矿:uZOp{Ov>Fh8~sn O{1_gk^_L`2Ōz5qTm헒^_̳'XNIsߵaml)%X=Ϥ`%w{W'Ud Ie %X|~hR#P?ӧѲzq{K=m]jSTJj$a|]#x4'btw `6MH*+k끔6oO8[}{'4?%-AB\;R %qs#Xx}K8 /KD[l\=kKD`q%͒`%A$[pJO] <0dquxeq?'XWk=[S%Sf՗lVV+X%Q2k8VK?'Xϸ%X_"Y%C,!*,, %wu?P;NfxQ&Olm{{bʔ@kw??3qbxO<ʶlJp(,U>Y^Y-X  ҁ`! @AA X1Y@AAЃ  BAA X  ,AANrrrG>?A#,l߾]=ZaÆ 8߸ZZZԐ!CPyYTWW}Zvm5wܰ3gNZt㊷sG[&7[e˖Cn)=&2jԨԘ1cԡC7(@$\A#Q,܋}yn2ۅ ˗/rJ57&naÉ^1bD-ZH:u*\^~[!Xa}ė 6UPPN>Is7ȷΥKo!4 4(rqC]x b Vd?^̙3,I&Ç<^.^tËtŧӸ[NR^^M~E'|>aTdl r<|;Sr 7t}ˀ`a}@g$Hv?zggϞp\ti|;_>vz9/utk?yC<.%ɾs q>|g(o"Ç/p 5S|5kq{8\"Tuת2u9Tb X,AA   AA  @AA X  ,AA  BA`!  ,AA   AA`! @AA H/  Ak߾}W˖-E:Y㪤DBܥ͛խުrssj֬Y#B$ܹs1:{l{C QΝ2ӧO_cܹ3\6mZX:\={6@.pnݺp&\9sf;6f̘pyĉѣG刘qO  A)S3f׸3x` G +:ÇW /4x Ezx<2 BxSvJTnϞ=k&M ؁ ,AVN8][… rKKKx _IENDB`libjfreechart-java-1.0.13.orig/docfiles/StatisticalLineRendererSample.png0000644000175000017500000003150311173030414026373 0ustar vincentvincentPNG  IHDRXr53 IDATxhU c11c0c c]J:珄4Mk5m`̑˪_m !$h]mڕf6N׺t?oRmc&ߛ7ǹz =&7>9u<.C!B<]B!B!"BA!BEG~]s #BE|~~z|+_1_׿ugӧ}}ĉ<џg\tlذG?^sA399rB)**2v2~a`3f`x"/yh/lgw}$w%1FD$AHpxNL sU1KA*YSAoxOiW^1;v0,+vh,믿nn޼i>S+`}-XNz-dɒ9}4###!C5փwЬ0ojltrg/_nO^omf~ӟ~gE?'G W͛~0~ץ<#oYjkk#mD[M'?r4_u?WrjjꎯS/~ {G~$olVOCsɭ;'OGm=`y"Q?}5<9qDgF`ګd;z^L$$OƬ tt4_:d~T?S$+~\ill9 81 {~E&!iK]]]ԃ:1߿?boCzt"ղ?G=^'Ǐ5rw'T9ͬ ?}[ ͦ0s^' 7޸Ī6 W=/T{?"^|^փ=Ÿ~Jf'R5~tKz oίAqET(B'?8郥_!TK?9SRRw}ssXH:{} XHE=W\QML=!z9GM`\ltuuzjR p!E,B扆ttR4cZ:Dg%Fz]\9) ڵk1a9+I;WrM=XsJfG9U;k"}"X"$ B`Y9Xrӕx6O{b%-֬q[(!a՛~O%j X$ПV֎ &3_rZTK?x-X},Uメ{rHxD_?y,A%sH` LJ2K Xxn]^M;:y}$|h{w[}}ݺ%/wNC29+} њV"w }OOO}?457C砉}NWKr`iH!5X"$^,Tdꫯ#: #\^swݳ~_n L` W"zkyϩ V2CF ԣ ͪt/ZNs~:uTKr[j,B/ AH=mMw'Z9~u@z+:ѺLָJ=`)eo{t/8 's~RVks%߽X5u,`@FC2֒Yrf\_ js) YY1Z99yUqj׋v"Po~ogk~ӦM)wre~T7R)N=`)Z^NmB@ZU5|ihQݜGusz $CbjNO2o:?X'LߧW8wZt霕ܵJA!B,B!`B! XB!!BE!B,B!B!"B!!BE!`B!B!J-;v옳]]]m֯_4555Vxon^z%yG, , , , BBB, ,  lܸ"uV344d1---ʓCZkeJtwwUVLgggk;::Lss3V)((VTTæ QJJLܰ(رcvPѐax~+כAgwemf;%Sy;+//"IvZH_Gz@V355eޫB,khFRUUeFGG`"X+uuuNMLL,ng"ljjB,+VN:ej%KeY @X,@,@, @,@B@, B  , @, @,@B@,}GV|# XOì\Y +XWOo@,H_|h-1;wg!šO7 XSOioVT`I$Y- , "󯘺SZ:cϼE>.ut> pdnk?7Ǐ,†V4Ⱦ W̦Mj^AC*װb4A@,#^egqIQ<`iQ} yJUJ`k( ]RzTw?3%4ѹuO X@JVޞt T/yH, @+K<"j-S񒎟[^C|`!X,k ЪAqu4}@,o߿XUT|^l^~B@:&BRZ@R!A }_3\F`E|*XݦE3</lͶ߷oFMo$_z|'9-Xill,רNK`Dku%Gkf;͢~, Yt)p Ml̂ ɞ=vu V3 %W---СCmt#cZ9sT٘++ZW'Nkdb;,B[8+pPY`;$7`Ѭ+lzU'wSۚ5B qb?da,A7VMvBA4+P=&ZeWR %]  z z%^U®@ut^yIP_=v2BڞqzrÇ/G 1F,@  3^eSBPz8!kW::BX^+'aTÅ6|7'`!XD-JH8Ʈ@, Co^k+ Bt[KY`@hhHCD55D', $hk7+W~aouC 6ԣI<`!X'cjQz`e0B,zcEKGFOz B6͙ZA2:66^a X?|]O Y2TFV '; իs(5eXNJtRMUg 7d.!C-3= eSӀhI+@BK :׊dl-w''J}!{ N6>1x TONdZAt,!N<*diD'o;cbڍ/ŃN^6}9d-TFE,(NHZE߫.pv+ߜY| ^Y`!X>>Qj}{eR/zE&[gi=k`!XA:QD:iX1.sK]sM&Њzs%,pMNBxtw ;3%!͒LZde0Cu\]#XV@Ovf(DUYvPV_ U[VvY D3Uj ݤk%yD )x DS—@h7Tj>3 ͭx;Y,B8QF}аz 4xkIf(n뵒H{vO>A,NP .h7h&3u ua$ʼn2)uE+ƹ93' u5|>A,3ᢋܿFVQټyݪĂ#=՘Bh"`s333>&yccc* Hڍz䊛3Ŀd +LjkkMooisSYYikkk30%!m7+qz%xoEŭ fdd$z,+#¥7[nt-gω yTRAܹsWK)**z܏9bz388hҿlǿ%cp^}~kժi{~_^\ێ`-kn`ܜ?6^l?fy73>#̙3'' v`,¦&+M'xa1C1 Uhb2[نA=IRMU$X \v[ׂ[X4@v+(`A;jI,4;J.?|fնV^ ޿zTPW7tqB'`AJWy޺iv9sB$:,Ansx ,7oTXbŭشR$Jr_4 ֯ "XH/:x>{ee7m ך5VD1YҬ@Yi9ZS#XX"J4)ׁMkDerb\==D@ AV`!X raC ޺'\+ zDKC:K93 5QM,7*;mI4z={Ӻ$D<,Z^+>~Va8GHj$Zf(N1ۋ|:2w67)oh`!XHu:Խ4D>CQW,L j^Vw'u" \6* p s`!X,7-}T0/1/POK-54,0>sбE:`$Qf0R \)GB H D4+9ڒ0uY%7妦@F37ln1_~yN V82ǒd&@,pYqF;$+ a ,[` X X¤9'Xц6 X@.k, , ,?677K.!XU^jjkk, *ZF,C:z(` X^@$K=W۶m3ccc`(`ǚ |k_`!Xk"Dx`SPP@`Ȉ`Ij$R) Yxq\C XKRe-**2ӧO&\~,@, %W=c._=^QaF7o6W̥ǏӃE'K׮]T, ҥK, $@?b*{Rڽ{w|͛O=e챯u}:7ʌ)- &1gL, JQSCPU;{-jii1B kok=SIz$U/bZNz7::@Sתm%cOI$m7 ,,UYڿYzG9qℭR|qqimme!d MXan._no_\e3Ϙ+f|VYyl_(|Z+g4"`` sIكugge%w%SDE"9TE֓^4(IlV59I*, Z"wѣGM#Z.Ӏ`AK$Ñ zz|&`3$b,[h3qΟ?oVt!2R*IDޛ ,|h9_zd[L!`g_nk‡ \p/'Kg0IToQ`/kjjʼ f۶ms U±1 rBtb׌pOsLc{_A0 ,(EdJtbwJ'vYw,c :X`A,D鄬5o& J_3gC|.XǏfS,&U7XG$[NF@>Ndiw[tƓf,o/6Dk1 @,X04/\>K`5u  KNlΰ#U`A. mBs4*}d _a, AOWᷨT oقTq̂LA\ `A}?{ul8Ym&u2 /b|~`!XY}Ĵ^svÂ1pL;=z,+kz?n>~[7S=X9WrXYƳ XVFNp_ H++ ,\%} o߮* {| `!X(ȧ{?:3t^r`!XI ZA]=U+-3AFrbŋ<633cZZZLUI`IB>ph5u ]?f-8">#XW}.\:bY|RSc@, .>l>5zW B,$ ۹3܃K`!Xh.blFTa<`!Xj c%Xb X , B, B,@, B, @B, @, B, B,e*^_ˋV E X X-XsA399`EFFF`ڵ+X9 >/l6lv"۾E833c zYt)V5Jrb:`lN8ajjjL~~)..6"B, , , ,    @,@,@,   @,@,@,@, , , , BBB, , , ,    @,@,@,  +233cZZZLCC'166`lLgggh477#X`% 3226eee Xɦ!Cc X $///ǜ,`f˖-fmfmݮ v!BHUUUeFGG`B!J6vOB!VIt,wkWE!B!BE!B,B!B!"H  Xv^{5vZSPP`JJJŋfMwwmDaaYh]FEMtuu7v;rlݺ !fʩSrJ4˦m@?guv R[[kz{{:uȑ#vwUVAf~m۶!XAC=d}وd~{/ onpɫjWͽkL^^JVq! m6# T7GlSWѣGCWpǎ3H]VV'xŒ^x[xfs Bu;iȐfݹ%V+ejjʚ~" 8<_?"X/̙3g(5XxۍS[\v6l޼ټ;9yBt099wvȓiѶcEʹ۷'tPBqN*z惤Dm3V+`!:DՀ {" X$hdv(EՁffMJo8M|0j<OB]v"SSSc|/l֭[g ̢E޽{͍7,B$~ŋ߿ߌy衇c*ٳv{{vSS;`B%Xzs=gO:e^j+//7nCCCv3dBE `xc}ܹߧRHOA!VxJKKM~~4>JXWzB,B5'|>m۶PUp}lvn !"V>9z] =88hg jX޲j>裐I!"RZ#~mPѺͥK|j|KCfbB,BHpaE5!1#BdժUV\`B,BI5OC{w<! XB!!BE!B,B!B!"B!!BE!`B2|]c!!$CEl !!0%"p&|N„ϖ`B8 >[B,B'agKA$,fݺu… ~ŋt.{6555,Z444aRfffӧMYYقR֚^󦧧͑#GLee%EE `9QTTږ߿vZ344du:W\!Jg/`e:QEEV*)I!4v =wAsQ8v9p}'4'O?uꔹ{MGG~Mkkg[{UΝ;g{,B,BH G SD9ӋLMMbP9c[oqFhy̙3,B,BHPKyLUU%@C\zII"{5$R2^õ}v366-!"dX {:t(w=׶&l4ܖ͂ﵯg% X,,e!![vS:u^9])ηkkg?$D"H$IOD"H$"XD"H$"XD"H$"XD"H$,DҦNOdPH$,dax'/;QMbguQ4{ee~{vQ3^DK"ŋ cKqd(_|Ev5 OO[`Eٹsgxgȑ#"XDK"I)sϠ3iҤw{ݺukvue_ːfl…ى'.ڽ{w6o޼pϳk6ꫯV+Pܹsٝwޙ^̙3s4wK_9ȸq_G Kck\ D$,eSh Oz{{!'ՂѣROwn暿終m`4JV?~ѹZٿ;qY1/gJc{衇,D"HӠodw7g?. |˗W [l!n` K.W+sU_y-ތXdhx_4w7J?Fu8gjfGK"HZVAha+3wbl!W]uՠm(/fQj2!۷os}O?]q \uuuUVw؊kd\8C֮][gq[HD${ @LgN!1psRl5ن+Dv]^=waUk`Ek5N|h`I$"XIK/j@-n"T f  "X|?gΜoo"Xl?gq3,DK"iit!cl|VrxwV%)~zj V2XCl72) 2XDґ;By?Ewl̘1u~̢T˒E)Jdǎu ]ɴǂk2ykJh`I$"XIoeټyg쟅kxq ~~>Qſ{~^)3d8Oj^5%jD"%Kq|o~󛊿ˡ*UV}RNZ{HFrW^yqMI,DK"iy)o=Ϫ tM-R lڴi!#R;wn(d7u5Šc)uos#HCb+7jǩw\SFGK"H$D"H$D"`I$D"`I$D"`I$D"`I$D"HD$D"HD$D"HD$D"H$"XD"H$"XD"H$"XD"H$,D"H$F뮻6s̊?h%݄%d#M62Zt3gVQ]v]SlDFFnzև~6X[zzܰvuG7cwnx%݄j~Gv85q%U'ʮm93{os]vf>x'MvXX|?}o+ XO>zq7mWH膍\ :=Z#\iݬY&1zo6ПXC\ӣ^ҏ;~8;uuVDڀ`[*8FO^{-8=w傷ÿUͬY_5>$۟ѹsS"6mv{^2],;_E g[7ldwd}\cn7{kcsd_zYֻvmW.>EMZa͚׻M|7;e yE'[=z4);`@=N_T?p9^>Nz~cYg<p-W#Y_>pAۦMx\dzo„}w`[gOy[UVӱc~6cƌ7@Q֬YķS-Bjj<<(K=' [TL RkͲVlvAX Ԣ)8 ?[nn/ɼ216 ;rHڣ\@6)weEKb!s ;yݺPR1{!UmK`tv+,O[:ޱ'Ɋ+ 38Θb5׎夞ݻl X7x B }0JHAF=srڴeYR,d%r"$[i?zPRxEL}ؾ7^t|l4U/^>l%{,{%Ka 8XǵVXdwR1?jez; H,ݮ+ttnG~T+1RSSSSSSS,enG~nGetӱlDFFn"X`iu&ԏM(ԏ` `)5Fq/,{'G7i#X[OOGڣ\\k%%br7dBe|`qӲnR.XrvL:[и~Vaʹx`}֍vf`#<{E?qsY4ɬb_sKk܄ w{FL:եP{%ՂP:gIzP^ xnM>~؜9TD; ({L"?Hu}LO),3,K@ٟx[^$XFsZYШETQue/vqZQ?6VQZ?Vj0ɗ-3]!۬=>x޺1) 5=zεX#E1i2y VdogaabƑcEenw~j'y/VcG ¶"ssL?NFn[>Hf(MdI}7ҺQD1# ˑGϹIdEq nk_.wi6Y?7/_mun&덿#=EF;5Qz߁A;w8= i馰'{F:e?&abdq$%fPp8fpcF2f{W3:Wl5Eh*O؟ybUcK#d瘚ÑGϹfɊXwf@*31>ò&Y`}/ULDR~{~ʢ6`a$8O7.r](nCؒq??)fUO/gFRaVCG2`NYku:~p8X>"a,!#xnanYO#5d)J*O(^q6 <Ī؇-NT^jUܜOdZQ+jco,"q,&,&nѢj%nmI֭[͙3';vlvg-><]o9BSK ~nG~Tk;wnݝ?>Ϟxl:OrlҤIٖ-[: V'aI7aI7وt:fK/ ˖-}]ҪBQjFzzzBV ?~| Yl=a:vX[8n4Hyr gV Ve…!)_SߒL 0ɓ~LJx^}͛_}3Uۻz=^ooGJ]l x䮻١>.F5+;su:ܙ93ܫeݱ#[я}1I֮.s *c7,׃ \ظobSWQ?^.~6&ye&iExe7R}39X9׬<($B~;q.[]W)XY Y,Qgzg˗|+V…{J^4n+ly&ID'#dYDjxaS"n()x޺1.=s"֙,<26H"x9lև燎a l08jK5f̘-ʃrȝAV___[,p4J0H Zg(J"{V^U012L -J2ܘ$5߬=U[1a78gtdX}\ >ŝd/g#xXB;Y&1c5LVÚ5a@m||XacXH,($A$x=;ʢ&6"XHpڽqŢEP-p@ؒqx衤&!iNw*jxHLVڱx/Sg5,)2w[ g=#=b&m~(gc2ΐ|3g% d^*0uqkX3%c6`˙Y"l`+{o1Vg2{dplE=-p10 z܃f0ASab#a`W[lӜ?O"`G,VɍybՋ9=yrpYZҥ}HldLIeidnvb"1q[J̔x vxj`a1SF&k׺dʸ?˶xPz;a9Wz٣gCcow`Z4f&q5(jܭT5T%hls(IY=1}Zm8?xlA5U/^[jsʇ:7g퓭}?EV XăVKGK KFld&ZF/݄%݄%d#A7EMK,ΤQQ,ҾtS?J7t`)5Fq/X>ڼU7O{饀Gykz+ܸm;cK}IKvjA/ !Z>Tأ\]֥skք;IqltSʕ8)S|Ж,Ɏg"e"X-Hz<x#†"`Zcyڣ\.\Ģ0 VdokWC<G ebQnj#y/Vcb%rUZjj¶J1 pL <&:&lL A~lbvzou1# ˑGϹ<[f۠)Ȫ}1_y>8vg}5[ƦzoHO*Iah^(J#{ 01Dq8fp=2 YǟXܹLF? ލ߁gˮxA_{P ̞&h*̡_izئ97~ky E2D (XĪszjw{kK&!eH#crbxĠřR`ċaã3X , CjQ ~'RʸT`/T)Z+2fVL)1]EIg%G6}v„>ߗ?O~KwwvnʔP['Oξzm3}*zUs6oN_}3ϘWoxy)u=;S{/㑻 Wۿ#ҏw| #Κyl`3gWxc_>f37?iR?wa#A?Ic~~;aCx[}&XV 'VEBUSnS6Nln^>|ꩀGyk,47nsA])YR'X|?__uU({b_,Cm/ /& ӻ~91<,ʐŢukP֪)FVٲXzX]SӍmssL?NF w |?yrMds⍴n3Bj){k,?t軋ۻy"0.(m<ѹil76.:l# Gz$5i icVdHY򪂉Aab-V18d31#ڊ 9#+sPVÊkȈ'^F<ᱥƑLl٧ÑGϹfɊXX&(x13b_<ư&Y`QIHSa/cώhɽVtP8 {aU誃-]0q}|@!okPJau pԱN9;t-fxX8pw<3ei^s-f[lr?bsd6-1~ q"`ִUNƁv\ofVkUnAvfX}Z+A $ Č 2}q zFl*gFئ97~9{}2xk<2`Jn^;T 7jg= mfg8xlZ3/5r&f8g&N'Vx)^TsVJ׏̘T /d_x'Xsf1eq&1FS1&Cю:5[#u+!ѡJՏ)qŠ+TӬS>6 <Ī؇lyԋbJi]YdkOf:uª6)oeTPMMMMMMͩ`I7aI7aI7hMkv*ttH7hMK,ΤQQ,RSSSSSS,e٨8{5ӻcOn֩XҭM皧hslDnrɓ]S<*ǂΜ9e;3{v׺ Ҭn.b4)d]-bqɦu_o-ڈGVꚛ|Vԩ8&SVk(dٰwzb=dF\+b``-  Rmoڃl6m IAr?7_uU{M?[8`q7gF^,'nJu=zϵO^}5;3qb(c~9'`.]}Ǡ5i.:a5/rELeplyC QsM6!X#U4H/U4LPބByRJݻl骞I5Ub%6zfy+Dx-O{k 9G9L/m'3Xٮ'Q Ղ^8],V<[eųl`Qj˰|nԮ(߉reR2U/XQTCԨ[I[lx#%I{k8\n>M-oM8Czs^Ѭ1c^ۈ`q/Q4PB+XnVq+MY gLf +{u Zwl[:)c%^T V bQBJDVGN͊Ř-| "gMcsWR=xAJ" klԩ;1+ ǧj[`5H`E{,V7w`[IJZ|=Omt ܷ֘xxXƙby=zSVۅE VӬ{#I34uVnXqeC jkR?Z5f8}V~=l5YcCñ}oNi^}JX'JxQ "F%g:}q~nG~aȥ^g`iu&ԏM(ԏ`UgzN&G^X%-Fr:K'\[#;y=ڸqc6uԊj}( . Hy}"/ܔ)չ-0ɓ6S|8;sfv]Nٗ?5ے,T߷u-^Oĉ'jk^&Mʎ/Xʪۿ#~<;.ܿfϷKoW{ߟ5+\}wǎЏEǏ6o\n6m2ǃlΝM_쟺xϳӧxZ ֪UBرck= =ǣslrë ywAЬu"wsb@ijZ},2~VY* [7lĪHڣ\C=cu8`QGcuB_E'lLtmmM\  lߣsd eZ RǸcᤋx86gNڔ" >IM9U}jza37HVs'أ\c|( eJD}'_ϛg dqb瘵 W23Xb`uuuUL]Vd^Yaz_EQ&z[![b߉|x벏W٤$g VԱ Rc}GcJPP=OZD+uzcff֬ذ˳X!h]& veR0qnV݃5f̘mڅ`#g5h]d@qXVe_\ X0)nUNOY gLf cI쬞ٶzuS'J&ZX_-6Ocղ1x`F--RJ*%yYmE77HU=V8LcuuGҥzV/b8ԸAasrԤpl_}u;s 6D?fX-6V-ewX]XV3cJJތMԃw?Hϛ9)HI1X~1-Gf`Ru =+S>Gna"l`EG[J-7[~8+"šJL{_ch_`&wR,ԏM(ԏDT襛ld4& VgM(ԏM :~MK,ΤQQ,ҾtS?J7t`)5;J6oH,ږ*E1uS?JǞ6ڏxlDJp{\h %Jtx\ (kQgyfl/֛LE,n/~{sFJ7.dYisFME W{oWF^2aQv Q;ȊӏlQkzp%my'8a~"U 7MۦM l8dr L8YVL)l֬1v3 6bQRȒlyڣ\weM~>~0(-^Ȭ8ՓOf' ˰ 8>s,x͉Uc5eڄ`KQI { .8{ˊZq۔/N`V\i,U!pXQt0X80[8`1O$`PJAZƯRF'VRUl5k'#es +H$cg"rhP.z~>ɦ?yLDٟðmԵJqKgڌ`q ! z<IL+W[ y8wbOv.$X>IBV Xsb:H! /0R,$X*fsAzܭ|d)Sg#|@t Rc*5Ŏ^г8KsUڅIdUyS rR/Ux]2C%-[>}8iY__,^ c3x^X]K=z5Y>-9Kn =[Ǵ}w11˔|xժ bI`[U`u=XB6\aTR?oܶ%f$^¬Spl/fzxmk8xN?HGأ\[aTŊ!w +"U̎ZR,݃ղw`m`- ϾLY︥؈7箻^ ;i%{k1tRfQ`&Ēn’n&-`Z& VgM(ԏM `i_\Q ukKnݺlΜ9رc/<[hQv糿˿ ?<ю; VM(ԏM V-;wnTOdӧO=ٚ5k~g͖-[3Xjjjjjjj:5\KiӲ#G ҪBQre ,Wg~knX{>=Q>_ΝُqU ƍS3fESg|V`-\0Hy}`,/֮ܔ)5,0Ē%N}wYڵޖo„󳯟}v5މo̎^}kfxLCCݗzlۦM&xunҤ9' hr*y#wngX>˗) V?>'1Ҩk'VF-^ -3dzjPf56~Ƌ<}gЍ>g14>d5uej8Vߏm3'EX#~'̩P0  e1cFvAgƍV 0XMݪj{qhj+}{/͙ 0&|ȠO;9mZiy fy A} /7YB?B͟kfk3u*/P r+nlЋ!p XW_ݐ~X" {&>I{kd U윀wE,"8L1A㼵 >|ngGIɕՙ(0*x`0/:IpGzO?,>E rqEXQݲhlѲ"}l-A!k;bc"2!X( f=gq4R4YA?]<;t-nx礧$]j#ߘ8KFCksɺK+WfgΜQ-BM"݄%݄%d#2݆ ¡sE8JlDFFn#rȝ6W=K VM(݄%݄ 0/<mZKB^y+"t2XZUH7tt2Xuĉ?!.ܵ/.tvBI7tS?vA 馕tnG~l Kpj1,555555?ծ˓ SQ j'ԏMnmH<հDZ3 Μ ZWmֹIBϭp#S)nK͵8U5a TŪp]Ģ)E{{- Q.R=6o<[jePpۧGjXHأ\ww? B\ eiFnNCѪb1nb}_?ߧƈ LU׶<|/u{w/YV,ڶw zOo˪r^UWX f$\`LEkGE$Mߏ.s/_pw6l_/Zd_ЁœfTsŊ0n0[p*-|G\u܋h7 ߵtiҪd \8{\Vk16lB 8kLXmdp/+LVe$2 )%'vY$^!>GϹbcw-5F[|-cw3{YNl |"VF Zjç*H?T?Z5f1뱑Tñf1kxV2XKa'dsw,ռ|?: I,lU$ckіɽ hĺ"}5,pԘ[*HõGO|8[.,n)ۿ`i_\Quk(3f@+ɓ^z);|hk׮&Nؖ,bHV?ƭgRbk#)0c^8\k'pR\JjxM~V E)=U&Xcǎ Ī(^zi[g{4XBbx`Q ˳=K]<0<|Gl°it<:`[.{Dz 6dxlɒ%UlEYpaHEFZss^Sī_`=R[Vlxpz6k j)|=3xK FO,H 7HՕҜo J^b[ϘԵ^I9{lokxd=,|WZ~9tLG,bXjz*ձ` ֌3ށk̙֬Ӗg[ EV,v<9t~xsx>Jg:`U:oծgtVK,e`Ui=XDQu0i(^pر@xYv=IQ K K`&w*lDI7` 2XZUH7tS?J7a))KMg'tS?J7`)UtS?J7tS?*3Xjjjjjjj: !ټ^FM^K[`&{7:&w/{M3EZ VݵG=`kZ^,0UyMuZ-B/{EwUExp#k_oѠK%rL"EUͶl[e6wfX[׭ LMqamؐ<\ʕٮϾٳ/Xzz*ѯ/.X/bGuJЏ>7vsO~};cFLۿ kvx$qIf~|'<c'CVj-A7GOB礧xۣ\~1f֬5}x= Ɩ,l,0-H)*D ;S1#e0_>$f`ȼM5g,pH LJs.U`VǔsZvw2x?X~Q6o6t6+!`,M"ԏM(ԏK,M"݄%݄%d#K`,enG~nGetKM(݄%݄3X`iU!d#M6~nG,RSSSSSS,enG&,&,etKMXM6"ݤ``)CK]^,pԘ[*L(XKa'dswc'P 5 VƣDN;2k+.]o9Bk3XLdu?+nzG:WJNNhe+~J>ŚV#`P #eZ$j5; ֘1cZQ8M4)۲eK VbXUDLu}.+~RԲZ|AAbƭx+twXuĬyo&HR4fx*G 6Y ]+{/as#xX׭ EɒE2׌=z5,|WLHIN,}$ BmU1bTx1-3Xe,wn-Bb50n ǿ=;;EK;vd;~88Z؏p枝;s'|3kVdr콰90<+(pXQD$O/NyHç˗' n[:?'+اvsO֗=Xe}ҏ'zl/F<6c``Cډ=ϵ܏bha>3ڻ}{ }N̘a;;a /MnyדY¦}F[`@1ĶGjXGƏH_!LǎHb+|cd>z|_<{*xo8YA[s{*>|п}S\(;.h'ߏz6G0;;_ʷS6/I.ymcvvʔXu;y0%xsDX_N=ҏSf6 ڟC1rdA?,6lhxN:p{^of>=B>ce7xHWu-==sT>0何 v?<~#<,GȪCz׮ 3}l۴)>B_%{0~쿒8u%d8|WtbkVS7O<~nvӭ)yGau$* DkرzPwH7tS?J7j`M81;rȠG?=XDQuVg͖/_>p'[b2XZUH7tS?J72Xù|]Ã>5S-B5555555ܕLQR-BK7tS?J7a 2XZUH7aI7وt(%c5555555 le VLjڵn+uVL0XW# yb wܚds-b.]IJE??ne l,@JV c'O{8-3X/[8A>9mZZ3V&V}cF1kaEwF7<E޲m5ZxbfǬs/.Z"޻6˽כbxŴU {P乘YNEhQ-BbUleQ+-q;W\YU4X0gPg\X`vJ 91뮁hjLy`3`+8' 2{Co"v`IKALR=z5Ƌ~ca}e XBb^,Y|O\o7É}\oT9n V,*= qn{M7 b7߬j`DMVLSbRɝɍgՆ~>E8&!P8 hB*f0*g+~'XĊ6RTO{kbD,|o@S׋Ɓ4).BeSwab(mwdcVޏ""X-!N dԏҭG>ͰȨz'^5=XjjjjjjjK7+ttH7hMK]^ K KFFn"X`iu&ԏM(ԏ` `)UttH7و2X"XnM(ԏM3XͽVm4/X[^~mk}Ե} ñ6F<;nIc&}5S?.0W²03Y~.kEX*f3?jGRAoj-" Yuwn04D4n ,57%gZse,w/YZX|7˗'Xk'V-rX;i{,ϵ8 HoN"yVxG S;$qONziLT$>1vIVJ@y; ~w [%Q.X- ;N֣zdޕ :'-d,3X71@,}!()1ki Omf0+ȎNQ.V3QVX*}8Xi)}Ax>ɯ~e^̚zdd x8`&v8-2 cMR Ks: V%o߾lΜ9٩Sڒ`y//rU\qV[ X4& Xfcl XDqTe!;aۀ ch9~x޺"VlsWs[Q`y!39BI+w^j^cǎe3fȎ=Z:b#{\_Jv]m۴ic|XX}.SgL?B;'gE hn؈Gɫfg&N cgQڝBMRmui.:a5τOJ0F3]vpEb[Q.\ScʏWGߗ?O~Kwwv>q,pLn`O=ze3ef{{d''/)^ϹI@cj^NAҏ9Bv"'gsKv>xݻcGG͛]}v{5 9ٳs}`5>x|n#~-qx6ksZz  ֏s:K)\[#;xt|Zjjjjjjjjttt:⚆ZۀCIѪQqX],ΤQQ!Xjjjjjjjj Vg՝9CcJz,f=xXwwԫ[,%#)o;o%5f={Y/梞8eƣt 8\:^#X'M2-E=ZHJTGv Y> wYac,eq&嗫Nk*3X ,e6%U+1o&o!yZzN̪EW­)ƴ:rcW bֻ$ƏoJVNz>?nB~k{d7;jaANNj>z.5E,kLbi~H\>_,JAe-?n?'L`lzʉճ&dMM@.dp)d@дJG,VULv Xea'H !wأ\+fXn_C+'$V=q>]=`댕8ze"X-Hp8C,VZá|rb`_.'Ozy농G&!=<2Wmw \i1 S+dI ,cv<9 cܦjq$0!!'GڻGc%s:b۬E<&5qD,u֍vr֬p#/{kяXgtpF{^`箾,Y^D+F<"W Kk37;v>鉷gNW<6SaKB`%$Xq%K.Ǐ7䴼w̅z}*LV^{8{(upv„dCӷ\jyzҤ19_˖qȯ~ez(7{h^<.@.8nkQ:'ub 3,a9ˮ.DAJbq&*b0j$)bFtJYrݿEajGrsj#箻B5xŹ7IiTVLFK8f1}?yr(HXLǭx5B$VGK4[E,ngcă~n\y3/9x "c4  sfUG +u$3gN6v/-Z>|-V .s8LX| jݣE;zՎJwof 5<$Q7s1xZe|Y{yb1+V=z5A NM.-r<(Q۶?ǿٺo[5f̘Vsf'ȦOv,(#i}(1(JaS+U\UJ'3/%KCBWL1T˗'=ZXO֍3$(rsy}Dymee;tKX?GOb [`k=U&XK/m+՛oR" ӫyn|vsyebG{,YoSS3V`AX@`=5 Yv"Xv@y"㬗/9 `B۶iS ޼UH#GN3K \X+31x޺a#I=zϵ޵k3W>r͚2ۼ?^bpv8,Ɏ/XqbLW_}kƍԩS+XV 6S~>y[s&e9َ,d̬w$wxmÁULǫŊlwo-^}&Bc@qƭS YٱG SqΝ0?^ks:w箊g@vUgÑxaNΚ,Rybq {kяC>x`oHX^1!3[V Kkze{8FB7O?wsր7*|wwmb],DqC cR Cg$XqUȋxX0\ V>T*OݿV0`rIgJ̡VLen]OYlgg&Lxy8+?=/<l^g 77Ӈds CbS-|mČa|,2X9Kgˉx$qe:!hONM oå`fMס0ё:mPŮq^Ԍ'ޑ|-<%t,qke:Y-&a.pz$ HٳM/k\˲oX{$p` {,2o ǺlN9ueŒ)1bBDgꌾ$HChZX|gR3x?ĪWs38`^s GܖYYpOYW~U,ƚqRgjut;2žW\1gϟ/2[hQ OcǎB/RL;pL9Žj}qѪGU5 UU cH&ؤ-[2X{`EGݞZ&WUuX}Z>0Pc˖N"=^"HWZ/q7HV)k 9Ғ%~}ʩ]̚5+Wfq7͛ͱ'd r3Xe5-w"GxlEztߺҹ+zV筼jS%yd0"!hf;sVֺyyfI{k 5[X؆W1kR=| kWNgı#X]vE[埵:zѢʫ3/r[o :bw#!Xm6ejXYunXfF~dxOH!^_?A Nv|#Y"G*x>L.\ScʏWGߗ?O~KOOvnlo ͛)ɟ2%;Olk<}8|YWo㏛33f?'WbmxgZ*n_X7sυq4{zGεƣ͚xMݝI֮.s&ɓëoڴЏxy=ʟ+Ղ73ɼ<_p''V$[ڈH{uj\jXGf+G:5n8"TSSSSSSskG~`)¥KM̙HZ >4k=XD"H$#-.H$D"H$D"I)^ߠhx KFtS?J7lDI7tS?`I$D"`I$D"`I$D"`I$D"`uP +3+Y*uօ+ǎ]~AGj8Z`]65kV}#_TZ)%VxȮ]o9e歪[%,l[o馛no[|`|bŊ0j' ?RMGja##,P#²#R'X'֬Y3˖-3곔XsͺHxlX4 k5G ,HҗհRSx&Mmٲ,G X'O^z!N8L|0 >~x&{Ʃ5,P7ڏԋʏ#,H-~d8vЬeGj#flӦM P\e? 2p}^ziaUce˪ԩSIҋ`U~U w3burfR _#>kMq*)cY2jlR2)g ?2j V9mڒi5 [cX~}H[醑Ϙ1#;zhDl+2{衇3gΘqEڶO٧LbV~6l<ْ%K.䒋19瓵5-w-_ҏ> ?RƳ#e,k?RƳ#-)cY2^ ?2j V-N#X7n̦N V-eҩV͛7//38oݔ8΢Xvw; gx 7gHŷ~kGmGҗ~2UO~MGja#վʏ,H#eYoJ?R +RJxV~J9+YZ#,H%~dbz7c7YXc%$!}9wcƼb~3)N-bcM*K?2M9ka# ~d(RRZX~d(ݚ#]"H$$`I$D"`I$D"`I$D"`I$D"HD$D"HD$D"HD$D"H$"XD"H$"XD"H$"XD>>ڥ|H%D {D"%H$u uڨ79C=NH$"XD2\h,d xK$D"4 }}} 7ܐ]ve̙33gΨs$D"4*ǏƏ2W?OcǎS$D"4#*,D"%H$$n;6vD"H$&n 7|3߸qcx%DK"H)e( ,~D"%H$uJh E+ *taqfADJ܀NȔr fl,feG\RJ)V|sjNb>f~.f3FyQ@`,X   @`,` q  o,X^@`zX^@`z zpo=<2\U^_\\,F 9zGrVU ,X  , o 6CCIENDB`libjfreechart-java-1.0.13.orig/docfiles/WaterfallBarRendererSample.png0000644000175000017500000003766211173030414025661 0ustar vincentvincentPNG  IHDRXr5?yIDATx pUYuEDDQBLHH!@g*AALeeYp,ūŖk^ |jbTM;3ϐ̙ڵk}!iN5DZ/v܉`B,B#UVX`E^x!mG!"$ҝȱcd>P:}>IIIr9lk۔`iرɡd`ND tZJtbs~ʲ9tZk׮m;w,!_eveɂ o߾reُ??# c:_J}E?.K,>}4a׮]mP=X֍#G̙3Y޽{O%;f͒C6n7xZU\#}C mn݋ٳz#<8РA>#kzH:t`S\\LF,B]N:Lw ,Z(]{GMG{H9c{"]O$rr[vB%UYY)W^yeP T7nr|ɓ'#z ʾ}>wa8p`6E~{/D{MK/\㨸JEH '|"999>t:o=77ݻw7)7siI:|ώꫯ_^駟Jrrrď,}Hv{iϗ{=*"y~:MA_ƍ ҩDt{.\I/ap!i=<[}x ӧOYN_sf$ *!!q&XU:bb}MvvD$ ĉ}kowGCw"'z(Zv{?ο706~u\#*(p]sC~Ws^>_>#W~&1u&>W#"Vkby_ +{g ct9}K Q򞯇@ג=Xn/B9;,o ;w2Q $ ڛcT:6W/qklP%KŜ:VJ'?H:㴴wM-*2 Xı`NwzL=;T/NxH+ZjNR;.w_C0_%ˑ,ez5 wm0 v1vl7:X>dD~iП2=ylدӽ{ln'"$N%7|A%X+ޥhRׯ_uon,@YZ=>}tPnxF˛<~z/Q'45R硇u޶"X"$Qӽ{z,gD|=S?:=@ 4pY9tg?s7/q? N!v}hF$ nPEx=HKs^琠Կ*f*k~x- X X>Ɲ4β?^NGz, ;|&s5YeqD}]C)sv{9;ogpYmSjkYHF@`{gux2cTu,-_ͩ{Ѿ_Nt;Sf9M,``ONeW$cm unS :^n"漆HJ{:F,{׿G[zu9[[Mt'9"X"jғ{_Z $]xU>t̓fB(P,=++;o" '=":NJSR)^3֢^릗GpWwt!0hc=נHy̑D}^9B_R$(su/ R0 t=+ XB!"BA!B,B!`B! XB!!BA!B,B!B!"B!!BE!`Xgzܹ2sLf3|;K.7x<`!X`!X`!X`!X`!X`!X`!X$#kGJW]׿aO aY:%(FJN]`lE1RAt, #%nHÞf0e=`!XC^mI1R& Ct, @2=-` h5&N#ez]`!XndZ4F1R24BZ~PhDBHQmQ9uc p#>$(F#u4j<\Ү]y.(M@t, `oV{Μ9cz;w.=XPX[(I#eVݨ=M0e-+ٳgɓ'}`?k'`2.AW.\({1X*F;vgzEXVV`bL΀Vk,2 O:X0v)+c/H)ְ :dfK/W7A,72vt)u4w!, 'W*H`!X` i *W–1cߐr=2qZG%ϩEX?UzhTC X~-?tɍ2P8f5A#X`!XMf2lὛrnC>B,rf;gˏvo?@:pb/B>W!,k9`2 / ;sU$HfPӝ;IڡgR.`R^n C X pQ B,~*UE^O`!X@ۇ{Ǟ[CX֓^6UocB, p!dRmUۨFk(B\ꍒF1V^zz`!X66ToǪ?R 00e@BeϞ=2|IMMtYr8q^ ~(.cekV!`!XMS\\,ry9{l۶M|F ).c2-XI`IIIAW?/)@=D,+|{=W,-%//O6o,@z +UC BB7ߔ1Xީ4X9x @in|bhhرʆ=p07߼M VEET[[6:NKӃ?ceg&uX4`Akӗby``G1V~uX1?Xy u,@,p#( -X# `Ak3b̦ndXC 0`A buTaO3 `!X)J: XQ $`e!,Y fXyu,@ZZ.KKKC &Q [F!V=R,hIFR=SK)ĄLȳ: ,X`Zx"EEEra bBXYYL Xb;Ċc A@,Bp#c( $`CRCB R>gȂ5XR)QeeA@jiŋKjj*=X` ceg9uXre˖qO1V2ZnyC#]fB ־=80K;={d tYr8q^=c6l<):Ax;C:h OT*˞e+e$SM@سcuQ-3Y,@jʹARYYi˔m۶M|A{e׮]ݹs#XЄ⠨\:4 &H׉]/m/ }n{%\G9=Gdy4uX6cњYfIMMM|*((@ 3⠨HMCxYzWq/wӻ\]/^sz.ޔ}LzRe&** X`F{=W@`ReX0`T4ΟD4C:At'\ǏH2ds3eƙҿtvY $`CVXiӌ3䭷ފzo5 h3>_JJJK vtQsmRk]+cm͠交 ʔ[f멏L'c#:-1{B9|p뫨{ӃmSTaNx+E{ q]!BzJCORD QgrI1XǏG .w+&OK_*{ i7`;!;7%%_鯧m n Ak²%,v z;vgzEXVV`A\^A/Сs[~}$۞? %ݣtM N4Oo~@|L2.`!X 2=C}u u{A + "Jඟ%~*ڲ`A,'g3UuE`P@1VH?F#)ǩ`҂jĂ41 $`MC XĀc ,"B1V=V:}ĄdR)VK ֺu$770b X` =W{/?J.D  +xB V!u-X_}"X+<󨃀`҂5c [d >|XdĄceg.uXCX DCee%1^a X`e}]7o}HP]2 3Q99AH`H:X`ceg6u,@ZRo\3vaOS曭1{YdҸRVCm`!:rw`2g'N؇SSSm9}t?^w< …)`{@,W G}dvZX-*X*lq+Xz 40KG9QQI㖕uAU\\lG{T6l [lKzqKz0= Xk̘1 -U*HײJNNn}JEEEܞEum35 aYeM6њ5k|̛7/ah%},U,Yb*X'O\+ %X.`{0#XSxIZؒ} Ac:zdܹ;+K4C -XNП3Ex’~ Ac**g5/dٲe2 ,p`kLC^d~s, ֒%/`{@,= ,@.^hԉ.LC*XD0ew`ALBt%w%`{@,]A !AEO4` (`{0#X`,.4Xr r`ݻ> `&.\h/KQ4H4`FΝH ك2De,C`B222W_ ywM" ֽ 0k+55UΟ?6ڋ(|% ,=sLmI 0=`ZN*..[]ϟ0䓖w!hB\!X]V>zE2{J0= XkrʠWqןI`Xaɰa3p`i'fj{QQڵ+.4c 4`!X\݅S .`{0#X(,`{@,  ڼ`GÞf,J*-$%E4`!X kJKRS Acf+ aYk, ,@B%X#FVJziK 4`!XK+=]4`!X g,9R4`Fƀ!,k5(!`{@,˅j%3 @HF0= XBzYK Acfk4²EEF7`{@,+@,Kg;lذAV\i˓R[[z%3@"HRRR#پ}ڵqzΝR^^5f!hBYfIMMM' .kKrr Ac`E(Xi(~ œ` (0eB+X9UUUeo Z=gرhifرӰC|ob~ӃeKk8Cmb߃1=X Xgϖ'O?~|\ ڵ , Pva9}aYYY V²ALu, ,@{ n%&H0@/`{@,˅~%z T0=t0e=`%`M(`{@,˅L$`{0#Xi`+kdC`!X.2KL0=`Z`%`M*`{@,˅U^nɴi B\*X3 @D^xck㛆, r`M.P 4?7C˛699GGJ٘z4`FRU`%`m`Ɍsޖ{ӟvAy }\yeo ,̃F^74`!XKkL9*WG|&egχ$)i^s$5u=^^n@D6nHbNJaw42Kl:tQ]$ӧ=c*?y/jKwh2l2k#ہ, r`͚%1gذ ⊞4V. vɓw,oXݻʈnяKf9'3gJsL#ہV2²B8DغoKTNC$9ygC̘q uq>k3O+p,@6!XDM^Pp ִi'?:mtɑ}iĉ},H @8U֭>O%J_uU&?ke BvNN=%z͕}}NaihVz~D&Mڞx]YY``` m)uB]JY.>we;u%KV֡ߧB{ls,@B;Wrh`%!,ke\E`!Xk4C@D,:U4`!XKkC 'D矷ddC`!X.I Acf>0 ~%' , r`0e-GA֭$?_4`!XKkC`!X.k-?^4{sÞf0J 0={ B ,+j{Βc Ac`P֬$7W4`FC X X`?IJJ H VN!h` CXV u!VzVdC`!X.lC `]`͛>.g-=Z4`!XV3RSSc Viii@rNIII`IUUokM`ee _ficm C|ژ߮?󒚚=XVY2j!6 fzSXRzZ*Olp)`{@,+KeesraٲeK\ 3X!`{0#Xw! Ⱦ}d,RQQg`)`{@,˅WriK Acfk² X"Xii B\(X+WZ2b!h aO `%`$ 4`!X ԒC aYO X"X/`{@,˅S$' V?0@5|!hB, ,@B±b%II3u²#X"XÆ , r`=%C V_0@u} B\(X˗[2d!h`EV B\(X˖Yr3 `%`s!hB, VI% m`zJnC`!X.K-8P4`!XK뮻 Ac {`+AkK 0= XR_4`Fz!,k!y!hB, V~3 `%`-^lw, BW֭`z JW4`!X k"K0=`  ,@v!hB, V3 aY D -K4`F!= Ac`P{̒[o0= XRC4`FnCX֣Vssyٰa\Җ'6.kKw0= Xao.vj޹sǭ`u&`{`{Þf0u5k4N8qB R}Ԓ[@c`E& œ`h`uCXV1$%%E4/XYYY5ݷot2R~ oLp_f2rdIOl%1NO{݃E!b:q/Xgϖ'O?~<!BfǎN29B! XM,*"BB!"B!!BE!`B!D@?5D^mK,r(>"_elpm>w&-ZzkU1fYn/i\hu'bvm Z݅<6A,+koKrrrlKmָ/zkgPp?PSz~bɒ%RUUe{}cSMZEېʀJs{m4O>m˅wܼy|_5|4ޣ q~c߻t>5e邂&De1cm/ݻ{쾑})qwʬ>sm^wrرFںuk5knPL˽{6ʻ\BBKiK[m θ~zv޿Gς=p<}RrާPP;P DHw7;ߠohtȅ,%T:sW^755Ho_kPi\7CF]W:} {'݉nkȈHmɓ'7m/-Qom;6ՖwG4w ʜ؇:}~g#&Tw},w~K1FN7|(o@#]Kͭ:j[{v> ]*{"}onkʯj,gY\UD=yvmUt/*ͭ-QP#}> h,sVDB}nB@uǭ, KW7PІ[~4ʇѣ?\fyh nܴtG uPm F&7o^esgZǏ͕ChnR)ձA-Qo#iɩwi+XzR衽P=Xs d{{םpAĝ`is[?@,-[4~ȴAux֬Y[~ۚ`UTTc cAFE8,}_~^UK `Is){`mzoۂ`x@+T=.}u,F;}/۞vI׷lٲ6'X:~W_z^zIqK6+#^QXXhҝ/ zo8M6܄ށN E~Xuj#D}bY!SJ.Sgсz)S&Xڈ8>}~uFVo`ZX:PՉv;gZW6}CmA- -½_zaOǁ9sȂmPL둞 H֑#G|zz-筽zIqKvauGZC'g¡'xEZ|q'{M "XBDp־B*m\kϕ"tu}HbE/A!B,B!B! XB!!BE!B,B!B!"BA!BE!`B;îp{8 ooedd… e޽QoCBA! /+W_֭[̙3ryyW&!"D%o\e;V۟={־ݻy*\%KӇU$T"Yf͚e/$'OV,9P0Qɓ'7>}\uUVVV1Smr؎)UG[{ >BE`0*7v'`;v̞WTTdOϛ7Ϟ/i봮3:TthTtZe?g]F׫2=4oQ .gޯ>iO?cqҞDo)~5kP A!p^mqz]t::t#"*I$.:[LgggۇN8+X:UVT(Ф_o |I޷ u>PZh=5 !"đ`!Ppzlpa;<`!44gCn G'h۶m'4p'<`iƏo?=lͥ`BIGoWQQaKZ|`sl`yGag׮]Ah7@&y_}Uu;=aّ.g!"ĉ`9wiO_޲e:GϞSѳ5:vqrB%LE$RRhC`:<#*"<=C1M#Jz95+d ^&Lgz8Ϲ휓ʗ_~shRO X V0]eTthJVCWzJʋTTJTYYYvOPqVG6},᧒ l߼ysUPPs.磗2e^+Hs)gz#d.ϧ`Bڢ #XRqz.!" X~|뭷zovԟih8.BEiC``sy:ʹJN1^-]/zQUBE!`B!B!"BA!B,B!`B!Q?df; IENDB`libjfreechart-java-1.0.13.orig/docfiles/WindItemRendererSample.png0000644000175000017500000004417311173030414025026 0ustar vincentvincentPNG  IHDRXr5HBIDATx pT}3f4ͤɤm&o;mv2d2ma`Dxpya,!X &`G\G $(ز1Xla9,Y2ؒ-#=UWծ={?ߙHs3H`` FG ,73<=zt=Ѐ͛7C xFLI:q93|{g?Y/~|{3֭3yccҗd LEEr '_\xx|ܸqWWWx\tj*{{1ǯ|+4X.ӣ9!`.کS?'HG΄ lnܸ1yG7w3gwceɓ'[C7 1_ә𸴍+bf͚euױ|7hfFڑݔ>WǧZz=Fc޽z:n~ @xѻx׀o}[qMFN/= 9!|tpPu mz2i{GM6%WR4XYb5 .Lxz Д_PE W+a+EC_$ER5XĊԥj^TP&J:s,X0(zg$kc"N‹/8x~F'\t6}7`&:;;D)1zghC#}R5Xrd>%lG>{p V1y?&JĮ"`i-#G~cz,Q1!@Nk:GVmV2Xe1ZP9^^n89Ҝ> NWXQXZc=F y]<ѹU/^;E}`EN]4\q_<'N?C_jZ9^((?>6+:K"b` PNQHx#ڤ${QOzW/(jÉĪ5ܕ{]Uu8+ZcǎlTgc۶m5 Wo=m*B0X8X#zsgʌ~3eMQK?`y.8JLw.gVP,\B}}}2X Y!ނ :9dd` o-]e~b}TeWSo2S&ՊWG^մ[tDfK-mQUHO`u:^Mzqg*L!MWoEGVrm*`` ,  `0X,`eF]է̳>x677;=}`f^z%NRAA#A  B!E `0X`0XFG>Ї,!b0X}}0X,} " !B  >>h>@ E}0X,FG>F>, B`@4B"X,r  }}}B!9X, ǎ;^S[[k*++!;::b>bt>}}' ֈ#z}۶m35551#璃>@A#ALF9s昶ۭ0kSy.,FG}Bk MF7璃!K^~V*//K]oo_p!}}G@|ևV#XJ`yU'NTK}BknjWF KBC[!\P" u Jϐ<_m}0X,?7fsl>4  !~`, }}|ⵒ;y2цb}}sO ͍)SЈ6>, }}`c}3Xw܁F!`a l2t, }}Gf>4\]hC`1>>۷o_]zA4  GA/BVwt͞mިB#`0X 9g5Mk֠ , }^Q{I]̍S͕ŋEEш6>, >2X?!\1:[Җ-hDB  >.;i&k?ӼiddwS;wm}0X,] X_ =DMjzP{ h! G>ry'%@ۺW`(VL0`>HIj,{c W~;F!`ap>؋.mT%Kj[hC`A5* ,QZj~c 0, }\Gy>J]y?N΢E7>jd8b}GSP׊{ ÏMӄ(j tq GGz7oUTةB5 9s~,1bĈL`eRsFHT1\uWE,0o)OG[o5"'9}W2ou *m1( JCR.Vʕ捪*1 `e6X`]껀TmL׬YC찷lˏhOڏJhLoӚ5cA,._lfΜp:qԨQ:u֙c$k .vZsGLwRr^>r }+ڏV9~tVV7>(?%>2X+V0G.N%`UTTa z *pfqXT\+% R`yH܇ 9˹s^3zhr߇1 eTsIE9so?WQq+cXw!8}tJ4ƍ#}CE}y]E-ȉW*Uw2X^_`Xes }uES7*444ȕUmm#GSOjZse><9cu*qq:{kwHB1rH3~xa"0;c٪N?5X]&|,ʉs&`"XBOdOP#%R $ts~dvez9b}照O ߆r/ ӭJ4s }`bti%Q%k%Ǥ~d"2jl?޴-}`0X:H&c)r}>mmrhb0XqTȂ^]qx,ۃs>}0X,a}dJWWcASll?TnCr0XDx+2"5թcLws }`a0~tm=N~Me $ bt>Qt̕~N?v睜cA`1>+ ։L|s>}0X,?>8`H{cA`AG nrE O <"X魄TW1 `aF%͵6}`0XC}R$+9Ї,r:˥"K+)cC E0}TH9XE9Ї, ,FG0}ѰK@ri!`aty?`Jfmfjjj`1:)sub{' B1!7nkkj 0 >brfFe9]n܂ASbt>/ 9e(hH mS2XIGbgEr;7W\ C޽`~.]`zM+ ];oohv|KVvEЭ"TTjDO B$tmg#X\[j/+3z2s rfܸq1+**2r&NH)R\r1l]ӱܡC捪*5kj4\_`e}RN)֭[UDQ]&]`5Zem'0qiY=p.x4cV{nSZZjFiƏo6l7NJ:X}Gu\+b,Er L]ɔzv{ߑ)S,ZK>93X]]]624f̘GSt;v젒;}G},V&HFJӁVӃ3DRAUUU̪gΜQ& nSQRr2H-"1us )~[QI0K;w)2`m}Uqmg"X J#%+z)W6mDR~\E@]z5n  >BȰ]q-4R{̙ l`3gZ3b Vcc={MH`}}>v6}v- DٸF^ڲDRÇ`ER%0XO 7r\]AJj15\i\5:uʔ)A]i'*Aħ]ruaG\r)4ҪSkЪB_>$+EU\ M} }G]ZR4RΕa)zUt!5 (];GCL"`0|E"X2ǏO77n^t\G+E`T|1ETj"J5;}}44"5 rɤI{1۟>Z~p%KhDR{dʫvN>N,Um `'6_]tOnPjLP;}ʦϮD\_A(9z^E'c裉`gr Ν`A'w27L13f Oc}=Sǡ|!tq%*S+ B,?2WϛgCRG+\WΕ+5X5 o裉`ab~?'T[ۈ".A$^r%} }49X"$(w BmAJU+,"X Am)9Gʸ:})..6_;wڍUok̘1ҴY# #ٲ^T%% 5=i-rXAشfB? ʜ:yd\3*++===fͶi\)Y+A^\(B+sۂA`e`iJkׯ_k~TT+:u֙n"XrJM\ɠ(k(o(+\`PaNDM+3ȑ#fqs"f VEEELc1Y{?rnٰ,ݾ#OKǣ[s1 _﹇ۡ)B}.ᆾ"LIFy[J'(lxc^NV. wGԗVTsrbQ{ FF^裉`e`:u*n{&VN"jƍ#/m=˲G JoEk#&+KedxJJJs&Չ'F"#W\֚:"XrqE2>6߳}d^!,TygѢA_裉`Aѡj[E{n[3K$?N+! " RRWL*Skrڹu~N2.mCQ}ܔ ,\?0}}4, {Bwʼ\7\}4Ed, TWA`a`1: tp.6> W#X. ԔG``w ܨsժ@o,VjGݖ)l1X,?Mm?M6}FA`P55}}4 db}MIQN9X󭊊ADeD`btx*2 Z^ZIMzļN7-}}4{oQˏ?N+EӢ\(FUUR8, 9X;ASsT!yPs~}{Vm*KD>,"X0oQlD'ȫjZ\먃lB"X>z aMZ!9XZAxƉ+E8!̲={Ypu,?dZ rPQ`%2X_vڵ)BB"X>O666E3g}}^ #(V&+hOPK55Kd[*VbK9Xjii1555fr_Gyfs5 }|Vq)+hK51a^Ju'@I2V2X2ZҥK,䩝;3JYQJn"XAnoZ(K%g35Uxb< 8E=&c:ARM }/U& +WE\sLJ7X"XD2/OkΜ9,}HSP#|G۪(<)ƍY+zVW\ '9 ֯ygF EVF<- #?NqOeU]:]}dt"t f?eh8SfcKO|L߯kaEΚ/|ҠU/l?^_l-wר3;|K3YTs*w7t_$3IT߽Mydn=ag?I66Lt^_7l__ |h6n<5}O>'GG':d4볳Ƈ}i, 7nzѬZh_:=^]m.kr>/=fӦ'ɓ NA}q'A5`JF#?GG :f,bG_egiٲW̘1ogl(¨wutژD|SZeIpڴ_'ra#>C;nA׹4w̕ίpk>"}P?~X}P[I`9d>O̡CZuA(*0z_ױ>/r?_GY d Mhd5/[= ߉br˛|2hrYh.(D,}_깸IM~PDG,}:/ӡw/L_nr)Ң#Cl>&)Gd4S׌>{| ZSYYi ёssa"Uy^=ϛwjClkԠri>3fhoΪSrn fFmmd;E&tE2mگ[f`E]EoH~?~EOFM&'N5>~C>7yo۶mEN}nP"Xr31OԙxFY3XVV?z;}n]z6r3rՌDR +WmZK六ڬ7UVtyAPd`ydMRQ\裒 gG>"ӆ&QKLEq.J1=ڌ1b=nmm5i?7K͍G6XVHlٳ_7Kj0F~կ~h;N+ ,h*mtcv g2Ȣ3}BH'bNW$Ӧj?%#:Ma^m lA>!VgkQ?Ӷ`k>"d5DɾPO:MN ֒%KbLAӀ 繹0X<5$L!z_^kF!\"G'Ug_6SVM"Rǡ _oǔI* >6dGCɴ>EN5jKVxԒȖZ;Igt ^Ӻv;(J|:K/?OVS gr91O?~á~t,;vO2lL\ Vyy=w~pBG'nϴiRSSƎ7ۊܘ>\;3GZ\W~/?ڏ]!7eJ`O/K'j=L1<ٻ7x/^~'Ǜ3P6O 핦T/rKWGZ76Mr~37 i(Bmxꩼ+ sbPTTdUM81lת4/q:TQ-eU2>hI,]jR|t7ZKљ!vK;d>uV0re`uuu)/ˏ}mثiAh2RP{% O>}.P?EիhD7^CEe+}V:XArJNf_LSK={Tr@}@4;UB5Dt7ZK֮`a2b{U\𜏄WD=GǂIMj6`h;z"V9E" 媃SCtUid@PTd(cڥ@I#2$%uiS\\lW_a?-c6׍WPѫcC>F+}ƛ"HGSR(CuɸӃ 5EvK5^>P+|@A4GFhmV7O}z^D`)Z]t[]a=٦I6z=!nm2ՖJ&-ɓ\7IV,M vuu fԨQJ.w)zE}2Yi h01N *^jm)?ǚLg494>hDh*O}ҡSrB6E(@"Y]~ADb(4,IcUR3{E eڻU sMx[]mp*]ՃM5TXXX U=HcA!>m) R-ٳgF V@ݿrl6w-}(QK>H+9X$wZ5\9UMIf;zE >_o`@e/?xVKB,]n]8`e`رÔ…fӦM_]Yu|:\!􁽓&e|' rrlkuʕAѣGjvi͜w̘1Ҵ#FwՈlSUsU15>cH+Kfƍ}#G`ٍ{{{MOOټy;w/aa.:9(UOѫlEAA0,bŋ[#\tLC+lehJY}(ѬVc3ĝ;tPFӧmT+'5u֙nrt,K"ɽB́29X9\Ex1SRRb eh4m'I9rF`Ec$msm5N?… )^'e-=>}x2c)}t}'#},-we%oذF:::~/M_&JSV9慧=^*A4g}$$+#X]]]ڮ4BEEEߐT{4ƍ#lzaj !ϠOfoOzir4XUUU1#MgΜ1Ǐ\8q"a*#W\֚`dI8r1#K!0ߩdY0,,ETJF&z*2 CնwP,}=M+Y{2fz]IH+ ÇN 'YdIU-^e!S]:XNꯃ' TBKKK'NLk/+ct}fILD`adV'ٸC`9XHrOu? Vn'47CycJJs1ft>hOVʂt܎ _{W\r]12U]f.z!#sGuYwu9 Vݿ_<vkkך \5>٨mH+G+ X{br;蕢X~˖+W2WA^>FO6v  Ek*JyX~r^ٴ/c F]QDXEHVOB-1u9z}}|;EHG !_gr`"SDp~SʫuB^;kFF0dID0X`yا-ުϿTaӚ5䇐>hsO.V!OצʷF2lO?U5̍>~!0w^3w\SPP`Y\\l~_b6G1Юi WӁBaO(CV,xS+V`NꥤY2h,Zdm{W0FA#L`e`)r%#|rd+ϟJ߿k%^J:u]1kި"h}R$<0X ~[R Vܿ_<tmv?rF!UHV رcMwwwǻ̘1c0Xc~^!)BUrP<0XF9̻?V(꽻PdTd!kA#tȽ>zXD`%S:XFJۂZqݧBd>FaGUѝ<1X{G_ռ2߳_)]KO5̱>~ J3TVVZ$vtt2+}^| k~Td;0ͫVvg! #X-NV@`ez xضm e+M[/7&iFM ;GF(XQkH3mmm[[[Maaar{t~OUs'h<}<4XZ(Nq׭[T퉞23V#Q^^nx]믟8x .$~|.+5?so?HF mAto{DӲa-BO6{VtJ"hWX`s!1ݶePE+xGN+9X.>G~GJ9X!"Fgg7n\NJL{{'&{կze& @,-r0X)444h̕0Ŝ^Z9:4,jW1z>h؜,&gkv#GǛ 6ͱ s0q!0Tέro`Q=_I*8*]f1zEA補ۖK`a0Xիכw-"N}B fc%!9XPF{%%yJFUG:yA4 >ZIH +Q-mܴfMZ@!t=bh}:H9XPFtb.Zdk`in]QJ7-t!, V(sdȕLVCBC WWɞL'K+UL[ɥmrd;t#DAAw"rjZ<_+.r_ N}£ս&ٿJx' f6uu}(dtΙcU&$ e ''ƣAaȨ " {Lĉ.}¨bP^ۥ) m*>FaGv|hB}R$Ѽr%9X, V/~a[:7F>h>}jP?#`aBul>:6! )z-$$ b}'MDZw+35bĈL}­r1u5 ̭`>FaGEG-Ӯe`W"XynCm X|M(0 VҸ|9sfQFYNk֭3D=BA4 >ZM0 VXb9rHS2X1HvHss~V\/}'Op9s),4Lw+^r|ܹ)Woo=z4,F}Bv8kds^iƍGPfzCV/!LCC\\֚:"X!FD`8={vH{nSZZjFiƏo6l!xj\0XTrg}'$ R7'XBj`oݜؽ6#*=`aY2;qhp@~O 9X,ߨ ^~q8O?v睌=`aK]8_ٴɴ-X@'!, +lXSc #F>h>D0X4|6N@A#! J^JӋf1:b>FC J^ޕE'!, + z+8=^HܡCw$"X,W}}}9s O?=`߳|tm`aroj^UwFG}}ΎRҖ- ֩;wA {Y8#íBayubsn:qi^r0X0Xa2zDA4BMw\iި`^+`aa{M2O lZ\3y*Kr0X0XZ=ƙ>}'[ # V冈`a|Wh}!Bz Lzļ`aa4_et}=pܘ:u5˜ܵ+K{q!>FMzKT~, V 8݇#d^F]Îgg>,G #TdB!.4k[; †cǎp_oo51_sm(8݇#dުAUD2X#Fg$\oo۶|TmW݇AA#&[.5Vװ}}`yEG`ںu] 2:zn,!082X޶9rLCP" V`1:BA4BW e`Q=0ܙGA4BWb2XW/>,F>FUӸr5XL, V,!0]Q UU`a`1z>h>~ƍ`#">FOi K["{X%E EBU\T~EG>F>, >F>, }}, 9XB!`a`0X_$ E@A#A 9XB!`a$b}AFCDA4B`a BwUZZjMBMy @``r B1X!1}}}Їq`  0XfĈ =Yp)((DCkkYdI6 ,0/_F>477c֚%+>;w[=ڌ36>@hgŋ'b \bnVؘ¢nvec3cƌ㮯7۷o�m6SSS:SVVfl[17o6sE`---v5v„ fԨQo6;9s昶ۊVd0X_ׇ(hzȴc=رcf_brA3sLO'+n扦t¦t~ӟ}WC+WO㌞9j#9}ju2E n;gʈ2Fq]H\s䔅ĢEST[S_>q3q's^ȑ#6R(+l_'>.k Vh,F?A*\DT]\5b|p.$A4X'wh:2T"M_O0;nذaP}诓1Xa1X(c5ɓ'ik׮ƜoH͹GwSʏI&g&,DAљ'VXQ ܊B g }Gk KsJ1-WcT̷ Vy=#i儬Y}>2h-znjTd^ĉĪUߑ Ƨ脖755%v֮]k&j{ TIڈŊ&}MR+JfkRaԇzh}_c0X, ``0X`  tC[rhkbwa`Sm~! 4 ˗##Y7.kcÇ3gi۪*Յ` \?wdMooٱc}\%zSN>;wՈ edtAAA#GڨT*)) x_E,4fѢEoG6{=:!Z` t~(dt{ \O 0XP+V_ۚ ~^kc=؈  Knj0cƌFСC^;{l{[ N8acW^9s/ `yF|*/Z%[n*,,`SXz*D `0X,`` ,  g>: q x,`0X  `0/we4_n̘1cѣMqqٺukʟ?b_ٌ;`c̄ `-\כk^y{_.!`3XF*~ӟ l2~e&O{<}_cd 8gJJJMcc ֦Mo>|ج\KPtM~Ύ;0X  ? K2@wm4kѢE'yyQǻ5ɓ'>& p`EBѥ͛7ٳgXLd̙3fo6`0X VcA9R"NDpUSPP`T^>dm۶J'D`2C^,%>%c,@^]vDw_)rUYYٿOR^?FLdf3:vXBck`0X/ pp 0X  ##l @-0IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYAreaRenderer2Sample.png0000644000175000017500000004632511173030414024522 0ustar vincentvincentPNG  IHDRXr5LIDATx}lz?UUUUU}UUUU! j("%R"Pc'p0N 6&pL 1رK 813c q01T y}|.钽޽̳\=PV`0X, `2l4cFxg|oV_I77Q?w7uu"SOM{_|1_ Q;;߫+W_,ե??R{~wW??UMMMԼorssUYY˸ϴ`NYxtlذ!1y~idppp{_A1XFɟ~:gUsssF|,VVVX ~]!4I~|lΝ߼+Q_u8A0&^<Ă1J t%5k˃WS^A7Y70Xx)ۿ9sf}LcLOT}7/ryPD̯˄duL*>_x>}Z}ҳ1=L??4 ʕ+Ӗ|Hlٲ%9>-/#"JJLh#i٦M__jt %Kh_R#Qk׮Z>hFR&km/^zI*c")/#c 7]vl b#Vˬׄfҷ{ ϓ7|Sc1F>|X3ܔr[` |qIYf%I/xhOӟ'&>_(طo_B(_ |Tc999Q61ϟoj9N]NlX2#+Ŭb|T%cFH1cXjU'gzb  d~_4L.BSSS/c<{P¶mM4\xqڗ;v$FNLWmGu, HT!SɝzL[)b7J<\Β4CrUmx̶Si$yr`䙃guN2[9911mfoLW1XOYc5G+4#Tx0Xnz/O>drY:R1X~ef^N]Nf$d:rJW_}0NE dg7I,cI{n\Led3,C OT,c})uDjK`"*|Mi~'ZN˨SH~`2`IX/5X@ R"4&# -9)VH~7˄^_ ' GIuFyF~Y zUm,c+%-EN]N V Kwxє; qRL YVe`0ZFSZ.kfGG=G #)744L3d-R,SM| XVb$}V't9Vf~gV; >X,g06F֜񚁱[Fa쫥2E1<<'^G(eQRC ]%"cz`R`LˬT Ν;Z'VXcvp`I:+Jؤz6Xz%2N; ` `  0X, ``0XĆ n/[L-Yw,,,DЄ& Mh+V`jJKK'|;^rMhB+4C_Zv/7ф&4B0X4X%%%ܨB!``q&4BH0X` Mh MhBS3gd?~U(̓$XhBHЄ&4aW- xhhhPMMM,!bT]]]I VAAftܿ_` Mh"BЄZxqY4Ο?_ԨIܨ%C}` Mh MhBS-[SN]:UVV7݊uߌ34&Xau,?p{``WzN?߶ c?|e )ٳmIBa'Xdח9>Ts~/**RQ5X , MhB5XhB0X!|i^-s%mjkk3#"yjЄ&4Q&4Es`^uN:vq&%FիЮh͛&G }Є&4` MyQYN+-U--S6iZB5k8X]Nvu1F,E&4 Mh¾̕$X&kt{fk Mh Mh2 jl(C%Y/jjɏ?faHЄ&4` Mq߻m`E:?ev ּy_uudBaFP̕,3Rxmnu, V+7wZkvzGb1"[o8GЅ&kg%XQiVYkg`edy穖֣0֭/~A}Є.4XәN%2NjLSRAz>kN?>dwoMhB|Z U2d6H(ε`a˘j;9̺QK&!tfOWyG V%%IZZz'0%3VG=^]+H+4ŧ4 ]Qa$`EY4 PȹTh@^S&_۵ 4 ]h˾-Tjbhh}Zՠ 7ڶmT)7< qĊ&4 M>$ˈJ")lg' +,,+jkγ$+#aBڶ+iL`y`%JTw ܼJ?鯯Mhr\R;v MaެJ{_n7IH0X)q{ZuT+h;q^zcQs&49Oi|,b6n/ٱoqwi˾ܑ4kZjE +mnzT)DXzԮh4e&9yfÆQmnD55_cN1VYIv˝f>LE ׮SR]Zk~ka&Q**CJK喙+) `ʞ=f G  wicŨY7鈴Mvbe\K@Дia~e/}-{4WN`ţ$:A, k|뭻R-U?k(MVce$J']~*Mr79TY,jNP՞xSN9X>v;MZ;@k˘io[UZ.>5X$XP?bz_u_آ(,W^ԛ8FS&h:]P> :ځ&1 N+/Hn"`Ɵ6VF~xLZnv ԁ)4Iڔh`+Yc[;$giխ}iV`a5cL1͕_Z^$X~hQ4IZ-M8Ʈl?g4kowYw'=E :#j+3;MXXY -ߨFW^Z Sizzo̻7ޖ  Vܴ`i}a[e7R6[j}:WznQ4tQ] Sj3t+R)1X,# o$HL`鼜T+޺AS5=zZݵ8f[;0$Ui@& >b+K)>_|ה9J'E!5:GzTbXф&s7ntVJ5ځ9e&;[V~Ke(^Y,`I}U+U_e'Tjjm~B|睫'ܾ}Бpys\Hy:ֆ"m}UӲՅodNbҐ4# /5p i3RVes*=Mӌ[&E7EZ+rɠǏc`m[yY[6LF1g>rZuKX~4*&XR-V+8F5]&W!˭}NI'L:}~fIPN(igc\2X[Vݰo5X[=T$lE@gMvuj+&i9u}δM\-USeŋet{sN\jƠvW)IXuZ^k A_5Y˨IVGǧ̩ޝ>^|\}ҙ^ }rKo z*WWE$Ov V;g %{Њ:k&au/z S`umiVF3gƤǪzjBfF&rxGb%AxG=|X;Hh,kvi}WThg&M+]w6gTb)朒V\RCr͕'HeCed*v+z0XŪWK\IZƩy`eee>5XAge F޽-dWoҧՕ={ԍ;8)|e/>o)>&(;Ѳ~UU^>/%U-nN{ &ptF)b ͛7!Zs 3d>W'HfdO;YH uu@mhKLԽRێQ~I]zI? %Xv-甔445M} j.\ecelH-gO1$ܩrF,]X縫--jS:(j`>ͭ[SJR/ cbD]_`1ZtKzrD;+Kvx_h)ԭ7P#PǐWݤc@ҕշݛ+z%/2堮df\`M_6k+1Z J`Qe* v-TO{ڤfUVxl)K}]7('ZrvMzUMWQβ cH|)VbPILgXEʆ@z_ئuU]^V;<і+*nm_\'n,q `QKM5Xͷ}v;SCͅ:9#*S`iv _QZZzcs9CYvx^sLe܍eC?0X$X$sj4ZEt{@%X<͢vr ֟ܞR(ԡC%xd[zVoӻfi^/ڬ\ ݮ* 2Rw8D])ؔџS1Z&ZT+q0X$Xd]Un~wF+_k.bi<_z_k)Mbd<ؗI(7, 5X (ųu-jN(䛾7j_.6j$r4}xb EuUVGǧE><kx=)wAkg]%g[/`Qմ])o}Cuvg;nDls?*.Q"'p+Er1ջeeOCNg _K.-EIU)>YͅF)U_MR/gbZ~dvʳvhyw8>iه$ZennH̥w0X`AY?QC>l&ϡ-'4żI+w!+PlhtEy , sm S2Zb *MxsBx 5X$; `%cyji{^uW`S[2Z#H{R-``J8:ȊС^9\Q`I ~=q-i`e }>M)K}Q+jk;յWg:;=_.s͂ϡ<1E8M/ȸ˨i[3_û`}{IM[ Aܑ8LK[Ukq?{8& ++{_fK?`%TQ1-fS HyyRF \9Y5XQt0hgO'4a0XY}!Z+^{LOzM,QdQ4Cb)WV^V8 E ]C(gJ{uwqB  Vaٔ`M_JJ ֝PW6fQ4Є`Fnf r VwԾ}/*s&S34 $kXO6ki#De( Є& 5XO5dׯFnYuWfB!+5^2 tn0칢=|k%3dw%ԣh4 2Zv+VPgVsQPHݿ_{l̙1)x֞/Ij)v Pk׎ګi-7j,]N5XhB2`^0=zH׫°ԤH)v `2Zv]Sg}`V֯$]^ Є["5kVRUPP÷%ˣ+@<+ ,)S55_L3mi BH VU__jK̖pS_.5jrrR{,777$3ާ3fiL$ݳm=.Ӊׯ(?Ħ@nVP[WO֮]UOpB%?e9x{`` ~p*%Kz:NϏu{hGA&m̧'qԩS*???\ I`M%^`SS UGǧ`Ts~/**RQ5X ,+`L]֭_6wVWZs%Dls!`AOOO* C1WҖV{Q;s0,Jjڶ2 ܶmHs,k]M3 Є3Xz]utth=rrrԼye%A`eRUk,Z+4 E'w0R5`YӴymu`:~ܞ mۖ`L MhBkfW QCGTSS_ZdWW˃n_B1X$XY}N,5Bi&+ gQ4Є`Fjj Q[Z:LgyJ eeY_B Є`q{T[j@e_uw'6ZQc%%'XN4%BЄ++'穓<.?>`;^w%D?_BΝ;… H8H?'֯-cukִ Tkk]TjTGqv[~UV˭f` Mhjkk`q ^'Sn誵,YnsMhj%녅jxx>XQX~'q˪YE>XSx5%쵵jrr# G($X$7(Fʵ1,i&꧋8` Mh`Y~vv<(5r'(E`CD^2ZXI3QjЄ&4ѣGY=Ӛ 1XaѮMV^mJ1r84ˈ~A555z*, O>`ӲBj6Xj%Bi,!GN7UQ,5I iGDZpawՒ,Y#]5Xkg Mh6 $X)Q,5GDjooϨF`ruPPg/,~y!I%_~]-[# 5`9ik}qt M$XNEiKK.Z4\t)K~.,**Ҟxb k䎵kYMrm8Є&j6X}ٖ!+++#m)'rY˃q Mh"2`hhHmڴI=L՜9s9`A5@'==!5Xn7_si,B0\m@&iGDMknQS厦GԐ9.4,  Vk:%MrRs]hB ,av ^I7!5X,,+'HZuK]| 8Є&, 5X٢=j$&9.4ϞGKzbI+i tHі Gk _X8Є&>{[Fqe5oj2Oޮ,{4m[y9N Є&?x˃B). x͘1#H]V]rE?^}'O?/zկ6n?֩׬~z}PWz1JƬOr[>w~vd>t>OO , &2Y:}`I $ /N1 0=M}N9œB=1X-Rߴiոn3 +R`-XˏUwh3$O [[2|B`u%-VZ&L@ccv`Yr ԗUbJ4%[oqA__|& Mh2%uVCCCS%YC,`k+ M^.2+4+-[{9.]%zgΜn;5XfCQmۘGB'%*^a{[[ j+" O?UcSې+5M<{D&4'K Ƒ"vǒeBo5XIRjkczD Є& +455`I1HЄ&4`I!ի*2aP 5XcǴbmjQ)B}fdi-QQ,0t˂&Y<|"B7%ZZZԣGDH Vfhg5X4y<gЄ&j,=5Xax|k+ MSG',4 M>4XRսU) Rׯ_W'O$7nVU`tO$XhBjȝԿ?5X&4ay9X M`e"Mg;;Ih[V-2HЄ&4h,h>jG^۵y!~6Xer9$XaE}$X 4ٖ',4 M>6XbTHPo4ttPGD V<ZQ%= ݪ# 4 jm- MhB , F~i5885X+رz<B,7~ז I8JF,6of>` Mh :rfeeeQW`FGj"8| MhBS4<|P3Y4pB544Dn{خ E^9X M$X={ӫP9!A7X}ڲe GjJ#1HЄ&4`}7jժU@)j!g>sg5rO5I'InZ>`>Q&42RI;{PLI8\ӵݻ>3e2l2HЄ&4`=jΝZ,)nH`Ztz5X=t(.1 0KJUbV\`eƦo6'X<|"B:r=htk֬`>Q&4)+mH2[A |"B$e`A?PW#!``qጦ;.kC5m MhBS&55riYW%f>Q&4 Ecld[uD&4 E t'Q&4 Ele5X]|"BЄ-Z[[Պ+ٳ՜9sT( _4:Q+ _="$Lt=Djnk57![^0=zH׫¤Tԗ&UUUE&5x`+-U'g>` Mh`%t2UPPǣ.>G ,4ٮ! Є& V|:uJk"!i2K1cFF%Y߸ۙ{Z¤ Dw7ۛ6mHﺅuuuZyBuI MV5Ѯ',4 M$Xq%=>|Ν^TT&&&j,X@ ` Mh``Qt]<{0B1X$XaC'X+*O$XhB0X`FMRt,5XVd>Q&4 E+jF%ER|"BЄ Nkp!bH8pMSHg>` Mh`Q?59ѮSǎ1BЄ"ßht  MhB,އv Nҁl;!``q_MNkp:<|"BЄ5r5ݮJ5XhB0X$Xa_Lv$XhB0X`Aөv 7:86B  Gdgj Є& 5XGmiaQ&4 EFp4ٮԇjא.Bl!``qm`We  MhB,=הnj>̶Cc&4aH8Mk#)/gۡB0X`̢ҡ?B1X$Xadt5ؑ`ٹ<|"BЄ5r_h:ݭM}`ۡB0X$XadT5` ˶Cc&4at53?b̙3cRcU]]BfF&/5`IsSirʶCc&4al5Xf8|USS&''rss+˂} zٮ*)c!, ~_Ǣ34&XMY~O~/''_BOzys8ey}opp$?iFH5{l,jdwTjƦɮ.+4Y<|P͝;WHMLLDY-X c`ɋv ` mƶCc&4aGqq(1WzV{q N` MhbkFKMV5X:@`ۡB0X\#tͱm& Mh`q-BFx7=B!#tc,iCc&4`Qyj`X M``qN=]/ЮnY:q8MDE n޶Ю!ŘB!5X$Xa鲉v f,4MDE kYL35Xn.BЄ"k0`]eۡBHPݻӮ:XB!5X$Xy4;x0km& Mh"h4ER:'jאKkȶCc&4QEG_nݚrua+4,ط/ګ B"ͣ)%J%ػm& Mh"h4YmאLg'MD  nMEMA Є& 5X0L֮z B"ͣ)ic&aۡBHb=MkU5mMD  nMf(~fl;41VhB 5XjٙJOvu1^BH  nMf j MDE haϞ5X}MM+4,,<,ihk`ݛpن+4,k8~\+-Yu#! 7Tx7b&X--+4,֣є ",,BЄ"#><-k& Mh" t8 E_ome\ ,,<55nYV8BHb=MiBkkjm-& Mh 75twkő\{;& Mh" B;8m 1BH  GhcX M$X̙3c2c?V* iIj tv==+4,b||\-Z(l⡡A577o755*,4 M$XhB0XFTVV@3c:߿B!+jQˇf8|USS&''rssV ` Mh"BДk˖-ԩSq`Mb7cƌ05Xo\7oX?Ooodd|b|>@,caUXXo%={6 Є&,4 M$Xf R___<|P͝;WHMLLD`-X,!bCCCj/..VZ:%J2j566jgFE($XhBHЄ&4a~4RW^vGGZbQSuuuQKBD,4 M,:s&4BH!B`` Mh"BЄ`Q&4,4 M,,4 M$XhB0X`A!2XALBa$#`<  `̘ĎG]hBЅ&4egBЄ&hBՅb&4Є& ``0XaO$|ǏUuu BS4~Jrk̤Z<ƜJ>^)+S$FƏdEsJNW՜2ɭq4{hh(|[j|3t d2X>TsuDʑI88|2˫J4׽++?)x5NVwI#k`O>dEsJ)MnSzx5Xf Fy)0drhmm:zzz&D^Mn+g |Zk^'+ds^2MnSbhrkݱcGx _?޽[+&tVL,a>XիI罛ceV[$݄RY8f`0X, ``0XES-|q[t~g\h`2>Oi`)IyB].4kb'=m^.6Xz&hTƂ4 l4*Ϣ%M zѢ_COQ0X~DeeeIUp0Xb׊#Eqq,=`  0X, `F  "`.0XK |)\K0,_c̙? / Ke-S7'bΚ5K-^x꩗iO6F")Kc?C!^nc,QFѩS4,0X+KҎx:)奢" ,ɲXF&*cnc,QƌQ]]*))Q<07,0X?b͚aꄦDjkk÷%i3оT1s΍2 IcLgnmeq2b.][K eR6Ħ<Ĕ$4bD1R-5F7cccSo%H ^_$FEn,C1鉛Za`R4~)ONNիWk_R-g 73ӊHꉤ' 91rP~&]Y#e]C6Q\ ,_ "`.0XK |)\K0,]`2) l/IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYAreaRendererSample.png0000644000175000017500000005125211173030414024433 0ustar vincentvincentPNG  IHDRXr5RqIDATx}lTWzWTUUUU*UUUUe("%iDzE(6nUB0ou!Y `16W!!6Q 9}J_w;g~sJ.=37#^23%? W7/y0X6h^z ߫66H~,+|_<(=eO>d9=Ϝ9cQ`L,W^~GYX؏>H=| ŋKYrFǏ }y菬.eBuywkqo:JN̯[:o2b bI$?___O:$\ߏ|;7~7,\rc}~4m csd>cɘIDu۶mmRMNn#ā,#d(X. dW 9i t^z0>a> INg>yܹ< |ff1M}j9|.1=т^?U`Y1F:$@ uq=Q  '/h$/9tر@o#n:݄Źs(%a91%r;H*0h4d>XӯA? ^t4MD ~nI4- 6`NْegѢE=~8Ho~ T\Yޑۄɥ2˽rU`_[|ߺu* Y[jD`IE0XY"0###,CdIkٱ ]?yQ7!򼒓$'^ޙ(?f#0?^<0xivY k~A nO3 WDF.T\ԍ2a-Wʼ$u! ̼A¼Z,Yfӯ9}NyE$K%jP0XaviQ_&,fti'\ſ˿{~O__:>+뭥2%.DKI0X fEj6ut#2/{^iGVqކy^ь)"'144d]/˱^> k¼^4Q !Hs~Nq,3KJE8}~r~J. CZURbn Q |J'_oFer+KhfG(y\ho@$sO"mqUrw<^̞'O ls`˖bav:Ո  Bz\/BfQNoVr_0k󼝝,qU[L/`y~ߋ[N^T%ЩX)N^ Z* Œ%KJ~"Kfo@'!)ff-ueF$gIveQ*K}e,3ɶy).)+-&C}Ѻ+^E3yL;);J _Yb^q~Nq,;%EJr;  0X,  `0X,``bԔѢfggU{{ZvzW,޽{O,}zxvvvqwwjkks0+VPSJkEGt~eZZZg 8qmtΝ;jٲe ~<KkEGt~e_5}K Z˃bܖCY2ZRLb#:#AtLv4Xjdd2K=RvRVrm]],`ZPr1s1{`Q"X@ : g}$J;޶Y̔`-],脎ё,pÆ żQo:.vuuY~z"X #,7oeiPÇ V:Xi6XB!LSk*"X an#X,:bБ,!EA脎ё5ttD'tDCGr0X@AtBX8xEc`A!קN}Z@r0X@AtBǸxw}ѭ۷ÇяqH :/'z2Ybn[θ0cbL ::pruaΒˎ9b+c8$B;n[.o2/z,z`1a&N](b$_~~׮uczc`N.:AtÑwߵ D˯Fz%3`a#:At^ \-,{0WC"X1ΑQoKVW6o.(#o;`h*q["X CY ] ̿8d`ѱK ] Kޝ W{Ѿqv6X ,dѡA;5xktmq`1AGtBdSܢ+'0~VҶm 2!,r 01߽;1[3v7^ټ b脎浍c1XzUxfp0pU|/!$EDGtB0l{'^ݴhS_GdBr0X@1Wvu\YyTZhr8DšfUWAVBr`AtD't9/;A<[w!$EDGtBǚSoA7gC?!c`Nw9==e_G5m8$UWWH'ΪvvZ< ޽K,݉}=͊f:L9Sf86U[[,脎)Opv0Xgzw!|/tΝ;jٲe`AtD'tLye_4ndZ8`K,Qmlldh^F #:c܅oX(ڠdq3PSb֬Y;teV˝_9c=>۰A}~eRo%檹VډO^ϕ4 r8%*@::&oUm$t)pڨ2e5}&{E9^ܬfffJr.]JDGtB gZK"L'*>]%_ټ9uv2asV\FFFh+)ðuV%.k砾p}aC #:czw,YWZL; ' 爨3c"p V_ҢŋՎ;\s!U@œ۝$]V_O+6;3tD'tL.T\IkzWɳ_O#} 0w9X,19hO `Qe_~b.X\ϥ6!d::&=݊VUl {{$>Mʙšl" K۶󯊻s*דR , 3tD'tLwީzƍ%W[Ğvv!$EDGtBEΝ -Kq"бnUN%>璂CH,!*?&nDYeKl%Ib"9X Ƒw߭cIV|q"б4ki >" BGIOJF[[Im88R , 3tD'tL k`+WT###VJU{{ںu+,脎1qdEC~g6W/V;v!s9etF?C`Qɝ::&z+s8"DGtBN7ҋDGtBNJʦM`]{ !$!d'?` @ ,脎ssR_BD0X#:cѣ5582c`AtD'tR .!a 9XB/O8+-[E #:c<#X8;" #:c޸QM:^/JN2#㍏O~5V0kxg?tٻ7z\ok+mB=łɗ&~;tT,1HN$ $:JAG-g×Nx"VD^V0b,D?&{;6"cLʘA+V})Zt)9X:Jg/ɸbĐݘ3BdIQC˨mxvY, :~ ^0Y k^{ r8gd`]w/x`J('01RIK"Qvv+?dMΝP^Q<~oeǛ9"X_q09 lkAY*[1C#mSO(?դ\/vmɫ&b..o-T3-!u $:(#lFOtCZjHxN^QA1y:U_ʖۙ Lb+)KϜ?`aXCOſ=:|5\4Z#vZjHx?'/g4N{K[h$*C4AH`L;He/Cze)vrTNEp ؝&eYK WYn=77>̅ Lb+j!D0X05E%o s6s{{?\ ͙,懼֥[Px:!F+E1JY t6h-#~6e/a;$ *ժh_ltN4%I91~XR Io|Fk] v<7h7֯/> Ljkm8`^ca"=U2Rn$0Or2,a-K5$yM4{${+JfTL V/J֬u% 7bf֝?`1 \*!|N5N?LO~KV$yM$u󝜊Zl`WhFVv:Ɉ92[`2)m8bRs7c,3+`@9wkU!le 5*+krޯQǵdu rG,5n V|`IMPfՔpۉWj,m#*'2ؠ9 i5mw[eP9v'Z,1]nz}sVJ:dj,:2DG?Ϳ{DO$[d4MLbV?`1jk=<8g ]`5dTO7Ǜ\Wkf LZ{ɝ2~q`T>%BXDj _T QZJݾ}uuu$+=贶=vP}6Ya*T$^ՒSksJNB U5Q)*. +ϬZrQN<"KpvOP3bH+?ըH.MzsIuJx:V,szB"D[͝,W,X 5 3 ی鐨M-*a5*[JK/o4+a?'daj-I$ѩG+d=+Hy`%`=zHWq%C7%KdQy RJ'݃n3b9YM$|*~i4+a?ZFD!MNeGs:,"X5Xv>/-fGceSGkkNm/<Ƹc+3ZG3uOwP7 r, ޕwxp|'N̻~l` j<Fsm##v[cNr||ۿ7;~v,F~}Ç+VlIr<_2 ۽fŠܵTRF`T>%Za 9]U|YQK Fx<"XcXetܻwO-ZտqgKjNG]eqδǛT]K&ώZkTW:H/Fr*IrRc^~e5>>nEK+KSbPU{aoݺV :# SFޱ7=VfE"i, y1Bm*gʔ*!Uj (V`[Iןx f''W͵zxbczfAN*wI!}-IB`~zS+3f%UQJ'8,M+k… KPssOE%wf ORu6GV"X~'ߋ[mX}9¬sAS{'^p@+b5Q#^{ͱĄe`w+3t/;љi%R}9Q7Afz`X2>s߻1XЩȥ_JsCmI3e~w:J -jmVnD Y jtFl%}M/ѣ[KU>cDR]_#t}.Foz5}ysψar[tceB>rXL .EY®qtx)&jmy,ۀb⇗B(i`yՠp0#7pZ萙KŘvyJ8ƛ 69i^9`aXCaȤ^ir֡Ss*Suhⷯ]P-tAVŸsm~dy/fS7,?z9X]"7/_`1 ě!{{UqB- tK0N^Icj7cNw5'q7{s٘rш`j)`9O?z b`%% &"KS˭[kapNIf8K4KHX䤅g8`s (4 $PIRei\"XVN31ne t'.{ ~Vb;*ՋvW\ 0=U>,1W{ .z"rNd?鐿,<kC㴃0.NUwj$=ejUwM5DGU9^Jip fI`1bRfg'kϭbר:INI~ƽ)vHtwM5D+G`)Dje$rzjuݲ-)mllTVEڵk-$zr8e7Oy-;Ђ @N-^zoj]&3}"S2f4/$^Zy۷O=3T===Dv+qR[~H:v9i_d8ǛlP[Jq\u,XxySS.߹sG-[jzy8tҗ"pItHRr98}rK9zz%C'dh^F+DӜEܪ[zCsszBs>lأ~UHJ8}4Q<~_cS_ev~iZ[[-wj (9NƱ4ȏ`YEt}żV̓<\b_)|nap]%^s5*9~ecIg;_51Xdb-E`=|Jz_b@$T RUQ0$`ǡܬ~C҉gOmRN++ /@+#,11bcrܬfffJr.]JV(*Kǜ)M`:q萚zdy:S%[˗k4OV>AV c=fEhQ ;:::_VK+K`WWsPE0!J0I6=!ھV<>,|e^t>WmG{Tdk?ENhD+?j6, 9Mcxcy3w^ /e2 W*6OZJNy旕S,O\pA=3[`51Q9djUqwU"hBK5X+Y.$zkJNf*TG[Ghu3}d[9z:RZzuI»`rW V~f \F!\$jU*]ڲl?U0YQǶDo^ܶ ]PEX`Dɪtd8WTWvc*Lr:XbZN8A,f Q90MV% CnT^P`Zj?rz8Trg =2 9Ԃ &Ύ^m}":x8r $)(DI/ iGv2Jd1Z|f "X9ES---A-\P]VݹsuY҉`%(&%el}t^Q￟Lq ###VףGom+u3XDEefDBvlOlߎC(a3,"XAnBN/Ii?rd^Dr#q(ˁOlQod`ttԊjy\.YDuttJRcȻ&f:y̾}r';oz![Eչݫ?`j9X:-%M;y>>SZD_(O~N:d,?Wfssy0 >e|.=.PC7?Nڱca R]$9V8J'ֹ.Di#$i14viub=WZ#pަ#\>$E*(A!u<9X![NC{{dߒ+GEXW$Ew;[[ m70w38HL1S9b `֭D Z+nP[9H{u:n1:?:2sn_~wsz_NVV}}}VͬzxbkY^_qc#B4qjݺeryhԩFcjNOS-vz\L;{:XTr'uvϞ`u|{ո t Сy`(,:2ךc(NBHCv;k:E|`_Wv #И_ݸ1v*HN/IyrK7ơvs 5@>^mxž?IrEH!'D St17(Suۼd]BGơk֞=cg^MTD&xCE++вΝ_͒ ?N0;A9Q4q̘'- ӷ3UOp/6_ΪVvþIGD9XLDQ-~+K Ze NQ/;S ]0hQ,󇾁#["X` X_R{V#[nKI|7wnGur_RF3PёqX)QdFA;, Vf"XھjƌK|vu'~P m3#&r Ǎ_8 }dv+.g-, V&r˧ϮeVsH3Dn2nD' FJ$o,vFqݒD)qr^>ϝRYό>PB̈i&j'oDs[nt8ЌwK ,3ʍ~ގ45xr_R[]re1^ <-$=j-9XG&|ba{EŘ9HC+v#0P_AmwEa&] l[y4&,S9ʵpr45FBbJ>㍄)r<C\퉃C撃J@YzX5>D /%Bd"gF7NQ]n%C̙:D0XX\q7}FTvmHN/ѯ&͡SQMH171y' UNBBvAUeƌ_ɲYrŒ8hh + t{Lu^V aӇBk\GzTq*/Qo>Ң… ڵk՝;wo;;; 'q'ݻw3awmtpeGfD_|0嚘{P7E+kʕjdd2O=RozoYp===nV೚/bj xNǐftBG~h u#^9hdMV`˛tX"]˖-l+Jaj,uT9@GtD*Si&DQ+yKer7%3:GG9>Wɮ]rOO+A_s1=,]ws}<ϸSo]s|]V]AXaݶȌ:B $u3 wa̡ďӪGDfva u`{m x^9?t:_(nSݾrGj2'+%Kސ$Css)Ztif#XqUF#ݯF Ẍ@tDR򥜢0b|+I*4QҁV ew/|!Z+In^[s?nBeBփOEwՉƮE`%`r[rjk 8L1tWeB= SEμ]Z;W|{ׁTӫxiGr: !ŸLx@Iـ(Q su(+6FUv%9X90X'K{ayz{;3b"/a:DZl\^*4%EsgG"XyE]+Aa)*9hCj(%'Vq6Gu?MܚD|f脎臎ѩe9uvD:#u3dJ57h;r: !eCGYnip>  bKrrfn$4y\o9̈ [|zTIO+ok2C`<<1!U?\l_݂2sUpjd} V S|"PaFN/:f,_LRL|4o{w<,Κ\}]v@DG˧W7n2gNxU+ze$+GKDRgrRXT0c cVz{3'*ze`e`ɚpRzݐ n !<[;u%s[WN2c!%Q$"HUޓ@DG˹2>~\zV<$ M3$${&:^AjgED~}29X~ ւ ,.YDutt8+:Z[[-wj (v|CL$i3\CR_s1;Rn9e~X32<8e˼1==m5kd*5ɍuv`F̌򥣹z:,tYА)%3"HRE g#(^W7dҢŋՎ;2~fr̈ NGSlRj)Vt7ѣ&j{F4L.9脎ӨqmlrתpOBF}vn3jƴ]:LfAPý=J]]6ʰe ?BSN_j$ 6^Ҥ\l?JB!|*`_az}7XnR=mfggU{{ZvewM>fr !֊~zbWi]N`NSoA[ s1s/;ovtzgV`Ǚ7XN{',69ɡ:̛wyn[;isC+@+E\r@'tD?'H $jyܬfffJr.]8u+Q/Jfr̈ IG݈P(e`uuuY;] b$`I4RBam2 fZnݻuvQ)L6Z0^+/3btBGH+ӕnݻu[E/he"":BCk:nT\b M3c700C'tD?D2k+8鷕eB۝QH B!`e`I]jyUs(פ-3fr脎ёV ŗ N#Xd{hN.:#D?t$+KE5x)ݺz)gw :#D?t$ %yQO"Qeg+eBNK۶1!BrcU@ ::ʵB`۷3a6 !8 6YO脎臎 ?33f#`~{ !w0脎臎V=:zif F :##$z)B5;;ڵk-C${nۦ`1AGtBGH+4:;;UOOO񸻻[Em kN~ &5==]5KW>uՍ7|?GԤ^lYdơC3{tҀE浔-] ^{e۷o.3߿~܏9{ֹh"C[Ǻ2w_|D Ms<AC:!XM0X2 'OT/.^/?Dqzl5x5$"PhR vY!3XqiQ L^ :pVZe1%)=<<唃%KeϠiG!r0D1',ޓ~7AH@޾}pS3 VhHN|wJ۱c5,u? |o~3xyiirD%KT2uV1'}e?yr5&gA K/1c0CX-0X1Iȏ,)H];ABf533S<-ўrי*&hd GG"X 2Z'*=ž.똻zy|kKr1γ޲˃y)"9:VR3 VDH$ d)AfpvF/ \= ېu:&&&Էb3K~M d=$mnݚy-u>% /cNfuHNZMMMgvLc1(OXe,?H´t-O$XI0X!!?$t MfP%H(a^caq$+}I~2ev"k^3˲^Zys=\qYˆ,yB^" ,o ` ` `:0X:0Xw0X  뗿Tjv~ra~ ,P?Huz0X uVPjɒܬԵkgvvV;vL-[,u6^σ` ͥf{{Y#&%Jt'Tg}ֺnƍtvvŋR|G 6 Zl/&~LN_{IեqSOӧOG2r, `^lV4%bzzzԚ5ko'G}۷iȑ#@h>sttt{Z%| ~ps1P-a,@e 38,|ڵk՗_~\FF̒}O?]4WH~ÇKLsc,@u D̕WS"Kp͖Yqmt2,ٷu22aHu1X :9o52iJdio֭cF۷O}c-ZTb$ZeF$ `kNRW)ח1%?я >+#&e$%I%뒇%ԏ,1qvc9X, <)yZj{.3Џ(/9Ss588XP .Ŋj<2r , P5N ` ` ` `:0XXG`T!lX2kIENDB`libjfreechart-java-1.0.13.orig/docfiles/XYBarRendererSample.png0000644000175000017500000004025511173030414024270 0ustar vincentvincentPNG  IHDRXr5@tIDATx lי+VUZUjUUUjUiUUUe!,DBaMHIRul6 ]( 8)@`IIu G&# "C<ss^ܙgw| B3XB!`!BX!BB!B!,X'O4>__2xbsة?bXmz!˙3gF_*1\2t<'X ʿmG_z߭@,JI7n ViĔύmڨuLH!ۄBlٲ'8wn:sNR:Y褣lnGٚ\8kZL'BKH[V8}'rI }O<}v93mڴ+_8e).ٳǍ=3a%SyXtOB'u J'wu;(ד}ݗ4^jRlΝ{@D]NV 饗~W'~cX? ?Iu0|?GJ98M{u[&`o.BxXtJ'/ ,$ڔgyƝuH56QOjn%e|OK 7 vZe/6`*8N L ?SpvDBA_di']92-W:wtK0_ X4o}%UۄB+tten2eҝ!i:fԣQA QIUߒN] V6PX*l{COvo! j?]ϨK*@O&DBȇ~WO5  rˀdt{G<N) ~0B.g.WO:_U㤧Ώp HTmwrQ͛.5wmu VP V៖#ǏwõH S@L8seUѓw?bc o"w9S}СCnŋ'zT=r,H~P)\ |q{oۣSt[oo 3j&DB\{yXJ({&H7?I59*6`K=liiɹ,:Ju+_G|C3bk͚5Y(t/~Sp&DB\š, ?š'S*)3#/ߺۃ"@ 㹦k|:7tKEOrR=xw9U#ǖ_ (5]w4?ݦ ?WlI=k8ܳWNmv/L=ލtU+r(YϷ6,3[?qX!BB!B!,B!`!BX!BB!B!,B! M K]\=Gxbg^14/NcT8"kܥis=I>}{T:hH=j1tbdETRIN녳zWVV殈9L/ O׋z5?nXYF kH| Si˖- ˔/]Çvwޏ?؝oquuek'׮]s/p;1/Bm6Z*ijkk'O3n6R)0>&}~o|ý9]L6sٶ{uڷC>^F2_!΋l5kؘJV 5|K?vE֔WUu[άYt>e~B~n2X~մٳg;~8on>88Jˏ{\al100ྣ~#w3yU~,'+Wdlf.w'qyxq۶mt,\Lwy}/cc.+Vzrێ)?lW`M9 '|+{^RVC:sLʓ`.61GĦ|+(5NWdVPPVW,[ܠ٦ R}6+TM٤ysRÙ'+܆-2}D҉џ4sm/~7W\>j]u6sݶ~|%z>in"[6=cc.+VR=nvE֔d" `RX 0|2<-]*>#8 Xa0&~ A_r"+,j?~X2׉AYRQedk'8aj/^qU/pO6f*BtXj{Qmxwr2Tw 9>dk_٦gkQWvE֔v kS`/D,E/^~KW:.[̍׾6OKIEmNt;LW/Ln]j޺ v/~1wyULqeۆB+/z|ԾMl|`,! ޞS٧RZ:*'"T|i\*_pJwH5><zV?X+t_'AL6cX/:JzDmE 7v6L0> -ke۾ID됫V^dk_٦gkQW &9ZmXSRzEW8ύO(%aq+bK_N8UDx t*,W ؀$z)T&Ё7nnC&/lӳ(b*/l;",)'=YRQQ #}:WúMTo>`㥝N5 Ŵi\d;v~(KtabD`Z;x:I;9ok~8MuRu@ ·>FuSF~;ʓ˗ `ek' _gIB~2m{ImYu[)\|Uu̶ftۻ?]p`˶4e˂$:e>x򻙎x}2=S/Mҗ(6PΙѱҚ5kܶ^reI`_P&ek_PQKu x0t4R']dnٳTFˤ[@SM־J! o Җn]k;xuk)RjB!B!B!`!BX!BB!B!,B! !BX|Ľ(<z!|S|WOK|IQb `Xc===D3gL744dMCC$E<: " X1iKoTkkپ}{bXo8ojj: J O |W<%`@+jߟ3UUUYX )5Xib-C?.4+-<%_ qGPd0 30 3&E+-<%_ -Zd*++NS_O jV[[{:0`ccciWZxJ+)13Xn5AAEO\xJ),VO|s^c}D^ϝkh}`1>hCg,^l6< "S|%uJ " "A Ep,2XE+X[x"-#w玲R`\i)dFhd, *2``XWZx `"`X_)J mzS_ A " ,j^_ |%E[,/W| ⊀S|W ,  ",W<%_`d,/{,~°|kç)*`#~ʕ+ t*9-:U*toll>2XA5X5XRgg{rPZhHS_,\u).w %'O*`Q+5X5XYۃ%KWxJ+"`ѓ;A`QE EpJ+,*`Q+5X5XW+Xd`XAA 5X+d2X+XUj,+-c]~M+++T`Q+,-ZdΝ;Vjhyd,/W|jR['H +-n UKK#5SWxJ+XLRVj8zPZ,_E?X_) `X`ѓ;W+X,  ,zS_"`X_x `X`XY=b<`A`T?X֭[7b'ĸ .A(+HGlb>Kkw4zƍ_^F, \ V:RW+XX-vvW7ٷw۲nb/qe V[ۅ"S|Wkj c*<jRĉi'ғY<% ])X,=-2떠B馁 X,:_]6u3c׮]d$7663fۂ^+XVywuuғMMM`Ik׮M:uꔙ3g+5!kReR:ohh( iӦXA`MT5X*j\IAz)//z%_`qG%:yYh~\S|W +?=ztT_|y|rcK l%XdW2XU`Q}[ʕ+,pZ[[mܞ֣(A5XE?X$y睔ӪO *J &wk߾}.s5ךO:bJ$n mB0<΃jkkݽXo2m8 V??,_c׏m`=˱COsEs ӹw9}䈹h>z\v\2~t9;wtSڿYf%nTΝ;f֭fŊ#XJ5 Y<% 552X`K[sG}jV^]T g|f, j,k g.`ͷ&Xg%s=W $`UVVXdW2X$,mVv35kLlZ{9kn61>\l[7&y>kd+bޮ'׭[6뭉R[[މ`ѷJ?Xg_iuP*6XT[۷oY<% `*2`NAX`d_ 2X$O-[W&,ZWjyx S|W , , -ԡ'+Zz`pSMt套LLM̞dc6%'굟, ʣS|X׉7t[,+ ֛o `d_, X555t@`XUL{XZ + `;y^? ^-BZ(1… Mk!_, "uƍ_!)EVS|, *,  Bn*ۅŸEo!lFq `X'NB$Vkkn{bXikS_, *n4Ts1iXv'._UU`S_, lm5ixnJ~[qA`XV)[%OJ5.hTPv_ ={?FaXGß$TD<o`XcXj%e`Qׂ,2XŒ~={nJ<%,+؍zeWaӦMnZ[[{r0acc#E`X,gzگݻ׮fڴifΜ9% `S_, *Iҭ:g" O |,kӧ]̙3YO,X}Ue , " )`Mn,ZW `ݸqu0cƌ;::,+`XVZvm[Nr]+XA`XyJ]vn5Wz"+@)X`EhW&`QB)NmzoyisNsPfz^yW_5=سcw::Lxp r5Nr…D'O4 "+@)Xy`=z4m z E`XA'N=n JOvvvMYO,~Z_X?lvm{`gG  `M~FaykS_, tջ;& uk*++,ZW JRܓ,xJ+`Xts,  J^n͍V7 NVO՚߹]< r'&na+M?7q{B&f׻i, ĀG,<%7شE:yƞ},,+`XVR7 AA-, €*r )A+g=>5`XF]u-xJPc˖-`XY<|,=s , EO, kS, -B=r `XU,]xz", *2r `XU,ڱcE] `XU"0Xd*`5MsΑˑiYw,k"֍7\IpUWWgܹSt>}[m7Hb|__ĸyēg=Q s˖H'`7`]~zU)-ݻIe"<"ۂx `XUi5WpO>\v-1.Rjkk]=?/ц+W( ױGX-}oVr `XS_ ` [7k׮o߾2Xd[( ?o8`nxE{RrX,@Ipnݺ1nۑI5XAk=%NX`XRG4ɓ']vOO&ك >E`mSbg, €u:ڼye'L}i'L-kλ}ra/<\\V˿|, , "U2U3fIrS˱ukz ,  , ,2X`X`X5Xgu}޼Ȁջt7 , `MyF7U̓g1={LZ^{7m2/dz[ZL= ݶ^, ,P/ `X`Xd, , j, , `XS #u, ,bV `X`Xd,kbE"E"`XE+:`-j``  dt, AGO"lll, ,+n5, , ɝ, , "`X`X`Q`X`XE , , , , `X`X5X`X`Xd, , )G{ӹ4lakݍ}xv, , "U"{`z`'; , ,j, , `X`X`S޳'#;wX`X`*`%`X`X`X`X`, , q\7:tߧpO}ۿi]i=܇ՑÇ, ,  ЦM}&RwcV, , ʠ!6x, , FYֻv4a+fyZ{9ϛ&f!f\͛M4Tj,Mn3Ǿ}{a;, 1P ι>SUU5amW^c>;!r8p QpU"8^ RU `X`XVjUTTe`Xh$E`MJ<, , J qkl]]=:bƿrŊlcrvC-]jjg]iXWk?ˋ{?v9v>m綯g?k on_ }k>ˇFmnӗ'ܷVpjyo_=հ߾v+^ھQ3m|GWyxb&W3myh9"o_ ez2m_>޵ھlߟwnl~uOlcQq}4O}ۈ#;쥖G<}5r4M;D)-qE !Bh|4kѢEf`` B!+ܓ^VE!UV  "]LBG6<OKW q S|E `!BMlX!BB!B!`!̙3ݹsǬ[̘1M[~}b:y+pԓBt钛VhwW*UifO3MUcv^R^^ B<ӧզ?)+SUUI+VGWjjr: O`q9N6m^ )UWÇիWi{t||t0Q̝;lܸܺu Oximut|}dkwQi4ߊV,uŊ.T'P/^Nj~z+|E[,_՘xLh+m5Yǎ3 .L ejwQiV,U)}A^}}i-2ΝK|WZr5z%_S4Lh+mb|ɤbt2XbU |p =!Aqx]aTVVk588hfϞY<4::V盛eE񭐶 `HSN'|:Vv'~E!4YWZ'htlӦMxLh+m.pB!S: OV̶ `t}(UP#<|bU3k[ht|ݻw]9s8fF[_iWi1*B!TdX!BB!B!`!B! !BB!B!B!`!BX!4g'1͛޽BB壇zȁ+~7NBB<ZΝkn߾mܹc*++8M:zy͌3ڵk͍78^3gt/weO>m-Z侃BByf@fMO8=]pccc;+wtt,ABBUUU5k>ߺu+1GuPt7,Ұ2Y)Pu7 !,ДPWWW <1-ࠩ7+VpVQQ4BBMY!k/]Ip/,B@Hɔ[BBeN7~…իnܩSxIG+`BBe!h@c9sӂҹs|7X! !BB!B!B!`!BX!B BX!BB!B!,B! !4q g  XBB`/ !`!_! !T`cN, ۷3wx`!,VYYYksBXQ^ !`!jjjLOO톽njO?mz);wu֙3f SWWwT378?EsssA3|3}tpBs97wޱ<הBBhBŋ<>믆Ve˖=jV^>7& (ǥEyر ؽ{ٰaC;7o6nСC5kp !`!2` fHfpp01,9s|۷or5{Μ9)G1mڴBB؀IW^uח_TJmN2˖-3,8[tK,q⼔R(]J5g,/4mU `!,ЄK. * װbD n%#U]]j$el5S| 걂5XG5b7np˦bw !`! 74橧FƧtԠN< UuIENDB`libjfreechart-java-1.0.13.orig/docfiles/XYBlockRendererSample.png0000644000175000017500000010112511173030414024610 0ustar vincentvincentPNG  IHDRXr5IDATx Vuߙ:NNg:t:v5h4%6&5jDAQ @4(^((7EjPx ⍨&6=?y޼3s8׳g~~ã<,À[-D;wyyxxx<<:yIҗ7i_u{Gs9c ??l?Ӷm/ޥ^hӧO??ɟIqv7X]=z 67v ,_oAD1.wK,iz3uw/REq$`( ]::2L9}n.cƌFGqL$Fw]w]74|W+jI5\S#`5CVa(5$?sL1~'Ϳ/>Ӛ .0ڮX6m*oҥ__t jk׶mݟٟۇÀۏ{W[M1bDooījkF[?ƍ.޻F |x rH38mȐ!ٟ}Yi}wL<̶??nyW }q;ͽ_@_ww׵ T@sYc͚5m?Oo5Ӽ >uWg}I sw7Xa0`yxt5hР¿@(mokOI4>iҤR7p~<'MU^)᠃!+WtsZX~Gc|»@w GFp/P~'uc{bzx<<<'EC#Tz:e]V*1ɏjx*z$Ǹ~#=U.FhCcʕq;6*^j,G(Q[Io|w[(N8!(q JC27^55?k~^`Vb~Ae*:G4T_S[kVMN<RKGOd/_^FYKps9}$.Fo; hN |eڪ'X3+K9T=]wׁV?j̹uȶ=ɶ~W> X,N嫨VUPYͿ+FQ# Py`>жǶ~$vb.{G^5^[5r5zU]U0`yx<"lu㏷Z>)m%k_gpv *!.`_\XLꪫ9'X,.9F5X Z X[li; &;;ب F96jUx}'ɕw6Pwh3TTE,yUɋFW9 jZ XUÀahP*>9RĒJx XI5:|0m5l$k7 v-zĜW,=;s~Iu=&xZm޼y_]4y'Yz]R Q\=<< XEW)^QSV|uT_k{`>K%Zbe/2k[sY XKnygV0`yx<މkD{gA{G/˕ϠWկ~}k8'_ <x:蠂9Dzh"^?OtG$:#},vB}ѝJ,'|>(׿uW_}5Ѻu ZjU'x"т 3gNS&0aBk#F$"`8}&:3H?G?J9O?GA'xbO>9Q^ O~NO>!6O9ޟgx/.Dh.h'#GL4jԨN!Xy><_·9r%^^?^_6@;I5#UM;cmI\\} DD }#'DL?M?.30^H);K ˀe2` X,ˀe2` X,ˀe2`yj hD[l)hӦM֮]hʕ-^8u]vmnDcƌI# 2$х^.3HPsO8D}}wmˀe2` X,Vѐ]_^ʾ X]d@s9V9jŊ-ZTЃ>h֬YnւDW^yeaÆ%JJpYg( aEg9$q5M.W*Vܚ̙-ѣ $dĉ|͉LoO4mڴDSl֌39sf2qHGOW>~~\g<`q'9΀գG+C̀e2` X,ˀU&s-YҥK-[,˳z~C|xsynxmx|1$21*!As]DUs ܨhUVD7_}}04D_2yZK̺5 X,ˀe2` X,ˀe2` X,n XyDlɪUD٨4j⛫~'bn+vrC!b5b?("ngQn)+>3Hb.|d[K,IDՉ֬YK /DuK/u=Q#|H3+]hhk(?6]$-?O)V }}c:DL?|Uw.$]ˀe2` X,ˀe2` X,ˀe2` X,ˀe2`Z*fA(Z}I:6'|rV9V$Z]D.~%Psv'Qk&"!s=li7SO=Ag)ODx YJ"&&CzY曕Lc|9yxmxx}%$'5c6MĵɵQeny}04x]Q,qIFˀe2` X,ˀe2` X,ˀe2`jAɚ:̩`7uX+%Z9{r-m֠ɵիWA` -C]ŹfE΍y2Qb-&|b!7Dx lDnN"5HmKP^?QTGc|6#3kTw׆/e Nd5cGs]D>%a(oLKVg+pEyfSw$&3` X,ˀe2` X,ˀe2` X}h'}HnX"Vvs3h>LB \lS!q pB#q T~%b>GԲk۬n)S$bJ$nfk(9`C90 |G>D|IO?47;Ee|H3k`sh'QmA׍ĵ:+Oo<ѿJ<pE8gQ Ɲo X?keխKFZKɝӧO㎶ڀe2` X,ˀz)\tU2~9z~/ʸø$uQuDEe˖,տ|׳2` X,ˀeO Uz'xb9sfۋ/ˀe2` X,. X_X рEƷv>ggtuꩧ&j4n"vf= m`ᄏ $+WDfHԲ4 ('V+(IY[lI9o޼9lڴ)+^2qH~+ \эpg2^H);Ka+_x[ }y X,ˀe2`J:X,OO] ˀe2` Xn X;c:iq uOWfZQ1Xme0!SߞhΜ9XYZdIիW'z饗 bperr%ZrF}G#ٸqc"p׮][ /8z$Ӛ5k~C|xsyK9(r_z}gJ?Dy[< ~@?r?)QƷ30^H);Q>؀e2` X,ˀe2` X,ˀe2` Xơ6xDuY;hT۟s0?Hc)W63O#h錊9x*Vy(s,V~ ܯZ*/] ^'x"Qx{ŕDc|9yxmxx}%@.G uVy_5u=' M][Qi>GOW>8#ߊ(0` X,ˀe2` X,ˀe2` X,Vq]p R+r&ʭSTy@_`9-˗/O! zy=ϟ_Ѓ>M}ެYex<ov3+]rh9ry\:hōEb|TkK? WПzFEE&?ҿJern˔aa\o?ˀe2` X,ˀe2` X,ˀe2` X,ˀe2`JYf,Q=z3QFoQnD܂jUuO(_|qQF%7n\Ad϶QM\{DhYC(Ψab}(y9OLXiŊ"XZpa"@-r(ͺ; 6mZ"&3I[o5/3=<F 9r%^^m `V;kp sGh'GEGHIZ憛~}Vjˀe2` XSpkQGھ!g-,ˀe2` X1uB@nXZZLzeWCN?hナUk\{m{x+5D^{m[n z>jmQ5 PEκNPOX|DJA #fXI Y+yLze,=h&Oh„ H NcUD7 ~~MmҿJx!ʊg6`Z3?v)JwqE΀e2` X,ˀUr1U` X,ˀe2`phGYgվ`sdeazꩉZ>Ntvzg'x.Kt5$4iR3f V%t&` Pq֭߰[ɧڼys":{ 0>#=GB &N(ڞNh3fL"n_9rdA_~y"ڞvRÆ ,~!Xy><9gxmxx}%v$hW)uS2yZQ1}VtsBGHIۓ%e(k2`o>jȑ΢11lE(j2` X,ˀe`hTv{ekJp{` X,ˀe2`aa[zg,BכUe-~WªҢE\2SKZ"Vo.Sr3wTbUzDQ>ڵkљҴj]ws7'r#F A;:thA2`DW /,~'|xQq^#(hڑD[=^%4LZ'7}DkCIrǥ7enܣ{ˀe2` X,ˀe2` X,ˀe2` î6*ӐR˭ʚ5dȐDQ^ =ܓ(r6~KHZ~%J.x7sѬ2焍%\\3?'*V\rI)~}&b7MoDN{,~'jc|9A _ȴ H i=Ŏʛ,SځFOߊ愾L;{챇ˀe2` X,ˀe2` X,ˀeڡJeUJKze].2jU<ט3 ` Qk|r1FC܍-[$R=fENNɅVTްaC"6]lYA=X"ngonJ]?h(`.4pDn)t~z,ڞr) !Xy><(OsyK6~ h'Ql*Ѧi\P'OFOߊJ?ҿJ~2}=BS_r,ӿoʩ4S46gΜ/JkE>Āe2` X,ˀ48'O/"{ji2` X,ˀejU 7Mjvʪ^ X,ˀe2`^g*ͯJ5)[:J2ʀUq(Ijr!%&^p1>%&}3Ig%89Fd͚5d6{o"ɓ b2,DI Lׯ_AL&<_·9F6~ h'Qb5mH{hӴ{ *p DDE&?F%zƃn%m3(i]VZc22` X,ˀeK$[kG#ʷe2` X,ˀխKP9ؼP ۣׅ*ˠׄ']j=x`VW2Ъ9W.:;ZEW\qEk6є)S չbutQ VoD* O>d~8QTwhڴi&L(ʧbԈr3X/\;h(DgMMG5v82F _T6@;ZhW6Mຉ+\:S;F}_:Y}04D_xx!1ꎀ X~݄r` X,ˀe2`ukÀe2` X,ˀeu+s?g /04zD'NL4cƌϟN3WAR`ʴiE^֭[.v̩[D~{A̳;f > 5Js0'Or΂:P ,jEЎ$1ϤM.n"#XjE -5)WʁO*OӏKQ9YEh2` X,ˀe2` X,ˀe2` X-\y.*zOϭtV &ZjU_~9Qs%Te'ZW/fuT& ,}7ĭ1׆#;acgd4'9*h'QmH{hӴ{ kS:J.T/ɕq?_%`F՜(/+W]2` X,ˀe2` X,ˀe2` XnXj©*$ֳgvduA!W=Ԟ˷rfΜh-]4 /W_M;Vݪ(?OQvn4lذDZ߷o߂hljyж4x-8|\2L khȟhW)\\QI-?OjgY'dzL>GOW>~~2Q~iV`(S}͉֮][+-?c4VLh= \y\cOO ~?㐪63`L$*9W]{<ק5u^{+:EЯI}}0~\g<`ShэWuC.jn X,ˀe2`8NڞSI& <8Ib,ˀe2` Xu^G̩n XB+6g-,95ˀe2` X,VC- UzAsyZIJs; KѹM0 `%Ij9άj+7L~D3[xqx ѝwYmEXC( N `<Ѭ(2`"@G:(QΙZLMJ46R+qHѦ 4"I\[\\09U_Ԓ'wӗKz駣fW vϸ{ Xʩx%=u X,ˀe2`vW5 X,ˀe2` X-{Wky^' ;6ѭZ/A9/Dr9WQ'{֜裏d5kV"mYÇO6QpWEA6z%jBPr l2`DQ+C&b-(A낿c|#LkVAu@4Fjq sG+Oo:~1w(OGBbLaa\կ X,ˀe2` X,ˀe2` X,6W^9א!C 5jT"r|D-٬-ŦMDy U󭢜+m$h믿^кu}тhu1bD"^HW:[#'>;Q|/8!s(]y啉hk6/3=<Fyw3+]U+jE纈9_t$ (/d?_%`iqBaa\ X,ˀe2` X,ˀe2` X,6WYQ9sD$2u]s=+$K9WLB&bƍ ZfM'x"Qǔ.Zp?z1Pɯb tIU:gjD[/DB 7P|͉Bo=QT Xy><_·9F!xmxx}%@++Ms]D~,W̍"9D_AB#U*SU/$^ Ɲp3` X,ˀe2`:UwT܀e2` X,ˀӧjwW۷~u msZ۝%9KsB#monE29WQEEy-$b73:s@U^T'bQD{?~|"B-w}wst}U?x</Cq^9 _'CWrh<(/kSz(UɊd)7qBGȘ+ }_v\GRchU1` X,ˀe2`5=z^gѐ)s X,ˀe2`2?.EN<6W:s=7l6Wa2n޼t"C\ 6zn;sT՛Y9vQnT.*DwW$R>B'#8,ޙEp?p"V?6K ~C|xQyxmx M.n$_I\\"w#n&#:R6DqqI:!QNZݡF2` X,ˀe%K2}$Kѐˀe2` X,+SNm]J^B\l0` X,ˀeրEݪ¾ }ݷxBrF]ФI͞=;QT+-%^~D. k\$&2yk& PMY5`ˀ̖.#G,ehkΙ3'Ѽyb,YRZ*QT瞫,~!Xy><_·9Fm}xmxx}#袝D5lȵẈkS:+r:'DL?>zښʸ:`a2` X,ˀe2` X,ˀe2`vKR߿":ֆ>A=3![|<[&W_M0/1C`NHԾDźC$OE5x> Q}3f$jK1ڬ\2Q>UaÆDJA6mJD%~'c| 9F76~QmvB;r7ur.n$\NVSׇv#'oѯAJ?.3D9);KAd2` X,ˀe2` X,ˀe2` X`ɘ9J[:sco;}j7iӦ%V(%T"9:eص~˖-جիW'ZpaAt*SLI帰UGv:%r[ޥ\pZЖxQP9sf"(9KDڄRD8g/&boK=? 'Vʎ?+χ8gר= DЎ\)Vẑ$ (jن:1 4D_xx!1*Kzˀy X,ˀe2` X~e2` X,ˀs묳j/ޜ|F!'ՙsDUn*GUYyjA9Q\Y(R 7ܐhĈ 4(7\iEU޽ + :QQTrB3G+ ,10[ܥrg{c|35mnhe*t4,ޛFS:: W6HI[kRUר{{T=W]݀2.IvC4Q Nھ`w3ƀe2` X,+;.nQ\2` X,ˀemerbNEd|ېȹu*GA,_ؐ*{oA іo6+fr)p renag9s /~+IhUvJJ3DSw* X,ˀe2` X,ˀe2` X,ˀe2` X,ˀe̡nPκ5r*+$zwaD3gÆ Z*ѣ>.hɉYսjT{b; &2yͼy1WbQQYEurj|r%q8w׆/oDD˴5ZX09D_AB#'ZDsZqCJ?M?.↔q'wG X,ˀe2` X,ˀe2` X,8 9ÇOߟ'H9kveoE]:u]^z饂~Dlu1ŝ&LeС7駟(SUTCNIģ|{'s37Ö!Q+\*)r:$5ok+:[+)q sH'7}R9S7~\g<`Sw#<Ҁe2` X,ˀe2` X,ˀe2` X!n?nܸDӦM+(^(Y];ҥK͟??ѝwYsȑu2g2tV%K$@lO{FRhGQ?QqEr%Q ^^j[ڨ.Q\ < T'7}Vt3Qk12Swo~,ˀe2` X,Vǣjamx8p`[=e2` X,ˀe¸w6֌ FCz\\E](8#9ZrD9AgAD铨W^U+Gy\5ׯ_(_,k2k֬kJ֭+(sI<bnݚD C%~!U)rkr7w׆׏W rD#5OZ=)UAnRs7MjUk`nP jtZď:nX*C"?hq"4` X,ˀeh5˶^ Y={l7uⶆ^IYN,ˀe2` X$`EsQ(k[niCvCʀUqz衕sj ,HlٲDe'K6rی<6t;َXZ:XUgj6ks[ZuQ~QU [o%rXր&*}8(/+ r+h'AAjeI|IT„ڀe2` X,ˀY'Jg{YRNnD;:'@FH:;"݌DI_Ajפ)V"l`1vs=-2` X,ˀeKZp7naSoˀe2` X,.X'tR;d B٣JV̙3 byueD%(`j SX'>`UXQ\WI*Z3r-\͸:Wf\T6ՌXUŕ*+FWʀxcˀUSUfg*} X,ˀe2`v$w뿶'X,ˀe2` X<+ctҷ9Xrs,`vI݇j3Goˀe2` X,. XZ$' T'u X,ˀe2`LCJJJK.v*`͙3gXˀe2` Xg3ɹVY X0` X,ˀ՚WiѦ6]}{  hȑnDz.-X ˺u m=Xzm?m=Y<~έ (Hw9:Sqy繭OD~F~_t֬o9ZGQ?ZjU 6e˖D~aUO =[|1O/3=Q k.E9f HiRIsL&'Q\Ir%Mm1,z 1qqI:ꨣ`ٳUm2` X,ˀe8tLF^vch-䉛ˀe2` X,XvZ{KzO?_~ir!m]tQ#F$yq;ҥK1D{DQX4k͉ܚ'|2у>hڴi7.6g?YA}IԫWD'pBA*,,N<Ă%GЬC-&LHNN܌2 ^NG(Giіv~'#sq^N^?^_6@;hW6Mຑ>%asFOߢ_O)g'Qzƃc k…aqb X,ˀe2`uKSs=Se X,ˀe2`va2` X,ˀk[;k"% ZXgD9Ag.I s9'&`g{xѱ@\}1)ɒ%KE ruXIB (A%?_V8%KWQ? D(8hmT]ȭhm6 IUoP jt ݠF7&5w*}4` X,ˀe2`uG+Bˀe2` XN,K?.q>|x\ 2u\OUu<Ӊg2ŝr&Q^S߾}LjbK\{IĚI+W,ur9YN+\S>ϨS*S\UT׆׏WʵơIUE5r&O&J'7}V[G0%#j 20.I-bR6`:4E@ʫIˀe2` XnXsLfg=PGizMBW_}6O X,ˀe2`u{jnתwqgfl_lAO8eʔ ~ʼn֬YS+wIT QI%HԮ-A}DQ[ɓ''ʵ)$jsS%}>GYw^A_|q"vKmO޸qc MgW\Z9/EmhڑD[=uk!:+Oo6RRQ:J%z 1 q]fB=+CmlZO,ˀe2` X 98lذ$7JOA˔|JOXΪ?y8ˀe2` X,N/Ӡ ӏ׷ V vD?.3n$Ɲ膴%9H]Lm9Xײ@~׀e2` X,{v6^6WnL:}`.B= ^֥)ˀe2` X,V,YiW'Jy}|sm9%{k4iRc6`}>Tcȍo|ḞꪫM8ٳg'R͏fX nNpm;*?T&nEs=7QTz{6D/Ь޽{'Qߛn)+hѢEX* Ox` KD 5Q0-'~'Fc|#q^9 DDF{JT-<묎'7}R+PuD</$Ɲ(Wr%:ZRVnX۪Z(ˀe2` X}%PF=,%x"4`djU X,ˀe<l݀ l8 NdF(rܚ`D˖-+4/eC^V֭[),)ٱY9"GnW/|";)YѶjU(gY3f(*Qw1ח,m[#(ۺuk"<^g{uc|94J HzQF"WLYb~@?x"ϠOG78Q9%C풻U^T UA7 ĀunQ2ˀe2` X]Lk'[ ˀe2` X];q[>ՏP;TPր=ڞd,ˀe2`T⨑ҫC.Xdk\qƍWдi=,YR8ّISZEU[H:/ .,H5Jb0ӧOAzj"Ū.} 7KDj͜93~̀Ŗ/LʍhE6??jZq8w׆׏W NhGR. .n$-v]D_(ZDܪnnhQB>}=ĘB;r!]TB驧j 4JWފ΀44?:X,ˀe2`o(QAֈ>l4Uw X` X,ˀe'X/ \h4-(F-8gvymxx}%v$UmS'*;- ק5uN? ^nf\[54D_xTbLaa\:.X_sL)YCEGzi2` X,ˀe*;Ti':'jöme&ssTA|b@SfEkID'3`db+]xᅉ[b m-jE2gΜD p=X(G9KVJf͚"Pˉx</Cq^A^^?^_6+ uMA.J#?re49ߗkS5NrqhkcJJx`]u' X,ˀe2` X,ˀe2` X,V_~$ZٽL RQf =^RfmolC<:T`YܪA՜,KD`myr`<餓ѮpEڬu`~Fs=嬶MasOD%~'c|5*k)6@;j )WZF\Ey\\NiՒ Q)'DL?M?.?ea\ԉĀe2` X,ˀe2` X,ˀe2` XW\5cT}nKt\:96<_·9F]xmx"xoE1*@s]D~kS:ynofΝQ&*Aqn/$^ %IH X,ˀe2` X,ˀe2` X,ˀe2` X,k,]F\(/7ԱA X]h|+_)8*&7:oSUbE)a^ڴiSwy'⥪Ie0I5J|g;G} 3b07n\A#FHkZ?:SNk g(jetaB7P"0 j$a"o~y<o9F&FjPimvu]s-?Ok<Kj6Ij(j^I>; qn%;S&եh֠A X,ˀe2` X:{o=ԓmW_}֭[ X,ˀe2` XѣG!~wۀ^{v '$ZKb(_-BؓZ~}"vzg'xvdEyYeǼ+{DQ $b#2H Ь'G͢F$\t zF0Gy?0q$MaȰa "p]?|xsyK6u` P^%4"d-?Ok~@ZϯLU?_%`:z~W͗8v7 i[$0ڰaCn¢'ˀe2` X,V%Tuu)2` X,ˀe%_#K>2`eٳۓ؎>趞={;eMll=ܳ$ڂ,yonwϘ1#ҥK b'w%5K,DyYhRy^ xElW0G8 N|tpEy?x>K_߿e3=Q+χ9θTx>Mmvu$-- p&P[ɹM?_%`iqxV3DTfԩSw6"(V;˗L~YwKˀe2` X]k:֖Nˀe2` X]v0`5 mS qc=U阣`tE%+]wuq 4;/Z :3h[o9R{+?Gl͉֮][$3߁s$M6-Q{;(Aty~xQWT>'~!Xy><b:=_$ЦsUٹn$-?Ok~ sӗ.?F7};}=ĘB̐ˀղ!m`Ui2` X,ˀֶ[N4mX?2` X,ˀe9=Vҩ/$9eB='&9sfhKt՜,V*s;t5ojeEUE YE9j]$iۊ^s@&љZܯV,|Toh'?Ut@s]D Q檥c"oE7y}(>~~\5r93DbklBnKˀe2` X,+ʐˀe2` X,wxDɊn{XE%6V.\U_~DoFA^Vl. [!ެg}6QTNtw'b~O]U:gp jeVmAZ"8Ys#mvB;hk&6Mຑ>%\ s~M駣q'Z!6` X,ˀe2` X,ˀe2` X,ˀe2` X, '([>l$(񝉒Q 'fdK@6[nM"ԬY C=Rb >|xAC IkKc}#&S_7\,U9q8$>G7OG(?1L6/ˀe2` X,ˀe2` X,ˀe2`z $(/+JGK]y啉<;3<O3ļ7|3Qݙ[[\QG}(\t1hpyn[9ϓ'O.[m.+Hɔ0`@~ N; cʢ|#x+J.)m}I.JI͟F{JЦi9*T\RgkF$>GOγDL?M?.UmS&ʀe2` X,ˀe2` X,ˀe2` X-FN_5'+Nmgnqs7'={v"nŎ*J9lٲ> ѧ~N2[sA,Q/[{,Y bl:5*+tGz?DQUhV '<~"HիW"j9E)7c|9yxmxx}%v$hW6M纈nVr@ժ.'7}RDGHI*OG(oLΕˀe2` X,ˀe2` X,ˀe2`Z6kᆪmaЈ*qN/^hqq-Ć\sM(@ӡ3#* C߾}E7?"DըkRF ~O c|9Ei4mH{hӴ{fj~UnrUo$$hNre?|8`4}=ANq%wˀe2` X,ˀe2` X,kGٌ^{z\FCz裏nѣGYن޻'R5'+6*4IE {DA-JrD/RA;$eJ;3Ͼ[k׮MzDQ.>讻*ׇQ;vl"@T `@;b.Qi+!^%6-#~'q|x,q8w׆׏W N *Ѧi\Q'f+OI[k} 'm@-^>zƃ(7c&!n%Н>}tWV0|/lOyto2` X,ˀeec׿nWvuQ,ˀe2` XW}|eȟECW.2gʋ pq!i L4)ь3 7o^"V73^~DevF>G7l.uD~"Q7oN +V$z'E^YQ%i68qbn 1cuw'D4lذg{x`syJ Himvuu5fQy'7}DGH8}p͝q.)^g$WInn X%UI3` X,ˀ`ŒXA^m<8òꖀQ"[8ˀe2` X]U6ќes4ٶ7!΀e2` X,VSNmPDk8z]v١:h <؀Uw0w}+,j֖կ_d<ͺ+]{ZLl;K,)h͚5[vY|I"ܑxof(1~ݺu8GQ]W-fEAbܹF%J&L<9ф EDۊ%j?&|x,q8w׆׏W NhGmЦi\UӪN{+ΑDDE&Ѷ?_%\VbFMZ ri?̀57\zrǶf V7&I3` X,ˀJ`5@*%& ˀe2` X,VF#m{ʝ0{(jEr$GhGŽғO>(\t+: ejimܸ1Q8}D̽}$ʵu̙S[yD99b{ y$zb,HUF{ۊ`GrA<q{j5+ F/NV,/¶#Pa*7 y</Cq^r%6~@NhGm-OT*~&_5Ox=%$\ }_ Z|˘R{3` X,ˀe2` X,ˀe2` X,Vq衇77+.+Pg['\駟cL vwH9<(+3k*>D 4e"$z+N7x#zlR59=qWZ.]Z'LN ~Od[GOW>e{Q%0` X,ˀe2` X,ˀe2` X,VqGr}ى:g+al;zDQUpEXy,_lْ+hGlWrNp}Ts5eІ q׮][ / k8$+χFq8w׆/ի ORg$JH\[<suuTT[Q#\κy2^H);Kl2` X,ˀe2`u1`|G2` X,ˀe2`KַU{%$ !uꩧ&U-SݷVSN9%Ftt\tq4*Kl\+W/&5r\|VEm[n-Sʘ'@9JJ@X7mڔ_Dc|ܡ,E% xmx" xj`d7&\09D_A'oE7}*x!100.Izme2` X,ˀe2` X,ˀe2` X,ˀe2` X,VWsLu]hĈ +wމ,Vt\W]$xeؒ"d?{DKhѢXψ L^XurIR%O΀(Fo2?)Q=1+χ]s΂:5xR.a"Cǵ)q sH'QM\{t3VGfSw:ʀe2` X,ˀe2` X,ˀe2` Xwݶɓ''k >%as$jU5PթW vf:m~QmvhQ4"ʧ$ >)Su*D_xx!100.Iw\,][uZh =ҼuJW>r J  X,ˀe2`u]ѣG!bŊZCNEZ˨v X,e2`hCEn:NآW^YuK+?5T'{{hWC[hyDsIDrĜ\hO>HO:餂"m1Sc {ЪW]UMfĀ!qr)rQNĎbePN®DzFy2 gN4w܂hKܲ /q?9;*˗gŒex<oTfsy _K H@q]pH\[\;**_?O`9Tэc NT6D9pc=6+ˀe2` X,Vo꯲2` X,ˀe2`v袋 \6mJT.tY7ʳ5jT":Ձ&۷oAtV5.9Qnf#Y(Kv,:YVx-ƌ(@:iҤDQ״iM>=4gΜDEKDy衇:E(r>$.EDЎ$k|^8]|-~%`%(hD"Q Z- 7Qn ."mBJ Vbt~g3Xy3g}99:uZqDžj[TXzr6[;ܧQyWr!O|':ۍ. X`!X`!X`!X`!X`!XUٙ /_8']yenl>|n/WZW9kZ*VlMyKĺ6w&f V;w2[o~&"GUI`hh 'HķPC'r;uMV}?~}jij[go1ķ5:^-tLɓD*︮zڷ+o'_y}5j~ywrR*P`!X`!X`!X`!X`!X`!X`!X`톾 :}ҥn{`zt!na5utA.M߱z2.]rBĮbru9 ޏn֖ ]@}RfB_xۙzG:k$^'T tO&бBb100Pq迡GamWBLWkJ?1w#5:^-IQ+6'}yDUsGku5Ok\'S>yG% _`!X`!X`!X`!X`!XX= idWX۷mKoGp nǷ݇Z>###N<~؉{eBwI':hM_¯tKjtW9 ŋN`'eZHX]9xWWW&tNմ9E,`ZJag'OҳS B, Bj.$'ODj-Xvxvvv TK.`!X`%X^4o*> ;w*J']z|9>|pNLMMebbb‰q'vvNު[#6Ftk 4,tHU;Qѿ+N"HN4D'k׮eB?7o: Ž zZ_m}푴ϴ_}kϯYqⓥ~A<=8>\o\hNҼZLsG͟_-4kO*dzj/ X5:jJ:B, B0jn׮].+uxCCCM`YbKv8|Ny_%&gZ̙3N455e¾.Ǐ;qرL9rĉ8wL޽ۉ;w:}LlݺՉ-[8yLlڴiա]mŶmۜcǎL}gϞLh۷ωgB?:q!'>:T6}?~?,ϴ_}cZ?|IYǀG1~8>~74'iҼfOr j\};i9Edzj/Fllذ!7e҃Ű sssD;`!X+`[y&h+0 %X^4AľKuuuIsss288j` XawѤH!X` T" X , , @, , , , * _B|ҩZ[={nk{EOl'NtbBlo,EcϘjL9 ܊`!XQ V)VIyzz:pZ[5… ׯ_Prʕ@bz!7>?c1倘r+` jmmMfggۙ73@;۪5!7;""XV4eٳgdqq1]yvYx$Z[3j}6=*!7>?cXs+`E`uww{mׯ_O>~mKhm-n[dru-!זz֟r@=ON6nܘV^[™utk{{{mL:;;!Է\Z[ RV:B˭֟U% ISSSs%c[ZZ BoQj[mA1͘3ֱz9"XVbre I)`?Bk7wޥtq֩]4Bmo}S4Vc1V Α9^ '!jZ2&vSۚM`Clkbjo ubϘZdvvvׯ_ϯDRޞ466&cccڒE:Z׀\5E`]0??IZ:w\U"'X3y׮ċ/Ry {* q X"lhhH!U.W^MۺUJ\+LNNy@V8 ===ˏ{-BK|ؕ,{~V)j[ V`!X4BXR  X B,@,@,  /DmX{, @z %XIENDB`libjfreechart-java-1.0.13.orig/docfiles/XYBoxAndWhiskerRendererSample.png0000644000175000017500000003455711173030414026304 0ustar vincentvincentPNG  IHDRXr596IDATx Tyd[88Y:zmwL h)ha1,CQJ傈,cVPhQiH+VIC,%%*AE"p n}'=MwOܙ{NAwOs߷{/!"""\,""""EDDD`7T,*\ . ⋓ $@}կ~u=wqm=u $=ĸ#Vz䳟lz,u?$LT~L=yO:WOZЇ>4V*#}v<53U%rRƦDkeXc'l1U5$ m^z #,*`Eq˖-㞷f͚@<):l kַ%izi￿GV}_uS=NWK+WŹke*׍b:y:cFSj|d n瞆k3z_ }0j/-c裏jN<UNNh8{~L-;fT-vǨg3WU{h14yBkVcSw2>)iXLvROUTȆW)L1ZR=gʩl IbWL77kM 6) v% tLTZL>ssB1Wy bqnv;B{flڰ]'FbQ5豆RM;vG j摇R#Xg;Uڭ'СCʅ' D2Ȫ|,hс+!pDcu+SHNTGi5 XNbR5~3wWqhgMV,DQmB4g [}yTVLU>>k֬bӮfFL['#k?1Jh+jZQ%D?soU}_מԚV4X5`FMUwԕ˫U}y@F(^Wi6Z13Ƿ<k2Fb\upuiѓh1]^3v+I& zQ<r /ZQuj;+^0xǚl^uJjXgqlXWeGޱwbDa+Vm9ݼc*clOFϏT$TN9r$XWbp"kU,^7֓߉' 1Jա+kx쫑[Nj[bŤnI'`mhh`U_b裏Nj;rȤnI'`K_jdEOb_<%Vii,Ċ/xK,k_<ŗ5X_<ŗXe `;4M4 `r×X_||6_<%֞={R9s$ׯO;>v;H x6::j'Ċ/V#Z*ٿ SgΜImۖ,[,}lɮ]~wΝɦM4M4V5{ߥK&Ǐ?F.\h'Ċ/V+:p@:XrUߗU*5<c{/_8qb+O|_<`5Ҿ}ncǎʫ7nh,+x"|bMUf,sδ"Դ\8yQ `Yh/-Be b _>[b%V3TxXF|`%Vb5X>ezfX,g<DX@k/9`,O| `"-,W"<D `Md' `,j'|x'|{w=ijkx/$Q+"|,xu=b%^<%FEO|dJ/ X'#Xb%^<%VXs1wq;v,^:yO8VT/ `DcR/Nٳi۽{wh"œQ_<j*500UfϞ xt|_]ڳgOuL^|d޽Ɇ OFt|_] Zre U J0clf͚dpp0mK'XX J=z4k %V|j*iӦ'0E`e/0 ` 5gΜtz0itt`ėέ:9(XYf%OΞ=9s&ٺukvښ`J kFFF};;?d?K~Ekf֋"`(>Wz*500`'ϖvkѢE7o<_:7XΝ;͛7:p@rw,ҹ,jet{L l>}`ė `|LtnKAR0O:9($}ItnKnObsr`,x+_rP,Ltn:7%V `,6_< `O:7X `)|tnKX:mtn:7% X:mœN`A9/MAN/ `Ai,tKAX:7 `,EGsӹ,98R{k_j}R{{R{`,X:7{֋#rs~^UZR>_jX `,_]jmV- CX `,9ȗX,_OWY{}I:rH2wܺ?I?}X|5qbU5ͭX]XNYdݺuKa12 ϟۄ]'{r@=sPr),%_~.`*ko3FGG˗''N `KaXKWy 98#nH}ن#\XeRڮb};:|Vo)YW4_Ew/n)Vy+ZG^̼z1ƫ[EVڬirFjKAfrYKXrPՌ r`,:^~B,_MVnh`):7XUX6 dvrX ΍/9_Մ&VezFԹXXuapuI=%VNsS0JA9_MBV\5xq+RXĊ/9_XzS R{o="RXĊ/Wp_oR{m9b)ڏ K_r`,ɪ,9(VbXUaXb%Ŋ/9"V|A `IV+ `,ɪ,9(Ŋ/"V|AK,`*,|AK,%Y%'6y_j&EW&:dUXlgcg_Gwگ+R/A$`y eE:dUXl3XjO_ XUaXr-V| `IV`sMR{TRV:rH2wqٳ'J9s$ׯO;x9|KX9UjժUg&gΜImۖ,[ `),bWr0!`QR$D={6RXĊ:2_ j:p@:p9ؗS+A5'K,+L*5<<IP.bVڽ]dO#^EUXS6 BYzѳe˖t4jttUĊbݱVK45E mӠܦrjbաg *ԩSƍm*iݻ;}M8j9_$Ԟ+AU^s~:[ަujhRXĊi'K6J_ P\ņWU5̚5N/98r-BV,lpϾ$ZRVTWS|/b;|J呩FpRy+ԋX]w] 2=\ X[LTX/98csRhՈV@Wl0Xj#b^{챺k`) _rPJO>drקS* +ZKaXӒR{sW5AAK `EKaX ګX4RbϏKJ?kʟ}6kD[*,SaiӬR/ SAj'xg]W{חڗ XK;%.KR{UOlSY9kpӦM3<8Y{Wfta9ٗ@-gdn*!wZc2|MZQlW2`=ɪUW'n cr/6?Wo,uS+,XPr(;7#(`~X6U0ӯ0[]x{ ˞Q1oK6 ՋI?WO+ZԨ!z ^`թ r Jm W.kzsՅkjr}}gv=ԃܫ`)|)5qEifG Ջ|Tm5ekQ_A6qu%KVW!'/)p8ŅB_5X6m⊵O}65X^|G OX99S]X}`+omW M["_p F^U5!>&G[[؋OI(+>cqouE1+ڸR7j[u4X3euZ+h) &gΜI߻worwR۷oOv5v{ΝwN`p*#@ yS ӟ1*T| Xj\r~5h_ucUuQLџW/XE|Ȋ7`;(0-SW'X+tt 2ӱcǒ N`r`|' X0C6baT٬԰`5}rq_stt.;͵XƝcUL֮]l۶-iN+FĪ *kNHzvSAx7)[rĞt~\^.<^ܚW*^lyū)_+:_onq^WDzMso5Q̔֋z#tk6c471"`ok_Wl2iz(7ua J_ן?PzL=U M\ul+Q75331+Qiߦ_N!+-Z>|xJF& z{XR+~|vӉ)5'gӴxFl _W \W{ӔV,l饗rjZ|yrĉqkʩWV vn f*` uQyiZ`#ceSXw{Խޛ,[l Zݦ_6!+9f;Og p_6bV.zꩧkEX܌d]Q9o_)NGh`_Ρ}Lj['OLqӅ=1/"ifJ0_P_Wňe0 4E5&V `ӧO'kY^[z_ӻ&W6Ǿ־u̎XmrϦ `V@O<>X]X:V *F+97%; `u}_S$,9>/_ h0(j}l V/ `Ċ/98 ڻ.< `,sӹbX X5}9X&V `,sKtnXK`,ҹrP,`_:7r`,_rPsS/ X:7`tnX `)b%un `),/΍/9MX:7z!Vֱcǒo1Lի^x`)bŗMXjJ={6mwN-ZLK&VrPv500UfϞ LK&VrPvgϞd֭Ƀ>޽{ 6Ujxx89rH2227]έ{Hɚ+GyūH+[ޏz="`tK9 Zre U JIN|x]!`_:7r`Z뭬R0Ŋ/XA9:PlӄXe˖)V|JAզFGGSq5aXe )V|JAe'w_rPsS/ X:7`Mr`,Sҹ `:7z!ҹ)KsS/ XK+9sS/XKaX|tn|Atn &ҹ 9M+9sS/XKaX|_r`, tn:7B,sS0ԹrP,`_:7r`,_rPsS/ X:7`Mr`,Sҹ `f<`Mr`,S,`+z!Vֳ>Y&LR0Ls+9(V:zhr&4`*K&VrsI`mڴ)y'L*, &ҹњ z.\B֜9sQ`*K&Vr`v5k֬dٳg3g$[nM֮][Vȑ#Hzv{H%?EW+xuz; KO.Rp</bfՋHQOdJh g,beK05-ZhQrq͛7/7¢;w&7o[wu;LEa `AupFV讻J`ӧ¢,9(VrPXE]TX9TRX%J `)  `) " %A`A X X,9,9^,9RX9(TRX%Ŋ/u`,SaIK,`*, XEir`,S禰ABz^ `) b%V|,`*|oٕX> `,ʗ& `,ʗ,XK,;,fX)V|,9XKeKŶ.|,%YĊ/ `,œ,' X>|Y%y/$+_FĊ/ `,ɪX%V|ėX/#X|׸䫵RXK |L#XbOkX/MėɗQK X'kĊ/ `,/gr' L4K4|y2%V|ė,' $+_FJKXˇPĊ/ gϞdhh(H̙_>9v/#X|ėժU'gϞMΜ9l۶-Yl/k/5`ٳg,2O|+/8p X:(^ `9p_|/X`),iX,#X 37I/g[{_|Y%^ `͸ LX`iiVgϞMd)wEUӍ+Fb4ԩSMVs]*'U#8Qߢh*Z'OL.ұ{g{,ٰaC-[$w}wTBZzn=%*um%?xϝnO[@ʕ+K|#>Xȵ܋OXEUؒ%KƭhwNyjX*΍v_7pCn<&O`Uig\ZZ@^~~3ϝlYÇn0y7*F1{Ww8+m4;Ų|5T^Utf3NкD拏saU"qkdbnft\=ݓ)_踳ԭ<jZ'ZYSQXeڷo_z]x1\)Pƙetk:}5ԌnUVFW#XEj`˺tIK+PCkb^6#Ho\-|g:驷ޠ<24av u{2=镒LS`;vss]n_<5b"Z$]-ݘtkV^ap'7ۦqcz&nfϋiŠZo8S+V "ib$NW/4 MFQ<5XG+Z|hXe~"fk+S櫝}D,fD=TX3Ul!tGen곌`""""XDDDD""""XDDDD"""""ED=ʯ܈Ř;wnrpp`uXC""ED!`e[+Gz eǏ_cǎqo~34,"X?-[6v_Ց#Gg&wN^~:u*ݓ'O,"P|^<>k֬B7|s1z6lp`X1Jvdݿ5k֤c0n8pA&"ED+tС0Pm۶-}̙3<+LGFGGӑ/&"ED+mݖ|'T{Ͻ{֭KݼyLDV,R㾀L-J;x`z{޽<ѣՊ X63gNze`X=Sldɒw}wѯUV]uU.,"7C 0se˲2 V,[L]uU~iS{T沼,'N믿^ƯrM7Irr6Go9eSKI~1uT7tsLwmۆ #/0`Yr]9@:~j3܁:ۯvmvK%];S,XpO6PbŊ. ,`oѣGwM"omu@ZZZt|ꩧfbz|Mǿ]6Π.c1׷:ꫯvH9˶ԝDelVuf<w3 mK 3CV?x6ujٳg^x٬(%S@TEEU4vT;:;mvIP|W Yϛ3=t4X˖AEh3,0X*L:̓~%%%uaҶ=`zW mK33XzCuw?Qж7nrZ  n42: TI٦Ǐ%w{2mjJu(micl5j2NQU)9^tGPǨN9s)4*5*/))ER[c?h_ /@أVfML02'L3D|̙5afٽ{ߍ=+ Bh#eeeV|Řd477ոb`G?KڵK/ Λ+X9h_e2k"Gv9;v쐍 dƌ^2r@~J*`aG?}_2a+>Yvc>1t++Xj5$$/^LIKKI̙3.o#!0sseҤ.oɚ5^+{t`skrԩ'OJll`G?lU!!5U%_deMm62XB-M6MN>˖ sv,3G?Is^f>7;`Yo,[V3gTC=$Gmvffl]uOfm{Nrr6ɰaUU`ގ9(ٛ>4X#,fhG?яsW2} Tl**X]1\q)њqy,3G?Amm,^\F:.?^nカmXt㙂.o~GW-֮KtKqذ$;DW``!8V5eG+t؟>Xtrgv~uyA`YYjUU,EȵAG?57o,s c;F`aG?=ӯ*4knA S/,7E,!ՙ?^K.,F2X,fhG?я~oܘ'qqSKq}RPPL EG?~nOOϓ~ch)u'˗om,`aEG?]RRR|w˄JMM , B8#F$kqq-R\\J ,G?~$,*X.5ʪUyT0X Ў~$K K"EY$я~buuu\բ9n]: ,!{>CMNW`aEG?HbcRrjJJJ`aAG?A2Xnr#[@ ,G? gR`A!NZ4dKXqUnRuWcF ,G?˖mJ~kԘQ`@;я~  ,fhG?O J$,,xe޼yr1 KWBh\|,2X2X&$---rEj5j[=uꔌ;`QB?c~?XYYEz5g:E~ܺ_zzر# 9G=w1#e.\Zd Ǐ &tZ>TL1::ZܹsTأH!`!C4_ٳg]ɒ%w^K`5VVvDrrvցW?fmfՅLyVU5oO7ޏ`?^g̘~>*ϥTأDjE`ٳ륮 383F )))rikkH2Xgя~m۶ǪR2Xn,LˊٳgˡCt/Ԏ]Kqg#*s)999TأH{s%``>pz̨`}69RɑR}7.{ILLPXgя~~qѢBZ& B=Vw0XTأ2kKD[TpCU} B!tFZgRR^J{~Gߵk,^'aaPV%n=H 9G'ʨQ`pĝiS ,3G?Pj:VlTugIy{`B/Q^$wǏ)%%>{ ,3G?TSSbŲ{n= {A_uv2eO`=`l1XTأb۷o4^[:Ỵ3`BF"]`Qbv ^,=*X'd*c`G? ܹSVΕ!C51czd1XTأ%l"+VʠA}+:EV,YT`A!^x[7xҥ7%EY$я~ˬ + u"*XoʢEEɞ{ ,3G?{ IKI%W_5\,G?Z" bU*IHH0\w˼yرcvb /^Lix2XB{ 15=Xbb {FV(y3XIIIҢ buu5ʡr)//o.++ *Xgя~*۶mureڴΜY#99e^ V~<6X'OSNoYpaa\ ֐!eR)/˱xuK 2_ђ-ΝӷŎP0ۿQB?c~7WK2cƋ~Y0L WlIUy*e|Ξ=Z VjjꖽYY+99YZl6l{񛌌2famTjzb;"#}DD1=EyQ/3E ^ }@fmTp=""BVPɞjhh0vJTTuZBUKe~JKK%;{^] Ue>-].*C%Ƿ̙OIJJacF)**ұgի`ɝYя~߿ Wcc V jڵ %k蟫Veˆ u;k/ʺ:݇*Ud!9G?`aQB?я~;{~ V,!`1`~|wR`B?c~h'E я~T0XB!$~G?{ ,ю~h'b&v结 uf!b`1aя~T0XeG?$b&, G?O E B!d`1 C;я~ lrG?w', ,3G? VUU$$$HXX˼yرcv[]]-49y-$$.`A!eE.^LԨQ\… R\\, {G;,ׯ TEG?яv2X^J%Cwp]ղ,e%;;[Ν;G =я~V)e|Ξ={I&g:ԩS`5VVvDrrvցW?fmfmuyz1cә3gGT {G;,Όu$22 {G{`͞=[:+N_~`)qЊ;Zuyd9uTɓ'%66mdأG?{m… R[[ A-!.Z6*Xgя~ٳgߜfkdj~6l6l|:>c *XdЎ~he&0m49}tULL`G?я~ ٳСC_ 2;,>;㙂.o~G?ޫ*XͺU:s0""BVhkkk!B`ɝя~N*X,ֲG?{ ,f2=я~  B!d0XG?`a`G?я~LG?яv*X,!`QB?c~= khG?я~`1@;я~I E B!,*XdЎ~h Ν;M,rhG?я~ ,} 3G?ߝTDFFhrܹ,Xo[z5 B!d|}޽YF;я~I;U@\QB?c~^Wbcc5dϞ=,! TJUf̘!gϞ,gjILLƬ&'O{_k̖n~G?,u,Ϸ]n=Pi III"/^ .HqqǻԩS2vvE =я~=`^Wկ_?.;vh, G?яv*X^~]rǏ˄ :-*cvXYZ^dmfmk&Mr%K8lJMM~G?xg#u2r W O2p'ϏAG_em2gN,ZY,ٽ{w\ssgƫ\ dG?$`K`Me^+dmv; ޽{$P*eRSSVU`777˺u$1Z/yRQrTNw~vLSB? UkTź\{K~x5|wR7M`-TJ=`BhWJɇS]Z3X[~pXxGbbjeذz yX+dѢjbG?$8x{6=R>m49}t VLL ,3"ouzԹu=M75לuh:Vem?oZ5kحQر}结 VObNV:q̕jːoX,g +*}\ h5(}r J>wi6q/ˈu92K ô=+sISo!}z z[3+44Tb%A`ߵWWo5\Y+XscsՑ*g0m{eMNM>яv*Xtrg-AjY/R\- ~%sed63 2Y`AG?`az&}v1T%++K֭['ׯ\ݤR `ɛdWL30)/[Nw\Y  xJx`irرMÛя~;`a;viݺlIOsѣ_!CޓuxSƏI*˖PlšLO#6Ѽ|$wqL~Ïm  w4j2R@`a{&:o޼Y֮`]Wd-m۶1 32}zi-ӟ'W]iKo2bDig^jJWy,~ +`ֲUo<ݏȑ5"9q޼JSo]>1\YO5UΓO֑A?$ $!.5GGb)cE jMy?ђ'ǤO/bIU̘Qn;@|wR`Ewres+ꬲ.2;tp2z_oJC2dRL>y !, V`-];y6Kee50;'TUUI~~,[A,`uC$1qL%eܸ0"#F4С/ʠAG^|(}^^skKUbckLm۠X ed`7 , eԣn65Dmo / ||P˨Quү_%?'U>˕W]fx[߼$QQ2rd["GW/K̸>vq_?^b/095A?``L@1jUq ̕^p|~m םwȰal-W7)fEߕfS%% O ˿3fl󺹲]8gΦ^'N23s䷿}]=4o]f:7 Um9J""9ipB/zTuզ[6c_n>!3gZܺ4`L@e22 9$YYŽfxӦM2`!ʵ׺,͕W~!o;5XV~;^:h?}_ux?5L߫Cqq;h T0X())}fU /9ufu:m|!Ɨn,+c2xp V'#F4^&ᗿG,;K&k-nxOSeտG-i^u@`ar&bE s-n]aT*%Nx]2& օ.,~aje-S/gJ>m>`]'2bDjK1w яv*X,\^$WŽ`|-+[Ŕw\Y٧م*u-z,Ik̘29s JۦzJvvYgLLrtSXY+JII^VgȺ{2@'E Er|nT`>WHL̛_ق4XU/r?|Q־iXdʍpamX*ii2i^:^gz W}RD&7ɓ7$$.ޓ߬]Q]RM6g;!ykH3XYQ'dO V.n>7XslIt9"_Օ>Xӟ ##}+&>XiiwJK$9Tg|GF-K| SAA?,*Xe8+UW,e%;;[Ν;gXYZ^ˢE ;` f& [X$!ـ=̝[M-B ZQ&̙3WT>3X־M))>:| iiE4`%ӟj}OfNTLu-g{>dTNfٳI]wԲY=f:-z!G~2Xd`~>,L]0-孠5M/ /~1.&TK ϛg1ujpѢNw观Eo 9Du ;o3 4GNPR5D\4O zNjgBC7;8bM3(W^|_f36FkE?a ш{R,.#"Z8@pտwGmhh=BCC%**J/#YgNfD {Q;. ,lժl:o3 ţGMrU{_U5gNIId)6^~eɓ"观EN5Y%&6=avU22կ7XW\53dxO6uםjw; {M5$Ç?'kxGJuR7oS\YŁ { "d-^g^v3ɓeŊR0 ҡeUŝܴ*`Y.qqҷ{ҧϗ^^QK8^͞] }ڧ<~oTtΜ2/׺* DC`a`&Z8^](oq.3RFºԢ~툈d%>FRR,L0;gWkU}]i3wdSԋ-}n;v!jl3X=*99|vO  0X֮6 ;ro~v#o^.2dHVF=UR;Vwf޴ʕ Oڠ\ugYվc^27+Xj ֬峋~*XT0XdERR宻Z>T&KַpDDl7L{}_ľ}?ro5N2WüyRP`1z))rX B2X,*X¬ܽ{_#oʯ}DS\TLvY7a^t?}?u-ruvZ?+WiCdVj톩5sQDH9e6E?,*X,2Xl.YR"!!*83 -jW|nK٬>}&ÆС2hЫnel Uw_7BFxʔ%AeƏZx"_JK˺Tr$'w= V7#SoV̞]&3gHbbr֬ -MRR,RauQ-UѺ暓kMrG ÜfM{%陲tzڲz!C^3caB q*tmA@`efB?,*X`jBqqCɌ2b:e}]Ջp}m_Սɓ+%!8(7Iuu_Ranna@w }~Sugd:7АѣIHl2`#"6n{UOkܷF/(7Hm:W\\KsٲaB_EZkY +*XAZJdȧ OW&!Ӧ^7 S 6̙rя>F8Z_Ci466JyyoHfz@#YnǫP e=z>ŵk={No+&1B?,*X`Kjj˴eUň-eʝ{WRs䷿}[YL5ܼW ,:R+!9`:aB?c優_.3gVʠAʁD= u[eݽj6?[$,w}Y{=BBɨQ52eZ5TUz2E~*XT0XR5keҤf@D=\.IL] %#cLZ'kӟ>}-cumsj Vܹ).Gu%5W*yZ7dzhä&'O{ߋ/Jff2HgΜqy[0V̗ѣTß5ޯv՛farKKر[H߾5לX{B~ ZncaSoE._^O /Ha*`Q$--- ]pAo"g fdd-2XjU(&<#e*iO(s[QQ!+Wɼy"˭E~b>k3ֿʽh]o3 l9lhn|Te?#&9"Kɓ'˩SڷU+66mV*)QAG-ΙS'YXssTUUڵ11g$$dɃf1+3gKJJ[bԏc~u_ ֐!%;BT`:pjCxxeKֿ9XYZ^&@]&3h뗼m'On+wx۵M2ujwߝo0?>/7X{I&9`8ۂ\ID ^ٚ>\߻x\bb^ VtKU~*XT`8 Q sii2c1Ʈ9 ?dëTQQZU%iieb ESR dbYDrr*ʔe@rȽ͚U;SkZ9 WqAtwiӦӧ;bbb\ ,uYzze4itLL)3 rlP)˗[-Ԧ %9Tz)-}  eFzJͳȓO͕^yͽmiS91b\oCRUUCT`ڿӪUe>u^uv`3] }T;ٳX~(sL~w Cx`6`-uOHP՟Jlm۞Aj9vݛJ];00h_k3׬x;}&O*e/? 2Ph`>X7 sum=p1i0]~0[j-F3g6f^vh]xqX2Ȯ_Jƍc&K Ɇ UT {:k奥K{pB~w?@ӯ9x>Gtq$9Y5/ޣc+Vɵ^ЬYRPլޚAQ2Y°rvmdO ++Xܹ[{j_Ս3;v%ht k36ƍM=2*DZ&ce&N!v+gWԩ> @>ZMS ʗM|~O~w 3/2h3< )slßipg$# @4 /p{wBO}t2`K+??_1suMK3V ![M*ǫ>{U?+s7i]r!3%K6M9yDuB"#̙5\fS VVVn~iYաI6-Lֆ ^Kd=o:0ɠtfEE,XP-ӦUV]̨ǩϚYV, [ ++XVeHێ8]XR9ry#:.뭱ߴiLX''s˖lY̙S"STK\n]RԥBOt2C=T%3兛S VFFwܡ+[is˽r*s5{&-ؕXK,-[tŋeryM*2Xh.Kՙt!, Nz,VY7V0X^O]q_|ǯOMʙEG;, /ւ7n(O2X jS祾Qdݦe2YdPЏ~ gO77tegK ˺uU٤/_,YEEG;, yfy衧|rΣrux|K7eJS.][#cdQ2BH N 6[n9ꑱ_Ͳuk(llܥ,SgcKqѢg1G?яv*Xn755Iff׃jyp{ V/z%˫Ww?쮺īs_RQQAG?`ad^=uWG<`p1󪶡C_ =9}PVZY$я~S`y*zx;ك?!C^oSrXsTmkݰ!`yIeeeF{nmm#tGl0xO,襤KkKa~T0XX X,^;vWBC_㑘X95lrG?N '.aC/ V߾'$.g6`G6Xя~ $ɪU98ޣ$2rDDHL,1`ŝ],__`BHO*tztu[T:.>D>:v+496w/eʺ=?Y_ƿ3X&:Y$я~S1Dp);vls{Rj۰`6SQg}(aa,dY9gkK֜<;8Џ~30IJOO dՙz"))MU~wy{yYƌ|[2ō_W?@,h32a„Nׯfttdgg˹s.ekT%K-pܫU_dvs曻dNJw;C!$eZdݻҡ2XvˆVg~bz}H֮-WeOgiЮ.~ &#G5Q[ٺ<ٞ>R^z`駟i*qR"">ޮoby}~?0VwwNsE =VWW˺u5nޑD,34t]-Cb1ED)gט6))_ Vd䛲fMOrG?{*X)))rikSm"6evrhmz9{}O~ҿ32n\p9ѣKViz9wek֬-H Џ~ W ߎ9" /))IZZZtJL # 2q>6-tBPgƾ,; Z" dʨQ;~w8h_u{]9sJٶgبud ml5,ex˞A%44Tt;"tRUU{gd Sjf+KIE2u4%MS*رMqYxn '$4C HhE'`]޸@ƌx34lX̟_!{1^b))BjȪUzя~`L@U,mo րj)xzobLRQ?-bZfG?N 쬯RYS$7w_UU2f/;Y߫RZjaB2X2P-g& \dRaZ&1bo)SHvvGKя~ +ֲJK+\hfK- \u{u֞2L*Y&<{^uA2(G?N 3t\=zW*X*>s&))#cLҥzۙ,ӧ7UwZ20G?яv*X gewY}&L&iiem}}jnժMv?[,! +geBMMn)CuyiWoƎm6FX, ^iձ/+5tѪjiٲIvȊy-,G?ک`azZe c, emlvHv:T픇$?^.=b{rr0Z C#yB?nڴmxqZ"~d0XA<P9"U)**5k 3/ ck̗bY"֕KEE\ ƝWձX*eɒ"=LFmŗEE"'6>%jU7^33xhAA+/ 'K%5@HŴm49}t VLL 20X$---:̕jːoX,A+Qo+[РACCC%**Jo-:f B集~G?[?/ G?{ ``ym%T=kUiUቦi42p.oOg@,tWO}$g}w/}9,/cc .Hqq;|c h*))m5##ï^~رcz}=ߞ|/ς#YpgH L_ } V_~Ai&Ow\+!66֯^cǎ[=??ca`Gmw±/PW>8pvڎXC(FGGKvv;w2jm?~\&L`k'/*,3XYp6Y踏j@<8__,b޽2i$fMMM4dOcɒ%=0KY g/> g ς>h}gawߗ>GPL|G= ){gBu(W,8{H q31X>uSIdd_gM&OnVНKƁ4HO {@,2XYp? @_}W}c; txzSթ999=ߕ->c 49" 7HWo@,8; 2> #;3}ߞ1X>sS GhhDEERgOÕo`;_\g@,8c,8Gawgaw5=cL `  0X, >2ƌFҷ2P xxmԵȬغu 0X!Z[[^rS \]*++r{NN`@W*W!ֿ;w`;hiiѕ+ŗ^z` X ``  `0X,``0X`  h__Z%`^3Xn`0n u0X0X8wٳGV^'=\);w`0XP&*++Of̰W #/,&O?˗K%,,x X, 1u1X g ֮]{dT?r„rپ}e;wȅ ŋra2kVb,@Kʕ=E2/{|~rBIMM'xB/99s}2|mWy$::ZW- Q̿v ?HHH\9teFKU ڷy-m7? 9{LDD;vL* +XiiWTuIAjּyikkk2F\n;{СC^pa,@=2r VLLlڴsRqqL4أ31̞=[,[n`0X7X, 2bĥղ\)sp[589g92XcG}$, jHrJNΔ;4WAkJQe}Q} 3 T넎,{fcT6KT``y:tW+UJKKk?OA.RO>]/#:3Xh"?Twj-1b,@@,^7 h,F `0Xn`L5!t-IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYDifferenceRendererSample.png0000644000175000017500000014767311173030414025632 0ustar vincentvincentPNG  IHDRXr5IDATx}iLYvv(S)(HQ~DQEʏ(ZnhQ+h l؍;CQTAQYml ƀ .}^FdI6`s#zyϻ~C ,444444444Xhhᴃ{Ghi9,4ĝ`߇z/C>|y-t{dggG@+~ 9x !BC꼓ZR ܞs=gHurs6ȶ6!BCV`??v{:Z'9K-,44ިF_BxO>Kcgc;:/׿OOc`E p:{o!__R>Aee%۷o__ѥp|&o޼Ic9x~Gr!s?ajjvg#؎,%?ӥ-==ͭ(//~@vL. .sΆCxlD"ݖYۿ[نf4)tƑ%`"7+kpp/ o޼;L ?w~V(p7 -]d-MLL1wΆwoy{5R`ഒL^[Y@44XhhW Ȭd轗Y"tHv`hg:\ 'c~׋oF eSE~'"Y(qpps6Ը d wg?D -FmȲF$ C'h u[ g3~kΥ#;g&"ǛyI$s6Ը@jAF2K)#%g'˅`apF" W`^?@|_E~O$3Xq dIw>Amdlq=b5sҼmB -Y8:Y$ t gz>lE~7; (y^%uΆjXhb`''F`{ u?I=ތTYJ/o|uu5|XPN,44XhM!f2p)J=Ow3}=w83)=ތ9{{VWWDTyDsXJ|9dYdi}rv>#sQE>Ā|# :gC{3)TrG ,44444444Xhhhhhhhhh`!BCCCCCCCC ,444444444Xhhhhhhhh`Eֺ=ͅT{FFFTN# cb `***ݨG:c1 E'>1ءc (vb`_# :1a 1BGc1D,ㄎ1a 1 9XB# cCb c1NC9X03tc1D rёuAjPZZ ~m;@o3XQ9k;t!fk677)x" 112 T*Bv`Gmgflk;t!r"l׮ǯ^k׮a =jh2-AY`Nc\ءc 1o ccctЛ%KCz4Rw a$LZ .dϷ(~txsܸ`zzı)3Aψqs c1DVdTz,xg?Y\sff"R^lw Me8ṆC"+|VTT{{{4ߔE%QZ9x-n9X\voj % }rrwaU*#9X3BHc*zX j pVVo )`\ءc y=*{/BE@lK`T 'A_ 5:ƐN#^A~s˄d :3+'?en3|61Nxa1W U&#^3.kKʠ޳ѭ\0boiy i`I2bYĸ_k ¨,Vg,f5\Q˄@/IIC;Ѝej>*m Uk;tndZ-❃53\lH{~uܥw/py`JQ%i6Adw^ 5:jb737J)=r!$0V&X`,YDrz `Y[A8ṆC^Q3=0Hc*8` 8`Y̦Cv:'lO<BY0$ؠ_j~+3X33`Id g5l n7H`dY6q +]kX ;ttt}sS`s3#Ef-D۷H:/n5Ai/l^ ]̱nyXVN/H{8 ccd6Q|}EV|ri}`=Orϓɀo}^wt /[Ez`0k]6+Z̻ "7Cy#<fTUy&K\*pvRKr)o+U/3B+gq{#x`f@WSbc1|#GC2,`= zUWezP} 4$lx}zDS of8.{WpEqJcߢ ­9V,N{ChhhW^yw"QCWPsvP.IiguNbE(Ňa=#6X`X/X8 cb= UX677テ0<< >r%E^R k:~ԛka܏]Qg)v;\u(qIM\ v cF{v{`Kn\@G4xJDXRmS!pЊ} +*蹽s!pUR S tug*+DὫD3;tac^7^&>ަY-_/?OAo+ʓOF7twN6~ _fҿ -ŠNFw;/`B_ c1g's@Pgfn1hnYO?SYꉊ; j\c|yc`-,,@ZZOY{5XqzA(l;tZaV"NZ(987i;oօD[ 1([&IF_ O3XY 0ԺsgAءc ôD85V/U1(o~mr|`A-MF^u*q$;9cMHZW*P.V?eC)zu濊hho` 1vx'1R.]ENBtվ[*E3w (um21? al&'W@:J>mPwrY  cv]"9/f0v0#% ȉ/ku~␀+>q29 [>fu:4 kX[A5t./Rm+v&Ա :iSAws[aXĉXg s""[Z X0xa c =!El2%`:UfߓJ}&pU~864)z98U2//{*H+3 L.Q EW0=7GټeE_EcxG*FX"2^;Hn10iv0Jh+8E2_ yzz;lʮ?Тځ)trW?>o KwG.{$\\cck8ek4p9Y:èGj`#(뵃( }frp 1"N'.B㜙3a<Foh`G]] Uv̾4`Mm6d= n{T6y.Yq5`6^S|] =8e GMy 0p\XV(ˀBކSޣ48ςX#A?3Y@xBθn:`HydȺJV)$3әh0c<ѣRh! YkޓMIk]t/XʶN}/fu:(Knfu4|w ]X:Kp{ y6SAV>Q]1c\?Cf2x`팎´象LNdz BL:jPLT0ŅnrKP7A[r4DaRt%˖x݋W'XM(9RQy ?!9X8JGo#OR`SSX ,Phy(fRanjKMuʸ_ΎqcP_뫅)⍃u{'٪fk"Ȥ4͌("jY)(A:l&y_pDs |S+XPq!Uؓ)ep̕C2cb2-CRBGgd'VM?o/Nu: vEPNJ("|W&CQt'eR󳺾ǰUN,g'COv$VR0nK޸7`0efitɐM+,8acĘMLTX}}5_va^XXZFkc#7+ѦI@_?N2,ZS]BW[0xkuLY0$<X}q$32C׸XDAcE,ݸ9ܞ ☞Ց W@3qVƮDd|%!D* V@1I,sy70k )۠62X䘈ڷO%o=YW11D~|=8!`Sn/:;<V:rC 'zbӭq+!Wdهl7~KK`=OJB7IYsPȷVX ,Ф/D`uA8X6ph`fppC/h>`Q݅yr `-LOÓVݺP[MA!*N.}ØW@CƒsX5W eτE!fd(Uv;,E} Ж\*WM.\\>]v/ëucw O8fWA*+3X: ރ^w}|>nCo&ֲ&]jX!5n7ab$*c+a@~2KTsTp]5T_7]dwvtVm*;/Mŏ`'fT.*jZa>6%B<&qV RyLjah 2vرp8Io[Ld2PT c `ʆ۞}IÐ7ۇ쬎Ӵs5+XiB/,^fCC`h?P6C9YΊː;@|v`Q;T>пf_\kT),940n6א/n>XS w}kcvZL 4nNU^BwSe ٣?IWj`Twa=hoŇT}09IמЬAi`5^bԁ|3֙CfUV*ðttW1 1:bG ?R0`I`~!T]`mooӬ7{= ?Xŕ)_dgL3c>9&yFk$Ifxf fM{ gz}m?>L.G!9(~33[Qw:Q QJ6$<HsB/?|~?h*8>JAXENǫf^$R 6]?5a&Sy\X\x^M6Sb ` ?zEP&!,xg?YT,gY3 [a$"b=1 dec".[V.SpҒX .*^#ˆLͅ>: JR'k'nn1Nf'`gE{! {`>5ht~`]` ),e.UmmmQ ]i 6VHEz"wJXZ_0clEFP־y n&mf4zZٯ 9LqL\7;JP)x2`lŠ.k iC%(Ur7XXcHDiIO#?Ma,Z쯎Pfu/UvܖDIp/y2sV3,Jާ`Rx}m$M3?DOf'g٣*LԞ,՞7k#)r*X+) V )CI[E+ K4 t qCBPq@"{m>)/LN:&i^4EcK3yL'BRr] yd0`$kY̹cAnu5DTmvC  7sn'˛%:iV:ǚRMXb]}'jY3!0HۻN' (9g`AH_sn5X]Cc;^1.=u^d|ODWU\s3c( fOه!2RO+:sdu<Qwr}F3iK2 m.7٥0R06i3l.UbI`8Jʥ"' =>/ȖŝY @tHXcxυƘ!m$0ܦNa-vS"f`)9$9$<ۗ{rqX`p KL%Eb:'08ةPyTxt㻕b"Nwgq\{0jJ/˛`N;SΆЈgb(A2ys˖ya~(``x些ҝ-oF Py@"[ )fV*~V]S4}. \N8l UK{wx!+)Ty - I V|<bjfLO\YNM(эqVd픓Ŕ ӤL_J/&j~D^sK[4WŽQI/uޗkA,:@G,i{鼰 lhR\T=q/}~Dj \!@.m"& 8O:H{zXX9+ĉ` +ShE 9:5a&xV!<)nm܊Zu׵`xOҷP2VS7 6c80>5~Y&Zyu 6%;;L';X 2 `yKy Vx?.5w݉kg][1[=1s[*9a+ZSJ}e(:):g28NL0 !l &(#V4k2eZ`YPyܝ܈):FϾZT|~^0+sl˛9N=|CHF`pAF`E=|{U2WN?`ú*[s\q͐};վjf'Ok$3Eӂfw˦e¦F3e>3`UBժ ,C'idgFب>w#X)h <)VI1 }0)%Uhô^" 6^$] s CA.7ʲ_{FuSmWf I} =2X&至B>/M(W|haMͨƐT$juէKMa_IhpPjZ>IoI?DM׊]MUVȫgZP V Ҧ0u^W]g F7ВctǮY aܭ?-,rO-܊o+SG!itǥgjYPXX*}@|Pg,/Z1^l̘T#ͰTr,U})Hf&Lʄ{4GN<ԛOl @Rbu@)Kt5j-Ug]U~]ʮk60" P,^eˇe~[=R>Z_Z=>:RW7PmHoqf'٬&}蒮 V ,<ϣ"5a&Ao+SgS1칽Ky8t0U/>( B0X7oq+B%v~DGS3uQ8 E/R^indK9vtdúgTU)YX'8KhUB_G}?яn;x`Ҩ m Ei %3cEe9zX]$Kb\L1 8ldͺ2tVgH#ZM|3ES%"}sa!Mև,  Љ8F=>C:Q-9(|69ch&3\BsgK5eV5S)V܎("Ymזa tūSnZc^6}))% RCzlhk~JICa9ᗉ ;iPL&5)N9fn5ifGKAjCgŷ% MqmUd2,YJ>t/m%XXFeܶ.[NLʄ#dUine=sN/*Ҽ¸ *]٥P?Cش@;aƆ$3Xeģkg}([_ cS|fX4 w 6M`4g~G}r;3XX. 7 iaIP%baMuw)ə+^7,jA?HN<",ч}ӄ)Iu+$-`k5X`P?_ i5V,sH޲ދIeRx@]>M`;i]΂eзD.5nAEyȆަv8ϣ9XP~zg^U} 7%w(&HL'b8 3UW`dz3mB d tf^d=>z<"D8%6So܂WRqo*C}wvihYp20(Nb.1y[uw4?#Us'au=Nx(Iz/?WiY0kXtVoP ͳߘdT믣Ca˅kkEテ{,R *F:~L'ދLU(ya6YXˮ' {'Ue+"AWX^;I).H쀱nŠiQ4ߏ}Tl2@*;IJZX)F@^9-XU@n Zaio>,*AaYfR-,LvhJ5aEGʏxmkx~MV1'‹B ]5ǺE{0"+v9X[j5(u3Q~R0:ˠl9]&#NE?2.qo$_펎VW:ÁM"C?c9;`?let+'CvS?HZ7Rl͈.–-Z?r%1 8Ϯi`(T9w1fREh$Ԟ;ªA-bTnP3;&i8/p G ?'?FW ` f0Zl93Hf1.պHr|vtnQ5̱+aP\`Biz6>u2XTR]7h+rOW+Dw餵7қ OOa*Q8 tx 59'%w¿sw] ޘ HcR=>Q q)GL`1sZ##+ߠR б |o.6|Nlt-x5YWz6.v oR^Ҙ^kT?o0}'Wsnf9[---~ +2b65k" ;aSLO@ FbŚl/rF}χWf]xazz  CzژfKTX*u͹Ylv5fA: ߍv¡q#C:+f9Xʉ:1 JhXL١ZH_xO B-%ՂDrcCnԂƍPFi9Xć3A 9XQ ]`O= d@3q((OVqʫӧP5V9 T7G.<(dzK-1j8 =>3X XtR|TZW~0&’bmT5LUnJԱMZN^#ћmx^rvi)>c!jwg6R 7>afË"h|"lyƄ$IKɘB˾f `5+L<ѣx}+C1 8)Z+|MIy_QYmhX+ /"m9XQ p$$Kr o^o DU2Ox(r4yWtN*.!a AW,~hj$+A'EJGIj63X;U謸ry F#`'UHah[`5u_,]7 mDl3XrAzcH%o)~kacF2 ,[mm_6#w0˺s7Wyr&da.fڨ`U{nǑ,,9**aaTn='t!A#4])#E?5t1&B~V@y׃TZ{9i73(yHަUYfeXb՜͕{HjVCLކg).#. 1f C`51R|!h`!u :I񉨞QM/}ejG8Z=G<9QRyqd]~05EtE`ELmS0ōo~o vTg܋2xb(XӬּKUk/)qœěL#o} VqIƅ$M'u[ё*UПn1*K&`U !͍-ZMU a0.),`EKPt2&$YJߘA~P΅TUUZyn ;x:ࣜ:BL_i4XhX6 T^\,d gR|C::TLQRswhMS&e_|d*Θ7юG~12.qàr 3XQ{6(:X{>WxƘ ĎIR/VAXw;W2}V)V{Nf>܃yZ8)EIr9MBҌ E`ӃWŇBm~oN)19A%E kc>ZI#f`'h5I$ӣ.#3p{te;n% + tWR*c;jlIaPZX>c,C \= 4fAN^(,P[Qzs"ё^ԍZ`eb>-.=L)aWU+ETC9X&rjMm鞁™K5&3N*Ma#~#e7y,pjޤ*Nف:阭̹F$۟c+ Ǖ`yH UFބDz5hnzV+May~;*}SmP6Qj f`` I"04`Tw-ʕ_jO*%9FLaG8oeXi}-{09BIq/ai4u#ʛ8P + 2&J,(*=A gdU R|V^8WvexꫂGl`!&?%LTX`0"py` ި~KU:֘ OtJ2DFAܦIm.5bZofjaEsPmܨ`q)o 7P9AHn4Գ׼9/oK]Kc}G?w}|>(x"70 `5g"9Oؠ^Ҳ_~QP׽wc 9XVA%B,׹R=HڻynO2.Pj!+iWn2uw`IMqZn 6YZsZZ+68g`IK?/tMvvW7oDx=LVGIIbsKVzz:~իWp5F!!;"Mz|WN4@/ұ:Go.ɟz+M} C0%{'CeC8`c tc@P}љK&<4G}| ']¾'yU3t4]}aw᫼<*$J Gĕ0ix!3+wX2^?5 {tΏC}??T0~{o0ߔ܁9[_\*+%t> 7 g.,-3°`c5n\ҍ@Tҕx,eBJW[0ٹlP3|/5h~L5XB䠕fZΨ>u_߸XDV|a@ϓG;@UgrfDpk)=*3Xĕr*3qWEB:U~;ݹjE4H[-aT*5l ֕,xg?cIN#꜂V6w`]ڜyV](AK4[6p~^\ _:Η`]ɱhɏ}{}?uYN5B{bX+ ׯfn6<5öVX'$[ͩ9 *ynͱ??Z6srl!-LXJ% 0uGd ]Ⱥ8XAhEV3~Uq]|@7P.6*؇Q/rsY@x8*VK^ W`NKz,9b., W&A9 o_&$ l/qw(f9EI WE'NfeK稃 B˘{Enjz7=,ڍ7a3 _x]wU춯ص1 Shѕ!d\t: vg~ĵ;Io'c뜓jC6+0PawoϒU]YbNVm,gY(ׯ#dE0SS͵!;'zeS|,g82XtWQljy/h\ *Ɍ^t̰ Wš4Cm&edO4f P*} `~pΕ-2*Rpu>W_{xs+w'_ʳe!D*gA7Ҡ$%4̚g L?_:Gm' F.єȇ Gxˮ&Qeep$sqlh-p}D3|E,hߵ *F[y edtQG[]oP绉IRՇVJJ *~)XlAZZ-ZGwt6T'IK*\Ԩo !^*u\31,[]=DF3Qߟ:֦J_9]L`8=x]0nUvg:7O+ v Eb!<Њ5nAS:%XdZ3u)8Ra ronn-"=7t=N[ulӸL(|6v߸B};Ur99XIxI: 1LmtK`h/sr"6b+B,@!*/:fT:@⁸+dBQI;j<Ḹ8$ٓsHAoh:ynDd666 //.  $X$ji ynɧt_2 )PL8WJ3bFG 4)3X]l [\jCmvGGḪ*>>`+l X4a7،]`]"/= sڱ:\qHNL\x;{@*~N p?--u/]IE{^bn6/A_gW:*|sc$_?NÔxJevkqu{CC'܃K`BŇG`skG4E]GbO}3*/3f2֦N warr>)Iԧ%%j0o7`n"ѣGQ`dþdRslx? 3XwJKA7L@JT6hDn398{p׮7n 1bIlS|xT~A,_N7 qCb NyC-c݂G,蹽,1ܠZXTݽ1]a YX=G!mO3p8Q, Q%ZO]Pۄ8nmcY6YLX) xђ,ɀ;W.߁SP[^RԤ pnHR*D'6 tdT!}!O\F.ZQzL(i]5V9uVl"n@&;fmX\,q2:i/[[:oՃ@~ ه ÊFQ $il2]#=͌D.'A -/\4}NZgΰLOwKQ;gƟ_*;wcp4+MV1OV dF]G%V&'ǽ 'I7A2k}],]ɦі ^9o(cƭnA^GܵOEݗ<u6|3/ctRQ 3ˢ(a 1 NU0/+$} ǽ l<-#E^r9x8ZW׷rPXw VdY%OP(@@4gȹX/XqR`9Liy^Th~"YJV* 8 BFԵG"<B PG/2:v#4QRܢ\YιR f`+Hy=4gtC^駕aY™Ι!$$vm,H`W))2''3X­=]~:9f;נ9; _;Ν. W,hx#K)5=%8x)fX$sU^^|M,P9pwِ U`NRG?Bm5uQ6W b5m_r*9lee%)!?܂@z%<,gChϩ bGKpy0KʢS|U ^L %ha%BM(1 LvQ554f -rb]htVTZO''fyUIU d!kς2`b{6,m_vλm@sΘs"'H6L& IN֞=RKRKHBM-[RK꾺}sHgnYË"2Y" w C qh)2އ?j15aNf>D߱ƲeQ'q :@wǢ`=`0X`as3 x@dGtt2+ cQ}e>XӕVv'RP!KK(Ii.D@EE}I"@ij>m`t2T>猜 e>9#7YTԣ`=v%l%$7]B`/yN ]u![>t 4*orD cXzsv Q*.x _O-DSCnXUo:|r{Q3w+$P6p%yٽcQdݐl5& 85Vb]tXfYet>X-$ Cmv`?Wͳ 5SQRӠ ӏh[#2X9D]m(i9caVIn2EBD'Yu֍ظ,i|pح6mǘ/NWXu6[6JC/E9QQ _ 6X[AP9kͲ5YNssT_Hp0l,wK˗/D~;gнQRW¬͊܍جV2 ѴYVL}.pJцMη3Ƭ>>z.y!qm@#vlCg'cPdlݹhd9/L-d>N*@V5fXdMCwȳo[uhHh#[yaW ôU*%'z@N&K" ZH5 BbƗhlXZꂢa'n"#8'd M6O c7 B}wed}4Qݖ:IHqqק O@邜궮fBp@$+f,FտuL@3f k!6hn:i5ӗs!/-Yr/:FuNsHjzdaD`O?秦kiiNL&u 9&Hq2lf1AHG` QPTt̰VVM¼c8rS;aI&׷3>"O8;>)Io&᥯/{ ~ 雿`ﮮo{;:A?>aчh+2X*5rȂeV?̅[Sf. 4 5YGzXٔ*(o!d!Cd404 YA&] ;nnnɓ'VXkUԖT;PG2(jR}S.qb7}II8- 03p_^eP^hv`Yl莘9wP􄿓iLZ*H FkZ97{bnf|Al:$M^EU>B_݅%Vיٴ W߿";fM64Y0퐡s A?O1?i:Qɼ. W4-2X[xDQ݋s0XXYY:ev+dܢؙSNPu]z?aaTӅ+=4No@^u5=7,W藆lCUմJ:@-hhE'f@yx}[ap@._Ćv`s־v8LM?bbhlb5z٪1{: ˦Q!¿d$ S*d`9p+U~ U 'L~!_X \u-u=J ,<{}=oo/D]/PT(ݡUn|TjEgg ";[|~הnS̮o !/&g Zm> {.h}p_d$[9>(%W` U.o"\G@JaE7}OҎ!^+ CqBt/?L^b<^t+xcGKFfxjڝ9FJv~~W!-hNXrfqvN1u*I+lLLhEL,,n!gp 45JJi>XQE+:Bn8`*ƫN<ss|rYa?>N1`/٭|Ȣ7 ?PT*,z4X@e¶_#jRaSSQ:rvҘ[U_ RQQF c"/PXȎq-5xx+  >ېН5&`oˀQ,W ,X/P].;AvLJliJ%tԩ$u{jm[hH} Y]AyvWW<NY1tΆM&Bw7$BB.~ə;Mvd#+Y 6`Vx8/{̕c+hlJ\ƦVKD8 J\\5M3䃥  fo#RFRhc~S#Dҕi3z`m{0F4Lo_3P2w͂\Y &{u@A c Mp"I] #7r& 7'ZXkn@f==/lpsD,7 wB:|+'g&IѬm>XxwdSqʑ O҈XeM_/LѨ+ɣf֝qPtvGaB7$]Uiѐ?#2XB'!VcK[n1'fTQ@Dm9vƇizpܪ}D6H*"[jx{gGp$ hSRUZ5{W6ZFY M8={b$@]05[cxWd,Z0p':ݵI%kN,p:Aq/?GY6|SY:-/dU7Em5 6]y{{fOѝ6&XNq!D~,2XBvH1]s̃EM bhg @XyRK@ FšyK֪"my UU775 5n6D7}k 9͚A'2>jGWȀMOSS+Lhx@뭇?ݖ25]WdX Àa.8_г靄׷ZJ`2]##z]4չȦ,U9l*-sd _W ^, -tgʃ<,rAa7ۯPҴcԦCk~J~cS4ԣ<>SG6__qB&{D͗X&]ZK^g~2@^5-zX|>} 3JI+䇘f,\y4XVCCP&KRY(NQWl}I3_+]ձ5á :dcqis>Fɸ2O] xn("],Pg3&nbD)xG  4"[uUϸ@[lr7b )=묅IjI=y4A 䠠>S j~[Bk#R>ܫP+"QI5~EkF2"4\R7az,\?,;IWi4n'qp>qhd1g &"+جZPPϵ@tRS. iBϬ_,[~n< e))z-,1"/ $ͦ"qv6)>N@玸Pa;8& U#.A[5!4XQetה3kh]Kr#a4Xh:Janz̢B SYm6`QI8GV5/!~Ƙ\72X ua<` v2aVѤ@DdrJE6+ BH/M6{H?نcg7:+'dgDTPiɈaĺ:X"=KaLe_P2;>N@%Ն>lk^dO65ԎܡʼD}5/й;gZ+D@MwM/AY[)uÍcv`/ÊSĭlu>+j2E`ԂG,+K HF4/Vo:h{B \/qfY.e,֭,B{Xdbo5ʚp;A l=KE7r& zo\.S,~'F]YK?{fZ# =M $I_[3Sumoyv^<;'f)@ hTL\NAA:<+賎CNIT9 /3@ZcadGBo٘i,KZLJ<4JVFF]U 1qfM~Ŕ}e65Z NYlF!=Ewzwd%>| `BxQ?P+'](|v:zȮx|nYr7.pfTAb\ 6Bvoo]1 0ܷ(쵖G[D𔫝hi`,%yS.x2=1iD˪ߟ=3OO\;Ͼ,,aH2~ U1h-`{x0?c#}WD(ȿ0oT)]0 4U1d44ZGVLthOS ->=4i4Ʋ E#P>nW z`u87ZtW1y8 r@ U״McUNB"@A.pvAd~x<ۛ@&_~p0ɨ;l2#]~QX؂$UYZ3/^;-pOgur2}vCykjz NB =feA?)!6u [ˠ T/# XGdL+__$'7~lreTSKjݒդ}EY"c N[79))9Tm)j͠{ Ϛt~~DuH#SЩXճ(XWj*g,}|)99b>AtM65lEe´Jc>tpp?f`t?VEX~?+˨:~p3B& Z@,2p#H80U/uC~ l}qq,A:ߓ{?1\KCemN N2`}Aoc#k Z5)_FmՀƗ.u-SXx ^AP=e VO(;fPGBا{l)k.]djzk LMG88o1^N1 K6}9Ϣ߁s8r~LX8YN7_\3,:@ՐŁj0z )^HLb& 'dP ,휎!#俣0V 914Euj_8[bm } {^(Ռ uzh4`! zITCÅemL= ڹLj?VYPh54$#7w[KwF]Z3:%߆-V.Y#8uvf.E VWBvJ=k;kh^F=MOiQŬ%V:;! ׹VCeTׁN-^Jm.49P{eLҷn>wL 5wJ@2 j*6(ܤݽls + X d+ m~M} |56;,NL֎ƱuBAP[K(ogYJj2/rn,ʤX֏\Kh3jΐE@Qj2jd}?`f4P}oE6:n M cG ,4Kp1X٬ "f i)$f J@E12tI(Z1+L١:Gk KZ+X ؐ& 92, ;e/q*YMT3X*+2'uY&.k,2svs@͠z."p -OhNޤk(Q=kf'šdqKII},ڭ6 TrWԂ\hBeT7LZN؝1zê}~u511mȢA|f0{[ϧ\*sQC8m7~  )A. o4 s= brgwufB{UǙ2I+V)[$Xx )L*6[?hjPdcM1X.Bې99/l!#"])nlJ6^-}k9 ١pȢڣR--0ٛ-=~\`'X&Aaa὏X,Dy4PW GK*̢B`aLL&!VL/>,NhzE!hc ;"v "yLFu2©s> &rV@Xr/@vߦ=֎rr2νOkIfoB65{td \|eԨJp[MMi6k+xؙLTe8`0BZV8N :ը5Z =e+6 c~ yv]pu'/_0onn {,:ˡu@)L!!CH 4p 2)CŠvqq'1g\u\]/z`µ'FDТ#-Xm h26aT>Gqc{QosIdشu;ΜCqk}.dN9A{Zٞ4 3N)4AQwh c<,GspPA\&9?eOUt@AߘޕũMY W>_ddȎw- {`x3~ZjA^Xn.4/ϢaAZqz:cE ~Z\%%T$#,MAeiT;==Y^}H}8*6o^SjVa ¨c>(JƼH?YcX 5qN{8ըP9o>EI~ /FwW8999?-U"?_QS. k6WB OsJ77uP 2mZ&zdm0]b|||۷o,]?|c9yoW̓{`!!PMwN&g&N4왻]!K$ >,s0 ˳:jN Jgpe.!Bj (MHK__;<^AAL*,z%3deL Z[YVXl%T.Kӓ/KXm]C$rJ*g}OW::VOVQAG30>.@{\Zy9܊-j\=ɫi+hΚWBb%w@Pǭ~ϖVIQn6нZk{fjfp k`T%ꥌ {g vQl /-\ˍ:PY`ed02! bcy3]Dqo2MwxKIab]$}sCeiVYYVB.8BK>4DΞόeg5JsҪt!7xV(F%d髺:SoU'<4^(5{+ UmG ŗ}٠۱[#>c+4Bs&eNg:A3>陆+:6@E#۝PX3Y]{ ;`2l[ǪηRn;~ʼ0k;op)SB\ ujT48Vo+}uHǂ݊ZRGtr{ӧ.j %Usyn;4D@xCK]chc@MF.:{'jL>P+0ԅv B3GܖAԱQf#!miI^IpV б`5`d@C.Pwؠ- + `\5AM}Jyr{V㡬QjAa63TE9*92bA^Q[5\flv-ÂoKC&>~zz%SQ|1b[,˨ZtzMM:5x9Xd iX)QVh ')5k ,u6 czțm!QX??.YBh8Ma^z6DB,v7Ϣd, pbFL#75=fm1A 3 1D/sq&*{{rACL+KΦJ Vn3gelZbF_+KVO7l F k :U;N|;ֲ@6NR5L 2 j3毆@}X匎_ kA8=e"4XM[{xg7_Pp: u *@MF㥳VW ?<,Z~h  UTI:7V[ 7 ky:]\D,$Z8V6 `AKe?ZM!F=>7 O";701r:VoS8T%<݂w~:UZ!;d-]`(ѬV`X:k~Ȳ ]^YuoA%fdH#Jf`Q]1B[z6]Y4r|.2}^C",ȦQgQMRmx> ~u wPz -<;N~/,@}st4`)j@]7V3w& k2 d.~O!!F[H2h yibXHY`axcq߅Ob]WT7>e@ r/ct}|},]2&f{fLoЄe"e30s_Ula7`kUkCK+tMu"IA4G5ٺ!X J{ `02E/u?/]tn}Tg${84HuO6T!@K}ԨsNYzVs2slsT}lmLL| ]|W-|AHY DKg&X2VP>Y FJV鍏~dTowmYz 9JH7..^Xa`W  8zm*,.L^rr&$lZ99jb1Yf**Xe,ِI*NXɆC_=`nfɭ7_!4OO׭%@]̔s)M}$z2aL92{uz0ϧup 3F'5egKz8ortx }\&i,@V٦Kg_L#X"5XU+8լBe8*su_'-z#`8iϏU9#ۂ k7`pf6h&&rB鸠μe..zZ1Rmf Ŏ&ΦZy"˪٩u|\$I](sCG"tD :P+6w(neb{&&fLuhcy}ѯGEvy=Mk蚁sv`KX81|B޵m+2we#L` Z/5[Q,m6711|U mTyX&|"% 5st«+ӧpiЂweepBt{PYԯ||#iŠz95Ūhq/idY4dEL)ߦ>0$%aP]nnٓByk ʱA 83->N(%5N3?H3u@Xڪ׫ 7/隁svxGϣXJkq⮆Ct{7{\K`Ԏhh؂W2-R*V#G!M`u-NEQ dZ+s 3&%S07tx{n6Wۮ532A4&>nl7VjP) ؐ5{kDh*s7`KĘ,LHڕAEa˅0Ą<AWO01\K]m],Z@Л\3|ojAL.UrGpbgq6<`NiúM1ƊKdSKo̚ P<޳nNT}.k,ެ{&oZGN93]VResk_aaO ~2ck!F7nv@eHN1haH"I86v͆ B%ؗ0T5Xt^GPN/~1'묶y(PEwrFM&-m5i; fl3ߛQ?c'TqSp^ep; svУX^Y`UZu6 c_LXv4XkqP\|DE}A2Do4='&~]QH\d Moh6\=ihMž䫭'wFB.g11Vх`BtBmx{VX%_{<2RK4ra8<';W𹕅1aBbp[`TR~XIJS6d9Ⱦ!jZ&Y]cXN:TӖ[ם|wv+8lH2SQ%Ux J} SS?A_E3޻]J%+,֓',4Dd)|Lk|N=5 QG֏3zԮSt3iԩ-`Ab^H+Fd /x4,C#0|aTk/x _z7<Š[m;UXC+3K˜W+}h̹3n-%izj ɦV @M»UО?c"|&Neg-{ !ŋNJN5U_0f\7bVrQ,Pii ΈռwG_` !M_T}pv8U .g xOMs-bJ̻ V峫2 [Rgqq(dlWaaԧA:*mW5 ++V)0gu  ہQzS=+P0u59v/#)e(a)*6.fkr) fW+4őr\s+!)ЌeYsFaBն0BYRH:l҆ I"2`CTbv!/7F'5y 1ZWWDUS+&ukOTRe8ȥ yIM\{iacН(.>#+tn26Tj~2pe>\a.,䆲и伇WS:~ts>23kN匛{Mʟ7M$XpZV]%P?Ff&'a<3'^!յ rZ蹨zӠ/Yx <JU?1pMX{ehښiXXF,8zLDe >Ɨm#jTD@}f%%23w 3Ka,e_haS4{pFs̃7K/o@޹D&nbȥqG,2]e/v!# m? :x> mQAmZr24|HԽ>0 ,#_˔j|m3pB.aX#9Kr"Vxכ jj{+z7'̪_b00nnـSbaTk3Xb+Y5LyB}hycY i^P(!2°]8eQ>X %'e3ES4qĥ.He43րtlSV8b emPp—{z3T7Gmjd>%c[>م#rNBg[ޯAQzu7(T_?O3'5de@Xk>u{U69^:g &ULJ}o~ivv G;<mĢC~9gK-N7˿Q :G= +YJԠ!V6@eP;*L,YHVp)mBC!B2qn56733= '+PU: ` ? wkjDN,!89R&N.:\H[|!U4;> ip%?v`0XȮ,h\5xxCC)iD?u@e4|vaOۦg\ !QzQa ~L!爉lf|||۷o, ?,轿+0 `;v5XGPpu_RKFLMO z_d/$r2GS o| eڢì,BF3X"p)T/jSE\]f`v=8Õ/{r?* d2xO6o҆  _8lbPxsڅC 5mש > G69&!$ uc )NZFM",((  e\C Pb,ʯ6Mn5oAFd^ApGA;,SOJROd^+33ׅ.'$3cC)g!!FMqk; j +fѬ??h%Z`Gvz'PߋaC7/^NX?QCG@S9<+WB7?=6 NSVf{Xdq "o[uuuFe"#v> Uf3K}Z(o|3 U.=LvTh45 wYϿ2aTk^;,d/ -˔C25-H]{yѰ8n*Ό(f ͮ'O ?qhNPBm8rsЦ͑) qLa'y-TX;D'w#m`Y^f3X.CfC{ q Yј,M8%muWBz~` ) ck;=KrEEk2,÷w*XBOM! hܛ%T?k_s{nJA*v:Z'~ZAxV:"eC 9kV^!/ a }3ټ"kH\ˤUٖu cc=0^ V[Z gdL~76:aͺ:5ֲX_=>%D%ľC gN:vT[o] "hzÍа_A^ems9Eo7:[~EQ NFz]̄.'2X`L`Yq39e93TIheȞ `aH",~עBAKpSYI7Xnd[SId)&g+2#Ž;CA*iP1_*BJC."߆^^xv!Kww5ع Y0YǪɺm45эOHdVq!nE- M?";#Y1>g!:&;2qk kW'ϟ1sâ"$FòP,}aM  ZdgYwMu W$*!ci3;`**BBjfR }B\."4ת() 6~>ETUFuV` |\`f.6ȫ;EqUU!D2 5 xX #L fZAZ-ub5XXh6[˱ěy,ЌϱX\-/lz11I)wuM E-`apUhuyImNt_ޫ7 sD ]~VGDcld͕O+7%T*6kMe-З Nh7CSp0e4"M+OO\^C5F>2Ş)hb5X6p.KKrOaL9#pWy3( _k[MMj h)laaFe^DFRvIvR x,usZ6._竀'rnQբiq`Tn]j$~Y3$TZ ߰߱F ݩE43 WWyuMg!+1:~bJ2|Vv@z>>h2@ZD Ul =#/1XA2,tWG,d١_kI:Sҥnޖ2ZDp??lifdP񝃻vzps'"Բ:72w֍ĹNl"efr  cZTȗM7#ndjϟQA'+ 6lCCpe]`]z{;+\>pAȬ]/,jn+.PDN햔P|$ Rwb5XVXh.axysɶ wu,qL eݯ}5 g%'?LxQ ٴgeR&kǟD V<ɡp⠴V]GoF2:!'" DwBz2=hkoǾÅ Y,(lwчں`BWGG@?{P{S\c[3Ò2X(/'U]Ŵ4HO7&ub!{/C 8Pw_0D߆ZÓ]NP&B͕W ;=BՉp:3.FL91l j~}ZazXu,2Ol"e"z9>K`QPl=Jh8μ Ig`yy ]HRt3ăc~ǘyc<^<{(/>FPvu|]?N=Ź9zF݅ԬqcX߿?{zŸ%QǏؒ`[=3 zo`l5zR(Hug Z烦y8m`9U@`wub?}Oc+, w dLLXЊKlk__ErWO䵏a27߾}ci~{ޗj/SxQSSp\veX-_ ,@tQ _ $+Q&k5ʠw|BD]O?@~ i8Vt4+(Ыd@okv_4T%z##YpW %Es=,j4kkkYd/R.8BZpc,r\Jʝ#m3EM@luz7`ahѭO,#~A9u:'VM &[4zZͅP~8%q1g`Zs=,2X ÇLI:r4lDw~vBeˉ+-Y\8Mec Gbܚ$#!}js׽]Q\rrXǽ+-$}0cbnF'wljgMeZ1\moN\h6?4Īhl-,~'LY8l 9\=,jl`a *.eյz ClBhjR3]$U P˩hp%9|0 E]O?J.g!>(6`}%@m S˩e:0oBB`To=,2Xi=BwE]y|$< >\*uvbj3`mATMl?RCqk9^e0;2b׎n|}u M@jMXXKx5U+ Tg t@W*z{:$v C@e&'gr0*:r;f.~Z`]St GߛP.fߑj}@`?Gx  jWpݗ"M,U+nrڌ}UNYKӢ%ͳzgi{~nûu b?`}PaOAAL*Yy9+CSX-#+5X`ou"54#mWjۅԆS#_,~s oz^juN++ckrMN/ich`e98+ˤϘxF@vGՈ1!)P1\)BUTifF~Z j;f)㹐鋬9˧ d SF+xI,,64-Ю 3SU\lRgʳEMMQ?`"S'GPC qmÜcf`LG%;zCдVT R4g4+j=N0tw#N Y6++wjk)e,!kĦDiǹazL TtRe|}}߬{)BþmpaY "e}8/BRn&x̡Zb<]%N}=K1 ϞJS:wEEf߽#z'Z1z\wB!O 00jV!xoC/e1Hv braD fRGVAxdknDՉfK Y5Ok F[ $ F/ϱžˣBs ǔx #XX0$}ǩ+#]n-l?wu-ZUJPD-b SŊ#[v(uW*22͹K_#$$9//${=9=R߲Ũ̕ɓd'k6KOıZ2㑓aA)IO'OXUUp7m 9-p~t˖X ~Ȯ]rԩZaJyV#z`i?Ֆcѧ{VUUg[7l9闗3O]bM![2ՃnLZU9f#)4![6}xxmUG~-hHT/+r=y``iTU=9s5Z?Epo ![=?z:} 蔡^V*Gw`yMMO2xzAr0=Xid4|)MFZysHv9f̞W~k<fuy%q~gMJVQ͛zS]ͮWl{ `Jthūz׸y6x[Oʚl VUWO} ̌/cl6r:#kT-[LEM֛oD_>{| `EHzT1aVNhhB/4{~6Xkm\sKo>X&L%5L E+tOIA^^rt CLTsS6;kkN;5j0!azDOVVc ֮ϥͮd6¬0oȆ OU_xA~]{;mi.$x SZј%~n`=ą//klw'">^YVxee]ڃ.ip'zhXA0C'4:tPigNc -? VL+''Dqq4fs3333XwCZ[YO/0n>eh7XÁ1~?4+ Icjkkvvfy*X80X !ׯ__1}{ي#c&}$۷rغ#83\i"[ź877'`?sF6`. hCLCK7]_/hE`g?~,3X::…YO/p߽;`olm6l:vA~~SRsU566`:ls)K@'4%F^]70=WSu\ -#z`uvvJeedggKQQ477S:tBØÇ5`xfo,]7|0X]]hGT'H&&"ָX7ugfs=ϣAЃ:.vߖlfB;`aXOGGtBx3gdk.#Ё, tD'4#>wN&֯+`ܴk;T0XA)c{v4!z0XF0θ[]mjC; `aXOGGtBÄ셵{-/ۇ`a#:a"_]OЎ@C*X, D?8A`a#:ab17~?hH z::&".:%ٳhG!=X,f#NhKLUV R`ALpA l CC*X,K@'  `Q"А" , fuD!ڡ!,w,/+g}椾G͓=X:`|o쬴qokkO8!E#:!ڡ!Ak!rrro///VJJJ" H yyyO-F@GtBCCC ^)++++++۬psNj _SoM-Ǫ#zoKq}?J ;ͦi 脆hG!(Qר zÇ!=X+W  z{TW?n>9h6X,  B }i}`$Je7AA45脆hh0XX  `0X,tQoT30X 9]:~ٞ?77W͎zE%.ʡC+((wy'VXtN'yWTTutQ^611an72%,Q]_y>L4bq$K3 Vf|r3[wuuڵk͹2cr ޮds:{)rmmݻ7dioo7噋qi>oy]]]𶦦&s[47==-V|fYl9kZ)<2Yxroƍ!rtA{{cFbt\J0XKd.]$EEEdceݺuQlEV?|nt.;;;d0Q4Kgǎ RљǏ7yFuWXa&]osS㮨lUeV&kOت~V@9c1Kgk ͂ t^)ֹH6k"YԘBw_z5% S.=蛷]+k6JDh~$Kej)ZׁJς}|yIƓ{Zq~Eg|.0f$`%R3 VV ԰lfXfģRiJB߀tiAK*|4 ^W>|9;CCCK/ˡfXv-{O3yoccchjll,d:KebLUf;ϧ}.Nw J?SɩL0S>汙6L[Ki.2f$_djJKx:;V=AڬK%ϡhWCK@KQtVnذ!3]b-#:F:Keb- ]ׯ֒433Ɠ{ 5ggB:'3f$_djHyf,0Xa'GZ`   . XK֮]kΕp1RTTd*#Z!~2zs3~}Kl2Yb\rtB&  s V`^tSikkZ߯cdrrwww%2EƉ'Xw444H{{]OG}܍7@o?:Jti200`Z, Ta_~efgg;sV p#'O5q< 힦T``d]Fzf7AtɺY9kI*BǩbAfٱcLMM-i Sc'=zdC4F0hi% In7Xnnpp4? @F,e޽W=Jj1 |D{ɾ}BԈX}DSd#rrv}}}V0X, VM̌ԘWhhLi־'D'4{kPK]۵s,  `{`r0X r `R r0X?IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYDotRendererSample.png0000644000175000017500000002761511173030414024317 0ustar vincentvincentPNG  IHDRXr5/TIDATxheg^?DDDDA"0!e2, 80݄eߙTTS̄jC--aed[:KkZH2 &$T :9_o9s&8Û̽zϽ9TL)`,` _J10X{/ɟ =;|=\7i'`*~>W5wxx8LOO/ `d~uB8͞_h\>_Ij)w ]`0Xaaae``E^z57¢?=0XOO;QKo}[1!oo77m4X|'<vagϞMt^t`Czjޛ/9|ޤG~GSO=vWWixc?c}ݶVG|Nzʢ1_φ+Wl|~~/ODNjpAM95͛7SWoow?Ԕʯʱ'+EyqAbx??~쵵!>~|]Qo?v ?^kkkj$|i\YW^yfOM ĩzϗ6'5+c}M{#mq{7 V4+QA;ֶZ Xs[>iDGLN5B=M b"r&zO+fԝsUUayL3v3|}_r kXiCA#(6l_x19;koO}0Xqz{L8Oo=ON, 'SXs[uJ Z_ce :eүw줆#{nKwdfi$X @> ۿIrQ1K)X4,Eğ{JQ/yhvK%noE V(.ofgVݷYNScrDí[mq͑To'fqNKk_Ӗvij+JOų"%l?7`t0X @Oz\C<-hFzk=67{mfijStRqz}vm`z8%SBlj)R{\۪ZOSSS~cUYY;6rrJf~ќUB|5Mb| ,,_|JR^<^RyЪ*N<Ȝ?2XVWW.Eh$R[ziU[z4fggí[ČU I"""ʡzAxgM9s&ȡAXXXɶcS*ƪj\r%ln?t;V>|r`]o/wC{>,|=˪Bzw9}i3X/R}vݩh[t纞)?h#< z;n}h-[miͥJ7W.\1j+z2XZJ/[_  oΞ=bb"BDD0S\e]l[^^N>06KpLe$L/D#Ke$L+JB`BDDԃ`I:`-IԖVzi`1X"e2߯KmiV=X `Cmi҃z$X=yQ 0*baO濋l`堕^Z`1X, {^U[z,=XE!DDD=X ,rK+ ,zԖ^ZU[=X,z%XjK+J,DDDԃ`I$XjK/j ,^^Z`1XFJԖVzi`1Xz`=H$XJ/,7zԖVziՃ`I`Cmi҃z$XFJԖVzi`1XՃK+ hIJ2X100P033ݦ`!}zzdaii)]^YY sssM% ##^HHXʡ[j5>>.omm҃kUKo VנK/Ҫ+W̙3 Gh a?6<<|qZr]micUa5\tX:+^~^r tZћ6X<^dzU M{ƻ]_秷s+x n-\{LnUk᭷5n z&ǭc1?̥J7nwvބ 6pn ssOV[ziWmKoaoo/={6D9g5::t[ f V7SB >[m饕^eR IU\zڵkɶ3gggn`-U^ZU d Ν Ǧ:V^{`}Q `-`I襕^Z%X VN翳2 =ssd P ,ziV=X VNGYVH/`K+J,]-`!",+ V7;`4W,B#aZU`+g U=XJ/z&X{Ae$L+J`y},DDԃ`90$Xz,ziV eTZo^,ziV=X CgvFw 2*bLn$mQ%`Zkwt{/J/,KVA`e=X{VziՃ`I$XjK/j ,D2z7s[t!K2Mote,ziV=X Cfmj%XX|UmiV  {Vkn!""%CY'X(2^Z%X BVF}k`b堕^Z`1X%X4Au!KR?2z8^f VX9pʺ{YA/2Xz 0ݏ[qL_վ0X˴K,Ke%^^Z%X ,㾯^ hzEH/*Z CCC'333akk+600Pa~~>}4OzZi~03ՖVziՃs555ѣꫯ .zXZZ GWVVGs,&X1XiT^Z%X">.kllL,Ce"$ժh"G a?6<<|~1K_W1VVʕ+as^?ܙL/ӛ]6X?m\&[}\N-}vxgzӪh[t绞)?h#gқ=~74mԖVzi-\tzɴ]FRfvn߿Y77u"Ֆ^Z饵7z `F {{{ٳ'&&αў,jroAڏ V;wM0*.pڵdrr`Y-LO>^_7Ǐ?3^9JZWcV3{=7n)|=˪7y->.q`5Zjmm-Y#kpp0;w.F<:Xz7տEKmiV=XVr?JzGTR[ZU7 `1XF<:-?K+ V,mzKmiV=X hI%^UmՖ҃g`1X,% iLV3ՖVzi`1Xz`-Ҫ`-IdznP%堗Vz,=XXj7 1XY<~ Qe@o_%X PfPŬ VJ/|{,eZU[=X,z0:zp\e5)򹥗V Xu20XBD=X hYicYۆӕ]jrK+ ,*Tm`ӡVz, ђP}lɈL)J9襕^Kbҳz,z%X6[˴KKoz`elѓO^Ze$XFK$X3;5}(堗Vz,=XBDd$XFKRVsK/,=XՃ!GiĎ,}:J/%2Z`hhrK+ ,Ұ]G , V^Ze`׃Uv`ӡVz, ђԵgR[Ze`4fff $}Y V$+e:<"%啕077'2Z`qCW`I9襕^0>>.omm1=X`mK3~l0}]XUX+W.nxソoJ>ez7 [z V_ZFs[N.\}aiz ˗[o3_bU>10ڵka? V7 ݻwK7{U[Km饵zj˿0::ww=3XaggXV|m4X1+ӛyɹ򹥕>3X<=5X]K"4җ+SFFFs^ ڶWsKc~뷎oܸ$Yy=XRV6[!OfKmi V- 2Z`m64XiiQ[zi-hoǞ`!b&=Y Rt}zi,z%XjZժ 'LԖ^e`WV!kJOKmi`-I6zZ],zi`1X4w`Y `=+*|3 ,^K~=Xj[2XjK+ hIۮJ%^V[K"b)#"%2z`mv`-2XzRRMzv J/%2Z`m)VzNjԖ^e`!"aj5`!"%2Z`m V=E5m,z,=XՃURUzUzZj``I`ۖRVz,=X=:Q%2Z`m6^7  ,Z{m``I`+^U`!"`e `-IԶzObԖVz,=X`-Niv9Fe[Ke@{cٔ\`-҃ؕFf(cl`*u`!2X,z%Xv`Ee2X,zKk^{099O<fffVm``&#|rh"www`׃[yc N_T7,zKkzb=z^}p…#UKKKauuNe$R[zN%X6X> V 8sLS5>>.kllL"bFi5XIU1XlE~~mxxbb*ƕ+WC~3o%O{>^_7~þ{އgY>`Z\7m7}i3Xo>QV5bZ ttQ6X.p|3GmdLzOo-֚fRoՖz,Z\\L5ǔ*6÷`u`R͞7ՖBkmf6Xzn|nb{3텳g&;;;zFGG{jv Oz: bi ֝;wVgFsevZmyy99s,Y ђKmPk [ZhdpܹdzJ4`W?Uڦ>փU%XJV}Uv`2X5X2X`I`y/zL$X,7zԖLYϨtk:ޯ~>փ%2zW-e`!"6X'={1|AU=X,z%Xj+iږ`I`WZp`j*Zb`I`-=JL҃Xj"O{҃`I`4 27z-~1XjK/%2zWEo,U`!"~(ԃ`I$XjK/E5X-7zie26X> ^ 2 K`!""ǚb#A_, ,ޮ ,^ތ 2X,z%X˴Fi{$X,=X]lYt%2zWL`1XzՃ`E珺` KԖim z[YÊb,DD̍ꋳ;hlF22W'X`T[҃C[`dm0ѻs`I`y/sE3X6oӬ"<j23ffft,DD/ yaL2Ki޽[7 snKkN`-{{{ٳ'&&α>Ѧze677K7{?ҚSNԖ:$P\ť]l[^^N>Spvv6 KmUm 8 c`mm-LNNpܹxlگS`BD<_1XZ]EKm`I,R[Zˣ Vj`I `-?e mZ+c$XF,m'*`@,LMG-TOkQ u$XFJԖVz;n:$X ,DD,Z_*%/w`JԖ^Z%X}KKozԖVzKKȐ^ JoM҃X"`JԖ^Z%Xj`2O,eZ?sZ ^ 2(T[K""c,d$XFJi`2M,^Z`1X,% ҫjK/ `1XFJԖVzi`1XzՃtԖVz, ђKm饕^Z%XzQe@KmZ#,K~=XjKZPKeDKmiW%b=uV#`1XFJJԖVzi=`5@M6vppLb"www`mЃҪ%0XzAztyeep?'22`-Jcvv6ܺuOX[[[allL"""2XxAxgM9s&ȡ^XXɶcS*ƪj\r%+8=fx~{}޽{gYVHo.qY;p륗^ o߮;u ttQ6X.p\3GmdLzOo-Kk`Ex…)P[ V7 ,՛9?Sm饕^Z{P_  oΞ=bb"BDD0S\e]l[^^N>06K$XjK/jK/?F>x099ùs)Ӭ^=XjO^Zaz]=X%^]EKmzzuza$X%2Xec , ,^ 2O,^Z[7X`)+R[)`BDDD=X,z%XjK+J,sR[Z饵z, ђKm饕^e`!"",^ J/mbI`WJov``-+R[Z`I,DDDoKeDKmiV e^=XjK+vYv, ,^Z36X,=X҃%2ZWK2O,^Z˫`-IԖ^ZU[K"""Z2zWK҃e_K`I`K+J,DDDԃ`I$XjKJ/|,VziՃ`=+R[ZU`gFDDD+C/})1Y՜dz  `rؓX V6z饕^Z饵\z,onzUmՖVz,`0X Oua~~>⹻t[^000PͶ4ikOC 'x"ѶUei>e>ӱ]ztyee%5ݖWloo"ֹXϩ|A=z(… oQX֚Zk~Ǔ7yq866t[^1;;nݺUJUz™3g mR2Դ"X`u.QcFgyؾ_ܑ###aaa!羾4$ EoYXZk֨zNW㥗^ o߮-zzz0Nk*Z=ӈ}guZߢױ5-y92X'(l'XǦJG=D}(Nk*ˆp再yo-%*SMy~X`uaggr)6ݖ7TC#텳g՚Tjܽ{7ing_EckZkYre:X䌅 camy?g+s$n`ZDeѸh-H-4 ``0X`0X  ›SBDlH  w0X<w<w<|G|GP4~~`;ߩ?#ax'Pxr_H| W^M>-\ 677ç?n:^{099zbkk鞨O^p 0X1X## /£Go;$u]^YY sss n~ܯV0R_TX__O^g|jpB=Qx~g:sL\ߠ$g?|ͣ/ϝ;ydt|&|s {teSO%|r $g6LVebNr@n`u?T, V @ VZqFxP"4*xxe^}bz*;Y;ĔW^9z~;~FՈ+O+!bcc#Is0Xy^3X``Qq⎣x@<5.~Wz*FGGMiWTL43~wr'3̏$s&H̙9s^}s@DDDD5u""""H""""H" &"jCm^7Xee%|#0 G7=o|ynԝ{1g1%o= X{8&o{»پ? $`텮\|?N(|p}qg}6 G?ZԦ?iB= :wazz"U+I"K=#c 1w}?W +^Sn(i"`٘4jvE$`QCĆ|3imqJ@cccW}{ëڐ;b,wMU;XA{ߝEcz6+<׉'6S*Wt^8=C`L۝''?Io}k7Nk{ upw|yb?^{w#@CPu߭Ơ*sV?O=^rN ru?X_o%F/xY?,2)}m׮]KvO^<{o׋ZnNb|e}ԩS%mܩ_zİQx[aX,tl˕>sVbX)|JK{L<?z_TZIQ#50ŝy/MgΜ)Sx'kjjĪBOӚn~jnnnmyyᇋT:|G7XXxjE4U]rzJO,w(:6'?Mioo~+xmuJp¯?gڥ$*}4Oox-ܲRTib~_n-V);wn˝n-}ډ6Pg.g<}JO,`~'M:Se/w6Oa3~ێ;8_53<6?0-O/g1RlZ`U(`Ƽ,:Ƥ} XDR>x=Z|E;bWOk<ߚ,C+g%K/\Xmv X XDPVUᩈC]X )^irO ogE-r^7V N>~l)mX5߾}ҀUxcurv9 ed{@$`o~,VT*u_~Mqǚ^kك+3bhk\;լ_q\fffZZJO,:W( '[Wy:_);NoJncK4Ɵ c}nqc)VU* XQ_\h3K+T-k7sW)xER?u*wH"""""H""""H"""","""","""",""""H""""|pcw>z(8p`c^_<zꩆK/Xp؃׿.`o{8!`}ÊT}C ,=X;8,,8p``9cCK҃Xph߈n)i*g^,8pGpϡ`ùsv$``8]rJK>%qggg +++zp V18q"nySU΅+F.ƿY98p¡K (8p0&8T`133,KQ8PR҃z =X*X>p ,K33,KQ8Tp``r8̧N] }}%;_8y=X*X>pKcs䩻n_W׉+5 Y!`bffިյF_j8rx X*X8pǶ*?bK>8pQ;L tmXpM#Ϧpϯq=Xzb\NrW?'RrXp 8CE8P`133m X*XpCKK8p,K 8P`133҃( 8 ,K8p`V|#<ᶦTimm-$`+Vbcng8fu:a<|<˗7rʧs+㑹JHK33}WZ^^Wn҃Xp500jT W2 OMM%,8pC4_aff&&&&2r,8TT!333[>p ,oz,,GQ8p-G/CK҃AmszTEQaQ8vjKuQKzTEe<[8`1,,8T`9,a¡K 8T!`bf=X̬K*X6CK8p2XpT}eC҃zY Ԏ  z!``9CK ,=X̬` X*X8pP‚s8`C 8Tu ,fCkIZ{,,G8֕RN] f?_;^,8T`9GRw޹)\E|jC 8 *X8p`b憹ѣ==XφefK=X҃w/%{J| zl#8pXz?ǁRb%+Xp:X8pq ={6p044RԔj,8pu }077j8}t-zY/3 $HR 8epBR*;d +++*|?~<9M7Ӆ+g؝xd.`Ά#GbUpeC+MIҶ+mx=X̬rhooW u +_ϟ/Yʟ?1\qGE\ *2 kV$jnniE"ā u }_[̬`-B,K8`aCRr *XzY3TpK8p,,G8p`,=X̬ 8T[8p`rz  8p`CK333Rq ,8p*X8p`bfff=X 8p`CBVEt?ǁcC V8p0&8T`5Hbfff=X*X>p XΟ zT}C ,=XzYRr,8pXz?ǁ,8```1%`bfffK8TpPھ҃nmmm-$E/-->y`9,8p4|jjjZw&''3gHs3NU~y/~8!h嫧',..O/,,ǖ3o5=XR%K33] XmmmNVɼT} *XEVtʙ7ןU? H6]*DURWtZ?nM+^~a<3?q:r㡂Xp؏p }U]]]-g^=X̼oTmoοռEXpطiȿ\V׶X&8p`8p`*X~0+``9 *X`9,8pyzTTp  X|,=X\}[ʊ 8p*Xxݩ'x"Zz Z᷿,=X8paLp}uu5LOOoCU}1UFvZ47pC,fff533f\?E877K 8 J֗&'O&,zjs8p`#=XvZW}1Uvz!333N4ԎXpv:XΟ1KK 8!`bfff=X*X>pØP҃38p`CRr,8p`bfff=X*XR;8p`C҃XpT}C ,=X 8p`C҃UΝa?ǁ8,z VpPCKVf]Y (8p*XR]=X8p-..Ç X*X*X8p VΝۑ]rJKNliiIfr +++*X*X8tu=,8p4H:qDSU:~xr67 oV ?+W^WQq1oax0&8```9R28!`҃3(BU1Xp`jX ;v+Y!```9W*X8p`҃t/k6̬KKQ   Vv\,8,,G8|z3 ,=X̮̬KKjǁYZ1n\ }Wa:g!``YYpXz`uYRrx`*Xz?ǡxЃe҃ ,cC҃,`uY vv =XMMMNZ CCCIx^ZZ҃e҃eLpXk gΜ ###*X8pX+,cC4`酅ݭYbUZZZwy62,-r.p, mLp`bfff=X 8p`C҃98|fK8p*Xz1`={6p044RmjjJ 8p`C@ kkkauu5>}: Xz?ǁ8`U X*X8p}.\T;;;XXYYуV1Ά#GbSU΅c91x߬Nuya%Yd>`mg!Ά#G=_ 788Xw[-[VĉɘԂ+&Y^JnRY^Jv'H KHe6Ugp}՘9bs`=Բea`MMM%)+>w/u=#qe_K -+/cǎez< wY^ 96dֶmmGR˚mᯃgK$ innIY^ղeeLۉ," tڵp]wc%=VVV9D$`UW_}5tww'C%o  XDD(*,")w5ivw,"*ur_"MDDQ]!^!_o XDDTBi uQ","""",""""H"""""H""""H"""","j:&"* XD "DɺAdىu,";QnX7,"%EDvd "h_D;;o5u]ajjkjj)K/Cfߋ .$U-H":XwgWpʕ *]ayyy}r}Q'7]17tSmJV?`{1;;9H",|ŊJ;\PHsPQ1=nOXӆitbbb"w},"2r}AQR'X(׿ XQ!>Ӆ/pUOE<ݫZ7H"݉ozcPD3g$`N;J b3xs֗~{qU+H":X?x{b&^k)CF%=z49uV*TzC=F<3%UiVN1 XDq" XDvD "DɺA$`(Y7H"% XDTNH""""7]eKIIENDB`libjfreechart-java-1.0.13.orig/docfiles/XYLineAndShapeRendererSample.png0000644000175000017500000003622211173030414026056 0ustar vincentvincentPNG  IHDRXr5ߙy9gY7N-^X}4n'O?tg}^xAs\sf6ڣWۧ s=^df~''> ˺('e˖9 e#O 6ؘ'OW\q:p'JzG<%(?o1czh/م$c(IN2rM21dye_h'jj=d~Nc]Hͯˉ:z5rHОdӃ2gK4ӺիW.Lzsː?: _>|>~dI.}~i>yY<@=z$^r7o:SKJJl?oϞ=fIR!:R?VZZ8toZ'y4a˶|r\|N䵶%e3ge$vڽ7|3wHfggS?mQTk9Tld,pwzHg*)vi Yƺ{o_Xr>&k VwA_y,'*\W>̜ҥK_zjrriT,9ĪڰakyGGǀe=*xldTzwܡ\kdTʉ_jFJfLUĻlF%KF ;ʨy n.2 Ғ~03˕L$`ɾc7w9z^'ݾs}LѴ8P@eaKu '` i(n0`7$,Ճ<~F|b-'krw,~X' G[]6;YיN,MK6^NW^y߲%R=\RhLg&1֙~֭[mkF]>mER aw,733p! 15 Ag'%q[Xvd97[ÂyzШu iPfP|XJF/4s̸M$R#'#ɔxTtgxy]؞ZTz>yrzݿ洭7ՏgNk +"`!$zIʀ[}\iD-u%')8;eϴ#-[A؝06vֺ4 id|W*g2+Hi68˙}x1zpJPB QsaXjMEl&lyt;BrsSD<'9xwJw%{{&sR`^jYdT`I98*51'Dʲ^q#KLxyCb,4e֯>Kz0oZowess %mvWJQ"`ld.W*?3*eFr&3`YkVv^j VώI[i"`! WuCjS{+x %-KoUv4.6N i6s-5F.Hr)|)M*JRzzx:QN>ְnq[^y5v2]ܞ\T~f4LfN[J s;"PH~bݍ-Duuu¢w}Uު.~4+'2"v;'2;O>=mk;t5 ڨJw%s{&{3iײ]M Xd" Yo(g!no,޽{uhi3MBeOF;K݄4!Aųl|򉾼8HoخȼM%HQqe+lr?6rz^S\2c:I@;Kxme;[ZJL:Hgzmײ%TQq.g1%|'wyN,DB ‰!X!BB,"`!nlB,B!B! !BB!X!BC%`q޴!|9PdOW;;rmw_vt 0pmذA7>G3vܩ ަX._ssꪫ^ˏ3fw}W?Օw={~>N~X,y,$KxO~gymۦVO~??{e59XIn|ytd7֨W^e~[kmڴIeyO9k}KD2"]}վn/w򽱶믿?Cڏn7MFsJKK|Dzekf"z/?\"9NE^K.dK/'3yNVoeUoNrD"첢~H/37ExY^xOLiD3gӸkcaAo~e3,1ñwttĽ%s=wsҰs뭷/wʔ)'| 7mY/鵍-,sG(esOjc#2nt-}^^ ֑iFsxY>Ґ'&YF#7N.i^^]nݺU?~gcy>gfeJ~8=4j',keg}g2e0ʺҡb}_2k2M7㙲q^2!3mݦ+$Kg ?~MS bB/;o*'= #~_yM+J'dA#ǻ2zd7.ON!,JX}TE bKdj~}'W?m6@`7"©ݦsy X~Q2}=M\^?Ǯ,iK5Z?j+F/uK2ad,7dsւ !;ŋ_|e N+4#GT f2zvw0V2`,c.d{`%CvnS"RX4ob\bxY>ch'= TQ%$;]v/d'2›+mmh^\o,O֫x]=&~}e׋c}_*kxN^8VaFuzj[e\ײ${%sb-q7EǮ%_RDdJq ,y]eEy{ޱcz&/,˕Nrc|2olw%sb-˺_~]deXv@d'Y:+[9qXAi X/%bfuX=dvO$J5|ų2Jb}&~r@T7^'ހ%%=* ;Tﴟ]^_{9ys<>Yn6߮ìdn7XO u5jԨ"mˍ;Y2JeQVyY/t<-}/M(\2y]:՝FkB!dYojB!qiD"^FefǸL9B!XUj;Tq_HB!PEB!"`!BB!X!BB!DB!"`!B!B!+2?Tyܹ)^x^xoqq1-`y_Nݛ^xw(}twygH /;x XiXc1</ /,j^x^jX^xᅗ,5Xc1b+++vUUUU\'qggg ݫէ.V?GUcސ׶w߽7~K[/rye X^UWW744ʴ;[pk ?%7~ꫯNvqKcl_x ?{ڮR<o3gjoo{֦ 6>x*9ö:4RwؾL/q<~OXF.((Pу^yyy v9q#wt\5L:]z8ˋg) XeeeG3곬T^M=;\꽨aaw ӹ9rbw㌸PFrss3b9~x ֞=ހz:ݮsSWWϷ}Hutt:ujZ־}7{em!i7̖t_ o-Ws4%*))Q---z4J•܆v ^_9h"KV~]}<1zkװ;X?|;W2`555b&Ojkkk|,[!W3=Bx3r0S-ӂ>r o&7tE? /oC^x^E1`=$x^x%`QŜ7 /RE/ /`c1,z /9ox^xE^x^x%`Q1cj/ /`^x^x X`C^x^Fc15X,z /,^xᅗ=x^xe1cjX` / /,j^x^jX^xᅗffgj0cLϥK X`C^x^F(U{{XeeeʰY:B1yc{^{ΨϲR^M|C'n~aqfHdC$ ٙ,1#XcFdJ4jNJ sW ;`U}ᅗ XAUip͚}Wʴ|%\UV""ް_TYy_UFW/"d7w~*_rW XA`>:`Y`_ /!֚5wkrǸE10oC^x^E? /=$x^x%`Q1cjX^xᅗ,5X / /,z / c1`1 / /,j^x^j/ /`0c X`C^x^Fb^x^x"`c^x^FX`a1Ƙ=x^xeŜ7 /REb ^x^x%`Q1cjX^xᅗ`M6 \,YZ[[mߛekj^x^I%%%Ejo޼Y͘11`1E ^x^xC999 Xc1+pGmٲEO:, _₂U]]"#X^xᅗV_%h1ޮVYYm2lVii56ǟ}YJ??h^xw(~[/XfK/ /`Ő[h2KS1cY/Vw֣Q5X WJR555`C^x^Y:8IITeeOvIl5ydU[[orx^x%`q'wz / c1`/ / Xy / /5X,z / /,1S=x^xeŜ7 /Kb /c15X,z /,^xᅗ=x^xe1cjX` / /,j^x^j/ /`0c X`C^x^Fb^x^x"`c^x^x X`a18k˖-I A6mR .T*//O-YDھWUUUrĝi X/ڰaZ|Uޫx<=x uUOߕ?8^xC~7>ZSV/h{NEԀΝ=QIIjiiIyf5c թƾ 2mK6bŚ5jOFVOT`ii7PgR~9S>O`G.U7دnXHZ*wP Y٪FE"M>?gM-`?YtMƩSUýCހqk㭷ڶ2`pe~z$+KF}Y55$$hIy뭷 V===zQ $Se>7kʕ l7pۙgkAzNwUw0*)qlƩ+V]BL]wu:hYgQ,hQe XzHo"t>o8bo|C}ZVww4iRB,)z_`AF`U.^?u+:^xC8u%jjjR}SR v***Rjd25X$ :`&5 rѯpMjï~ހzwm[nףOhq4޽[F>|X`Iףe+**zᚕ+s$- pU_m?\9 \߆oToHܪ0߇ABn,*R\"W&6 V rL3mlVuly,]Rq! ojO[*K˖Ǵ_x G}jJU=}k֭ɝ9~x^xx^~*"/ /,~c16,zH /K9ox^xE^x^x"`Q1c#X^xᅗ,s /K  /K c1`1E^x^x"`1 / // /`Q1cjX^xᅗ,5X / /,z / c1`^x^x X`1 / /`1 / /#XX7oV*77W?^6feeٚ,1L*))Q---W7s:,F! / /#Xq('''9ox^x+k׮]zT)`IjD/ /,'رC͞=۱ˬvlaJKKu56c<1y8V0uvvzےxF! / /#XɊBwR`1/ /,v:je.l7_q(᪪J0E ^x^x X~meSSgVvv[꯷^!rt[߯;Mq"Xγ_eEip:`[c1 X!=$x^x%`[ / oy X`C^x^5Xc1E^x^x"`Q/ // /`0cL  /K9~x^x,z / c1Ƙ=$x^xe,^xᅗ,=x^xeE c X`c^x^FXy / /5X,F^x^5Xc1E^x^x V &'++`1/ /,}`C^x^F|0,1Sʀ]PPU$a /1BޮVYYm2lVii56ǟ}YJ??h^xw(%U`C^x^FT~~>5Xc1&` XJJJTKKpUUUjjj/ /,/ XMMMXeggɓ'Z~ / /;c^x^FXc1=$x^x%`eHb^x^x"`c^x^x X`a1Ƙ,F1 / /#X,^x^#X^xᅗE c"`c^x^FX`1/ /,F1 / /#X,1SEb ^x^x%`Q? /R=x^xe1cLb /2E s /K  /K c1,dxo„ UUUU\'qgggZ֎S{gT]]R1 o~;OC_x Kfuph~ڀg7թƾ 2mK6ƍS9G9Ži ˱cWvő/ /orv<|`uࢋ~C?E+`͙3G=nkkSi X枯?ɡ/A=E{mە%=a/8Q㎳mqJv7``,:='5rl:dy& 〺ۮL+**z/v.X{mV1UHr[k#ĭ0})νrU`qmk0?o/X_ECO^uznrʾrmU=p=3^x-BzH /K1cl/ /,j^x^jX^xᅗ,5Xc1&`1E^x^x K*..!+UN /;x%?B!(B! !B(?1c48x^xwhء^x^B!PEB!"`!BB!Xhݫ&L^UUU.ZXy7oެ: 77W?^ײlf^7Lܾnaپnh&_?~fBMoXM… 5o^^Zdjmm M%`yN566=nhhP1_ +oIIjii;oOOڸq;wngdu{=Uj̙ھnh&_?~fBÛiW,sƌi,'&7͙3GĆgQXX)'''t+CaVTT^x!׺fzśi7o_ۗ;ۗ a%xL9ڵK8 .((P*>`91eݷo5kudLox3ʹgfB-[)ð_VG8s! xǎjٶs\VV1VL߾<^EP嶏fbśio&_?aoFIN߿?4헀PUwykѠJb+S&o_)Ueͤ7گLh~x3u B~ XI.>Ht]|]u.|¬8>/4N3O12hB>,DBR+çwqS===WٳG?N(]uwt]\{q7DŒpҢEiƍjn4 y^Rf>B,sƌ躨g_46FŋχytR;o#^ϺNB,qyȑNz'TYYJggg߁jڴitNkד\ٝ<ޓ 2z#+V+}3UCg]1hhH{{Xv],DBւJws5wHoQ|Dn>:0ZxԳ>uwt]\{靇s]֪;SoċG{7h_=S/X{ZۣFe_]/k]x-Qv0L) %ʸsqJzNNL1+aGGpp Vni_HL ȕ7e.u躨GdZPF$\=Pׅ+*ul ҺѰ|"`$,#XrR`uiJ]@!Wb644:\SawtBWyN%8.[E¹.vk.Xl_^=TZzOQO"hBF29|2][Uu|8ERډ\:>h ݺ0_]*᪪J %)`%[Uk|RIo/_Cz #ZMeֺ=TV+++ u뢩I_M&OXB?"`!!XBqD,!ODB=@`1B!RV e\IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYShapeRendererSample.png0000644000175000017500000003244111173030414024622 0ustar vincentvincentPNG  IHDRXr54IDATx \gy=pT/-j*ԊV,lE4;]+i R'za q+KN$&(P `'8\:x<;3ugw;3;sܹs} &o` `X `zN#,\?w;kw]=mo{igv?K.I'~73z4gΜf͚t|Qۿ=yOZn]O*`M4ٙ92}C1X3Çg'8}PP|:7[n=#@<3}]w]ŠQD0V) }{۷ouō7>03F~>fs嗟v;Wi+2CF3yCV0 >gSvŷc FG*^oM/RO:8q"/"ۗU7E* =# XS?D0{ߜ, `x'Ϙ+cÆ =欳:#D*^篶TK>򑏤7MUVe!1B`xE` }suee;wܬW~Y?Yx襊տy&,p 7dq:1]g5ir=pꙌXxI ,k PJ@L Zt{i,QɯReP7VGϸ=V+dXwVsM|jSKԣg2 W4X`EDOrԖ/_U ӎ/'Jkn*9BV\ɾuxQ#*`2_}tSf2uMs?K_3ZLf*"1Hу@ ֪*EUQ὞XzBiLDK;I3O( bt - GT %ǗJ&*^U#cMN|Z{qiz&3`N[Ճ",IF|aTxEXnj>K_Td\_sW} =\plٲZoЏ~3a XZnM,YoT>g5W_>Zz&3`YK (]\~i}&1?&VC'`s?J4싟1%m:tt{菕 'Ř)w`WF5/V'>Qz@fQ*^5~趀MJXU9 X `FSf͚t%L*/IΩ`#%/%33Γm'LuQjЀu5פoۓ{nҟs*:yK:yI kr4:yK:yIlXSg '#`їָwwTNoV8` fUB\dIIengLަKm{wc3v/{ʠ?\rQYoUV*QفSωn9rdRo ̫>x`Cq8~sG_U;ф^/Γ*X z{{t*X Q#4`!""6Q,#yI}N'/U,=X%QeDK餑*XKT%䥀Ռk׮]- קG{_)̙Sz=K.`422N:6oޜZ[[ǽ\R2jt`vgͫ<,DDD=X*X`VXK,I===ixxl*YID927UU_lO-ՃkV400SN͛7-[3>v۶mX,F^>*XM7E8o޼UQZlYٿz=9*` fUϘ,ZeK^trmY}FߟV\9ڃ5gΜ3SZ[*QY/)m۶m۶mqTjۛt,#2^N^ҨKFFR^:;v촾K}ZK/yiKS:`=VZNa֭ՀWnܸxU2j9Tj!Y۪8`Y 1` XM,F^iKKj4I#/` X>Kth%9cG_zT,\餑zT,,F^iKK҃p=X;wZ]2ҡttRK҃N^K` X*XFdNy*BW XzT,,F:yiKO/i4,#yI'TsδvҒϟ Xz`@ɸk׮tE X*XFdNy5S`)%tKvXM:uTڽ{w6e(``F:y˦`]sM_T]`9̙3'cK/ Xzkk>`,Q#/i_w9/U,K:s1\1?\׬Nw޹Kth4+_y,]zke?XmC %`!bܹ;cicǣAԃ%` XF:q"΃O~:~h=,4Xi%9TT%Q z˞7lHuQtiF^`` Xz=NN^ X Q#46\/[ꢀ%`!""RTyI}N'/,K:yI'/iԃ%``F:i,=X"""` X*XFtN^ҨK҃4I#/+VrT,HǨF:i VTvܙ̙o}[Ow^ڵk QV-Xn]Zxq?mݻw4p800 ``5K:yVe ,H}}}gɶ׮]422>OJ҃N^K^ZZD:uT{sf fm۶եKyK"v=z%a \yƟ"HZjU>zh"2 >g,UyI#4R+`; ehO`ty Xش׏ӎ{Dԃ2 pX0E8ħeDֈ7m~jm=u嗿.^I#/U֬Ye14}3K M_^Kl/1?6o~tK=Xξn]SbJ0V)(ɓ'\KiP2"k$_iʑ1VT6]}*X X?nЃ-C!zz;EϏӅ3:EP2j(7l8\ՇB4Ny˕o1ũX;^`{ vu=WUںq^I#/`xVŔ`0~f|HY5~+Wy>^I#/UrrШ_!p" .NE4=8ѵ<,, ᄇ!+.g~K:i V+X,}9Ӆѓ,X/餑zp駟|ꩧ,,F:yI'/i+o HVZz :X9u X*XFtN^ҨUzF:iXϦ瘟%]6=# Q#4cw^K""Z֖V\80K+,,F:yI'/iԃU+bJ^8p%&w=X%!zb%nJuq*V]^=j׮]i Q#4`Պŋ'xⴀU?? Xz`Պ;wh\mܸ1akpp0j XzkJO+WԃeDKo[r??}m??4΂ }S]ۛi<~ .\J}l:::9›2~Nt_盪ҟy{ȑ\+lNkWqt3sd#, ``Y0EhRKjztر.]Zoky,DM8K9示(`Mbںukv5`7n,eHg562 9/UTbֶ*X B~???4ZKj`5NN^"0`!""Rth%9|,}NyWШeC#/  QeDie_}i۶ _8nPڱQ^:~䥀%`z{#iݺK.I> /L/}?/?trZ}S],#\1G>MMohw7?e{C'/U,=X?Z)2" X Q#U0*S#~p]pySZ[ҹ禺(` X=jzxZStK,++~.}cH+W5k'?y$QsǎU}pͯC'/,+;z):80qOkpmBDW X X׿P6\x/7"3jV7`-\^:~ .c{{[Oi?9ok_~:y)` X X_SUo#2iUϖzGUW7/?tR,zXji9E[o}7(` X%QKMxI}N'/,2 FtN^؀K/K眓ꢀhWWc-4%`:`5H'T) XxI#4R)BHF^iK̙S}t,DDD=XV144.K˨N^K^淂u}鬳R]7nLwuW,}NyK+8|pZbŘӉ˸dɒӓU}K^ XV%lذ!W=l*Y/)m۶m۶mqfYZߌ,F:yizrk`Msĉh"=X}K^"JqСvq@Vpݝ6mڤeH'/s^RJ驧7`ٳ'sŋ:Xܛ*XF>*XV,}NyKth%9|y_:T, Q eK:s:y)` Xz=K:yI,Kˈ4I#/U, ,K˨N^KU,=Xz xI#4z, `K:s:y%`BDDԃ%``F:ieSUZ[ҹ禺(` X=H'ԃ%``5NN^ X,DDĆtY. XQ#tK,,K^iKKR2jtF,WpCiÆimGDD=XzzL^Zt;:;߈̨F:i U 7m?SF:i,KwݟZ[Oy.4j%9u}sR]4`Ep/\'\>""6c U3?*`pOȌiF^jsw X{Nyٔ=Xs9se9~l'?>m~rprHڽ#2F餑*X*X3Ŗ-[Gmۖ*;ѽ1F>aժUihhhtѣiٲeӾV/`+eDfH#4Y+XQ7o^%K4<<\?cʰB*ٜuM?ݎ uOs"~7ҟyGɵv̳F_v8~ ,lrTΪ]cU|Q#/)BW_UeB XzĉiѢEe[zu:vi=XK.U2j9/y|y_:TID{{{ȪQbM6ܺukv`U7nрe^H' VgϞ֖Ν/^z{{+X:XF:4Ny%`5dB""־t. XQ#tK,,9{K}?O˯w=$3O|≴`OrF=X}O<:|Fx{ӹ_Pv???4Pr[ ~v~u,+#+\| fh>]և82??Oz,=XVp|n_LUA~:~hԃ%``oǪ X5OWAU_??4` Xz}~TUU}BD=XդۿdpuCFF~[ʘk_O*XrZzv}=AɴZָӟ>O ރu}sR]?]-XZc2o==Ix/N W}͏C %`5}$khsymV,K21jNyePj,}}N'/U,,#2^N^ҨK` Yg(` XF:F4I#/UT,=XxI}N'/,K˨N^KU,=Xz`5]ZvmG?eI, r `ڗ=7E T2,+7N^H'X/}vO… ,N^H'l.SU3g(,h*L01|[J}}}uf{ `!`X04ѣkMϸnݺt\iqA_⫭ʫZ|gӕW^94G j˗o= 8a|Ε}sipp0^Jgӗiޞ2o"m޼9}-[GmۖrgRgStsEn{tWO~ELjxȑtZg)2y8瞙:akSs4]yJci%BqJZ* +-[,W66F9FU-* 'O^Ig^Fciߟ{ظqc뮻r1f5%FQ 7^xto1WΝ{ƁL *i1J+vtƈ}ٔa4ƀdرc3\dIIùY15\3-my_ƴۊ+r1 4{͚5;>bNg?Y4F_KL ,B#<2#?\r̾1iKEg-)4v4^qYLZcT#`uvvJc " SܰaCiùG) /1=tvJȓ!Whr^8{{{tyXI?_}լ$Ny8S ݏqL@fRc^,ջX<{,Rn;o=Xؿvt!c:a1r[ti4tEg=LYtp8^'NH-ʕh. |ȭ10-\ 7y8X046JXa'x'Ok(xՁnݚ]9X@ն]j,T!\O2+霩uj8y9Zu=#;/kp}>S{ɦbn 7olL*QΣx_>S3~G @@,, `Ë!Vnq@FرciwO===L VwEz{7ێ,:_f͚4{e]@x饗Ҳe˲矟?&TXaKKKn, *W}}}vX5LC,Pdq?P% Ƃ Zh, , @ @@~ IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYSplineRendererSample.png0000644000175000017500000004071211173030414025014 0ustar vincentvincentPNG  IHDRStAIDATx{LUi;L&d2L&ddҙI&dB Ju;XR XPPUA-@+jcsi)X|شJY^K+JP Aw[;9ps{ߓ<}sZz'`3L`Qw2/)BEP?ׯ_>?88(#S˦)ߩl>Gs|5)BP3S~hh\xT{CT {=ijjpb9ު3R,3yג)v1Ջooﭑ1ϩA {'>>~)~ڡxMf ŋ>͑^9_سgߋYyZ;5Yd֭ƤMfZZZLA#-ޏ w_yNM~&{XQO0$jN5zos5)Š;J-P 9ϟ?4.~nEޏۿ[̔o.4daɒ%cӺ'tGoxxy?:> ;d(^ )g]|A(j/}bT,[lʋduF5S^: smX{_-^S?X(A0SD:wYv~fpA 3gdӦMLIӽjzS>LrSx dlBaLfMLQ?΂k4ZFWeGry?Lx\gy#X5Z\|Mf \>SZ > eRRRwhP[甿V^{^&f?é^,J {{||ݛw1 Lrh/Q!yRX+FLJ]bƛ=m.3L#)ԙ:[.ҿof4Bc՝=>TZZyưP&3@HkOL6f\ƿtN [xq@'X+&͙ܻwoB~*Xqj >k0S 5?S8}o-Z4#3Q5>ZpYxƕnݚi+iyi~~աfPևitG#-xO& _i`ǾjBBb )f 0S`Nxf 3)f 3)L^zYE>TGnX MhBeVVf;::B51VhBЄ@`iΟ?ﺃԍ+4 MhBfʦf B!"f+4 Mh|f;Є&4 ML MhBDd 3!Bj0S~d+4 MhBf.fJ\4Є&4 MaaגZD~TWLq'.4 MhBS {.W0S)!NEH.\8"˗`0Sɠ MhB4F|^z-zLcGЄ&4i*&'p]򙤥c0Sɠ MhB4kj.(Z%5Sbbb|r0SBat,^i{])LybmIoi!ǎ.4 Mhr&M便KyuGrIȈlٲE֭[gU):N]hB&M%%1kNG#eee=,}ȭC!tuŋc>TZZnwwwKbb+#SJzѥfL MhBAKLKee Ν;o5717Ly{^^NЄ&4њ**35SNtB*,,UO5L]t`n߼y3yȩy kۢ[?'O|vI҆Ϯ:sl>>9"2*ܼYoBH~}ټC? T̟?rJS3ښ)o>̌R3L MhBfC]2fժ'AOQ35 DHi+jܮ] >|6mru͔ų | uBЄ&'h&NH3$YYY2gY`ԌIEK)_[TdЄ&4 JKEtLYԨ@jRBhgj/ii9z/̔"S uu,=]>Є&4ɶrr?x])Lyˣt MhB-5UU]5k] 3ȔġC*)),>"ShBЄPz))/¶d )jfL=՗ѥf ‰ù=0SQUTpw.4 MhP"2ET2tIQ7.4 MhpfTHxohЅ&4 MRD ԋ2\=H-=0SQROK I1:)4 MhBT WO)"SL zy9uC MhBSX55SDBJ-Btߩ;MhB¢-=LQ3r^lzOA! {eۮֈȔŇ'wgu MhBS(5ݒܞ"2ETf mjЄ&4 Mf-]:5SDB+۷˳tc;MhBI#QOe۶b0SQV35>ݧ =C! &7l'yy"ޣfTyŤf̓Є&4޽$)镙-cš)o~^_//nz4 Mh3kUWUcx31111/ϻEEg?pw]'Є&4JA+G)95Sӣfv !pFhf:t";LuvvJVV 8LNbm .]*';MhB擒Rv"*ʑfOV\) k/288DYڵkMn3]]]!}lwӼiǏmgcO77m7:N|>99sɑ۷oO1fT>=ucV"Su MhBS@,/.iiizy< x1d"ShBKJKDXLeggK{{HڲeTWWgj2>ShBЄ&_*V=ÇFXL555Y~s̑ HMM f@Mi6$2&4 Mh$%8pЩW7;;tBS{)"SPC*Gd MhBGSII˛v3O!5RVv}"25S8tȤ|5$2&4 M֤]s 3E,})4 MhMKjiXaLkW۶BЄ(Ф 9|sf`Q| 'Bgw/0SDB5jId MhBܧi+:)"SL9bv̓)4 Mhr&]&&-_O3V)"S%whB,qI22[o65RZp^[{LQ3BfÒ0" ʫ)c&4 MSQ#R'Γ+5S) MhB%C&"XaLa+4 Mh 2h a0SLa R38Li 3Ed 3X MhBlm=&K25RVDJ>XEjii푑ٲe[%e__5Say}LNф&4!TTVv˵DP?LInaϞ=T4i#ǙѹAЄ&rjՓ.hefSd```JKKnILLf*Îbژ2]'# ͔V\)fL͝;wjocDBXkY ݻAЄ&RۼljȔ۷G͔=fS7Sk׮5Uk`nwuu# ڿ_.˧N9Vnh9&=|]^~]}ܼyߧp4Sj|ȔGIfg;~;i4 MnԤiK-*Ɖ4̕U3< ;D=YJnnBP)*˾L7Sv23gmڴT4iMmhNMhB"L{q"253E)ZU%ii0$hB8pƬW_yT}g?lɠ MhBSfi_h'"S=|4Ԧ! /u^fc="2oOۻ;4 Mh sz="S)GhFjN76R&4 M!C'LkQ;NLrVQa ҏp׉&4 M!'"SLwB_s1)"S.tk֘Y~u MhBSpѨz,lj5SE X Mhr&btƉ)"SQ~kkDЄYRrڻDdh;UR$%ۯ?"2jyl"Uu MhBr\ӟMf);JJL RQ&4 MS)*8Q3Ed Gyyu MhB4Z YD0SL~!wdŊ&f))rN4 Mh/%9e@k"2ET64В%f-?!Є&4ib ]x5SDpd MhB58pƴ@8f N[ ¨v5OIy13%LsJ^^tvvbbb|Ȕs5i˄49qwhBVky0Z LIvvȈaCC$%%)jW7 "kcx Mh:MUHA@f 30SܝͮUHф&4E&5O=4RDL ˧~j~RcJfTj+_ȡC'> R;7LAի}>5UZN͔{4bNi)c&4ɵn{:qfjZ$jΜ9R]]=imgeLLS[S .]*_mX Mhr&!DԄ(Qss$$$S(gϞʅ |ҤFj˖-ƸQ3>j3O~i5hv9gP35ix}}G?VO( ---4iy󤬬'ESSdeeׂ |.PWg յ MhB5iDJQC8iϞ=L6uRS cЄ&4Sf{1NLMi+ͧ)9(]&|ƞЄphҖC*+OO2ND&ҥKG зon"TZ9sBh{LkOcP3D[eeA)LgЄ&4RS]Sk텺9)Em 5SԤFJ['غBd;M̌ۯ0NL9DܫI{QiOѥh+4 M֤>/o_;Dd 3O-F͕ǙH}![Z5\aP3;JerۻBvMZ⹉Jyb"S)jȱOʋ0=%h+4 MдyMShuR5S)\5iQ^eeM>B4MުUOLp.V8f ?tMSZԮBE%%֭7lbLq't]>k+4 MդQiik7q"2"Hi 5VЄ&eew!!aD ^ZdE'jL#JMuLq MdѢNo5,_z)5S0,tΎ+Vͧ ?u]odB^A͕R::F^])+9wxy(ڻ܄>Qjy;m#L߿_2=8;wIggynddDl"֭3FIGd M!uauIʯZm][.\}RMx\h/_>1&MUU] INηt頉*ir 6w´9CTvvlhh$KQWW'gG5Sh Ӎrevyty+^MflѮ))d*cHGq1l_VW;oiz3wF*)՘mzjC /u9;{K9ZSJVV+GM=2'5ug՝c]Kƚiii3xww(K^55ץ;LdKSzoptfJO5k xiR"fCO hTh͚n|l $aRJI`+5Xj 1NωLMaOMOi?ohjc荵kkx6v߾&gгo9f)J]/+ˤOzqu631SDA[45LWc|s+.jN[4dDd 3E>;BПYz<3i@)88~0q졉95SDpr&Ji498RVzb u]==45SFQoT WOQ$hR3Ed Ǐ(Ԥ>MM8=*2{d(CLQ3E.]QIuIUU.Ҩ;}B5S)\?w2h #O67  ,Nq"sQ g9Є&"SGCCdyNqqqoȺu뤻<LA<)-5\iN7jÆ{+2)liooO>DyQ3Ed;tG)8=I;ĚCL0SхxK<ϗosrL 0Iv99ںȜr:wVYfJ2>>^*++eppMZQ*ϗ/YCO,ZZJJH}璖/7޶}9'4r:v,_|f===L4QvZ`?fml>rʫ0QRJʰٶTMM$Bu"ShB{412ҧ~ű&4 thTS3&tHTbkF8Є&j6(~jl"DЄ."SEǏuS/8Є&"SdL9sȂ L* t'3S77ov~eAy!YHY|8 MD0SLAݼVQ!Ë7sdJMTaײdɐlz#Bj0S~dN76&CKȝRәy/JMԚ5xqBLaBc&3zrs͒4u +3NhB0SD%t8"hֲ#9͢,^xC)auhU*T5rr5Ѩkr.׳LA"2(ѵlk*T1NuP+JJJ:#Si P8Lq#2f M.&;wɮi~:`ޑ?l^K<0fOɽ 7뱧'׭22lJ&j0S~d"N]UUWME{-]:hX_O-\8bd).}M][.;פ5R-Il:}a7Mr':SOPs"%Ť;JJds= AVUmN)hܓUL}{ӉLi?WII5gfN޽&4 <_,7xC֭['湑ٲeyL):8pƘ6:p*.0P_ڄ[o ͨfJR^[J1 jbye(iE j¬{E]ڱC׬1}ciA;_Ѧ׋cML^پݤ3%4ϋ]j؜LLe{hۍqO>Dy\P__?{ˈL5hŋTSURSKTW_ zdLW(5|ZS6332zkc1B--&rkLN7`EQ3$YP{.Rv5U4_ll&===k*11)49^F|4Ŧ (NMZĭG͋wKh1IPoz Ksm^PY5cTө4XQ@D#<m:f(fJ_[#Jw`E}RSS1R]2SΝ3*ܹs<ѫY&ʢ7֮]kvbg0o޼׏vWWX#yΜ1z KSUU\zϱ_{9vtUNJzKcT_LH]jmo{^w@zRZLjkȘnkd論nhG35CCo-=|^gL&ujjNJ2QǞþ_ZnzLF}gg#z9skfرc|њ 1jQ'RC,M3EfMI VzN3k|͘i XiiFm̬©RN̏F47!$2555xf Mvԥ&@ktjΠ v:-c&ӗк0z2]SiK܇&jf1Z>+W15S LֺDi G#5nzgT*f*OҚ0-ׂzMɹML6vefy۴i)4R4eU4L?-hw"S=oӌ 3csLMELAЊD6DAMԙZ7LwJPHйNf5QV@zD1VhBHuDMjvgЅbm>4EXR҆V$*>^*++epp)jeyT0 c&4)Қ>l"VBR60XLa&ǘB&ʢ7֮]kvbg0o޼׏vWW׬_ԩf]E7RT\V|aSZKٰy\ә3æϢƋ:Nnijw=GW繎޸Qn}ܻzS?W)ȈQ3qIӟӣ}˿ (ڤ쪪oj-֭7d/BqB7Њ`,Az)ËfKZZ5ULMieLH ZpZvwGF;k4) NV./tmY,NЄ&'je&Ê3E4Tvv-[Huu55SA/%'Ssj=}3N[8)DЄ&h+5SFn$YYY2gY`0/E቉~44u MhBS dfJ;;qA"Sg;k6]RҐ =}}!df7;p4]iCnۻ7lL9NСf6x1M*)]'Є&4LYsY.֚EiB퍥 /ՙesLa\_3tl>5T d69v4 Mhr lBj0SeViNC5hBЄ&$2 5d¯M}mҶNM!]="՝)"S7tF=gRzܝ MhBɟHMGyyr4h LLWLmRBw36l k}uBЄ&kRվo\g500Sa0SZjx h6ݻBЄ&43MrZx.Z4tBa ݽgb\finv]whBTrݲeх&4 MhQ,̔k-{)˗.Ѫ+ɠ MhBЄLj/0=rB!f 3ŝ )4 MhBSTLE|hbЄ&49fw2BЄ&4bm>!)"ShbЄ&49f)rBЄ&4Q3Ed Ǐ.4 MhB)Bb3e Ba Tf L`0S!PA!N054 MhB0S|Є&4 ML`0S) L8y7dݺuhMLiܹ'qN۷3ǟqH?G3oA#9a\Ȏ[ѶO?Ԥ=1\Rz{{]cDT^RYY)֤'v5Tj4TTO~ЈFmÇr)..v9sL0jdƧUR)رc|rLyJͩk18vzf4Թ^n-nNիWF^맞>}hMzi L;=Ξ=:3/EL555V Z=iX{]Ojܦɂ:҂Fyoݺ5&DSNZ4dW)"S)B Npwc_ϟh Z]ӡ Utr[h[[wB3) )TlnFgIw,/_45SuL3/H鉿њtvNOWj>>E]Q7z'4gE7[pe3cesv21F0SRGڃI/z9o)CCCzj;w|gFF s)O)Vkm P<`ڜ'M;)f 30S)f `0S) _}B`)86L` 0S.c &` 8686L` 0S]0s <}TJKK7ސ8Yzڵkڟ/&&&z;::7ߜ押O*rT`g} YYYgZntwwcLd{=aK." 5#gb3R*?1Qdٲ EvvGO,>yw0S`v2SboP6l ~YhTs G7}>S5}"pݐ!ޟ3f 0[35y㐙)۷o .L0ٱcѣGx0?~͛'}3]a}8wVaLfk(FJD=湄[[uL㍎=?ӧOy&+}رc ˩3FJ.gs޵K˒+?я9$fMDm޻@yGS)0S) ZcEO3ܹsCbǏJHf#/4}E3>6)@h/:[ͪRjFAZ#9y&Wj,԰۾,M3\03 86L` f .cLp /`w6C%IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYStepAreaRendererSample.png0000644000175000017500000002223511173030414025266 0ustar vincentvincentPNG  IHDRXr5$dIDATxqw񂈈 """ )%Im (!!%}ZlIlll !'1*4F{ mb Wzڐ~Os^2>沷w;ߝ*HWsU """BDDDD%"UWMCD`Ier 7L;}_L?|0g>OM/}iŋ;vX>}(}LGSOOOH>l_^UD%@?/kצn>iӦ466v<};!BʩS''xrswO/~}vp/~ٳgό_;SluR\gU"'믿NJMEǾ}.矐-[V 3?Og!L~8Ӿ~UxEw$cǎe>sAt.XAoo/*6\%_`Ie}ܷ]g9s&{]{T{O~2={x=ܹs}q*w]g>SڃmvzѺux\KW[ttz}dz`,`^{gjs}MO3$*xEI+OįJ6r3]1[agNj٣իWg`T{z0fhvE{Mgz뭙2Ǻy?mJ,O}3ub?}#^cǏ'lݹ,W7Cى<~[jz ,?!X󩿅G>τ_:/>%R' oÆ 3~… ٓp)6nVqX~ݺu'qjo*qy>^qh?G5 }@ӄ-8Eb}r0>uB6fW[dIۧ\=fR|Njw_߉K_<6Fqn,B8H}wކOw,V7ʹm۶LZ}ӟ4 >^4z/>Ç߉NKC8kS|`Bln٤ Dq~+_ikjW###]] gDmt7swc;;G؎PvYlw9ۙm{/zO?M`S bYokfE*:$=@/ oq $R<8c`կN[_eӬ;SbF[S8mӮ`?~6.u/Nj{g.6v1*YY:TWlݗ/6.B`4`ŜFD^/(N~YF]xFʕ+[zVfG==ϐũfEg;ptƬOi][붸^kFk]m>VNտVk?/+%4M 9:8EV,JiUFj..ڈӄv?We7x^ 1,mu]m>_9%N՛kw9 V%Kt.v yqJ\: Z]F]H64l/^N#.h`s~+m.։`v|>\~80~,g7KKH)(UV 2n){vx5u:W̶E騝%)m7"tr ј#uS~5ىPDenc>rvS3Xqz]3XBDVU{3TAhݡوA//fߏSf+ČWWN鍖#HqɂP;^eP>Ͷ^] N,[qi<~Qp|~vwǎFlG(rt9)XӖH"SDT"YE9] 'Td弘Faݻwvfg~wiŵ)~hv[Y/,K]tr 6Ccu2ۭ[5ߏ9RYMjvr,%K./W;񊟽WO0ZyRNJW!/1Ԟ-)oQwcB.*y|xx8^/3BUThy˯EWC>vn[Yb[ԛtv8WTo8.g+d{ ,*PED`,!X"KDDȕUEDD,%"""BDDDD`,%""""KDDD`{큁t7+WC jPWP<;s=7A jjPY]wE惗_~jPl5A T\W`A j XfgW,Ԡ3X:X _ jjPtR`ՠ5`rZ jjP`H&&&Ҷm… ӢEuԠ5X~5A :Xs#~x?Tuvl*/|]$c?;][%+N nܸ1t߲eK`%\zfѣGC=dK j Xh}A j0V^}tM7ӧOR`_P`8= 'N@5`,B `fW}A j XfԠ3XjP,,RԠ,te R}A j XfgW,`,5,,te *E  :XjP,` fj0E@t jP2,``y,`ٟՠEV,@tԠԠe 03X,ՠe_P,5`/A K˫5,`A :Xf,3X,ՠe_P\:}tڸqcXvm:u,5` `tMСCirr2ciŊ:XjPԠi2Moo,` `8p ڵ+=S魷J>lUNm`n۷/ǏWzkNU?nvWs?۟.񭒂R500IՒ9bw15` `vm7ޘo߾488hK j X054` f3XsH\!NFb}Ν4`A  :XjPVϤ)M,,5` `˕teV@` X:XjPԠusjP2e_P,ՠe_P,` `KA :Xg5`,ՠe˾5,,5`AK j2, bjP/A  @`Ԡ3X:X^A :Xg5`, ՠe_P,@`K j0ՠe_P@` X:XjPԠe9j5,`,5,,@` f3Xm.:XjPԠե9s&\ @`K j0խlٲ%=3:XjPԠՍ:u*}{k(V95_۷=gd> Gݾ8+/Xw_:rH={բ`_PV%+,qժU|'ts'`UR6nܘFGG j'X/A :Xo֬YS`yBw `UNҟg  jP֕r%wON; 5"X(^{h/ԠE``"X] 5`,s'@j'X/A :X N`"X(^{h/ԠE̝ X``v,tNԠEP̝`_@PjJ` jP"X0wB`_P`,xբ`_Pr@1w}"X`5`,;15"X(^{h/ԠE``"X] 5`,s'@W^i,}A jj'Nu֥ s'  266V\;  jPV7u /8Es' 5 VlٲL.\ a+V9Vnn۷=(Ǐ绋u;c;TykE틱?TR,XFFFdHvJׯ3XVmBR`u+V3gLW_M `ݻ7m۶mjjtt4m߾`Ԡ5<#ِ{ ٺp3X,Wr,5`, 5`,Rt`,@KD j X ,s3jP"X5`,O`fs5,fԠ3X ttNԠE3X,5A`,?j0E,5`,f"Xs,E25,@KA j X `f`霨A"SfԠ3Xs,,Rt`[z{{3̱cǎty:XjPV7r̙L6mTWrj3<<Wp|mOy;/wNNN>,Pe!XΝK\s I` srCG}`NO`tuץ;wz!(u.`}tZl:X)0FzzzZ^>Uq4<:>/-\0[q*mvj(vؿZfMVC|ɓ'+کۡ6nLe^jnvۡʼ?8q"[.ۧ}KYG,wN훺Eݺukj(#PvOUVUj;SCCҸ|nj(v/ 64]2?/ZCYC;UN eccciʕرc?[o59sfvt'-[V~@Moooel5l[tD}ݦYj `u;\ /Tj;6ԭVl%K;vϗn[fnjv.mUP4j?~]N e,WYC;5u; dE;ilՅOٌ ˏhӦMȑ#[ni:T0[ e_8{l%C+5u;~I+뵬ۡ4rUyu[`ivf+˼Vr`50pYsΦNZ!r…l`|``l5u;3l\Ief[tYe!XUM9mwG;tJ ֹs5\Seax2[ʼZۡFOdUf*ۡ~]sSYCvhgݖe;Xb\Uꫯ.v X-<~oϞ=;ĿlRja;OG}Ѧ*lvj(vXvmNX{/_n\C;5u;̶_Wyiʺf[*lvj(vum۶טoݾ}{8ص.fZ'-뮻.;Uvhn^Q<Ɛŋxvhnv nٖ ۡʼ?<#ِ{tC!X""""KDDD`!X""""KDDDD!X""""BDo~j5%>F'!X""-&>,>엿LJwa%i7!S/bvgnEDHpBHիW[9"BDD:ٳgӲe˲ 7ܐǭ!X""sI%"ҥawE`1wygֹo>rHv;/"BDDL~,CmߏEDH/4 !X""""KDDDD!X""""BDDDD%"""BDDDD\p#"KD.`m+"KDŶ!X" ,,amE`ض"KDŶ%r%wI<@ZpaKiϞ=m===]7L-j_m=ܛ~x{zfLj=p@̖%iK`H+-Y2`[.޽;MLL+d߻ i%ښV߬ N:CVPɖ%'HV"X"KD.XQvڕ6mڔ~f;>>>%Ann;/$V+ټgSrs'O~ZK`Hk͚5Kǎ!yǧn?_~y 5ŋ'Of&Xwy_R=SZ#YW`,`E%ꫯκ'ׯON[ti:wφ,sQEo7믿>hV;fvV*sGIr,%"`&:.1\$L:Ϋ֮]SOuM^_dZwнܹc"!X"Rbj]sC4Yj$~'[o&X~=m'=OUjS1ζ%"HZM.I b()޻woH\:v.t4Wa^ wSXѣGv ֡CInN\FqիSkͤ{_|X;6הf  ض"BDAض%"bۊ,qVD8۶"BDd^¸|%""""h(C5IENDB`libjfreechart-java-1.0.13.orig/docfiles/XYStepRendererSample.png0000644000175000017500000002420311173030414024472 0ustar vincentvincentPNG  IHDRXr5(JIDATx\w񂈈 R?D%dِZ[x4m~q4diwkji!61HBB*mKLhUmƆ ٤651~osﬓٙٙ9>lfLy3y Z<DDDDEDDD$`ED2E4ZxU7ޘ} _UO}_oO,X`kǏOwyg>>~hjkkK^}P)@?/ 6o5I<>ߟc[0MQ^tlC*axયY(O~򓱟ٽ{?9_3uPhdO|ODp߻w>#DnڴI,G?Ѹ.@?ٿ˿g?||Uvڶm[A+d8=C\[?qwMw* ??fLx7Qw3"T}?{.VM{쩹QT6`b}_O[n͂[~qSt~jmZuСgKT@KW+o߾qA"atqtTEtu]g3^ի2ssE$`lRsqZx˿vϩjYlf]gϗFV瞀EQ5"l=Hom0voo5ZZ?/|VZZZVL?nySʁ,dʀE$`u~k`U^+Ч^ jwqG](vj]s^nyEZ[2Z+SL1G4S~LʵD4:[*gRxaHYVUe(f•ݑZO.W^yq 1] o2~:b3-Tʸ|D|T>fZ>_y+3\tg37E'VӖۃd2E4͊EXybEXW?NEƯW|Xh׮]`3s?oa/c.cMu}}>:3qf7Vks*"R'Vz\K"(@7xLJƋϕŋ'⾢S%Jゝof՟5uJ+htq?qbDעZ#DƵ>jAXSY_#k_]ڌXZFE0BUb+8Ɋz_=nJ XD4͇H""H"",I1gSn"","""","""",""""H"""""Hxnwvv;sZvi?0``0`'CWW/NO<9  dw+`M;V'   V333_$| 0 ,3Xγc`0`0%c`0`,, 0X? t`9Gc VHںuk7o^?~z't0``0`|t.\H?xڹs,fff65YEת\iҥ:X0`~ 0`MVsIW}  9t[Gң,o?_صROϥeˠc3XӓݛbEzתV%7{pK 6>дL,cE]܎:y+W3-\8:xvm € duwK˖-€:X0`MVY*ܹs`1Y `MVO;wL=\z /y䑪rfR=444? XrQE^֭C|*}xv 6w5P ,3X6wVf3X:X>5P3,9j lj0X:X0@ ,3XX ` X> :Xj0Xf0`, ``yAD AKbf?j]  lj` ,mj 6w5€A s81$| t@0``1Y `5€:X0`HgϞM˗/7] `a`UڴiSzs~ci֡Ŭ.:C_PwӖ-i@ ftbŊrfVގ`/fGȚz=mgv?>!w|6dy{:X0`5HVr, NA  0jѣG] w tZ7|3[uصԁՀuZ?1x׮jXA"tڦj^W1$|:`:` `bs'jlK˻:x]Š%`9GmSQ3Xj0X:X޵:c,3XlSQVf3XoSQ,5P ,͝::` ``y]:c,3XlSQuPf3X]: , NA  0m*ju6V5`fK˻vA  0`rݦj^W1$|:`:` `2wlK˻A *,9j:Ru`KkWuPuA 8q"mܸ1uttd6NԁՀ 444/_?vuP :X͛/l C]_.TV~7Xz]]: 9,`9`-Y$ YNF`J.Woool|lMBf naOE?#VQXrQu뷿5~kΜ9i`` scr[iŊKY';:WڲeR VV"h€€ dlٲt٫>wM7€€ dgϞuֱG'xB  ֯TOfCqj0֕+W`13b6J> /`90` XQc`KR ,, 0``a5K3lK1`0Xf0``f0`0%c`cl,, 0X :Xfgǀ,3X0Xf ,f3X:Xޥ``c5 f,uA1`0Xf`11`5 `  _ ,3X,KǀAKR fjkkj3X0`~3X0B.€A: Xsf^ƶm˗u0``U~,`^n[ ~ p_PwӖ-V=={6 XUUο^4co?~Z&n z>'Pφ,`1u~ZY[]  _o+utN0\ "`E'Kk]x1|f93 Xi`` \Ezu0``0`&g}6uuu9s[o5ر"Āc Xp%wR0`~ 0X XqyUVe"dfffkҥYȊS{13UU:Xޥ``0`s=-Z%K^{mV,1`0kFGFF޽{-m.ǀUCW\I{I , XqSq=+3Xޥ``0`&e˖ ?SY'k;ώ, 0X. cA 0`*b:xusQfff Ǟu0``0`<; f0` ` X> , 333 X:Xޥ``0`,1`0t0``0``133%`y ,   w)0X? ,Y:t0``0`Z(ޛˀ<; f0` `.`:u*uuu{O  ֏kNk֬IΝn1`[Ҋ䣏5P__:-[`:s `A@M###gIV2,`13 Xܹsu0` VtѬe ًٻWg/hE v 0T+{MiʕUg"X\l*CCCz3q{pp돏%uq;P3^̘ZW耵cǎ5<<:X9[ҊY'ܙU-[t)a   yc(d:rȄ]+3X0`~ 0\+B€cA"dffYhKǀ`Agǀ1``KKǀ1`%`1333 X:X0`~ 0`rǀ,KǀA  ,3XlK˻  :Xs0€K  j 333$| t0`%`9G5]  ֏,3XlK1`0``a1``K˻  :X3335Vs7ǀVm:X0`~ 0`8hbfff3XA1`€֬ XJ.WooovV>L*},"Oԡ ǃxv<4{[Kǀ`A 3331`~ 0`2 ]u0`0`p,Wr.ǀ,`I0`P 0X XQc`  f,  j 3331`~ 0` XQcA 0` ``a1`e` X> :X0` `€` w)0X? t,ffffKǀ`A2<; ֏3X:X> :X0`,, 0X? t`9Gc %c0``133&5::{f)<<<ǀdk׮wޱ{I7o6ǀꮻJgϞ}̙d, 0X? t&q +?g`5>WϪ X]]]/fa+>nnvdY""""ʳr֬YΝ;w ֢ETjo޴i5Y5{Jf1333O fX 0X? _  ,"""|K"""",""""zU5^R" gZkٟ"hooOl C^o߾nݺ!BOOO:uT C^PC]S_akYW^ C'N7ft:XUTk׮wޱqQ͛7!oGIi`` ;8FFF3V\Yw~)u!u(n .0ׯfNy\Zf4Ѻc:̙3;wfydfCRyю;;)Ba{BW\;;; {d6[q?u,""""H"""""H""""H"""",""""/Ɵ֨3:>""A0Uo۶̓DDQ?aW^n <ED4 ]r%uvvtڵk˗=8D$`MV.\HK,:W/N"T XDD-Ra{{{6! XDDSߟu~_e>ݎ XDDMt,C XDD tѸh5H]h,""""H"""""H""""H"""","""",""""ZvpsMED XDDDs1!  XD6Q &JDDs,r]wI?ҼyR{{{Lwnz}mmm-=yd?~` ?㫯N3y{,ߟĚ|tH"7]v4::^sRPJRZ{␕Ǣc-gy&ZJ"hZowծ*7~5wl;w?=ixxx,{ic'_~,:2FDPDת!X&+>~,(` XD4k@5_֭KO=T:~pݜ~zK/y䑱qرqa,X :u*ג‡"׏EѣYWK"h:V ;XQMnʺ#===-Z.^8JsQtvm7M̓`n}VÇ+W"hV5Mr\Q9KA녊z?ifÆ [nI=\KV5tccǎt}^,"*P*)Be5T+T~1m+ݩˣR̅7Xĩts,"M4~K4s薄b@{Ϟ=o sGBEy-l E{,9Rk%` XDul;f[Z*#d,Q|}ڵ٩z_~Ϝy39;S!B(V}MB!`!BX!BB!B ?|sf@! z2NG??xի:sr/ G?R6lP{~~A_e/~QٳGݻw/5eڏ$__Q駟VSSSLX%C_~~.uJVڀx{7~7 _)1QX%C_W3NTR~<m޼!U\<;wϪd!`!8Wޓ 1WR8U3`]v󾾦F;߾}__O5`i}ΐ__uiPf~~+zk׮XO夸~zKKuvvUzԣ>~K_E't$ |T; yW~>ggM_d{YbCbOOBI?nbo˨+d_'˫H|:??9dV'F֯_݁@<?BB)t?+DOa'~9{:;;y8ooZ*aؑ#G ˿,h8,m%,%` V>9{DTlْ3fy! kdd$DpɒV/^p!%UZ3N J5Bw=,%0*![* ҷ: XRyWX Em]lqG? ' ێ~蓊m˿ `!v_E Cr(K'`]xQ[>l9yR ,;#{|dÇ#/]/KU.&Ӷ,`_| s .k=AB(:-`N|Q'(/D9qO=PO^%O{$'XW(ۺTq%}NA'׶ z?qD^X}iYTօ*tJeAK~2f铧4{_((o%lkkk ' \jc>C,b`]WhbzЉyƍz)uΝKfy_8L ֥o]>'`QBB*W%1A+k $ȺQW jU-,=Ϲs޽bH?_8WȾ$`.ޯ|8߃%KErH z'Aٳg kyئ̌T d&v_He,W{~LpV gA+fڱcO XaK=(b! XAk V:k(-Rq`i54KGX'\XR} $,+lk}G$3dHJNRmɽ|2I>dX"/JȐa1螟Bu)_}J'8QKWdw%wyJB!BB!B!`!B! !BB!B!B!`!BX!BB!B!,B!+7񸣣C=裩 6q q(M6XQk?A*?$b!- (Q,_OfGzwX}88J `m۶-5;aa3Ky %߯@sT[lQQ"b!- rBjjj\jhhHGFFT__ԔZvx"=X qo=X@˫6533>VMMMZgΜ'b!- ⠂`dPV\;|HaaZ5>>@ڿ265O[k=MC>+WRI;wվUUK\]]=XA,EBN`v5;;уښџ%Zj=XA,Es>~}{M><=X63s;}``P`aaX)Y6i=X,]!lݻw;M24(@88طXb6Ž7g8K ^\=qEKAN ,Eaa`у`Q"b!- quT^oS{VSd|ƙ706C,XXzsV߃>ܑ#],*X\=G$*`=zԭdiחEaYo+uI,z`q-q9!++XI,*X`1OOq9!+{{=8?qzf2z`qD8X+80%J3D;mm 4*X`aaXj7at30. WO\qbIlÇuħ|,z'8KbXQ},z`q-q9!ccVpV,z0 0bVMMM,  Xdi-,*X!U__5d}+V8Fݳgw=XA,ER*.i.@V`T&T~i#Xi${O[k=TC_r%A>}˽y_/>~G.d}W^qҏs?q_UUK 0 *ʦ Vp`9U:jooW=X޹sG=`qT},IG,zBkxxؙ9E٩ǝʕ,w^zX}8> +k3oQvW`уeX\Cu,iV} _P/"X}8%`UzQr,EaaV̀E"J+Z rR!xS'OZ˥|]Jۭ7.Z]T! dqKk(M ˦X>|9cH;X= ,*X\Re  'V9c =XaXj+ ժ(}ϯ-U r0 =Mz)JR `%`уE/q *ʷUX,z`qEK8X #6*q̴-B$Tflq{+P0 Xt-q K+XqV9s")=`Q d8I,_@.xhښ XIa,*X\9!b`+jwXw)ä>Ww~6q`l9YUO?`Q 0 +oV܀e:q8I,X-UrB[a'$V9 ,( ^E=qKAqxO~$V9 j1H,hU,LX`уat\p,Y ^yD{,z`qEK8"8Nȹ|է^bY:|YJ»Bs3ExxiCCCoiiIn{1USSCq qoY,O k==0…,*fƠռj;=X1IHWCCCjtt}<222^#uּ q qKyMtkL];pyU9dH*`3lA V"U0hy֦fffӪ}|uiy'O,z0 ÒUT2"F,Uk^уUb2>*looWR"b!tV)O,4i׾5599ySO9c: s֭TCOMMb8_>u*2`-9sypCuϻXa'ʰi\_&y瓪`yz`U.rZE<=XKaӖ,ؐ.'nnYЅ3s;7EBR^. '\K2\敘T'*Xe];uBuXXB{Nȥ6uXɝ+Z   `q/B ðJ+dK3X=XT%b!b)eM, V=XA,Q ==MOzH-|Y~݀`X`XTX}+%؏#\XڷŚWTªǜ ƶnv>z,*XqKi2rBiΝÁ--e\U- ,z/Ii,rBI瞋 ?[ǎ`}; =XT:E8kĦeyR֭oH쿗?v{{ ~C,|TRj, efXvW,*X\SEUX;a `ᣂ`уUqnz՝V '`XMӿܺGp :OPU(/H `I^"Ae ,+a=XorwĎ~+4V1'7 =XV*XI, Tطgދ:ۅ_v 2w'cI1X`уNU`_9>99};х gx}+!8 =XV+XC y/8) ]IT[Һo%bkt'qBG Kh!÷UwwHbssssRN׫.u`%GVMw/´VץɒXуBqͫ!5::>Q}ݲ:;;abj TL3tNzל!JT̼1 ==zj*Xa+;SϼkyM}D+15,|1`ᣂ`|1y#XiN {|{nwʲ~w,ޣ|Omgk|R"4_I|y|9|!^bzvLy͔YFnoR,*V#Y2M⁏ VWlFVccceFaE$tOԡ0JBIRYQKԓo'rVg$;T@|҃` ;3{{{7oެ.^T>3K^HBΝY՜/9+8dLӂW9sSRm%9S.ǓP (,|TZ\Cu-e9zjg;w^\ M ;mmY@ _rY&9)'` Ni0dquͫJ@i}$޲:XUS7n+`tN5TqBN `U%UTc+XaD `O*X¥FmK_26XnWQ =XwW†|+݃.j$l"CH!㸡*,+K"`%iadq~+v2ygkutN?u$5NӨ}a]*kl+XT), ,+倕d_%w/+ vBd8f]ɪj qV,+AeRk0[** 9䫇w)ٔoDI;#jStqTL;U `EbK.DL^ `ᣂ`GVK*l@$ oߪfSN|KXL돚ϸ) rMV Ǩ`E'Z =XVwAJV\w\zB.p`+XVi'-}GLX>*XV\=j__VñJqJ9sfVšדXqMO"`Mdd?K񣞞XoULуjԗ6.J[+T I,`pJߎ+RCYۯ{Q,\c2 ij:.tt}h5ulҤkZv@A\G*t6?_x! + J`bzL808! b]+2j\8 Xai`zB[ݽTȨ3E,WO`yIQ.DX U,+yJXaD ` *R';gVJ ܀G *ty-tfMb&I,oZXYޙQ0sVP?F9` aCM4&80?ʷ㭎V7j ℌ `꭭V)fFR.ʗvG}aC֬D:צy$ϲs7`% {,+oNbz(-&`$qЌLS'd|T,+Xs\ NX2. 3,dc444dTvIlnnyW_UXuuujʕk . ]>ut;3Uy5xddD9wvvqK/q{h<.WQkf˖YXYf =XU4D6533> USSSWXa=`[Պ2 >`볆 > F2Z%p`1%jd?_d|>|OV=KnK)W~: w )u|O'k8>OI{ǯo?/U󮌍O<g޽cY|NMM y\_|Qm۶m~Oc+UXp@R"|`Q2V{{jllt UJ{ic\},9v agwaoosBVi}r7JbQǁ1>zLw\`cy f1>*X,1>r, #`XŁہ ,1>rL>`X:v,kx1EGc|`X>1>, ǁ9Gу`EGc|T, 9v ,|c|, f|9Gŗ9&1>*X3>rOz,|c|,/->9Gу`X80#1`#*А[ZZR$X80#Tjjj\jhhHGFFT___,|c|lz`yɫ6533>VMMMq`G`XT__5dX80#1+2STKJr$X׉ӏ/u|^r?c{^՛ϩ) }L >|c|lzlzJXjvv6ǁ9Gg:{j-Y>1>rL>كMmmڻww^,4x][+}>1>,+Kѣΐ,pyVrǁ9GуU@?UQq`Gc|TF^ǁ9GуU,9rd9!qq`Gc|T Ukko>dX1>9GVU.`#566lc;c|`Y`#`X>r@у`X80#1`#c;c|, ǁ9G'=X>1>r ŗ/2>r q`G`Qq`Gc|`X|c|,KKh!÷UwwHbsssX80#`U=`ԸАu,|c|l*XT=XTJXc| 򨽽]fY566>`c;8xP]1onJ5<< }ǁ9vM`ٲLwǁ9G,zXf|9`X|icrK`у`#,/f|9Nܑ#sYs?G]s٣Gk1qHŗہ#TUsR 3>r[ X>~}c+E3>r[ XA`G1>r/E3>r3ŮܙQq`G" O{у`#ǩچAd`#V%U-=X>1>rl%`E5*X_Z|lrW/?q`GdH4ޙ{[ǎMMCzZxg&Rq`G0ghR6E3>rX1-..rJР#=`c;$μZOO,EVv/'~bb}~~^ڵK߿?9 f|!NĒʔWsss%9 f|!ؘ\f X`V---eBq`G*vT)4+YyK:VSϟw!*s~,I8cy޽ygZhׯyl+W{+cclNpspMMMwxх 'PwS^[ndo8I3{oojnn} >|c|VVT*d8 V:w9 9G1i7~o_,EVtZLy=`#19nutYw,*X% uvvX80# 7]Պ{J`;>1>r`X80#αa2qV#M\Vb2d`X8#cf = />rʍ^TSCԭMb`b`X8#UQKf *{A*X/>rd*0 9bߛ'N-]>q UB`X8#)F%_.[җ8U`X>N1k%/E qGϓkp412;uUEr E`#q˿dA>=J^p   g+V}8U*Xf|(eut(e Ӫo ,||=qm7nM-`IodQ`䋏+0X5?P} 0z,||c|EVV6V9`X8#UXkygkd,||c~*_&8wey*XT,5Uy t--N̻ =XP+WT jpp}nzzZm_ۼyq/>rlO!v#р* bg z{Ψ`Q*v/lj׮]ju_1ءCTkk+/>rl zVƍ9׼J*`ӗ_kQ+jܜjiiq~sʫ+VX8#ǖ- LV.+`^`fAW_uYGn޼N/J籽yO X mmY/IvuVIwHl8uյ:XZϟwKjƍT=cJ?'|B  |8$,*XV 8 TI{oojnnvkooWW^u_+ Ivx '_|J0`y ^;}xHΝSV`䋏X=plDY6r 2႗H[Շ %t3sPgɲ 2L(_|Qm۶ 9N'􂝶iYn"Á uvvɌC&bу/>rl/ՒaC[ +;>Nȱ4X`X>Nq|2g*XT`Xqլ̷߯. \fh`X8#EtvqT`Q,||c +>ޥn%z,U1w׌`e)po},uGcrC8`XVJ}A' &BU0z, `XBu^3*!ÆTK `X8{߾KvWCmlt~}T`C`XOHfX~ ˧>_ZBT, `X1у`<0MND ixECE`5ޡ@mQa*8h~18`X79p"ZEJ+`c>A`X`X_RF3ͭ[, ,˞[v^eer ,,o.l JoW_wdYʎ=_)g2/`Q-E,VY+,V_аI Y)DN XNLL1>BN,Gj``@\R544AUb2I4OT Q+UYj * yk.~kgffڵk+XTA `%ra`a=XTS---Ǐ'X/c&Yߥ*Xc +Cjii)WWW7nGyb=XQن+;X6,?`]޻7A.( ?5FdX=XTWWuzΟ?og}V>}:K)W~:GcyޅS'N+ccS~ޣ̧N|z:y\_oחߓ?50`C z<񄺵 {8'gyǯwga-l yO;Z[zy/$5d{{D,_ʕ+Vđ|bJ`ɐ働@40`ssskd#AV%Ãbjrr29]|9qt`lTd»'6~8 ?LAiZ *}-ð&sgUb!*X_m`~衬a\BOȦ-iZ9NV^JVX Xr1`p`pҟgTg0z| >aMIBr]Md(U>e8qFFb,=*k=EX Uŀ%W֦+nLK?N,pB!`%mhV<Ւ\crs܀UHRE=XVKL*Z=][؍8!r-6^b% X7f EE8`X%,nz-v-`t=u^I%NsY|zgzҀZU `ڎa=XV NXUM'8]Xɺ*[|+XqAܜq"`R}ZB,A+рsbWm4U.Y2IoV+W{e|4PP`C,AV'Pʙc6Pڼ$kݤ$V&2XEbj)k[V~cZBTN*XTK Vk۶mV+/˸x2xg[m,`|ᅌkկfUK}~|;45#~ɷr1bL*Sz ,b!*X)J3`W/N1VTVw/UCԙ L$V!C,A,+sjJ] rSKIzqZ%BTɊY;T3+rIr܀e`P * UBЍwfSh)ZLVU%iOnvSUkHlTJjŚj ,z*pEeJ{_ ~ȼ%Y qZ}MX qЃE+ƃpV详lެ>޺5kVbFi;Z `Q"⠂EVjNdn~ ~Lw5> JZrjhhPONN-[zǨ`ųwꌣ nþE,Alڽ j׮]j㩩)vZuŪ2r ?o_o5`1_qT `o}'z#Zy577ZZZԙ3gR׃%[{I.ocN+$;žE,AUKKK:gSSY2|(ÃS%f{Vԡ-)-S*6a=X%TWWuzΟ?eP^o+m!B)!/O'k+Nuw8{<69+OgE'þʕ+VQ36fo?D/KaJ`IEJ@HJ*U,4|܃U"Q*XHaH\7f +Xz͸)"8LGΝSﭭjff&UVY߃Ud1QNb"b!'V.]֭[###JfqHKd*bbN&x}b|oDaI, 0'tֽ/ CBT&$4sT=qN>ط8`q/T5'' 'B`q/B*X\=qEKBN ,+M=X>k^aaE WEBTJX;uLӓAB, q qo, 0 Uq  'T,zXXX E'b! 'BT0 0,*X:q q q 9bX}88UWOABN =XaaVAi&0 0 r0B!TAX!BB!XIOaaX,b!b!b!b!'Tؑr qoB!T]B!,B! !BJTv]Y!^}Uuuujʕ===m],RNK]~}رcKo٘Ieg1jn>6oެnܸaeNsuWrUu544FGG###Ϛp5N5>>E饗?n],8[ZZ[nlݰ{255֮].^̌m[Nwjmm2'wVj׮]jRȹqU`9_nISSuqw4ĵbŊTbsR}⧟~K.)99s&DZ^uqbJUʏTrš\{:Eel,+)T^{5g8ޮfgg1b[Nzb>ڳgwuqȁ_ Kpܶm;a]y+-PKѣ͛ɓjǎV椶6  mG=;,m+^[9ӧO{1]1})׾5ںժO?m]rˉ]zl?w}KjƍT K?'|beNd_2ٷd; X6ŒϹqQUQW6Dzd8r5"+s44%^KRzXEm̉sD#mnn.*X !TM,fjBO[I8ͱܹsG=!~ѪU·uc2l;wΙag[, W3s@K~rlKAcmEi,/Ϝ,ȥa_c6)p%'{Zo2^OLTz-D2LoҥK IݦaS, `YVZI˺8^*vNSӲ9r3l#Cl_J/7Rؒah[-\|c_I>ĤK`٘iC,?X !BrX!BB!B!`!B! !BB!B!B!`!BX!d_չ܆$3B%,E! !p/BBċB"8!`!EX7@O>QV\ƍp&x>C`!,PrK=`k˖-jhhH-..%{9JJ`MB֊+ O?zzz͹駟5kָs̙AR&G- !`!o>u,Вw]ovϻロC޳zjuu:tBXtTVZTԍ7՝;w (?ǹ/~QۑcBBJJK/z\1Y.K.͛7ѣBBXQg$=R"8gVhݼySX! !d`#1Ĥj۶msҬ>220 , zfIcBXTؘ.WRvgJ߰a3 r7uٜ`ebBB "^BB",A! !,B%j3B!*(O9MIENDB`libjfreechart-java-1.0.13.orig/experimental/0000755000175000017500000000000011173030414020643 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/0000755000175000017500000000000011173030414021432 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/0000755000175000017500000000000011173030414022525 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/0000755000175000017500000000000011173030414025222 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/0000755000175000017500000000000011173030414026323 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/annotations/0000755000175000017500000000000011173030414030660 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/annotations/junit/0000755000175000017500000000000011173030414032011 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/axis/0000755000175000017500000000000011173030414027267 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/demo/0000755000175000017500000000000011216245561027260 5ustar vincentvincent././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDemo1.javalibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDe0000644000175000017500000001655711173030414033536 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CombinedCategoryPlotDemo1.java * ------------------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 05-May-2008 : Version 1 (DG); * */ package org.jfree.experimental.chart.demo; import java.awt.Font; import javax.swing.JPanel; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.experimental.chart.plot.CombinedCategoryPlot; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; /** * A demo for the {@link CombinedCategoryPlot} class. */ public class CombinedCategoryPlotDemo1 extends ApplicationFrame { /** * Creates a new demo instance. * * @param title the frame title. */ public CombinedCategoryPlotDemo1(String title) { super(title); JPanel chartPanel = createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } /** * Creates a dataset. * * @return A dataset. */ public static CategoryDataset createDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); String series1 = "First"; String series2 = "Second"; String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(1.0, series1, type1); result.addValue(4.0, series1, type2); result.addValue(3.0, series1, type3); result.addValue(5.0, series1, type4); result.addValue(5.0, series1, type5); result.addValue(7.0, series1, type6); result.addValue(7.0, series1, type7); result.addValue(8.0, series1, type8); result.addValue(5.0, series2, type1); result.addValue(7.0, series2, type2); result.addValue(6.0, series2, type3); result.addValue(8.0, series2, type4); result.addValue(4.0, series2, type5); result.addValue(4.0, series2, type6); result.addValue(2.0, series2, type7); result.addValue(1.0, series2, type8); return result; } /** * Creates a dataset. * * @return A dataset. */ public static CategoryDataset createDataset2() { DefaultCategoryDataset result = new DefaultCategoryDataset(); String series1 = "Third"; String series2 = "Fourth"; String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(11.0, series1, type1); result.addValue(14.0, series1, type2); result.addValue(13.0, series1, type3); result.addValue(15.0, series1, type4); result.addValue(15.0, series1, type5); result.addValue(17.0, series1, type6); result.addValue(17.0, series1, type7); result.addValue(18.0, series1, type8); result.addValue(15.0, series2, type1); result.addValue(17.0, series2, type2); result.addValue(16.0, series2, type3); result.addValue(18.0, series2, type4); result.addValue(14.0, series2, type5); result.addValue(14.0, series2, type6); result.addValue(12.0, series2, type7); result.addValue(11.0, series2, type8); return result; } /** * Creates a chart. * * @return A chart. */ private static JFreeChart createChart() { CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Value"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(); NumberAxis rangeAxis2 = new NumberAxis("Value"); rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer2 = new BarRenderer(); renderer2.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2); subplot2.setDomainGridlinesVisible(true); CategoryAxis domainAxis = new CategoryAxis("Category"); CombinedCategoryPlot plot = new CombinedCategoryPlot( domainAxis, new NumberAxis("Range")); plot.add(subplot1, 2); plot.add(subplot2, 1); JFreeChart result = new JFreeChart( "Combined Domain Category Plot Demo", new Font("SansSerif", Font.BOLD, 12), plot, true); return result; } /** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createChart(); return new ChartPanel(chart); } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { String title = "Combined Category Plot Demo 1"; CombinedCategoryPlotDemo1 demo = new CombinedCategoryPlotDemo1(title); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.javalibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.ja0000644000175000017500000002343311173030414033316 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CombinedXYPlotDemo1.java * ------------------------ * (C) Copyright 2008, 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 05-May-2008 : Version 1 (DG); * */ package org.jfree.experimental.chart.demo; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import javax.swing.JPanel; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.LegendTitle; import org.jfree.data.time.Month; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.experimental.chart.plot.CombinedXYPlot; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; /** * A demonstration application showing a {@link CombinedXYPlot} with * two subplots. */ public class CombinedXYPlotDemo1 extends ApplicationFrame { /** * Constructs a new demonstration application. * * @param title the frame title. */ public CombinedXYPlotDemo1(String title) { super(title); JPanel panel = createDemoPanel(); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); } /** * Creates an overlaid chart. * * @return The chart. */ private static JFreeChart createCombinedChart() { // create plot ... IntervalXYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); renderer1.setSeriesStroke(0, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer1.setSeriesPaint(0, Color.blue); DateAxis domainAxis = new DateAxis("Year"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.02); ValueAxis rangeAxis = new NumberAxis("$billion"); XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1); plot1.setBackgroundPaint(Color.lightGray); plot1.setDomainGridlinePaint(Color.white); plot1.setRangeGridlinePaint(Color.white); // add a second dataset and renderer... IntervalXYDataset data2 = createDataset2(); XYBarRenderer renderer2 = new XYBarRenderer() { public Paint getItemPaint(int series, int item) { XYDataset dataset = getPlot().getDataset(); if (dataset.getYValue(series, item) >= 0.0) { return Color.red; } else { return Color.green; } } }; renderer2.setSeriesPaint(0, Color.red); renderer2.setDrawBarOutline(false); renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"), renderer2); plot2.setBackgroundPaint(Color.lightGray); plot2.setDomainGridlinePaint(Color.white); plot2.setRangeGridlinePaint(Color.white); CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis); cplot.add(plot1, 3); cplot.add(plot2, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1", JFreeChart.DEFAULT_TITLE_FONT, cplot, false); chart.setBackgroundPaint(Color.white); LegendTitle legend = new LegendTitle(cplot); chart.addSubtitle(legend); return chart; } /** * Creates a sample dataset. You wouldn't normally hard-code the * population of a dataset in this way (it would be better to read the * values from a file or a database query), but for a self-contained demo * this is the least complicated solution. * * @return The dataset. */ private static IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1"); series1.add(new Month(1, 2005), 7627.743); series1.add(new Month(2, 2005), 7713.138); series1.add(new Month(3, 2005), 6776.939); series1.add(new Month(4, 2005), 5764.537); series1.add(new Month(5, 2005), 4777.880); series1.add(new Month(6, 2005), 4836.496); series1.add(new Month(7, 2005), 3887.618); series1.add(new Month(8, 2005), 3926.933); series1.add(new Month(9, 2005), 4932.710); series1.add(new Month(10, 2005), 4027.123); series1.add(new Month(11, 2005), 8092.322); series1.add(new Month(12, 2005), 8170.414); series1.add(new Month(1, 2006), 8196.070); series1.add(new Month(2, 2006), 8269.886); series1.add(new Month(3, 2006), 5371.156); series1.add(new Month(4, 2006), 5355.718); series1.add(new Month(5, 2006), 5356.777); series1.add(new Month(6, 2006), 8420.042); series1.add(new Month(7, 2006), 8444.347); series1.add(new Month(8, 2006), 8515.034); series1.add(new Month(9, 2006), 8506.974); series1.add(new Month(10, 2006), 8584.329); series1.add(new Month(11, 2006), 8633.246); series1.add(new Month(12, 2006), 8680.224); series1.add(new Month(1, 2007), 8707.561); return new TimeSeriesCollection(series1); } /** * Creates a sample dataset. You wouldn't normally hard-code the * population of a dataset in this way (it would be better to read the * values from a file or a database query), but for a self-contained demo * this is the least complicated solution. * * @return A sample dataset. */ private static IntervalXYDataset createDataset2() { TimeSeriesCollection dataset = new TimeSeriesCollection(); TimeSeries series1 = new TimeSeries("Series 2"); series1.add(new Month(1, 2005), 1200); series1.add(new Month(2, 2005), 1400); series1.add(new Month(3, 2005), 1500); series1.add(new Month(4, 2005), 1700); series1.add(new Month(5, 2005), 1600); series1.add(new Month(6, 2005), 2400); series1.add(new Month(7, 2005), 2100); series1.add(new Month(8, 2005), 2200); series1.add(new Month(9, 2005), 800); series1.add(new Month(10, 2005), 2350); series1.add(new Month(11, 2005), 500); series1.add(new Month(12, 2005), 700); series1.add(new Month(1, 2006), 900); series1.add(new Month(2, 2006), 1500); series1.add(new Month(3, 2006), 2100); series1.add(new Month(4, 2006), 2200); series1.add(new Month(5, 2006), 1900); series1.add(new Month(6, 2006), 3000); series1.add(new Month(7, 2006), 3780); series1.add(new Month(8, 2006), 4000); series1.add(new Month(9, 2006), 4500); series1.add(new Month(10, 2006), 7000); series1.add(new Month(11, 2006), 5500); series1.add(new Month(12, 2006), 6000); series1.add(new Month(1, 2007), 6500); dataset.addSeries(series1); return dataset; } /** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createCombinedChart(); return new ChartPanel(chart); } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { CombinedXYPlotDemo1 demo = new CombinedXYPlotDemo1( "JFreeChart : CombinedXYPlotDemo1"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } } libjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/plot/0000755000175000017500000000000011216245561027312 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/plot/dial/0000755000175000017500000000000011173030414030212 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/plot/dial/junit/0000755000175000017500000000000011173030414031343 5ustar vincentvincent././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.javalibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.j0000644000175000017500000001012111173030414033524 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CombinedCategoryPlot.java * ------------------------- * (C) Copyright 2008, by Richard West and Contributors. * * Original Author: Richard West, Advanced Micro Devices, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 02-Feb-2007 : Version 1, contributed by Richard West - see * patch 1924543 (DG); * */ package org.jfree.experimental.chart.plot; import java.util.Iterator; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.CombinedDomainCategoryPlot; import org.jfree.data.Range; /** * A specialised form of {@link CombinedDomainCategoryPlot} where the * subplots share not only the same x-axis, but also the same y-axis. */ public class CombinedCategoryPlot extends CombinedDomainCategoryPlot { /** * Creates a new instance with the specified axes. * * @param domainAxis the x-axis. * @param rangeAxis the y-axis. */ public CombinedCategoryPlot (CategoryAxis domainAxis, ValueAxis rangeAxis) { super(domainAxis); super.setGap(10.0); super.setRangeAxis(rangeAxis); } /** * Adds a new subplot with weight 1. * * @param subplot the subplot. */ public void add(CategoryPlot subplot) { this.add(subplot, 1); } /** * Adds a new subplot with the specified weight. * * @param subplot the subplot. * @param weight the weight for the subplot. */ public void add(CategoryPlot subplot, int weight) { super.add(subplot, weight); ValueAxis l_range = super.getRangeAxis(); subplot.setRangeAxis(0, l_range, false); super.setRangeAxis(l_range); if (null == l_range) { return; } l_range.configure(); } /** * Returns the bounds of the data values that will be plotted against * the specified axis. * * @param axis the axis. * * @return The bounds. */ public Range getDataRange(ValueAxis axis) { Range l_result = null; Iterator l_itr = getSubplots().iterator(); while (l_itr.hasNext()) { CategoryPlot l_subplot = (CategoryPlot) l_itr.next(); l_result = Range.combine(l_result, l_subplot.getDataRange(axis)); } return l_result; } /** * Sets the range axis that is shared by all the subplots. * * @param axis the axis. */ public void setRangeAxis(ValueAxis axis) { Iterator l_itr = getSubplots().iterator(); while (l_itr.hasNext()) { CategoryPlot l_subplot = (CategoryPlot) l_itr.next(); l_subplot.setRangeAxis(0, axis, false); } super.setRangeAxis(axis); if (null == axis) { return; } axis.configure(); } } libjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/plot/CombinedXYPlot.java0000644000175000017500000001000711173030414033002 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CombinedXYPlot.java * ------------------- * (C) Copyright 2008, by Richard West and Contributors. * * Original Author: Richard West, Advanced Micro Devices, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-May-2008 : Version 1, contributed by Richard West - see * patch 1924543 (DG); * */ package org.jfree.experimental.chart.plot; import java.util.Iterator; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CombinedDomainCategoryPlot; import org.jfree.chart.plot.CombinedDomainXYPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; /** * A specialised form of {@link CombinedDomainCategoryPlot} where the * subplots share not only the same x-axis, but also the same y-axis. */ public class CombinedXYPlot extends CombinedDomainXYPlot { /** * Creates a new instance with the specified axes. * * @param domainAxis the x-axis. * @param rangeAxis the y-axis. */ public CombinedXYPlot(ValueAxis domainAxis, ValueAxis rangeAxis) { super(domainAxis); super.setGap(10.0); super.setRangeAxis(rangeAxis); } /** * Adds a new subplot with weight 1. * * @param subplot the subplot. */ public void add(XYPlot subplot) { this.add(subplot, 1); } /** * Adds a new subplot with the specified weight. * * @param subplot the subplot. * @param weight the weight for the subplot. */ public void add(XYPlot subplot, int weight) { super.add(subplot, weight); ValueAxis l_range = super.getRangeAxis(); subplot.setRangeAxis(0, l_range, false); super.setRangeAxis(l_range); if (null == l_range) { return; } l_range.configure(); } /** * Returns the bounds of the data values that will be plotted against * the specified axis. * * @param axis the axis. * * @return The bounds. */ public Range getDataRange(ValueAxis axis) { Range l_result = null; Iterator l_itr = getSubplots().iterator(); while (l_itr.hasNext()) { XYPlot l_subplot = (XYPlot) l_itr.next(); l_result = Range.combine(l_result, l_subplot.getDataRange(axis)); } return l_result; } /** * Sets the range axis that is shared by all the subplots. * * @param axis the axis. */ public void setRangeAxis(ValueAxis axis) { Iterator l_itr = getSubplots().iterator(); while (l_itr.hasNext()) { XYPlot l_subplot = (XYPlot) l_itr.next(); l_subplot.setRangeAxis(0, axis, false); } super.setRangeAxis(axis); if (null == axis) { return; } axis.configure(); } } libjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/renderer/0000755000175000017500000000000011173030414030131 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/renderer/junit/0000755000175000017500000000000011173030414031262 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/renderer/xy/0000755000175000017500000000000011216245561030602 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/renderer/xy/junit/0000755000175000017500000000000011173030414031722 5ustar vincentvincent././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/renderer/xy/XYSmoothLineAndShapeRenderer.javalibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/renderer/xy/XYSmoothLineAnd0000644000175000017500000002604411173030414033507 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * XYSmoothLineAndShapeRenderer.java * --------------------------------- * (C) Copyright 2007, by Object Refinery Limited and Contributors. * * Original Author: -; * Contributor(s): -; * * Changes * ------- * 14-Jun-2007 : Version 1; * */ package org.jfree.experimental.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRendererState; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; /** * A line and shape renderer that performs line smoothing. See * http://www.jfree.org/phpBB2/viewtopic.php?t=20671 * * WARNING: THIS CLASS IS NOT PART OF THE STANDARD JFREECHART API AND IS * SUBJECT TO ALTERATION OR REMOVAL. DO NOT RELY ON THIS CLASS FOR * PRODUCTION USE. Please experiment with this code and provide feedback. */ public class XYSmoothLineAndShapeRenderer extends XYLineAndShapeRenderer { /** * Draws the item (first pass). This method draws the lines * connecting the items. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). */ protected void drawPrimaryLine(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { if (item == 0) { return; } // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1) || Double.isNaN(x1)) { return; } double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); if (Double.isNaN(y0) || Double.isNaN(x0)) { return; } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } Point2D.Double point0 = new Point2D.Double(); Point2D.Double point1 = new Point2D.Double(); Point2D.Double point2 = new Point2D.Double(); Point2D.Double point3 = new Point2D.Double(); if (item == 1) { point0 = null; } else { point0.x = domainAxis.valueToJava2D(dataset.getXValue(series, item - 2), dataArea, xAxisLocation); point0.y = rangeAxis.valueToJava2D(dataset.getYValue(series, item - 2), dataArea, yAxisLocation); } point1.x = transX0; point1.y = transY0; point2.x = transX1; point2.y = transY1; if ((item + 1) == dataset.getItemCount(series)) { point3 = null; } else { point3.x = domainAxis.valueToJava2D(dataset.getXValue(series, item + 1), dataArea, xAxisLocation); point3.y = rangeAxis.valueToJava2D(dataset.getYValue(series, item + 1), dataArea, yAxisLocation); } int steps = ((int) ((point2.x - point1.x) / 0.2) < 30) ? (int) ((point2.x - point1.x) / 0.2) : 30; Point2D.Double[] points = getBezierCurve(point0, point1, point2, point3, 1, steps); for (int i = 1; i < points.length; i++) { transX0 = points[i - 1].x; transY0 = points[i - 1].y; transX1 = points[i].x; transY1 = points[i].y; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } if (state.workingLine.intersects(dataArea)) { drawFirstPassShape(g2, pass, series, item, state.workingLine); } } } /** * Draws the item shapes and adds chart entities (second pass). This method * draws the shapes which mark the item positions. If entities * is not null it will be populated with entity information * for points that fall within the data area. * * @param g2 the graphics device. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param dataArea the area within which the data is being drawn. * @param rangeAxis the range axis. * @param dataset the dataset. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState the crosshair state. * @param entities the entity collection. */ protected void drawSecondaryPass(Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, Rectangle2D dataArea, ValueAxis rangeAxis, CrosshairState crosshairState, EntityCollection entities) { // super.drawSecondaryPass(g2, plot, dataset, pass, series, item, // domainAxis, dataArea, rangeAxis, crosshairState, entities); } /** * Updates the control points. * * @param point0 * @param point1 * @param point2 * @param point3 * @param control1 * @param control2 * @param smooth */ public static void getControlPoints(Point2D.Double point0, Point2D.Double point1, Point2D.Double point2, Point2D.Double point3, Point2D.Double control1, Point2D.Double control2, double smooth) { // Reference: http://www.antigrain.com/research/bezier_interpolation/ if (point0 == null) point0 = point1; //new Point2D.Double(0, 0); if (point3 == null) point3 = point2; //new Point2D.Double(0, 0); Point2D.Double c1 = new Point2D.Double( (point0.x + point1.x) / 2.0, (point0.y + point1.y) / 2.0); Point2D.Double c2 = new Point2D.Double( (point1.x + point2.x) / 2.0, (point1.y + point2.y) / 2.0); Point2D.Double c3 = new Point2D.Double( (point2.x + point3.x) / 2.0, (point2.y + point3.y) / 2.0); double len1 = point1.distance(point0); double len2 = point2.distance(point1); double len3 = point3.distance(point2); double k1 = len1 / (len1 + len2); double k2 = len2 / (len2 + len3); Point2D.Double m1 = new Point2D.Double( c1.x + (c2.x - c1.x) * k1, c1.y + (c2.y - c1.y) * k1); Point2D.Double m2 = new Point2D.Double( c2.x + (c3.x - c2.x) * k2, c2.y + (c3.y - c2.y) * k2); control1.setLocation(new Point2D.Double( m1.x + (c2.x - m1.x) * smooth + point1.x - m1.x, m1.y + (c2.y - m1.y) * smooth + point1.y - m1.y)); control2.setLocation(new Point2D.Double( m2.x + (c2.x - m2.x) * smooth + point2.x - m2.x, m2.y + (c2.y - m2.y) * smooth + point2.y - m2.y)); } /** * Returns the points for a bezier curve. * * @param point0 * @param point1 * @param point2 * @param point3 * @param smooth * @param steps * * @return The curve points. */ public static Point2D.Double[] getBezierCurve(Point2D.Double point0, Point2D.Double point1, Point2D.Double point2, Point2D.Double point3, double smooth, int steps) { Point2D.Double control1 = new Point2D.Double(); Point2D.Double control2 = new Point2D.Double(); getControlPoints(point0, point1, point2, point3, control1, control2, smooth); Point2D.Double C = new Point2D.Double( 3 * (control1.x - point1.x), 3 * (control1.y - point1.y)); Point2D.Double B = new Point2D.Double(3 * (control2.x - control1.x) - C.x, 3 * (control2.y - control1.y) - C.y); Point2D.Double A = new Point2D.Double(point2.x - point1.x - C.x - B.x, point2.y - point1.y - C.y - B.y); Point2D.Double[] res = new Point2D.Double[steps + 1]; double stepSize = 1.0 / steps; double step = stepSize; res[0] = point1; for (int i = 1; i < steps; i++) { res[i] = new Point2D.Double(A.x * Math.pow(step, 3) + B.x * Math.pow(step, 2) + C.x * step + point1.x, A.y * Math.pow(step, 3) + B.y * Math.pow(step, 2) + C.y * step + point1.y); //System.out.println(step + " : " + res[i]); step += stepSize; } res[steps] = point2; return res; } } libjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/title/0000755000175000017500000000000011173030414027444 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/title/junit/0000755000175000017500000000000011173030414030575 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/chart/util/0000755000175000017500000000000011173030414027300 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/data/0000755000175000017500000000000011173030414026133 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/data/xy/0000755000175000017500000000000011173030414026573 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/data/xy/junit/0000755000175000017500000000000011173030414027724 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/experimental/org/jfree/experimental/swt/0000755000175000017500000000000011173030414026037 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/lib/0000755000175000017500000000000011216245561016725 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/0000755000175000017500000000000011216245562017460 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/0000755000175000017500000000000011173030414020235 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/0000755000175000017500000000000011173030414021330 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/0000755000175000017500000000000011216245561022442 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/0000755000175000017500000000000011216245561024777 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/AbstractXYAnnotation.java0000644000175000017500000001461111173030414031713 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * AbstractXYAnnotation.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 29-Sep-2004 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Mar-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.XYAnnotationEntity; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.util.ObjectUtilities; /** * The interface that must be supported by annotations that are to be added to * an {@link XYPlot}. */ public abstract class AbstractXYAnnotation implements XYAnnotation { /** The tool tip text. */ private String toolTipText; /** The URL. */ private String url; /** * Creates a new instance that has no tool tip or URL specified. */ protected AbstractXYAnnotation() { this.toolTipText = null; this.url = null; } /** * Returns the tool tip text for the annotation. This will be displayed in * a {@link org.jfree.chart.ChartPanel} when the mouse pointer hovers over * the annotation. * * @return The tool tip text (possibly null). * * @see #setToolTipText(String) */ public String getToolTipText() { return this.toolTipText; } /** * Sets the tool tip text for the annotation. * * @param text the tool tip text (null permitted). * * @see #getToolTipText() */ public void setToolTipText(String text) { this.toolTipText = text; } /** * Returns the URL for the annotation. This URL will be used to provide * hyperlinks when an HTML image map is created for the chart. * * @return The URL (possibly null). * * @see #setURL(String) */ public String getURL() { return this.url; } /** * Sets the URL for the annotation. * * @param url the URL (null permitted). * * @see #getURL() */ public void setURL(String url) { this.url = url; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public abstract void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info); /** * A utility method for adding an {@link XYAnnotationEntity} to * a {@link PlotRenderingInfo} instance. * * @param info the plot rendering info (null permitted). * @param hotspot the hotspot area. * @param rendererIndex the renderer index. * @param toolTipText the tool tip text. * @param urlText the URL text. */ protected void addEntity(PlotRenderingInfo info, Shape hotspot, int rendererIndex, String toolTipText, String urlText) { if (info == null) { return; } EntityCollection entities = info.getOwner().getEntityCollection(); if (entities == null) { return; } XYAnnotationEntity entity = new XYAnnotationEntity(hotspot, rendererIndex, toolTipText, urlText); entities.add(entity); } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractXYAnnotation)) { return false; } AbstractXYAnnotation that = (AbstractXYAnnotation) obj; if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { return false; } if (!ObjectUtilities.equal(this.url, that.url)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; if (this.toolTipText != null) { result = 37 * result + this.toolTipText.hashCode(); } if (this.url != null) { result = 37 * result + this.url.hashCode(); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/CategoryAnnotation.java0000644000175000017500000000456411173030414031452 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * CategoryAnnotation.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Apr-2003 : Version 1 (DG); * 02-Jul-2003 : Eliminated Annotation base interface (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; /** * The interface that must be supported by annotations that are to be added to * a {@link org.jfree.chart.plot.CategoryPlot}. */ public interface CategoryAnnotation { /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. */ public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/CategoryLineAnnotation.java0000644000175000017500000003276311173030414032264 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryLineAnnotation.java * --------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 29-Jul-2005 : Version 1, based on CategoryTextAnnotation (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Mar-2007 : Reimplemented hashCode() (DG); * 23-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.CategoryAnchor; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A line annotation that can be placed on a {@link CategoryPlot}. */ public class CategoryLineAnnotation implements CategoryAnnotation, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 3477740483341587984L; /** The category for the start of the line. */ private Comparable category1; /** The value for the start of the line. */ private double value1; /** The category for the end of the line. */ private Comparable category2; /** The value for the end of the line. */ private double value2; /** The line color. */ private transient Paint paint = Color.black; /** The line stroke. */ private transient Stroke stroke = new BasicStroke(1.0f); /** * Creates a new annotation that draws a line between (category1, value1) * and (category2, value2). * * @param category1 the category (null not permitted). * @param value1 the value. * @param category2 the category (null not permitted). * @param value2 the value. * @param paint the line color (null not permitted). * @param stroke the line stroke (null not permitted). */ public CategoryLineAnnotation(Comparable category1, double value1, Comparable category2, double value2, Paint paint, Stroke stroke) { if (category1 == null) { throw new IllegalArgumentException("Null 'category1' argument."); } if (category2 == null) { throw new IllegalArgumentException("Null 'category2' argument."); } if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.category1 = category1; this.value1 = value1; this.category2 = category2; this.value2 = value2; this.paint = paint; this.stroke = stroke; } /** * Returns the category for the start of the line. * * @return The category for the start of the line (never null). * * @see #setCategory1(Comparable) */ public Comparable getCategory1() { return this.category1; } /** * Sets the category for the start of the line. * * @param category the category (null not permitted). * * @see #getCategory1() */ public void setCategory1(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.category1 = category; } /** * Returns the y-value for the start of the line. * * @return The y-value for the start of the line. * * @see #setValue1(double) */ public double getValue1() { return this.value1; } /** * Sets the y-value for the start of the line. * * @param value the value. * * @see #getValue1() */ public void setValue1(double value) { this.value1 = value; } /** * Returns the category for the end of the line. * * @return The category for the end of the line (never null). * * @see #setCategory2(Comparable) */ public Comparable getCategory2() { return this.category2; } /** * Sets the category for the end of the line. * * @param category the category (null not permitted). * * @see #getCategory2() */ public void setCategory2(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.category2 = category; } /** * Returns the y-value for the end of the line. * * @return The y-value for the end of the line. * * @see #setValue2(double) */ public double getValue2() { return this.value2; } /** * Sets the y-value for the end of the line. * * @param value the value. * * @see #getValue2() */ public void setValue2(double value) { this.value2 = value; } /** * Returns the paint used to draw the connecting line. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint used to draw the connecting line. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; } /** * Returns the stroke used to draw the connecting line. * * @return The stroke (never null). * * @see #setStroke(Stroke) */ public Stroke getStroke() { return this.stroke; } /** * Sets the stroke used to draw the connecting line. * * @param stroke the stroke (null not permitted). * * @see #getStroke() */ public void setStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.stroke = stroke; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. */ public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) { CategoryDataset dataset = plot.getDataset(); int catIndex1 = dataset.getColumnIndex(this.category1); int catIndex2 = dataset.getColumnIndex(this.category2); int catCount = dataset.getColumnCount(); double lineX1 = 0.0f; double lineY1 = 0.0f; double lineX2 = 0.0f; double lineY2 = 0.0f; PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); if (orientation == PlotOrientation.HORIZONTAL) { lineY1 = domainAxis.getCategoryJava2DCoordinate( CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea, domainEdge); lineX1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge); lineY2 = domainAxis.getCategoryJava2DCoordinate( CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea, domainEdge); lineX2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge); } else if (orientation == PlotOrientation.VERTICAL) { lineX1 = domainAxis.getCategoryJava2DCoordinate( CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea, domainEdge); lineY1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge); lineX2 = domainAxis.getCategoryJava2DCoordinate( CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea, domainEdge); lineY2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge); } g2.setPaint(this.paint); g2.setStroke(this.stroke); g2.drawLine((int) lineX1, (int) lineY1, (int) lineX2, (int) lineY2); } /** * Tests this object for equality with another. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryLineAnnotation)) { return false; } CategoryLineAnnotation that = (CategoryLineAnnotation) obj; if (!this.category1.equals(that.getCategory1())) { return false; } if (this.value1 != that.getValue1()) { return false; } if (!this.category2.equals(that.getCategory2())) { return false; } if (this.value2 != that.getValue2()) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * result + this.category1.hashCode(); long temp = Double.doubleToLongBits(this.value1); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + this.category2.hashCode(); temp = Double.doubleToLongBits(this.value2); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); result = 37 * result + this.stroke.hashCode(); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.stroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/CategoryPointerAnnotation.java0000644000175000017500000004044711173030414033013 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CategoryPointerAnnotation.java * ------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Oct-2006 : Version 1 (DG); * 06-Mar-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An arrow and label that can be placed on a {@link CategoryPlot}. The arrow * is drawn at a user-definable angle so that it points towards the (category, * value) location for the annotation. *

* The arrow length (and its offset from the (category, value) location) is * controlled by the tip radius and the base radius attributes. Imagine two * circles around the (category, value) coordinate: the inner circle defined by * the tip radius, and the outer circle defined by the base radius. Now, draw * the arrow starting at some point on the outer circle (the point is * determined by the angle), with the arrow tip being drawn at a corresponding * point on the inner circle. * * @since 1.0.3 */ public class CategoryPointerAnnotation extends CategoryTextAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4031161445009858551L; /** The default tip radius (in Java2D units). */ public static final double DEFAULT_TIP_RADIUS = 10.0; /** The default base radius (in Java2D units). */ public static final double DEFAULT_BASE_RADIUS = 30.0; /** The default label offset (in Java2D units). */ public static final double DEFAULT_LABEL_OFFSET = 3.0; /** The default arrow length (in Java2D units). */ public static final double DEFAULT_ARROW_LENGTH = 5.0; /** The default arrow width (in Java2D units). */ public static final double DEFAULT_ARROW_WIDTH = 3.0; /** The angle of the arrow's line (in radians). */ private double angle; /** * The radius from the (x, y) point to the tip of the arrow (in Java2D * units). */ private double tipRadius; /** * The radius from the (x, y) point to the start of the arrow line (in * Java2D units). */ private double baseRadius; /** The length of the arrow head (in Java2D units). */ private double arrowLength; /** The arrow width (in Java2D units, per side). */ private double arrowWidth; /** The arrow stroke. */ private transient Stroke arrowStroke; /** The arrow paint. */ private transient Paint arrowPaint; /** The radius from the base point to the anchor point for the label. */ private double labelOffset; /** * Creates a new label and arrow annotation. * * @param label the label (null permitted). * @param key the category key. * @param value the y-value (measured against the chart's range axis). * @param angle the angle of the arrow's line (in radians). */ public CategoryPointerAnnotation(String label, Comparable key, double value, double angle) { super(label, key, value); this.angle = angle; this.tipRadius = DEFAULT_TIP_RADIUS; this.baseRadius = DEFAULT_BASE_RADIUS; this.arrowLength = DEFAULT_ARROW_LENGTH; this.arrowWidth = DEFAULT_ARROW_WIDTH; this.labelOffset = DEFAULT_LABEL_OFFSET; this.arrowStroke = new BasicStroke(1.0f); this.arrowPaint = Color.black; } /** * Returns the angle of the arrow. * * @return The angle (in radians). * * @see #setAngle(double) */ public double getAngle() { return this.angle; } /** * Sets the angle of the arrow. * * @param angle the angle (in radians). * * @see #getAngle() */ public void setAngle(double angle) { this.angle = angle; } /** * Returns the tip radius. * * @return The tip radius (in Java2D units). * * @see #setTipRadius(double) */ public double getTipRadius() { return this.tipRadius; } /** * Sets the tip radius. * * @param radius the radius (in Java2D units). * * @see #getTipRadius() */ public void setTipRadius(double radius) { this.tipRadius = radius; } /** * Returns the base radius. * * @return The base radius (in Java2D units). * * @see #setBaseRadius(double) */ public double getBaseRadius() { return this.baseRadius; } /** * Sets the base radius. * * @param radius the radius (in Java2D units). * * @see #getBaseRadius() */ public void setBaseRadius(double radius) { this.baseRadius = radius; } /** * Returns the label offset. * * @return The label offset (in Java2D units). * * @see #setLabelOffset(double) */ public double getLabelOffset() { return this.labelOffset; } /** * Sets the label offset (from the arrow base, continuing in a straight * line, in Java2D units). * * @param offset the offset (in Java2D units). * * @see #getLabelOffset() */ public void setLabelOffset(double offset) { this.labelOffset = offset; } /** * Returns the arrow length. * * @return The arrow length. * * @see #setArrowLength(double) */ public double getArrowLength() { return this.arrowLength; } /** * Sets the arrow length. * * @param length the length. * * @see #getArrowLength() */ public void setArrowLength(double length) { this.arrowLength = length; } /** * Returns the arrow width. * * @return The arrow width (in Java2D units). * * @see #setArrowWidth(double) */ public double getArrowWidth() { return this.arrowWidth; } /** * Sets the arrow width. * * @param width the width (in Java2D units). * * @see #getArrowWidth() */ public void setArrowWidth(double width) { this.arrowWidth = width; } /** * Returns the stroke used to draw the arrow line. * * @return The arrow stroke (never null). * * @see #setArrowStroke(Stroke) */ public Stroke getArrowStroke() { return this.arrowStroke; } /** * Sets the stroke used to draw the arrow line. * * @param stroke the stroke (null not permitted). * * @see #getArrowStroke() */ public void setArrowStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' not permitted."); } this.arrowStroke = stroke; } /** * Returns the paint used for the arrow. * * @return The arrow paint (never null). * * @see #setArrowPaint(Paint) */ public Paint getArrowPaint() { return this.arrowPaint; } /** * Sets the paint used for the arrow. * * @param paint the arrow paint (null not permitted). * * @see #getArrowPaint() */ public void setArrowPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.arrowPaint = paint; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. */ public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); CategoryDataset dataset = plot.getDataset(); int catIndex = dataset.getColumnIndex(getCategory()); int catCount = dataset.getColumnCount(); double j2DX = domainAxis.getCategoryMiddle(catIndex, catCount, dataArea, domainEdge); double j2DY = rangeAxis.valueToJava2D(getValue(), dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { double temp = j2DX; j2DX = j2DY; j2DY = temp; } double startX = j2DX + Math.cos(this.angle) * this.baseRadius; double startY = j2DY + Math.sin(this.angle) * this.baseRadius; double endX = j2DX + Math.cos(this.angle) * this.tipRadius; double endY = j2DY + Math.sin(this.angle) * this.tipRadius; double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength; double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength; double arrowLeftX = arrowBaseX + Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth; double arrowLeftY = arrowBaseY + Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth; double arrowRightX = arrowBaseX - Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth; double arrowRightY = arrowBaseY - Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth; GeneralPath arrow = new GeneralPath(); arrow.moveTo((float) endX, (float) endY); arrow.lineTo((float) arrowLeftX, (float) arrowLeftY); arrow.lineTo((float) arrowRightX, (float) arrowRightY); arrow.closePath(); g2.setStroke(this.arrowStroke); g2.setPaint(this.arrowPaint); Line2D line = new Line2D.Double(startX, startY, endX, endY); g2.draw(line); g2.fill(arrow); // draw the label g2.setFont(getFont()); g2.setPaint(getPaint()); double labelX = j2DX + Math.cos(this.angle) * (this.baseRadius + this.labelOffset); double labelY = j2DY + Math.sin(this.angle) * (this.baseRadius + this.labelOffset); /* Rectangle2D hotspot = */ TextUtilities.drawAlignedString(getText(), g2, (float) labelX, (float) labelY, getTextAnchor()); // TODO: implement the entity for the annotation } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryPointerAnnotation)) { return false; } if (!super.equals(obj)) { return false; } CategoryPointerAnnotation that = (CategoryPointerAnnotation) obj; if (this.angle != that.angle) { return false; } if (this.tipRadius != that.tipRadius) { return false; } if (this.baseRadius != that.baseRadius) { return false; } if (this.arrowLength != that.arrowLength) { return false; } if (this.arrowWidth != that.arrowWidth) { return false; } if (!this.arrowPaint.equals(that.arrowPaint)) { return false; } if (!ObjectUtilities.equal(this.arrowStroke, that.arrowStroke)) { return false; } if (this.labelOffset != that.labelOffset) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.angle); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.tipRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.baseRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.arrowLength); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.arrowWidth); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + HashUtilities.hashCodeForPaint(this.arrowPaint); result = 37 * result + this.arrowStroke.hashCode(); temp = Double.doubleToLongBits(this.labelOffset); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.arrowPaint, stream); SerialUtilities.writeStroke(this.arrowStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.arrowPaint = SerialUtilities.readPaint(stream); this.arrowStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/CategoryTextAnnotation.java0000644000175000017500000002171411173030414032313 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryTextAnnotation.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Apr-2003 : Version 1 (DG); * 02-Jul-2003 : Added new text alignment and rotation options (DG); * 04-Jul-2003 : Added a category anchor option (DG); * 19-Aug-2003 : Added equals() method and implemented Cloneable (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities * --> TextUtilities (DG); * ------------- JFREECHART 1.0.x ------------------------------------------- * 06-Mar-2007 : Implemented hashCode() (DG); * 23-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.CategoryAnchor; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A text annotation that can be placed on a {@link CategoryPlot}. */ public class CategoryTextAnnotation extends TextAnnotation implements CategoryAnnotation, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3333360090781320147L; /** The category. */ private Comparable category; /** The category anchor (START, MIDDLE, or END). */ private CategoryAnchor categoryAnchor; /** The value. */ private double value; /** * Creates a new annotation to be displayed at the given location. * * @param text the text (null not permitted). * @param category the category (null not permitted). * @param value the value. */ public CategoryTextAnnotation(String text, Comparable category, double value) { super(text); if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.category = category; this.value = value; this.categoryAnchor = CategoryAnchor.MIDDLE; } /** * Returns the category. * * @return The category (never null). * * @see #setCategory(Comparable) */ public Comparable getCategory() { return this.category; } /** * Sets the category that the annotation attaches to. * * @param category the category (null not permitted). * * @see #getCategory() */ public void setCategory(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.category = category; } /** * Returns the category anchor point. * * @return The category anchor point. * * @see #setCategoryAnchor(CategoryAnchor) */ public CategoryAnchor getCategoryAnchor() { return this.categoryAnchor; } /** * Sets the category anchor point. * * @param anchor the anchor point (null not permitted). * * @see #getCategoryAnchor() */ public void setCategoryAnchor(CategoryAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.categoryAnchor = anchor; } /** * Returns the value that the annotation attaches to. * * @return The value. * * @see #setValue(double) */ public double getValue() { return this.value; } /** * Sets the value. * * @param value the value. * * @see #getValue() */ public void setValue(double value) { this.value = value; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. */ public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) { CategoryDataset dataset = plot.getDataset(); int catIndex = dataset.getColumnIndex(this.category); int catCount = dataset.getColumnCount(); float anchorX = 0.0f; float anchorY = 0.0f; PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); if (orientation == PlotOrientation.HORIZONTAL) { anchorY = (float) domainAxis.getCategoryJava2DCoordinate( this.categoryAnchor, catIndex, catCount, dataArea, domainEdge); anchorX = (float) rangeAxis.valueToJava2D(this.value, dataArea, rangeEdge); } else if (orientation == PlotOrientation.VERTICAL) { anchorX = (float) domainAxis.getCategoryJava2DCoordinate( this.categoryAnchor, catIndex, catCount, dataArea, domainEdge); anchorY = (float) rangeAxis.valueToJava2D(this.value, dataArea, rangeEdge); } g2.setFont(getFont()); g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); } /** * Tests this object for equality with another. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryTextAnnotation)) { return false; } CategoryTextAnnotation that = (CategoryTextAnnotation) obj; if (!super.equals(obj)) { return false; } if (!this.category.equals(that.getCategory())) { return false; } if (!this.categoryAnchor.equals(that.getCategoryAnchor())) { return false; } if (this.value != that.getValue()) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = 37 * result + this.category.hashCode(); result = 37 * result + this.categoryAnchor.hashCode(); long temp = Double.doubleToLongBits(this.value); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/TextAnnotation.java0000644000175000017500000002461011173030414030613 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * TextAnnotation.java * ------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Aug-2002 : Version 1 (DG); * 07-Nov-2002 : Fixed errors reported by Checkstyle, added accessor * methods (DG); * 13-Jan-2003 : Reviewed Javadocs (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 02-Jun-2003 : Added anchor and rotation settings (DG); * 19-Aug-2003 : Added equals() method and implemented Cloneable (DG); * 29-Sep-2004 : Updated equals() method (DG); * 06-Jun-2005 : Fixed equals() method to work with GradientPaint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 16-Jan-2007 : Added argument checks, fixed hashCode() method and updated * API docs (DG); * */ package org.jfree.chart.annotations; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A base class for text annotations. This class records the content but not * the location of the annotation. */ public class TextAnnotation implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7008912287533127432L; /** The default font. */ public static final Font DEFAULT_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default paint. */ public static final Paint DEFAULT_PAINT = Color.black; /** The default text anchor. */ public static final TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.CENTER; /** The default rotation anchor. */ public static final TextAnchor DEFAULT_ROTATION_ANCHOR = TextAnchor.CENTER; /** The default rotation angle. */ public static final double DEFAULT_ROTATION_ANGLE = 0.0; /** The text. */ private String text; /** The font. */ private Font font; /** The paint. */ private transient Paint paint; /** The text anchor. */ private TextAnchor textAnchor; /** The rotation anchor. */ private TextAnchor rotationAnchor; /** The rotation angle. */ private double rotationAngle; /** * Creates a text annotation with default settings. * * @param text the text (null not permitted). */ protected TextAnnotation(String text) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } this.text = text; this.font = DEFAULT_FONT; this.paint = DEFAULT_PAINT; this.textAnchor = DEFAULT_TEXT_ANCHOR; this.rotationAnchor = DEFAULT_ROTATION_ANCHOR; this.rotationAngle = DEFAULT_ROTATION_ANGLE; } /** * Returns the text for the annotation. * * @return The text (never null). * * @see #setText(String) */ public String getText() { return this.text; } /** * Sets the text for the annotation. * * @param text the text (null not permitted). * * @see #getText() */ public void setText(String text) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } this.text = text; } /** * Returns the font for the annotation. * * @return The font (never null). * * @see #setFont(Font) */ public Font getFont() { return this.font; } /** * Sets the font for the annotation. * * @param font the font (null not permitted). * * @see #getFont() */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.font = font; } /** * Returns the paint for the annotation. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint for the annotation. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; } /** * Returns the text anchor. * * @return The text anchor. * * @see #setTextAnchor(TextAnchor) */ public TextAnchor getTextAnchor() { return this.textAnchor; } /** * Sets the text anchor (the point on the text bounding rectangle that is * aligned to the (x, y) coordinate of the annotation). * * @param anchor the anchor point (null not permitted). * * @see #getTextAnchor() */ public void setTextAnchor(TextAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.textAnchor = anchor; } /** * Returns the rotation anchor. * * @return The rotation anchor point (never null). * * @see #setRotationAnchor(TextAnchor) */ public TextAnchor getRotationAnchor() { return this.rotationAnchor; } /** * Sets the rotation anchor point. * * @param anchor the anchor (null not permitted). * * @see #getRotationAnchor() */ public void setRotationAnchor(TextAnchor anchor) { this.rotationAnchor = anchor; } /** * Returns the rotation angle in radians. * * @return The rotation angle. * * @see #setRotationAngle(double) */ public double getRotationAngle() { return this.rotationAngle; } /** * Sets the rotation angle. The angle is measured clockwise in radians. * * @param angle the angle (in radians). * * @see #getRotationAngle() */ public void setRotationAngle(double angle) { this.rotationAngle = angle; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } // now try to reject equality... if (!(obj instanceof TextAnnotation)) { return false; } TextAnnotation that = (TextAnnotation) obj; if (!ObjectUtilities.equal(this.text, that.getText())) { return false; } if (!ObjectUtilities.equal(this.font, that.getFont())) { return false; } if (!PaintUtilities.equal(this.paint, that.getPaint())) { return false; } if (!ObjectUtilities.equal(this.textAnchor, that.getTextAnchor())) { return false; } if (!ObjectUtilities.equal(this.rotationAnchor, that.getRotationAnchor())) { return false; } if (this.rotationAngle != that.getRotationAngle()) { return false; } // seem to be the same... return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * result + this.font.hashCode(); result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); result = 37 * result + this.rotationAnchor.hashCode(); long temp = Double.doubleToLongBits(this.rotationAngle); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + this.text.hashCode(); result = 37 * result + this.textAnchor.hashCode(); return result; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYAnnotation.java0000644000175000017500000000554111173030414030231 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * XYAnnotation.java * ----------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Aug-2002 : Version 1 (DG); * 07-Nov-2002 : Fixed errors reported by Checkstyle (DG); * 13-Jan-2003 : Reviewed Javadocs (DG); * 09-May-2003 : Added plot to draw() method (DG); * 02-Jul-2003 : Eliminated the Annotation base interface (DG); * 29-Sep-2004 : Added 'rendererIndex' and 'info' parameter to draw() method * to support chart entities (tool tips etc) (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; /** * The interface that must be supported by annotations that are to be added to * an {@link XYPlot}. */ public interface XYAnnotation { /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info an optional info object that will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYAnnotationBoundsInfo.java0000644000175000017500000000462311173030414032220 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XYAnnotationBoundsInfo.java * --------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 10-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.annotations; import org.jfree.data.Range; /** * An interface that supplies information about the bounds of the annotation. * * @since 1.0.13 */ public interface XYAnnotationBoundsInfo { /** * Returns a flag that determines whether or not the annotation's * bounds should be taken into account for auto-range calculations on * the axes that the annotation is plotted against. * * @return A boolean. */ public boolean getIncludeInDataBounds(); /** * Returns the range of x-values (in data space) that the annotation * uses. * * @return The x-range. */ public Range getXRange(); /** * Returns the range of y-values (in data space) that the annotation * uses. * * @return The y-range. */ public Range getYRange(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYBoxAnnotation.java0000644000175000017500000002545311173030414030706 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYBoxAnnotation.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jan-2005 : Version 1 (DG); * 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A box annotation that can be placed on an {@link XYPlot}. The * box coordinates are specified in data space. */ public class XYBoxAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 6764703772526757457L; /** The lower x-coordinate. */ private double x0; /** The lower y-coordinate. */ private double y0; /** The upper x-coordinate. */ private double x1; /** The upper y-coordinate. */ private double y1; /** The stroke used to draw the box outline. */ private transient Stroke stroke; /** The paint used to draw the box outline. */ private transient Paint outlinePaint; /** The paint used to fill the box. */ private transient Paint fillPaint; /** * Creates a new annotation (where, by default, the box is drawn * with a black outline). * * @param x0 the lower x-coordinate of the box (in data space). * @param y0 the lower y-coordinate of the box (in data space). * @param x1 the upper x-coordinate of the box (in data space). * @param y1 the upper y-coordinate of the box (in data space). */ public XYBoxAnnotation(double x0, double y0, double x1, double y1) { this(x0, y0, x1, y1, new BasicStroke(1.0f), Color.black); } /** * Creates a new annotation where the box is drawn as an outline using * the specified stroke and outlinePaint. * * @param x0 the lower x-coordinate of the box (in data space). * @param y0 the lower y-coordinate of the box (in data space). * @param x1 the upper x-coordinate of the box (in data space). * @param y1 the upper y-coordinate of the box (in data space). * @param stroke the shape stroke (null permitted). * @param outlinePaint the shape color (null permitted). */ public XYBoxAnnotation(double x0, double y0, double x1, double y1, Stroke stroke, Paint outlinePaint) { this(x0, y0, x1, y1, stroke, outlinePaint, null); } /** * Creates a new annotation. * * @param x0 the lower x-coordinate of the box (in data space). * @param y0 the lower y-coordinate of the box (in data space). * @param x1 the upper x-coordinate of the box (in data space). * @param y1 the upper y-coordinate of the box (in data space). * @param stroke the shape stroke (null permitted). * @param outlinePaint the shape color (null permitted). * @param fillPaint the paint used to fill the shape (null * permitted). */ public XYBoxAnnotation(double x0, double y0, double x1, double y1, Stroke stroke, Paint outlinePaint, Paint fillPaint) { this.x0 = x0; this.y0 = y0; this.x1 = x1; this.y1 = y1; this.stroke = stroke; this.outlinePaint = outlinePaint; this.fillPaint = fillPaint; } /** * Draws the annotation. This method is usually called by the * {@link XYPlot} class, you shouldn't need to call it directly. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info the plot rendering info. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); double transX0 = domainAxis.valueToJava2D(this.x0, dataArea, domainEdge); double transY0 = rangeAxis.valueToJava2D(this.y0, dataArea, rangeEdge); double transX1 = domainAxis.valueToJava2D(this.x1, dataArea, domainEdge); double transY1 = rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge); Rectangle2D box = null; if (orientation == PlotOrientation.HORIZONTAL) { box = new Rectangle2D.Double(transY0, transX1, transY1 - transY0, transX0 - transX1); } else if (orientation == PlotOrientation.VERTICAL) { box = new Rectangle2D.Double(transX0, transY1, transX1 - transX0, transY0 - transY1); } if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(box); } if (this.stroke != null && this.outlinePaint != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.stroke); g2.draw(box); } addEntity(info, box, rendererIndex, getToolTipText(), getURL()); } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } // now try to reject equality if (!super.equals(obj)) { return false; } if (!(obj instanceof XYBoxAnnotation)) { return false; } XYBoxAnnotation that = (XYBoxAnnotation) obj; if (!(this.x0 == that.x0)) { return false; } if (!(this.y0 == that.y0)) { return false; } if (!(this.x1 == that.x1)) { return false; } if (!(this.y1 == that.y1)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } // seem to be the same return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; long temp; temp = Double.doubleToLongBits(this.x0); result = (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.x1); result = 29 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y0); result = 29 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y1); result = 29 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class, but may be * by subclasses. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream (null not permitted). * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.stroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writePaint(this.fillPaint, stream); } /** * Provides serialization support. * * @param stream the input stream (null not permitted). * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.stroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.fillPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYDataImageAnnotation.java0000644000175000017500000002654211173030414031772 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYDataImageAnnotation.java * -------------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 17-Sep-2008 : Version 1, based on XYImageAnnotation (DG); * 10-Mar-2009 : Implemented XYAnnotationBoundsInfo (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.Image; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An annotation that allows an image to be placed within a rectangle specified * in data coordinates on an {@link XYPlot}. Note that this annotation * is not currently serializable, so don't use it if you plan on serializing * your chart(s). * * @since 1.0.11 */ public class XYDataImageAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, XYAnnotationBoundsInfo { /** The image. */ private transient Image image; /** * The x-coordinate (in data space). */ private double x; /** * The y-coordinate (in data space). */ private double y; /** * The image display area width in data coordinates. */ private double w; /** * The image display area height in data coordinates. */ private double h; /** * A flag indicating whether or not the annotation should contribute to * the data range for a plot/renderer. * * @since 1.0.13 */ private boolean includeInDataBounds; /** * Creates a new annotation to be displayed within the specified rectangle. * * @param image the image (null not permitted). * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). * @param w the image display area width. * @param h the image display area height. */ public XYDataImageAnnotation(Image image, double x, double y, double w, double h) { this(image, x, y, w, h, false); } /** * Creates a new annotation to be displayed within the specified rectangle. * * @param image the image (null not permitted). * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). * @param w the image display area width. * @param h the image display area height. * @param includeInDataBounds a flag that controls whether or not the * annotation is included in the data bounds for the axis autoRange. * * @since 1.0.13 */ public XYDataImageAnnotation(Image image, double x, double y, double w, double h, boolean includeInDataBounds) { if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } this.image = image; this.x = x; this.y = y; this.w = w; this.h = h; this.includeInDataBounds = includeInDataBounds; } /** * Returns the image for the annotation. * * @return The image. */ public Image getImage() { return this.image; } /** * Returns the x-coordinate (in data space) for the annotation. * * @return The x-coordinate. */ public double getX() { return this.x; } /** * Returns the y-coordinate (in data space) for the annotation. * * @return The y-coordinate. */ public double getY() { return this.y; } /** * Returns the width (in data space) of the data rectangle into which the * image will be drawn. * * @return The width. */ public double getWidth() { return this.w; } /** * Returns the height (in data space) of the data rectangle into which the * image will be drawn. * * @return The height. */ public double getHeight() { return this.h; } /** * Returns the flag that controls whether or not the annotation should * contribute to the autoRange for the axis it is plotted against. * * @return A boolean. * * @since 1.0.13 */ public boolean getIncludeInDataBounds() { return this.includeInDataBounds; } /** * Returns the x-range for the annotation. * * @return The range. * * @since 1.0.13 */ public Range getXRange() { return new Range(this.x, this.x + this.w); } /** * Returns the y-range for the annotation. * * @return The range. * * @since 1.0.13 */ public Range getYRange() { return new Range(this.y, this.y + this.h); } /** * Draws the annotation. This method is called by the drawing code in the * {@link XYPlot} class, you don't normally need to call this method * directly. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); AxisLocation xAxisLocation = plot.getDomainAxisLocation(); AxisLocation yAxisLocation = plot.getRangeAxisLocation(); RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation, orientation); RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation, orientation); float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge); float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge); float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w, dataArea, xEdge); float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h, dataArea, yEdge); float xx0 = 0.0f; float yy0 = 0.0f; float xx1 = 0.0f; float yy1 = 0.0f; if (orientation == PlotOrientation.HORIZONTAL) { xx0 = j2DY0; xx1 = j2DY1; yy0 = j2DX0; yy1 = j2DX1; } else if (orientation == PlotOrientation.VERTICAL) { xx0 = j2DX0; xx1 = j2DX1; yy0 = j2DY0; yy1 = j2DY1; } // TODO: rotate the image when drawn with horizontal orientation? g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1), (int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null); String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, new Rectangle2D.Float(xx0, yy0, (xx1 - xx0), (yy1 - yy0)), rendererIndex, toolTip, url); } } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } // now try to reject equality... if (!super.equals(obj)) { return false; } if (!(obj instanceof XYDataImageAnnotation)) { return false; } XYDataImageAnnotation that = (XYDataImageAnnotation) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } if (this.w != that.w) { return false; } if (this.h != that.h) { return false; } if (this.includeInDataBounds != that.includeInDataBounds) { return false; } if (!ObjectUtilities.equal(this.image, that.image)) { return false; } // seems to be the same... return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { return this.image.hashCode(); } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); // FIXME //SerialUtilities.writeImage(this.image, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); // FIXME //this.image = SerialUtilities.readImage(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYDrawableAnnotation.java0000644000175000017500000002170111173030414031667 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYDrawableAnnotation.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 21-May-2003 : Version 1 (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 30-Sep-2004 : Added support for tool tips and URLs (DG); * 18-Jun-2008 : Added scaling factor (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.ui.Drawable; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A general annotation that can be placed on an {@link XYPlot}. */ public class XYDrawableAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6540812859722691020L; /** The scaling factor. */ private double drawScaleFactor; /** The x-coordinate. */ private double x; /** The y-coordinate. */ private double y; /** The width. */ private double displayWidth; /** The height. */ private double displayHeight; /** The drawable object. */ private Drawable drawable; /** * Creates a new annotation to be displayed within the given area. * * @param x the x-coordinate for the area. * @param y the y-coordinate for the area. * @param width the width of the area. * @param height the height of the area. * @param drawable the drawable object (null not permitted). */ public XYDrawableAnnotation(double x, double y, double width, double height, Drawable drawable) { this(x, y, width, height, 1.0, drawable); } /** * Creates a new annotation to be displayed within the given area. If you * specify a drawScaleFactor of 2.0, the drawable * will be drawn at twice the requested display size then scaled down to * fit the space. * * @param x the x-coordinate for the area. * @param y the y-coordinate for the area. * @param displayWidth the width of the area. * @param displayHeight the height of the area. * @param drawScaleFactor the scaling factor for drawing. * @param drawable the drawable object (null not permitted). * * @since 1.0.11 */ public XYDrawableAnnotation(double x, double y, double displayWidth, double displayHeight, double drawScaleFactor, Drawable drawable) { if (drawable == null) { throw new IllegalArgumentException("Null 'drawable' argument."); } this.x = x; this.y = y; this.displayWidth = displayWidth; this.displayHeight = displayHeight; this.drawScaleFactor = drawScaleFactor; this.drawable = drawable; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge); float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); Rectangle2D displayArea = new Rectangle2D.Double( j2DX - this.displayWidth / 2.0, j2DY - this.displayHeight / 2.0, this.displayWidth, this.displayHeight); // here we change the AffineTransform so we can draw the annotation // to a larger area and scale it down into the display area // afterwards, the original transform is restored AffineTransform savedTransform = g2.getTransform(); Rectangle2D drawArea = new Rectangle2D.Double(0.0, 0.0, this.displayWidth * this.drawScaleFactor, this.displayHeight * this.drawScaleFactor); g2.scale(1/this.drawScaleFactor, 1/this.drawScaleFactor); g2.translate((j2DX - this.displayWidth / 2.0) * this.drawScaleFactor, (j2DY - this.displayHeight / 2.0) * this.drawScaleFactor); this.drawable.draw(g2, drawArea); g2.setTransform(savedTransform); String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, displayArea, rendererIndex, toolTip, url); } } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object to test against. * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { // simple case return true; } // now try to reject equality... if (!super.equals(obj)) { return false; } if (!(obj instanceof XYDrawableAnnotation)) { return false; } XYDrawableAnnotation that = (XYDrawableAnnotation) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } if (this.displayWidth != that.displayWidth) { return false; } if (this.displayHeight != that.displayHeight) { return false; } if (this.drawScaleFactor != that.drawScaleFactor) { return false; } if (!ObjectUtilities.equal(this.drawable, that.drawable)) { return false; } // seem to be the same... return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; long temp; temp = Double.doubleToLongBits(this.x); result = (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 29 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.displayWidth); result = 29 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.displayHeight); result = 29 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYImageAnnotation.java0000644000175000017500000002366411173030414031202 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XYImageAnnotation.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Mike Harris; * * Changes: * -------- * 01-Dec-2003 : Version 1 (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 18-May-2004 : Fixed bug with plot orientation (DG); * 29-Sep-2004 : Now extends AbstractXYAnnotation, with modified draw() * method signature and updated equals() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Dec-2006 : Added anchor attribute (see patch 1584860 from * Mike Harris) (DG); */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.Image; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An annotation that allows an image to be placed at some location on * an {@link XYPlot}. * * TODO: implement serialization properly (image is not serializable). */ public class XYImageAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4364694501921559958L; /** The x-coordinate (in data space). */ private double x; /** The y-coordinate (in data space). */ private double y; /** The image. */ private transient Image image; /** * The image anchor point. * * @since 1.0.4 */ private RectangleAnchor anchor; /** * Creates a new annotation to be displayed at the specified (x, y) * location. * * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). * @param image the image (null not permitted). */ public XYImageAnnotation(double x, double y, Image image) { this(x, y, image, RectangleAnchor.CENTER); } /** * Creates a new annotation to be displayed at the specified (x, y) * location. * * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). * @param image the image (null not permitted). * @param anchor the image anchor (null not permitted). * * @since 1.0.4 */ public XYImageAnnotation(double x, double y, Image image, RectangleAnchor anchor) { if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.x = x; this.y = y; this.image = image; this.anchor = anchor; } /** * Returns the x-coordinate (in data space) for the annotation. * * @return The x-coordinate. * * @since 1.0.4 */ public double getX() { return this.x; } /** * Returns the y-coordinate (in data space) for the annotation. * * @return The y-coordinate. * * @since 1.0.4 */ public double getY() { return this.y; } /** * Returns the image for the annotation. * * @return The image. * * @since 1.0.4 */ public Image getImage() { return this.image; } /** * Returns the image anchor for the annotation. * * @return The image anchor. * * @since 1.0.4 */ public RectangleAnchor getImageAnchor() { return this.anchor; } /** * Draws the annotation. This method is called by the drawing code in the * {@link XYPlot} class, you don't normally need to call this method * directly. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); AxisLocation domainAxisLocation = plot.getDomainAxisLocation(); AxisLocation rangeAxisLocation = plot.getRangeAxisLocation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(domainAxisLocation, orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation); float j2DX = (float) domainAxis.valueToJava2D(this.x, dataArea, domainEdge); float j2DY = (float) rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); float xx = 0.0f; float yy = 0.0f; if (orientation == PlotOrientation.HORIZONTAL) { xx = j2DY; yy = j2DX; } else if (orientation == PlotOrientation.VERTICAL) { xx = j2DX; yy = j2DY; } int w = this.image.getWidth(null); int h = this.image.getHeight(null); Rectangle2D imageRect = new Rectangle2D.Double(0, 0, w, h); Point2D anchorPoint = RectangleAnchor.coordinates(imageRect, this.anchor); xx = xx - (float) anchorPoint.getX(); yy = yy - (float) anchorPoint.getY(); g2.drawImage(this.image, (int) xx, (int) yy, null); String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, new Rectangle2D.Float(xx, yy, w, h), rendererIndex, toolTip, url); } } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } // now try to reject equality... if (!super.equals(obj)) { return false; } if (!(obj instanceof XYImageAnnotation)) { return false; } XYImageAnnotation that = (XYImageAnnotation) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } if (!ObjectUtilities.equal(this.image, that.image)) { return false; } if (!this.anchor.equals(that.anchor)) { return false; } // seems to be the same... return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { return this.image.hashCode(); } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); //SerialUtilities.writeImage(this.image, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); //this.image = SerialUtilities.readImage(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYLineAnnotation.java0000644000175000017500000002565111173030414031045 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYLineAnnotation.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Apr-2003 : Version 1 (DG); * 19-Aug-2003 : Added equals method, implemented Cloneable, and applied * serialization fixes (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 14-Apr-2004 : Fixed draw() method to handle plot orientation correctly (DG); * 29-Sep-2004 : Added support for tool tips and URLS, now extends * AbstractXYAnnotation (DG); * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint() (DG); * 05-Nov-2008 : Added workaround for JRE bug 6574155, see JFreeChart bug * 2221495 (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.util.LineUtilities; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A simple line annotation that can be placed on an {@link XYPlot}. */ public class XYLineAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -80535465244091334L; /** The x-coordinate. */ private double x1; /** The y-coordinate. */ private double y1; /** The x-coordinate. */ private double x2; /** The y-coordinate. */ private double y2; /** The line stroke. */ private transient Stroke stroke; /** The line color. */ private transient Paint paint; /** * Creates a new annotation that draws a line from (x1, y1) to (x2, y2) * where the coordinates are measured in data space (that is, against the * plot's axes). * * @param x1 the x-coordinate for the start of the line. * @param y1 the y-coordinate for the start of the line. * @param x2 the x-coordinate for the end of the line. * @param y2 the y-coordinate for the end of the line. */ public XYLineAnnotation(double x1, double y1, double x2, double y2) { this(x1, y1, x2, y2, new BasicStroke(1.0f), Color.black); } /** * Creates a new annotation that draws a line from (x1, y1) to (x2, y2) * where the coordinates are measured in data space (that is, against the * plot's axes). * * @param x1 the x-coordinate for the start of the line. * @param y1 the y-coordinate for the start of the line. * @param x2 the x-coordinate for the end of the line. * @param y2 the y-coordinate for the end of the line. * @param stroke the line stroke (null not permitted). * @param paint the line color (null not permitted). */ public XYLineAnnotation(double x1, double y1, double x2, double y2, Stroke stroke, Paint paint) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; this.stroke = stroke; this.paint = paint; } /** * Draws the annotation. This method is called by the {@link XYPlot} * class, you won't normally need to call it yourself. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); float j2DX1 = 0.0f; float j2DX2 = 0.0f; float j2DY1 = 0.0f; float j2DY2 = 0.0f; if (orientation == PlotOrientation.VERTICAL) { j2DX1 = (float) domainAxis.valueToJava2D(this.x1, dataArea, domainEdge); j2DY1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge); j2DX2 = (float) domainAxis.valueToJava2D(this.x2, dataArea, domainEdge); j2DY2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea, rangeEdge); } else if (orientation == PlotOrientation.HORIZONTAL) { j2DY1 = (float) domainAxis.valueToJava2D(this.x1, dataArea, domainEdge); j2DX1 = (float) rangeAxis.valueToJava2D(this.y1, dataArea, rangeEdge); j2DY2 = (float) domainAxis.valueToJava2D(this.x2, dataArea, domainEdge); j2DX2 = (float) rangeAxis.valueToJava2D(this.y2, dataArea, rangeEdge); } g2.setPaint(this.paint); g2.setStroke(this.stroke); Line2D line = new Line2D.Float(j2DX1, j2DY1, j2DX2, j2DY2); // line is clipped to avoid JRE bug 6574155, for more info // see JFreeChart bug 2221495 boolean visible = LineUtilities.clipLine(line, dataArea); if (visible) { g2.draw(line); } String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, ShapeUtilities.createLineRegion(line, 1.0f), rendererIndex, toolTip, url); } } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof XYLineAnnotation)) { return false; } XYLineAnnotation that = (XYLineAnnotation) obj; if (this.x1 != that.x1) { return false; } if (this.y1 != that.y1) { return false; } if (this.x2 != that.x2) { return false; } if (this.y2 != that.y2) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } // seems to be the same... return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; long temp; temp = Double.doubleToLongBits(this.x1); result = (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.x2); result = 29 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y1); result = 29 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y2); result = 29 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.stroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYPointerAnnotation.java0000644000175000017500000004264011173030414031573 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYPointerAnnotation.java * ------------------------ * (C) Copyright 2003-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 21-May-2003 : Version 1 (DG); * 10-Jun-2003 : Changed BoundsAnchor to TextAnchor (DG); * 02-Jul-2003 : Added accessor methods and simplified constructor (DG); * 19-Aug-2003 : Implemented Cloneable (DG); * 13-Oct-2003 : Fixed bug where arrow paint is not set correctly (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 29-Sep-2004 : Changes to draw() method signature (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Feb-2006 : Correction for equals() method (fixes bug 1435160) (DG); * 12-Jul-2006 : Fix drawing for PlotOrientation.HORIZONTAL, thanks to * Skunk (DG); * 12-Feb-2009 : Added support for rotated label, plus background and * outline (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An arrow and label that can be placed on an {@link XYPlot}. The arrow is * drawn at a user-definable angle so that it points towards the (x, y) * location for the annotation. *

* The arrow length (and its offset from the (x, y) location) is controlled by * the tip radius and the base radius attributes. Imagine two circles around * the (x, y) coordinate: the inner circle defined by the tip radius, and the * outer circle defined by the base radius. Now, draw the arrow starting at * some point on the outer circle (the point is determined by the angle), with * the arrow tip being drawn at a corresponding point on the inner circle. * */ public class XYPointerAnnotation extends XYTextAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4031161445009858551L; /** The default tip radius (in Java2D units). */ public static final double DEFAULT_TIP_RADIUS = 10.0; /** The default base radius (in Java2D units). */ public static final double DEFAULT_BASE_RADIUS = 30.0; /** The default label offset (in Java2D units). */ public static final double DEFAULT_LABEL_OFFSET = 3.0; /** The default arrow length (in Java2D units). */ public static final double DEFAULT_ARROW_LENGTH = 5.0; /** The default arrow width (in Java2D units). */ public static final double DEFAULT_ARROW_WIDTH = 3.0; /** The angle of the arrow's line (in radians). */ private double angle; /** * The radius from the (x, y) point to the tip of the arrow (in Java2D * units). */ private double tipRadius; /** * The radius from the (x, y) point to the start of the arrow line (in * Java2D units). */ private double baseRadius; /** The length of the arrow head (in Java2D units). */ private double arrowLength; /** The arrow width (in Java2D units, per side). */ private double arrowWidth; /** The arrow stroke. */ private transient Stroke arrowStroke; /** The arrow paint. */ private transient Paint arrowPaint; /** The radius from the base point to the anchor point for the label. */ private double labelOffset; /** * Creates a new label and arrow annotation. * * @param label the label (null permitted). * @param x the x-coordinate (measured against the chart's domain axis). * @param y the y-coordinate (measured against the chart's range axis). * @param angle the angle of the arrow's line (in radians). */ public XYPointerAnnotation(String label, double x, double y, double angle) { super(label, x, y); this.angle = angle; this.tipRadius = DEFAULT_TIP_RADIUS; this.baseRadius = DEFAULT_BASE_RADIUS; this.arrowLength = DEFAULT_ARROW_LENGTH; this.arrowWidth = DEFAULT_ARROW_WIDTH; this.labelOffset = DEFAULT_LABEL_OFFSET; this.arrowStroke = new BasicStroke(1.0f); this.arrowPaint = Color.black; } /** * Returns the angle of the arrow. * * @return The angle (in radians). * * @see #setAngle(double) */ public double getAngle() { return this.angle; } /** * Sets the angle of the arrow. * * @param angle the angle (in radians). * * @see #getAngle() */ public void setAngle(double angle) { this.angle = angle; } /** * Returns the tip radius. * * @return The tip radius (in Java2D units). * * @see #setTipRadius(double) */ public double getTipRadius() { return this.tipRadius; } /** * Sets the tip radius. * * @param radius the radius (in Java2D units). * * @see #getTipRadius() */ public void setTipRadius(double radius) { this.tipRadius = radius; } /** * Returns the base radius. * * @return The base radius (in Java2D units). * * @see #setBaseRadius(double) */ public double getBaseRadius() { return this.baseRadius; } /** * Sets the base radius. * * @param radius the radius (in Java2D units). * * @see #getBaseRadius() */ public void setBaseRadius(double radius) { this.baseRadius = radius; } /** * Returns the label offset. * * @return The label offset (in Java2D units). * * @see #setLabelOffset(double) */ public double getLabelOffset() { return this.labelOffset; } /** * Sets the label offset (from the arrow base, continuing in a straight * line, in Java2D units). * * @param offset the offset (in Java2D units). * * @see #getLabelOffset() */ public void setLabelOffset(double offset) { this.labelOffset = offset; } /** * Returns the arrow length. * * @return The arrow length. * * @see #setArrowLength(double) */ public double getArrowLength() { return this.arrowLength; } /** * Sets the arrow length. * * @param length the length. * * @see #getArrowLength() */ public void setArrowLength(double length) { this.arrowLength = length; } /** * Returns the arrow width. * * @return The arrow width (in Java2D units). * * @see #setArrowWidth(double) */ public double getArrowWidth() { return this.arrowWidth; } /** * Sets the arrow width. * * @param width the width (in Java2D units). * * @see #getArrowWidth() */ public void setArrowWidth(double width) { this.arrowWidth = width; } /** * Returns the stroke used to draw the arrow line. * * @return The arrow stroke (never null). * * @see #setArrowStroke(Stroke) */ public Stroke getArrowStroke() { return this.arrowStroke; } /** * Sets the stroke used to draw the arrow line. * * @param stroke the stroke (null not permitted). * * @see #getArrowStroke() */ public void setArrowStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' not permitted."); } this.arrowStroke = stroke; } /** * Returns the paint used for the arrow. * * @return The arrow paint (never null). * * @see #setArrowPaint(Paint) */ public Paint getArrowPaint() { return this.arrowPaint; } /** * Sets the paint used for the arrow. * * @param paint the arrow paint (null not permitted). * * @see #getArrowPaint() */ public void setArrowPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.arrowPaint = paint; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info the plot rendering info. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); double j2DX = domainAxis.valueToJava2D(getX(), dataArea, domainEdge); double j2DY = rangeAxis.valueToJava2D(getY(), dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { double temp = j2DX; j2DX = j2DY; j2DY = temp; } double startX = j2DX + Math.cos(this.angle) * this.baseRadius; double startY = j2DY + Math.sin(this.angle) * this.baseRadius; double endX = j2DX + Math.cos(this.angle) * this.tipRadius; double endY = j2DY + Math.sin(this.angle) * this.tipRadius; double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength; double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength; double arrowLeftX = arrowBaseX + Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth; double arrowLeftY = arrowBaseY + Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth; double arrowRightX = arrowBaseX - Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth; double arrowRightY = arrowBaseY - Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth; GeneralPath arrow = new GeneralPath(); arrow.moveTo((float) endX, (float) endY); arrow.lineTo((float) arrowLeftX, (float) arrowLeftY); arrow.lineTo((float) arrowRightX, (float) arrowRightY); arrow.closePath(); g2.setStroke(this.arrowStroke); g2.setPaint(this.arrowPaint); Line2D line = new Line2D.Double(startX, startY, endX, endY); g2.draw(line); g2.fill(arrow); // draw the label double labelX = j2DX + Math.cos(this.angle) * (this.baseRadius + this.labelOffset); double labelY = j2DY + Math.sin(this.angle) * (this.baseRadius + this.labelOffset); g2.setFont(getFont()); Shape hotspot = TextUtilities.calculateRotatedStringBounds( getText(), g2, (float) labelX, (float) labelY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (getBackgroundPaint() != null) { g2.setPaint(getBackgroundPaint()); g2.fill(hotspot); } g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, (float) labelX, (float) labelY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (isOutlineVisible()) { g2.setStroke(getOutlineStroke()); g2.setPaint(getOutlinePaint()); g2.draw(hotspot); } String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, hotspot, rendererIndex, toolTip, url); } } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYPointerAnnotation)) { return false; } XYPointerAnnotation that = (XYPointerAnnotation) obj; if (this.angle != that.angle) { return false; } if (this.tipRadius != that.tipRadius) { return false; } if (this.baseRadius != that.baseRadius) { return false; } if (this.arrowLength != that.arrowLength) { return false; } if (this.arrowWidth != that.arrowWidth) { return false; } if (!this.arrowPaint.equals(that.arrowPaint)) { return false; } if (!ObjectUtilities.equal(this.arrowStroke, that.arrowStroke)) { return false; } if (this.labelOffset != that.labelOffset) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); long temp = Double.doubleToLongBits(this.angle); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.tipRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.baseRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.arrowLength); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.arrowWidth); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = result * 37 + HashUtilities.hashCodeForPaint(this.arrowPaint); result = result * 37 + this.arrowStroke.hashCode(); temp = Double.doubleToLongBits(this.labelOffset); result = 37 * result + (int) (temp ^ (temp >>> 32)); return super.hashCode(); } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.arrowPaint, stream); SerialUtilities.writeStroke(this.arrowStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.arrowPaint = SerialUtilities.readPaint(stream); this.arrowStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYPolygonAnnotation.java0000644000175000017500000003073111173030414031600 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYPolygonAnnotation.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 09-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Arrays; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A polygon annotation that can be placed on an {@link XYPlot}. The * polygon coordinates are specified in data space. */ public class XYPolygonAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6984203651995900036L; /** The polygon. */ private double[] polygon; /** The stroke used to draw the box outline. */ private transient Stroke stroke; /** The paint used to draw the box outline. */ private transient Paint outlinePaint; /** The paint used to fill the box. */ private transient Paint fillPaint; /** * Creates a new annotation (where, by default, the polygon is drawn * with a black outline). The array of polygon coordinates must contain * an even number of coordinates (each pair is an (x, y) location on the * plot) and the last point is automatically joined back to the first point. * * @param polygon the coordinates of the polygon's vertices * (null not permitted). */ public XYPolygonAnnotation(double[] polygon) { this(polygon, new BasicStroke(1.0f), Color.black); } /** * Creates a new annotation where the box is drawn as an outline using * the specified stroke and outlinePaint. * The array of polygon coordinates must contain an even number of * coordinates (each pair is an (x, y) location on the plot) and the last * point is automatically joined back to the first point. * * @param polygon the coordinates of the polygon's vertices * (null not permitted). * @param stroke the shape stroke (null permitted). * @param outlinePaint the shape color (null permitted). */ public XYPolygonAnnotation(double[] polygon, Stroke stroke, Paint outlinePaint) { this(polygon, stroke, outlinePaint, null); } /** * Creates a new annotation. The array of polygon coordinates must * contain an even number of coordinates (each pair is an (x, y) location * on the plot) and the last point is automatically joined back to the * first point. * * @param polygon the coordinates of the polygon's vertices * (null not permitted). * @param stroke the shape stroke (null permitted). * @param outlinePaint the shape color (null permitted). * @param fillPaint the paint used to fill the shape (null * permitted). */ public XYPolygonAnnotation(double[] polygon, Stroke stroke, Paint outlinePaint, Paint fillPaint) { if (polygon == null) { throw new IllegalArgumentException("Null 'polygon' argument."); } if (polygon.length % 2 != 0) { throw new IllegalArgumentException("The 'polygon' array must " + "contain an even number of items."); } this.polygon = (double[]) polygon.clone(); this.stroke = stroke; this.outlinePaint = outlinePaint; this.fillPaint = fillPaint; } /** * Returns the coordinates of the polygon's vertices. The returned array * is a copy, so it is safe to modify without altering the annotation's * state. * * @return The coordinates of the polygon's vertices. * * @since 1.0.2 */ public double[] getPolygonCoordinates() { return (double[]) this.polygon.clone(); } /** * Returns the fill paint. * * @return The fill paint (possibly null). * * @since 1.0.2 */ public Paint getFillPaint() { return this.fillPaint; } /** * Returns the outline stroke. * * @return The outline stroke (possibly null). * * @since 1.0.2 */ public Stroke getOutlineStroke() { return this.stroke; } /** * Returns the outline paint. * * @return The outline paint (possibly null). * * @since 1.0.2 */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Draws the annotation. This method is usually called by the * {@link XYPlot} class, you shouldn't need to call it directly. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info the plot rendering info. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { // if we don't have at least 2 (x, y) coordinates, just return if (this.polygon.length < 4) { return; } PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); GeneralPath area = new GeneralPath(); double x = domainAxis.valueToJava2D(this.polygon[0], dataArea, domainEdge); double y = rangeAxis.valueToJava2D(this.polygon[1], dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { area.moveTo((float) y, (float) x); for (int i = 2; i < this.polygon.length; i += 2) { x = domainAxis.valueToJava2D(this.polygon[i], dataArea, domainEdge); y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea, rangeEdge); area.lineTo((float) y, (float) x); } area.closePath(); } else if (orientation == PlotOrientation.VERTICAL) { area.moveTo((float) x, (float) y); for (int i = 2; i < this.polygon.length; i += 2) { x = domainAxis.valueToJava2D(this.polygon[i], dataArea, domainEdge); y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea, rangeEdge); area.lineTo((float) x, (float) y); } area.closePath(); } if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(area); } if (this.stroke != null && this.outlinePaint != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.stroke); g2.draw(area); } addEntity(info, area, rendererIndex, getToolTipText(), getURL()); } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } // now try to reject equality if (!super.equals(obj)) { return false; } if (!(obj instanceof XYPolygonAnnotation)) { return false; } XYPolygonAnnotation that = (XYPolygonAnnotation) obj; if (!Arrays.equals(this.polygon, that.polygon)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } // seem to be the same return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * result + HashUtilities.hashCodeForDoubleArray( this.polygon); result = 37 * result + HashUtilities.hashCodeForPaint(this.fillPaint); result = 37 * result + HashUtilities.hashCodeForPaint( this.outlinePaint); if (this.stroke != null) { result = 37 * result + this.stroke.hashCode(); } return result; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class, but may be * by subclasses. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream (null not permitted). * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.stroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writePaint(this.fillPaint, stream); } /** * Provides serialization support. * * @param stream the input stream (null not permitted). * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.stroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.fillPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYShapeAnnotation.java0000644000175000017500000002634411173030414031216 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XYShapeAnnotation.java * ---------------------- * (C) Copyright 2003-2008, by Ondax, Inc. and Contributors. * * Original Author: Greg Steckman (for Ondax, Inc.); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 15-Aug-2003 : Version 1, adapted from * org.jfree.chart.annotations.XYLineAnnotation (GS); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 20-Apr-2004 : Added new constructor and fixed bug 934258 (DG); * 29-Sep-2004 : Added 'fillPaint' to allow for colored shapes, now extends * AbstractXYAnnotation to add tool tip and URL support, and * implemented equals() and Cloneable (DG); * 21-Jan-2005 : Modified constructor for consistency with other * constructors (DG); * 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Oct-2006 : Calculate AffineTransform on shape's bounding rectangle * rather than sample points (0, 0) and (1, 1) (DG); * 06-Mar-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A simple Shape annotation that can be placed on an * {@link XYPlot}. The shape coordinates are specified in data space. */ public class XYShapeAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8553218317600684041L; /** The shape. */ private transient Shape shape; /** The stroke used to draw the shape's outline. */ private transient Stroke stroke; /** The paint used to draw the shape's outline. */ private transient Paint outlinePaint; /** The paint used to fill the shape. */ private transient Paint fillPaint; /** * Creates a new annotation (where, by default, the shape is drawn * with a black outline). * * @param shape the shape (coordinates in data space, null * not permitted). */ public XYShapeAnnotation(Shape shape) { this(shape, new BasicStroke(1.0f), Color.black); } /** * Creates a new annotation where the shape is drawn as an outline using * the specified stroke and outlinePaint. * * @param shape the shape (null not permitted). * @param stroke the shape stroke (null permitted). * @param outlinePaint the shape color (null permitted). */ public XYShapeAnnotation(Shape shape, Stroke stroke, Paint outlinePaint) { this(shape, stroke, outlinePaint, null); } /** * Creates a new annotation. * * @param shape the shape (null not permitted). * @param stroke the shape stroke (null permitted). * @param outlinePaint the shape color (null permitted). * @param fillPaint the paint used to fill the shape (null * permitted. */ public XYShapeAnnotation(Shape shape, Stroke stroke, Paint outlinePaint, Paint fillPaint) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.shape = shape; this.stroke = stroke; this.outlinePaint = outlinePaint; this.fillPaint = fillPaint; } /** * Draws the annotation. This method is usually called by the * {@link XYPlot} class, you shouldn't need to call it directly. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info the plot rendering info. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); // compute transform matrix elements via sample points. Assume no // rotation or shear. Rectangle2D bounds = this.shape.getBounds2D(); double x0 = bounds.getMinX(); double x1 = bounds.getMaxX(); double xx0 = domainAxis.valueToJava2D(x0, dataArea, domainEdge); double xx1 = domainAxis.valueToJava2D(x1, dataArea, domainEdge); double m00 = (xx1 - xx0) / (x1 - x0); double m02 = xx0 - x0 * m00; double y0 = bounds.getMaxY(); double y1 = bounds.getMinY(); double yy0 = rangeAxis.valueToJava2D(y0, dataArea, rangeEdge); double yy1 = rangeAxis.valueToJava2D(y1, dataArea, rangeEdge); double m11 = (yy1 - yy0) / (y1 - y0); double m12 = yy0 - m11 * y0; // create transform & transform shape Shape s = null; if (orientation == PlotOrientation.HORIZONTAL) { AffineTransform t1 = new AffineTransform(0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f); AffineTransform t2 = new AffineTransform(m11, 0.0f, 0.0f, m00, m12, m02); s = t1.createTransformedShape(this.shape); s = t2.createTransformedShape(s); } else if (orientation == PlotOrientation.VERTICAL) { AffineTransform t = new AffineTransform(m00, 0, 0, m11, m02, m12); s = t.createTransformedShape(this.shape); } if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(s); } if (this.stroke != null && this.outlinePaint != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.stroke); g2.draw(s); } addEntity(info, s, rendererIndex, getToolTipText(), getURL()); } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } // now try to reject equality if (!super.equals(obj)) { return false; } if (!(obj instanceof XYShapeAnnotation)) { return false; } XYShapeAnnotation that = (XYShapeAnnotation) obj; if (!this.shape.equals(that.shape)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } // seem to be the same return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * result + this.shape.hashCode(); if (this.stroke != null) { result = 37 * result + this.stroke.hashCode(); } result = 37 * result + HashUtilities.hashCodeForPaint( this.outlinePaint); result = 37 * result + HashUtilities.hashCodeForPaint(this.fillPaint); return result; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException ???. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.shape, stream); SerialUtilities.writeStroke(this.stroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writePaint(this.fillPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.shape = SerialUtilities.readShape(stream); this.stroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.fillPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYTextAnnotation.java0000644000175000017500000004676611173030414031114 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYTextAnnotation.java * --------------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Aug-2002 : Version 1 (DG); * 07-Nov-2002 : Fixed errors reported by Checkstyle (DG); * 13-Jan-2003 : Reviewed Javadocs (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 02-Jul-2003 : Added new text alignment and rotation options (DG); * 19-Aug-2003 : Implemented Cloneable (DG); * 17-Jan-2003 : Added fix for bug 878706, where the annotation is placed * incorrectly for a plot with horizontal orientation (thanks to * Ed Yu for the fix) (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 26-Jan-2006 : Fixed equals() method (bug 1415480) (DG); * 06-Mar-2007 : Added argument checks, re-implemented hashCode() method (DG); * 12-Feb-2009 : Added background paint and outline paint/stroke (DG); * 01-Apr-2009 : Fixed bug in hotspot calculation (DG); * */ package org.jfree.chart.annotations; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A text annotation that can be placed at a particular (x, y) location on an * {@link XYPlot}. */ public class XYTextAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2946063342782506328L; /** The default font. */ public static final Font DEFAULT_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default paint. */ public static final Paint DEFAULT_PAINT = Color.black; /** The default text anchor. */ public static final TextAnchor DEFAULT_TEXT_ANCHOR = TextAnchor.CENTER; /** The default rotation anchor. */ public static final TextAnchor DEFAULT_ROTATION_ANCHOR = TextAnchor.CENTER; /** The default rotation angle. */ public static final double DEFAULT_ROTATION_ANGLE = 0.0; /** The text. */ private String text; /** The font. */ private Font font; /** The paint. */ private transient Paint paint; /** The x-coordinate. */ private double x; /** The y-coordinate. */ private double y; /** The text anchor (to be aligned with (x, y)). */ private TextAnchor textAnchor; /** The rotation anchor. */ private TextAnchor rotationAnchor; /** The rotation angle. */ private double rotationAngle; /** * The background paint (possibly null). * * @since 1.0.13 */ private transient Paint backgroundPaint; /** * The flag that controls the visibility of the outline. * * @since 1.0.13 */ private boolean outlineVisible; /** * The outline paint (never null). * * @since 1.0.13 */ private transient Paint outlinePaint; /** * The outline stroke (never null). * * @since 1.0.13 */ private transient Stroke outlineStroke; /** * Creates a new annotation to be displayed at the given coordinates. The * coordinates are specified in data space (they will be converted to * Java2D space for display). * * @param text the text (null not permitted). * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). */ public XYTextAnnotation(String text, double x, double y) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } this.text = text; this.font = DEFAULT_FONT; this.paint = DEFAULT_PAINT; this.x = x; this.y = y; this.textAnchor = DEFAULT_TEXT_ANCHOR; this.rotationAnchor = DEFAULT_ROTATION_ANCHOR; this.rotationAngle = DEFAULT_ROTATION_ANGLE; // by default the outline and background won't be visible this.backgroundPaint = null; this.outlineVisible = false; this.outlinePaint = Color.black; this.outlineStroke = new BasicStroke(0.5f); } /** * Returns the text for the annotation. * * @return The text (never null). * * @see #setText(String) */ public String getText() { return this.text; } /** * Sets the text for the annotation. * * @param text the text (null not permitted). * * @see #getText() */ public void setText(String text) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } this.text = text; } /** * Returns the font for the annotation. * * @return The font (never null). * * @see #setFont(Font) */ public Font getFont() { return this.font; } /** * Sets the font for the annotation. * * @param font the font (null not permitted). * * @see #getFont() */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.font = font; } /** * Returns the paint for the annotation. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint for the annotation. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; } /** * Returns the text anchor. * * @return The text anchor (never null). * * @see #setTextAnchor(TextAnchor) */ public TextAnchor getTextAnchor() { return this.textAnchor; } /** * Sets the text anchor (the point on the text bounding rectangle that is * aligned to the (x, y) coordinate of the annotation). * * @param anchor the anchor point (null not permitted). * * @see #getTextAnchor() */ public void setTextAnchor(TextAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.textAnchor = anchor; } /** * Returns the rotation anchor. * * @return The rotation anchor point (never null). * * @see #setRotationAnchor(TextAnchor) */ public TextAnchor getRotationAnchor() { return this.rotationAnchor; } /** * Sets the rotation anchor point. * * @param anchor the anchor (null not permitted). * * @see #getRotationAnchor() */ public void setRotationAnchor(TextAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.rotationAnchor = anchor; } /** * Returns the rotation angle. * * @return The rotation angle. * * @see #setRotationAngle(double) */ public double getRotationAngle() { return this.rotationAngle; } /** * Sets the rotation angle. The angle is measured clockwise in radians. * * @param angle the angle (in radians). * * @see #getRotationAngle() */ public void setRotationAngle(double angle) { this.rotationAngle = angle; } /** * Returns the x coordinate for the text anchor point (measured against the * domain axis). * * @return The x coordinate (in data space). * * @see #setX(double) */ public double getX() { return this.x; } /** * Sets the x coordinate for the text anchor point (measured against the * domain axis). * * @param x the x coordinate (in data space). * * @see #getX() */ public void setX(double x) { this.x = x; } /** * Returns the y coordinate for the text anchor point (measured against the * range axis). * * @return The y coordinate (in data space). * * @see #setY(double) */ public double getY() { return this.y; } /** * Sets the y coordinate for the text anchor point (measured against the * range axis). * * @param y the y coordinate. * * @see #getY() */ public void setY(double y) { this.y = y; } /** * Returns the background paint for the annotation. * * @return The background paint (possibly null). * * @see #setBackgroundPaint(Paint) * * @since 1.0.13 */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint for the annotation. * * @param paint the paint (null permitted). * * @see #getBackgroundPaint() * * @since 1.0.13 */ public void setBackgroundPaint(Paint paint) { this.backgroundPaint = paint; } /** * Returns the outline paint for the annotation. * * @return The outline paint (never null). * * @see #setOutlinePaint(Paint) * * @since 1.0.13 */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint for the annotation. * * @param paint the paint (null not permitted). * * @see #getOutlinePaint() * * @since 1.0.13 */ public void setOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.outlinePaint = paint; } /** * Returns the outline stroke for the annotation. * * @return The outline stroke (never null). * * @see #setOutlineStroke(Stroke) * * @since 1.0.13 */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the outline stroke for the annotation. * * @param stroke the stroke (null not permitted). * * @see #getOutlineStroke() * * @since 1.0.13 */ public void setOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.outlineStroke = stroke; } /** * Returns the flag that controls whether or not the outline is drawn. * * @return A boolean. * * @since 1.0.13 */ public boolean isOutlineVisible() { return this.outlineVisible; } /** * Sets the flag that controls whether or not the outline is drawn. * * @param visible the new flag value. * * @since 1.0.13 */ public void setOutlineVisible(boolean visible) { this.outlineVisible = visible; } /** * Draws the annotation. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info an optional info object that will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( plot.getRangeAxisLocation(), orientation); float anchorX = (float) domainAxis.valueToJava2D( this.x, dataArea, domainEdge); float anchorY = (float) rangeAxis.valueToJava2D( this.y, dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { float tempAnchor = anchorX; anchorX = anchorY; anchorY = tempAnchor; } g2.setFont(getFont()); Shape hotspot = TextUtilities.calculateRotatedStringBounds( getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (this.backgroundPaint != null) { g2.setPaint(this.backgroundPaint); g2.fill(hotspot); } g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (this.outlineVisible) { g2.setStroke(this.outlineStroke); g2.setPaint(this.outlinePaint); g2.draw(hotspot); } String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, hotspot, rendererIndex, toolTip, url); } } /** * Tests this annotation for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYTextAnnotation)) { return false; } XYTextAnnotation that = (XYTextAnnotation) obj; if (!this.text.equals(that.text)) { return false; } if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } if (!this.font.equals(that.font)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!this.rotationAnchor.equals(that.rotationAnchor)) { return false; } if (this.rotationAngle != that.rotationAngle) { return false; } if (!this.textAnchor.equals(that.textAnchor)) { return false; } if (this.outlineVisible != that.outlineVisible) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!(this.outlineStroke.equals(that.outlineStroke))) { return false; } return super.equals(obj); } /** * Returns a hash code for the object. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * this.text.hashCode(); result = 37 * this.font.hashCode(); result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + this.textAnchor.hashCode(); result = 37 * result + this.rotationAnchor.hashCode(); temp = Double.doubleToLongBits(this.rotationAngle); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writePaint(this.backgroundPaint, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.backgroundPaint = SerialUtilities.readPaint(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/XYTitleAnnotation.java0000644000175000017500000003114611173030414031233 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XYTitleAnnotation.java * ---------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrew Mickish; * * Changes: * -------- * 02-Feb-2007 : Version 1 (DG); * 30-Apr-2007 : Fixed equals() method (DG); * 26-Feb-2008 : Fixed NullPointerException when drawing chart with a null * ChartRenderingInfo - see patch 1901599 by Andrew Mickish (DG); * 03-Sep-2008 : Moved from experimental to main (DG); * */ package org.jfree.chart.annotations; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.block.BlockParams; import org.jfree.chart.block.EntityBlockResult; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.title.Title; import org.jfree.chart.util.XYCoordinateType; import org.jfree.data.Range; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.Size2D; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An annotation that allows any {@link Title} to be placed at a location on * an {@link XYPlot}. * * @since 1.0.11 */ public class XYTitleAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4364694501921559958L; /** The coordinate type. */ private XYCoordinateType coordinateType; /** The x-coordinate (in data space). */ private double x; /** The y-coordinate (in data space). */ private double y; /** The maximum width. */ private double maxWidth; /** The maximum height. */ private double maxHeight; /** The title. */ private Title title; /** * The title anchor point. */ private RectangleAnchor anchor; /** * Creates a new annotation to be displayed at the specified (x, y) * location. * * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). * @param title the title (null not permitted). */ public XYTitleAnnotation(double x, double y, Title title) { this(x, y, title, RectangleAnchor.CENTER); } /** * Creates a new annotation to be displayed at the specified (x, y) * location. * * @param x the x-coordinate (in data space). * @param y the y-coordinate (in data space). * @param title the title (null not permitted). * @param anchor the title anchor (null not permitted). */ public XYTitleAnnotation(double x, double y, Title title, RectangleAnchor anchor) { if (title == null) { throw new IllegalArgumentException("Null 'title' argument."); } if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.coordinateType = XYCoordinateType.RELATIVE; this.x = x; this.y = y; this.maxWidth = 0.0; this.maxHeight = 0.0; this.title = title; this.anchor = anchor; } /** * Returns the coordinate type (set in the constructor). * * @return The coordinate type (never null). */ public XYCoordinateType getCoordinateType() { return this.coordinateType; } /** * Returns the x-coordinate for the annotation. * * @return The x-coordinate. */ public double getX() { return this.x; } /** * Returns the y-coordinate for the annotation. * * @return The y-coordinate. */ public double getY() { return this.y; } /** * Returns the title for the annotation. * * @return The title. */ public Title getTitle() { return this.title; } /** * Returns the title anchor for the annotation. * * @return The title anchor. */ public RectangleAnchor getTitleAnchor() { return this.anchor; } /** * Returns the maximum width. * * @return The maximum width. */ public double getMaxWidth() { return this.maxWidth; } /** * Sets the maximum width. * * @param max the maximum width (0.0 or less means no maximum). */ public void setMaxWidth(double max) { this.maxWidth = max; } /** * Returns the maximum height. * * @return The maximum height. */ public double getMaxHeight() { return this.maxHeight; } /** * Sets the maximum height. * * @param max the maximum height. */ public void setMaxHeight(double max) { this.maxHeight = max; } /** * Draws the annotation. This method is called by the drawing code in the * {@link XYPlot} class, you don't normally need to call this method * directly. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info if supplied, this info object will be populated with * entity information. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); AxisLocation domainAxisLocation = plot.getDomainAxisLocation(); AxisLocation rangeAxisLocation = plot.getRangeAxisLocation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( domainAxisLocation, orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( rangeAxisLocation, orientation); Range xRange = domainAxis.getRange(); Range yRange = rangeAxis.getRange(); double anchorX = 0.0; double anchorY = 0.0; if (this.coordinateType == XYCoordinateType.RELATIVE) { anchorX = xRange.getLowerBound() + (this.x * xRange.getLength()); anchorY = yRange.getLowerBound() + (this.y * yRange.getLength()); } else { anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge); anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); } float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, domainEdge); float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea, rangeEdge); float xx = 0.0f; float yy = 0.0f; if (orientation == PlotOrientation.HORIZONTAL) { xx = j2DY; yy = j2DX; } else if (orientation == PlotOrientation.VERTICAL) { xx = j2DX; yy = j2DY; } double maxW = dataArea.getWidth(); double maxH = dataArea.getHeight(); if (this.coordinateType == XYCoordinateType.RELATIVE) { if (this.maxWidth > 0.0) { maxW = maxW * this.maxWidth; } if (this.maxHeight > 0.0) { maxH = maxH * this.maxHeight; } } if (this.coordinateType == XYCoordinateType.DATA) { maxW = this.maxWidth; maxH = this.maxHeight; } RectangleConstraint rc = new RectangleConstraint( new Range(0, maxW), new Range(0, maxH)); Size2D size = this.title.arrange(g2, rc); Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, size.height); Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, this.anchor); xx = xx - (float) anchorPoint.getX(); yy = yy - (float) anchorPoint.getY(); titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight()); BlockParams p = new BlockParams(); if (info != null) { if (info.getOwner().getEntityCollection() != null) { p.setGenerateEntities(true); } } Object result = this.title.draw(g2, titleRect, p); if (info != null) { if (result instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) result; info.getOwner().getEntityCollection().addAll( ebr.getEntityCollection()); } String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, new Rectangle2D.Float(xx, yy, (float) size.width, (float) size.height), rendererIndex, toolTip, url); } } } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYTitleAnnotation)) { return false; } XYTitleAnnotation that = (XYTitleAnnotation) obj; if (this.coordinateType != that.coordinateType) { return false; } if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } if (this.maxWidth != that.maxWidth) { return false; } if (this.maxHeight != that.maxHeight) { return false; } if (!ObjectUtilities.equal(this.title, that.title)) { return false; } if (!this.anchor.equals(that.anchor)) { return false; } return super.equals(obj); } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 193; result = HashUtilities.hashCode(result, this.anchor); result = HashUtilities.hashCode(result, this.coordinateType); result = HashUtilities.hashCode(result, this.x); result = HashUtilities.hashCode(result, this.y); result = HashUtilities.hashCode(result, this.maxWidth); result = HashUtilities.hashCode(result, this.maxHeight); result = HashUtilities.hashCode(result, this.title); return result; } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException if the annotation can't be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/annotations/package.html0000644000175000017500000000023311173030414027245 0ustar vincentvincent A framework for addings annotations to charts. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/0000755000175000017500000000000011216245561023406 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/Axis.java0000644000175000017500000014024511173030414025152 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Axis.java * --------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Bill Kelemen; * Nicolas Brodu; * Peter Kolb (patches 1934255 and 2603321); * Andrew Mickish (patch 1870189); * * Changes * ------- * 21-Aug-2001 : Added standard header, fixed DOS encoding problem (DG); * 18-Sep-2001 : Updated header (DG); * 07-Nov-2001 : Allow null axis labels (DG); * : Added default font values (DG); * 13-Nov-2001 : Modified the setPlot() method to check compatibility between * the axis and the plot (DG); * 30-Nov-2001 : Changed default font from "Arial" --> "SansSerif" (DG); * 06-Dec-2001 : Allow null in setPlot() method (BK); * 06-Mar-2002 : Added AxisConstants interface (DG); * 23-Apr-2002 : Added a visible property. Moved drawVerticalString to * RefineryUtilities. Added fixedDimension property for use in * combined plots (DG); * 25-Jun-2002 : Removed unnecessary imports (DG); * 05-Sep-2002 : Added attribute for tick mark paint (DG); * 18-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 07-Nov-2002 : Added attributes to control the inside and outside length of * the tick marks (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 18-Nov-2002 : Added axis location to refreshTicks() parameters (DG); * 15-Jan-2003 : Removed monolithic constructor (DG); * 17-Jan-2003 : Moved plot classes to separate package (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 03-Jul-2003 : Modified reserveSpace method (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 11-Sep-2003 : Took care of listeners while cloning (NB); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 06-Nov-2003 : Modified refreshTicks() signature (DG); * 06-Jan-2004 : Added axis line attributes (DG); * 16-Mar-2004 : Added plot state to draw() method (DG); * 07-Apr-2004 : Modified text bounds calculation (DG); * 18-May-2004 : Eliminated AxisConstants.java (DG); * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities --> * TextUtilities (DG); * 04-Oct-2004 : Modified getLabelEnclosure() method to treat an empty String * the same way as a null string - see bug 1026521 (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 01-Jun-2005 : Added hasListener() method for unit testing (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 22-Aug-2006 : API doc updates (DG); * 06-Jun-2008 : Added setTickLabelInsets(RectangleInsets, boolean) (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * 26-Sep-2008 : Added fireChangeEvent() method (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart.axis; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Arrays; import java.util.EventListener; import java.util.List; import javax.swing.event.EventListenerList; import org.jfree.chart.entity.AxisEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.event.AxisChangeListener; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * The base class for all axes in JFreeChart. Subclasses are divided into * those that display values ({@link ValueAxis}) and those that display * categories ({@link CategoryAxis}). */ public abstract class Axis implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7719289504573298271L; /** The default axis visibility. */ public static final boolean DEFAULT_AXIS_VISIBLE = true; /** The default axis label font. */ public static final Font DEFAULT_AXIS_LABEL_FONT = new Font( "SansSerif", Font.PLAIN, 12); /** The default axis label paint. */ public static final Paint DEFAULT_AXIS_LABEL_PAINT = Color.black; /** The default axis label insets. */ public static final RectangleInsets DEFAULT_AXIS_LABEL_INSETS = new RectangleInsets(3.0, 3.0, 3.0, 3.0); /** The default axis line paint. */ public static final Paint DEFAULT_AXIS_LINE_PAINT = Color.gray; /** The default axis line stroke. */ public static final Stroke DEFAULT_AXIS_LINE_STROKE = new BasicStroke(1.0f); /** The default tick labels visibility. */ public static final boolean DEFAULT_TICK_LABELS_VISIBLE = true; /** The default tick label font. */ public static final Font DEFAULT_TICK_LABEL_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default tick label paint. */ public static final Paint DEFAULT_TICK_LABEL_PAINT = Color.black; /** The default tick label insets. */ public static final RectangleInsets DEFAULT_TICK_LABEL_INSETS = new RectangleInsets(2.0, 4.0, 2.0, 4.0); /** The default tick marks visible. */ public static final boolean DEFAULT_TICK_MARKS_VISIBLE = true; /** The default tick stroke. */ public static final Stroke DEFAULT_TICK_MARK_STROKE = new BasicStroke(1); /** The default tick paint. */ public static final Paint DEFAULT_TICK_MARK_PAINT = Color.gray; /** The default tick mark inside length. */ public static final float DEFAULT_TICK_MARK_INSIDE_LENGTH = 0.0f; /** The default tick mark outside length. */ public static final float DEFAULT_TICK_MARK_OUTSIDE_LENGTH = 2.0f; /** A flag indicating whether or not the axis is visible. */ private boolean visible; /** The label for the axis. */ private String label; /** The font for displaying the axis label. */ private Font labelFont; /** The paint for drawing the axis label. */ private transient Paint labelPaint; /** The insets for the axis label. */ private RectangleInsets labelInsets; /** The label angle. */ private double labelAngle; /** A flag that controls whether or not the axis line is visible. */ private boolean axisLineVisible; /** The stroke used for the axis line. */ private transient Stroke axisLineStroke; /** The paint used for the axis line. */ private transient Paint axisLinePaint; /** * A flag that indicates whether or not tick labels are visible for the * axis. */ private boolean tickLabelsVisible; /** The font used to display the tick labels. */ private Font tickLabelFont; /** The color used to display the tick labels. */ private transient Paint tickLabelPaint; /** The blank space around each tick label. */ private RectangleInsets tickLabelInsets; /** * A flag that indicates whether or not major tick marks are visible for * the axis. */ private boolean tickMarksVisible; /** * The length of the major tick mark inside the data area (zero * permitted). */ private float tickMarkInsideLength; /** * The length of the major tick mark outside the data area (zero * permitted). */ private float tickMarkOutsideLength; /** * A flag that indicates whether or not minor tick marks are visible for the * axis. * * @since 1.0.12 */ private boolean minorTickMarksVisible; /** * The length of the minor tick mark inside the data area (zero permitted). * * @since 1.0.12 */ private float minorTickMarkInsideLength; /** * The length of the minor tick mark outside the data area (zero permitted). * * @since 1.0.12 */ private float minorTickMarkOutsideLength; /** The stroke used to draw tick marks. */ private transient Stroke tickMarkStroke; /** The paint used to draw tick marks. */ private transient Paint tickMarkPaint; /** The fixed (horizontal or vertical) dimension for the axis. */ private double fixedDimension; /** * A reference back to the plot that the axis is assigned to (can be * null). */ private transient Plot plot; /** Storage for registered listeners. */ private transient EventListenerList listenerList; /** * Constructs an axis, using default values where necessary. * * @param label the axis label (null permitted). */ protected Axis(String label) { this.label = label; this.visible = DEFAULT_AXIS_VISIBLE; this.labelFont = DEFAULT_AXIS_LABEL_FONT; this.labelPaint = DEFAULT_AXIS_LABEL_PAINT; this.labelInsets = DEFAULT_AXIS_LABEL_INSETS; this.labelAngle = 0.0; this.axisLineVisible = true; this.axisLinePaint = DEFAULT_AXIS_LINE_PAINT; this.axisLineStroke = DEFAULT_AXIS_LINE_STROKE; this.tickLabelsVisible = DEFAULT_TICK_LABELS_VISIBLE; this.tickLabelFont = DEFAULT_TICK_LABEL_FONT; this.tickLabelPaint = DEFAULT_TICK_LABEL_PAINT; this.tickLabelInsets = DEFAULT_TICK_LABEL_INSETS; this.tickMarksVisible = DEFAULT_TICK_MARKS_VISIBLE; this.tickMarkStroke = DEFAULT_TICK_MARK_STROKE; this.tickMarkPaint = DEFAULT_TICK_MARK_PAINT; this.tickMarkInsideLength = DEFAULT_TICK_MARK_INSIDE_LENGTH; this.tickMarkOutsideLength = DEFAULT_TICK_MARK_OUTSIDE_LENGTH; this.minorTickMarksVisible = false; this.minorTickMarkInsideLength = 0.0f; this.minorTickMarkOutsideLength = 2.0f; this.plot = null; this.listenerList = new EventListenerList(); } /** * Returns true if the axis is visible, and * false otherwise. * * @return A boolean. * * @see #setVisible(boolean) */ public boolean isVisible() { return this.visible; } /** * Sets a flag that controls whether or not the axis is visible and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #isVisible() */ public void setVisible(boolean flag) { if (flag != this.visible) { this.visible = flag; fireChangeEvent(); } } /** * Returns the label for the axis. * * @return The label for the axis (null possible). * * @see #getLabelFont() * @see #getLabelPaint() * @see #setLabel(String) */ public String getLabel() { return this.label; } /** * Sets the label for the axis and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param label the new label (null permitted). * * @see #getLabel() * @see #setLabelFont(Font) * @see #setLabelPaint(Paint) */ public void setLabel(String label) { String existing = this.label; if (existing != null) { if (!existing.equals(label)) { this.label = label; fireChangeEvent(); } } else { if (label != null) { this.label = label; fireChangeEvent(); } } } /** * Returns the font for the axis label. * * @return The font (never null). * * @see #setLabelFont(Font) */ public Font getLabelFont() { return this.labelFont; } /** * Sets the font for the axis label and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param font the font (null not permitted). * * @see #getLabelFont() */ public void setLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (!this.labelFont.equals(font)) { this.labelFont = font; fireChangeEvent(); } } /** * Returns the color/shade used to draw the axis label. * * @return The paint (never null). * * @see #setLabelPaint(Paint) */ public Paint getLabelPaint() { return this.labelPaint; } /** * Sets the paint used to draw the axis label and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getLabelPaint() */ public void setLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.labelPaint = paint; fireChangeEvent(); } /** * Returns the insets for the label (that is, the amount of blank space * that should be left around the label). * * @return The label insets (never null). * * @see #setLabelInsets(RectangleInsets) */ public RectangleInsets getLabelInsets() { return this.labelInsets; } /** * Sets the insets for the axis label, and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param insets the insets (null not permitted). * * @see #getLabelInsets() */ public void setLabelInsets(RectangleInsets insets) { setLabelInsets(insets, true); } /** * Sets the insets for the axis label, and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param insets the insets (null not permitted). * @param notify notify listeners? * * @since 1.0.10 */ public void setLabelInsets(RectangleInsets insets, boolean notify) { if (insets == null) { throw new IllegalArgumentException("Null 'insets' argument."); } if (!insets.equals(this.labelInsets)) { this.labelInsets = insets; if (notify) { fireChangeEvent(); } } } /** * Returns the angle of the axis label. * * @return The angle (in radians). * * @see #setLabelAngle(double) */ public double getLabelAngle() { return this.labelAngle; } /** * Sets the angle for the label and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param angle the angle (in radians). * * @see #getLabelAngle() */ public void setLabelAngle(double angle) { this.labelAngle = angle; fireChangeEvent(); } /** * A flag that controls whether or not the axis line is drawn. * * @return A boolean. * * @see #getAxisLinePaint() * @see #getAxisLineStroke() * @see #setAxisLineVisible(boolean) */ public boolean isAxisLineVisible() { return this.axisLineVisible; } /** * Sets a flag that controls whether or not the axis line is visible and * sends an {@link AxisChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #isAxisLineVisible() * @see #setAxisLinePaint(Paint) * @see #setAxisLineStroke(Stroke) */ public void setAxisLineVisible(boolean visible) { this.axisLineVisible = visible; fireChangeEvent(); } /** * Returns the paint used to draw the axis line. * * @return The paint (never null). * * @see #setAxisLinePaint(Paint) */ public Paint getAxisLinePaint() { return this.axisLinePaint; } /** * Sets the paint used to draw the axis line and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getAxisLinePaint() */ public void setAxisLinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.axisLinePaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the axis line. * * @return The stroke (never null). * * @see #setAxisLineStroke(Stroke) */ public Stroke getAxisLineStroke() { return this.axisLineStroke; } /** * Sets the stroke used to draw the axis line and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getAxisLineStroke() */ public void setAxisLineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.axisLineStroke = stroke; fireChangeEvent(); } /** * Returns a flag indicating whether or not the tick labels are visible. * * @return The flag. * * @see #getTickLabelFont() * @see #getTickLabelPaint() * @see #setTickLabelsVisible(boolean) */ public boolean isTickLabelsVisible() { return this.tickLabelsVisible; } /** * Sets the flag that determines whether or not the tick labels are * visible and sends an {@link AxisChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #isTickLabelsVisible() * @see #setTickLabelFont(Font) * @see #setTickLabelPaint(Paint) */ public void setTickLabelsVisible(boolean flag) { if (flag != this.tickLabelsVisible) { this.tickLabelsVisible = flag; fireChangeEvent(); } } /** * Returns the flag that indicates whether or not the minor tick marks are * showing. * * @return The flag that indicates whether or not the minor tick marks are * showing. * * @see #setMinorTickMarksVisible(boolean) * * @since 1.0.12 */ public boolean isMinorTickMarksVisible() { return this.minorTickMarksVisible; } /** * Sets the flag that indicates whether or not the minor tick marks are showing * and sends an {@link AxisChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #isMinorTickMarksVisible() * * @since 1.0.12 */ public void setMinorTickMarksVisible(boolean flag) { if (flag != this.minorTickMarksVisible) { this.minorTickMarksVisible = flag; fireChangeEvent(); } } /** * Returns the font used for the tick labels (if showing). * * @return The font (never null). * * @see #setTickLabelFont(Font) */ public Font getTickLabelFont() { return this.tickLabelFont; } /** * Sets the font for the tick labels and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param font the font (null not allowed). * * @see #getTickLabelFont() */ public void setTickLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (!this.tickLabelFont.equals(font)) { this.tickLabelFont = font; fireChangeEvent(); } } /** * Returns the color/shade used for the tick labels. * * @return The paint used for the tick labels. * * @see #setTickLabelPaint(Paint) */ public Paint getTickLabelPaint() { return this.tickLabelPaint; } /** * Sets the paint used to draw tick labels (if they are showing) and * sends an {@link AxisChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getTickLabelPaint() */ public void setTickLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.tickLabelPaint = paint; fireChangeEvent(); } /** * Returns the insets for the tick labels. * * @return The insets (never null). * * @see #setTickLabelInsets(RectangleInsets) */ public RectangleInsets getTickLabelInsets() { return this.tickLabelInsets; } /** * Sets the insets for the tick labels and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param insets the insets (null not permitted). * * @see #getTickLabelInsets() */ public void setTickLabelInsets(RectangleInsets insets) { if (insets == null) { throw new IllegalArgumentException("Null 'insets' argument."); } if (!this.tickLabelInsets.equals(insets)) { this.tickLabelInsets = insets; fireChangeEvent(); } } /** * Returns the flag that indicates whether or not the tick marks are * showing. * * @return The flag that indicates whether or not the tick marks are * showing. * * @see #setTickMarksVisible(boolean) */ public boolean isTickMarksVisible() { return this.tickMarksVisible; } /** * Sets the flag that indicates whether or not the tick marks are showing * and sends an {@link AxisChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #isTickMarksVisible() */ public void setTickMarksVisible(boolean flag) { if (flag != this.tickMarksVisible) { this.tickMarksVisible = flag; fireChangeEvent(); } } /** * Returns the inside length of the tick marks. * * @return The length. * * @see #getTickMarkOutsideLength() * @see #setTickMarkInsideLength(float) */ public float getTickMarkInsideLength() { return this.tickMarkInsideLength; } /** * Sets the inside length of the tick marks and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param length the new length. * * @see #getTickMarkInsideLength() */ public void setTickMarkInsideLength(float length) { this.tickMarkInsideLength = length; fireChangeEvent(); } /** * Returns the outside length of the tick marks. * * @return The length. * * @see #getTickMarkInsideLength() * @see #setTickMarkOutsideLength(float) */ public float getTickMarkOutsideLength() { return this.tickMarkOutsideLength; } /** * Sets the outside length of the tick marks and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param length the new length. * * @see #getTickMarkInsideLength() */ public void setTickMarkOutsideLength(float length) { this.tickMarkOutsideLength = length; fireChangeEvent(); } /** * Returns the stroke used to draw tick marks. * * @return The stroke (never null). * * @see #setTickMarkStroke(Stroke) */ public Stroke getTickMarkStroke() { return this.tickMarkStroke; } /** * Sets the stroke used to draw tick marks and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getTickMarkStroke() */ public void setTickMarkStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } if (!this.tickMarkStroke.equals(stroke)) { this.tickMarkStroke = stroke; fireChangeEvent(); } } /** * Returns the paint used to draw tick marks (if they are showing). * * @return The paint (never null). * * @see #setTickMarkPaint(Paint) */ public Paint getTickMarkPaint() { return this.tickMarkPaint; } /** * Sets the paint used to draw tick marks and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getTickMarkPaint() */ public void setTickMarkPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.tickMarkPaint = paint; fireChangeEvent(); } /** * Returns the inside length of the minor tick marks. * * @return The length. * * @see #getMinorTickMarkOutsideLength() * @see #setMinorTickMarkInsideLength(float) * * @since 1.0.12 */ public float getMinorTickMarkInsideLength() { return this.minorTickMarkInsideLength; } /** * Sets the inside length of the minor tick marks and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param length the new length. * * @see #getMinorTickMarkInsideLength() * * @since 1.0.12 */ public void setMinorTickMarkInsideLength(float length) { this.minorTickMarkInsideLength = length; fireChangeEvent(); } /** * Returns the outside length of the minor tick marks. * * @return The length. * * @see #getMinorTickMarkInsideLength() * @see #setMinorTickMarkOutsideLength(float) * * @since 1.0.12 */ public float getMinorTickMarkOutsideLength() { return this.minorTickMarkOutsideLength; } /** * Sets the outside length of the minor tick marks and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param length the new length. * * @see #getMinorTickMarkInsideLength() * * @since 1.0.12 */ public void setMinorTickMarkOutsideLength(float length) { this.minorTickMarkOutsideLength = length; fireChangeEvent(); } /** * Returns the plot that the axis is assigned to. This method will return * null if the axis is not currently assigned to a plot. * * @return The plot that the axis is assigned to (possibly * null). * * @see #setPlot(Plot) */ public Plot getPlot() { return this.plot; } /** * Sets a reference to the plot that the axis is assigned to. *

* This method is used internally, you shouldn't need to call it yourself. * * @param plot the plot. * * @see #getPlot() */ public void setPlot(Plot plot) { this.plot = plot; configure(); } /** * Returns the fixed dimension for the axis. * * @return The fixed dimension. * * @see #setFixedDimension(double) */ public double getFixedDimension() { return this.fixedDimension; } /** * Sets the fixed dimension for the axis. *

* This is used when combining more than one plot on a chart. In this case, * there may be several axes that need to have the same height or width so * that they are aligned. This method is used to fix a dimension for the * axis (the context determines whether the dimension is horizontal or * vertical). * * @param dimension the fixed dimension. * * @see #getFixedDimension() */ public void setFixedDimension(double dimension) { this.fixedDimension = dimension; } /** * Configures the axis to work with the current plot. Override this method * to perform any special processing (such as auto-rescaling). */ public abstract void configure(); /** * Estimates the space (height or width) required to draw the axis. * * @param g2 the graphics device. * @param plot the plot that the axis belongs to. * @param plotArea the area within which the plot (including axes) should * be drawn. * @param edge the axis location. * @param space space already reserved. * * @return The space required to draw the axis (including pre-reserved * space). */ public abstract AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space); /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location (determines where to draw the axis). * @param plotArea the area within which the axes and plot should be drawn. * @param dataArea the area within which the data should be drawn. * @param edge the axis location (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public abstract AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState); /** * Calculates the positions of the ticks for the axis, storing the results * in the tick list (ready for drawing). * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the area inside the axes. * @param edge the edge on which the axis is located. * * @return The list of ticks. */ public abstract List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge); /** * Created an entity for the axis. * * @param cursor the initial cursor value. * @param state the axis state after completion of the drawing with a * possibly updated cursor position. * @param dataArea the data area. * @param edge the edge. * @param plotState the PlotRenderingInfo from which a reference to the * entity collection can be obtained. * * @since 1.0.13 */ protected void createAndAddEntity(double cursor, AxisState state, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState){ if (plotState == null || plotState.getOwner() == null) { return; // no need to create entity if we can´t save it anyways... } Rectangle2D hotspot = null; if (edge.equals(RectangleEdge.TOP)){ hotspot = new Rectangle2D.Double(dataArea.getX(), state.getCursor(), dataArea.getWidth(), cursor - state.getCursor()); } else if(edge.equals(RectangleEdge.BOTTOM)) { hotspot = new Rectangle2D.Double(dataArea.getX(), cursor, dataArea.getWidth(), state.getCursor() - cursor); } else if(edge.equals(RectangleEdge.LEFT)) { hotspot = new Rectangle2D.Double(state.getCursor(), dataArea.getY(), cursor - state.getCursor(), dataArea.getHeight()); } else if(edge.equals(RectangleEdge.RIGHT)){ hotspot = new Rectangle2D.Double(cursor, dataArea.getY(), state.getCursor() - cursor, dataArea.getHeight()); } EntityCollection e = plotState.getOwner().getEntityCollection(); if (e != null) { e.add(new AxisEntity(hotspot, this)); } } /** * Registers an object for notification of changes to the axis. * * @param listener the object that is being registered. * * @see #removeChangeListener(AxisChangeListener) */ public void addChangeListener(AxisChangeListener listener) { this.listenerList.add(AxisChangeListener.class, listener); } /** * Deregisters an object for notification of changes to the axis. * * @param listener the object to deregister. * * @see #addChangeListener(AxisChangeListener) */ public void removeChangeListener(AxisChangeListener listener) { this.listenerList.remove(AxisChangeListener.class, listener); } /** * Returns true if the specified object is registered with * the dataset as a listener. Most applications won't need to call this * method, it exists mainly for use by unit testing code. * * @param listener the listener. * * @return A boolean. */ public boolean hasListener(EventListener listener) { List list = Arrays.asList(this.listenerList.getListenerList()); return list.contains(listener); } /** * Notifies all registered listeners that the axis has changed. * The AxisChangeEvent provides information about the change. * * @param event information about the change to the axis. */ protected void notifyListeners(AxisChangeEvent event) { Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == AxisChangeListener.class) { ((AxisChangeListener) listeners[i + 1]).axisChanged(event); } } } /** * Sends an {@link AxisChangeEvent} to all registered listeners. * * @since 1.0.12 */ protected void fireChangeEvent() { notifyListeners(new AxisChangeEvent(this)); } /** * Returns a rectangle that encloses the axis label. This is typically * used for layout purposes (it gives the maximum dimensions of the label). * * @param g2 the graphics device. * @param edge the edge of the plot area along which the axis is measuring. * * @return The enclosing rectangle. */ protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) { Rectangle2D result = new Rectangle2D.Double(); String axisLabel = getLabel(); if (axisLabel != null && !axisLabel.equals("")) { FontMetrics fm = g2.getFontMetrics(getLabelFont()); Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm); RectangleInsets insets = getLabelInsets(); bounds = insets.createOutsetRectangle(bounds); double angle = getLabelAngle(); if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { angle = angle - Math.PI / 2.0; } double x = bounds.getCenterX(); double y = bounds.getCenterY(); AffineTransform transformer = AffineTransform.getRotateInstance(angle, x, y); Shape labelBounds = transformer.createTransformedShape(bounds); result = labelBounds.getBounds2D(); } return result; } /** * Draws the axis label. * * @param label the label text. * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the area inside the axes. * @param edge the location of the axis. * @param state the axis state (null not permitted). * * @return Information about the axis. */ protected AxisState drawLabel(String label, Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state) { // it is unlikely that 'state' will be null, but check anyway... if (state == null) { throw new IllegalArgumentException("Null 'state' argument."); } if ((label == null) || (label.equals(""))) { return state; } Font font = getLabelFont(); RectangleInsets insets = getLabelInsets(); g2.setFont(font); g2.setPaint(getLabelPaint()); FontMetrics fm = g2.getFontMetrics(); Rectangle2D labelBounds = TextUtilities.getTextBounds(label, g2, fm); if (edge == RectangleEdge.TOP) { AffineTransform t = AffineTransform.getRotateInstance( getLabelAngle(), labelBounds.getCenterX(), labelBounds.getCenterY()); Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); labelBounds = rotatedLabelBounds.getBounds2D(); double labelx = dataArea.getCenterX(); double labely = state.getCursor() - insets.getBottom() - labelBounds.getHeight() / 2.0; TextUtilities.drawRotatedString(label, g2, (float) labelx, (float) labely, TextAnchor.CENTER, getLabelAngle(), TextAnchor.CENTER); state.cursorUp(insets.getTop() + labelBounds.getHeight() + insets.getBottom()); } else if (edge == RectangleEdge.BOTTOM) { AffineTransform t = AffineTransform.getRotateInstance( getLabelAngle(), labelBounds.getCenterX(), labelBounds.getCenterY()); Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); labelBounds = rotatedLabelBounds.getBounds2D(); double labelx = dataArea.getCenterX(); double labely = state.getCursor() + insets.getTop() + labelBounds.getHeight() / 2.0; TextUtilities.drawRotatedString(label, g2, (float) labelx, (float) labely, TextAnchor.CENTER, getLabelAngle(), TextAnchor.CENTER); state.cursorDown(insets.getTop() + labelBounds.getHeight() + insets.getBottom()); } else if (edge == RectangleEdge.LEFT) { AffineTransform t = AffineTransform.getRotateInstance( getLabelAngle() - Math.PI / 2.0, labelBounds.getCenterX(), labelBounds.getCenterY()); Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); labelBounds = rotatedLabelBounds.getBounds2D(); double labelx = state.getCursor() - insets.getRight() - labelBounds.getWidth() / 2.0; double labely = dataArea.getCenterY(); TextUtilities.drawRotatedString(label, g2, (float) labelx, (float) labely, TextAnchor.CENTER, getLabelAngle() - Math.PI / 2.0, TextAnchor.CENTER); state.cursorLeft(insets.getLeft() + labelBounds.getWidth() + insets.getRight()); } else if (edge == RectangleEdge.RIGHT) { AffineTransform t = AffineTransform.getRotateInstance( getLabelAngle() + Math.PI / 2.0, labelBounds.getCenterX(), labelBounds.getCenterY()); Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); labelBounds = rotatedLabelBounds.getBounds2D(); double labelx = state.getCursor() + insets.getLeft() + labelBounds.getWidth() / 2.0; double labely = dataArea.getY() + dataArea.getHeight() / 2.0; TextUtilities.drawRotatedString(label, g2, (float) labelx, (float) labely, TextAnchor.CENTER, getLabelAngle() + Math.PI / 2.0, TextAnchor.CENTER); state.cursorRight(insets.getLeft() + labelBounds.getWidth() + insets.getRight()); } return state; } /** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(axisLine); } /** * Returns a clone of the axis. * * @return A clone. * * @throws CloneNotSupportedException if some component of the axis does * not support cloning. */ public Object clone() throws CloneNotSupportedException { Axis clone = (Axis) super.clone(); // It's up to the plot which clones up to restore the correct references clone.plot = null; clone.listenerList = new EventListenerList(); return clone; } /** * Tests this axis for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Axis)) { return false; } Axis that = (Axis) obj; if (this.visible != that.visible) { return false; } if (!ObjectUtilities.equal(this.label, that.label)) { return false; } if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { return false; } if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { return false; } if (!ObjectUtilities.equal(this.labelInsets, that.labelInsets)) { return false; } if (this.labelAngle != that.labelAngle) { return false; } if (this.axisLineVisible != that.axisLineVisible) { return false; } if (!ObjectUtilities.equal(this.axisLineStroke, that.axisLineStroke)) { return false; } if (!PaintUtilities.equal(this.axisLinePaint, that.axisLinePaint)) { return false; } if (this.tickLabelsVisible != that.tickLabelsVisible) { return false; } if (!ObjectUtilities.equal(this.tickLabelFont, that.tickLabelFont)) { return false; } if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { return false; } if (!ObjectUtilities.equal( this.tickLabelInsets, that.tickLabelInsets )) { return false; } if (this.tickMarksVisible != that.tickMarksVisible) { return false; } if (this.tickMarkInsideLength != that.tickMarkInsideLength) { return false; } if (this.tickMarkOutsideLength != that.tickMarkOutsideLength) { return false; } if (!PaintUtilities.equal(this.tickMarkPaint, that.tickMarkPaint)) { return false; } if (!ObjectUtilities.equal(this.tickMarkStroke, that.tickMarkStroke)) { return false; } if (this.minorTickMarksVisible != that.minorTickMarksVisible) { return false; } if (this.minorTickMarkInsideLength != that.minorTickMarkInsideLength) { return false; } if (this.minorTickMarkOutsideLength != that.minorTickMarkOutsideLength) { return false; } if (this.fixedDimension != that.fixedDimension) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.labelPaint, stream); SerialUtilities.writePaint(this.tickLabelPaint, stream); SerialUtilities.writeStroke(this.axisLineStroke, stream); SerialUtilities.writePaint(this.axisLinePaint, stream); SerialUtilities.writeStroke(this.tickMarkStroke, stream); SerialUtilities.writePaint(this.tickMarkPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.labelPaint = SerialUtilities.readPaint(stream); this.tickLabelPaint = SerialUtilities.readPaint(stream); this.axisLineStroke = SerialUtilities.readStroke(stream); this.axisLinePaint = SerialUtilities.readPaint(stream); this.tickMarkStroke = SerialUtilities.readStroke(stream); this.tickMarkPaint = SerialUtilities.readPaint(stream); this.listenerList = new EventListenerList(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/AxisCollection.java0000644000175000017500000001064011173030414027161 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * AxisCollection.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2003 : Added standard header (DG); * */ package org.jfree.chart.axis; import java.util.List; import org.jfree.ui.RectangleEdge; /** * A collection of axes that have been assigned to the TOP, BOTTOM, LEFT or * RIGHT of a chart. This class is used internally by JFreeChart, you won't * normally need to use it yourself. */ public class AxisCollection { /** The axes that need to be drawn at the top of the plot area. */ private List axesAtTop; /** The axes that need to be drawn at the bottom of the plot area. */ private List axesAtBottom; /** The axes that need to be drawn at the left of the plot area. */ private List axesAtLeft; /** The axes that need to be drawn at the right of the plot area. */ private List axesAtRight; /** * Creates a new empty collection. */ public AxisCollection() { this.axesAtTop = new java.util.ArrayList(); this.axesAtBottom = new java.util.ArrayList(); this.axesAtLeft = new java.util.ArrayList(); this.axesAtRight = new java.util.ArrayList(); } /** * Returns a list of the axes (if any) that need to be drawn at the top of * the plot area. * * @return A list of axes. */ public List getAxesAtTop() { return this.axesAtTop; } /** * Returns a list of the axes (if any) that need to be drawn at the bottom * of the plot area. * * @return A list of axes. */ public List getAxesAtBottom() { return this.axesAtBottom; } /** * Returns a list of the axes (if any) that need to be drawn at the left * of the plot area. * * @return A list of axes. */ public List getAxesAtLeft() { return this.axesAtLeft; } /** * Returns a list of the axes (if any) that need to be drawn at the right * of the plot area. * * @return A list of axes. */ public List getAxesAtRight() { return this.axesAtRight; } /** * Adds an axis to the collection. * * @param axis the axis (null not permitted). * @param edge the edge of the plot that the axis should be drawn on * (null not permitted). */ public void add(Axis axis, RectangleEdge edge) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } if (edge == null) { throw new IllegalArgumentException("Null 'edge' argument."); } if (edge == RectangleEdge.TOP) { this.axesAtTop.add(axis); } else if (edge == RectangleEdge.BOTTOM) { this.axesAtBottom.add(axis); } else if (edge == RectangleEdge.LEFT) { this.axesAtLeft.add(axis); } else if (edge == RectangleEdge.RIGHT) { this.axesAtRight.add(axis); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/AxisLocation.java0000644000175000017500000001356011173030414026642 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * AxisLocation.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nick Guenther; * * Changes: * -------- * 02-May-2003 : Version 1 (DG); * 03-Jul-2003 : Added isTopOrBottom() and isLeftOrRight() methods (DG); * 13-Aug-2003 : Fixed readResolve() bug (id=788202) (DG); * 24-Mar-2004 : Added static getOpposite() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 22-Mar-2007 : Added getOpposite() method, suggested by Nick Guenther (DG); * */ package org.jfree.chart.axis; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the location of an axis on a 2D plot, prior to knowing the * orientation of the plot. */ public final class AxisLocation implements Serializable { /** For serialization. */ private static final long serialVersionUID = -3276922179323563410L; /** Axis at the top or left. */ public static final AxisLocation TOP_OR_LEFT = new AxisLocation( "AxisLocation.TOP_OR_LEFT"); /** Axis at the top or right. */ public static final AxisLocation TOP_OR_RIGHT = new AxisLocation( "AxisLocation.TOP_OR_RIGHT"); /** Axis at the bottom or left. */ public static final AxisLocation BOTTOM_OR_LEFT = new AxisLocation( "AxisLocation.BOTTOM_OR_LEFT"); /** Axis at the bottom or right. */ public static final AxisLocation BOTTOM_OR_RIGHT = new AxisLocation( "AxisLocation.BOTTOM_OR_RIGHT"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private AxisLocation(String name) { this.name = name; } /** * Returns the location that is opposite to this location. * * @return The opposite location. * * @since 1.0.5 */ public AxisLocation getOpposite() { return getOpposite(this); } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof AxisLocation)) { return false; } AxisLocation location = (AxisLocation) obj; if (!this.name.equals(location.toString())) { return false; } return true; } /** * Returns the location that is opposite to the supplied location. * * @param location the location (null not permitted). * * @return The opposite location. */ public static AxisLocation getOpposite(AxisLocation location) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } AxisLocation result = null; if (location == AxisLocation.TOP_OR_LEFT) { result = AxisLocation.BOTTOM_OR_RIGHT; } else if (location == AxisLocation.TOP_OR_RIGHT) { result = AxisLocation.BOTTOM_OR_LEFT; } else if (location == AxisLocation.BOTTOM_OR_LEFT) { result = AxisLocation.TOP_OR_RIGHT; } else if (location == AxisLocation.BOTTOM_OR_RIGHT) { result = AxisLocation.TOP_OR_LEFT; } else { throw new IllegalStateException("AxisLocation not recognised."); } return result; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(AxisLocation.TOP_OR_RIGHT)) { return AxisLocation.TOP_OR_RIGHT; } else if (this.equals(AxisLocation.BOTTOM_OR_RIGHT)) { return AxisLocation.BOTTOM_OR_RIGHT; } else if (this.equals(AxisLocation.TOP_OR_LEFT)) { return AxisLocation.TOP_OR_LEFT; } else if (this.equals(AxisLocation.BOTTOM_OR_LEFT)) { return AxisLocation.BOTTOM_OR_LEFT; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/AxisSpace.java0000644000175000017500000002601611173030414026125 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * AxisSpace.java * -------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Jul-2003 : Version 1 (DG); * 14-Aug-2003 : Implemented Cloneable (DG); * 18-Aug-2003 : Implemented Serializable (DG); * 17-Mar-2004 : Added a toString() method for debugging (DG); * 07-Jan-2005 : Updated equals() method (DG); * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * */ package org.jfree.chart.axis; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A record that contains the space required at each edge of a plot. */ public class AxisSpace implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2490732595134766305L; /** The top space. */ private double top; /** The bottom space. */ private double bottom; /** The left space. */ private double left; /** The right space. */ private double right; /** * Creates a new axis space record. */ public AxisSpace() { this.top = 0.0; this.bottom = 0.0; this.left = 0.0; this.right = 0.0; } /** * Returns the space reserved for axes at the top of the plot area. * * @return The space (in Java2D units). */ public double getTop() { return this.top; } /** * Sets the space reserved for axes at the top of the plot area. * * @param space the space (in Java2D units). */ public void setTop(double space) { this.top = space; } /** * Returns the space reserved for axes at the bottom of the plot area. * * @return The space (in Java2D units). */ public double getBottom() { return this.bottom; } /** * Sets the space reserved for axes at the bottom of the plot area. * * @param space the space (in Java2D units). */ public void setBottom(double space) { this.bottom = space; } /** * Returns the space reserved for axes at the left of the plot area. * * @return The space (in Java2D units). */ public double getLeft() { return this.left; } /** * Sets the space reserved for axes at the left of the plot area. * * @param space the space (in Java2D units). */ public void setLeft(double space) { this.left = space; } /** * Returns the space reserved for axes at the right of the plot area. * * @return The space (in Java2D units). */ public double getRight() { return this.right; } /** * Sets the space reserved for axes at the right of the plot area. * * @param space the space (in Java2D units). */ public void setRight(double space) { this.right = space; } /** * Adds space to the top, bottom, left or right edge of the plot area. * * @param space the space (in Java2D units). * @param edge the edge (null not permitted). */ public void add(double space, RectangleEdge edge) { if (edge == null) { throw new IllegalArgumentException("Null 'edge' argument."); } if (edge == RectangleEdge.TOP) { this.top += space; } else if (edge == RectangleEdge.BOTTOM) { this.bottom += space; } else if (edge == RectangleEdge.LEFT) { this.left += space; } else if (edge == RectangleEdge.RIGHT) { this.right += space; } else { throw new IllegalStateException("Unrecognised 'edge' argument."); } } /** * Ensures that this object reserves at least as much space as another. * * @param space the other space. */ public void ensureAtLeast(AxisSpace space) { this.top = Math.max(this.top, space.top); this.bottom = Math.max(this.bottom, space.bottom); this.left = Math.max(this.left, space.left); this.right = Math.max(this.right, space.right); } /** * Ensures there is a minimum amount of space at the edge corresponding to * the specified axis location. * * @param space the space. * @param edge the location. */ public void ensureAtLeast(double space, RectangleEdge edge) { if (edge == RectangleEdge.TOP) { if (this.top < space) { this.top = space; } } else if (edge == RectangleEdge.BOTTOM) { if (this.bottom < space) { this.bottom = space; } } else if (edge == RectangleEdge.LEFT) { if (this.left < space) { this.left = space; } } else if (edge == RectangleEdge.RIGHT) { if (this.right < space) { this.right = space; } } else { throw new IllegalStateException( "AxisSpace.ensureAtLeast(): unrecognised AxisLocation." ); } } /** * Shrinks an area by the space attributes. * * @param area the area to shrink. * @param result an optional carrier for the result. * * @return The result. */ public Rectangle2D shrink(Rectangle2D area, Rectangle2D result) { if (result == null) { result = new Rectangle2D.Double(); } result.setRect( area.getX() + this.left, area.getY() + this.top, area.getWidth() - this.left - this.right, area.getHeight() - this.top - this.bottom ); return result; } /** * Expands an area by the amount of space represented by this object. * * @param area the area to expand. * @param result an optional carrier for the result. * * @return The result. */ public Rectangle2D expand(Rectangle2D area, Rectangle2D result) { if (result == null) { result = new Rectangle2D.Double(); } result.setRect( area.getX() - this.left, area.getY() - this.top, area.getWidth() + this.left + this.right, area.getHeight() + this.top + this.bottom ); return result; } /** * Calculates the reserved area. * * @param area the area. * @param edge the edge. * * @return The reserved area. */ public Rectangle2D reserved(Rectangle2D area, RectangleEdge edge) { Rectangle2D result = null; if (edge == RectangleEdge.TOP) { result = new Rectangle2D.Double( area.getX(), area.getY(), area.getWidth(), this.top ); } else if (edge == RectangleEdge.BOTTOM) { result = new Rectangle2D.Double( area.getX(), area.getMaxY() - this.top, area.getWidth(), this.bottom ); } else if (edge == RectangleEdge.LEFT) { result = new Rectangle2D.Double( area.getX(), area.getY(), this.left, area.getHeight() ); } else if (edge == RectangleEdge.RIGHT) { result = new Rectangle2D.Double( area.getMaxX() - this.right, area.getY(), this.right, area.getHeight() ); } return result; } /** * Returns a clone of the object. * * @return A clone. * * @throws CloneNotSupportedException This class won't throw this exception, * but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with another object. * * @param obj the object to compare against. * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AxisSpace)) { return false; } AxisSpace that = (AxisSpace) obj; if (this.top != that.top) { return false; } if (this.bottom != that.bottom) { return false; } if (this.left != that.left) { return false; } if (this.right != that.right) { return false; } return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 23; long l = Double.doubleToLongBits(this.top); result = 37 * result + (int) (l ^ (l >>> 32)); l = Double.doubleToLongBits(this.bottom); result = 37 * result + (int) (l ^ (l >>> 32)); l = Double.doubleToLongBits(this.left); result = 37 * result + (int) (l ^ (l >>> 32)); l = Double.doubleToLongBits(this.right); result = 37 * result + (int) (l ^ (l >>> 32)); return result; } /** * Returns a string representing the object (for debugging purposes). * * @return A string. */ public String toString() { return super.toString() + "[left=" + this.left + ",right=" + this.right + ",top=" + this.top + ",bottom=" + this.bottom + "]"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/AxisState.java0000644000175000017500000001175411173030414026155 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * AxisState.java * -------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2003 : Added standard header (DG); * 07-Nov-2003 : Added 'max' attribute (DG); * */ package org.jfree.chart.axis; import java.util.List; import org.jfree.ui.RectangleEdge; /** * Instances of this class are used to carry state information for an axis * during the drawing process. By retaining this information in a separate * object, it is possible for multiple threads to draw the same axis to * different output targets (each drawing will maintain separate state * information). */ public class AxisState { /** The cursor position. */ private double cursor; /** The axis ticks. */ private List ticks; /** The maximum width/height. */ private double max; /** * Creates a new axis state. */ public AxisState() { this(0.0); } /** * Creates a new axis state. * * @param cursor the cursor. */ public AxisState(double cursor) { this.cursor = cursor; this.ticks = new java.util.ArrayList(); } /** * Returns the cursor position. * * @return The cursor position. */ public double getCursor() { return this.cursor; } /** * Sets the cursor position. * * @param cursor the cursor position. */ public void setCursor(double cursor) { this.cursor = cursor; } /** * Moves the cursor outwards by the specified number of units. * * @param units the units. * @param edge the edge. */ public void moveCursor(double units, RectangleEdge edge) { if (edge == RectangleEdge.TOP) { cursorUp(units); } else if (edge == RectangleEdge.BOTTOM) { cursorDown(units); } else if (edge == RectangleEdge.LEFT) { cursorLeft(units); } else if (edge == RectangleEdge.RIGHT) { cursorRight(units); } } /** * Moves the cursor up by the specified number of Java 2D units. * * @param units the units. */ public void cursorUp(double units) { this.cursor = this.cursor - units; } /** * Moves the cursor down by the specified number of Java 2D units. * * @param units the units. */ public void cursorDown(double units) { this.cursor = this.cursor + units; } /** * Moves the cursor left by the specified number of Java 2D units. * * @param units the units. */ public void cursorLeft(double units) { this.cursor = this.cursor - units; } /** * Moves the cursor right by the specified number of Java 2D units. * * @param units the units. */ public void cursorRight(double units) { this.cursor = this.cursor + units; } /** * Returns the list of ticks. * * @return The list of ticks. */ public List getTicks() { return this.ticks; } /** * Sets the list of ticks. * * @param ticks the ticks. */ public void setTicks(List ticks) { this.ticks = ticks; } /** * Returns the maximum width/height. * * @return The maximum width/height. */ public double getMax() { return this.max; } /** * Sets the maximum width/height. * * @param max the maximum width/height. */ public void setMax(double max) { this.max = max; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryAnchor.java0000644000175000017500000000752611173030414027162 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CategoryAnchor.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 04-Jul-2003 : Version 1 (DG); * */ package org.jfree.chart.axis; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate one of three positions within a category: * START, MIDDLE and END. */ public final class CategoryAnchor implements Serializable { /** For serialization. */ private static final long serialVersionUID = -2604142742210173810L; /** Start of period. */ public static final CategoryAnchor START = new CategoryAnchor("CategoryAnchor.START"); /** Middle of period. */ public static final CategoryAnchor MIDDLE = new CategoryAnchor("CategoryAnchor.MIDDLE"); /** End of period. */ public static final CategoryAnchor END = new CategoryAnchor("CategoryAnchor.END"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private CategoryAnchor(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof CategoryAnchor)) { return false; } CategoryAnchor position = (CategoryAnchor) obj; if (!this.name.equals(position.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(CategoryAnchor.START)) { return CategoryAnchor.START; } else if (this.equals(CategoryAnchor.MIDDLE)) { return CategoryAnchor.MIDDLE; } else if (this.equals(CategoryAnchor.END)) { return CategoryAnchor.END; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryAxis.java0000644000175000017500000015527511173030414026661 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * CategoryAxis.java * ----------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert; * Contributor(s): Pady Srinivasan (patch 1217634); * Peter Kolb (patches 2497611 and 2603321); * * Changes * ------- * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); * 18-Sep-2001 : Updated header (DG); * 04-Dec-2001 : Changed constructors to protected, and tidied up default * values (DG); * 19-Apr-2002 : Updated import statements (DG); * 05-Sep-2002 : Updated constructor for changes in Axis class (DG); * 06-Nov-2002 : Moved margins from the CategoryPlot class (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 22-Jan-2002 : Removed monolithic constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 09-May-2003 : Merged HorizontalCategoryAxis and VerticalCategoryAxis into * this class (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 05-Nov-2003 : Fixed serialization bug (DG); * 26-Nov-2003 : Added category label offset (DG); * 06-Jan-2004 : Moved axis line attributes to Axis class, rationalised * category label position attributes (DG); * 07-Jan-2004 : Added new implementation for linewrapping of category * labels (DG); * 17-Feb-2004 : Moved deprecated code to bottom of source file (DG); * 10-Mar-2004 : Changed Dimension --> Dimension2D in text classes (DG); * 16-Mar-2004 : Added support for tooltips on category labels (DG); * 01-Apr-2004 : Changed java.awt.geom.Dimension2D to org.jfree.ui.Size2D * because of JDK bug 4976448 which persists on JDK 1.3.1 (DG); * 03-Sep-2004 : Added 'maxCategoryLabelLines' attribute (DG); * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * 21-Jan-2005 : Modified return type for RectangleAnchor.coordinates() * method (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 08-Jun-2005 : Fixed bug in axis layout (DG); * 22-Nov-2005 : Added a method to access the tool tip text for a category * label (DG); * 23-Nov-2005 : Added per-category font and paint options - see patch * 1217634 (DG); * ------------- JFreeChart 1.0.x --------------------------------------------- * 11-Jan-2006 : Fixed null pointer exception in drawCategoryLabels - see bug * 1403043 (DG); * 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan * Joubert (1277726) (DG); * 02-Oct-2006 : Updated category label entity (DG); * 30-Oct-2006 : Updated refreshTicks() method to account for possibility of * multiple domain axes (DG); * 07-Mar-2007 : Fixed bug in axis label positioning (DG); * 27-Sep-2007 : Added getCategorySeriesMiddle() method (DG); * 21-Nov-2007 : Fixed performance bug noted by FindBugs in the * equalPaintMaps() method (DG); * 23-Apr-2008 : Fixed bug 1942059, bad use of insets in * calculateTextBlockWidth() (DG); * 26-Jun-2008 : Added new getCategoryMiddle() method (DG); * 27-Oct-2008 : Set font on Graphics2D when creating category labels (DG); * 14-Jan-2009 : Added new variant of getCategorySeriesMiddle() to make it * simpler for renderers with hidden series (PK); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * 16-Apr-2009 : Added tick mark drawing (DG); * */ package org.jfree.chart.axis; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.jfree.chart.entity.CategoryLabelEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.G2TextMeasurer; import org.jfree.text.TextBlock; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.ShapeUtilities; /** * An axis that displays categories. */ public class CategoryAxis extends Axis implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5886554608114265863L; /** * The default margin for the axis (used for both lower and upper margins). */ public static final double DEFAULT_AXIS_MARGIN = 0.05; /** * The default margin between categories (a percentage of the overall axis * length). */ public static final double DEFAULT_CATEGORY_MARGIN = 0.20; /** The amount of space reserved at the start of the axis. */ private double lowerMargin; /** The amount of space reserved at the end of the axis. */ private double upperMargin; /** The amount of space reserved between categories. */ private double categoryMargin; /** The maximum number of lines for category labels. */ private int maximumCategoryLabelLines; /** * A ratio that is multiplied by the width of one category to determine the * maximum label width. */ private float maximumCategoryLabelWidthRatio; /** The category label offset. */ private int categoryLabelPositionOffset; /** * A structure defining the category label positions for each axis * location. */ private CategoryLabelPositions categoryLabelPositions; /** Storage for tick label font overrides (if any). */ private Map tickLabelFontMap; /** Storage for tick label paint overrides (if any). */ private transient Map tickLabelPaintMap; /** Storage for the category label tooltips (if any). */ private Map categoryLabelToolTips; /** * Creates a new category axis with no label. */ public CategoryAxis() { this(null); } /** * Constructs a category axis, using default values where necessary. * * @param label the axis label (null permitted). */ public CategoryAxis(String label) { super(label); this.lowerMargin = DEFAULT_AXIS_MARGIN; this.upperMargin = DEFAULT_AXIS_MARGIN; this.categoryMargin = DEFAULT_CATEGORY_MARGIN; this.maximumCategoryLabelLines = 1; this.maximumCategoryLabelWidthRatio = 0.0f; this.categoryLabelPositionOffset = 4; this.categoryLabelPositions = CategoryLabelPositions.STANDARD; this.tickLabelFontMap = new HashMap(); this.tickLabelPaintMap = new HashMap(); this.categoryLabelToolTips = new HashMap(); } /** * Returns the lower margin for the axis. * * @return The margin. * * @see #getUpperMargin() * @see #setLowerMargin(double) */ public double getLowerMargin() { return this.lowerMargin; } /** * Sets the lower margin for the axis and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param margin the margin as a percentage of the axis length (for * example, 0.05 is five percent). * * @see #getLowerMargin() */ public void setLowerMargin(double margin) { this.lowerMargin = margin; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the upper margin for the axis. * * @return The margin. * * @see #getLowerMargin() * @see #setUpperMargin(double) */ public double getUpperMargin() { return this.upperMargin; } /** * Sets the upper margin for the axis and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param margin the margin as a percentage of the axis length (for * example, 0.05 is five percent). * * @see #getUpperMargin() */ public void setUpperMargin(double margin) { this.upperMargin = margin; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the category margin. * * @return The margin. * * @see #setCategoryMargin(double) */ public double getCategoryMargin() { return this.categoryMargin; } /** * Sets the category margin and sends an {@link AxisChangeEvent} to all * registered listeners. The overall category margin is distributed over * N-1 gaps, where N is the number of categories on the axis. * * @param margin the margin as a percentage of the axis length (for * example, 0.05 is five percent). * * @see #getCategoryMargin() */ public void setCategoryMargin(double margin) { this.categoryMargin = margin; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the maximum number of lines to use for each category label. * * @return The maximum number of lines. * * @see #setMaximumCategoryLabelLines(int) */ public int getMaximumCategoryLabelLines() { return this.maximumCategoryLabelLines; } /** * Sets the maximum number of lines to use for each category label and * sends an {@link AxisChangeEvent} to all registered listeners. * * @param lines the maximum number of lines. * * @see #getMaximumCategoryLabelLines() */ public void setMaximumCategoryLabelLines(int lines) { this.maximumCategoryLabelLines = lines; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the category label width ratio. * * @return The ratio. * * @see #setMaximumCategoryLabelWidthRatio(float) */ public float getMaximumCategoryLabelWidthRatio() { return this.maximumCategoryLabelWidthRatio; } /** * Sets the maximum category label width ratio and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param ratio the ratio. * * @see #getMaximumCategoryLabelWidthRatio() */ public void setMaximumCategoryLabelWidthRatio(float ratio) { this.maximumCategoryLabelWidthRatio = ratio; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the offset between the axis and the category labels (before * label positioning is taken into account). * * @return The offset (in Java2D units). * * @see #setCategoryLabelPositionOffset(int) */ public int getCategoryLabelPositionOffset() { return this.categoryLabelPositionOffset; } /** * Sets the offset between the axis and the category labels (before label * positioning is taken into account). * * @param offset the offset (in Java2D units). * * @see #getCategoryLabelPositionOffset() */ public void setCategoryLabelPositionOffset(int offset) { this.categoryLabelPositionOffset = offset; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the category label position specification (this contains label * positioning info for all four possible axis locations). * * @return The positions (never null). * * @see #setCategoryLabelPositions(CategoryLabelPositions) */ public CategoryLabelPositions getCategoryLabelPositions() { return this.categoryLabelPositions; } /** * Sets the category label position specification for the axis and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param positions the positions (null not permitted). * * @see #getCategoryLabelPositions() */ public void setCategoryLabelPositions(CategoryLabelPositions positions) { if (positions == null) { throw new IllegalArgumentException("Null 'positions' argument."); } this.categoryLabelPositions = positions; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the font for the tick label for the given category. * * @param category the category (null not permitted). * * @return The font (never null). * * @see #setTickLabelFont(Comparable, Font) */ public Font getTickLabelFont(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } Font result = (Font) this.tickLabelFontMap.get(category); // if there is no specific font, use the general one... if (result == null) { result = getTickLabelFont(); } return result; } /** * Sets the font for the tick label for the specified category and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param category the category (null not permitted). * @param font the font (null permitted). * * @see #getTickLabelFont(Comparable) */ public void setTickLabelFont(Comparable category, Font font) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } if (font == null) { this.tickLabelFontMap.remove(category); } else { this.tickLabelFontMap.put(category, font); } notifyListeners(new AxisChangeEvent(this)); } /** * Returns the paint for the tick label for the given category. * * @param category the category (null not permitted). * * @return The paint (never null). * * @see #setTickLabelPaint(Paint) */ public Paint getTickLabelPaint(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } Paint result = (Paint) this.tickLabelPaintMap.get(category); // if there is no specific paint, use the general one... if (result == null) { result = getTickLabelPaint(); } return result; } /** * Sets the paint for the tick label for the specified category and sends * an {@link AxisChangeEvent} to all registered listeners. * * @param category the category (null not permitted). * @param paint the paint (null permitted). * * @see #getTickLabelPaint(Comparable) */ public void setTickLabelPaint(Comparable category, Paint paint) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } if (paint == null) { this.tickLabelPaintMap.remove(category); } else { this.tickLabelPaintMap.put(category, paint); } notifyListeners(new AxisChangeEvent(this)); } /** * Adds a tooltip to the specified category and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param category the category (null not permitted). * @param tooltip the tooltip text (null permitted). * * @see #removeCategoryLabelToolTip(Comparable) */ public void addCategoryLabelToolTip(Comparable category, String tooltip) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.categoryLabelToolTips.put(category, tooltip); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the tool tip text for the label belonging to the specified * category. * * @param category the category (null not permitted). * * @return The tool tip text (possibly null). * * @see #addCategoryLabelToolTip(Comparable, String) * @see #removeCategoryLabelToolTip(Comparable) */ public String getCategoryLabelToolTip(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } return (String) this.categoryLabelToolTips.get(category); } /** * Removes the tooltip for the specified category and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param category the category (null not permitted). * * @see #addCategoryLabelToolTip(Comparable, String) * @see #clearCategoryLabelToolTips() */ public void removeCategoryLabelToolTip(Comparable category) { if (category == null) { throw new IllegalArgumentException("Null 'category' argument."); } this.categoryLabelToolTips.remove(category); notifyListeners(new AxisChangeEvent(this)); } /** * Clears the category label tooltips and sends an {@link AxisChangeEvent} * to all registered listeners. * * @see #addCategoryLabelToolTip(Comparable, String) * @see #removeCategoryLabelToolTip(Comparable) */ public void clearCategoryLabelToolTips() { this.categoryLabelToolTips.clear(); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the Java 2D coordinate for a category. * * @param anchor the anchor point. * @param category the category index. * @param categoryCount the category count. * @param area the data area. * @param edge the location of the axis. * * @return The coordinate. */ public double getCategoryJava2DCoordinate(CategoryAnchor anchor, int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { double result = 0.0; if (anchor == CategoryAnchor.START) { result = getCategoryStart(category, categoryCount, area, edge); } else if (anchor == CategoryAnchor.MIDDLE) { result = getCategoryMiddle(category, categoryCount, area, edge); } else if (anchor == CategoryAnchor.END) { result = getCategoryEnd(category, categoryCount, area, edge); } return result; } /** * Returns the starting coordinate for the specified category. * * @param category the category. * @param categoryCount the number of categories. * @param area the data area. * @param edge the axis location. * * @return The coordinate. * * @see #getCategoryMiddle(int, int, Rectangle2D, RectangleEdge) * @see #getCategoryEnd(int, int, Rectangle2D, RectangleEdge) */ public double getCategoryStart(int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { double result = 0.0; if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) { result = area.getX() + area.getWidth() * getLowerMargin(); } else if ((edge == RectangleEdge.LEFT) || (edge == RectangleEdge.RIGHT)) { result = area.getMinY() + area.getHeight() * getLowerMargin(); } double categorySize = calculateCategorySize(categoryCount, area, edge); double categoryGapWidth = calculateCategoryGapSize(categoryCount, area, edge); result = result + category * (categorySize + categoryGapWidth); return result; } /** * Returns the middle coordinate for the specified category. * * @param category the category. * @param categoryCount the number of categories. * @param area the data area. * @param edge the axis location. * * @return The coordinate. * * @see #getCategoryStart(int, int, Rectangle2D, RectangleEdge) * @see #getCategoryEnd(int, int, Rectangle2D, RectangleEdge) */ public double getCategoryMiddle(int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { if (category < 0 || category >= categoryCount) { throw new IllegalArgumentException("Invalid category index: " + category); } return getCategoryStart(category, categoryCount, area, edge) + calculateCategorySize(categoryCount, area, edge) / 2; } /** * Returns the end coordinate for the specified category. * * @param category the category. * @param categoryCount the number of categories. * @param area the data area. * @param edge the axis location. * * @return The coordinate. * * @see #getCategoryStart(int, int, Rectangle2D, RectangleEdge) * @see #getCategoryMiddle(int, int, Rectangle2D, RectangleEdge) */ public double getCategoryEnd(int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { return getCategoryStart(category, categoryCount, area, edge) + calculateCategorySize(categoryCount, area, edge); } /** * A convenience method that returns the axis coordinate for the centre of * a category. * * @param category the category key (null not permitted). * @param categories the categories (null not permitted). * @param area the data area (null not permitted). * @param edge the edge along which the axis lies (null not * permitted). * * @return The centre coordinate. * * @since 1.0.11 * * @see #getCategorySeriesMiddle(Comparable, Comparable, CategoryDataset, * double, Rectangle2D, RectangleEdge) */ public double getCategoryMiddle(Comparable category, List categories, Rectangle2D area, RectangleEdge edge) { if (categories == null) { throw new IllegalArgumentException("Null 'categories' argument."); } int categoryIndex = categories.indexOf(category); int categoryCount = categories.size(); return getCategoryMiddle(categoryIndex, categoryCount, area, edge); } /** * Returns the middle coordinate (in Java2D space) for a series within a * category. * * @param category the category (null not permitted). * @param seriesKey the series key (null not permitted). * @param dataset the dataset (null not permitted). * @param itemMargin the item margin (0.0 <= itemMargin < 1.0); * @param area the area (null not permitted). * @param edge the edge (null not permitted). * * @return The coordinate in Java2D space. * * @since 1.0.7 */ public double getCategorySeriesMiddle(Comparable category, Comparable seriesKey, CategoryDataset dataset, double itemMargin, Rectangle2D area, RectangleEdge edge) { int categoryIndex = dataset.getColumnIndex(category); int categoryCount = dataset.getColumnCount(); int seriesIndex = dataset.getRowIndex(seriesKey); int seriesCount = dataset.getRowCount(); double start = getCategoryStart(categoryIndex, categoryCount, area, edge); double end = getCategoryEnd(categoryIndex, categoryCount, area, edge); double width = end - start; if (seriesCount == 1) { return start + width / 2.0; } else { double gap = (width * itemMargin) / (seriesCount - 1); double ww = (width * (1 - itemMargin)) / seriesCount; return start + (seriesIndex * (ww + gap)) + ww / 2.0; } } /** * Returns the middle coordinate (in Java2D space) for a series within a * category. * * @param categoryIndex the category index. * @param categoryCount the category count. * @param seriesIndex the series index. * @param seriesCount the series count. * @param itemMargin the item margin (0.0 <= itemMargin < 1.0); * @param area the area (null not permitted). * @param edge the edge (null not permitted). * * @return The coordinate in Java2D space. * * @since 1.0.13 */ public double getCategorySeriesMiddle(int categoryIndex, int categoryCount, int seriesIndex, int seriesCount, double itemMargin, Rectangle2D area, RectangleEdge edge) { double start = getCategoryStart(categoryIndex, categoryCount, area, edge); double end = getCategoryEnd(categoryIndex, categoryCount, area, edge); double width = end - start; if (seriesCount == 1) { return start + width / 2.0; } else { double gap = (width * itemMargin) / (seriesCount - 1); double ww = (width * (1 - itemMargin)) / seriesCount; return start + (seriesIndex * (ww + gap)) + ww / 2.0; } } /** * Calculates the size (width or height, depending on the location of the * axis) of a category. * * @param categoryCount the number of categories. * @param area the area within which the categories will be drawn. * @param edge the axis location. * * @return The category size. */ protected double calculateCategorySize(int categoryCount, Rectangle2D area, RectangleEdge edge) { double result = 0.0; double available = 0.0; if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) { available = area.getWidth(); } else if ((edge == RectangleEdge.LEFT) || (edge == RectangleEdge.RIGHT)) { available = area.getHeight(); } if (categoryCount > 1) { result = available * (1 - getLowerMargin() - getUpperMargin() - getCategoryMargin()); result = result / categoryCount; } else { result = available * (1 - getLowerMargin() - getUpperMargin()); } return result; } /** * Calculates the size (width or height, depending on the location of the * axis) of a category gap. * * @param categoryCount the number of categories. * @param area the area within which the categories will be drawn. * @param edge the axis location. * * @return The category gap width. */ protected double calculateCategoryGapSize(int categoryCount, Rectangle2D area, RectangleEdge edge) { double result = 0.0; double available = 0.0; if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) { available = area.getWidth(); } else if ((edge == RectangleEdge.LEFT) || (edge == RectangleEdge.RIGHT)) { available = area.getHeight(); } if (categoryCount > 1) { result = available * getCategoryMargin() / (categoryCount - 1); } return result; } /** * Estimates the space required for the axis, given a specific drawing area. * * @param g2 the graphics device (used to obtain font information). * @param plot the plot that the axis belongs to. * @param plotArea the area within which the axis should be drawn. * @param edge the axis location (top or bottom). * @param space the space already reserved. * * @return The space required to draw the axis. */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { // create a new space object if one wasn't supplied... if (space == null) { space = new AxisSpace(); } // if the axis is not visible, no additional space is required... if (!isVisible()) { return space; } // calculate the max size of the tick labels (if visible)... double tickLabelHeight = 0.0; double tickLabelWidth = 0.0; if (isTickLabelsVisible()) { g2.setFont(getTickLabelFont()); AxisState state = new AxisState(); // we call refresh ticks just to get the maximum width or height refreshTicks(g2, state, plotArea, edge); if (edge == RectangleEdge.TOP) { tickLabelHeight = state.getMax(); } else if (edge == RectangleEdge.BOTTOM) { tickLabelHeight = state.getMax(); } else if (edge == RectangleEdge.LEFT) { tickLabelWidth = state.getMax(); } else if (edge == RectangleEdge.RIGHT) { tickLabelWidth = state.getMax(); } } // get the axis label size and update the space object... Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); double labelHeight = 0.0; double labelWidth = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { labelHeight = labelEnclosure.getHeight(); space.add(labelHeight + tickLabelHeight + this.categoryLabelPositionOffset, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { labelWidth = labelEnclosure.getWidth(); space.add(labelWidth + tickLabelWidth + this.categoryLabelPositionOffset, edge); } return space; } /** * Configures the axis against the current plot. */ public void configure() { // nothing required } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (null not permitted). * @param dataArea the area within which the plot is being drawn * (null not permitted). * @param edge the location of the axis (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } AxisState state = new AxisState(cursor); if (isTickMarksVisible()) { drawTickMarks(g2, cursor, dataArea, edge, state); } // draw the category labels and axis label state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); createAndAddEntity(cursor, state, dataArea, edge, plotState); return state; } /** * Draws the category labels and returns the updated axis state. * * @param g2 the graphics device (null not permitted). * @param dataArea the area inside the axes (null not * permitted). * @param edge the axis location (null not permitted). * @param state the axis state (null not permitted). * @param plotState collects information about the plot (null * permitted). * * @return The updated axis state (never null). * * @deprecated Use {@link #drawCategoryLabels(Graphics2D, Rectangle2D, * Rectangle2D, RectangleEdge, AxisState, PlotRenderingInfo)}. */ protected AxisState drawCategoryLabels(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { // this method is deprecated because we really need the plotArea // when drawing the labels - see bug 1277726 return drawCategoryLabels(g2, dataArea, dataArea, edge, state, plotState); } /** * Draws the category labels and returns the updated axis state. * * @param g2 the graphics device (null not permitted). * @param plotArea the plot area (null not permitted). * @param dataArea the area inside the axes (null not * permitted). * @param edge the axis location (null not permitted). * @param state the axis state (null not permitted). * @param plotState collects information about the plot (null * permitted). * * @return The updated axis state (never null). */ protected AxisState drawCategoryLabels(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { if (state == null) { throw new IllegalArgumentException("Null 'state' argument."); } if (isTickLabelsVisible()) { List ticks = refreshTicks(g2, state, plotArea, edge); state.setTicks(ticks); int categoryIndex = 0; Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { CategoryTick tick = (CategoryTick) iterator.next(); g2.setFont(getTickLabelFont(tick.getCategory())); g2.setPaint(getTickLabelPaint(tick.getCategory())); CategoryLabelPosition position = this.categoryLabelPositions.getLabelPosition(edge); double x0 = 0.0; double x1 = 0.0; double y0 = 0.0; double y1 = 0.0; if (edge == RectangleEdge.TOP) { x0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); x1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); y1 = state.getCursor() - this.categoryLabelPositionOffset; y0 = y1 - state.getMax(); } else if (edge == RectangleEdge.BOTTOM) { x0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); x1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); y0 = state.getCursor() + this.categoryLabelPositionOffset; y1 = y0 + state.getMax(); } else if (edge == RectangleEdge.LEFT) { y0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); y1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); x1 = state.getCursor() - this.categoryLabelPositionOffset; x0 = x1 - state.getMax(); } else if (edge == RectangleEdge.RIGHT) { y0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, edge); y1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, edge); x0 = state.getCursor() + this.categoryLabelPositionOffset; x1 = x0 - state.getMax(); } Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); Point2D anchorPoint = RectangleAnchor.coordinates(area, position.getCategoryAnchor()); TextBlock block = tick.getLabel(); block.draw(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); Shape bounds = block.calculateBounds(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); if (plotState != null && plotState.getOwner() != null) { EntityCollection entities = plotState.getOwner().getEntityCollection(); if (entities != null) { String tooltip = getCategoryLabelToolTip( tick.getCategory()); entities.add(new CategoryLabelEntity(tick.getCategory(), bounds, tooltip, null)); } } categoryIndex++; } if (edge.equals(RectangleEdge.TOP)) { double h = state.getMax() + this.categoryLabelPositionOffset; state.cursorUp(h); } else if (edge.equals(RectangleEdge.BOTTOM)) { double h = state.getMax() + this.categoryLabelPositionOffset; state.cursorDown(h); } else if (edge == RectangleEdge.LEFT) { double w = state.getMax() + this.categoryLabelPositionOffset; state.cursorLeft(w); } else if (edge == RectangleEdge.RIGHT) { double w = state.getMax() + this.categoryLabelPositionOffset; state.cursorRight(w); } } return state; } /** * Creates a temporary list of ticks that can be used when drawing the axis. * * @param g2 the graphics device (used to get font measurements). * @param state the axis state. * @param dataArea the area inside the axes. * @param edge the location of the axis. * * @return A list of ticks. */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); // sanity check for data area... if (dataArea.getHeight() <= 0.0 || dataArea.getWidth() < 0.0) { return ticks; } CategoryPlot plot = (CategoryPlot) getPlot(); List categories = plot.getCategoriesForAxis(this); double max = 0.0; if (categories != null) { CategoryLabelPosition position = this.categoryLabelPositions.getLabelPosition(edge); float r = this.maximumCategoryLabelWidthRatio; if (r <= 0.0) { r = position.getWidthRatio(); } float l = 0.0f; if (position.getWidthType() == CategoryLabelWidthType.CATEGORY) { l = (float) calculateCategorySize(categories.size(), dataArea, edge); } else { if (RectangleEdge.isLeftOrRight(edge)) { l = (float) dataArea.getWidth(); } else { l = (float) dataArea.getHeight(); } } int categoryIndex = 0; Iterator iterator = categories.iterator(); while (iterator.hasNext()) { Comparable category = (Comparable) iterator.next(); g2.setFont(getTickLabelFont(category)); TextBlock label = createLabel(category, l * r, edge, g2); if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { max = Math.max(max, calculateTextBlockHeight(label, position, g2)); } else if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { max = Math.max(max, calculateTextBlockWidth(label, position, g2)); } Tick tick = new CategoryTick(category, label, position.getLabelAnchor(), position.getRotationAnchor(), position.getAngle()); ticks.add(tick); categoryIndex = categoryIndex + 1; } } state.setMax(max); return ticks; } /** * Draws the tick marks. * * @since 1.0.13 */ public void drawTickMarks(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge, AxisState state) { Plot p = getPlot(); if (p == null) { return; } CategoryPlot plot = (CategoryPlot) p; double il = getTickMarkInsideLength(); double ol = getTickMarkOutsideLength(); Line2D line = new Line2D.Double(); List categories = plot.getCategoriesForAxis(this); g2.setPaint(getTickMarkPaint()); g2.setStroke(getTickMarkStroke()); if (edge.equals(RectangleEdge.TOP)) { Iterator iterator = categories.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); double x = getCategoryMiddle(key, categories, dataArea, edge); line.setLine(x, cursor, x, cursor + il); g2.draw(line); line.setLine(x, cursor, x, cursor - ol); g2.draw(line); } state.cursorUp(ol); } else if (edge.equals(RectangleEdge.BOTTOM)) { Iterator iterator = categories.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); double x = getCategoryMiddle(key, categories, dataArea, edge); line.setLine(x, cursor, x, cursor - il); g2.draw(line); line.setLine(x, cursor, x, cursor + ol); g2.draw(line); } state.cursorDown(ol); } else if (edge.equals(RectangleEdge.LEFT)) { Iterator iterator = categories.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); double y = getCategoryMiddle(key, categories, dataArea, edge); line.setLine(cursor, y, cursor + il, y); g2.draw(line); line.setLine(cursor, y, cursor - ol, y); g2.draw(line); } state.cursorLeft(ol); } else if (edge.equals(RectangleEdge.RIGHT)) { Iterator iterator = categories.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); double y = getCategoryMiddle(key, categories, dataArea, edge); line.setLine(cursor, y, cursor - il, y); g2.draw(line); line.setLine(cursor, y, cursor + ol, y); g2.draw(line); } state.cursorRight(ol); } } /** * Creates a label. * * @param category the category. * @param width the available width. * @param edge the edge on which the axis appears. * @param g2 the graphics device. * * @return A label. */ protected TextBlock createLabel(Comparable category, float width, RectangleEdge edge, Graphics2D g2) { TextBlock label = TextUtilities.createTextBlock(category.toString(), getTickLabelFont(category), getTickLabelPaint(category), width, this.maximumCategoryLabelLines, new G2TextMeasurer(g2)); return label; } /** * A utility method for determining the width of a text block. * * @param block the text block. * @param position the position. * @param g2 the graphics device. * * @return The width. */ protected double calculateTextBlockWidth(TextBlock block, CategoryLabelPosition position, Graphics2D g2) { RectangleInsets insets = getTickLabelInsets(); Size2D size = block.calculateDimensions(g2); Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight()); Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), 0.0f, 0.0f); double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft() + insets.getRight(); return w; } /** * A utility method for determining the height of a text block. * * @param block the text block. * @param position the label position. * @param g2 the graphics device. * * @return The height. */ protected double calculateTextBlockHeight(TextBlock block, CategoryLabelPosition position, Graphics2D g2) { RectangleInsets insets = getTickLabelInsets(); Size2D size = block.calculateDimensions(g2); Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), size.getHeight()); Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), 0.0f, 0.0f); double h = rotatedBox.getBounds2D().getHeight() + insets.getTop() + insets.getBottom(); return h; } /** * Creates a clone of the axis. * * @return A clone. * * @throws CloneNotSupportedException if some component of the axis does * not support cloning. */ public Object clone() throws CloneNotSupportedException { CategoryAxis clone = (CategoryAxis) super.clone(); clone.tickLabelFontMap = new HashMap(this.tickLabelFontMap); clone.tickLabelPaintMap = new HashMap(this.tickLabelPaintMap); clone.categoryLabelToolTips = new HashMap(this.categoryLabelToolTips); return clone; } /** * Tests this axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryAxis)) { return false; } if (!super.equals(obj)) { return false; } CategoryAxis that = (CategoryAxis) obj; if (that.lowerMargin != this.lowerMargin) { return false; } if (that.upperMargin != this.upperMargin) { return false; } if (that.categoryMargin != this.categoryMargin) { return false; } if (that.maximumCategoryLabelWidthRatio != this.maximumCategoryLabelWidthRatio) { return false; } if (that.categoryLabelPositionOffset != this.categoryLabelPositionOffset) { return false; } if (!ObjectUtilities.equal(that.categoryLabelPositions, this.categoryLabelPositions)) { return false; } if (!ObjectUtilities.equal(that.categoryLabelToolTips, this.categoryLabelToolTips)) { return false; } if (!ObjectUtilities.equal(this.tickLabelFontMap, that.tickLabelFontMap)) { return false; } if (!equalPaintMaps(this.tickLabelPaintMap, that.tickLabelPaintMap)) { return false; } return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { if (getLabel() != null) { return getLabel().hashCode(); } else { return 0; } } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); writePaintMap(this.tickLabelPaintMap, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.tickLabelPaintMap = readPaintMap(stream); } /** * Reads a Map of (Comparable, Paint) * elements from a stream. * * @param in the input stream. * * @return The map. * * @throws IOException * @throws ClassNotFoundException * * @see #writePaintMap(Map, ObjectOutputStream) */ private Map readPaintMap(ObjectInputStream in) throws IOException, ClassNotFoundException { boolean isNull = in.readBoolean(); if (isNull) { return null; } Map result = new HashMap(); int count = in.readInt(); for (int i = 0; i < count; i++) { Comparable category = (Comparable) in.readObject(); Paint paint = SerialUtilities.readPaint(in); result.put(category, paint); } return result; } /** * Writes a map of (Comparable, Paint) * elements to a stream. * * @param map the map (null permitted). * * @param out * @throws IOException * * @see #readPaintMap(ObjectInputStream) */ private void writePaintMap(Map map, ObjectOutputStream out) throws IOException { if (map == null) { out.writeBoolean(true); } else { out.writeBoolean(false); Set keys = map.keySet(); int count = keys.size(); out.writeInt(count); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); out.writeObject(key); SerialUtilities.writePaint((Paint) map.get(key), out); } } } /** * Tests two maps containing (Comparable, Paint) * elements for equality. * * @param map1 the first map (null not permitted). * @param map2 the second map (null not permitted). * * @return A boolean. */ private boolean equalPaintMaps(Map map1, Map map2) { if (map1.size() != map2.size()) { return false; } Set entries = map1.entrySet(); Iterator iterator = entries.iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); Paint p1 = (Paint) entry.getValue(); Paint p2 = (Paint) map2.get(entry.getKey()); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryAxis3D.java0000644000175000017500000002107111173030414027032 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CategoryAxis3D.java * ------------------- * (C) Copyright 2003-2009, by Klaus Rheinwald and Contributors. * * Original Author: Klaus Rheinwald; * Contributor(s): Tin Luu, * David Gilbert (for Object Refinery Limited); * Adriaan Joubert; * * Changes * ------- * 19-Feb-2003 : File creation; * 21-Mar-2003 : Added to JFreeChart CVS, see bug id 685501 for code * contribution from KR (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 13-May-2003 : Renamed HorizontalCategoryAxis3D --> CategoryAxis3D, and * modified to take into account the plot orientation (DG); * 14-Aug-2003 : Implemented Cloneable (DG); * 21-Aug-2003 : Fixed draw() method bugs (DG); * 22-Mar-2004 : Added workaround for bug 920959 (null pointer exception with * no renderer) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan * Joubert (1277726) (DG); * 16-Apr-2009 : Draw axis line and tick marks (DG); * */ package org.jfree.chart.axis; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.Effect3D; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.ui.RectangleEdge; /** * An axis that displays categories and has a 3D effect. * Used for bar charts and line charts. */ public class CategoryAxis3D extends CategoryAxis implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 4114732251353700972L; /** * Creates a new axis. */ public CategoryAxis3D() { this(null); } /** * Creates a new axis using default attribute values. * * @param label the axis label (null permitted). */ public CategoryAxis3D(String label) { super(label); } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (null not permitted). * @param dataArea the area within which the plot is being drawn * (null not permitted). * @param edge the location of the axis (null not permitted). * @param plotState collects information about the plot (null * permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } // calculate the adjusted data area taking into account the 3D effect... // this assumes that there is a 3D renderer, all this 3D effect is a // bit of an ugly hack... CategoryPlot plot = (CategoryPlot) getPlot(); Rectangle2D adjustedDataArea = new Rectangle2D.Double(); if (plot.getRenderer() instanceof Effect3D) { Effect3D e3D = (Effect3D) plot.getRenderer(); double adjustedX = dataArea.getMinX(); double adjustedY = dataArea.getMinY(); double adjustedW = dataArea.getWidth() - e3D.getXOffset(); double adjustedH = dataArea.getHeight() - e3D.getYOffset(); if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { adjustedY += e3D.getYOffset(); } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { adjustedX += e3D.getXOffset(); } adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW, adjustedH); } else { adjustedDataArea.setRect(dataArea); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, adjustedDataArea, edge); } // draw the category labels and axis label AxisState state = new AxisState(cursor); if (isTickMarksVisible()) { drawTickMarks(g2, cursor, adjustedDataArea, edge, state); } state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge, state, plotState); state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); return state; } /** * Returns the Java 2D coordinate for a category. * * @param anchor the anchor point. * @param category the category index. * @param categoryCount the category count. * @param area the data area. * @param edge the location of the axis. * * @return The coordinate. */ public double getCategoryJava2DCoordinate(CategoryAnchor anchor, int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { double result = 0.0; Rectangle2D adjustedArea = area; CategoryPlot plot = (CategoryPlot) getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); if (renderer instanceof Effect3D) { Effect3D e3D = (Effect3D) renderer; double adjustedX = area.getMinX(); double adjustedY = area.getMinY(); double adjustedW = area.getWidth() - e3D.getXOffset(); double adjustedH = area.getHeight() - e3D.getYOffset(); if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { adjustedY += e3D.getYOffset(); } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { adjustedX += e3D.getXOffset(); } adjustedArea = new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH); } if (anchor == CategoryAnchor.START) { result = getCategoryStart(category, categoryCount, adjustedArea, edge); } else if (anchor == CategoryAnchor.MIDDLE) { result = getCategoryMiddle(category, categoryCount, adjustedArea, edge); } else if (anchor == CategoryAnchor.END) { result = getCategoryEnd(category, categoryCount, adjustedArea, edge); } return result; } /** * Returns a clone of the axis. * * @return A clone. * * @throws CloneNotSupportedException If the axis is not cloneable for * some reason. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryLabelPosition.java0000644000175000017500000002245011173030414030505 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * CategoryLabelPosition.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 31-Oct-2003 : Version 1 (DG); * 17-Feb-2004 : Added new constructor (DG); * 23-Mar-2004 : Added width calculation parameters (DG); * 07-Jan-2005 : Fixed bug in equals() method (DG); * 11-Jan-2005 : Removed deprecated constructor in preparation for the 1.0.0 * release (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.TextAnchor; /** * The attributes that control the position of the labels for the categories on * a {@link CategoryAxis}. Instances of this class are immutable and other * JFreeChart classes rely upon this. */ public class CategoryLabelPosition implements Serializable { /** For serialization. */ private static final long serialVersionUID = 5168681143844183864L; /** The category anchor point. */ private RectangleAnchor categoryAnchor; /** The text block anchor. */ private TextBlockAnchor labelAnchor; /** The rotation anchor. */ private TextAnchor rotationAnchor; /** The rotation angle (in radians). */ private double angle; /** The width calculation type. */ private CategoryLabelWidthType widthType; /** * The maximum label width as a percentage of the category space or the * range space. */ private float widthRatio; /** * Creates a new position record with default settings. */ public CategoryLabelPosition() { this(RectangleAnchor.CENTER, TextBlockAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0, CategoryLabelWidthType.CATEGORY, 0.95f); } /** * Creates a new category label position record. * * @param categoryAnchor the category anchor (null not * permitted). * @param labelAnchor the label anchor (null not permitted). */ public CategoryLabelPosition(RectangleAnchor categoryAnchor, TextBlockAnchor labelAnchor) { // argument checking delegated... this(categoryAnchor, labelAnchor, TextAnchor.CENTER, 0.0, CategoryLabelWidthType.CATEGORY, 0.95f); } /** * Creates a new category label position record. * * @param categoryAnchor the category anchor (null not * permitted). * @param labelAnchor the label anchor (null not permitted). * @param widthType the width type (null not permitted). * @param widthRatio the maximum label width as a percentage (of the * category space or the range space). */ public CategoryLabelPosition(RectangleAnchor categoryAnchor, TextBlockAnchor labelAnchor, CategoryLabelWidthType widthType, float widthRatio) { // argument checking delegated... this(categoryAnchor, labelAnchor, TextAnchor.CENTER, 0.0, widthType, widthRatio); } /** * Creates a new position record. The item label anchor is a point * relative to the data item (dot, bar or other visual item) on a chart. * The item label is aligned by aligning the text anchor with the item * label anchor. * * @param categoryAnchor the category anchor (null not * permitted). * @param labelAnchor the label anchor (null not permitted). * @param rotationAnchor the rotation anchor (null not * permitted). * @param angle the rotation angle (null not permitted). * @param widthType the width type (null not permitted). * @param widthRatio the maximum label width as a percentage (of the * category space or the range space). */ public CategoryLabelPosition(RectangleAnchor categoryAnchor, TextBlockAnchor labelAnchor, TextAnchor rotationAnchor, double angle, CategoryLabelWidthType widthType, float widthRatio) { if (categoryAnchor == null) { throw new IllegalArgumentException( "Null 'categoryAnchor' argument."); } if (labelAnchor == null) { throw new IllegalArgumentException( "Null 'labelAnchor' argument."); } if (rotationAnchor == null) { throw new IllegalArgumentException( "Null 'rotationAnchor' argument."); } if (widthType == null) { throw new IllegalArgumentException("Null 'widthType' argument."); } this.categoryAnchor = categoryAnchor; this.labelAnchor = labelAnchor; this.rotationAnchor = rotationAnchor; this.angle = angle; this.widthType = widthType; this.widthRatio = widthRatio; } /** * Returns the item label anchor. * * @return The item label anchor (never null). */ public RectangleAnchor getCategoryAnchor() { return this.categoryAnchor; } /** * Returns the text block anchor. * * @return The text block anchor (never null). */ public TextBlockAnchor getLabelAnchor() { return this.labelAnchor; } /** * Returns the rotation anchor point. * * @return The rotation anchor point (never null). */ public TextAnchor getRotationAnchor() { return this.rotationAnchor; } /** * Returns the angle of rotation for the label. * * @return The angle (in radians). */ public double getAngle() { return this.angle; } /** * Returns the width calculation type. * * @return The width calculation type (never null). */ public CategoryLabelWidthType getWidthType() { return this.widthType; } /** * Returns the ratio used to calculate the maximum category label width. * * @return The ratio. */ public float getWidthRatio() { return this.widthRatio; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryLabelPosition)) { return false; } CategoryLabelPosition that = (CategoryLabelPosition) obj; if (!this.categoryAnchor.equals(that.categoryAnchor)) { return false; } if (!this.labelAnchor.equals(that.labelAnchor)) { return false; } if (!this.rotationAnchor.equals(that.rotationAnchor)) { return false; } if (this.angle != that.angle) { return false; } if (this.widthType != that.widthType) { return false; } if (this.widthRatio != that.widthRatio) { return false; } return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 19; result = 37 * result + this.categoryAnchor.hashCode(); result = 37 * result + this.labelAnchor.hashCode(); result = 37 * result + this.rotationAnchor.hashCode(); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryLabelPositions.java0000644000175000017500000004115511173030414030673 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryLabelPositions.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jan-2004 : Version 1 (DG); * 17-Feb-2004 : Added equals() method (DG); * 05-Nov-2004 : Adjusted settings for UP_90 and DOWN_90 (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; /** * Records the label positions for a category axis. Instances of this class * are immutable. */ public class CategoryLabelPositions implements Serializable { /** For serialization. */ private static final long serialVersionUID = -8999557901920364580L; /** STANDARD category label positions. */ public static final CategoryLabelPositions STANDARD = new CategoryLabelPositions( new CategoryLabelPosition( RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER ), // TOP new CategoryLabelPosition( RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER ), // BOTTOM new CategoryLabelPosition( RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT, CategoryLabelWidthType.RANGE, 0.30f ), // LEFT new CategoryLabelPosition( RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 0.30f ) // RIGHT ); /** UP_90 category label positions. */ public static final CategoryLabelPositions UP_90 = new CategoryLabelPositions( new CategoryLabelPosition( RectangleAnchor.BOTTOM, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0, CategoryLabelWidthType.RANGE, 0.30f ), // TOP new CategoryLabelPosition( RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0, CategoryLabelWidthType.RANGE, 0.30f ), // BOTTOM new CategoryLabelPosition( RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_CENTER, TextAnchor.BOTTOM_CENTER, -Math.PI / 2.0, CategoryLabelWidthType.CATEGORY, 0.9f ), // LEFT new CategoryLabelPosition( RectangleAnchor.LEFT, TextBlockAnchor.TOP_CENTER, TextAnchor.TOP_CENTER, -Math.PI / 2.0, CategoryLabelWidthType.CATEGORY, 0.90f ) // RIGHT ); /** DOWN_90 category label positions. */ public static final CategoryLabelPositions DOWN_90 = new CategoryLabelPositions( new CategoryLabelPosition( RectangleAnchor.BOTTOM, TextBlockAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, Math.PI / 2.0, CategoryLabelWidthType.RANGE, 0.30f ), // TOP new CategoryLabelPosition( RectangleAnchor.TOP, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, Math.PI / 2.0, CategoryLabelWidthType.RANGE, 0.30f ), // BOTTOM new CategoryLabelPosition( RectangleAnchor.RIGHT, TextBlockAnchor.TOP_CENTER, TextAnchor.TOP_CENTER, Math.PI / 2.0, CategoryLabelWidthType.CATEGORY, 0.90f ), // LEFT new CategoryLabelPosition( RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_CENTER, TextAnchor.BOTTOM_CENTER, Math.PI / 2.0, CategoryLabelWidthType.CATEGORY, 0.90f ) // RIGHT ); /** UP_45 category label positions. */ public static final CategoryLabelPositions UP_45 = createUpRotationLabelPositions(Math.PI / 4.0); /** DOWN_45 category label positions. */ public static final CategoryLabelPositions DOWN_45 = createDownRotationLabelPositions(Math.PI / 4.0); /** * Creates a new instance where the category labels angled upwards by the * specified amount. * * @param angle the rotation angle (should be < Math.PI / 2.0). * * @return A category label position specification. */ public static CategoryLabelPositions createUpRotationLabelPositions( double angle) { return new CategoryLabelPositions( new CategoryLabelPosition( RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_LEFT, TextAnchor.BOTTOM_LEFT, -angle, CategoryLabelWidthType.RANGE, 0.50f ), // TOP new CategoryLabelPosition( RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -angle, CategoryLabelWidthType.RANGE, 0.50f ), // BOTTOM new CategoryLabelPosition( RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_RIGHT, TextAnchor.BOTTOM_RIGHT, -angle, CategoryLabelWidthType.RANGE, 0.50f ), // LEFT new CategoryLabelPosition( RectangleAnchor.LEFT, TextBlockAnchor.TOP_LEFT, TextAnchor.TOP_LEFT, -angle, CategoryLabelWidthType.RANGE, 0.50f ) // RIGHT ); } /** * Creates a new instance where the category labels angled downwards by the * specified amount. * * @param angle the rotation angle (should be < Math.PI / 2.0). * * @return A category label position specification. */ public static CategoryLabelPositions createDownRotationLabelPositions( double angle) { return new CategoryLabelPositions( new CategoryLabelPosition( RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_RIGHT, TextAnchor.BOTTOM_RIGHT, angle, CategoryLabelWidthType.RANGE, 0.50f ), // TOP new CategoryLabelPosition( RectangleAnchor.TOP, TextBlockAnchor.TOP_LEFT, TextAnchor.TOP_LEFT, angle, CategoryLabelWidthType.RANGE, 0.50f ), // BOTTOM new CategoryLabelPosition( RectangleAnchor.RIGHT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, angle, CategoryLabelWidthType.RANGE, 0.50f ), // LEFT new CategoryLabelPosition( RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_LEFT, TextAnchor.BOTTOM_LEFT, angle, CategoryLabelWidthType.RANGE, 0.50f ) // RIGHT ); } /** * The label positioning details used when an axis is at the top of a * chart. */ private CategoryLabelPosition positionForAxisAtTop; /** * The label positioning details used when an axis is at the bottom of a * chart. */ private CategoryLabelPosition positionForAxisAtBottom; /** * The label positioning details used when an axis is at the left of a * chart. */ private CategoryLabelPosition positionForAxisAtLeft; /** * The label positioning details used when an axis is at the right of a * chart. */ private CategoryLabelPosition positionForAxisAtRight; /** * Default constructor. */ public CategoryLabelPositions() { this.positionForAxisAtTop = new CategoryLabelPosition(); this.positionForAxisAtBottom = new CategoryLabelPosition(); this.positionForAxisAtLeft = new CategoryLabelPosition(); this.positionForAxisAtRight = new CategoryLabelPosition(); } /** * Creates a new position specification. * * @param top the label position info used when an axis is at the top * (null not permitted). * @param bottom the label position info used when an axis is at the * bottom (null not permitted). * @param left the label position info used when an axis is at the left * (null not permitted). * @param right the label position info used when an axis is at the right * (null not permitted). */ public CategoryLabelPositions(CategoryLabelPosition top, CategoryLabelPosition bottom, CategoryLabelPosition left, CategoryLabelPosition right) { if (top == null) { throw new IllegalArgumentException("Null 'top' argument."); } if (bottom == null) { throw new IllegalArgumentException("Null 'bottom' argument."); } if (left == null) { throw new IllegalArgumentException("Null 'left' argument."); } if (right == null) { throw new IllegalArgumentException("Null 'right' argument."); } this.positionForAxisAtTop = top; this.positionForAxisAtBottom = bottom; this.positionForAxisAtLeft = left; this.positionForAxisAtRight = right; } /** * Returns the category label position specification for an axis at the * given location. * * @param edge the axis location. * * @return The category label position specification. */ public CategoryLabelPosition getLabelPosition(RectangleEdge edge) { CategoryLabelPosition result = null; if (edge == RectangleEdge.TOP) { result = this.positionForAxisAtTop; } else if (edge == RectangleEdge.BOTTOM) { result = this.positionForAxisAtBottom; } else if (edge == RectangleEdge.LEFT) { result = this.positionForAxisAtLeft; } else if (edge == RectangleEdge.RIGHT) { result = this.positionForAxisAtRight; } return result; } /** * Returns a new instance based on an existing instance but with the top * position changed. * * @param base the base (null not permitted). * @param top the top position (null not permitted). * * @return A new instance (never null). */ public static CategoryLabelPositions replaceTopPosition( CategoryLabelPositions base, CategoryLabelPosition top) { if (base == null) { throw new IllegalArgumentException("Null 'base' argument."); } if (top == null) { throw new IllegalArgumentException("Null 'top' argument."); } return new CategoryLabelPositions( top, base.getLabelPosition(RectangleEdge.BOTTOM), base.getLabelPosition(RectangleEdge.LEFT), base.getLabelPosition(RectangleEdge.RIGHT) ); } /** * Returns a new instance based on an existing instance but with the bottom * position changed. * * @param base the base (null not permitted). * @param bottom the bottom position (null not permitted). * * @return A new instance (never null). */ public static CategoryLabelPositions replaceBottomPosition( CategoryLabelPositions base, CategoryLabelPosition bottom) { if (base == null) { throw new IllegalArgumentException("Null 'base' argument."); } if (bottom == null) { throw new IllegalArgumentException("Null 'bottom' argument."); } return new CategoryLabelPositions( base.getLabelPosition(RectangleEdge.TOP), bottom, base.getLabelPosition(RectangleEdge.LEFT), base.getLabelPosition(RectangleEdge.RIGHT) ); } /** * Returns a new instance based on an existing instance but with the left * position changed. * * @param base the base (null not permitted). * @param left the left position (null not permitted). * * @return A new instance (never null). */ public static CategoryLabelPositions replaceLeftPosition( CategoryLabelPositions base, CategoryLabelPosition left) { if (base == null) { throw new IllegalArgumentException("Null 'base' argument."); } if (left == null) { throw new IllegalArgumentException("Null 'left' argument."); } return new CategoryLabelPositions( base.getLabelPosition(RectangleEdge.TOP), base.getLabelPosition(RectangleEdge.BOTTOM), left, base.getLabelPosition(RectangleEdge.RIGHT) ); } /** * Returns a new instance based on an existing instance but with the right * position changed. * * @param base the base (null not permitted). * @param right the right position (null not permitted). * * @return A new instance (never null). */ public static CategoryLabelPositions replaceRightPosition( CategoryLabelPositions base, CategoryLabelPosition right) { if (base == null) { throw new IllegalArgumentException("Null 'base' argument."); } if (right == null) { throw new IllegalArgumentException("Null 'right' argument."); } return new CategoryLabelPositions( base.getLabelPosition(RectangleEdge.TOP), base.getLabelPosition(RectangleEdge.BOTTOM), base.getLabelPosition(RectangleEdge.LEFT), right ); } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof CategoryLabelPositions)) { return false; } CategoryLabelPositions that = (CategoryLabelPositions) obj; if (!this.positionForAxisAtTop.equals(that.positionForAxisAtTop)) { return false; } if (!this.positionForAxisAtBottom.equals( that.positionForAxisAtBottom)) { return false; } if (!this.positionForAxisAtLeft.equals(that.positionForAxisAtLeft)) { return false; } if (!this.positionForAxisAtRight.equals(that.positionForAxisAtRight)) { return false; } return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 19; result = 37 * result + this.positionForAxisAtTop.hashCode(); result = 37 * result + this.positionForAxisAtBottom.hashCode(); result = 37 * result + this.positionForAxisAtLeft.hashCode(); result = 37 * result + this.positionForAxisAtRight.hashCode(); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryLabelWidthType.java0000644000175000017500000000757711173030414030637 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryLabelWidthType.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 24-Mar-2004 : Version 1 (DG); * */ package org.jfree.chart.axis; import java.io.ObjectStreamException; import java.io.Serializable; /** * Represents the width types for a category label. */ public final class CategoryLabelWidthType implements Serializable { /** For serialization. */ private static final long serialVersionUID = -6976024792582949656L; /** Percentage of category. */ public static final CategoryLabelWidthType CATEGORY = new CategoryLabelWidthType( "CategoryLabelWidthType.CATEGORY" ); /** Percentage of range. */ public static final CategoryLabelWidthType RANGE = new CategoryLabelWidthType("CategoryLabelWidthType.RANGE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name (null not permitted). */ private CategoryLabelWidthType(String name) { if (name == null) { throw new IllegalArgumentException("Null 'name' argument."); } this.name = name; } /** * Returns a string representing the object. * * @return The string (never null). */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof CategoryLabelWidthType)) { return false; } CategoryLabelWidthType t = (CategoryLabelWidthType) obj; if (!this.name.equals(t.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(CategoryLabelWidthType.CATEGORY)) { return CategoryLabelWidthType.CATEGORY; } else if (this.equals(CategoryLabelWidthType.RANGE)) { return CategoryLabelWidthType.RANGE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CategoryTick.java0000644000175000017500000001052211173030414026630 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * CategoryTick.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Nov-2003 : Version 1 (DG); * 13-May-2004 : Added equals() method (DG); * */ package org.jfree.chart.axis; import org.jfree.text.TextBlock; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; /** * A tick for a {@link CategoryAxis}. */ public class CategoryTick extends Tick { /** The category. */ private Comparable category; /** The label. */ private TextBlock label; /** The label anchor. */ private TextBlockAnchor labelAnchor; /** * Creates a new tick. * * @param category the category. * @param label the label. * @param labelAnchor the label anchor. * @param rotationAnchor the rotation anchor. * @param angle the rotation angle (in radians). */ public CategoryTick(Comparable category, TextBlock label, TextBlockAnchor labelAnchor, TextAnchor rotationAnchor, double angle) { super("", TextAnchor.CENTER, rotationAnchor, angle); this.category = category; this.label = label; this.labelAnchor = labelAnchor; } /** * Returns the category. * * @return The category. */ public Comparable getCategory() { return this.category; } /** * Returns the label. * * @return The label. */ public TextBlock getLabel() { return this.label; } /** * Returns the label anchor. * * @return The label anchor. */ public TextBlockAnchor getLabelAnchor() { return this.labelAnchor; } /** * Tests this category tick for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof CategoryTick && super.equals(obj)) { CategoryTick that = (CategoryTick) obj; if (!ObjectUtilities.equal(this.category, that.category)) { return false; } if (!ObjectUtilities.equal(this.label, that.label)) { return false; } if (!ObjectUtilities.equal(this.labelAnchor, that.labelAnchor)) { return false; } return true; } return false; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 41; result = 37 * result + this.category.hashCode(); result = 37 * result + this.label.hashCode(); result = 37 * result + this.labelAnchor.hashCode(); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/ColorBar.java0000644000175000017500000003623411173030414025753 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * ColorBar.java * ------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double (DG); * 17-Jan-2003 : Moved plot classes to separate package (DG); * 20-Jan-2003 : Removed unnecessary constructors (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 09-Jul-2003 : Changed ColorBar from extending axis classes to enclosing * them (DG); * 05-Aug-2003 : Applied changes in bug report 780298 (DG); * 14-Aug-2003 : Implemented Cloneable (DG); * 08-Sep-2003 : Changed ValueAxis API (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.axis; import java.awt.BasicStroke; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.plot.ColorPalette; import org.jfree.chart.plot.ContourPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.RainbowPalette; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.ui.RectangleEdge; /** * A color bar. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class ColorBar implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2101776212647268103L; /** The default color bar thickness. */ public static final int DEFAULT_COLORBAR_THICKNESS = 0; /** The default color bar thickness percentage. */ public static final double DEFAULT_COLORBAR_THICKNESS_PERCENT = 0.10; /** The default outer gap. */ public static final int DEFAULT_OUTERGAP = 2; /** The axis. */ private ValueAxis axis; /** The color bar thickness. */ private int colorBarThickness = DEFAULT_COLORBAR_THICKNESS; /** * The color bar thickness as a percentage of the height of the data area. */ private double colorBarThicknessPercent = DEFAULT_COLORBAR_THICKNESS_PERCENT; /** The color palette. */ private ColorPalette colorPalette = null; /** The color bar length. */ private int colorBarLength = 0; // default make height of plotArea /** The amount of blank space around the colorbar. */ private int outerGap; /** * Constructs a horizontal colorbar axis, using default values where * necessary. * * @param label the axis label. */ public ColorBar(String label) { NumberAxis a = new NumberAxis(label); a.setAutoRangeIncludesZero(false); this.axis = a; this.axis.setLowerMargin(0.0); this.axis.setUpperMargin(0.0); this.colorPalette = new RainbowPalette(); this.colorBarThickness = DEFAULT_COLORBAR_THICKNESS; this.colorBarThicknessPercent = DEFAULT_COLORBAR_THICKNESS_PERCENT; this.outerGap = DEFAULT_OUTERGAP; this.colorPalette.setMinZ(this.axis.getRange().getLowerBound()); this.colorPalette.setMaxZ(this.axis.getRange().getUpperBound()); } /** * Configures the color bar. * * @param plot the plot. */ public void configure(ContourPlot plot) { double minZ = plot.getDataset().getMinZValue(); double maxZ = plot.getDataset().getMaxZValue(); setMinimumValue(minZ); setMaximumValue(maxZ); } /** * Returns the axis. * * @return The axis. */ public ValueAxis getAxis() { return this.axis; } /** * Sets the axis. * * @param axis the axis. */ public void setAxis(ValueAxis axis) { this.axis = axis; } /** * Rescales the axis to ensure that all data are visible. */ public void autoAdjustRange() { this.axis.autoAdjustRange(); this.colorPalette.setMinZ(this.axis.getLowerBound()); this.colorPalette.setMaxZ(this.axis.getUpperBound()); } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param cursor the cursor. * @param plotArea the area within which the chart should be drawn. * @param dataArea the area within which the plot should be drawn (a * subset of the drawArea). * @param reservedArea the reserved area. * @param edge the color bar location. * * @return The new cursor location. */ public double draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, Rectangle2D reservedArea, RectangleEdge edge) { Rectangle2D colorBarArea = null; double thickness = calculateBarThickness(dataArea, edge); if (this.colorBarThickness > 0) { thickness = this.colorBarThickness; // allow fixed thickness } double length = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { length = dataArea.getHeight(); } else { length = dataArea.getWidth(); } if (this.colorBarLength > 0) { length = this.colorBarLength; } if (edge == RectangleEdge.BOTTOM) { colorBarArea = new Rectangle2D.Double(dataArea.getX(), plotArea.getMaxY() + this.outerGap, length, thickness); } else if (edge == RectangleEdge.TOP) { colorBarArea = new Rectangle2D.Double(dataArea.getX(), reservedArea.getMinY() + this.outerGap, length, thickness); } else if (edge == RectangleEdge.LEFT) { colorBarArea = new Rectangle2D.Double(plotArea.getX() - thickness - this.outerGap, dataArea.getMinY(), thickness, length); } else if (edge == RectangleEdge.RIGHT) { colorBarArea = new Rectangle2D.Double(plotArea.getMaxX() + this.outerGap, dataArea.getMinY(), thickness, length); } // update, but dont draw tick marks (needed for stepped colors) this.axis.refreshTicks(g2, new AxisState(), colorBarArea, edge); drawColorBar(g2, colorBarArea, edge); AxisState state = null; if (edge == RectangleEdge.TOP) { cursor = colorBarArea.getMinY(); state = this.axis.draw(g2, cursor, reservedArea, colorBarArea, RectangleEdge.TOP, null); } else if (edge == RectangleEdge.BOTTOM) { cursor = colorBarArea.getMaxY(); state = this.axis.draw(g2, cursor, reservedArea, colorBarArea, RectangleEdge.BOTTOM, null); } else if (edge == RectangleEdge.LEFT) { cursor = colorBarArea.getMinX(); state = this.axis.draw(g2, cursor, reservedArea, colorBarArea, RectangleEdge.LEFT, null); } else if (edge == RectangleEdge.RIGHT) { cursor = colorBarArea.getMaxX(); state = this.axis.draw(g2, cursor, reservedArea, colorBarArea, RectangleEdge.RIGHT, null); } return state.getCursor(); } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param colorBarArea the area within which the axis should be drawn. * @param edge the location. */ public void drawColorBar(Graphics2D g2, Rectangle2D colorBarArea, RectangleEdge edge) { Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // setTickValues was missing from ColorPalette v. 0.96 //colorPalette.setTickValues(this.axis.getTicks()); Stroke strokeSaved = g2.getStroke(); g2.setStroke(new BasicStroke(1.0f)); if (RectangleEdge.isTopOrBottom(edge)) { double y1 = colorBarArea.getY(); double y2 = colorBarArea.getMaxY(); double xx = colorBarArea.getX(); Line2D line = new Line2D.Double(); while (xx <= colorBarArea.getMaxX()) { double value = this.axis.java2DToValue(xx, colorBarArea, edge); line.setLine(xx, y1, xx, y2); g2.setPaint(getPaint(value)); g2.draw(line); xx += 1; } } else { double y1 = colorBarArea.getX(); double y2 = colorBarArea.getMaxX(); double xx = colorBarArea.getY(); Line2D line = new Line2D.Double(); while (xx <= colorBarArea.getMaxY()) { double value = this.axis.java2DToValue(xx, colorBarArea, edge); line.setLine(y1, xx, y2, xx); g2.setPaint(getPaint(value)); g2.draw(line); xx += 1; } } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias); g2.setStroke(strokeSaved); } /** * Returns the color palette. * * @return The color palette. */ public ColorPalette getColorPalette() { return this.colorPalette; } /** * Returns the Paint associated with a value. * * @param value the value. * * @return The paint. */ public Paint getPaint(double value) { return this.colorPalette.getPaint(value); } /** * Sets the color palette. * * @param palette the new palette. */ public void setColorPalette(ColorPalette palette) { this.colorPalette = palette; } /** * Sets the maximum value. * * @param value the maximum value. */ public void setMaximumValue(double value) { this.colorPalette.setMaxZ(value); this.axis.setUpperBound(value); } /** * Sets the minimum value. * * @param value the minimum value. */ public void setMinimumValue(double value) { this.colorPalette.setMinZ(value); this.axis.setLowerBound(value); } /** * Reserves the space required to draw the color bar. * * @param g2 the graphics device. * @param plot the plot that the axis belongs to. * @param plotArea the area within which the plot should be drawn. * @param dataArea the data area. * @param edge the axis location. * @param space the space already reserved. * * @return The space required to draw the axis in the specified plot area. */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisSpace space) { AxisSpace result = this.axis.reserveSpace(g2, plot, plotArea, edge, space); double thickness = calculateBarThickness(dataArea, edge); result.add(thickness + 2 * this.outerGap, edge); return result; } /** * Calculates the bar thickness. * * @param plotArea the plot area. * @param edge the location. * * @return The thickness. */ private double calculateBarThickness(Rectangle2D plotArea, RectangleEdge edge) { double result = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { result = plotArea.getWidth() * this.colorBarThicknessPercent; } else { result = plotArea.getHeight() * this.colorBarThicknessPercent; } return result; } /** * Returns a clone of the object. * * @return A clone. * * @throws CloneNotSupportedException if some component of the color bar * does not support cloning. */ public Object clone() throws CloneNotSupportedException { ColorBar clone = (ColorBar) super.clone(); clone.axis = (ValueAxis) this.axis.clone(); return clone; } /** * Tests this object for equality with another. * * @param obj the object to test against. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ColorBar)) { return false; } ColorBar that = (ColorBar) obj; if (!this.axis.equals(that.axis)) { return false; } if (this.colorBarThickness != that.colorBarThickness) { return false; } if (this.colorBarThicknessPercent != that.colorBarThicknessPercent) { return false; } if (!this.colorPalette.equals(that.colorPalette)) { return false; } if (this.colorBarLength != that.colorBarLength) { return false; } if (this.outerGap != that.outerGap) { return false; } return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { return this.axis.hashCode(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CompassFormat.java0000644000175000017500000001012611173030414027016 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * CompassFormat.java * ------------------ * (C) Copyright 2003-2008, by Sylvain Vieujot and Contributors. * * Original Author: Sylvain Vieujot; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 18-Feb-2004 : Version 1 contributed by Sylvain Vieujot (DG); * */ package org.jfree.chart.axis; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; /** * A formatter that displays numbers as directions. */ public class CompassFormat extends NumberFormat { /** North. */ private static final String N = "N"; /** East. */ private static final String E = "E"; /** South. */ private static final String S = "S"; /** West. */ private static final String W = "W"; /** The directions. */ public static final String[] DIRECTIONS = { N, N + N + E, N + E, E + N + E, E, E + S + E, S + E, S + S + E, S, S + S + W, S + W, W + S + W, W, W + N + W, N + W, N + N + W, N }; /** * Creates a new formatter. */ public CompassFormat() { super(); } /** * Returns a string representing the direction. * * @param direction the direction. * * @return A string. */ public String getDirectionCode(double direction) { direction = direction % 360; if (direction < 0.0) { direction = direction + 360.0; } int index = ((int) Math.floor(direction / 11.25) + 1) / 2; return DIRECTIONS[index]; } /** * Formats a number into the specified string buffer. * * @param number the number to format. * @param toAppendTo the string buffer. * @param pos the field position (ignored here). * * @return The string buffer. */ public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { return toAppendTo.append(getDirectionCode(number)); } /** * Formats a number into the specified string buffer. * * @param number the number to format. * @param toAppendTo the string buffer. * @param pos the field position (ignored here). * * @return The string buffer. */ public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { return toAppendTo.append(getDirectionCode(number)); } /** * This method returns null for all inputs. This class cannot * be used for parsing. * * @param source the source string. * @param parsePosition the parse position. * * @return null. */ public Number parse(String source, ParsePosition parsePosition) { return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/CyclicNumberAxis.java0000644000175000017500000012353411173030414027454 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * CyclicNumberAxis.java * --------------------- * (C) Copyright 2003-2008, by Nicolas Brodu and Contributors. * * Original Author: Nicolas Brodu; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Nov-2003 : Initial import to JFreeChart from the JSynoptic project (NB); * 16-Mar-2004 : Added plotState to draw() method (DG); * 07-Apr-2004 : Modifed text bounds calculation (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets, removed redundant * argument in selectAutoTickUnit() (DG); * 22-Apr-2005 : Renamed refreshHorizontalTicks() --> refreshTicksHorizontal * (for consistency with other classes) and removed unused * parameters (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * */ package org.jfree.chart.axis; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.text.NumberFormat; import java.util.List; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** This class extends NumberAxis and handles cycling. Traditional representation of data in the range x0..x1

|-------------------------|
x0                       x1
Here, the range bounds are at the axis extremities. With cyclic axis, however, the time is split in "cycles", or "time frames", or the same duration : the period. A cycle axis cannot by definition handle a larger interval than the period :
x1 - x0 >= period
. Thus, at most a full period can be represented with such an axis. The cycle bound is the number between x0 and x1 which marks the beginning of new time frame:
|---------------------|----------------------------|
x0                   cb                           x1
<---previous cycle---><-------current cycle-------->
It is actually a multiple of the period, plus optionally a start offset:
cb = n * period + offset
Thus, by definition, two consecutive cycle bounds period apart, which is precisely why it is called a period. The visual representation of a cyclic axis is like that:
|----------------------------|---------------------|
cb                         x1|x0                  cb
<-------current cycle--------><---previous cycle--->
The cycle bound is at the axis ends, then current cycle is shown, then the last cycle. When using dynamic data, the visual effect is the current cycle erases the last cycle as x grows. Then, the next cycle bound is reached, and the process starts over, erasing the previous cycle. A Cyclic item renderer is provided to do exactly this. */ public class CyclicNumberAxis extends NumberAxis { /** For serialization. */ static final long serialVersionUID = -7514160997164582554L; /** The default axis line stroke. */ public static Stroke DEFAULT_ADVANCE_LINE_STROKE = new BasicStroke(1.0f); /** The default axis line paint. */ public static final Paint DEFAULT_ADVANCE_LINE_PAINT = Color.gray; /** The offset. */ protected double offset; /** The period.*/ protected double period; /** ??. */ protected boolean boundMappedToLastCycle; /** A flag that controls whether or not the advance line is visible. */ protected boolean advanceLineVisible; /** The advance line stroke. */ protected transient Stroke advanceLineStroke = DEFAULT_ADVANCE_LINE_STROKE; /** The advance line paint. */ protected transient Paint advanceLinePaint; private transient boolean internalMarkerWhenTicksOverlap; private transient Tick internalMarkerCycleBoundTick; /** * Creates a CycleNumberAxis with the given period. * * @param period the period. */ public CyclicNumberAxis(double period) { this(period, 0.0); } /** * Creates a CycleNumberAxis with the given period and offset. * * @param period the period. * @param offset the offset. */ public CyclicNumberAxis(double period, double offset) { this(period, offset, null); } /** * Creates a named CycleNumberAxis with the given period. * * @param period the period. * @param label the label. */ public CyclicNumberAxis(double period, String label) { this(0, period, label); } /** * Creates a named CycleNumberAxis with the given period and offset. * * @param period the period. * @param offset the offset. * @param label the label. */ public CyclicNumberAxis(double period, double offset, String label) { super(label); this.period = period; this.offset = offset; setFixedAutoRange(period); this.advanceLineVisible = true; this.advanceLinePaint = DEFAULT_ADVANCE_LINE_PAINT; } /** * The advance line is the line drawn at the limit of the current cycle, * when erasing the previous cycle. * * @return A boolean. */ public boolean isAdvanceLineVisible() { return this.advanceLineVisible; } /** * The advance line is the line drawn at the limit of the current cycle, * when erasing the previous cycle. * * @param visible the flag. */ public void setAdvanceLineVisible(boolean visible) { this.advanceLineVisible = visible; } /** * The advance line is the line drawn at the limit of the current cycle, * when erasing the previous cycle. * * @return The paint (never null). */ public Paint getAdvanceLinePaint() { return this.advanceLinePaint; } /** * The advance line is the line drawn at the limit of the current cycle, * when erasing the previous cycle. * * @param paint the paint (null not permitted). */ public void setAdvanceLinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.advanceLinePaint = paint; } /** * The advance line is the line drawn at the limit of the current cycle, * when erasing the previous cycle. * * @return The stroke (never null). */ public Stroke getAdvanceLineStroke() { return this.advanceLineStroke; } /** * The advance line is the line drawn at the limit of the current cycle, * when erasing the previous cycle. * * @param stroke the stroke (null not permitted). */ public void setAdvanceLineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.advanceLineStroke = stroke; } /** * The cycle bound can be associated either with the current or with the * last cycle. It's up to the user's choice to decide which, as this is * just a convention. By default, the cycle bound is mapped to the current * cycle. *
* Note that this has no effect on visual appearance, as the cycle bound is * mapped successively for both axis ends. Use this function for correct * results in translateValueToJava2D. * * @return true if the cycle bound is mapped to the last * cycle, false if it is bound to the current cycle * (default) */ public boolean isBoundMappedToLastCycle() { return this.boundMappedToLastCycle; } /** * The cycle bound can be associated either with the current or with the * last cycle. It's up to the user's choice to decide which, as this is * just a convention. By default, the cycle bound is mapped to the current * cycle. *
* Note that this has no effect on visual appearance, as the cycle bound is * mapped successively for both axis ends. Use this function for correct * results in valueToJava2D. * * @param boundMappedToLastCycle Set it to true to map the cycle bound to * the last cycle. */ public void setBoundMappedToLastCycle(boolean boundMappedToLastCycle) { this.boundMappedToLastCycle = boundMappedToLastCycle; } /** * Selects a tick unit when the axis is displayed horizontally. * * @param g2 the graphics device. * @param drawArea the drawing area. * @param dataArea the data area. * @param edge the side of the rectangle on which the axis is displayed. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // Compute number of labels double n = getRange().getLength() * tickLabelWidth / dataArea.getWidth(); setTickUnit( (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n), false, false ); } /** * Selects a tick unit when the axis is displayed vertically. * * @param g2 the graphics device. * @param drawArea the drawing area. * @param dataArea the data area. * @param edge the side of the rectangle on which the axis is displayed. */ protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // Compute number of labels double n = getRange().getLength() * tickLabelWidth / dataArea.getHeight(); setTickUnit( (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n), false, false ); } /** * A special Number tick that also hold information about the cycle bound * mapping for this tick. This is especially useful for having a tick at * each axis end with the cycle bound value. See also * isBoundMappedToLastCycle() */ protected static class CycleBoundTick extends NumberTick { /** Map to last cycle. */ public boolean mapToLastCycle; /** * Creates a new tick. * * @param mapToLastCycle map to last cycle? * @param number the number. * @param label the label. * @param textAnchor the text anchor. * @param rotationAnchor the rotation anchor. * @param angle the rotation angle. */ public CycleBoundTick(boolean mapToLastCycle, Number number, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { super(number, label, textAnchor, rotationAnchor, angle); this.mapToLastCycle = mapToLastCycle; } } /** * Calculates the anchor point for a tick. * * @param tick the tick. * @param cursor the cursor. * @param dataArea the data area. * @param edge the side on which the axis is displayed. * * @return The anchor point. */ protected float[] calculateAnchorPoint(ValueTick tick, double cursor, Rectangle2D dataArea, RectangleEdge edge) { if (tick instanceof CycleBoundTick) { boolean mapsav = this.boundMappedToLastCycle; this.boundMappedToLastCycle = ((CycleBoundTick) tick).mapToLastCycle; float[] ret = super.calculateAnchorPoint( tick, cursor, dataArea, edge ); this.boundMappedToLastCycle = mapsav; return ret; } return super.calculateAnchorPoint(tick, cursor, dataArea, edge); } /** * Builds a list of ticks for the axis. This method is called when the * axis is at the top or bottom of the chart (so the axis is "horizontal"). * * @param g2 the graphics device. * @param dataArea the data area. * @param edge the edge. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } double unit = getTickUnit().getSize(); double cycleBound = getCycleBound(); double currentTickValue = Math.ceil(cycleBound / unit) * unit; double upperValue = getRange().getUpperBound(); boolean cycled = false; boolean boundMapping = this.boundMappedToLastCycle; this.boundMappedToLastCycle = false; CycleBoundTick lastTick = null; float lastX = 0.0f; if (upperValue == cycleBound) { currentTickValue = calculateLowestVisibleTickValue(); cycled = true; this.boundMappedToLastCycle = true; } while (currentTickValue <= upperValue) { // Cycle when necessary boolean cyclenow = false; if ((currentTickValue + unit > upperValue) && !cycled) { cyclenow = true; } double xx = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } float x = (float) xx; TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } anchor = TextAnchor.CENTER_RIGHT; // If tick overlap when cycling, update last tick too if ((lastTick != null) && (lastX == x) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.TOP_RIGHT : TextAnchor.BOTTOM_RIGHT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.BOTTOM_RIGHT : TextAnchor.TOP_RIGHT; } rotationAnchor = anchor; } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; if ((lastTick != null) && (lastX == x) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.BOTTOM_LEFT : TextAnchor.BOTTOM_RIGHT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.BOTTOM_RIGHT : TextAnchor.BOTTOM_LEFT; } rotationAnchor = anchor; } else { anchor = TextAnchor.TOP_CENTER; if ((lastTick != null) && (lastX == x) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.TOP_LEFT : TextAnchor.TOP_RIGHT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.TOP_RIGHT : TextAnchor.TOP_LEFT; } rotationAnchor = anchor; } } CycleBoundTick tick = new CycleBoundTick( this.boundMappedToLastCycle, new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle ); if (currentTickValue == cycleBound) { this.internalMarkerCycleBoundTick = tick; } result.add(tick); lastTick = tick; lastX = x; currentTickValue += unit; if (cyclenow) { currentTickValue = calculateLowestVisibleTickValue(); upperValue = cycleBound; cycled = true; this.boundMappedToLastCycle = true; } } this.boundMappedToLastCycle = boundMapping; return result; } /** * Builds a list of ticks for the axis. This method is called when the * axis is at the left or right of the chart (so the axis is "vertical"). * * @param g2 the graphics device. * @param dataArea the data area. * @param edge the edge. * * @return A list of ticks. */ protected List refreshVerticalTicks(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); result.clear(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } double unit = getTickUnit().getSize(); double cycleBound = getCycleBound(); double currentTickValue = Math.ceil(cycleBound / unit) * unit; double upperValue = getRange().getUpperBound(); boolean cycled = false; boolean boundMapping = this.boundMappedToLastCycle; this.boundMappedToLastCycle = true; NumberTick lastTick = null; float lastY = 0.0f; if (upperValue == cycleBound) { currentTickValue = calculateLowestVisibleTickValue(); cycled = true; this.boundMappedToLastCycle = true; } while (currentTickValue <= upperValue) { // Cycle when necessary boolean cyclenow = false; if ((currentTickValue + unit > upperValue) && !cycled) { cyclenow = true; } double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } float y = (float) yy; TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.BOTTOM_CENTER; if ((lastTick != null) && (lastY == y) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.BOTTOM_LEFT : TextAnchor.BOTTOM_RIGHT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.BOTTOM_RIGHT : TextAnchor.BOTTOM_LEFT; } rotationAnchor = anchor; angle = -Math.PI / 2.0; } else { anchor = TextAnchor.BOTTOM_CENTER; if ((lastTick != null) && (lastY == y) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.BOTTOM_RIGHT : TextAnchor.BOTTOM_LEFT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.BOTTOM_LEFT : TextAnchor.BOTTOM_RIGHT; } rotationAnchor = anchor; angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; if ((lastTick != null) && (lastY == y) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.BOTTOM_RIGHT : TextAnchor.TOP_RIGHT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.TOP_RIGHT : TextAnchor.BOTTOM_RIGHT; } rotationAnchor = anchor; } else { anchor = TextAnchor.CENTER_LEFT; if ((lastTick != null) && (lastY == y) && (currentTickValue != cycleBound)) { anchor = isInverted() ? TextAnchor.BOTTOM_LEFT : TextAnchor.TOP_LEFT; result.remove(result.size() - 1); result.add(new CycleBoundTick( this.boundMappedToLastCycle, lastTick.getNumber(), lastTick.getText(), anchor, anchor, lastTick.getAngle()) ); this.internalMarkerWhenTicksOverlap = true; anchor = isInverted() ? TextAnchor.TOP_LEFT : TextAnchor.BOTTOM_LEFT; } rotationAnchor = anchor; } } CycleBoundTick tick = new CycleBoundTick( this.boundMappedToLastCycle, new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle ); if (currentTickValue == cycleBound) { this.internalMarkerCycleBoundTick = tick; } result.add(tick); lastTick = tick; lastY = y; if (currentTickValue == cycleBound) { this.internalMarkerCycleBoundTick = tick; } currentTickValue += unit; if (cyclenow) { currentTickValue = calculateLowestVisibleTickValue(); upperValue = cycleBound; cycled = true; this.boundMappedToLastCycle = false; } } this.boundMappedToLastCycle = boundMapping; return result; } /** * Converts a coordinate from Java 2D space to data space. * * @param java2DValue the coordinate in Java2D space. * @param dataArea the data area. * @param edge the edge. * * @return The data value. */ public double java2DToValue(double java2DValue, Rectangle2D dataArea, RectangleEdge edge) { Range range = getRange(); double vmax = range.getUpperBound(); double vp = getCycleBound(); double jmin = 0.0; double jmax = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { jmin = dataArea.getMinX(); jmax = dataArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { jmin = dataArea.getMaxY(); jmax = dataArea.getMinY(); } if (isInverted()) { double jbreak = jmax - (vmax - vp) * (jmax - jmin) / this.period; if (java2DValue >= jbreak) { return vp + (jmax - java2DValue) * this.period / (jmax - jmin); } else { return vp - (java2DValue - jmin) * this.period / (jmax - jmin); } } else { double jbreak = (vmax - vp) * (jmax - jmin) / this.period + jmin; if (java2DValue <= jbreak) { return vp + (java2DValue - jmin) * this.period / (jmax - jmin); } else { return vp - (jmax - java2DValue) * this.period / (jmax - jmin); } } } /** * Translates a value from data space to Java 2D space. * * @param value the data value. * @param dataArea the data area. * @param edge the edge. * * @return The Java 2D value. */ public double valueToJava2D(double value, Rectangle2D dataArea, RectangleEdge edge) { Range range = getRange(); double vmin = range.getLowerBound(); double vmax = range.getUpperBound(); double vp = getCycleBound(); if ((value < vmin) || (value > vmax)) { return Double.NaN; } double jmin = 0.0; double jmax = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { jmin = dataArea.getMinX(); jmax = dataArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { jmax = dataArea.getMinY(); jmin = dataArea.getMaxY(); } if (isInverted()) { if (value == vp) { return this.boundMappedToLastCycle ? jmin : jmax; } else if (value > vp) { return jmax - (value - vp) * (jmax - jmin) / this.period; } else { return jmin + (vp - value) * (jmax - jmin) / this.period; } } else { if (value == vp) { return this.boundMappedToLastCycle ? jmax : jmin; } else if (value >= vp) { return jmin + (value - vp) * (jmax - jmin) / this.period; } else { return jmax - (vp - value) * (jmax - jmin) / this.period; } } } /** * Centers the range about the given value. * * @param value the data value. */ public void centerRange(double value) { setRange(value - this.period / 2.0, value + this.period / 2.0); } /** * This function is nearly useless since the auto range is fixed for this * class to the period. The period is extended if necessary to fit the * minimum size. * * @param size the size. * @param notify notify? * * @see org.jfree.chart.axis.ValueAxis#setAutoRangeMinimumSize(double, * boolean) */ public void setAutoRangeMinimumSize(double size, boolean notify) { if (size > this.period) { this.period = size; } super.setAutoRangeMinimumSize(size, notify); } /** * The auto range is fixed for this class to the period by default. * This function will thus set a new period. * * @param length the length. * * @see org.jfree.chart.axis.ValueAxis#setFixedAutoRange(double) */ public void setFixedAutoRange(double length) { this.period = length; super.setFixedAutoRange(length); } /** * Sets a new axis range. The period is extended to fit the range size, if * necessary. * * @param range the range. * @param turnOffAutoRange switch off the auto range. * @param notify notify? * * @see org.jfree.chart.axis.ValueAxis#setRange(Range, boolean, boolean) */ public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { double size = range.getUpperBound() - range.getLowerBound(); if (size > this.period) { this.period = size; } super.setRange(range, turnOffAutoRange, notify); } /** * The cycle bound is defined as the higest value x such that * "offset + period * i = x", with i and integer and x < * range.getUpperBound() This is the value which is at both ends of the * axis : x...up|low...x * The values from x to up are the valued in the current cycle. * The values from low to x are the valued in the previous cycle. * * @return The cycle bound. */ public double getCycleBound() { return Math.floor( (getRange().getUpperBound() - this.offset) / this.period ) * this.period + this.offset; } /** * The cycle bound is a multiple of the period, plus optionally a start * offset. *

*

cb = n * period + offset

* * @return The current offset. * * @see #getCycleBound() */ public double getOffset() { return this.offset; } /** * The cycle bound is a multiple of the period, plus optionally a start * offset. *

*

cb = n * period + offset

* * @param offset The offset to set. * * @see #getCycleBound() */ public void setOffset(double offset) { this.offset = offset; } /** * The cycle bound is a multiple of the period, plus optionally a start * offset. *

*

cb = n * period + offset

* * @return The current period. * * @see #getCycleBound() */ public double getPeriod() { return this.period; } /** * The cycle bound is a multiple of the period, plus optionally a start * offset. *

*

cb = n * period + offset

* * @param period The period to set. * * @see #getCycleBound() */ public void setPeriod(double period) { this.period = period; } /** * Draws the tick marks and labels. * * @param g2 the graphics device. * @param cursor the cursor. * @param plotArea the plot area. * @param dataArea the area inside the axes. * @param edge the side on which the axis is displayed. * * @return The axis state. */ protected AxisState drawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) { this.internalMarkerWhenTicksOverlap = false; AxisState ret = super.drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); // continue and separate the labels only if necessary if (!this.internalMarkerWhenTicksOverlap) { return ret; } double ol = getTickMarkOutsideLength(); FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); if (isVerticalTickLabels()) { ol = fm.getMaxAdvance(); } else { ol = fm.getHeight(); } double il = 0; if (isTickMarksVisible()) { float xx = (float) valueToJava2D(getRange().getUpperBound(), dataArea, edge); Line2D mark = null; g2.setStroke(getTickMarkStroke()); g2.setPaint(getTickMarkPaint()); if (edge == RectangleEdge.LEFT) { mark = new Line2D.Double(cursor - ol, xx, cursor + il, xx); } else if (edge == RectangleEdge.RIGHT) { mark = new Line2D.Double(cursor + ol, xx, cursor - il, xx); } else if (edge == RectangleEdge.TOP) { mark = new Line2D.Double(xx, cursor - ol, xx, cursor + il); } else if (edge == RectangleEdge.BOTTOM) { mark = new Line2D.Double(xx, cursor + ol, xx, cursor - il); } g2.draw(mark); } return ret; } /** * Draws the axis. * * @param g2 the graphics device (null not permitted). * @param cursor the cursor position. * @param plotArea the plot area (null not permitted). * @param dataArea the data area (null not permitted). * @param edge the edge (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState ret = super.draw( g2, cursor, plotArea, dataArea, edge, plotState ); if (isAdvanceLineVisible()) { double xx = valueToJava2D( getRange().getUpperBound(), dataArea, edge ); Line2D mark = null; g2.setStroke(getAdvanceLineStroke()); g2.setPaint(getAdvanceLinePaint()); if (edge == RectangleEdge.LEFT) { mark = new Line2D.Double( cursor, xx, cursor + dataArea.getWidth(), xx ); } else if (edge == RectangleEdge.RIGHT) { mark = new Line2D.Double( cursor - dataArea.getWidth(), xx, cursor, xx ); } else if (edge == RectangleEdge.TOP) { mark = new Line2D.Double( xx, cursor + dataArea.getHeight(), xx, cursor ); } else if (edge == RectangleEdge.BOTTOM) { mark = new Line2D.Double( xx, cursor, xx, cursor - dataArea.getHeight() ); } g2.draw(mark); } return ret; } /** * Reserve some space on each axis side because we draw a centered label at * each extremity. * * @param g2 the graphics device. * @param plot the plot. * @param plotArea the plot area. * @param edge the edge. * @param space the space already reserved. * * @return The reserved space. */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { this.internalMarkerCycleBoundTick = null; AxisSpace ret = super.reserveSpace(g2, plot, plotArea, edge, space); if (this.internalMarkerCycleBoundTick == null) { return ret; } FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); Rectangle2D r = TextUtilities.getTextBounds( this.internalMarkerCycleBoundTick.getText(), g2, fm ); if (RectangleEdge.isTopOrBottom(edge)) { if (isVerticalTickLabels()) { space.add(r.getHeight() / 2, RectangleEdge.RIGHT); } else { space.add(r.getWidth() / 2, RectangleEdge.RIGHT); } } else if (RectangleEdge.isLeftOrRight(edge)) { if (isVerticalTickLabels()) { space.add(r.getWidth() / 2, RectangleEdge.TOP); } else { space.add(r.getHeight() / 2, RectangleEdge.TOP); } } return ret; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.advanceLinePaint, stream); SerialUtilities.writeStroke(this.advanceLineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.advanceLinePaint = SerialUtilities.readPaint(stream); this.advanceLineStroke = SerialUtilities.readStroke(stream); } /** * Tests the axis for equality with another object. * * @param obj the object to test against. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CyclicNumberAxis)) { return false; } if (!super.equals(obj)) { return false; } CyclicNumberAxis that = (CyclicNumberAxis) obj; if (this.period != that.period) { return false; } if (this.offset != that.offset) { return false; } if (!PaintUtilities.equal(this.advanceLinePaint, that.advanceLinePaint)) { return false; } if (!ObjectUtilities.equal(this.advanceLineStroke, that.advanceLineStroke)) { return false; } if (this.advanceLineVisible != that.advanceLineVisible) { return false; } if (this.boundMappedToLastCycle != that.boundMappedToLastCycle) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/DateAxis.java0000644000175000017500000022267611173030414025761 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * DateAxis.java * ------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert; * Contributor(s): Jonathan Nash; * David Li; * Michael Rauch; * Bill Kelemen; * Pawel Pabis; * Chris Boek; * Peter Kolb (patches 1934255 and 2603321); * Andrew Mickish (patch 1870189); * Fawad Halim (bug 2201869); * * Changes (from 23-Jun-2001) * -------------------------- * 23-Jun-2001 : Modified to work with null data source (DG); * 18-Sep-2001 : Updated header (DG); * 27-Nov-2001 : Changed constructors from public to protected, updated Javadoc * comments (DG); * 16-Jan-2002 : Added an optional crosshair, based on the implementation by * Jonathan Nash (DG); * 26-Feb-2002 : Updated import statements (DG); * 22-Apr-2002 : Added a setRange() method (DG); * 25-Jun-2002 : Removed redundant local variable (DG); * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); * 21-Aug-2002 : The setTickUnit() method now turns off auto-tick unit * selection (fix for bug id 528885) (DG); * 05-Sep-2002 : Updated the constructors to reflect changes in the Axis * class (DG); * 18-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 25-Sep-2002 : Added new setRange() methods, and deprecated * setAxisRange() (DG); * 04-Oct-2002 : Changed auto tick selection to parallel number axis * classes (DG); * 24-Oct-2002 : Added a date format override (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double, moved * crosshair settings to the plot (DG); * 15-Jan-2003 : Removed anchor date (DG); * 20-Jan-2003 : Removed unnecessary constructors (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 02-May-2003 : Added additional units to createStandardDateTickUnits() * method, as suggested by mhilpert in bug report 723187 (DG); * 13-May-2003 : Merged HorizontalDateAxis and VerticalDateAxis (DG); * 24-May-2003 : Added support for underlying timeline for * SegmentedTimeline (BK); * 16-Jul-2003 : Applied patch from Pawel Pabis to fix overlapping dates (DG); * 22-Jul-2003 : Applied patch from Pawel Pabis for monthly ticks (DG); * 25-Jul-2003 : Fixed bug 777561 and 777586 (DG); * 13-Aug-2003 : Implemented Cloneable and added equals() method (DG); * 02-Sep-2003 : Fixes for bug report 790506 (DG); * 04-Sep-2003 : Fixed tick label alignment when axis appears at the top (DG); * 10-Sep-2003 : Fixes for segmented timeline (DG); * 17-Sep-2003 : Fixed a layout bug when multiple domain axes are used (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 07-Nov-2003 : Modified to use new tick classes (DG); * 12-Nov-2003 : Modified tick labelling to use roll unit from DateTickUnit * when a calculated tick value is hidden (which can occur in * segmented date axes) (DG); * 24-Nov-2003 : Fixed some problems with the auto tick unit selection, and * fixed bug 846277 (labels missing for inverted axis) (DG); * 30-Dec-2003 : Fixed bug in refreshTicksHorizontal() when start of time unit * (ex. 1st of month) was hidden, causing infinite loop (BK); * 13-Jan-2004 : Fixed bug in previousStandardDate() method (fix by Richard * Wardle) (DG); * 21-Jan-2004 : Renamed translateJava2DToValue --> java2DToValue, and * translateValueToJava2D --> valueToJava2D (DG); * 12-Mar-2004 : Fixed bug where date format override is ignored for vertical * axis (DG); * 16-Mar-2004 : Added plotState to draw() method (DG); * 07-Apr-2004 : Changed string width calculation (DG); * 21-Apr-2004 : Fixed bug in estimateMaximumTickLabelWidth() method (bug id * 939148) (DG); * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * 13-Jan-2005 : Fixed bug (see * http://www.jfree.org/forum/viewtopic.php?t=11330) (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets, removed redundant * argument from selectAutoTickUnit() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 10-Feb-2006 : Added some API doc comments in respect of bug 821046 (DG); * 19-Apr-2006 : Fixed bug 1472942 in equals() method (DG); * 25-Sep-2006 : Fixed bug 1564977 missing tick labels (DG); * 15-Jan-2007 : Added get/setTimeZone() suggested by 'skunk' (DG); * 18-Jan-2007 : Fixed bug 1638678, time zone for calendar in * previousStandardDate() (DG); * 04-Apr-2007 : Use time zone in date calculations (CB); * 19-Apr-2007 : Fix exceptions in setMinimum/MaximumDate() (DG); * 03-May-2007 : Fixed minor bugs in previousStandardDate(), with new JUnit * tests (DG); * 21-Nov-2007 : Fixed warnings from FindBugs (DG); * 01-Sep-2008 : Use new methods from DateRange, added fix for bug * 2078057 (DG); * 18-Sep-2008 : Added locale to go with timezone (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * 25-Nov-2008 : Added bug fix 2201869 by Fawad Halim (DG); * 21-Jan-2009 : Check tickUnit for minor tick count (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart.axis; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.TimeZone; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.data.Range; import org.jfree.data.time.DateRange; import org.jfree.data.time.Month; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.Year; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; /** * The base class for axes that display dates. You will find it easier to * understand how this axis works if you bear in mind that it really * displays/measures integer (or long) data, where the integers are * milliseconds since midnight, 1-Jan-1970. When displaying tick labels, the * millisecond values are converted back to dates using a * DateFormat instance. *

* You can also create a {@link org.jfree.chart.axis.Timeline} and supply in * the constructor to create an axis that only contains certain domain values. * For example, this allows you to create a date axis that only contains * working days. */ public class DateAxis extends ValueAxis implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -1013460999649007604L; /** The default axis range. */ public static final DateRange DEFAULT_DATE_RANGE = new DateRange(); /** The default minimum auto range size. */ public static final double DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS = 2.0; /** The default date tick unit. */ public static final DateTickUnit DEFAULT_DATE_TICK_UNIT = new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat()); /** The default anchor date. */ public static final Date DEFAULT_ANCHOR_DATE = new Date(); /** The current tick unit. */ private DateTickUnit tickUnit; /** The override date format. */ private DateFormat dateFormatOverride; /** * Tick marks can be displayed at the start or the middle of the time * period. */ private DateTickMarkPosition tickMarkPosition = DateTickMarkPosition.START; /** * A timeline that includes all milliseconds (as defined by * java.util.Date) in the real time line. */ private static class DefaultTimeline implements Timeline, Serializable { /** * Converts a millisecond into a timeline value. * * @param millisecond the millisecond. * * @return The timeline value. */ public long toTimelineValue(long millisecond) { return millisecond; } /** * Converts a date into a timeline value. * * @param date the domain value. * * @return The timeline value. */ public long toTimelineValue(Date date) { return date.getTime(); } /** * Converts a timeline value into a millisecond (as encoded by * java.util.Date). * * @param value the value. * * @return The millisecond. */ public long toMillisecond(long value) { return value; } /** * Returns true if the timeline includes the specified * domain value. * * @param millisecond the millisecond. * * @return true. */ public boolean containsDomainValue(long millisecond) { return true; } /** * Returns true if the timeline includes the specified * domain value. * * @param date the date. * * @return true. */ public boolean containsDomainValue(Date date) { return true; } /** * Returns true if the timeline includes the specified * domain value range. * * @param from the start value. * @param to the end value. * * @return true. */ public boolean containsDomainRange(long from, long to) { return true; } /** * Returns true if the timeline includes the specified * domain value range. * * @param from the start date. * @param to the end date. * * @return true. */ public boolean containsDomainRange(Date from, Date to) { return true; } /** * Tests an object for equality with this instance. * * @param object the object. * * @return A boolean. */ public boolean equals(Object object) { if (object == null) { return false; } if (object == this) { return true; } if (object instanceof DefaultTimeline) { return true; } return false; } } /** A static default timeline shared by all standard DateAxis */ private static final Timeline DEFAULT_TIMELINE = new DefaultTimeline(); /** The time zone for the axis. */ private TimeZone timeZone; /** * The locale for the axis (null is not permitted). * * @since 1.0.11 */ private Locale locale; /** Our underlying timeline. */ private Timeline timeline; /** * Creates a date axis with no label. */ public DateAxis() { this(null); } /** * Creates a date axis with the specified label. * * @param label the axis label (null permitted). */ public DateAxis(String label) { this(label, TimeZone.getDefault()); } /** * Creates a date axis. A timeline is specified for the axis. This allows * special transformations to occur between a domain of values and the * values included in the axis. * * @see org.jfree.chart.axis.SegmentedTimeline * * @param label the axis label (null permitted). * @param zone the time zone. * * @deprecated From 1.0.11 onwards, use {@link #DateAxis(String, TimeZone, * Locale)} instead, to explicitly set the locale. */ public DateAxis(String label, TimeZone zone) { this(label, zone, Locale.getDefault()); } /** * Creates a date axis. A timeline is specified for the axis. This allows * special transformations to occur between a domain of values and the * values included in the axis. * * @see org.jfree.chart.axis.SegmentedTimeline * * @param label the axis label (null permitted). * @param zone the time zone. * @param locale the locale (null not permitted). * * @since 1.0.11 */ public DateAxis(String label, TimeZone zone, Locale locale) { super(label, DateAxis.createStandardDateTickUnits(zone, locale)); setTickUnit(DateAxis.DEFAULT_DATE_TICK_UNIT, false, false); setAutoRangeMinimumSize( DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS); setRange(DEFAULT_DATE_RANGE, false, false); this.dateFormatOverride = null; this.timeZone = zone; this.locale = locale; this.timeline = DEFAULT_TIMELINE; } /** * Returns the time zone for the axis. * * @return The time zone (never null). * * @since 1.0.4 * * @see #setTimeZone(TimeZone) */ public TimeZone getTimeZone() { return this.timeZone; } /** * Sets the time zone for the axis and sends an {@link AxisChangeEvent} to * all registered listeners. * * @param zone the time zone (null not permitted). * * @since 1.0.4 * * @see #getTimeZone() */ public void setTimeZone(TimeZone zone) { if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (!this.timeZone.equals(zone)) { this.timeZone = zone; setStandardTickUnits(createStandardDateTickUnits(zone, this.locale)); notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the underlying timeline used by this axis. * * @return The timeline. */ public Timeline getTimeline() { return this.timeline; } /** * Sets the underlying timeline to use for this axis. *

* If the timeline is changed, an {@link AxisChangeEvent} is sent to all * registered listeners. * * @param timeline the timeline. */ public void setTimeline(Timeline timeline) { if (this.timeline != timeline) { this.timeline = timeline; notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the tick unit for the axis. *

* Note: if the autoTickUnitSelection flag is * true the tick unit may be changed while the axis is being * drawn, so in that case the return value from this method may be * irrelevant if the method is called before the axis has been drawn. * * @return The tick unit (possibly null). * * @see #setTickUnit(DateTickUnit) * @see ValueAxis#isAutoTickUnitSelection() */ public DateTickUnit getTickUnit() { return this.tickUnit; } /** * Sets the tick unit for the axis. The auto-tick-unit-selection flag is * set to false, and registered listeners are notified that * the axis has been changed. * * @param unit the tick unit. * * @see #getTickUnit() * @see #setTickUnit(DateTickUnit, boolean, boolean) */ public void setTickUnit(DateTickUnit unit) { setTickUnit(unit, true, true); } /** * Sets the tick unit attribute. * * @param unit the new tick unit. * @param notify notify registered listeners? * @param turnOffAutoSelection turn off auto selection? * * @see #getTickUnit() */ public void setTickUnit(DateTickUnit unit, boolean notify, boolean turnOffAutoSelection) { this.tickUnit = unit; if (turnOffAutoSelection) { setAutoTickUnitSelection(false, false); } if (notify) { notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the date format override. If this is non-null, then it will be * used to format the dates on the axis. * * @return The formatter (possibly null). */ public DateFormat getDateFormatOverride() { return this.dateFormatOverride; } /** * Sets the date format override. If this is non-null, then it will be * used to format the dates on the axis. * * @param formatter the date formatter (null permitted). */ public void setDateFormatOverride(DateFormat formatter) { this.dateFormatOverride = formatter; notifyListeners(new AxisChangeEvent(this)); } /** * Sets the upper and lower bounds for the axis and sends an * {@link AxisChangeEvent} to all registered listeners. As a side-effect, * the auto-range flag is set to false. * * @param range the new range (null not permitted). */ public void setRange(Range range) { setRange(range, true, true); } /** * Sets the range for the axis, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. As a side-effect, * the auto-range flag is set to false (optional). * * @param range the range (null not permitted). * @param turnOffAutoRange a flag that controls whether or not the auto * range is turned off. * @param notify a flag that controls whether or not listeners are * notified. */ public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } // usually the range will be a DateRange, but if it isn't do a // conversion... if (!(range instanceof DateRange)) { range = new DateRange(range); } super.setRange(range, turnOffAutoRange, notify); } /** * Sets the axis range and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param lower the lower bound for the axis. * @param upper the upper bound for the axis. */ public void setRange(Date lower, Date upper) { if (lower.getTime() >= upper.getTime()) { throw new IllegalArgumentException("Requires 'lower' < 'upper'."); } setRange(new DateRange(lower, upper)); } /** * Sets the axis range and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param lower the lower bound for the axis. * @param upper the upper bound for the axis. */ public void setRange(double lower, double upper) { if (lower >= upper) { throw new IllegalArgumentException("Requires 'lower' < 'upper'."); } setRange(new DateRange(lower, upper)); } /** * Returns the earliest date visible on the axis. * * @return The date. * * @see #setMinimumDate(Date) * @see #getMaximumDate() */ public Date getMinimumDate() { Date result = null; Range range = getRange(); if (range instanceof DateRange) { DateRange r = (DateRange) range; result = r.getLowerDate(); } else { result = new Date((long) range.getLowerBound()); } return result; } /** * Sets the minimum date visible on the axis and sends an * {@link AxisChangeEvent} to all registered listeners. If * date is on or after the current maximum date for * the axis, the maximum date will be shifted to preserve the current * length of the axis. * * @param date the date (null not permitted). * * @see #getMinimumDate() * @see #setMaximumDate(Date) */ public void setMinimumDate(Date date) { if (date == null) { throw new IllegalArgumentException("Null 'date' argument."); } // check the new minimum date relative to the current maximum date Date maxDate = getMaximumDate(); long maxMillis = maxDate.getTime(); long newMinMillis = date.getTime(); if (maxMillis <= newMinMillis) { Date oldMin = getMinimumDate(); long length = maxMillis - oldMin.getTime(); maxDate = new Date(newMinMillis + length); } setRange(new DateRange(date, maxDate), true, false); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the latest date visible on the axis. * * @return The date. * * @see #setMaximumDate(Date) * @see #getMinimumDate() */ public Date getMaximumDate() { Date result = null; Range range = getRange(); if (range instanceof DateRange) { DateRange r = (DateRange) range; result = r.getUpperDate(); } else { result = new Date((long) range.getUpperBound()); } return result; } /** * Sets the maximum date visible on the axis and sends an * {@link AxisChangeEvent} to all registered listeners. If * maximumDate is on or before the current minimum date for * the axis, the minimum date will be shifted to preserve the current * length of the axis. * * @param maximumDate the date (null not permitted). * * @see #getMinimumDate() * @see #setMinimumDate(Date) */ public void setMaximumDate(Date maximumDate) { if (maximumDate == null) { throw new IllegalArgumentException("Null 'maximumDate' argument."); } // check the new maximum date relative to the current minimum date Date minDate = getMinimumDate(); long minMillis = minDate.getTime(); long newMaxMillis = maximumDate.getTime(); if (minMillis >= newMaxMillis) { Date oldMax = getMaximumDate(); long length = oldMax.getTime() - minMillis; minDate = new Date(newMaxMillis - length); } setRange(new DateRange(minDate, maximumDate), true, false); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the tick mark position (start, middle or end of the time period). * * @return The position (never null). */ public DateTickMarkPosition getTickMarkPosition() { return this.tickMarkPosition; } /** * Sets the tick mark position (start, middle or end of the time period) * and sends an {@link AxisChangeEvent} to all registered listeners. * * @param position the position (null not permitted). */ public void setTickMarkPosition(DateTickMarkPosition position) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } this.tickMarkPosition = position; notifyListeners(new AxisChangeEvent(this)); } /** * Configures the axis to work with the specified plot. If the axis has * auto-scaling, then sets the maximum and minimum values. */ public void configure() { if (isAutoRange()) { autoAdjustRange(); } } /** * Returns true if the axis hides this value, and * false otherwise. * * @param millis the data value. * * @return A value. */ public boolean isHiddenValue(long millis) { return (!this.timeline.containsDomainValue(new Date(millis))); } /** * Translates the data value to the display coordinates (Java 2D User Space) * of the chart. * * @param value the date to be plotted. * @param area the rectangle (in Java2D space) where the data is to be * plotted. * @param edge the axis location. * * @return The coordinate corresponding to the supplied data value. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { value = this.timeline.toTimelineValue((long) value); DateRange range = (DateRange) getRange(); double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); double result = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { double minX = area.getX(); double maxX = area.getMaxX(); if (isInverted()) { result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX); } else { result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX); } } else if (RectangleEdge.isLeftOrRight(edge)) { double minY = area.getMinY(); double maxY = area.getMaxY(); if (isInverted()) { result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } else { result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } } return result; } /** * Translates a date to Java2D coordinates, based on the range displayed by * this axis for the specified data area. * * @param date the date. * @param area the rectangle (in Java2D space) where the data is to be * plotted. * @param edge the axis location. * * @return The coordinate corresponding to the supplied date. */ public double dateToJava2D(Date date, Rectangle2D area, RectangleEdge edge) { double value = date.getTime(); return valueToJava2D(value, area, edge); } /** * Translates a Java2D coordinate into the corresponding data value. To * perform this translation, you need to know the area used for plotting * data, and which edge the axis is located on. * * @param java2DValue the coordinate in Java2D space. * @param area the rectangle (in Java2D space) where the data is to be * plotted. * @param edge the axis location. * * @return A data value. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { DateRange range = (DateRange) getRange(); double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } double result; if (isInverted()) { result = axisMax - ((java2DValue - min) / (max - min) * (axisMax - axisMin)); } else { result = axisMin + ((java2DValue - min) / (max - min) * (axisMax - axisMin)); } return this.timeline.toMillisecond((long) result); } /** * Calculates the value of the lowest visible tick on the axis. * * @param unit date unit to use. * * @return The value of the lowest visible tick on the axis. */ public Date calculateLowestVisibleTickValue(DateTickUnit unit) { return nextStandardDate(getMinimumDate(), unit); } /** * Calculates the value of the highest visible tick on the axis. * * @param unit date unit to use. * * @return The value of the highest visible tick on the axis. */ public Date calculateHighestVisibleTickValue(DateTickUnit unit) { return previousStandardDate(getMaximumDate(), unit); } /** * Returns the previous "standard" date, for a given date and tick unit. * * @param date the reference date. * @param unit the tick unit. * * @return The previous "standard" date. */ protected Date previousStandardDate(Date date, DateTickUnit unit) { int milliseconds; int seconds; int minutes; int hours; int days; int months; int years; Calendar calendar = Calendar.getInstance(this.timeZone, this.locale); calendar.setTime(date); int count = unit.getCount(); int current = calendar.get(unit.getCalendarField()); int value = count * (current / count); switch (unit.getUnit()) { case (DateTickUnit.MILLISECOND) : years = calendar.get(Calendar.YEAR); months = calendar.get(Calendar.MONTH); days = calendar.get(Calendar.DATE); hours = calendar.get(Calendar.HOUR_OF_DAY); minutes = calendar.get(Calendar.MINUTE); seconds = calendar.get(Calendar.SECOND); calendar.set(years, months, days, hours, minutes, seconds); calendar.set(Calendar.MILLISECOND, value); Date mm = calendar.getTime(); if (mm.getTime() >= date.getTime()) { calendar.set(Calendar.MILLISECOND, value - 1); mm = calendar.getTime(); } return mm; case (DateTickUnit.SECOND) : years = calendar.get(Calendar.YEAR); months = calendar.get(Calendar.MONTH); days = calendar.get(Calendar.DATE); hours = calendar.get(Calendar.HOUR_OF_DAY); minutes = calendar.get(Calendar.MINUTE); if (this.tickMarkPosition == DateTickMarkPosition.START) { milliseconds = 0; } else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { milliseconds = 500; } else { milliseconds = 999; } calendar.set(Calendar.MILLISECOND, milliseconds); calendar.set(years, months, days, hours, minutes, value); Date dd = calendar.getTime(); if (dd.getTime() >= date.getTime()) { calendar.set(Calendar.SECOND, value - 1); dd = calendar.getTime(); } return dd; case (DateTickUnit.MINUTE) : years = calendar.get(Calendar.YEAR); months = calendar.get(Calendar.MONTH); days = calendar.get(Calendar.DATE); hours = calendar.get(Calendar.HOUR_OF_DAY); if (this.tickMarkPosition == DateTickMarkPosition.START) { seconds = 0; } else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { seconds = 30; } else { seconds = 59; } calendar.clear(Calendar.MILLISECOND); calendar.set(years, months, days, hours, value, seconds); Date d0 = calendar.getTime(); if (d0.getTime() >= date.getTime()) { calendar.set(Calendar.MINUTE, value - 1); d0 = calendar.getTime(); } return d0; case (DateTickUnit.HOUR) : years = calendar.get(Calendar.YEAR); months = calendar.get(Calendar.MONTH); days = calendar.get(Calendar.DATE); if (this.tickMarkPosition == DateTickMarkPosition.START) { minutes = 0; seconds = 0; } else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { minutes = 30; seconds = 0; } else { minutes = 59; seconds = 59; } calendar.clear(Calendar.MILLISECOND); calendar.set(years, months, days, value, minutes, seconds); Date d1 = calendar.getTime(); if (d1.getTime() >= date.getTime()) { calendar.set(Calendar.HOUR_OF_DAY, value - 1); d1 = calendar.getTime(); } return d1; case (DateTickUnit.DAY) : years = calendar.get(Calendar.YEAR); months = calendar.get(Calendar.MONTH); if (this.tickMarkPosition == DateTickMarkPosition.START) { hours = 0; minutes = 0; seconds = 0; } else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { hours = 12; minutes = 0; seconds = 0; } else { hours = 23; minutes = 59; seconds = 59; } calendar.clear(Calendar.MILLISECOND); calendar.set(years, months, value, hours, 0, 0); // long result = calendar.getTimeInMillis(); // won't work with JDK 1.3 Date d2 = calendar.getTime(); if (d2.getTime() >= date.getTime()) { calendar.set(Calendar.DATE, value - 1); d2 = calendar.getTime(); } return d2; case (DateTickUnit.MONTH) : years = calendar.get(Calendar.YEAR); calendar.clear(Calendar.MILLISECOND); calendar.set(years, value, 1, 0, 0, 0); Month month = new Month(calendar.getTime(), this.timeZone, this.locale); Date standardDate = calculateDateForPosition( month, this.tickMarkPosition); long millis = standardDate.getTime(); if (millis >= date.getTime()) { month = (Month) month.previous(); // need to peg the month in case the time zone isn't the // default - see bug 2078057 month.peg(Calendar.getInstance(this.timeZone)); standardDate = calculateDateForPosition( month, this.tickMarkPosition); } return standardDate; case(DateTickUnit.YEAR) : if (this.tickMarkPosition == DateTickMarkPosition.START) { months = 0; days = 1; } else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { months = 6; days = 1; } else { months = 11; days = 31; } calendar.clear(Calendar.MILLISECOND); calendar.set(value, months, days, 0, 0, 0); Date d3 = calendar.getTime(); if (d3.getTime() >= date.getTime()) { calendar.set(Calendar.YEAR, value - 1); d3 = calendar.getTime(); } return d3; default: return null; } } /** * Returns a {@link java.util.Date} corresponding to the specified position * within a {@link RegularTimePeriod}. * * @param period the period. * @param position the position (null not permitted). * * @return A date. */ private Date calculateDateForPosition(RegularTimePeriod period, DateTickMarkPosition position) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } Date result = null; if (position == DateTickMarkPosition.START) { result = new Date(period.getFirstMillisecond()); } else if (position == DateTickMarkPosition.MIDDLE) { result = new Date(period.getMiddleMillisecond()); } else if (position == DateTickMarkPosition.END) { result = new Date(period.getLastMillisecond()); } return result; } /** * Returns the first "standard" date (based on the specified field and * units). * * @param date the reference date. * @param unit the date tick unit. * * @return The next "standard" date. */ protected Date nextStandardDate(Date date, DateTickUnit unit) { Date previous = previousStandardDate(date, unit); Calendar calendar = Calendar.getInstance(this.timeZone, this.locale); calendar.setTime(previous); calendar.add(unit.getCalendarField(), unit.getMultiple()); return calendar.getTime(); } /** * Returns a collection of standard date tick units that uses the default * time zone. This collection will be used by default, but you are free * to create your own collection if you want to (see the * {@link ValueAxis#setStandardTickUnits(TickUnitSource)} method inherited * from the {@link ValueAxis} class). * * @return A collection of standard date tick units. */ public static TickUnitSource createStandardDateTickUnits() { return createStandardDateTickUnits(TimeZone.getDefault(), Locale.getDefault()); } /** * Returns a collection of standard date tick units. This collection will * be used by default, but you are free to create your own collection if * you want to (see the * {@link ValueAxis#setStandardTickUnits(TickUnitSource)} method inherited * from the {@link ValueAxis} class). * * @param zone the time zone (null not permitted). * * @return A collection of standard date tick units. * * @deprecated Since 1.0.11, use {@link #createStandardDateTickUnits( * TimeZone, Locale)} to explicitly set the locale as well as the * time zone. */ public static TickUnitSource createStandardDateTickUnits(TimeZone zone) { return createStandardDateTickUnits(zone, Locale.getDefault()); } /** * Returns a collection of standard date tick units. This collection will * be used by default, but you are free to create your own collection if * you want to (see the * {@link ValueAxis#setStandardTickUnits(TickUnitSource)} method inherited * from the {@link ValueAxis} class). * * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @return A collection of standard date tick units. * * @since 1.0.11 */ public static TickUnitSource createStandardDateTickUnits(TimeZone zone, Locale locale) { if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } TickUnits units = new TickUnits(); // date formatters DateFormat f1 = new SimpleDateFormat("HH:mm:ss.SSS", locale); DateFormat f2 = new SimpleDateFormat("HH:mm:ss", locale); DateFormat f3 = new SimpleDateFormat("HH:mm", locale); DateFormat f4 = new SimpleDateFormat("d-MMM, HH:mm", locale); DateFormat f5 = new SimpleDateFormat("d-MMM", locale); DateFormat f6 = new SimpleDateFormat("MMM-yyyy", locale); DateFormat f7 = new SimpleDateFormat("yyyy", locale); f1.setTimeZone(zone); f2.setTimeZone(zone); f3.setTimeZone(zone); f4.setTimeZone(zone); f5.setTimeZone(zone); f6.setTimeZone(zone); f7.setTimeZone(zone); // milliseconds units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 1, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 5, DateTickUnitType.MILLISECOND, 1, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 10, DateTickUnitType.MILLISECOND, 1, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 25, DateTickUnitType.MILLISECOND, 5, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 50, DateTickUnitType.MILLISECOND, 10, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 100, DateTickUnitType.MILLISECOND, 10, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 250, DateTickUnitType.MILLISECOND, 10, f1)); units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 500, DateTickUnitType.MILLISECOND, 50, f1)); // seconds units.add(new DateTickUnit(DateTickUnitType.SECOND, 1, DateTickUnitType.MILLISECOND, 50, f2)); units.add(new DateTickUnit(DateTickUnitType.SECOND, 5, DateTickUnitType.SECOND, 1, f2)); units.add(new DateTickUnit(DateTickUnitType.SECOND, 10, DateTickUnitType.SECOND, 1, f2)); units.add(new DateTickUnit(DateTickUnitType.SECOND, 30, DateTickUnitType.SECOND, 5, f2)); // minutes units.add(new DateTickUnit(DateTickUnitType.MINUTE, 1, DateTickUnitType.SECOND, 5, f3)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 2, DateTickUnitType.SECOND, 10, f3)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 5, DateTickUnitType.MINUTE, 1, f3)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 10, DateTickUnitType.MINUTE, 1, f3)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 15, DateTickUnitType.MINUTE, 5, f3)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 20, DateTickUnitType.MINUTE, 5, f3)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 30, DateTickUnitType.MINUTE, 5, f3)); // hours units.add(new DateTickUnit(DateTickUnitType.HOUR, 1, DateTickUnitType.MINUTE, 5, f3)); units.add(new DateTickUnit(DateTickUnitType.HOUR, 2, DateTickUnitType.MINUTE, 10, f3)); units.add(new DateTickUnit(DateTickUnitType.HOUR, 4, DateTickUnitType.MINUTE, 30, f3)); units.add(new DateTickUnit(DateTickUnitType.HOUR, 6, DateTickUnitType.HOUR, 1, f3)); units.add(new DateTickUnit(DateTickUnitType.HOUR, 12, DateTickUnitType.HOUR, 1, f4)); // days units.add(new DateTickUnit(DateTickUnitType.DAY, 1, DateTickUnitType.HOUR, 1, f5)); units.add(new DateTickUnit(DateTickUnitType.DAY, 2, DateTickUnitType.HOUR, 1, f5)); units.add(new DateTickUnit(DateTickUnitType.DAY, 7, DateTickUnitType.DAY, 1, f5)); units.add(new DateTickUnit(DateTickUnitType.DAY, 15, DateTickUnitType.DAY, 1, f5)); // months units.add(new DateTickUnit(DateTickUnitType.MONTH, 1, DateTickUnitType.DAY, 1, f6)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 2, DateTickUnitType.DAY, 1, f6)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 3, DateTickUnitType.MONTH, 1, f6)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 4, DateTickUnitType.MONTH, 1, f6)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 6, DateTickUnitType.MONTH, 1, f6)); // years units.add(new DateTickUnit(DateTickUnitType.YEAR, 1, DateTickUnitType.MONTH, 1, f7)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 2, DateTickUnitType.MONTH, 3, f7)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 5, DateTickUnitType.YEAR, 1, f7)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 10, DateTickUnitType.YEAR, 1, f7)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 25, DateTickUnitType.YEAR, 5, f7)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 50, DateTickUnitType.YEAR, 10, f7)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 100, DateTickUnitType.YEAR, 20, f7)); return units; } /** * Rescales the axis to ensure that all data is visible. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { if (this.timeline instanceof SegmentedTimeline) { //Timeline hasn't method getStartTime() r = new DateRange(( (SegmentedTimeline) this.timeline).getStartTime(), ((SegmentedTimeline) this.timeline).getStartTime() + 1); } else { r = new DateRange(); } } long upper = this.timeline.toTimelineValue( (long) r.getUpperBound()); long lower; long fixedAutoRange = (long) getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = upper - fixedAutoRange; } else { lower = this.timeline.toTimelineValue((long) r.getLowerBound()); double range = upper - lower; long minRange = (long) getAutoRangeMinimumSize(); if (range < minRange) { long expand = (long) (minRange - range) / 2; upper = upper + expand; lower = lower - expand; } upper = upper + (long) (range * getUpperMargin()); lower = lower - (long) (range * getLowerMargin()); } upper = this.timeline.toMillisecond(upper); lower = this.timeline.toMillisecond(lower); DateRange dr = new DateRange(new Date(lower), new Date(upper)); setRange(dr, false, false); } } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. */ protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { selectHorizontalAutoTickUnit(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { selectVerticalAutoTickUnit(g2, dataArea, edge); } } /** * Selects an appropriate tick size for the axis. The strategy is to * display as many ticks as possible (selected from a collection of * 'standard' tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { long shift = 0; if (this.timeline instanceof SegmentedTimeline) { shift = ((SegmentedTimeline) this.timeline).getStartTime(); } double zero = valueToJava2D(shift + 0.0, dataArea, edge); double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double x1 = valueToJava2D(shift + unit1.getSize(), dataArea, edge); double unit1Width = Math.abs(x1 - zero); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); DateTickUnit unit2 = (DateTickUnit) tickUnits.getCeilingTickUnit(guess); double x2 = valueToJava2D(shift + unit2.getSize(), dataArea, edge); double unit2Width = Math.abs(x2 - zero); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (DateTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); } /** * Selects an appropriate tick size for the axis. The strategy is to * display as many ticks as possible (selected from a collection of * 'standard' tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the axis location. */ protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); double zero = valueToJava2D(0.0, dataArea, edge); // start with a unit that is at least 1/10th of the axis length double estimate1 = getRange().getLength() / 10.0; DateTickUnit candidate1 = (DateTickUnit) tickUnits.getCeilingTickUnit(estimate1); double labelHeight1 = estimateMaximumTickLabelHeight(g2, candidate1); double y1 = valueToJava2D(candidate1.getSize(), dataArea, edge); double candidate1UnitHeight = Math.abs(y1 - zero); // now extrapolate based on label height and unit height... double estimate2 = (labelHeight1 / candidate1UnitHeight) * candidate1.getSize(); DateTickUnit candidate2 = (DateTickUnit) tickUnits.getCeilingTickUnit(estimate2); double labelHeight2 = estimateMaximumTickLabelHeight(g2, candidate2); double y2 = valueToJava2D(candidate2.getSize(), dataArea, edge); double unit2Height = Math.abs(y2 - zero); // make final selection... DateTickUnit finalUnit; if (labelHeight2 < unit2Height) { finalUnit = candidate2; } else { finalUnit = (DateTickUnit) tickUnits.getLargerTickUnit(candidate2); } setTickUnit(finalUnit, false, false); } /** * Estimates the maximum width of the tick labels, assuming the specified * tick unit is used. *

* Rather than computing the string bounds of every tick on the axis, we * just look at two values: the lower bound and the upper bound for the * axis. These two values will usually be representative. * * @param g2 the graphics device. * @param unit the tick unit to use for calculation. * * @return The estimated maximum width of the tick labels. */ private double estimateMaximumTickLabelWidth(Graphics2D g2, DateTickUnit unit) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight(); Font tickLabelFont = getTickLabelFont(); FontRenderContext frc = g2.getFontRenderContext(); LineMetrics lm = tickLabelFont.getLineMetrics("ABCxyz", frc); if (isVerticalTickLabels()) { // all tick labels have the same width (equal to the height of // the font)... result += lm.getHeight(); } else { // look at lower and upper bounds... DateRange range = (DateRange) getRange(); Date lower = range.getLowerDate(); Date upper = range.getUpperDate(); String lowerStr = null; String upperStr = null; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { lowerStr = formatter.format(lower); upperStr = formatter.format(upper); } else { lowerStr = unit.dateToString(lower); upperStr = unit.dateToString(upper); } FontMetrics fm = g2.getFontMetrics(tickLabelFont); double w1 = fm.stringWidth(lowerStr); double w2 = fm.stringWidth(upperStr); result += Math.max(w1, w2); } return result; } /** * Estimates the maximum width of the tick labels, assuming the specified * tick unit is used. *

* Rather than computing the string bounds of every tick on the axis, we * just look at two values: the lower bound and the upper bound for the * axis. These two values will usually be representative. * * @param g2 the graphics device. * @param unit the tick unit to use for calculation. * * @return The estimated maximum width of the tick labels. */ private double estimateMaximumTickLabelHeight(Graphics2D g2, DateTickUnit unit) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom(); Font tickLabelFont = getTickLabelFont(); FontRenderContext frc = g2.getFontRenderContext(); LineMetrics lm = tickLabelFont.getLineMetrics("ABCxyz", frc); if (!isVerticalTickLabels()) { // all tick labels have the same width (equal to the height of // the font)... result += lm.getHeight(); } else { // look at lower and upper bounds... DateRange range = (DateRange) getRange(); Date lower = range.getLowerDate(); Date upper = range.getUpperDate(); String lowerStr = null; String upperStr = null; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { lowerStr = formatter.format(lower); upperStr = formatter.format(upper); } else { lowerStr = unit.dateToString(lower); upperStr = unit.dateToString(upper); } FontMetrics fm = g2.getFontMetrics(tickLabelFont); double w1 = fm.stringWidth(lowerStr); double w2 = fm.stringWidth(upperStr); result += Math.max(w1, w2); } return result; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List result = null; if (RectangleEdge.isTopOrBottom(edge)) { result = refreshTicksHorizontal(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { result = refreshTicksVertical(g2, dataArea, edge); } return result; } /** * Corrects the given tick date for the position setting. * * @param time the tick date/time. * @param unit the tick unit. * @param position the tick position. * * @return The adjusted time. */ private Date correctTickDateForPosition(Date time, DateTickUnit unit, DateTickMarkPosition position) { Date result = time; switch (unit.getUnit()) { case (DateTickUnit.MILLISECOND) : case (DateTickUnit.SECOND) : case (DateTickUnit.MINUTE) : case (DateTickUnit.HOUR) : case (DateTickUnit.DAY) : break; case (DateTickUnit.MONTH) : result = calculateDateForPosition(new Month(time, this.timeZone, this.locale), position); break; case(DateTickUnit.YEAR) : result = calculateDateForPosition(new Year(time, this.timeZone, this.locale), position); break; default: break; } return result; } /** * Recalculates the ticks for the date axis. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } DateTickUnit unit = getTickUnit(); Date tickDate = calculateLowestVisibleTickValue(unit); Date upperDate = getMaximumDate(); while (tickDate.before(upperDate)) { // could add a flag to make the following correction optional... tickDate = correctTickDateForPosition(tickDate, unit, this.tickMarkPosition); long lowestTickTime = tickDate.getTime(); long distance = unit.addToDate(tickDate, this.timeZone).getTime() - lowestTickTime; int minorTickSpaces = getMinorTickCount(); if (minorTickSpaces <= 0) { minorTickSpaces = unit.getMinorTickCount(); } for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { long minorTickTime = lowestTickTime - distance * minorTick / minorTickSpaces; if (minorTickTime > 0 && getRange().contains(minorTickTime) && (!isHiddenValue(minorTickTime))) { result.add(new DateTick(TickType.MINOR, new Date(minorTickTime), "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position String tickLabel; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { tickLabel = formatter.format(tickDate); } else { tickLabel = this.tickUnit.dateToString(tickDate); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle); result.add(tick); long currentTickTime = tickDate.getTime(); tickDate = unit.addToDate(tickDate, this.timeZone); long nextTickTime = tickDate.getTime(); for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++){ long minorTickTime = currentTickTime + (nextTickTime - currentTickTime) * minorTick / minorTickSpaces; if (getRange().contains(minorTickTime) && (!isHiddenValue(minorTickTime))) { result.add(new DateTick(TickType.MINOR, new Date(minorTickTime), "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } } else { tickDate = unit.rollDate(tickDate, this.timeZone); continue; } } return result; } /** * Recalculates the ticks for the date axis. * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } DateTickUnit unit = getTickUnit(); Date tickDate = calculateLowestVisibleTickValue(unit); Date upperDate = getMaximumDate(); while (tickDate.before(upperDate)) { // could add a flag to make the following correction optional... tickDate = correctTickDateForPosition(tickDate, unit, this.tickMarkPosition); long lowestTickTime = tickDate.getTime(); long distance = unit.addToDate(tickDate, this.timeZone).getTime() - lowestTickTime; int minorTickSpaces = getMinorTickCount(); if (minorTickSpaces <= 0) { minorTickSpaces = unit.getMinorTickCount(); } for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { long minorTickTime = lowestTickTime - distance * minorTick / minorTickSpaces; if (minorTickTime > 0 && getRange().contains(minorTickTime) && (!isHiddenValue(minorTickTime))) { result.add(new DateTick(TickType.MINOR, new Date(minorTickTime), "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position String tickLabel; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { tickLabel = formatter.format(tickDate); } else { tickLabel = this.tickUnit.dateToString(tickDate); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; if (edge == RectangleEdge.LEFT) { angle = -Math.PI / 2.0; } else { angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle); result.add(tick); long currentTickTime = tickDate.getTime(); tickDate = unit.addToDate(tickDate, this.timeZone); long nextTickTime = tickDate.getTime(); for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++){ long minorTickTime = currentTickTime + (nextTickTime - currentTickTime) * minorTick / minorTickSpaces; if (getRange().contains(minorTickTime) && (!isHiddenValue(minorTickTime))) { result.add(new DateTick(TickType.MINOR, new Date(minorTickTime), "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } } else { tickDate = unit.rollDate(tickDate, this.timeZone); } } return result; } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axes and data should be * drawn (null not permitted). * @param dataArea the area within which the data should be drawn * (null not permitted). * @param edge the location of the axis (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { AxisState state = new AxisState(cursor); // even though the axis is not visible, we need to refresh ticks in // case the grid is being drawn... List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); return state; } // draw the tick marks and labels... AxisState state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); // draw the axis label (note that 'state' is passed in *and* // returned)... state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); createAndAddEntity(cursor, state, dataArea, edge, plotState); return state; } /** * Zooms in on the current range. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomRange(double lowerPercent, double upperPercent) { double start = this.timeline.toTimelineValue( (long) getRange().getLowerBound() ); double length = (this.timeline.toTimelineValue( (long) getRange().getUpperBound()) - this.timeline.toTimelineValue( (long) getRange().getLowerBound())); Range adjusted = null; if (isInverted()) { adjusted = new DateRange(this.timeline.toMillisecond((long) (start + (length * (1 - upperPercent)))), this.timeline.toMillisecond((long) (start + (length * (1 - lowerPercent))))); } else { adjusted = new DateRange(this.timeline.toMillisecond( (long) (start + length * lowerPercent)), this.timeline.toMillisecond((long) (start + length * upperPercent))); } setRange(adjusted); } /** * Tests this axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DateAxis)) { return false; } DateAxis that = (DateAxis) obj; if (!ObjectUtilities.equal(this.tickUnit, that.tickUnit)) { return false; } if (!ObjectUtilities.equal(this.dateFormatOverride, that.dateFormatOverride)) { return false; } if (!ObjectUtilities.equal(this.tickMarkPosition, that.tickMarkPosition)) { return false; } if (!ObjectUtilities.equal(this.timeline, that.timeline)) { return false; } return super.equals(obj); } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { if (getLabel() != null) { return getLabel().hashCode(); } else { return 0; } } /** * Returns a clone of the object. * * @return A clone. * * @throws CloneNotSupportedException if some component of the axis does * not support cloning. */ public Object clone() throws CloneNotSupportedException { DateAxis clone = (DateAxis) super.clone(); // 'dateTickUnit' is immutable : no need to clone if (this.dateFormatOverride != null) { clone.dateFormatOverride = (DateFormat) this.dateFormatOverride.clone(); } // 'tickMarkPosition' is immutable : no need to clone return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/DateTick.java0000644000175000017500000001022011173030414025723 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * DateTick.java * ------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Peter Kolb (patch 1934255); * Andrew Mickish (patch 1870189); * * Changes * ------- * 07-Nov-2003 : Version 1 (DG); * 13-May-2004 : Added equals() method (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ package org.jfree.chart.axis; import java.util.Date; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; /** * A tick used by the {@link DateAxis} class. */ public class DateTick extends ValueTick { /** The date. */ private Date date; /** * Creates a new date tick. * * @param date the date. * @param label the label. * @param textAnchor the part of the label that is aligned to the anchor * point. * @param rotationAnchor defines the rotation point relative to the text. * @param angle the rotation angle (in radians). */ public DateTick(Date date, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { this(TickType.MAJOR, date, label, textAnchor, rotationAnchor, angle); } /** * Creates a new date tick. * * @param tickType the tick type. * @param date the date. * @param label the label. * @param textAnchor the part of the label that is aligned to the anchor * point. * @param rotationAnchor defines the rotation point relative to the text. * @param angle the rotation angle (in radians). * * @since 1.0.12 */ public DateTick(TickType tickType, Date date, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { super(tickType, date.getTime(), label, textAnchor, rotationAnchor, angle); this.date = date; } /** * Returns the date. * * @return The date. */ public Date getDate() { return this.date; } /** * Tests this tick for equality with an arbitrary object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DateTick)) { return false; } DateTick that = (DateTick) obj; if (!ObjectUtilities.equal(this.date, that.date)) { return false; } return super.equals(obj); } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { return this.date.hashCode(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/DateTickMarkPosition.java0000644000175000017500000000772411173030414030302 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * DateTickMarkPosition.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 30-Apr-2003 : Version 1 (DG); * */ package org.jfree.chart.axis; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the required position of tick marks on a date axis relative * to the underlying time period. */ public final class DateTickMarkPosition implements Serializable { /** For serialization. */ private static final long serialVersionUID = 2540750672764537240L; /** Start of period. */ public static final DateTickMarkPosition START = new DateTickMarkPosition("DateTickMarkPosition.START"); /** Middle of period. */ public static final DateTickMarkPosition MIDDLE = new DateTickMarkPosition("DateTickMarkPosition.MIDDLE"); /** End of period. */ public static final DateTickMarkPosition END = new DateTickMarkPosition("DateTickMarkPosition.END"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private DateTickMarkPosition(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DateTickMarkPosition)) { return false; } DateTickMarkPosition position = (DateTickMarkPosition) obj; if (!this.name.equals(position.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(DateTickMarkPosition.START)) { return DateTickMarkPosition.START; } else if (this.equals(DateTickMarkPosition.MIDDLE)) { return DateTickMarkPosition.MIDDLE; } else if (this.equals(DateTickMarkPosition.END)) { return DateTickMarkPosition.END; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/DateTickUnit.java0000644000175000017500000004734711173030414026607 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * DateTickUnit.java * ----------------- * (C) Copyright 2000-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Chris Boek; * * Changes * ------- * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 27-Nov-2002 : Added IllegalArgumentException to getMillisecondCount() * method (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 12-Nov-2003 : Added roll fields that can improve the labelling on segmented * date axes (DG); * 03-Dec-2003 : DateFormat constructor argument is now filled with an default * if null (TM); * 07-Dec-2003 : Fixed bug (null pointer exception) in constructor (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 21-Mar-2007 : Added toString() for debugging (DG); * 04-Apr-2007 : Added new methods addToDate(Date, TimeZone) and rollDate(Date, * TimeZone) (CB); * 09-Jun-2008 : Deprecated addToDate(Date) (DG); * 09-Jan-2009 : Replaced the unit and rollUnit fields with an enumerated * type (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; import org.jfree.util.ObjectUtilities; /** * A tick unit for use by subclasses of {@link DateAxis}. Instances of this * class are immutable. */ public class DateTickUnit extends TickUnit implements Serializable { /** For serialization. */ private static final long serialVersionUID = -7289292157229621901L; /** * The units. * * @since 1.0.13 */ private DateTickUnitType unitType; /** The unit count. */ private int count; /** * The roll unit type. * * @since 1.0.13 */ private DateTickUnitType rollUnitType; /** The roll count. */ private int rollCount; /** The date formatter. */ private DateFormat formatter; /** * Creates a new date tick unit. * * @param unitType the unit type (null not permitted). * @param multiple the multiple (of the unit type, must be > 0). * * @since 1.0.13 */ public DateTickUnit(DateTickUnitType unitType, int multiple) { this(unitType, multiple, DateFormat.getDateInstance(DateFormat.SHORT)); } /** * Creates a new date tick unit. * * @param unitType the unit type (null not permitted). * @param multiple the multiple (of the unit type, must be > 0). * @param formatter the date formatter (null not permitted). * * @since 1.0.13 */ public DateTickUnit(DateTickUnitType unitType, int multiple, DateFormat formatter) { this(unitType, multiple, unitType, multiple, formatter); } /** * Creates a new unit. * * @param unitType the unit. * @param multiple the multiple. * @param rollUnitType the roll unit. * @param rollMultiple the roll multiple. * @param formatter the date formatter (null not permitted). * * @since 1.0.13 */ public DateTickUnit(DateTickUnitType unitType, int multiple, DateTickUnitType rollUnitType, int rollMultiple, DateFormat formatter) { super(DateTickUnit.getMillisecondCount(unitType, multiple)); if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } if (multiple <= 0) { throw new IllegalArgumentException("Requires 'multiple' > 0."); } if (rollMultiple <= 0) { throw new IllegalArgumentException("Requires 'rollMultiple' > 0."); } this.unitType = unitType; this.count = multiple; this.rollUnitType = rollUnitType; this.rollCount = rollMultiple; this.formatter = formatter; // populate deprecated fields this.unit = unitTypeToInt(unitType); this.rollUnit = unitTypeToInt(rollUnitType); } /** * Returns the unit type. * * @return The unit type (never null). * * @since 1.0.13 */ public DateTickUnitType getUnitType() { return this.unitType; } /** * Returns the unit multiple. * * @return The unit multiple (always > 0). */ public int getMultiple() { return this.count; } /** * Returns the roll unit type. * * @return The roll unit type (never null). * * @since 1.0.13 */ public DateTickUnitType getRollUnitType() { return this.rollUnitType; } /** * Returns the roll unit multiple. * * @return The roll unit multiple. * * @since 1.0.13 */ public int getRollMultiple() { return this.rollCount; } /** * Formats a value. * * @param milliseconds date in milliseconds since 01-01-1970. * * @return The formatted date. */ public String valueToString(double milliseconds) { return this.formatter.format(new Date((long) milliseconds)); } /** * Formats a date using the tick unit's formatter. * * @param date the date. * * @return The formatted date. */ public String dateToString(Date date) { return this.formatter.format(date); } /** * Calculates a new date by adding this unit to the base date. * * @param base the base date. * @param zone the time zone for the date calculation. * * @return A new date one unit after the base date. * * @since 1.0.6 */ public Date addToDate(Date base, TimeZone zone) { // as far as I know, the Locale for the calendar only affects week // number calculations, and since DateTickUnit doesn't do week // arithmetic, the default locale (whatever it is) should be fine // here... Calendar calendar = Calendar.getInstance(zone); calendar.setTime(base); calendar.add(this.unitType.getCalendarField(), this.count); return calendar.getTime(); } /** * Rolls the date forward by the amount specified by the roll unit and * count. * * @param base the base date. * @return The rolled date. * * @see #rollDate(Date, TimeZone) */ public Date rollDate(Date base) { return rollDate(base, TimeZone.getDefault()); } /** * Rolls the date forward by the amount specified by the roll unit and * count. * * @param base the base date. * @param zone the time zone. * * @return The rolled date. * * @since 1.0.6 */ public Date rollDate(Date base, TimeZone zone) { // as far as I know, the Locale for the calendar only affects week // number calculations, and since DateTickUnit doesn't do week // arithmetic, the default locale (whatever it is) should be fine // here... Calendar calendar = Calendar.getInstance(zone); calendar.setTime(base); calendar.add(this.rollUnitType.getCalendarField(), this.rollCount); return calendar.getTime(); } /** * Returns a field code that can be used with the Calendar * class. * * @return The field code. */ public int getCalendarField() { return this.unitType.getCalendarField(); } /** * Returns the (approximate) number of milliseconds for the given unit and * unit count. *

* This value is an approximation some of the time (e.g. months are * assumed to have 31 days) but this shouldn't matter. * * @param unit the unit. * @param count the unit count. * * @return The number of milliseconds. * * @since 1.0.13 */ private static long getMillisecondCount(DateTickUnitType unit, int count) { if (unit.equals(DateTickUnitType.YEAR)) { return (365L * 24L * 60L * 60L * 1000L) * count; } else if (unit.equals(DateTickUnitType.MONTH)) { return (31L * 24L * 60L * 60L * 1000L) * count; } else if (unit.equals(DateTickUnitType.DAY)) { return (24L * 60L * 60L * 1000L) * count; } else if (unit.equals(DateTickUnitType.HOUR)) { return (60L * 60L * 1000L) * count; } else if (unit.equals(DateTickUnitType.MINUTE)) { return (60L * 1000L) * count; } else if (unit.equals(DateTickUnitType.SECOND)) { return 1000L * count; } else if (unit.equals(DateTickUnitType.MILLISECOND)) { return count; } else { throw new IllegalArgumentException("The 'unit' argument has a " + "value that is not recognised."); } } /** * A utility method that is used internally to convert the old unit * constants into the corresponding enumerated value. * * @param unit the unit specified using the deprecated integer codes. * * @return The unit type. * * @since 1.0.13 */ private static DateTickUnitType intToUnitType(int unit) { switch (unit) { case YEAR: return DateTickUnitType.YEAR; case MONTH: return DateTickUnitType.MONTH; case DAY: return DateTickUnitType.DAY; case HOUR: return DateTickUnitType.HOUR; case MINUTE: return DateTickUnitType.MINUTE; case SECOND: return DateTickUnitType.SECOND; case MILLISECOND: return DateTickUnitType.MILLISECOND; default: throw new IllegalArgumentException( "Unrecognised 'unit' value " + unit + "."); } } /** * Converts a unit type to the corresponding deprecated integer constant. * * @param unitType the unit type (null not permitted). * * @return The int code. * * @since 1.0.13 */ private static int unitTypeToInt(DateTickUnitType unitType) { if (unitType == null) { throw new IllegalArgumentException("Null 'unitType' argument."); } if (unitType.equals(DateTickUnitType.YEAR)) { return YEAR; } else if (unitType.equals(DateTickUnitType.MONTH)) { return MONTH; } else if (unitType.equals(DateTickUnitType.DAY)) { return DAY; } else if (unitType.equals(DateTickUnitType.HOUR)) { return HOUR; } else if (unitType.equals(DateTickUnitType.MINUTE)) { return MINUTE; } else if (unitType.equals(DateTickUnitType.SECOND)) { return SECOND; } else if (unitType.equals(DateTickUnitType.MILLISECOND)) { return MILLISECOND; } else { throw new IllegalArgumentException( "The 'unitType' is not recognised"); } } /** * A utility method to put a default in place if a null formatter is * supplied. * * @param formatter the formatter (null permitted). * * @return The formatter if it is not null, otherwise a default. */ private static DateFormat notNull(DateFormat formatter) { if (formatter == null) { return DateFormat.getDateInstance(DateFormat.SHORT); } else { return formatter; } } /** * Tests this unit for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DateTickUnit)) { return false; } if (!super.equals(obj)) { return false; } DateTickUnit that = (DateTickUnit) obj; if (!(this.unitType.equals(that.unitType))) { return false; } if (this.count != that.count) { return false; } if (!ObjectUtilities.equal(this.formatter, that.formatter)) { return false; } return true; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 19; result = 37 * result + this.unitType.hashCode(); result = 37 * result + this.count; result = 37 * result + this.formatter.hashCode(); return result; } /** * Returns a string representation of this instance, primarily used for * debugging purposes. * * @return A string representation of this instance. */ public String toString() { return "DateTickUnit[" + this.unitType.toString() + ", " + this.count + "]"; } /** * A constant for years. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int YEAR = 0; /** * A constant for months. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int MONTH = 1; /** * A constant for days. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int DAY = 2; /** * A constant for hours. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int HOUR = 3; /** * A constant for minutes. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int MINUTE = 4; /** * A constant for seconds. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int SECOND = 5; /** * A constant for milliseconds. * * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. */ public static final int MILLISECOND = 6; /** * The unit. * * @deprecated As of version 1.0.13, use the unitType field. */ private int unit; /** * The roll unit. * * @deprecated As of version 1.0.13, use the rollUnitType field. */ private int rollUnit; /** * Creates a new date tick unit. You can specify the units using one of * the constants YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or MILLISECOND. * In addition, you can specify a unit count, and a date format. * * @param unit the unit. * @param count the unit count. * @param formatter the date formatter (defaults to DateFormat.SHORT). * * @deprecated As of version 1.0.13, use {@link #DateTickUnit( * DateTickUnitType, int, DateFormat)}. */ public DateTickUnit(int unit, int count, DateFormat formatter) { this(unit, count, unit, count, formatter); } /** * Creates a new date tick unit. The dates will be formatted using a * SHORT format for the default locale. * * @param unit the unit. * @param count the unit count. * * @deprecated As of version 1.0.13, use {@link #DateTickUnit( * DateTickUnitType, int)}. */ public DateTickUnit(int unit, int count) { this(unit, count, null); } /** * Creates a new unit. * * @param unit the unit. * @param count the count. * @param rollUnit the roll unit. * @param rollCount the roll count. * @param formatter the date formatter (defaults to DateFormat.SHORT). * * @deprecated As of version 1.0.13, use {@link #DateTickUnit( * DateTickUnitType, int, DateTickUnitType, int, DateFormat)}. */ public DateTickUnit(int unit, int count, int rollUnit, int rollCount, DateFormat formatter) { this(intToUnitType(unit), count, intToUnitType(rollUnit), rollCount, notNull(formatter)); } /** * Returns the date unit. This will be one of the constants * YEAR, MONTH, DAY, * HOUR, MINUTE, SECOND or * MILLISECOND, defined by this class. Note that these * constants do NOT correspond to those defined in Java's * Calendar class. * * @return The date unit. * * @deprecated As of 1.0.13, use the getUnitType() method. */ public int getUnit() { return this.unit; } /** * Returns the unit count. * * @return The unit count. * * @deprecated As of version 1.0.13, use {@link #getMultiple()}. */ public int getCount() { return this.count; } /** * Returns the roll unit. This is the amount by which the tick advances if * it is "hidden" when displayed on a segmented date axis. Typically the * roll will be smaller than the regular tick unit (for example, a 7 day * tick unit might use a 1 day roll). * * @return The roll unit. * * @deprecated As of version 1.0.13, use {@link #getRollUnitType()}. */ public int getRollUnit() { return this.rollUnit; } /** * Returns the roll count. * * @return The roll count. * * @deprecated As of version 1.0.13, use the {@link #getRollMultiple()} * */ public int getRollCount() { return this.rollCount; } /** * Calculates a new date by adding this unit to the base date, with * calculations performed in the default timezone and locale. * * @param base the base date. * * @return A new date one unit after the base date. * * @see #addToDate(Date, TimeZone) * * @deprecated As of JFreeChart 1.0.10, this method is deprecated - you * should use {@link #addToDate(Date, TimeZone)} instead. */ public Date addToDate(Date base) { return addToDate(base, TimeZone.getDefault()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/DateTickUnitType.java0000644000175000017500000001240111173030414027430 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DateTickUnitType.java * --------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Jan-2009 : Version 1 (DG); * */ package org.jfree.chart.axis; import java.io.ObjectStreamException; import java.io.Serializable; import java.util.Calendar; /** * An enumeration of the unit types for a {@link DateTickUnit} instance. * * @since 1.0.13 */ public class DateTickUnitType implements Serializable { /** Year. */ public static final DateTickUnitType YEAR = new DateTickUnitType("DateTickUnitType.YEAR", Calendar.YEAR); /** Month. */ public static final DateTickUnitType MONTH = new DateTickUnitType("DateTickUnitType.MONTH", Calendar.MONTH); /** Day. */ public static final DateTickUnitType DAY = new DateTickUnitType("DateTickUnitType.DAY", Calendar.DATE); /** Hour. */ public static final DateTickUnitType HOUR = new DateTickUnitType("DateTickUnitType.HOUR", Calendar.HOUR_OF_DAY); /** Minute. */ public static final DateTickUnitType MINUTE = new DateTickUnitType("DateTickUnitType.MINUTE", Calendar.MINUTE); /** Second. */ public static final DateTickUnitType SECOND = new DateTickUnitType("DateTickUnitType.SECOND", Calendar.SECOND); /** Millisecond. */ public static final DateTickUnitType MILLISECOND = new DateTickUnitType("DateTickUnitType.MILLISECOND", Calendar.MILLISECOND); /** The name. */ private String name; /** The corresponding field value in Java's Calendar class. */ private int calendarField; /** * Private constructor. * * @param name the name. * @param calendarField the calendar field. */ private DateTickUnitType(String name, int calendarField) { this.name = name; this.calendarField = calendarField; } /** * Returns the calendar field. * * @return The calendar field. */ public int getCalendarField() { return this.calendarField; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DateTickUnitType)) { return false; } DateTickUnitType t = (DateTickUnitType) obj; if (!this.name.equals(t.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(DateTickUnitType.YEAR)) { return DateTickUnitType.YEAR; } else if (this.equals(DateTickUnitType.MONTH)) { return DateTickUnitType.MONTH; } else if (this.equals(DateTickUnitType.DAY)) { return DateTickUnitType.DAY; } else if (this.equals(DateTickUnitType.HOUR)) { return DateTickUnitType.HOUR; } else if (this.equals(DateTickUnitType.MINUTE)) { return DateTickUnitType.MINUTE; } else if (this.equals(DateTickUnitType.SECOND)) { return DateTickUnitType.SECOND; } else if (this.equals(DateTickUnitType.MILLISECOND)) { return DateTickUnitType.MILLISECOND; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/ExtendedCategoryAxis.java0000644000175000017500000002014611173030414030326 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ExtendedCategoryAxis.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Nov-2003 : Version 1 (DG); * 07-Jan-2004 : Updated the createLabel() method (DG); * 29-Jan-2004 : Added paint attribute (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 21-Mar-2007 : Implemented equals(), clone() and fixed serialization (DG); * */ package org.jfree.chart.axis; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Map; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.io.SerialUtilities; import org.jfree.text.TextBlock; import org.jfree.text.TextFragment; import org.jfree.text.TextLine; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; /** * An extended version of the {@link CategoryAxis} class that supports * sublabels on the axis. */ public class ExtendedCategoryAxis extends CategoryAxis { /** For serialization. */ static final long serialVersionUID = -3004429093959826567L; /** Storage for the sublabels. */ private Map sublabels; /** The sublabel font. */ private Font sublabelFont; /** The sublabel paint. */ private transient Paint sublabelPaint; /** * Creates a new axis. * * @param label the axis label. */ public ExtendedCategoryAxis(String label) { super(label); this.sublabels = new HashMap(); this.sublabelFont = new Font("SansSerif", Font.PLAIN, 10); this.sublabelPaint = Color.black; } /** * Returns the font for the sublabels. * * @return The font (never null). * * @see #setSubLabelFont(Font) */ public Font getSubLabelFont() { return this.sublabelFont; } /** * Sets the font for the sublabels and sends an {@link AxisChangeEvent} to * all registered listeners. * * @param font the font (null not permitted). * * @see #getSubLabelFont() */ public void setSubLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.sublabelFont = font; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the paint for the sublabels. * * @return The paint (never null). * * @see #setSubLabelPaint(Paint) */ public Paint getSubLabelPaint() { return this.sublabelPaint; } /** * Sets the paint for the sublabels and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getSubLabelPaint() */ public void setSubLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.sublabelPaint = paint; notifyListeners(new AxisChangeEvent(this)); } /** * Adds a sublabel for a category. * * @param category the category. * @param label the label. */ public void addSubLabel(Comparable category, String label) { this.sublabels.put(category, label); } /** * Overrides the default behaviour by adding the sublabel to the text * block that is used for the category label. * * @param category the category. * @param width the width (not used yet). * @param edge the location of the axis. * @param g2 the graphics device. * * @return A label. */ protected TextBlock createLabel(Comparable category, float width, RectangleEdge edge, Graphics2D g2) { TextBlock label = super.createLabel(category, width, edge, g2); String s = (String) this.sublabels.get(category); if (s != null) { if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { TextLine line = new TextLine(s, this.sublabelFont, this.sublabelPaint); label.addLine(line); } else if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { TextLine line = label.getLastLine(); if (line != null) { line.addFragment(new TextFragment(" " + s, this.sublabelFont, this.sublabelPaint)); } } } return label; } /** * Tests this axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ExtendedCategoryAxis)) { return false; } ExtendedCategoryAxis that = (ExtendedCategoryAxis) obj; if (!this.sublabelFont.equals(that.sublabelFont)) { return false; } if (!PaintUtilities.equal(this.sublabelPaint, that.sublabelPaint)) { return false; } if (!this.sublabels.equals(that.sublabels)) { return false; } return super.equals(obj); } /** * Returns a clone of this axis. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { ExtendedCategoryAxis clone = (ExtendedCategoryAxis) super.clone(); clone.sublabels = new HashMap(this.sublabels); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.sublabelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.sublabelPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/LogAxis.java0000644000175000017500000007756711173030414025634 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * LogAxis.java * ------------ * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrew Mickish (patch 1868745); * Peter Kolb (patches 1934255 and 2603321); * * Changes * ------- * 24-Aug-2006 : Version 1 (DG); * 22-Mar-2007 : Use defaultAutoArrange attribute (DG); * 02-Aug-2007 : Fixed zooming bug, added support for margins (DG); * 14-Feb-2008 : Changed default minorTickCount to 9 - see bug report * 1892419 (DG); * 15-Feb-2008 : Applied a variation of patch 1868745 by Andrew Mickish to * fix a labelling bug when the axis appears at the top or * right of the chart (DG); * 19-Mar-2008 : Applied patch 1902418 by Andrew Mickish to fix bug in tick * labels for vertical axis (DG); * 26-Mar-2008 : Changed createTickLabel() method from private to protected - * see patch 1918209 by Andrew Mickish (DG); * 25-Sep-2008 : Moved minor tick fields up to superclass, see patch 1934255 * by Peter Kolb (DG); * 14-Jan-2009 : Fetch minor ticks from TickUnit, and corrected * createLogTickUnits() (DG); * 21-Jan-2009 : No need to call setMinorTickCount() in constructor (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * 30-Mar-2009 : Added pan(double) method (DG); * */ package org.jfree.chart.axis; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import java.awt.geom.Rectangle2D; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.chart.util.LogFormat; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; /** * A numerical axis that uses a logarithmic scale. The class is an * alternative to the {@link LogarithmicAxis} class. * * @since 1.0.7 */ public class LogAxis extends ValueAxis { /** The logarithm base. */ private double base = 10.0; /** The logarithm of the base value - cached for performance. */ private double baseLog = Math.log(10.0); /** The smallest value permitted on the axis. */ private double smallestValue = 1E-100; /** The current tick unit. */ private NumberTickUnit tickUnit; /** The override number format. */ private NumberFormat numberFormatOverride; /** * Creates a new LogAxis with no label. */ public LogAxis() { this(null); } /** * Creates a new LogAxis with the given label. * * @param label the axis label (null permitted). */ public LogAxis(String label) { super(label, createLogTickUnits(Locale.getDefault())); setDefaultAutoRange(new Range(0.01, 1.0)); this.tickUnit = new NumberTickUnit(1.0, new DecimalFormat("0.#"), 9); } /** * Returns the base for the logarithm calculation. * * @return The base for the logarithm calculation. * * @see #setBase(double) */ public double getBase() { return this.base; } /** * Sets the base for the logarithm calculation and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param base the base value (must be > 1.0). * * @see #getBase() */ public void setBase(double base) { if (base <= 1.0) { throw new IllegalArgumentException("Requires 'base' > 1.0."); } this.base = base; this.baseLog = Math.log(base); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the smallest value represented by the axis. * * @return The smallest value represented by the axis. * * @see #setSmallestValue(double) */ public double getSmallestValue() { return this.smallestValue; } /** * Sets the smallest value represented by the axis and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param value the value. * * @see #getSmallestValue() */ public void setSmallestValue(double value) { if (value <= 0.0) { throw new IllegalArgumentException("Requires 'value' > 0.0."); } this.smallestValue = value; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the current tick unit. * * @return The current tick unit. * * @see #setTickUnit(NumberTickUnit) */ public NumberTickUnit getTickUnit() { return this.tickUnit; } /** * Sets the tick unit for the axis and sends an {@link AxisChangeEvent} to * all registered listeners. A side effect of calling this method is that * the "auto-select" feature for tick units is switched off (you can * restore it using the {@link ValueAxis#setAutoTickUnitSelection(boolean)} * method). * * @param unit the new tick unit (null not permitted). * * @see #getTickUnit() */ public void setTickUnit(NumberTickUnit unit) { // defer argument checking... setTickUnit(unit, true, true); } /** * Sets the tick unit for the axis and, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. In addition, an * option is provided to turn off the "auto-select" feature for tick units * (you can restore it using the * {@link ValueAxis#setAutoTickUnitSelection(boolean)} method). * * @param unit the new tick unit (null not permitted). * @param notify notify listeners? * @param turnOffAutoSelect turn off the auto-tick selection? * * @see #getTickUnit() */ public void setTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect) { if (unit == null) { throw new IllegalArgumentException("Null 'unit' argument."); } this.tickUnit = unit; if (turnOffAutoSelect) { setAutoTickUnitSelection(false, false); } if (notify) { notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the number format override. If this is non-null, then it will * be used to format the numbers on the axis. * * @return The number formatter (possibly null). * * @see #setNumberFormatOverride(NumberFormat) */ public NumberFormat getNumberFormatOverride() { return this.numberFormatOverride; } /** * Sets the number format override. If this is non-null, then it will be * used to format the numbers on the axis. * * @param formatter the number formatter (null permitted). * * @see #getNumberFormatOverride() */ public void setNumberFormatOverride(NumberFormat formatter) { this.numberFormatOverride = formatter; notifyListeners(new AxisChangeEvent(this)); } /** * Calculates the log of the given value, using the current base. * * @param value the value. * * @return The log of the given value. * * @see #calculateValue(double) * @see #getBase() */ public double calculateLog(double value) { return Math.log(value) / this.baseLog; } /** * Calculates the value from a given log. * * @param log the log value (must be > 0.0). * * @return The value with the given log. * * @see #calculateLog(double) * @see #getBase() */ public double calculateValue(double log) { return Math.pow(this.base, log); } /** * Converts a Java2D coordinate to an axis value, assuming that the * axis covers the specified edge of the area. * * @param java2DValue the Java2D coordinate. * @param area the area. * @param edge the edge that the axis belongs to. * * @return A value along the axis scale. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } double log = 0.0; if (isInverted()) { log = axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin); } else { log = axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin); } return calculateValue(log); } /** * Converts a value on the axis scale to a Java2D coordinate relative to * the given area, based on the axis running along the * specified edge. * * @param value the data value. * @param area the area. * @param edge the edge. * * @return The Java2D coordinate corresponding to value. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); value = calculateLog(value); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMaxY(); } if (isInverted()) { return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); } else { return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); } } /** * Configures the axis. This method is typically called when an axis * is assigned to a new plot. */ public void configure() { if (isAutoRange()) { autoAdjustRange(); } } /** * Adjusts the axis range to match the data range that the axis is * required to display. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } double upper = r.getUpperBound(); double lower = Math.max(r.getLowerBound(), this.smallestValue); double range = upper - lower; // if fixed auto range, then derive lower bound... double fixedAutoRange = getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = Math.max(upper - fixedAutoRange, this.smallestValue); } else { // ensure the autorange is at least in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { double expand = (minRange - range) / 2; upper = upper + expand; lower = lower - expand; } // apply the margins - these should apply to the exponent range double logUpper = calculateLog(upper); double logLower = calculateLog(lower); double logRange = logUpper - logLower; logUpper = logUpper + getUpperMargin() * logRange; logLower = logLower - getLowerMargin() * logRange; upper = calculateValue(logUpper); lower = calculateValue(logLower); } setRange(new Range(lower, upper), false, false); } } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location (determines where to draw the axis). * @param plotArea the area within which the axes and plot should be drawn. * @param dataArea the area within which the data should be drawn. * @param edge the axis location (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState state = null; // if the axis is not visible, don't draw it... if (!isVisible()) { state = new AxisState(cursor); // even though the axis is not visible, we need ticks for the // gridlines... List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); return state; } state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); createAndAddEntity(cursor, state, dataArea, edge, plotState); return state; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. * */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); if (RectangleEdge.isTopOrBottom(edge)) { result = refreshTicksHorizontal(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { result = refreshTicksVertical(g2, dataArea, edge); } return result; } /** * Returns a list of ticks for an axis at the top or bottom of the chart. * * @param g2 the graphics device. * @param dataArea the data area. * @param edge the edge. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { Range range = getRange(); List ticks = new ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); TextAnchor textAnchor; if (edge == RectangleEdge.TOP) { textAnchor = TextAnchor.BOTTOM_CENTER; } else { textAnchor = TextAnchor.TOP_CENTER; } if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } int minorTickCount = this.tickUnit.getMinorTickCount(); double start = Math.floor(calculateLog(getLowerBound())); double end = Math.ceil(calculateLog(getUpperBound())); double current = start; while (current <= end) { double v = calculateValue(current); if (range.contains(v)) { ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), textAnchor, TextAnchor.CENTER, 0.0)); } // add minor ticks (for gridlines) double next = Math.pow(this.base, current + this.tickUnit.getSize()); for (int i = 1; i < minorTickCount; i++) { double minorV = v + i * ((next - v) / minorTickCount); if (range.contains(minorV)) { ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0)); } } current = current + this.tickUnit.getSize(); } return ticks; } /** * Returns a list of ticks for an axis at the left or right of the chart. * * @param g2 the graphics device. * @param dataArea the data area. * @param edge the edge. * * @return A list of ticks. */ protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { Range range = getRange(); List ticks = new ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); TextAnchor textAnchor; if (edge == RectangleEdge.RIGHT) { textAnchor = TextAnchor.CENTER_LEFT; } else { textAnchor = TextAnchor.CENTER_RIGHT; } if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } int minorTickCount = this.tickUnit.getMinorTickCount(); double start = Math.floor(calculateLog(getLowerBound())); double end = Math.ceil(calculateLog(getUpperBound())); double current = start; while (current <= end) { double v = calculateValue(current); if (range.contains(v)) { ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), textAnchor, TextAnchor.CENTER, 0.0)); } // add minor ticks (for gridlines) double next = Math.pow(this.base, current + this.tickUnit.getSize()); for (int i = 1; i < minorTickCount; i++) { double minorV = v + i * ((next - v) / minorTickCount); if (range.contains(minorV)) { ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0)); } } current = current + this.tickUnit.getSize(); } return ticks; } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. * * @since 1.0.7 */ protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { selectHorizontalAutoTickUnit(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { selectVerticalAutoTickUnit(g2, dataArea, edge); } } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. * * @since 1.0.7 */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); } /** * Converts a length in data coordinates into the corresponding length in * Java2D coordinates. * * @param length the length. * @param area the plot area. * @param edge the edge along which the axis lies. * * @return The length in Java2D coordinates. * * @since 1.0.7 */ public double exponentLengthToJava2D(double length, Rectangle2D area, RectangleEdge edge) { double one = valueToJava2D(calculateValue(1.0), area, edge); double l = valueToJava2D(calculateValue(length + 1.0), area, edge); return Math.abs(l - one); } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the axis location. * * @since 1.0.7 */ protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelHeight = estimateMaximumTickLabelHeight(g2); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unitHeight = exponentLengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelHeight / unitHeight) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); double unit2Height = exponentLengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelHeight = estimateMaximumTickLabelHeight(g2); if (tickLabelHeight > unit2Height) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); } /** * Estimates the maximum tick label height. * * @param g2 the graphics device. * * @return The maximum height. * * @since 1.0.7 */ protected double estimateMaximumTickLabelHeight(Graphics2D g2) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom(); Font tickLabelFont = getTickLabelFont(); FontRenderContext frc = g2.getFontRenderContext(); result += tickLabelFont.getLineMetrics("123", frc).getHeight(); return result; } /** * Estimates the maximum width of the tick labels, assuming the specified * tick unit is used. *

* Rather than computing the string bounds of every tick on the axis, we * just look at two values: the lower bound and the upper bound for the * axis. These two values will usually be representative. * * @param g2 the graphics device. * @param unit the tick unit to use for calculation. * * @return The estimated maximum width of the tick labels. * * @since 1.0.7 */ protected double estimateMaximumTickLabelWidth(Graphics2D g2, TickUnit unit) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight(); if (isVerticalTickLabels()) { // all tick labels have the same width (equal to the height of the // font)... FontRenderContext frc = g2.getFontRenderContext(); LineMetrics lm = getTickLabelFont().getLineMetrics("0", frc); result += lm.getHeight(); } else { // look at lower and upper bounds... FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); Range range = getRange(); double lower = range.getLowerBound(); double upper = range.getUpperBound(); String lowerStr = ""; String upperStr = ""; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { lowerStr = formatter.format(lower); upperStr = formatter.format(upper); } else { lowerStr = unit.valueToString(lower); upperStr = unit.valueToString(upper); } double w1 = fm.stringWidth(lowerStr); double w2 = fm.stringWidth(upperStr); result += Math.max(w1, w2); } return result; } /** * Zooms in on the current range. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomRange(double lowerPercent, double upperPercent) { Range range = getRange(); double start = range.getLowerBound(); double end = range.getUpperBound(); double log1 = calculateLog(start); double log2 = calculateLog(end); double length = log2 - log1; Range adjusted = null; if (isInverted()) { double logA = log1 + length * (1 - upperPercent); double logB = log1 + length * (1 - lowerPercent); adjusted = new Range(calculateValue(logA), calculateValue(logB)); } else { double logA = log1 + length * lowerPercent; double logB = log1 + length * upperPercent; adjusted = new Range(calculateValue(logA), calculateValue(logB)); } setRange(adjusted); } /** * Slides the axis range by the specified percentage. * * @param percent the percentage. * * @since 1.0.13 */ public void pan(double percent) { Range range = getRange(); double lower = range.getLowerBound(); double upper = range.getUpperBound(); double log1 = calculateLog(lower); double log2 = calculateLog(upper); double length = log2 - log1; double adj = length * percent; log1 = log1 + adj; log2 = log2 + adj; setRange(calculateValue(log1), calculateValue(log2)); } /** * Creates a tick label for the specified value. Note that this method * was 'private' prior to version 1.0.10. * * @param value the value. * * @return The label. * * @since 1.0.10 */ protected String createTickLabel(double value) { if (this.numberFormatOverride != null) { return this.numberFormatOverride.format(value); } else { return this.tickUnit.valueToString(value); } } /** * Tests this axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LogAxis)) { return false; } LogAxis that = (LogAxis) obj; if (this.base != that.base) { return false; } if (this.smallestValue != that.smallestValue) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.base); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.smallestValue); result = 37 * result + (int) (temp ^ (temp >>> 32)); if (this.numberFormatOverride != null) { result = 37 * result + this.numberFormatOverride.hashCode(); } result = 37 * result + this.tickUnit.hashCode(); return result; } /** * Returns a collection of tick units for log (base 10) values. * Uses a given Locale to create the DecimalFormats. * * @param locale the locale to use to represent Numbers. * * @return A collection of tick units for integer values. * * @since 1.0.7 */ public static TickUnitSource createLogTickUnits(Locale locale) { TickUnits units = new TickUnits(); NumberFormat numberFormat = new LogFormat(); units.add(new NumberTickUnit(0.05, numberFormat, 2)); units.add(new NumberTickUnit(0.1, numberFormat, 10)); units.add(new NumberTickUnit(0.2, numberFormat, 2)); units.add(new NumberTickUnit(0.5, numberFormat, 5)); units.add(new NumberTickUnit(1, numberFormat, 10)); units.add(new NumberTickUnit(2, numberFormat, 10)); units.add(new NumberTickUnit(3, numberFormat, 15)); units.add(new NumberTickUnit(4, numberFormat, 20)); units.add(new NumberTickUnit(5, numberFormat, 25)); units.add(new NumberTickUnit(6, numberFormat)); units.add(new NumberTickUnit(7, numberFormat)); units.add(new NumberTickUnit(8, numberFormat)); units.add(new NumberTickUnit(9, numberFormat)); units.add(new NumberTickUnit(10, numberFormat)); return units; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/LogarithmicAxis.java0000644000175000017500000013320311173030414027331 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * LogarithmicAxis.java * -------------------- * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Original Author: Michael Duffy / Eric Thomas; * Contributor(s): David Gilbert (for Object Refinery Limited); * David M. O'Donnell; * Scott Sams; * Sergei Ivanov; * * Changes * ------- * 14-Mar-2002 : Version 1 contributed by Michael Duffy (DG); * 19-Apr-2002 : drawVerticalString() is now drawRotatedString() in * RefineryUtilities (DG); * 23-Apr-2002 : Added a range property (DG); * 15-May-2002 : Modified to be able to deal with negative and zero values (via * new 'adjustedLog10()' method); occurrences of "Math.log(10)" * changed to "LOG10_VALUE"; changed 'intValue()' to * 'longValue()' in 'refreshTicks()' to fix label-text value * out-of-range problem; removed 'draw()' method; added * 'autoRangeMinimumSize' check; added 'log10TickLabelsFlag' * parameter flag and implementation (ET); * 25-Jun-2002 : Removed redundant import (DG); * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); * 16-Jul-2002 : Implemented support for plotting positive values arbitrarily * close to zero (added 'allowNegativesFlag' flag) (ET). * 05-Sep-2002 : Updated constructor reflecting changes in the Axis class (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 22-Nov-2002 : Bug fixes from David M. O'Donnell (DG); * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double (DG); * 20-Jan-2003 : Removed unnecessary constructors (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 08-May-2003 : Fixed plotting of datasets with lower==upper bounds when * 'minAutoRange' is very small; added 'strictValuesFlag' * and default functionality of throwing a runtime exception * if 'allowNegativesFlag' is false and any values are less * than or equal to zero; added 'expTickLabelsFlag' and * changed to use "1e#"-style tick labels by default * ("10^n"-style tick labels still supported via 'set' * method); improved generation of tick labels when range of * values is small; changed to use 'NumberFormat.getInstance()' * to create 'numberFormatterObj' (ET); * 14-May-2003 : Merged HorizontalLogarithmicAxis and * VerticalLogarithmicAxis (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 07-Nov-2003 : Modified to use new NumberTick class (DG); * 08-Apr-2004 : Use numberFormatOverride if set - see patch 930139 (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 21-Apr-2005 : Added support for upper and lower margins; added * get/setAutoRangeNextLogFlag() methods and changed * default to 'autoRangeNextLogFlag'==false (ET); * 22-Apr-2005 : Removed refreshTicks() and fixed names and parameters for * refreshHorizontalTicks() & refreshVerticalTicks(); * changed javadoc on setExpTickLabelsFlag() to specify * proper default (ET); * 22-Apr-2005 : Renamed refreshHorizontalTicks --> refreshTicksHorizontal * (and likewise the vertical version) for consistency with * other axis classes (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 02-Mar-2007 : Applied patch 1671069 to fix zooming (DG); * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); * */ package org.jfree.chart.axis; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.List; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; /** * A numerical axis that uses a logarithmic scale. */ public class LogarithmicAxis extends NumberAxis { /** For serialization. */ private static final long serialVersionUID = 2502918599004103054L; /** Useful constant for log(10). */ public static final double LOG10_VALUE = Math.log(10.0); /** Smallest arbitrarily-close-to-zero value allowed. */ public static final double SMALL_LOG_VALUE = 1e-100; /** Flag set true to allow negative values in data. */ protected boolean allowNegativesFlag = false; /** * Flag set true make axis throw exception if any values are * <= 0 and 'allowNegativesFlag' is false. */ protected boolean strictValuesFlag = true; /** Number formatter for generating numeric strings. */ protected final NumberFormat numberFormatterObj = NumberFormat.getInstance(); /** Flag set true for "1e#"-style tick labels. */ protected boolean expTickLabelsFlag = false; /** Flag set true for "10^n"-style tick labels. */ protected boolean log10TickLabelsFlag = false; /** True to make 'autoAdjustRange()' select "10^n" values. */ protected boolean autoRangeNextLogFlag = false; /** Helper flag for log axis processing. */ protected boolean smallLogFlag = false; /** * Creates a new axis. * * @param label the axis label. */ public LogarithmicAxis(String label) { super(label); setupNumberFmtObj(); //setup number formatter obj } /** * Sets the 'allowNegativesFlag' flag; true to allow negative values * in data, false to be able to plot positive values arbitrarily close to * zero. * * @param flgVal the new value of the flag. */ public void setAllowNegativesFlag(boolean flgVal) { this.allowNegativesFlag = flgVal; } /** * Returns the 'allowNegativesFlag' flag; true to allow negative values * in data, false to be able to plot positive values arbitrarily close * to zero. * * @return The flag. */ public boolean getAllowNegativesFlag() { return this.allowNegativesFlag; } /** * Sets the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' * is false then this axis will throw a runtime exception if any of its * values are less than or equal to zero; if false then the axis will * adjust for values less than or equal to zero as needed. * * @param flgVal true for strict enforcement. */ public void setStrictValuesFlag(boolean flgVal) { this.strictValuesFlag = flgVal; } /** * Returns the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' * is false then this axis will throw a runtime exception if any of its * values are less than or equal to zero; if false then the axis will * adjust for values less than or equal to zero as needed. * * @return true if strict enforcement is enabled. */ public boolean getStrictValuesFlag() { return this.strictValuesFlag; } /** * Sets the 'expTickLabelsFlag' flag. If the 'log10TickLabelsFlag' * is false then this will set whether or not "1e#"-style tick labels * are used. The default is to use regular numeric tick labels. * * @param flgVal true for "1e#"-style tick labels, false for * log10 or regular numeric tick labels. */ public void setExpTickLabelsFlag(boolean flgVal) { this.expTickLabelsFlag = flgVal; setupNumberFmtObj(); //setup number formatter obj } /** * Returns the 'expTickLabelsFlag' flag. * * @return true for "1e#"-style tick labels, * false for log10 or regular numeric tick labels. */ public boolean getExpTickLabelsFlag() { return this.expTickLabelsFlag; } /** * Sets the 'log10TickLabelsFlag' flag. The default value is false. * * @param flag true for "10^n"-style tick labels, false for "1e#"-style * or regular numeric tick labels. */ public void setLog10TickLabelsFlag(boolean flag) { this.log10TickLabelsFlag = flag; } /** * Returns the 'log10TickLabelsFlag' flag. * * @return true for "10^n"-style tick labels, * false for "1e#"-style or regular numeric tick * labels. */ public boolean getLog10TickLabelsFlag() { return this.log10TickLabelsFlag; } /** * Sets the 'autoRangeNextLogFlag' flag. This determines whether or * not the 'autoAdjustRange()' method will select the next "10^n" * values when determining the upper and lower bounds. The default * value is false. * * @param flag true to make the 'autoAdjustRange()' * method select the next "10^n" values, false to not. */ public void setAutoRangeNextLogFlag(boolean flag) { this.autoRangeNextLogFlag = flag; } /** * Returns the 'autoRangeNextLogFlag' flag. * * @return true if the 'autoAdjustRange()' method will * select the next "10^n" values, false if not. */ public boolean getAutoRangeNextLogFlag() { return this.autoRangeNextLogFlag; } /** * Overridden version that calls original and then sets up flag for * log axis processing. * * @param range the new range. */ public void setRange(Range range) { super.setRange(range); // call parent method setupSmallLogFlag(); // setup flag based on bounds values } /** * Sets up flag for log axis processing. Set true if negative values * not allowed and the lower bound is between 0 and 10. */ protected void setupSmallLogFlag() { // set flag true if negative values not allowed and the // lower bound is between 0 and 10: double lowerVal = getRange().getLowerBound(); this.smallLogFlag = (!this.allowNegativesFlag && lowerVal < 10.0 && lowerVal > 0.0); } /** * Sets up the number formatter object according to the * 'expTickLabelsFlag' flag. */ protected void setupNumberFmtObj() { if (this.numberFormatterObj instanceof DecimalFormat) { //setup for "1e#"-style tick labels or regular // numeric tick labels, depending on flag: ((DecimalFormat) this.numberFormatterObj).applyPattern( this.expTickLabelsFlag ? "0E0" : "0.###"); } } /** * Returns the log10 value, depending on if values between 0 and * 1 are being plotted. If negative values are not allowed and * the lower bound is between 0 and 10 then a normal log is * returned; otherwise the returned value is adjusted if the * given value is less than 10. * * @param val the value. * * @return log10(val). * * @see #switchedPow10(double) */ protected double switchedLog10(double val) { return this.smallLogFlag ? Math.log(val) / LOG10_VALUE : adjustedLog10(val); } /** * Returns a power of 10, depending on if values between 0 and * 1 are being plotted. If negative values are not allowed and * the lower bound is between 0 and 10 then a normal power is * returned; otherwise the returned value is adjusted if the * given value is less than 1. * * @param val the value. * * @return 10val. * * @since 1.0.5 * @see #switchedLog10(double) */ public double switchedPow10(double val) { return this.smallLogFlag ? Math.pow(10.0, val) : adjustedPow10(val); } /** * Returns an adjusted log10 value for graphing purposes. The first * adjustment is that negative values are changed to positive during * the calculations, and then the answer is negated at the end. The * second is that, for values less than 10, an increasingly large * (0 to 1) scaling factor is added such that at 0 the value is * adjusted to 1, resulting in a returned result of 0. * * @param val value for which log10 should be calculated. * * @return An adjusted log10(val). * * @see #adjustedPow10(double) */ public double adjustedLog10(double val) { boolean negFlag = (val < 0.0); if (negFlag) { val = -val; // if negative then set flag and make positive } if (val < 10.0) { // if < 10 then val += (10.0 - val) / 10.0; //increase so 0 translates to 0 } //return value; negate if original value was negative: double res = Math.log(val) / LOG10_VALUE; return negFlag ? (-res) : res; } /** * Returns an adjusted power of 10 value for graphing purposes. The first * adjustment is that negative values are changed to positive during * the calculations, and then the answer is negated at the end. The * second is that, for values less than 1, a progressive logarithmic * offset is subtracted such that at 0 the returned result is also 0. * * @param val value for which power of 10 should be calculated. * * @return An adjusted 10val. * * @since 1.0.5 * @see #adjustedLog10(double) */ public double adjustedPow10(double val) { boolean negFlag = (val < 0.0); if (negFlag) { val = -val; // if negative then set flag and make positive } double res; if (val < 1.0) { res = (Math.pow(10, val + 1.0) - 10.0) / 9.0; //invert adjustLog10 } else { res = Math.pow(10, val); } return negFlag ? (-res) : res; } /** * Returns the largest (closest to positive infinity) double value that is * not greater than the argument, is equal to a mathematical integer and * satisfying the condition that log base 10 of the value is an integer * (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.). * * @param lower a double value below which a floor will be calcualted. * * @return 10N with N .. { 1 ... } */ protected double computeLogFloor(double lower) { double logFloor; if (this.allowNegativesFlag) { //negative values are allowed if (lower > 10.0) { //parameter value is > 10 // The Math.log() function is based on e not 10. logFloor = Math.log(lower) / LOG10_VALUE; logFloor = Math.floor(logFloor); logFloor = Math.pow(10, logFloor); } else if (lower < -10.0) { //parameter value is < -10 //calculate log using positive value: logFloor = Math.log(-lower) / LOG10_VALUE; //calculate floor using negative value: logFloor = Math.floor(-logFloor); //calculate power using positive value; then negate logFloor = -Math.pow(10, -logFloor); } else { //parameter value is -10 > val < 10 logFloor = Math.floor(lower); //use as-is } } else { //negative values not allowed if (lower > 0.0) { //parameter value is > 0 // The Math.log() function is based on e not 10. logFloor = Math.log(lower) / LOG10_VALUE; logFloor = Math.floor(logFloor); logFloor = Math.pow(10, logFloor); } else { //parameter value is <= 0 logFloor = Math.floor(lower); //use as-is } } return logFloor; } /** * Returns the smallest (closest to negative infinity) double value that is * not less than the argument, is equal to a mathematical integer and * satisfying the condition that log base 10 of the value is an integer * (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.). * * @param upper a double value above which a ceiling will be calcualted. * * @return 10N with N .. { 1 ... } */ protected double computeLogCeil(double upper) { double logCeil; if (this.allowNegativesFlag) { //negative values are allowed if (upper > 10.0) { //parameter value is > 10 // The Math.log() function is based on e not 10. logCeil = Math.log(upper) / LOG10_VALUE; logCeil = Math.ceil(logCeil); logCeil = Math.pow(10, logCeil); } else if (upper < -10.0) { //parameter value is < -10 //calculate log using positive value: logCeil = Math.log(-upper) / LOG10_VALUE; //calculate ceil using negative value: logCeil = Math.ceil(-logCeil); //calculate power using positive value; then negate logCeil = -Math.pow(10, -logCeil); } else { //parameter value is -10 > val < 10 logCeil = Math.ceil(upper); //use as-is } } else { //negative values not allowed if (upper > 0.0) { //parameter value is > 0 // The Math.log() function is based on e not 10. logCeil = Math.log(upper) / LOG10_VALUE; logCeil = Math.ceil(logCeil); logCeil = Math.pow(10, logCeil); } else { //parameter value is <= 0 logCeil = Math.ceil(upper); //use as-is } } return logCeil; } /** * Rescales the axis to ensure that all data is visible. */ public void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data. } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; double lower; Range r = vap.getDataRange(this); if (r == null) { //no real data present r = getDefaultAutoRange(); lower = r.getLowerBound(); //get lower bound value } else { //actual data is present lower = r.getLowerBound(); //get lower bound value if (this.strictValuesFlag && !this.allowNegativesFlag && lower <= 0.0) { //strict flag set, allow-negatives not set and values <= 0 throw new RuntimeException("Values less than or equal to " + "zero not allowed with logarithmic axis"); } } //apply lower margin by decreasing lower bound: final double lowerMargin; if (lower > 0.0 && (lowerMargin = getLowerMargin()) > 0.0) { //lower bound and margin OK; get log10 of lower bound final double logLower = (Math.log(lower) / LOG10_VALUE); double logAbs; //get absolute value of log10 value if ((logAbs = Math.abs(logLower)) < 1.0) { logAbs = 1.0; //if less than 1.0 then make it 1.0 } //subtract out margin and get exponential value: lower = Math.pow(10, (logLower - (logAbs * lowerMargin))); } //if flag then change to log version of lowest value // to make range begin at a 10^n value: if (this.autoRangeNextLogFlag) { lower = computeLogFloor(lower); } if (!this.allowNegativesFlag && lower >= 0.0 && lower < SMALL_LOG_VALUE) { //negatives not allowed and lower range bound is zero lower = r.getLowerBound(); //use data range bound instead } double upper = r.getUpperBound(); //apply upper margin by increasing upper bound: final double upperMargin; if (upper > 0.0 && (upperMargin = getUpperMargin()) > 0.0) { //upper bound and margin OK; get log10 of upper bound final double logUpper = (Math.log(upper) / LOG10_VALUE); double logAbs; //get absolute value of log10 value if ((logAbs = Math.abs(logUpper)) < 1.0) { logAbs = 1.0; //if less than 1.0 then make it 1.0 } //add in margin and get exponential value: upper = Math.pow(10, (logUpper + (logAbs * upperMargin))); } if (!this.allowNegativesFlag && upper < 1.0 && upper > 0.0 && lower > 0.0) { //negatives not allowed and upper bound between 0 & 1 //round up to nearest significant digit for bound: //get negative exponent: double expVal = Math.log(upper) / LOG10_VALUE; expVal = Math.ceil(-expVal + 0.001); //get positive exponent expVal = Math.pow(10, expVal); //create multiplier value //multiply, round up, and divide for bound value: upper = (expVal > 0.0) ? Math.ceil(upper * expVal) / expVal : Math.ceil(upper); } else { //negatives allowed or upper bound not between 0 & 1 //if flag then change to log version of highest value to // make range begin at a 10^n value; else use nearest int upper = (this.autoRangeNextLogFlag) ? computeLogCeil(upper) : Math.ceil(upper); } // ensure the autorange is at least in size... double minRange = getAutoRangeMinimumSize(); if (upper - lower < minRange) { upper = (upper + lower + minRange) / 2; lower = (upper + lower - minRange) / 2; //if autorange still below minimum then adjust by 1% // (can be needed when minRange is very small): if (upper - lower < minRange) { double absUpper = Math.abs(upper); //need to account for case where upper==0.0 double adjVal = (absUpper > SMALL_LOG_VALUE) ? absUpper / 100.0 : 0.01; upper = (upper + lower + adjVal) / 2; lower = (upper + lower - adjVal) / 2; } } setRange(new Range(lower, upper), false, false); setupSmallLogFlag(); //setup flag based on bounds values } } /** * Converts a data value to a coordinate in Java2D space, assuming that * the axis runs along one edge of the specified plotArea. * Note that it is possible for the coordinate to fall outside the * plotArea. * * @param value the data value. * @param plotArea the area for plotting the data. * @param edge the axis location. * * @return The Java2D coordinate. */ public double valueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = switchedLog10(range.getLowerBound()); double axisMax = switchedLog10(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getMinX(); max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } value = switchedLog10(value); if (isInverted()) { return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min)); } else { return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min)); } } /** * Converts a coordinate in Java2D space to the corresponding data * value, assuming that the axis runs along one edge of the specified * plotArea. * * @param java2DValue the coordinate in Java2D space. * @param plotArea the area in which the data is plotted. * @param edge the axis location. * * @return The data value. */ public double java2DToValue(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = switchedLog10(range.getLowerBound()); double axisMax = switchedLog10(range.getUpperBound()); double plotMin = 0.0; double plotMax = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { plotMin = plotArea.getX(); plotMax = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { plotMin = plotArea.getMaxY(); plotMax = plotArea.getMinY(); } if (isInverted()) { return switchedPow10(axisMax - ((java2DValue - plotMin) / (plotMax - plotMin)) * (axisMax - axisMin)); } else { return switchedPow10(axisMin + ((java2DValue - plotMin) / (plotMax - plotMin)) * (axisMax - axisMin)); } } /** * Zooms in on the current range. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomRange(double lowerPercent, double upperPercent) { double startLog = switchedLog10(getRange().getLowerBound()); double lengthLog = switchedLog10(getRange().getUpperBound()) - startLog; Range adjusted; if (isInverted()) { adjusted = new Range( switchedPow10( startLog + (lengthLog * (1 - upperPercent))), switchedPow10( startLog + (lengthLog * (1 - lowerPercent)))); } else { adjusted = new Range( switchedPow10(startLog + (lengthLog * lowerPercent)), switchedPow10(startLog + (lengthLog * upperPercent))); } setRange(adjusted); } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Range range = getRange(); //get lower bound value: double lowerBoundVal = range.getLowerBound(); //if small log values and lower bound value too small // then set to a small value (don't allow <= 0): if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { lowerBoundVal = SMALL_LOG_VALUE; } //get upper bound value double upperBoundVal = range.getUpperBound(); //get log10 version of lower bound and round to integer: int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); //get log10 version of upper bound and round to integer: int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) { //only 1 power of 10 value, it's > 0 and its resulting // tick value will be larger than lower bound of data --iBegCount; //decrement to generate more ticks } double currentTickValue; String tickLabel; boolean zeroTickFlag = false; for (int i = iBegCount; i <= iEndCount; i++) { //for each power of 10 value; create ten ticks for (int j = 0; j < 10; ++j) { //for each tick to be displayed if (this.smallLogFlag) { //small log values in use; create numeric value for tick currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j); if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) { //showing "1e#"-style ticks or negative exponent // generating tick value between 0 & 1; show fewer if (j == 0 || (i > -4 && j < 2) || currentTickValue >= upperBoundVal) { //first tick of series, or not too small a value and // one of first 3 ticks, or last tick to be displayed // set exact number of fractional digits to be shown // (no effect if showing "1e#"-style ticks): this.numberFormatterObj .setMaximumFractionDigits(-i); //create tick label (force use of fmt obj): tickLabel = makeTickLabel(currentTickValue, true); } else { //no tick label to be shown tickLabel = ""; } } else { //tick value not between 0 & 1 //show tick label if it's the first or last in // the set, or if it's 1-5; beyond that show // fewer as the values get larger: tickLabel = (j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal) ? makeTickLabel(currentTickValue) : ""; } } else { //not small log values in use; allow for values <= 0 if (zeroTickFlag) { //if did zero tick last iter then --j; //decrement to do 1.0 tick now } //calculate power-of-ten value for tick: currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); if (!zeroTickFlag) { // did not do zero tick last iteration if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0 && upperBoundVal >= 0.0) { //tick value is 1.0 and 0.0 is within data range currentTickValue = 0.0; //set tick value to zero zeroTickFlag = true; //indicate zero tick } } else { //did zero tick last iteration zeroTickFlag = false; //clear flag } //create tick label string: //show tick label if "1e#"-style and it's one // of the first two, if it's the first or last // in the set, or if it's 1-5; beyond that // show fewer as the values get larger: tickLabel = ((this.expTickLabelsFlag && j < 2) || j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal) ? makeTickLabel(currentTickValue) : ""; } if (currentTickValue > upperBoundVal) { return ticks; // if past highest data value then exit // method } if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) { //tick value not below lowest data value TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } } return ticks; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); //get lower bound value: double lowerBoundVal = getRange().getLowerBound(); //if small log values and lower bound value too small // then set to a small value (don't allow <= 0): if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { lowerBoundVal = SMALL_LOG_VALUE; } //get upper bound value double upperBoundVal = getRange().getUpperBound(); //get log10 version of lower bound and round to integer: int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); //get log10 version of upper bound and round to integer: int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) { //only 1 power of 10 value, it's > 0 and its resulting // tick value will be larger than lower bound of data --iBegCount; //decrement to generate more ticks } double tickVal; String tickLabel; boolean zeroTickFlag = false; for (int i = iBegCount; i <= iEndCount; i++) { //for each tick with a label to be displayed int jEndCount = 10; if (i == iEndCount) { jEndCount = 1; } for (int j = 0; j < jEndCount; j++) { //for each tick to be displayed if (this.smallLogFlag) { //small log values in use tickVal = Math.pow(10, i) + (Math.pow(10, i) * j); if (j == 0) { //first tick of group; create label text if (this.log10TickLabelsFlag) { //if flag then tickLabel = "10^" + i; //create "log10"-type label } else { //not "log10"-type label if (this.expTickLabelsFlag) { //if flag then tickLabel = "1e" + i; //create "1e#"-type label } else { //not "1e#"-type label if (i >= 0) { // if positive exponent then // make integer NumberFormat format = getNumberFormatOverride(); if (format != null) { tickLabel = format.format(tickVal); } else { tickLabel = Long.toString((long) Math.rint(tickVal)); } } else { //negative exponent; create fractional value //set exact number of fractional digits to // be shown: this.numberFormatterObj .setMaximumFractionDigits(-i); //create tick label: tickLabel = this.numberFormatterObj.format( tickVal); } } } } else { //not first tick to be displayed tickLabel = ""; //no tick label } } else { //not small log values in use; allow for values <= 0 if (zeroTickFlag) { //if did zero tick last iter then --j; } //decrement to do 1.0 tick now tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); if (j == 0) { //first tick of group if (!zeroTickFlag) { // did not do zero tick last // iteration if (i > iBegCount && i < iEndCount && Math.abs(tickVal - 1.0) < 0.0001) { // not first or last tick on graph and value // is 1.0 tickVal = 0.0; //change value to 0.0 zeroTickFlag = true; //indicate zero tick tickLabel = "0"; //create label for tick } else { //first or last tick on graph or value is 1.0 //create label for tick: if (this.log10TickLabelsFlag) { //create "log10"-type label tickLabel = (((i < 0) ? "-" : "") + "10^" + Math.abs(i)); } else { if (this.expTickLabelsFlag) { //create "1e#"-type label tickLabel = (((i < 0) ? "-" : "") + "1e" + Math.abs(i)); } else { NumberFormat format = getNumberFormatOverride(); if (format != null) { tickLabel = format.format(tickVal); } else { tickLabel = Long.toString( (long) Math.rint(tickVal)); } } } } } else { // did zero tick last iteration tickLabel = ""; //no label zeroTickFlag = false; //clear flag } } else { // not first tick of group tickLabel = ""; //no label zeroTickFlag = false; //make sure flag cleared } } if (tickVal > upperBoundVal) { return ticks; //if past highest data value then exit method } if (tickVal >= lowerBoundVal - SMALL_LOG_VALUE) { //tick value not below lowest data value TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = -Math.PI / 2.0; } else { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } //create tick object and add to list: ticks.add(new NumberTick(new Double(tickVal), tickLabel, anchor, rotationAnchor, angle)); } } } return ticks; } /** * Converts the given value to a tick label string. * * @param val the value to convert. * @param forceFmtFlag true to force the number-formatter object * to be used. * * @return The tick label string. */ protected String makeTickLabel(double val, boolean forceFmtFlag) { if (this.expTickLabelsFlag || forceFmtFlag) { //using exponents or force-formatter flag is set // (convert 'E' to lower-case 'e'): return this.numberFormatterObj.format(val).toLowerCase(); } return getTickUnit().valueToString(val); } /** * Converts the given value to a tick label string. * @param val the value to convert. * * @return The tick label string. */ protected String makeTickLabel(double val) { return makeTickLabel(val, false); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/MarkerAxisBand.java0000644000175000017500000002143611173030414027101 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * MarkerAxisBand.java * ------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Sep-2002 : Updated Javadoc comments (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 13-May-2003 : Renamed HorizontalMarkerAxisBand --> MarkerAxisBand (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 07-Apr-2004 : Changed text bounds calculation (DG); * */ package org.jfree.chart.axis; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.font.LineMetrics; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.chart.plot.IntervalMarker; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; /** * A band that can be added to a number axis to display regions. */ public class MarkerAxisBand implements Serializable { /** For serialization. */ private static final long serialVersionUID = -1729482413886398919L; /** The axis that the band belongs to. */ private NumberAxis axis; /** The top outer gap. */ private double topOuterGap; /** The top inner gap. */ private double topInnerGap; /** The bottom outer gap. */ private double bottomOuterGap; /** The bottom inner gap. */ private double bottomInnerGap; /** The font. */ private Font font; /** Storage for the markers. */ private List markers; /** * Constructs a new axis band. * * @param axis the owner. * @param topOuterGap the top outer gap. * @param topInnerGap the top inner gap. * @param bottomOuterGap the bottom outer gap. * @param bottomInnerGap the bottom inner gap. * @param font the font. */ public MarkerAxisBand(NumberAxis axis, double topOuterGap, double topInnerGap, double bottomOuterGap, double bottomInnerGap, Font font) { this.axis = axis; this.topOuterGap = topOuterGap; this.topInnerGap = topInnerGap; this.bottomOuterGap = bottomOuterGap; this.bottomInnerGap = bottomInnerGap; this.font = font; this.markers = new java.util.ArrayList(); } /** * Adds a marker to the band. * * @param marker the marker. */ public void addMarker(IntervalMarker marker) { this.markers.add(marker); } /** * Returns the height of the band. * * @param g2 the graphics device. * * @return The height of the band. */ public double getHeight(Graphics2D g2) { double result = 0.0; if (this.markers.size() > 0) { LineMetrics metrics = this.font.getLineMetrics( "123g", g2.getFontRenderContext() ); result = this.topOuterGap + this.topInnerGap + metrics.getHeight() + this.bottomInnerGap + this.bottomOuterGap; } return result; } /** * A utility method that draws a string inside a rectangle. * * @param g2 the graphics device. * @param bounds the rectangle. * @param font the font. * @param text the text. */ private void drawStringInRect(Graphics2D g2, Rectangle2D bounds, Font font, String text) { g2.setFont(font); FontMetrics fm = g2.getFontMetrics(font); Rectangle2D r = TextUtilities.getTextBounds(text, g2, fm); double x = bounds.getX(); if (r.getWidth() < bounds.getWidth()) { x = x + (bounds.getWidth() - r.getWidth()) / 2; } LineMetrics metrics = font.getLineMetrics( text, g2.getFontRenderContext() ); g2.drawString( text, (float) x, (float) (bounds.getMaxY() - this.bottomInnerGap - metrics.getDescent()) ); } /** * Draws the band. * * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the data area. * @param x the x-coordinate. * @param y the y-coordinate. */ public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, double x, double y) { double h = getHeight(g2); Iterator iterator = this.markers.iterator(); while (iterator.hasNext()) { IntervalMarker marker = (IntervalMarker) iterator.next(); double start = Math.max( marker.getStartValue(), this.axis.getRange().getLowerBound() ); double end = Math.min( marker.getEndValue(), this.axis.getRange().getUpperBound() ); double s = this.axis.valueToJava2D( start, dataArea, RectangleEdge.BOTTOM ); double e = this.axis.valueToJava2D( end, dataArea, RectangleEdge.BOTTOM ); Rectangle2D r = new Rectangle2D.Double( s, y + this.topOuterGap, e - s, h - this.topOuterGap - this.bottomOuterGap ); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha()) ); g2.setPaint(marker.getPaint()); g2.fill(r); g2.setPaint(marker.getOutlinePaint()); g2.draw(r); g2.setComposite(originalComposite); g2.setPaint(Color.black); drawStringInRect(g2, r, this.font, marker.getLabel()); } } /** * Tests this axis for equality with another object. Note that the axis * that the band belongs to is ignored in the test. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MarkerAxisBand)) { return false; } MarkerAxisBand that = (MarkerAxisBand) obj; if (this.topOuterGap != that.topOuterGap) { return false; } if (this.topInnerGap != that.topInnerGap) { return false; } if (this.bottomInnerGap != that.bottomInnerGap) { return false; } if (this.bottomOuterGap != that.bottomOuterGap) { return false; } if (!ObjectUtilities.equal(this.font, that.font)) { return false; } if (!ObjectUtilities.equal(this.markers, that.markers)) { return false; } return true; } /** * Returns a hash code for the object. * * @return A hash code. */ public int hashCode() { int result = 37; result = 19 * result + this.font.hashCode(); result = 19 * result + this.markers.hashCode(); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/ModuloAxis.java0000644000175000017500000003360111173030414026327 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ModuloAxis.java * --------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2004 : Version 1 (DG); * 13-Nov-2007 : Implemented equals() (DG); * */ package org.jfree.chart.axis; import java.awt.geom.Rectangle2D; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; /** * An axis that displays numerical values within a fixed range using a modulo * calculation. */ public class ModuloAxis extends NumberAxis { /** * The fixed range for the axis - all data values will be mapped to this * range using a modulo calculation. */ private Range fixedRange; /** * The display start value (this will sometimes be > displayEnd, in which * case the axis wraps around at some point in the middle of the axis). */ private double displayStart; /** * The display end value. */ private double displayEnd; /** * Creates a new axis. * * @param label the axis label (null permitted). * @param fixedRange the fixed range (null not permitted). */ public ModuloAxis(String label, Range fixedRange) { super(label); this.fixedRange = fixedRange; this.displayStart = 270.0; this.displayEnd = 90.0; } /** * Returns the display start value. * * @return The display start value. */ public double getDisplayStart() { return this.displayStart; } /** * Returns the display end value. * * @return The display end value. */ public double getDisplayEnd() { return this.displayEnd; } /** * Sets the display range. The values will be mapped to the fixed range if * necessary. * * @param start the start value. * @param end the end value. */ public void setDisplayRange(double start, double end) { this.displayStart = mapValueToFixedRange(start); this.displayEnd = mapValueToFixedRange(end); if (this.displayStart < this.displayEnd) { setRange(this.displayStart, this.displayEnd); } else { setRange(this.displayStart, this.fixedRange.getUpperBound() + (this.displayEnd - this.fixedRange.getLowerBound())); } notifyListeners(new AxisChangeEvent(this)); } /** * This method should calculate a range that will show all the data values. * For now, it just sets the axis range to the fixedRange. */ protected void autoAdjustRange() { setRange(this.fixedRange, false, false); } /** * Translates a data value to a Java2D coordinate. * * @param value the value. * @param area the area. * @param edge the edge. * * @return A Java2D coordinate. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { double result = 0.0; double v = mapValueToFixedRange(value); if (this.displayStart < this.displayEnd) { // regular number axis result = trans(v, area, edge); } else { // displayStart > displayEnd, need to handle split double cutoff = (this.displayStart + this.displayEnd) / 2.0; double length1 = this.fixedRange.getUpperBound() - this.displayStart; double length2 = this.displayEnd - this.fixedRange.getLowerBound(); if (v > cutoff) { result = transStart(v, area, edge, length1, length2); } else { result = transEnd(v, area, edge, length1, length2); } } return result; } /** * A regular translation from a data value to a Java2D value. * * @param value the value. * @param area the data area. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate. */ private double trans(double value, Rectangle2D area, RectangleEdge edge) { double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getX() + area.getWidth(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getMaxY() - area.getHeight(); } if (isInverted()) { return max - ((value - this.displayStart) / (this.displayEnd - this.displayStart)) * (max - min); } else { return min + ((value - this.displayStart) / (this.displayEnd - this.displayStart)) * (max - min); } } /** * Translates a data value to a Java2D value for the first section of the * axis. * * @param value the value. * @param area the data area. * @param edge the edge along which the axis lies. * @param length1 the length of the first section. * @param length2 the length of the second section. * * @return The Java2D coordinate. */ private double transStart(double value, Rectangle2D area, RectangleEdge edge, double length1, double length2) { double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getX() + area.getWidth() * length1 / (length1 + length2); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getMaxY() - area.getHeight() * length1 / (length1 + length2); } if (isInverted()) { return max - ((value - this.displayStart) / (this.fixedRange.getUpperBound() - this.displayStart)) * (max - min); } else { return min + ((value - this.displayStart) / (this.fixedRange.getUpperBound() - this.displayStart)) * (max - min); } } /** * Translates a data value to a Java2D value for the second section of the * axis. * * @param value the value. * @param area the data area. * @param edge the edge along which the axis lies. * @param length1 the length of the first section. * @param length2 the length of the second section. * * @return The Java2D coordinate. */ private double transEnd(double value, Rectangle2D area, RectangleEdge edge, double length1, double length2) { double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { max = area.getMaxX(); min = area.getMaxX() - area.getWidth() * length2 / (length1 + length2); } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMinY() + area.getHeight() * length2 / (length1 + length2); } if (isInverted()) { return max - ((value - this.fixedRange.getLowerBound()) / (this.displayEnd - this.fixedRange.getLowerBound())) * (max - min); } else { return min + ((value - this.fixedRange.getLowerBound()) / (this.displayEnd - this.fixedRange.getLowerBound())) * (max - min); } } /** * Maps a data value into the fixed range. * * @param value the value. * * @return The mapped value. */ private double mapValueToFixedRange(double value) { double lower = this.fixedRange.getLowerBound(); double length = this.fixedRange.getLength(); if (value < lower) { return lower + length + ((value - lower) % length); } else { return lower + ((value - lower) % length); } } /** * Translates a Java2D coordinate into a data value. * * @param java2DValue the Java2D coordinate. * @param area the area. * @param edge the edge. * * @return The Java2D coordinate. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { double result = 0.0; if (this.displayStart < this.displayEnd) { // regular number axis result = super.java2DToValue(java2DValue, area, edge); } else { // displayStart > displayEnd, need to handle split } return result; } /** * Returns the display length for the axis. * * @return The display length. */ private double getDisplayLength() { if (this.displayStart < this.displayEnd) { return (this.displayEnd - this.displayStart); } else { return (this.fixedRange.getUpperBound() - this.displayStart) + (this.displayEnd - this.fixedRange.getLowerBound()); } } /** * Returns the central value of the current display range. * * @return The central value. */ private double getDisplayCentralValue() { return mapValueToFixedRange( this.displayStart + (getDisplayLength() / 2) ); } /** * Increases or decreases the axis range by the specified percentage about * the central value and sends an {@link AxisChangeEvent} to all registered * listeners. *

* To double the length of the axis range, use 200% (2.0). * To halve the length of the axis range, use 50% (0.5). * * @param percent the resize factor. */ public void resizeRange(double percent) { resizeRange(percent, getDisplayCentralValue()); } /** * Increases or decreases the axis range by the specified percentage about * the specified anchor value and sends an {@link AxisChangeEvent} to all * registered listeners. *

* To double the length of the axis range, use 200% (2.0). * To halve the length of the axis range, use 50% (0.5). * * @param percent the resize factor. * @param anchorValue the new central value after the resize. */ public void resizeRange(double percent, double anchorValue) { if (percent > 0.0) { double halfLength = getDisplayLength() * percent / 2; setDisplayRange(anchorValue - halfLength, anchorValue + halfLength); } else { setAutoRange(true); } } /** * Converts a length in data coordinates into the corresponding length in * Java2D coordinates. * * @param length the length. * @param area the plot area. * @param edge the edge along which the axis lies. * * @return The length in Java2D coordinates. */ public double lengthToJava2D(double length, Rectangle2D area, RectangleEdge edge) { double axisLength = 0.0; if (this.displayEnd > this.displayStart) { axisLength = this.displayEnd - this.displayStart; } else { axisLength = (this.fixedRange.getUpperBound() - this.displayStart) + (this.displayEnd - this.fixedRange.getLowerBound()); } double areaLength = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { areaLength = area.getHeight(); } else { areaLength = area.getWidth(); } return (length / axisLength) * areaLength; } /** * Tests this axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ModuloAxis)) { return false; } ModuloAxis that = (ModuloAxis) obj; if (this.displayStart != that.displayStart) { return false; } if (this.displayEnd != that.displayEnd) { return false; } if (!this.fixedRange.equals(that.fixedRange)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/MonthDateFormat.java0000644000175000017500000003041411173030414027276 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * MonthDateFormat.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 10-May-2005 : Version 1 (DG); * */ package org.jfree.chart.axis; import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import org.jfree.data.time.Month; /** * A formatter that formats dates to show the initial letter(s) of the month * name and, as an option, the year for the first or last month of each year. */ public class MonthDateFormat extends DateFormat { /** The symbols used for the months. */ private String[] months; /** Flags that control which months will have the year appended. */ private boolean[] showYear; /** The year formatter. */ private DateFormat yearFormatter; /** * Creates a new instance for the default time zone. */ public MonthDateFormat() { this(TimeZone.getDefault()); } /** * Creates a new instance for the specified time zone. * * @param zone the time zone (null not permitted). */ public MonthDateFormat(TimeZone zone) { this(zone, Locale.getDefault(), 1, true, false); } /** * Creates a new instance for the specified time zone. * * @param locale the locale used to obtain the month * names (null not permitted). */ public MonthDateFormat(Locale locale) { this(TimeZone.getDefault(), locale, 1, true, false); } /** * Creates a new instance for the specified time zone. * * @param zone the time zone (null not permitted). * @param chars the maximum number of characters to use from the month * names (that are obtained from the date symbols of the * default locale). If this value is <= 0, the entire * month name is used in each case. */ public MonthDateFormat(TimeZone zone, int chars) { this(zone, Locale.getDefault(), chars, true, false); } /** * Creates a new instance for the specified time zone. * * @param locale the locale (null not permitted). * @param chars the maximum number of characters to use from the month * names (that are obtained from the date symbols of the * default locale). If this value is <= 0, the entire * month name is used in each case. */ public MonthDateFormat(Locale locale, int chars) { this(TimeZone.getDefault(), locale, chars, true, false); } /** * Creates a new formatter. * * @param zone the time zone used to extract the month and year from dates * passed to this formatter (null not permitted). * @param locale the locale used to determine the month names * (null not permitted). * @param chars the maximum number of characters to use from the month * names, or zero to indicate that the entire month name * should be used. * @param showYearForJan a flag that controls whether or not the year is * appended to the symbol for the first month of * each year. * @param showYearForDec a flag that controls whether or not the year is * appended to the symbol for the last month of * each year. */ public MonthDateFormat(TimeZone zone, Locale locale, int chars, boolean showYearForJan, boolean showYearForDec) { this(zone, locale, chars, new boolean[] {showYearForJan, false, false, false, false, false, false, false, false, false, false, false, showYearForDec}, new SimpleDateFormat("yy")); } /** * Creates a new formatter. * * @param zone the time zone used to extract the month and year from dates * passed to this formatter (null not permitted). * @param locale the locale used to determine the month names * (null not permitted). * @param chars the maximum number of characters to use from the month * names, or zero to indicate that the entire month name * should be used. * @param showYear an array of flags that control whether or not the * year is displayed for a particular month. * @param yearFormatter the year formatter. */ public MonthDateFormat(TimeZone zone, Locale locale, int chars, boolean[] showYear, DateFormat yearFormatter) { if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } DateFormatSymbols dfs = new DateFormatSymbols(locale); String[] monthsFromLocale = dfs.getMonths(); this.months = new String[12]; for (int i = 0; i < 12; i++) { if (chars > 0) { this.months[i] = monthsFromLocale[i].substring(0, Math.min(chars, monthsFromLocale[i].length())); } else { this.months[i] = monthsFromLocale[i]; } } this.calendar = new GregorianCalendar(zone); this.showYear = showYear; this.yearFormatter = yearFormatter; // the following is never used, but it seems that DateFormat requires // it to be non-null. It isn't well covered in the spec, refer to // bug parade 5061189 for more info. this.numberFormat = NumberFormat.getNumberInstance(); } /** * Formats the given date. * * @param date the date. * @param toAppendTo the string buffer. * @param fieldPosition the field position. * * @return The formatted date. */ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { this.calendar.setTime(date); int month = this.calendar.get(Calendar.MONTH); toAppendTo.append(this.months[month]); if (this.showYear[month]) { toAppendTo.append(this.yearFormatter.format(date)); } return toAppendTo; } /** * Parses the given string (not implemented). * * @param source the date string. * @param pos the parse position. * * @return null, as this method has not been implemented. */ public Date parse(String source, ParsePosition pos) { return null; } /** * Tests this formatter for equality with an arbitrary object. * * @param obj the object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MonthDateFormat)) { return false; } if (!super.equals(obj)) { return false; } MonthDateFormat that = (MonthDateFormat) obj; if (!Arrays.equals(this.months, that.months)) { return false; } if (!Arrays.equals(this.showYear, that.showYear)) { return false; } if (!this.yearFormatter.equals(that.yearFormatter)) { return false; } return true; } /** * Some test code. * * @param args ignored. */ public static void main(String[] args) { MonthDateFormat mdf = new MonthDateFormat(Locale.UK, 2); System.out.println("UK:"); System.out.println(mdf.format(new Month(1, 2005).getStart())); System.out.println(mdf.format(new Month(2, 2005).getStart())); System.out.println(mdf.format(new Month(3, 2005).getStart())); System.out.println(mdf.format(new Month(4, 2005).getStart())); System.out.println(mdf.format(new Month(5, 2005).getStart())); System.out.println(mdf.format(new Month(6, 2005).getStart())); System.out.println(mdf.format(new Month(7, 2005).getStart())); System.out.println(mdf.format(new Month(8, 2005).getStart())); System.out.println(mdf.format(new Month(9, 2005).getStart())); System.out.println(mdf.format(new Month(10, 2005).getStart())); System.out.println(mdf.format(new Month(11, 2005).getStart())); System.out.println(mdf.format(new Month(12, 2005).getStart())); System.out.println(); mdf = new MonthDateFormat(Locale.GERMANY, 2); System.out.println("GERMANY:"); System.out.println(mdf.format(new Month(1, 2005).getStart())); System.out.println(mdf.format(new Month(2, 2005).getStart())); System.out.println(mdf.format(new Month(3, 2005).getStart())); System.out.println(mdf.format(new Month(4, 2005).getStart())); System.out.println(mdf.format(new Month(5, 2005).getStart())); System.out.println(mdf.format(new Month(6, 2005).getStart())); System.out.println(mdf.format(new Month(7, 2005).getStart())); System.out.println(mdf.format(new Month(8, 2005).getStart())); System.out.println(mdf.format(new Month(9, 2005).getStart())); System.out.println(mdf.format(new Month(10, 2005).getStart())); System.out.println(mdf.format(new Month(11, 2005).getStart())); System.out.println(mdf.format(new Month(12, 2005).getStart())); System.out.println(); mdf = new MonthDateFormat(Locale.FRANCE, 2); System.out.println("FRANCE:"); System.out.println(mdf.format(new Month(1, 2005).getStart())); System.out.println(mdf.format(new Month(2, 2005).getStart())); System.out.println(mdf.format(new Month(3, 2005).getStart())); System.out.println(mdf.format(new Month(4, 2005).getStart())); System.out.println(mdf.format(new Month(5, 2005).getStart())); System.out.println(mdf.format(new Month(6, 2005).getStart())); System.out.println(mdf.format(new Month(7, 2005).getStart())); System.out.println(mdf.format(new Month(8, 2005).getStart())); System.out.println(mdf.format(new Month(9, 2005).getStart())); System.out.println(mdf.format(new Month(10, 2005).getStart())); System.out.println(mdf.format(new Month(11, 2005).getStart())); System.out.println(mdf.format(new Month(12, 2005).getStart())); System.out.println(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); sdf.setNumberFormat(null); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/NumberAxis.java0000644000175000017500000015635511173030414026334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * NumberAxis.java * --------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Laurence Vanhelsuwe; * Peter Kolb (patches 1934255 and 2603321); * * Changes * ------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 22-Sep-2001 : Changed setMinimumAxisValue() and setMaximumAxisValue() so * that they clear the autoRange flag (DG); * 27-Nov-2001 : Removed old, redundant code (DG); * 30-Nov-2001 : Added accessor methods for the standard tick units (DG); * 08-Jan-2002 : Added setAxisRange() method (since renamed setRange()) (DG); * 16-Jan-2002 : Added setTickUnit() method. Extended ValueAxis to support an * optional cross-hair (DG); * 08-Feb-2002 : Fixes bug to ensure the autorange is recalculated if the * setAutoRangeIncludesZero flag is changed (DG); * 25-Feb-2002 : Added a new flag autoRangeStickyZero to provide further * control over margins in the auto-range mechanism. Updated * constructors. Updated import statements. Moved the * createStandardTickUnits() method to the TickUnits class (DG); * 19-Apr-2002 : Updated Javadoc comments (DG); * 01-May-2002 : Updated for changes to TickUnit class, removed valueToString() * method (DG); * 25-Jul-2002 : Moved the lower and upper margin attributes, and the * auto-range minimum size, up one level to the ValueAxis * class (DG); * 05-Sep-2002 : Updated constructor to match changes in Axis class (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 04-Oct-2002 : Moved standardTickUnits from NumberAxis --> ValueAxis (DG); * 24-Oct-2002 : Added a number format override (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 19-Nov-2002 : Removed grid settings (now controlled by the plot) (DG); * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double, and moved * crosshair settings to the plot classes (DG); * 20-Jan-2003 : Removed the monolithic constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 16-Jul-2003 : Reworked to allow for multiple secondary axes (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 07-Oct-2003 : Fixed bug (815028) in the auto range calculation (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 07-Nov-2003 : Modified to use NumberTick class (DG); * 21-Jan-2004 : Renamed translateJava2DToValue --> java2DToValue, and * translateValueToJava2D --> valueToJava2D (DG); * 03-Mar-2004 : Added plotState to draw() method (DG); * 07-Apr-2004 : Changed string width calculation (DG); * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * 28-Mar-2005 : Renamed autoRangeIncludesZero() --> getAutoRangeIncludesZero() * and autoRangeStickyZero() --> getAutoRangeStickyZero() (DG); * 21-Apr-2005 : Removed redundant argument from selectAutoTickUnit() (DG); * 22-Apr-2005 : Renamed refreshHorizontalTicks --> refreshTicksHorizontal * (and likewise the vertical version) for consistency with * other axis classes (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 10-Feb-2006 : Added some API doc comments in respect of bug 821046 (DG); * 20-Feb-2006 : Modified equals() method to check rangeType field (fixes bug * 1435461) (DG); * 04-Sep-2006 : Fix auto range calculation for the case where all data values * are constant and large (see bug report 1549218) (DG); * 11-Dec-2006 : Fix bug in auto-tick unit selection with tick format override, * see bug 1608371 (DG); * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * 21-Jan-2009 : Default minor tick counts will now come from the tick unit * collection (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart.axis; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.List; import java.util.Locale; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.data.Range; import org.jfree.data.RangeType; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; /** * An axis for displaying numerical data. *

* If the axis is set up to automatically determine its range to fit the data, * you can ensure that the range includes zero (statisticians usually prefer * this) by setting the autoRangeIncludesZero flag to * true. *

* The NumberAxis class has a mechanism for automatically * selecting a tick unit that is appropriate for the current axis range. This * mechanism is an adaptation of code suggested by Laurence Vanhelsuwe. */ public class NumberAxis extends ValueAxis implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2805933088476185789L; /** The default value for the autoRangeIncludesZero flag. */ public static final boolean DEFAULT_AUTO_RANGE_INCLUDES_ZERO = true; /** The default value for the autoRangeStickyZero flag. */ public static final boolean DEFAULT_AUTO_RANGE_STICKY_ZERO = true; /** The default tick unit. */ public static final NumberTickUnit DEFAULT_TICK_UNIT = new NumberTickUnit( 1.0, new DecimalFormat("0")); /** The default setting for the vertical tick labels flag. */ public static final boolean DEFAULT_VERTICAL_TICK_LABELS = false; /** * The range type (can be used to force the axis to display only positive * values or only negative values). */ private RangeType rangeType; /** * A flag that affects the axis range when the range is determined * automatically. If the auto range does NOT include zero and this flag * is TRUE, then the range is changed to include zero. */ private boolean autoRangeIncludesZero; /** * A flag that affects the size of the margins added to the axis range when * the range is determined automatically. If the value 0 falls within the * margin and this flag is TRUE, then the margin is truncated at zero. */ private boolean autoRangeStickyZero; /** The tick unit for the axis. */ private NumberTickUnit tickUnit; /** The override number format. */ private NumberFormat numberFormatOverride; /** An optional band for marking regions on the axis. */ private MarkerAxisBand markerBand; /** * Default constructor. */ public NumberAxis() { this(null); } /** * Constructs a number axis, using default values where necessary. * * @param label the axis label (null permitted). */ public NumberAxis(String label) { super(label, NumberAxis.createStandardTickUnits()); this.rangeType = RangeType.FULL; this.autoRangeIncludesZero = DEFAULT_AUTO_RANGE_INCLUDES_ZERO; this.autoRangeStickyZero = DEFAULT_AUTO_RANGE_STICKY_ZERO; this.tickUnit = DEFAULT_TICK_UNIT; this.numberFormatOverride = null; this.markerBand = null; } /** * Returns the axis range type. * * @return The axis range type (never null). * * @see #setRangeType(RangeType) */ public RangeType getRangeType() { return this.rangeType; } /** * Sets the axis range type. * * @param rangeType the range type (null not permitted). * * @see #getRangeType() */ public void setRangeType(RangeType rangeType) { if (rangeType == null) { throw new IllegalArgumentException("Null 'rangeType' argument."); } this.rangeType = rangeType; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the flag that indicates whether or not the automatic axis range * (if indeed it is determined automatically) is forced to include zero. * * @return The flag. */ public boolean getAutoRangeIncludesZero() { return this.autoRangeIncludesZero; } /** * Sets the flag that indicates whether or not the axis range, if * automatically calculated, is forced to include zero. *

* If the flag is changed to true, the axis range is * recalculated. *

* Any change to the flag will trigger an {@link AxisChangeEvent}. * * @param flag the new value of the flag. * * @see #getAutoRangeIncludesZero() */ public void setAutoRangeIncludesZero(boolean flag) { if (this.autoRangeIncludesZero != flag) { this.autoRangeIncludesZero = flag; if (isAutoRange()) { autoAdjustRange(); } notifyListeners(new AxisChangeEvent(this)); } } /** * Returns a flag that affects the auto-range when zero falls outside the * data range but inside the margins defined for the axis. * * @return The flag. * * @see #setAutoRangeStickyZero(boolean) */ public boolean getAutoRangeStickyZero() { return this.autoRangeStickyZero; } /** * Sets a flag that affects the auto-range when zero falls outside the data * range but inside the margins defined for the axis. * * @param flag the new flag. * * @see #getAutoRangeStickyZero() */ public void setAutoRangeStickyZero(boolean flag) { if (this.autoRangeStickyZero != flag) { this.autoRangeStickyZero = flag; if (isAutoRange()) { autoAdjustRange(); } notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the tick unit for the axis. *

* Note: if the autoTickUnitSelection flag is * true the tick unit may be changed while the axis is being * drawn, so in that case the return value from this method may be * irrelevant if the method is called before the axis has been drawn. * * @return The tick unit for the axis. * * @see #setTickUnit(NumberTickUnit) * @see ValueAxis#isAutoTickUnitSelection() */ public NumberTickUnit getTickUnit() { return this.tickUnit; } /** * Sets the tick unit for the axis and sends an {@link AxisChangeEvent} to * all registered listeners. A side effect of calling this method is that * the "auto-select" feature for tick units is switched off (you can * restore it using the {@link ValueAxis#setAutoTickUnitSelection(boolean)} * method). * * @param unit the new tick unit (null not permitted). * * @see #getTickUnit() * @see #setTickUnit(NumberTickUnit, boolean, boolean) */ public void setTickUnit(NumberTickUnit unit) { // defer argument checking... setTickUnit(unit, true, true); } /** * Sets the tick unit for the axis and, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. In addition, an * option is provided to turn off the "auto-select" feature for tick units * (you can restore it using the * {@link ValueAxis#setAutoTickUnitSelection(boolean)} method). * * @param unit the new tick unit (null not permitted). * @param notify notify listeners? * @param turnOffAutoSelect turn off the auto-tick selection? */ public void setTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect) { if (unit == null) { throw new IllegalArgumentException("Null 'unit' argument."); } this.tickUnit = unit; if (turnOffAutoSelect) { setAutoTickUnitSelection(false, false); } if (notify) { notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the number format override. If this is non-null, then it will * be used to format the numbers on the axis. * * @return The number formatter (possibly null). * * @see #setNumberFormatOverride(NumberFormat) */ public NumberFormat getNumberFormatOverride() { return this.numberFormatOverride; } /** * Sets the number format override. If this is non-null, then it will be * used to format the numbers on the axis. * * @param formatter the number formatter (null permitted). * * @see #getNumberFormatOverride() */ public void setNumberFormatOverride(NumberFormat formatter) { this.numberFormatOverride = formatter; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the (optional) marker band for the axis. * * @return The marker band (possibly null). * * @see #setMarkerBand(MarkerAxisBand) */ public MarkerAxisBand getMarkerBand() { return this.markerBand; } /** * Sets the marker band for the axis. *

* The marker band is optional, leave it set to null if you * don't require it. * * @param band the new band (null permitted). * * @see #getMarkerBand() */ public void setMarkerBand(MarkerAxisBand band) { this.markerBand = band; notifyListeners(new AxisChangeEvent(this)); } /** * Configures the axis to work with the specified plot. If the axis has * auto-scaling, then sets the maximum and minimum values. */ public void configure() { if (isAutoRange()) { autoAdjustRange(); } } /** * Rescales the axis to ensure that all data is visible. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } double upper = r.getUpperBound(); double lower = r.getLowerBound(); if (this.rangeType == RangeType.POSITIVE) { lower = Math.max(0.0, lower); upper = Math.max(0.0, upper); } else if (this.rangeType == RangeType.NEGATIVE) { lower = Math.min(0.0, lower); upper = Math.min(0.0, upper); } if (getAutoRangeIncludesZero()) { lower = Math.min(lower, 0.0); upper = Math.max(upper, 0.0); } double range = upper - lower; // if fixed auto range, then derive lower bound... double fixedAutoRange = getFixedAutoRange(); if (fixedAutoRange > 0.0) { lower = upper - fixedAutoRange; } else { // ensure the autorange is at least in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { double expand = (minRange - range) / 2; upper = upper + expand; lower = lower - expand; if (lower == upper) { // see bug report 1549218 double adjust = Math.abs(lower) / 10.0; lower = lower - adjust; upper = upper + adjust; } if (this.rangeType == RangeType.POSITIVE) { if (lower < 0.0) { upper = upper - lower; lower = 0.0; } } else if (this.rangeType == RangeType.NEGATIVE) { if (upper > 0.0) { lower = lower - upper; upper = 0.0; } } } if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = Math.min(0.0, upper + getUpperMargin() * range); } else { upper = upper + getUpperMargin() * range; } if (lower >= 0.0) { lower = Math.max(0.0, lower - getLowerMargin() * range); } else { lower = lower - getLowerMargin() * range; } } else { upper = upper + getUpperMargin() * range; lower = lower - getLowerMargin() * range; } } setRange(new Range(lower, upper), false, false); } } /** * Converts a data value to a coordinate in Java2D space, assuming that the * axis runs along one edge of the specified dataArea. *

* Note that it is possible for the coordinate to fall outside the plotArea. * * @param value the data value. * @param area the area for plotting the data. * @param edge the axis location. * * @return The Java2D coordinate. * * @see #java2DToValue(double, Rectangle2D, RectangleEdge) */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = range.getLowerBound(); double axisMax = range.getUpperBound(); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMaxY(); } if (isInverted()) { return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); } else { return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); } } /** * Converts a coordinate in Java2D space to the corresponding data value, * assuming that the axis runs along one edge of the specified dataArea. * * @param java2DValue the coordinate in Java2D space. * @param area the area in which the data is plotted. * @param edge the location. * * @return The data value. * * @see #valueToJava2D(double, Rectangle2D, RectangleEdge) */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = range.getLowerBound(); double axisMax = range.getUpperBound(); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } if (isInverted()) { return axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin); } else { return axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin); } } /** * Calculates the value of the lowest visible tick on the axis. * * @return The value of the lowest visible tick on the axis. * * @see #calculateHighestVisibleTickValue() */ protected double calculateLowestVisibleTickValue() { double unit = getTickUnit().getSize(); double index = Math.ceil(getRange().getLowerBound() / unit); return index * unit; } /** * Calculates the value of the highest visible tick on the axis. * * @return The value of the highest visible tick on the axis. * * @see #calculateLowestVisibleTickValue() */ protected double calculateHighestVisibleTickValue() { double unit = getTickUnit().getSize(); double index = Math.floor(getRange().getUpperBound() / unit); return index * unit; } /** * Calculates the number of visible ticks. * * @return The number of visible ticks on the axis. */ protected int calculateVisibleTickCount() { double unit = getTickUnit().getSize(); Range range = getRange(); return (int) (Math.floor(range.getUpperBound() / unit) - Math.ceil(range.getLowerBound() / unit) + 1); } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axes and data should be drawn * (null not permitted). * @param dataArea the area within which the data should be drawn * (null not permitted). * @param edge the location of the axis (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState state = null; // if the axis is not visible, don't draw it... if (!isVisible()) { state = new AxisState(cursor); // even though the axis is not visible, we need ticks for the // gridlines... List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); return state; } // draw the tick marks and labels... state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); // // draw the marker band (if there is one)... // if (getMarkerBand() != null) { // if (edge == RectangleEdge.BOTTOM) { // cursor = cursor - getMarkerBand().getHeight(g2); // } // getMarkerBand().draw(g2, plotArea, dataArea, 0, cursor); // } // draw the axis label... state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); createAndAddEntity(cursor, state, dataArea, edge, plotState); return state; } /** * Creates the standard tick units. *

* If you don't like these defaults, create your own instance of TickUnits * and then pass it to the setStandardTickUnits() method in the * NumberAxis class. * * @return The standard tick units. * * @see #setStandardTickUnits(TickUnitSource) * @see #createIntegerTickUnits() */ public static TickUnitSource createStandardTickUnits() { TickUnits units = new TickUnits(); DecimalFormat df0 = new DecimalFormat("0.00000000"); DecimalFormat df1 = new DecimalFormat("0.0000000"); DecimalFormat df2 = new DecimalFormat("0.000000"); DecimalFormat df3 = new DecimalFormat("0.00000"); DecimalFormat df4 = new DecimalFormat("0.0000"); DecimalFormat df5 = new DecimalFormat("0.000"); DecimalFormat df6 = new DecimalFormat("0.00"); DecimalFormat df7 = new DecimalFormat("0.0"); DecimalFormat df8 = new DecimalFormat("#,##0"); DecimalFormat df9 = new DecimalFormat("#,###,##0"); DecimalFormat df10 = new DecimalFormat("#,###,###,##0"); // we can add the units in any order, the TickUnits collection will // sort them... units.add(new NumberTickUnit(0.0000001, df1, 2)); units.add(new NumberTickUnit(0.000001, df2, 2)); units.add(new NumberTickUnit(0.00001, df3, 2)); units.add(new NumberTickUnit(0.0001, df4, 2)); units.add(new NumberTickUnit(0.001, df5, 2)); units.add(new NumberTickUnit(0.01, df6, 2)); units.add(new NumberTickUnit(0.1, df7, 2)); units.add(new NumberTickUnit(1, df8, 2)); units.add(new NumberTickUnit(10, df8, 2)); units.add(new NumberTickUnit(100, df8, 2)); units.add(new NumberTickUnit(1000, df8, 2)); units.add(new NumberTickUnit(10000, df8, 2)); units.add(new NumberTickUnit(100000, df8, 2)); units.add(new NumberTickUnit(1000000, df9, 2)); units.add(new NumberTickUnit(10000000, df9, 2)); units.add(new NumberTickUnit(100000000, df9, 2)); units.add(new NumberTickUnit(1000000000, df10, 2)); units.add(new NumberTickUnit(10000000000.0, df10, 2)); units.add(new NumberTickUnit(100000000000.0, df10, 2)); units.add(new NumberTickUnit(0.00000025, df0, 5)); units.add(new NumberTickUnit(0.0000025, df1, 5)); units.add(new NumberTickUnit(0.000025, df2, 5)); units.add(new NumberTickUnit(0.00025, df3, 5)); units.add(new NumberTickUnit(0.0025, df4, 5)); units.add(new NumberTickUnit(0.025, df5, 5)); units.add(new NumberTickUnit(0.25, df6, 5)); units.add(new NumberTickUnit(2.5, df7, 5)); units.add(new NumberTickUnit(25, df8, 5)); units.add(new NumberTickUnit(250, df8, 5)); units.add(new NumberTickUnit(2500, df8, 5)); units.add(new NumberTickUnit(25000, df8, 5)); units.add(new NumberTickUnit(250000, df8, 5)); units.add(new NumberTickUnit(2500000, df9, 5)); units.add(new NumberTickUnit(25000000, df9, 5)); units.add(new NumberTickUnit(250000000, df9, 5)); units.add(new NumberTickUnit(2500000000.0, df10, 5)); units.add(new NumberTickUnit(25000000000.0, df10, 5)); units.add(new NumberTickUnit(250000000000.0, df10, 5)); units.add(new NumberTickUnit(0.0000005, df1, 5)); units.add(new NumberTickUnit(0.000005, df2, 5)); units.add(new NumberTickUnit(0.00005, df3, 5)); units.add(new NumberTickUnit(0.0005, df4, 5)); units.add(new NumberTickUnit(0.005, df5, 5)); units.add(new NumberTickUnit(0.05, df6, 5)); units.add(new NumberTickUnit(0.5, df7, 5)); units.add(new NumberTickUnit(5L, df8, 5)); units.add(new NumberTickUnit(50L, df8, 5)); units.add(new NumberTickUnit(500L, df8, 5)); units.add(new NumberTickUnit(5000L, df8, 5)); units.add(new NumberTickUnit(50000L, df8, 5)); units.add(new NumberTickUnit(500000L, df8, 5)); units.add(new NumberTickUnit(5000000L, df9, 5)); units.add(new NumberTickUnit(50000000L, df9, 5)); units.add(new NumberTickUnit(500000000L, df9, 5)); units.add(new NumberTickUnit(5000000000L, df10, 5)); units.add(new NumberTickUnit(50000000000L, df10, 5)); units.add(new NumberTickUnit(500000000000L, df10, 5)); return units; } /** * Returns a collection of tick units for integer values. * * @return A collection of tick units for integer values. * * @see #setStandardTickUnits(TickUnitSource) * @see #createStandardTickUnits() */ public static TickUnitSource createIntegerTickUnits() { TickUnits units = new TickUnits(); DecimalFormat df0 = new DecimalFormat("0"); DecimalFormat df1 = new DecimalFormat("#,##0"); units.add(new NumberTickUnit(1, df0, 2)); units.add(new NumberTickUnit(2, df0, 2)); units.add(new NumberTickUnit(5, df0, 5)); units.add(new NumberTickUnit(10, df0, 2)); units.add(new NumberTickUnit(20, df0, 2)); units.add(new NumberTickUnit(50, df0, 5)); units.add(new NumberTickUnit(100, df0, 2)); units.add(new NumberTickUnit(200, df0, 2)); units.add(new NumberTickUnit(500, df0, 5)); units.add(new NumberTickUnit(1000, df1, 2)); units.add(new NumberTickUnit(2000, df1, 2)); units.add(new NumberTickUnit(5000, df1, 5)); units.add(new NumberTickUnit(10000, df1, 2)); units.add(new NumberTickUnit(20000, df1, 2)); units.add(new NumberTickUnit(50000, df1, 5)); units.add(new NumberTickUnit(100000, df1, 2)); units.add(new NumberTickUnit(200000, df1, 2)); units.add(new NumberTickUnit(500000, df1, 5)); units.add(new NumberTickUnit(1000000, df1, 2)); units.add(new NumberTickUnit(2000000, df1, 2)); units.add(new NumberTickUnit(5000000, df1, 5)); units.add(new NumberTickUnit(10000000, df1, 2)); units.add(new NumberTickUnit(20000000, df1, 2)); units.add(new NumberTickUnit(50000000, df1, 5)); units.add(new NumberTickUnit(100000000, df1, 2)); units.add(new NumberTickUnit(200000000, df1, 2)); units.add(new NumberTickUnit(500000000, df1, 5)); units.add(new NumberTickUnit(1000000000, df1, 2)); units.add(new NumberTickUnit(2000000000, df1, 2)); units.add(new NumberTickUnit(5000000000.0, df1, 5)); units.add(new NumberTickUnit(10000000000.0, df1, 2)); return units; } /** * Creates a collection of standard tick units. The supplied locale is * used to create the number formatter (a localised instance of * NumberFormat). *

* If you don't like these defaults, create your own instance of * {@link TickUnits} and then pass it to the * setStandardTickUnits() method. * * @param locale the locale. * * @return A tick unit collection. * * @see #setStandardTickUnits(TickUnitSource) */ public static TickUnitSource createStandardTickUnits(Locale locale) { TickUnits units = new TickUnits(); NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); // we can add the units in any order, the TickUnits collection will // sort them... units.add(new NumberTickUnit(0.0000001, numberFormat, 2)); units.add(new NumberTickUnit(0.000001, numberFormat, 2)); units.add(new NumberTickUnit(0.00001, numberFormat, 2)); units.add(new NumberTickUnit(0.0001, numberFormat, 2)); units.add(new NumberTickUnit(0.001, numberFormat, 2)); units.add(new NumberTickUnit(0.01, numberFormat, 2)); units.add(new NumberTickUnit(0.1, numberFormat, 2)); units.add(new NumberTickUnit(1, numberFormat, 2)); units.add(new NumberTickUnit(10, numberFormat, 2)); units.add(new NumberTickUnit(100, numberFormat, 2)); units.add(new NumberTickUnit(1000, numberFormat, 2)); units.add(new NumberTickUnit(10000, numberFormat, 2)); units.add(new NumberTickUnit(100000, numberFormat, 2)); units.add(new NumberTickUnit(1000000, numberFormat, 2)); units.add(new NumberTickUnit(10000000, numberFormat, 2)); units.add(new NumberTickUnit(100000000, numberFormat, 2)); units.add(new NumberTickUnit(1000000000, numberFormat, 2)); units.add(new NumberTickUnit(10000000000.0, numberFormat, 2)); units.add(new NumberTickUnit(0.00000025, numberFormat, 5)); units.add(new NumberTickUnit(0.0000025, numberFormat, 5)); units.add(new NumberTickUnit(0.000025, numberFormat, 5)); units.add(new NumberTickUnit(0.00025, numberFormat, 5)); units.add(new NumberTickUnit(0.0025, numberFormat, 5)); units.add(new NumberTickUnit(0.025, numberFormat, 5)); units.add(new NumberTickUnit(0.25, numberFormat, 5)); units.add(new NumberTickUnit(2.5, numberFormat, 5)); units.add(new NumberTickUnit(25, numberFormat, 5)); units.add(new NumberTickUnit(250, numberFormat, 5)); units.add(new NumberTickUnit(2500, numberFormat, 5)); units.add(new NumberTickUnit(25000, numberFormat, 5)); units.add(new NumberTickUnit(250000, numberFormat, 5)); units.add(new NumberTickUnit(2500000, numberFormat, 5)); units.add(new NumberTickUnit(25000000, numberFormat, 5)); units.add(new NumberTickUnit(250000000, numberFormat, 5)); units.add(new NumberTickUnit(2500000000.0, numberFormat, 5)); units.add(new NumberTickUnit(25000000000.0, numberFormat, 5)); units.add(new NumberTickUnit(0.0000005, numberFormat, 5)); units.add(new NumberTickUnit(0.000005, numberFormat, 5)); units.add(new NumberTickUnit(0.00005, numberFormat, 5)); units.add(new NumberTickUnit(0.0005, numberFormat, 5)); units.add(new NumberTickUnit(0.005, numberFormat, 5)); units.add(new NumberTickUnit(0.05, numberFormat, 5)); units.add(new NumberTickUnit(0.5, numberFormat, 5)); units.add(new NumberTickUnit(5L, numberFormat, 5)); units.add(new NumberTickUnit(50L, numberFormat, 5)); units.add(new NumberTickUnit(500L, numberFormat, 5)); units.add(new NumberTickUnit(5000L, numberFormat, 5)); units.add(new NumberTickUnit(50000L, numberFormat, 5)); units.add(new NumberTickUnit(500000L, numberFormat, 5)); units.add(new NumberTickUnit(5000000L, numberFormat, 5)); units.add(new NumberTickUnit(50000000L, numberFormat, 5)); units.add(new NumberTickUnit(500000000L, numberFormat, 5)); units.add(new NumberTickUnit(5000000000L, numberFormat, 5)); units.add(new NumberTickUnit(50000000000L, numberFormat, 5)); return units; } /** * Returns a collection of tick units for integer values. * Uses a given Locale to create the DecimalFormats. * * @param locale the locale to use to represent Numbers. * * @return A collection of tick units for integer values. * * @see #setStandardTickUnits(TickUnitSource) */ public static TickUnitSource createIntegerTickUnits(Locale locale) { TickUnits units = new TickUnits(); NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); units.add(new NumberTickUnit(1, numberFormat, 2)); units.add(new NumberTickUnit(2, numberFormat, 2)); units.add(new NumberTickUnit(5, numberFormat, 5)); units.add(new NumberTickUnit(10, numberFormat, 2)); units.add(new NumberTickUnit(20, numberFormat, 2)); units.add(new NumberTickUnit(50, numberFormat, 5)); units.add(new NumberTickUnit(100, numberFormat, 2)); units.add(new NumberTickUnit(200, numberFormat, 2)); units.add(new NumberTickUnit(500, numberFormat, 5)); units.add(new NumberTickUnit(1000, numberFormat, 2)); units.add(new NumberTickUnit(2000, numberFormat, 2)); units.add(new NumberTickUnit(5000, numberFormat, 5)); units.add(new NumberTickUnit(10000, numberFormat, 2)); units.add(new NumberTickUnit(20000, numberFormat, 2)); units.add(new NumberTickUnit(50000, numberFormat, 5)); units.add(new NumberTickUnit(100000, numberFormat, 2)); units.add(new NumberTickUnit(200000, numberFormat, 2)); units.add(new NumberTickUnit(500000, numberFormat, 5)); units.add(new NumberTickUnit(1000000, numberFormat, 2)); units.add(new NumberTickUnit(2000000, numberFormat, 2)); units.add(new NumberTickUnit(5000000, numberFormat, 5)); units.add(new NumberTickUnit(10000000, numberFormat, 2)); units.add(new NumberTickUnit(20000000, numberFormat, 2)); units.add(new NumberTickUnit(50000000, numberFormat, 5)); units.add(new NumberTickUnit(100000000, numberFormat, 2)); units.add(new NumberTickUnit(200000000, numberFormat, 2)); units.add(new NumberTickUnit(500000000, numberFormat, 5)); units.add(new NumberTickUnit(1000000000, numberFormat, 2)); units.add(new NumberTickUnit(2000000000, numberFormat, 2)); units.add(new NumberTickUnit(5000000000.0, numberFormat, 5)); units.add(new NumberTickUnit(10000000000.0, numberFormat, 2)); return units; } /** * Estimates the maximum tick label height. * * @param g2 the graphics device. * * @return The maximum height. */ protected double estimateMaximumTickLabelHeight(Graphics2D g2) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom(); Font tickLabelFont = getTickLabelFont(); FontRenderContext frc = g2.getFontRenderContext(); result += tickLabelFont.getLineMetrics("123", frc).getHeight(); return result; } /** * Estimates the maximum width of the tick labels, assuming the specified * tick unit is used. *

* Rather than computing the string bounds of every tick on the axis, we * just look at two values: the lower bound and the upper bound for the * axis. These two values will usually be representative. * * @param g2 the graphics device. * @param unit the tick unit to use for calculation. * * @return The estimated maximum width of the tick labels. */ protected double estimateMaximumTickLabelWidth(Graphics2D g2, TickUnit unit) { RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight(); if (isVerticalTickLabels()) { // all tick labels have the same width (equal to the height of the // font)... FontRenderContext frc = g2.getFontRenderContext(); LineMetrics lm = getTickLabelFont().getLineMetrics("0", frc); result += lm.getHeight(); } else { // look at lower and upper bounds... FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); Range range = getRange(); double lower = range.getLowerBound(); double upper = range.getUpperBound(); String lowerStr = ""; String upperStr = ""; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { lowerStr = formatter.format(lower); upperStr = formatter.format(upper); } else { lowerStr = unit.valueToString(lower); upperStr = unit.valueToString(upper); } double w1 = fm.stringWidth(lowerStr); double w2 = fm.stringWidth(upperStr); result += Math.max(w1, w2); } return result; } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. */ protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { selectHorizontalAutoTickUnit(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { selectVerticalAutoTickUnit(g2, dataArea, edge); } } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit( guess); double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); } /** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the axis location. */ protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelHeight = estimateMaximumTickLabelHeight(g2); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unitHeight = lengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelHeight / unitHeight) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); double unit2Height = lengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelHeight = estimateMaximumTickLabelHeight(g2); if (tickLabelHeight > unit2Height) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. * */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); if (RectangleEdge.isTopOrBottom(edge)) { result = refreshTicksHorizontal(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { result = refreshTicksVertical(g2, dataArea, edge); } return result; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the data should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } TickUnit tu = getTickUnit(); double size = tu.getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { int minorTickSpaces = getMinorTickCount(); if (minorTickSpaces <= 0) { minorTickSpaces = tu.getMinorTickCount(); } for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { double minorTickValue = lowestTickValue - size * minorTick / minorTickSpaces; if (getRange().contains(minorTickValue)){ result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); result.add(tick); double nextTickValue = lowestTickValue + ((i + 1)* size); for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { double minorTickValue = currentTickValue + (nextTickValue - currentTickValue) * minorTick / minorTickSpaces; if (getRange().contains(minorTickValue)){ result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } } } return result; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); result.clear(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } TickUnit tu = getTickUnit(); double size = tu.getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { int minorTickSpaces = getMinorTickCount(); if (minorTickSpaces <= 0) { minorTickSpaces = tu.getMinorTickCount(); } for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++){ double minorTickValue = lowestTickValue - size * minorTick / minorTickSpaces; if (getRange().contains(minorTickValue)){ result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = -Math.PI / 2.0; } else { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); result.add(tick); double nextTickValue = lowestTickValue + ((i + 1)* size); for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++){ double minorTickValue = currentTickValue + (nextTickValue - currentTickValue) * minorTick / minorTickSpaces; if (getRange().contains(minorTickValue)){ result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, 0.0)); } } } } return result; } /** * Returns a clone of the axis. * * @return A clone * * @throws CloneNotSupportedException if some component of the axis does * not support cloning. */ public Object clone() throws CloneNotSupportedException { NumberAxis clone = (NumberAxis) super.clone(); if (this.numberFormatOverride != null) { clone.numberFormatOverride = (NumberFormat) this.numberFormatOverride.clone(); } return clone; } /** * Tests the axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof NumberAxis)) { return false; } NumberAxis that = (NumberAxis) obj; if (this.autoRangeIncludesZero != that.autoRangeIncludesZero) { return false; } if (this.autoRangeStickyZero != that.autoRangeStickyZero) { return false; } if (!ObjectUtilities.equal(this.tickUnit, that.tickUnit)) { return false; } if (!ObjectUtilities.equal(this.numberFormatOverride, that.numberFormatOverride)) { return false; } if (!this.rangeType.equals(that.rangeType)) { return false; } return super.equals(obj); } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { if (getLabel() != null) { return getLabel().hashCode(); } else { return 0; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/NumberAxis3D.java0000644000175000017500000001542211173030414026510 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * NumberAxis3D.java * ----------------- * (C) Copyright 2001-2009, by Serge V. Grachov and Contributors. * * Original Author: Serge V. Grachov; * Contributor(s): David Gilbert (for Object Refinery Limited); * Jonathan Nash; * Richard Atkinson; * Tin Luu; * * Changes * ------- * 31-Oct-2001 : Version 1 contributed by Serge V. Grachov (DG); * 23-Nov-2001 : Overhauled auto tick unit code for all axes (DG); * 12-Dec-2001 : Minor change due to grid lines bug fix (DG); * 08-Jan-2002 : Added flag allowing the axis to be 'inverted'. That is, run * from positive to negative. Added default values to * constructors (DG); * 16-Jan-2002 : Added an optional crosshair, based on the implementation by * Jonathan Nash (DG); * 25-Feb-2002 : Updated constructors for new autoRangeStickyZero flag (DG); * 19-Apr-2002 : drawVerticalString() is now drawRotatedString() in * RefineryUtilities (DG); * 25-Jun-2002 : Removed redundant import (DG); * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); * 06-Aug-2002 : Modified draw method to not draw axis label if label is empty * String (RA); * 05-Sep-2002 : Updated constructor for changes in the Axis class, and changed * draw method to observe tickMarkPaint (DG); * 22-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 20-Jan-2003 : Removed unnecessary constructors (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 13-May-2003 : Merged HorizontalNumberAxis3D and VerticalNumberAxis3D (DG); * 21-Aug-2003 : Updated draw() method signature (DG); * 07-Nov-2003 : Modified refreshTicks method signature (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-Jan-2006 : Fixed bug 1408904 (axis assumes CategoryPlot) (DG): * 16-Apr-2009 : Changed axis line visibility default (DG); * */ package org.jfree.chart.axis; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.List; import org.jfree.chart.Effect3D; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.ui.RectangleEdge; /** * A standard linear value axis with a 3D effect corresponding to the * offset specified by some renderers. */ public class NumberAxis3D extends NumberAxis implements Serializable { /** For serialization. */ private static final long serialVersionUID = -1790205852569123512L; /** * Default constructor. */ public NumberAxis3D() { this(null); } /** * Constructs a new axis. * * @param label the axis label (null permitted). */ public NumberAxis3D(String label) { super(label); } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param cursor the cursor. * @param plotArea the area for drawing the axes and data. * @param dataArea the area for drawing the data (a subset of the * plotArea). * @param edge the axis location. * @param plotState collects information about the plot (null * permitted). * * @return The updated cursor value. */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { AxisState state = new AxisState(cursor); // even though the axis is not visible, we need ticks for the // gridlines... List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); return state; } // calculate the adjusted data area taking into account the 3D effect... double xOffset = 0.0; double yOffset = 0.0; Plot plot = getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) plot; CategoryItemRenderer r = cp.getRenderer(); if (r instanceof Effect3D) { Effect3D e3D = (Effect3D) r; xOffset = e3D.getXOffset(); yOffset = e3D.getYOffset(); } } double adjustedX = dataArea.getMinX(); double adjustedY = dataArea.getMinY(); double adjustedW = dataArea.getWidth() - xOffset; double adjustedH = dataArea.getHeight() - yOffset; if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { adjustedY += yOffset; } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { adjustedX += xOffset; } Rectangle2D adjustedDataArea = new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH); // draw the tick marks and labels... AxisState info = drawTickMarksAndLabels(g2, cursor, plotArea, adjustedDataArea, edge); // draw the axis label... info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info); return info; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/NumberTick.java0000644000175000017500000000646111173030414026312 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * NumberTick.java * --------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Nov-2003 : Version 1 (DG); * 02-Aug-2007 : Added new constructor with tick type (DG); * */ package org.jfree.chart.axis; import org.jfree.ui.TextAnchor; /** * A numerical tick. */ public class NumberTick extends ValueTick { /** The number. */ private Number number; /** * Creates a new tick. * * @param number the number (null not permitted). * @param label the label. * @param textAnchor the part of the label that is aligned with the anchor * point. * @param rotationAnchor defines the rotation point relative to the text. * @param angle the rotation angle (in radians). */ public NumberTick(Number number, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { super(number.doubleValue(), label, textAnchor, rotationAnchor, angle); this.number = number; } /** * Creates a new tick. * * @param tickType the tick type. * @param value the value. * @param label the label. * @param textAnchor the part of the label that is aligned with the anchor * point. * @param rotationAnchor defines the rotation point relative to the text. * @param angle the rotation angle (in radians). * * @since 1.0.7 */ public NumberTick(TickType tickType, double value, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { super(tickType, value, label, textAnchor, rotationAnchor, angle); this.number = new Double(value); } /** * Returns the number. * * @return The number. */ public Number getNumber() { return this.number; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/NumberTickUnit.java0000644000175000017500000001206111173030414027143 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * NumberTickUnit.java * ------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Dec-2001 : Added standard header (DG); * 01-May-2002 : Updated for changed to TickUnit class (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 09-Jan-2002 : Added a new constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 05-Jul-2005 : Added equals() implementation (DG); * 05-Sep-2005 : Implemented hashCode(), thanks to Thomas Morgner (DG); * 02-Aug-2007 : Added new constructor with minorTickCount (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import java.text.NumberFormat; /** * A numerical tick unit. */ public class NumberTickUnit extends TickUnit implements Serializable { /** For serialization. */ private static final long serialVersionUID = 3849459506627654442L; /** A formatter for the tick unit. */ private NumberFormat formatter; /** * Creates a new number tick unit. * * @param size the size of the tick unit. */ public NumberTickUnit(double size) { this(size, NumberFormat.getNumberInstance()); } /** * Creates a new number tick unit. * * @param size the size of the tick unit. * @param formatter a number formatter for the tick unit (null * not permitted). */ public NumberTickUnit(double size, NumberFormat formatter) { super(size); if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.formatter = formatter; } /** * Creates a new number tick unit. * * @param size the size of the tick unit. * @param formatter a number formatter for the tick unit (null * not permitted). * @param minorTickCount the number of minor ticks. * * @since 1.0.7 */ public NumberTickUnit(double size, NumberFormat formatter, int minorTickCount) { super(size, minorTickCount); if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.formatter = formatter; } /** * Converts a value to a string. * * @param value the value. * * @return The formatted string. */ public String valueToString(double value) { return this.formatter.format(value); } /** * Tests this formatter for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof NumberTickUnit)) { return false; } if (!super.equals(obj)) { return false; } NumberTickUnit that = (NumberTickUnit) obj; if (!this.formatter.equals(that.formatter)) { return false; } return true; } /** * Returns a string representing this unit. * * @return A string. */ public String toString() { return "[size=" + this.valueToString(this.getSize()) + "]"; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = 29 * result + (this.formatter != null ? this.formatter.hashCode() : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/PeriodAxis.java0000644000175000017500000013112611173030414026313 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * PeriodAxis.java * --------------- * (C) Copyright 2004-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Jun-2004 : Version 1 (DG); * 16-Sep-2004 : Fixed bug in equals() method, added clone() method and * PublicCloneable interface (DG); * 25-Nov-2004 : Updates to support major and minor tick marks (DG); * 25-Feb-2005 : Fixed some tick mark bugs (DG); * 15-Apr-2005 : Fixed some more tick mark bugs (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 16-Jun-2005 : Fixed zooming (DG); * 15-Sep-2005 : Changed configure() method to check autoRange flag, * and added ticks to state (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Oct-2006 : Updated for deprecations in RegularTimePeriod and * subclasses (DG); * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); * 31-Jul-2007 : Fix for inverted axis labelling (see bug 1763413) (DG); * 08-Apr-2008 : Notify listeners in setRange(Range, boolean, boolean) - fixes * bug 1932146 (DG); * 16-Jan-2009 : Fixed bug 2490803, a problem in the setRange() method (DG); * 02-Mar-2009 : Added locale - see patch 2569670 by Benjamin Bignell (DG); * 02-Mar-2009 : Fixed draw() method to check tickMarksVisible and * tickLabelsVisible (DG); * */ package org.jfree.chart.axis; import java.awt.BasicStroke; import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Constructor; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.TimeZone; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.data.Range; import org.jfree.data.time.Day; import org.jfree.data.time.Month; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.Year; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.PublicCloneable; /** * An axis that displays a date scale based on a * {@link org.jfree.data.time.RegularTimePeriod}. This axis works when * displayed across the bottom or top of a plot, but is broken for display at * the left or right of charts. */ public class PeriodAxis extends ValueAxis implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8353295532075872069L; /** The first time period in the overall range. */ private RegularTimePeriod first; /** The last time period in the overall range. */ private RegularTimePeriod last; /** * The time zone used to convert 'first' and 'last' to absolute * milliseconds. */ private TimeZone timeZone; /** * The locale (never null). * * @since 1.0.13 */ private Locale locale; /** * A calendar used for date manipulations in the current time zone and * locale. */ private Calendar calendar; /** * The {@link RegularTimePeriod} subclass used to automatically determine * the axis range. */ private Class autoRangeTimePeriodClass; /** * Indicates the {@link RegularTimePeriod} subclass that is used to * determine the spacing of the major tick marks. */ private Class majorTickTimePeriodClass; /** * A flag that indicates whether or not tick marks are visible for the * axis. */ private boolean minorTickMarksVisible; /** * Indicates the {@link RegularTimePeriod} subclass that is used to * determine the spacing of the minor tick marks. */ private Class minorTickTimePeriodClass; /** The length of the tick mark inside the data area (zero permitted). */ private float minorTickMarkInsideLength = 0.0f; /** The length of the tick mark outside the data area (zero permitted). */ private float minorTickMarkOutsideLength = 2.0f; /** The stroke used to draw tick marks. */ private transient Stroke minorTickMarkStroke = new BasicStroke(0.5f); /** The paint used to draw tick marks. */ private transient Paint minorTickMarkPaint = Color.black; /** Info for each labelling band. */ private PeriodAxisLabelInfo[] labelInfo; /** * Creates a new axis. * * @param label the axis label. */ public PeriodAxis(String label) { this(label, new Day(), new Day()); } /** * Creates a new axis. * * @param label the axis label (null permitted). * @param first the first time period in the axis range * (null not permitted). * @param last the last time period in the axis range * (null not permitted). */ public PeriodAxis(String label, RegularTimePeriod first, RegularTimePeriod last) { this(label, first, last, TimeZone.getDefault(), Locale.getDefault()); } /** * Creates a new axis. * * @param label the axis label (null permitted). * @param first the first time period in the axis range * (null not permitted). * @param last the last time period in the axis range * (null not permitted). * @param timeZone the time zone (null not permitted). * * @deprecated As of version 1.0.13, you should use the constructor that * specifies a Locale also. */ public PeriodAxis(String label, RegularTimePeriod first, RegularTimePeriod last, TimeZone timeZone) { this(label, first, last, timeZone, Locale.getDefault()); } /** * Creates a new axis. * * @param label the axis label (null permitted). * @param first the first time period in the axis range * (null not permitted). * @param last the last time period in the axis range * (null not permitted). * @param timeZone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.13 */ public PeriodAxis(String label, RegularTimePeriod first, RegularTimePeriod last, TimeZone timeZone, Locale locale) { super(label, null); if (timeZone == null) { throw new IllegalArgumentException("Null 'timeZone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } this.first = first; this.last = last; this.timeZone = timeZone; this.locale = locale; this.calendar = Calendar.getInstance(timeZone, locale); this.first.peg(this.calendar); this.last.peg(this.calendar); this.autoRangeTimePeriodClass = first.getClass(); this.majorTickTimePeriodClass = first.getClass(); this.minorTickMarksVisible = false; this.minorTickTimePeriodClass = RegularTimePeriod.downsize( this.majorTickTimePeriodClass); setAutoRange(true); this.labelInfo = new PeriodAxisLabelInfo[2]; this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class, new SimpleDateFormat("MMM", locale)); this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class, new SimpleDateFormat("yyyy", locale)); } /** * Returns the first time period in the axis range. * * @return The first time period (never null). */ public RegularTimePeriod getFirst() { return this.first; } /** * Sets the first time period in the axis range and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param first the time period (null not permitted). */ public void setFirst(RegularTimePeriod first) { if (first == null) { throw new IllegalArgumentException("Null 'first' argument."); } this.first = first; this.first.peg(this.calendar); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the last time period in the axis range. * * @return The last time period (never null). */ public RegularTimePeriod getLast() { return this.last; } /** * Sets the last time period in the axis range and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param last the time period (null not permitted). */ public void setLast(RegularTimePeriod last) { if (last == null) { throw new IllegalArgumentException("Null 'last' argument."); } this.last = last; this.last.peg(this.calendar); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the time zone used to convert the periods defining the axis * range into absolute milliseconds. * * @return The time zone (never null). */ public TimeZone getTimeZone() { return this.timeZone; } /** * Sets the time zone that is used to convert the time periods into * absolute milliseconds. * * @param zone the time zone (null not permitted). */ public void setTimeZone(TimeZone zone) { if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } this.timeZone = zone; this.calendar = Calendar.getInstance(zone, this.locale); this.first.peg(this.calendar); this.last.peg(this.calendar); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the locale for this axis. * * @return The locale (never (null). * * @since 1.0.13 */ public Locale getLocale() { return this.locale; } /** * Returns the class used to create the first and last time periods for * the axis range when the auto-range flag is set to true. * * @return The class (never null). */ public Class getAutoRangeTimePeriodClass() { return this.autoRangeTimePeriodClass; } /** * Sets the class used to create the first and last time periods for the * axis range when the auto-range flag is set to true and * sends an {@link AxisChangeEvent} to all registered listeners. * * @param c the class (null not permitted). */ public void setAutoRangeTimePeriodClass(Class c) { if (c == null) { throw new IllegalArgumentException("Null 'c' argument."); } this.autoRangeTimePeriodClass = c; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the class that controls the spacing of the major tick marks. * * @return The class (never null). */ public Class getMajorTickTimePeriodClass() { return this.majorTickTimePeriodClass; } /** * Sets the class that controls the spacing of the major tick marks, and * sends an {@link AxisChangeEvent} to all registered listeners. * * @param c the class (a subclass of {@link RegularTimePeriod} is * expected). */ public void setMajorTickTimePeriodClass(Class c) { if (c == null) { throw new IllegalArgumentException("Null 'c' argument."); } this.majorTickTimePeriodClass = c; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the flag that controls whether or not minor tick marks * are displayed for the axis. * * @return A boolean. */ public boolean isMinorTickMarksVisible() { return this.minorTickMarksVisible; } /** * Sets the flag that controls whether or not minor tick marks * are displayed for the axis, and sends a {@link AxisChangeEvent} * to all registered listeners. * * @param visible the flag. */ public void setMinorTickMarksVisible(boolean visible) { this.minorTickMarksVisible = visible; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the class that controls the spacing of the minor tick marks. * * @return The class (never null). */ public Class getMinorTickTimePeriodClass() { return this.minorTickTimePeriodClass; } /** * Sets the class that controls the spacing of the minor tick marks, and * sends an {@link AxisChangeEvent} to all registered listeners. * * @param c the class (a subclass of {@link RegularTimePeriod} is * expected). */ public void setMinorTickTimePeriodClass(Class c) { if (c == null) { throw new IllegalArgumentException("Null 'c' argument."); } this.minorTickTimePeriodClass = c; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the stroke used to display minor tick marks, if they are * visible. * * @return A stroke (never null). */ public Stroke getMinorTickMarkStroke() { return this.minorTickMarkStroke; } /** * Sets the stroke used to display minor tick marks, if they are * visible, and sends a {@link AxisChangeEvent} to all registered * listeners. * * @param stroke the stroke (null not permitted). */ public void setMinorTickMarkStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.minorTickMarkStroke = stroke; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the paint used to display minor tick marks, if they are * visible. * * @return A paint (never null). */ public Paint getMinorTickMarkPaint() { return this.minorTickMarkPaint; } /** * Sets the paint used to display minor tick marks, if they are * visible, and sends a {@link AxisChangeEvent} to all registered * listeners. * * @param paint the paint (null not permitted). */ public void setMinorTickMarkPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.minorTickMarkPaint = paint; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the inside length for the minor tick marks. * * @return The length. */ public float getMinorTickMarkInsideLength() { return this.minorTickMarkInsideLength; } /** * Sets the inside length of the minor tick marks and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param length the length. */ public void setMinorTickMarkInsideLength(float length) { this.minorTickMarkInsideLength = length; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the outside length for the minor tick marks. * * @return The length. */ public float getMinorTickMarkOutsideLength() { return this.minorTickMarkOutsideLength; } /** * Sets the outside length of the minor tick marks and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param length the length. */ public void setMinorTickMarkOutsideLength(float length) { this.minorTickMarkOutsideLength = length; notifyListeners(new AxisChangeEvent(this)); } /** * Returns an array of label info records. * * @return An array. */ public PeriodAxisLabelInfo[] getLabelInfo() { return this.labelInfo; } /** * Sets the array of label info records and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param info the info. */ public void setLabelInfo(PeriodAxisLabelInfo[] info) { this.labelInfo = info; notifyListeners(new AxisChangeEvent(this)); } /** * Sets the range for the axis, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. As a side-effect, * the auto-range flag is set to false (optional). * * @param range the range (null not permitted). * @param turnOffAutoRange a flag that controls whether or not the auto * range is turned off. * @param notify a flag that controls whether or not listeners are * notified. */ public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { long upper = Math.round(range.getUpperBound()); long lower = Math.round(range.getLowerBound()); this.first = createInstance(this.autoRangeTimePeriodClass, new Date(lower), this.timeZone, this.locale); this.last = createInstance(this.autoRangeTimePeriodClass, new Date(upper), this.timeZone, this.locale); super.setRange(new Range(this.first.getFirstMillisecond(), this.last.getLastMillisecond() + 1.0), turnOffAutoRange, notify); } /** * Configures the axis to work with the current plot. Override this method * to perform any special processing (such as auto-rescaling). */ public void configure() { if (this.isAutoRange()) { autoAdjustRange(); } } /** * Estimates the space (height or width) required to draw the axis. * * @param g2 the graphics device. * @param plot the plot that the axis belongs to. * @param plotArea the area within which the plot (including axes) should * be drawn. * @param edge the axis location. * @param space space already reserved. * * @return The space required to draw the axis (including pre-reserved * space). */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { // create a new space object if one wasn't supplied... if (space == null) { space = new AxisSpace(); } // if the axis is not visible, no additional space is required... if (!isVisible()) { return space; } // if the axis has a fixed dimension, return it... double dimension = getFixedDimension(); if (dimension > 0.0) { space.ensureAtLeast(dimension, edge); } // get the axis label size and update the space object... Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); double labelHeight = 0.0; double labelWidth = 0.0; double tickLabelBandsDimension = 0.0; for (int i = 0; i < this.labelInfo.length; i++) { PeriodAxisLabelInfo info = this.labelInfo[i]; FontMetrics fm = g2.getFontMetrics(info.getLabelFont()); tickLabelBandsDimension += info.getPadding().extendHeight(fm.getHeight()); } if (RectangleEdge.isTopOrBottom(edge)) { labelHeight = labelEnclosure.getHeight(); space.add(labelHeight + tickLabelBandsDimension, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { labelWidth = labelEnclosure.getWidth(); space.add(labelWidth + tickLabelBandsDimension, edge); } // add space for the outer tick labels, if any... double tickMarkSpace = 0.0; if (isTickMarksVisible()) { tickMarkSpace = getTickMarkOutsideLength(); } if (this.minorTickMarksVisible) { tickMarkSpace = Math.max(tickMarkSpace, this.minorTickMarkOutsideLength); } space.add(tickMarkSpace, edge); return space; } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location (determines where to draw the axis). * @param plotArea the area within which the axes and plot should be drawn. * @param dataArea the area within which the data should be drawn. * @param edge the axis location (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState axisState = new AxisState(cursor); if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } if (isTickMarksVisible()) { drawTickMarks(g2, axisState, dataArea, edge); } if (isTickLabelsVisible()) { for (int band = 0; band < this.labelInfo.length; band++) { axisState = drawTickLabels(band, g2, axisState, dataArea, edge); } } // draw the axis label (note that 'state' is passed in *and* // returned)... axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, axisState); return axisState; } /** * Draws the tick marks for the axis. * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge. */ protected void drawTickMarks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { drawTickMarksHorizontal(g2, state, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { drawTickMarksVertical(g2, state, dataArea, edge); } } /** * Draws the major and minor tick marks for an axis that lies at the top or * bottom of the plot. * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge. */ protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new ArrayList(); double x0 = dataArea.getX(); double y0 = state.getCursor(); double insideLength = getTickMarkInsideLength(); double outsideLength = getTickMarkOutsideLength(); RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, this.first.getStart(), getTimeZone(), this.locale); long t0 = t.getFirstMillisecond(); Line2D inside = null; Line2D outside = null; long firstOnAxis = getFirst().getFirstMillisecond(); long lastOnAxis = getLast().getLastMillisecond() + 1; while (t0 <= lastOnAxis) { ticks.add(new NumberTick(new Double(t0), "", TextAnchor.CENTER, TextAnchor.CENTER, 0.0)); x0 = valueToJava2D(t0, dataArea, edge); if (edge == RectangleEdge.TOP) { inside = new Line2D.Double(x0, y0, x0, y0 + insideLength); outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength); } else if (edge == RectangleEdge.BOTTOM) { inside = new Line2D.Double(x0, y0, x0, y0 - insideLength); outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength); } if (t0 >= firstOnAxis) { g2.setPaint(getTickMarkPaint()); g2.setStroke(getTickMarkStroke()); g2.draw(inside); g2.draw(outside); } // draw minor tick marks if (this.minorTickMarksVisible) { RegularTimePeriod tminor = createInstance( this.minorTickTimePeriodClass, new Date(t0), getTimeZone(), this.locale); long tt0 = tminor.getFirstMillisecond(); while (tt0 < t.getLastMillisecond() && tt0 < lastOnAxis) { double xx0 = valueToJava2D(tt0, dataArea, edge); if (edge == RectangleEdge.TOP) { inside = new Line2D.Double(xx0, y0, xx0, y0 + this.minorTickMarkInsideLength); outside = new Line2D.Double(xx0, y0, xx0, y0 - this.minorTickMarkOutsideLength); } else if (edge == RectangleEdge.BOTTOM) { inside = new Line2D.Double(xx0, y0, xx0, y0 - this.minorTickMarkInsideLength); outside = new Line2D.Double(xx0, y0, xx0, y0 + this.minorTickMarkOutsideLength); } if (tt0 >= firstOnAxis) { g2.setPaint(this.minorTickMarkPaint); g2.setStroke(this.minorTickMarkStroke); g2.draw(inside); g2.draw(outside); } tminor = tminor.next(); tminor.peg(this.calendar); tt0 = tminor.getFirstMillisecond(); } } t = t.next(); t.peg(this.calendar); t0 = t.getFirstMillisecond(); } if (edge == RectangleEdge.TOP) { state.cursorUp(Math.max(outsideLength, this.minorTickMarkOutsideLength)); } else if (edge == RectangleEdge.BOTTOM) { state.cursorDown(Math.max(outsideLength, this.minorTickMarkOutsideLength)); } state.setTicks(ticks); } /** * Draws the tick marks for a vertical axis. * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge. */ protected void drawTickMarksVertical(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { // FIXME: implement this... } /** * Draws the tick labels for one "band" of time periods. * * @param band the band index (zero-based). * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge where the axis is located. * * @return The updated axis state. */ protected AxisState drawTickLabels(int band, Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { // work out the initial gap double delta1 = 0.0; FontMetrics fm = g2.getFontMetrics(this.labelInfo[band].getLabelFont()); if (edge == RectangleEdge.BOTTOM) { delta1 = this.labelInfo[band].getPadding().calculateTopOutset( fm.getHeight()); } else if (edge == RectangleEdge.TOP) { delta1 = this.labelInfo[band].getPadding().calculateBottomOutset( fm.getHeight()); } state.moveCursor(delta1, edge); long axisMin = this.first.getFirstMillisecond(); long axisMax = this.last.getLastMillisecond(); g2.setFont(this.labelInfo[band].getLabelFont()); g2.setPaint(this.labelInfo[band].getLabelPaint()); // work out the number of periods to skip for labelling RegularTimePeriod p1 = this.labelInfo[band].createInstance( new Date(axisMin), this.timeZone, this.locale); RegularTimePeriod p2 = this.labelInfo[band].createInstance( new Date(axisMax), this.timeZone, this.locale); String label1 = this.labelInfo[band].getDateFormat().format( new Date(p1.getMiddleMillisecond())); String label2 = this.labelInfo[band].getDateFormat().format( new Date(p2.getMiddleMillisecond())); Rectangle2D b1 = TextUtilities.getTextBounds(label1, g2, g2.getFontMetrics()); Rectangle2D b2 = TextUtilities.getTextBounds(label2, g2, g2.getFontMetrics()); double w = Math.max(b1.getWidth(), b2.getWidth()); long ww = Math.round(java2DToValue(dataArea.getX() + w + 5.0, dataArea, edge)); if (isInverted()) { ww = axisMax - ww; } else { ww = ww - axisMin; } long length = p1.getLastMillisecond() - p1.getFirstMillisecond(); int periods = (int) (ww / length) + 1; RegularTimePeriod p = this.labelInfo[band].createInstance( new Date(axisMin), this.timeZone, this.locale); Rectangle2D b = null; long lastXX = 0L; float y = (float) (state.getCursor()); TextAnchor anchor = TextAnchor.TOP_CENTER; float yDelta = (float) b1.getHeight(); if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; yDelta = -yDelta; } while (p.getFirstMillisecond() <= axisMax) { float x = (float) valueToJava2D(p.getMiddleMillisecond(), dataArea, edge); DateFormat df = this.labelInfo[band].getDateFormat(); String label = df.format(new Date(p.getMiddleMillisecond())); long first = p.getFirstMillisecond(); long last = p.getLastMillisecond(); if (last > axisMax) { // this is the last period, but it is only partially visible // so check that the label will fit before displaying it... Rectangle2D bb = TextUtilities.getTextBounds(label, g2, g2.getFontMetrics()); if ((x + bb.getWidth() / 2) > dataArea.getMaxX()) { float xstart = (float) valueToJava2D(Math.max(first, axisMin), dataArea, edge); if (bb.getWidth() < (dataArea.getMaxX() - xstart)) { x = ((float) dataArea.getMaxX() + xstart) / 2.0f; } else { label = null; } } } if (first < axisMin) { // this is the first period, but it is only partially visible // so check that the label will fit before displaying it... Rectangle2D bb = TextUtilities.getTextBounds(label, g2, g2.getFontMetrics()); if ((x - bb.getWidth() / 2) < dataArea.getX()) { float xlast = (float) valueToJava2D(Math.min(last, axisMax), dataArea, edge); if (bb.getWidth() < (xlast - dataArea.getX())) { x = (xlast + (float) dataArea.getX()) / 2.0f; } else { label = null; } } } if (label != null) { g2.setPaint(this.labelInfo[band].getLabelPaint()); b = TextUtilities.drawAlignedString(label, g2, x, y, anchor); } if (lastXX > 0L) { if (this.labelInfo[band].getDrawDividers()) { long nextXX = p.getFirstMillisecond(); long mid = (lastXX + nextXX) / 2; float mid2d = (float) valueToJava2D(mid, dataArea, edge); g2.setStroke(this.labelInfo[band].getDividerStroke()); g2.setPaint(this.labelInfo[band].getDividerPaint()); g2.draw(new Line2D.Float(mid2d, y, mid2d, y + yDelta)); } } lastXX = last; for (int i = 0; i < periods; i++) { p = p.next(); } p.peg(this.calendar); } double used = 0.0; if (b != null) { used = b.getHeight(); // work out the trailing gap if (edge == RectangleEdge.BOTTOM) { used += this.labelInfo[band].getPadding().calculateBottomOutset( fm.getHeight()); } else if (edge == RectangleEdge.TOP) { used += this.labelInfo[band].getPadding().calculateTopOutset( fm.getHeight()); } } state.moveCursor(used, edge); return state; } /** * Calculates the positions of the ticks for the axis, storing the results * in the tick list (ready for drawing). * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the area inside the axes. * @param edge the edge on which the axis is located. * * @return The list of ticks. */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { return Collections.EMPTY_LIST; } /** * Converts a data value to a coordinate in Java2D space, assuming that the * axis runs along one edge of the specified dataArea. *

* Note that it is possible for the coordinate to fall outside the area. * * @param value the data value. * @param area the area for plotting the data. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { double result = Double.NaN; double axisMin = this.first.getFirstMillisecond(); double axisMax = this.last.getLastMillisecond(); if (RectangleEdge.isTopOrBottom(edge)) { double minX = area.getX(); double maxX = area.getMaxX(); if (isInverted()) { result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX); } else { result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX); } } else if (RectangleEdge.isLeftOrRight(edge)) { double minY = area.getMinY(); double maxY = area.getMaxY(); if (isInverted()) { result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } else { result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } } return result; } /** * Converts a coordinate in Java2D space to the corresponding data value, * assuming that the axis runs along one edge of the specified dataArea. * * @param java2DValue the coordinate in Java2D space. * @param area the area in which the data is plotted. * @param edge the edge along which the axis lies. * * @return The data value. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { double result = Double.NaN; double min = 0.0; double max = 0.0; double axisMin = this.first.getFirstMillisecond(); double axisMax = this.last.getLastMillisecond(); if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } if (isInverted()) { result = axisMax - ((java2DValue - min) / (max - min) * (axisMax - axisMin)); } else { result = axisMin + ((java2DValue - min) / (max - min) * (axisMax - axisMin)); } return result; } /** * Rescales the axis to ensure that all data is visible. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } long upper = Math.round(r.getUpperBound()); long lower = Math.round(r.getLowerBound()); this.first = createInstance(this.autoRangeTimePeriodClass, new Date(lower), this.timeZone, this.locale); this.last = createInstance(this.autoRangeTimePeriodClass, new Date(upper), this.timeZone, this.locale); setRange(r, false, false); } } /** * Tests the axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PeriodAxis)) { return false; } PeriodAxis that = (PeriodAxis) obj; if (!this.first.equals(that.first)) { return false; } if (!this.last.equals(that.last)) { return false; } if (!this.timeZone.equals(that.timeZone)) { return false; } if (!this.locale.equals(that.locale)) { return false; } if (!this.autoRangeTimePeriodClass.equals( that.autoRangeTimePeriodClass)) { return false; } if (!(isMinorTickMarksVisible() == that.isMinorTickMarksVisible())) { return false; } if (!this.majorTickTimePeriodClass.equals( that.majorTickTimePeriodClass)) { return false; } if (!this.minorTickTimePeriodClass.equals( that.minorTickTimePeriodClass)) { return false; } if (!this.minorTickMarkPaint.equals(that.minorTickMarkPaint)) { return false; } if (!this.minorTickMarkStroke.equals(that.minorTickMarkStroke)) { return false; } if (!Arrays.equals(this.labelInfo, that.labelInfo)) { return false; } return super.equals(obj); } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { if (getLabel() != null) { return getLabel().hashCode(); } else { return 0; } } /** * Returns a clone of the axis. * * @return A clone. * * @throws CloneNotSupportedException this class is cloneable, but * subclasses may not be. */ public Object clone() throws CloneNotSupportedException { PeriodAxis clone = (PeriodAxis) super.clone(); clone.timeZone = (TimeZone) this.timeZone.clone(); clone.labelInfo = new PeriodAxisLabelInfo[this.labelInfo.length]; for (int i = 0; i < this.labelInfo.length; i++) { clone.labelInfo[i] = this.labelInfo[i]; // copy across references // to immutable objs } return clone; } /** * A utility method used to create a particular subclass of the * {@link RegularTimePeriod} class that includes the specified millisecond, * assuming the specified time zone. * * @param periodClass the class. * @param millisecond the time. * @param zone the time zone. * @param locale the locale. * * @return The time period. */ private RegularTimePeriod createInstance(Class periodClass, Date millisecond, TimeZone zone, Locale locale) { RegularTimePeriod result = null; try { Constructor c = periodClass.getDeclaredConstructor(new Class[] { Date.class, TimeZone.class, Locale.class}); result = (RegularTimePeriod) c.newInstance(new Object[] { millisecond, zone, locale}); } catch (Exception e) { try { Constructor c = periodClass.getDeclaredConstructor(new Class[] { Date.class}); result = (RegularTimePeriod) c.newInstance(new Object[] { millisecond}); } catch (Exception e2) { // do nothing } } return result; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.minorTickMarkStroke, stream); SerialUtilities.writePaint(this.minorTickMarkPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.minorTickMarkStroke = SerialUtilities.readStroke(stream); this.minorTickMarkPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/PeriodAxisLabelInfo.java0000644000175000017500000003175711173030414030100 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * PeriodAxisLabelInfo.java * ------------------------ * (C) Copyright 2004-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Jun-2004 : Version 1 (DG); * 23-Feb-2005 : Replaced Spacer with RectangleInsets (DG); * 01-Mar-2005 : Modified constructors to accept DateFormat (DG); * 20-May-2005 : Added default constants and null argument checks in the * constructor (DG); * 02-Mar-2009 : Updated createInstance to use locale (DG); * */ package org.jfree.chart.axis; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Stroke; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Constructor; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import org.jfree.data.time.RegularTimePeriod; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; /** * A record that contains information for one "band" of date labels in * a {@link PeriodAxis}. */ public class PeriodAxisLabelInfo implements Cloneable, Serializable { // TODO: this class is mostly immutable, so implementing Cloneable isn't // really necessary. But there is still a hole in that you can get the // dateFormat and modify it. We could return a copy, but that would slow // things down. Needs resolving. /** For serialization. */ private static final long serialVersionUID = 5710451740920277357L; /** The default insets. */ public static final RectangleInsets DEFAULT_INSETS = new RectangleInsets(2, 2, 2, 2); /** The default font. */ public static final Font DEFAULT_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default label paint. */ public static final Paint DEFAULT_LABEL_PAINT = Color.black; /** The default divider stroke. */ public static final Stroke DEFAULT_DIVIDER_STROKE = new BasicStroke(0.5f); /** The default divider paint. */ public static final Paint DEFAULT_DIVIDER_PAINT = Color.gray; /** The subclass of {@link RegularTimePeriod} to use for this band. */ private Class periodClass; /** Controls the gaps around the band. */ private RectangleInsets padding; /** The date formatter. */ private DateFormat dateFormat; /** The label font. */ private Font labelFont; /** The label paint. */ private transient Paint labelPaint; /** A flag that controls whether or not dividers are visible. */ private boolean drawDividers; /** The stroke used to draw the dividers. */ private transient Stroke dividerStroke; /** The paint used to draw the dividers. */ private transient Paint dividerPaint; /** * Creates a new instance. * * @param periodClass the subclass of {@link RegularTimePeriod} to use * (null not permitted). * @param dateFormat the date format (null not permitted). */ public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat) { this( periodClass, dateFormat, DEFAULT_INSETS, DEFAULT_FONT, DEFAULT_LABEL_PAINT, true, DEFAULT_DIVIDER_STROKE, DEFAULT_DIVIDER_PAINT ); } /** * Creates a new instance. * * @param periodClass the subclass of {@link RegularTimePeriod} to use * (null not permitted). * @param dateFormat the date format (null not permitted). * @param padding controls the space around the band (null * not permitted). * @param labelFont the label font (null not permitted). * @param labelPaint the label paint (null not permitted). * @param drawDividers a flag that controls whether dividers are drawn. * @param dividerStroke the stroke used to draw the dividers * (null not permitted). * @param dividerPaint the paint used to draw the dividers * (null not permitted). */ public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat, RectangleInsets padding, Font labelFont, Paint labelPaint, boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) { if (periodClass == null) { throw new IllegalArgumentException("Null 'periodClass' argument."); } if (dateFormat == null) { throw new IllegalArgumentException("Null 'dateFormat' argument."); } if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } if (labelFont == null) { throw new IllegalArgumentException("Null 'labelFont' argument."); } if (labelPaint == null) { throw new IllegalArgumentException("Null 'labelPaint' argument."); } if (dividerStroke == null) { throw new IllegalArgumentException( "Null 'dividerStroke' argument."); } if (dividerPaint == null) { throw new IllegalArgumentException("Null 'dividerPaint' argument."); } this.periodClass = periodClass; this.dateFormat = dateFormat; this.padding = padding; this.labelFont = labelFont; this.labelPaint = labelPaint; this.drawDividers = drawDividers; this.dividerStroke = dividerStroke; this.dividerPaint = dividerPaint; } /** * Returns the subclass of {@link RegularTimePeriod} that should be used * to generate the date labels. * * @return The class. */ public Class getPeriodClass() { return this.periodClass; } /** * Returns the date formatter. * * @return The date formatter (never null). */ public DateFormat getDateFormat() { return this.dateFormat; } /** * Returns the padding for the band. * * @return The padding. */ public RectangleInsets getPadding() { return this.padding; } /** * Returns the label font. * * @return The label font (never null). */ public Font getLabelFont() { return this.labelFont; } /** * Returns the label paint. * * @return The label paint. */ public Paint getLabelPaint() { return this.labelPaint; } /** * Returns a flag that controls whether or not dividers are drawn. * * @return A flag. */ public boolean getDrawDividers() { return this.drawDividers; } /** * Returns the stroke used to draw the dividers. * * @return The stroke. */ public Stroke getDividerStroke() { return this.dividerStroke; } /** * Returns the paint used to draw the dividers. * * @return The paint. */ public Paint getDividerPaint() { return this.dividerPaint; } /** * Creates a time period that includes the specified millisecond, assuming * the given time zone. * * @param millisecond the time. * @param zone the time zone. * * @return The time period. * * @deprecated As of 1.0.13, use the method that specifies the locale also. */ public RegularTimePeriod createInstance(Date millisecond, TimeZone zone) { return createInstance(millisecond, zone, Locale.getDefault()); } /** * Creates a time period that includes the specified millisecond, assuming * the given time zone. * * @param millisecond the time. * @param zone the time zone. * @param locale the locale. * * @return The time period. * * @since 1.0.13. */ public RegularTimePeriod createInstance(Date millisecond, TimeZone zone, Locale locale) { RegularTimePeriod result = null; try { Constructor c = this.periodClass.getDeclaredConstructor( new Class[] {Date.class, TimeZone.class, Locale.class}); result = (RegularTimePeriod) c.newInstance(new Object[] { millisecond, zone, locale}); } catch (Exception e) { // do nothing } return result; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof PeriodAxisLabelInfo) { PeriodAxisLabelInfo info = (PeriodAxisLabelInfo) obj; if (!info.periodClass.equals(this.periodClass)) { return false; } if (!info.dateFormat.equals(this.dateFormat)) { return false; } if (!info.padding.equals(this.padding)) { return false; } if (!info.labelFont.equals(this.labelFont)) { return false; } if (!info.labelPaint.equals(this.labelPaint)) { return false; } if (info.drawDividers != this.drawDividers) { return false; } if (!info.dividerStroke.equals(this.dividerStroke)) { return false; } if (!info.dividerPaint.equals(this.dividerPaint)) { return false; } return true; } return false; } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 41; result = 37 * this.periodClass.hashCode(); result = 37 * this.dateFormat.hashCode(); return result; } /** * Returns a clone of the object. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { PeriodAxisLabelInfo clone = (PeriodAxisLabelInfo) super.clone(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.labelPaint, stream); SerialUtilities.writeStroke(this.dividerStroke, stream); SerialUtilities.writePaint(this.dividerPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.labelPaint = SerialUtilities.readPaint(stream); this.dividerStroke = SerialUtilities.readStroke(stream); this.dividerPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/QuarterDateFormat.java0000644000175000017500000001536411173030414027643 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * QuarterDateFormat.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 01-Mar-2005 : Version 1 (DG); * 10-May-2005 : Added equals() method, and implemented Cloneable and * Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 08-Jun-2007 : Added Greek symbols, and support for reversing the date - see * patch 1577221 (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import java.text.DateFormat; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; /** * A formatter that formats dates to show the year and quarter (for example, * '2004 IV' for the last quarter of 2004. */ public class QuarterDateFormat extends DateFormat implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6738465248529797176L; /** Symbols for regular quarters. */ public static final String[] REGULAR_QUARTERS = new String[] {"1", "2", "3", "4"}; /** Symbols for roman numbered quarters. */ public static final String[] ROMAN_QUARTERS = new String[] {"I", "II", "III", "IV"}; /** * Symbols for greek numbered quarters. * * @since 1.0.6 */ public static final String[] GREEK_QUARTERS = new String[] {"\u0391", "\u0392", "\u0393", "\u0394"}; /** The strings. */ private String[] quarters = REGULAR_QUARTERS; /** A flag that controls whether the quarter or the year goes first. */ private boolean quarterFirst; /** * Creates a new instance for the default time zone. */ public QuarterDateFormat() { this(TimeZone.getDefault()); } /** * Creates a new instance for the specified time zone. * * @param zone the time zone (null not permitted). */ public QuarterDateFormat(TimeZone zone) { this(zone, REGULAR_QUARTERS); } /** * Creates a new instance for the specified time zone. * * @param zone the time zone (null not permitted). * @param quarterSymbols the quarter symbols. */ public QuarterDateFormat(TimeZone zone, String[] quarterSymbols) { this(zone, quarterSymbols, false); } /** * Creates a new instance for the specified time zone. * * @param zone the time zone (null not permitted). * @param quarterSymbols the quarter symbols. * @param quarterFirst a flag that controls whether the quarter or the * year is displayed first. * * @since 1.0.6 */ public QuarterDateFormat(TimeZone zone, String[] quarterSymbols, boolean quarterFirst) { if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } this.calendar = new GregorianCalendar(zone); this.quarters = quarterSymbols; this.quarterFirst = quarterFirst; // the following is never used, but it seems that DateFormat requires // it to be non-null. It isn't well covered in the spec, refer to // bug parade 5061189 for more info. this.numberFormat = NumberFormat.getNumberInstance(); } /** * Formats the given date. * * @param date the date. * @param toAppendTo the string buffer. * @param fieldPosition the field position. * * @return The formatted date. */ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { this.calendar.setTime(date); int year = this.calendar.get(Calendar.YEAR); int month = this.calendar.get(Calendar.MONTH); int quarter = month / 3; if (this.quarterFirst) { toAppendTo.append(this.quarters[quarter]); toAppendTo.append(" "); toAppendTo.append(year); } else { toAppendTo.append(year); toAppendTo.append(" "); toAppendTo.append(this.quarters[quarter]); } return toAppendTo; } /** * Parses the given string (not implemented). * * @param source the date string. * @param pos the parse position. * * @return null, as this method has not been implemented. */ public Date parse(String source, ParsePosition pos) { return null; } /** * Tests this formatter for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof QuarterDateFormat)) { return false; } QuarterDateFormat that = (QuarterDateFormat) obj; if (!Arrays.equals(this.quarters, that.quarters)) { return false; } if (this.quarterFirst != that.quarterFirst) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/SegmentedTimeline.java0000644000175000017500000020033211173030414027642 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * SegmentedTimeline.java * ----------------------- * (C) Copyright 2003-2008, by Bill Kelemen and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 23-May-2003 : Version 1 (BK); * 15-Aug-2003 : Implemented Cloneable (DG); * 01-Jun-2004 : Modified to compile with JDK 1.2.2 (DG); * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); * 04-Nov-2004 : Reverted change of 30-Sep-2004, won't work with JDK 1.3 (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 14-Nov-2006 : Fix in toTimelineValue(long) to avoid stack overflow (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 11-Jul-2007 : Fixed time zone bugs (DG); * 06-Jun-2008 : Performance enhancement posted in forum (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; /** * A {@link Timeline} that implements a "segmented" timeline with included, * excluded and exception segments. *

* A Timeline will present a series of values to be used for an axis. Each * Timeline must provide transformation methods between domain values and * timeline values. *

* A timeline can be used as parameter to a * {@link org.jfree.chart.axis.DateAxis} to define the values that this axis * supports. This class implements a timeline formed by segments of equal * length (ex. days, hours, minutes) where some segments can be included in the * timeline and others excluded. Therefore timelines like "working days" or * "working hours" can be created where non-working days or non-working hours * respectively can be removed from the timeline, and therefore from the axis. * This creates a smooth plot with equal separation between all included * segments. *

* Because Timelines were created mainly for Date related axis, values are * represented as longs instead of doubles. In this case, the domain value is * just the number of milliseconds since January 1, 1970, 00:00:00 GMT as * defined by the getTime() method of {@link java.util.Date}. *

* In this class, a segment is defined as a unit of time of fixed length. * Examples of segments are: days, hours, minutes, etc. The size of a segment * is defined as the number of milliseconds in the segment. Some useful segment * sizes are defined as constants in this class: DAY_SEGMENT_SIZE, * HOUR_SEGMENT_SIZE, FIFTEEN_MINUTE_SEGMENT_SIZE and MINUTE_SEGMENT_SIZE. *

* Segments are group together to form a Segment Group. Each Segment Group will * contain a number of Segments included and a number of Segments excluded. This * Segment Group structure will repeat for the whole timeline. *

* For example, a working days SegmentedTimeline would be formed by a group of * 7 daily segments, where there are 5 included (Monday through Friday) and 2 * excluded (Saturday and Sunday) segments. *

* Following is a diagram that explains the major attributes that define a * segment. Each box is one segment and must be of fixed length (ms, second, * hour, day, etc). *

*

 * start time
 *   |
 *   v
 *   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 ...
 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+...
 * |  |  |  |  |  |EE|EE|  |  |  |  |  |EE|EE|  |  |  |  |  |EE|EE|
 * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+...
 *  \____________/ \___/            \_/
 *        \/         |               |
 *     included   excluded        segment
 *     segments   segments         size
 *  \_________  _______/
 *            \/
 *       segment group
 * 
* Legend:
* <space> = Included segment
* EE = Excluded segments in the base timeline
*

* In the example, the following segment attributes are presented: *

    *
  • segment size: the size of each segment in ms. *
  • start time: the start of the first segment of the first segment group to * consider. *
  • included segments: the number of segments to include in the group. *
  • excluded segments: the number of segments to exclude in the group. *
*

* Exception Segments are allowed. These exception segments are defined as * segments that would have been in the included segments of the Segment Group, * but should be excluded for special reasons. In the previous working days * SegmentedTimeline example, holidays would be considered exceptions. *

* Additionally the startTime, or start of the first Segment of * the smallest segment group needs to be defined. This startTime could be * relative to January 1, 1970, 00:00:00 GMT or any other date. This creates a * point of reference to start counting Segment Groups. For example, for the * working days SegmentedTimeline, the startTime could be * 00:00:00 GMT of the first Monday after January 1, 1970. In this class, the * constant FIRST_MONDAY_AFTER_1900 refers to a reference point of the first * Monday of the last century. *

* A SegmentedTimeline can include a baseTimeline. This combination of * timelines allows the creation of more complex timelines. For example, in * order to implement a SegmentedTimeline for an intraday stock trading * application, where the trading period is defined as 9:00 AM through 4:00 PM * Monday through Friday, two SegmentedTimelines are used. The first one (the * baseTimeline) would be a working day SegmentedTimeline (daily timeline * Monday through Friday). On top of this baseTimeline, a second one is defined * that maps the 9:00 AM to 4:00 PM period. Because the baseTimeline defines a * timeline of Monday through Friday, the resulting (combined) timeline will * expose the period 9:00 AM through 4:00 PM only on Monday through Friday, * and will remove all other intermediate intervals. *

* Two factory methods newMondayThroughFridayTimeline() and * newFifteenMinuteTimeline() are provided as examples to create special * SegmentedTimelines. * * @see org.jfree.chart.axis.DateAxis */ public class SegmentedTimeline implements Timeline, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1093779862539903110L; //////////////////////////////////////////////////////////////////////////// // predetermined segments sizes //////////////////////////////////////////////////////////////////////////// /** Defines a day segment size in ms. */ public static final long DAY_SEGMENT_SIZE = 24 * 60 * 60 * 1000; /** Defines a one hour segment size in ms. */ public static final long HOUR_SEGMENT_SIZE = 60 * 60 * 1000; /** Defines a 15-minute segment size in ms. */ public static final long FIFTEEN_MINUTE_SEGMENT_SIZE = 15 * 60 * 1000; /** Defines a one-minute segment size in ms. */ public static final long MINUTE_SEGMENT_SIZE = 60 * 1000; //////////////////////////////////////////////////////////////////////////// // other constants //////////////////////////////////////////////////////////////////////////// /** * Utility constant that defines the startTime as the first monday after * 1/1/1970. This should be used when creating a SegmentedTimeline for * Monday through Friday. See static block below for calculation of this * constant. * * @deprecated As of 1.0.7. This field doesn't take into account changes * to the default time zone. */ public static long FIRST_MONDAY_AFTER_1900; /** * Utility TimeZone object that has no DST and an offset equal to the * default TimeZone. This allows easy arithmetic between days as each one * will have equal size. * * @deprecated As of 1.0.7. This field is initialised based on the * default time zone, and doesn't take into account subsequent * changes to the default. */ public static TimeZone NO_DST_TIME_ZONE; /** * This is the default time zone where the application is running. See * getTime() below where we make use of certain transformations between * times in the default time zone and the no-dst time zone used for our * calculations. * * @deprecated As of 1.0.7. When the default time zone is required, * just call TimeZone.getDefault(). */ public static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault(); /** * This will be a utility calendar that has no DST but is shifted relative * to the default time zone's offset. */ private Calendar workingCalendarNoDST; /** * This will be a utility calendar that used the default time zone. */ private Calendar workingCalendar = Calendar.getInstance(); //////////////////////////////////////////////////////////////////////////// // private attributes //////////////////////////////////////////////////////////////////////////// /** Segment size in ms. */ private long segmentSize; /** Number of consecutive segments to include in a segment group. */ private int segmentsIncluded; /** Number of consecutive segments to exclude in a segment group. */ private int segmentsExcluded; /** Number of segments in a group (segmentsIncluded + segmentsExcluded). */ private int groupSegmentCount; /** * Start of time reference from time zero (1/1/1970). * This is the start of segment #0. */ private long startTime; /** Consecutive ms in segmentsIncluded (segmentsIncluded * segmentSize). */ private long segmentsIncludedSize; /** Consecutive ms in segmentsExcluded (segmentsExcluded * segmentSize). */ private long segmentsExcludedSize; /** ms in a segment group (segmentsIncludedSize + segmentsExcludedSize). */ private long segmentsGroupSize; /** * List of exception segments (exceptions segments that would otherwise be * included based on the periodic (included, excluded) grouping). */ private List exceptionSegments = new ArrayList(); /** * This base timeline is used to specify exceptions at a higher level. For * example, if we are a intraday timeline and want to exclude holidays, * instead of having to exclude all intraday segments for the holiday, * segments from this base timeline can be excluded. This baseTimeline is * always optional and is only a convenience method. *

* Additionally, all excluded segments from this baseTimeline will be * considered exceptions at this level. */ private SegmentedTimeline baseTimeline; /** A flag that controls whether or not to adjust for daylight saving. */ private boolean adjustForDaylightSaving = false; //////////////////////////////////////////////////////////////////////////// // static block //////////////////////////////////////////////////////////////////////////// static { // make a time zone with no DST for our Calendar calculations int offset = TimeZone.getDefault().getRawOffset(); NO_DST_TIME_ZONE = new SimpleTimeZone(offset, "UTC-" + offset); // calculate midnight of first monday after 1/1/1900 relative to // current locale Calendar cal = new GregorianCalendar(NO_DST_TIME_ZONE); cal.set(1900, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { cal.add(Calendar.DATE, 1); } // FIRST_MONDAY_AFTER_1900 = cal.getTime().getTime(); // preceding code won't work with JDK 1.3 FIRST_MONDAY_AFTER_1900 = cal.getTime().getTime(); } //////////////////////////////////////////////////////////////////////////// // constructors and factory methods //////////////////////////////////////////////////////////////////////////// /** * Constructs a new segmented timeline, optionaly using another segmented * timeline as its base. This chaining of SegmentedTimelines allows further * segmentation into smaller timelines. * * If a base * * @param segmentSize the size of a segment in ms. This time unit will be * used to compute the included and excluded segments of the * timeline. * @param segmentsIncluded Number of consecutive segments to include. * @param segmentsExcluded Number of consecutive segments to exclude. */ public SegmentedTimeline(long segmentSize, int segmentsIncluded, int segmentsExcluded) { this.segmentSize = segmentSize; this.segmentsIncluded = segmentsIncluded; this.segmentsExcluded = segmentsExcluded; this.groupSegmentCount = this.segmentsIncluded + this.segmentsExcluded; this.segmentsIncludedSize = this.segmentsIncluded * this.segmentSize; this.segmentsExcludedSize = this.segmentsExcluded * this.segmentSize; this.segmentsGroupSize = this.segmentsIncludedSize + this.segmentsExcludedSize; int offset = TimeZone.getDefault().getRawOffset(); TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset); this.workingCalendarNoDST = new GregorianCalendar(z, Locale.getDefault()); } /** * Returns the milliseconds for midnight of the first Monday after * 1-Jan-1900, ignoring daylight savings. * * @return The milliseconds. * * @since 1.0.7 */ public static long firstMondayAfter1900() { int offset = TimeZone.getDefault().getRawOffset(); TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset); // calculate midnight of first monday after 1/1/1900 relative to // current locale Calendar cal = new GregorianCalendar(z); cal.set(1900, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { cal.add(Calendar.DATE, 1); } //return cal.getTimeInMillis(); // preceding code won't work with JDK 1.3 return cal.getTime().getTime(); } /** * Factory method to create a Monday through Friday SegmentedTimeline. *

* The startTime of the resulting timeline will be midnight * of the first Monday after 1/1/1900. * * @return A fully initialized SegmentedTimeline. */ public static SegmentedTimeline newMondayThroughFridayTimeline() { SegmentedTimeline timeline = new SegmentedTimeline(DAY_SEGMENT_SIZE, 5, 2); timeline.setStartTime(firstMondayAfter1900()); return timeline; } /** * Factory method to create a 15-min, 9:00 AM thought 4:00 PM, Monday * through Friday SegmentedTimeline. *

* This timeline uses a segmentSize of FIFTEEN_MIN_SEGMENT_SIZE. The * segment group is defined as 28 included segments (9:00 AM through * 4:00 PM) and 68 excluded segments (4:00 PM through 9:00 AM the next day). *

* In order to exclude Saturdays and Sundays it uses a baseTimeline that * only includes Monday through Friday days. *

* The startTime of the resulting timeline will be 9:00 AM * after the startTime of the baseTimeline. This will correspond to 9:00 AM * of the first Monday after 1/1/1900. * * @return A fully initialized SegmentedTimeline. */ public static SegmentedTimeline newFifteenMinuteTimeline() { SegmentedTimeline timeline = new SegmentedTimeline( FIFTEEN_MINUTE_SEGMENT_SIZE, 28, 68); timeline.setStartTime(firstMondayAfter1900() + 36 * timeline.getSegmentSize()); timeline.setBaseTimeline(newMondayThroughFridayTimeline()); return timeline; } /** * Returns the flag that controls whether or not the daylight saving * adjustment is applied. * * @return A boolean. */ public boolean getAdjustForDaylightSaving() { return this.adjustForDaylightSaving; } /** * Sets the flag that controls whether or not the daylight saving adjustment * is applied. * * @param adjust the flag. */ public void setAdjustForDaylightSaving(boolean adjust) { this.adjustForDaylightSaving = adjust; } //////////////////////////////////////////////////////////////////////////// // operations //////////////////////////////////////////////////////////////////////////// /** * Sets the start time for the timeline. This is the beginning of segment * zero. * * @param millisecond the start time (encoded as in java.util.Date). */ public void setStartTime(long millisecond) { this.startTime = millisecond; } /** * Returns the start time for the timeline. This is the beginning of * segment zero. * * @return The start time. */ public long getStartTime() { return this.startTime; } /** * Returns the number of segments excluded per segment group. * * @return The number of segments excluded. */ public int getSegmentsExcluded() { return this.segmentsExcluded; } /** * Returns the size in milliseconds of the segments excluded per segment * group. * * @return The size in milliseconds. */ public long getSegmentsExcludedSize() { return this.segmentsExcludedSize; } /** * Returns the number of segments in a segment group. This will be equal to * segments included plus segments excluded. * * @return The number of segments. */ public int getGroupSegmentCount() { return this.groupSegmentCount; } /** * Returns the size in milliseconds of a segment group. This will be equal * to size of the segments included plus the size of the segments excluded. * * @return The segment group size in milliseconds. */ public long getSegmentsGroupSize() { return this.segmentsGroupSize; } /** * Returns the number of segments included per segment group. * * @return The number of segments. */ public int getSegmentsIncluded() { return this.segmentsIncluded; } /** * Returns the size in ms of the segments included per segment group. * * @return The segment size in milliseconds. */ public long getSegmentsIncludedSize() { return this.segmentsIncludedSize; } /** * Returns the size of one segment in ms. * * @return The segment size in milliseconds. */ public long getSegmentSize() { return this.segmentSize; } /** * Returns a list of all the exception segments. This list is not * modifiable. * * @return The exception segments. */ public List getExceptionSegments() { return Collections.unmodifiableList(this.exceptionSegments); } /** * Sets the exception segments list. * * @param exceptionSegments the exception segments. */ public void setExceptionSegments(List exceptionSegments) { this.exceptionSegments = exceptionSegments; } /** * Returns our baseTimeline, or null if none. * * @return The base timeline. */ public SegmentedTimeline getBaseTimeline() { return this.baseTimeline; } /** * Sets the base timeline. * * @param baseTimeline the timeline. */ public void setBaseTimeline(SegmentedTimeline baseTimeline) { // verify that baseTimeline is compatible with us if (baseTimeline != null) { if (baseTimeline.getSegmentSize() < this.segmentSize) { throw new IllegalArgumentException( "baseTimeline.getSegmentSize() " + "is smaller than segmentSize"); } else if (baseTimeline.getStartTime() > this.startTime) { throw new IllegalArgumentException( "baseTimeline.getStartTime() is after startTime"); } else if ((baseTimeline.getSegmentSize() % this.segmentSize) != 0) { throw new IllegalArgumentException( "baseTimeline.getSegmentSize() is not multiple of " + "segmentSize"); } else if (((this.startTime - baseTimeline.getStartTime()) % this.segmentSize) != 0) { throw new IllegalArgumentException( "baseTimeline is not aligned"); } } this.baseTimeline = baseTimeline; } /** * Translates a value relative to the domain value (all Dates) into a value * relative to the segmented timeline. The values relative to the segmented * timeline are all consecutives starting at zero at the startTime. * * @param millisecond the millisecond (as encoded by java.util.Date). * * @return The timeline value. */ public long toTimelineValue(long millisecond) { long result; long rawMilliseconds = millisecond - this.startTime; long groupMilliseconds = rawMilliseconds % this.segmentsGroupSize; long groupIndex = rawMilliseconds / this.segmentsGroupSize; if (groupMilliseconds >= this.segmentsIncludedSize) { result = toTimelineValue(this.startTime + this.segmentsGroupSize * (groupIndex + 1)); } else { Segment segment = getSegment(millisecond); if (segment.inExceptionSegments()) { int p; while ((p = binarySearchExceptionSegments(segment)) >= 0) { segment = getSegment(millisecond = ((Segment) this.exceptionSegments.get(p)).getSegmentEnd() + 1); } result = toTimelineValue(millisecond); } else { long shiftedSegmentedValue = millisecond - this.startTime; long x = shiftedSegmentedValue % this.segmentsGroupSize; long y = shiftedSegmentedValue / this.segmentsGroupSize; long wholeExceptionsBeforeDomainValue = getExceptionSegmentCount(this.startTime, millisecond - 1); // long partialTimeInException = 0; // Segment ss = getSegment(millisecond); // if (ss.inExceptionSegments()) { // partialTimeInException = millisecond // - ss.getSegmentStart(); // } if (x < this.segmentsIncludedSize) { result = this.segmentsIncludedSize * y + x - wholeExceptionsBeforeDomainValue * this.segmentSize; // - partialTimeInException; } else { result = this.segmentsIncludedSize * (y + 1) - wholeExceptionsBeforeDomainValue * this.segmentSize; // - partialTimeInException; } } } return result; } /** * Translates a date into a value relative to the segmented timeline. The * values relative to the segmented timeline are all consecutives starting * at zero at the startTime. * * @param date date relative to the domain. * * @return The timeline value (in milliseconds). */ public long toTimelineValue(Date date) { return toTimelineValue(getTime(date)); //return toTimelineValue(dateDomainValue.getTime()); } /** * Translates a value relative to the timeline into a millisecond. * * @param timelineValue the timeline value (in milliseconds). * * @return The domain value (in milliseconds). */ public long toMillisecond(long timelineValue) { // calculate the result as if no exceptions Segment result = new Segment(this.startTime + timelineValue + (timelineValue / this.segmentsIncludedSize) * this.segmentsExcludedSize); long lastIndex = this.startTime; // adjust result for any exceptions in the result calculated while (lastIndex <= result.segmentStart) { // skip all whole exception segments in the range long exceptionSegmentCount; while ((exceptionSegmentCount = getExceptionSegmentCount( lastIndex, (result.millisecond / this.segmentSize) * this.segmentSize - 1)) > 0 ) { lastIndex = result.segmentStart; // move forward exceptionSegmentCount segments skipping // excluded segments for (int i = 0; i < exceptionSegmentCount; i++) { do { result.inc(); } while (result.inExcludeSegments()); } } lastIndex = result.segmentStart; // skip exception or excluded segments we may fall on while (result.inExceptionSegments() || result.inExcludeSegments()) { result.inc(); lastIndex += this.segmentSize; } lastIndex++; } return getTimeFromLong(result.millisecond); } /** * Converts a date/time value to take account of daylight savings time. * * @param date the milliseconds. * * @return The milliseconds. */ public long getTimeFromLong(long date) { long result = date; if (this.adjustForDaylightSaving) { this.workingCalendarNoDST.setTime(new Date(date)); this.workingCalendar.set( this.workingCalendarNoDST.get(Calendar.YEAR), this.workingCalendarNoDST.get(Calendar.MONTH), this.workingCalendarNoDST.get(Calendar.DATE), this.workingCalendarNoDST.get(Calendar.HOUR_OF_DAY), this.workingCalendarNoDST.get(Calendar.MINUTE), this.workingCalendarNoDST.get(Calendar.SECOND) ); this.workingCalendar.set(Calendar.MILLISECOND, this.workingCalendarNoDST.get(Calendar.MILLISECOND)); // result = this.workingCalendar.getTimeInMillis(); // preceding code won't work with JDK 1.3 result = this.workingCalendar.getTime().getTime(); } return result; } /** * Returns true if a value is contained in the timeline. * * @param millisecond the value to verify. * * @return true if value is contained in the timeline. */ public boolean containsDomainValue(long millisecond) { Segment segment = getSegment(millisecond); return segment.inIncludeSegments(); } /** * Returns true if a value is contained in the timeline. * * @param date date to verify * * @return true if value is contained in the timeline */ public boolean containsDomainValue(Date date) { return containsDomainValue(getTime(date)); } /** * Returns true if a range of values are contained in the * timeline. This is implemented verifying that all segments are in the * range. * * @param domainValueStart start of the range to verify * @param domainValueEnd end of the range to verify * * @return true if the range is contained in the timeline */ public boolean containsDomainRange(long domainValueStart, long domainValueEnd) { if (domainValueEnd < domainValueStart) { throw new IllegalArgumentException( "domainValueEnd (" + domainValueEnd + ") < domainValueStart (" + domainValueStart + ")"); } Segment segment = getSegment(domainValueStart); boolean contains = true; do { contains = (segment.inIncludeSegments()); if (segment.contains(domainValueEnd)) { break; } else { segment.inc(); } } while (contains); return (contains); } /** * Returns true if a range of values are contained in the * timeline. This is implemented verifying that all segments are in the * range. * * @param dateDomainValueStart start of the range to verify * @param dateDomainValueEnd end of the range to verify * * @return true if the range is contained in the timeline */ public boolean containsDomainRange(Date dateDomainValueStart, Date dateDomainValueEnd) { return containsDomainRange(getTime(dateDomainValueStart), getTime(dateDomainValueEnd)); } /** * Adds a segment as an exception. An exception segment is defined as a * segment to exclude from what would otherwise be considered a valid * segment of the timeline. An exception segment can not be contained * inside an already excluded segment. If so, no action will occur (the * proposed exception segment will be discarded). *

* The segment is identified by a domainValue into any part of the segment. * Therefore the segmentStart <= domainValue <= segmentEnd. * * @param millisecond domain value to treat as an exception */ public void addException(long millisecond) { addException(new Segment(millisecond)); } /** * Adds a segment range as an exception. An exception segment is defined as * a segment to exclude from what would otherwise be considered a valid * segment of the timeline. An exception segment can not be contained * inside an already excluded segment. If so, no action will occur (the * proposed exception segment will be discarded). *

* The segment range is identified by a domainValue that begins a valid * segment and ends with a domainValue that ends a valid segment. * Therefore the range will contain all segments whose segmentStart * <= domainValue and segmentEnd <= toDomainValue. * * @param fromDomainValue start of domain range to treat as an exception * @param toDomainValue end of domain range to treat as an exception */ public void addException(long fromDomainValue, long toDomainValue) { addException(new SegmentRange(fromDomainValue, toDomainValue)); } /** * Adds a segment as an exception. An exception segment is defined as a * segment to exclude from what would otherwise be considered a valid * segment of the timeline. An exception segment can not be contained * inside an already excluded segment. If so, no action will occur (the * proposed exception segment will be discarded). *

* The segment is identified by a Date into any part of the segment. * * @param exceptionDate Date into the segment to exclude. */ public void addException(Date exceptionDate) { addException(getTime(exceptionDate)); //addException(exceptionDate.getTime()); } /** * Adds a list of dates as segment exceptions. Each exception segment is * defined as a segment to exclude from what would otherwise be considered * a valid segment of the timeline. An exception segment can not be * contained inside an already excluded segment. If so, no action will * occur (the proposed exception segment will be discarded). *

* The segment is identified by a Date into any part of the segment. * * @param exceptionList List of Date objects that identify the segments to * exclude. */ public void addExceptions(List exceptionList) { for (Iterator iter = exceptionList.iterator(); iter.hasNext();) { addException((Date) iter.next()); } } /** * Adds a segment as an exception. An exception segment is defined as a * segment to exclude from what would otherwise be considered a valid * segment of the timeline. An exception segment can not be contained * inside an already excluded segment. This is verified inside this * method, and if so, no action will occur (the proposed exception segment * will be discarded). * * @param segment the segment to exclude. */ private void addException(Segment segment) { if (segment.inIncludeSegments()) { int p = binarySearchExceptionSegments(segment); this.exceptionSegments.add(-(p + 1), segment); } } /** * Adds a segment relative to the baseTimeline as an exception. Because a * base segment is normally larger than our segments, this may add one or * more segment ranges to the exception list. *

* An exception segment is defined as a segment * to exclude from what would otherwise be considered a valid segment of * the timeline. An exception segment can not be contained inside an * already excluded segment. If so, no action will occur (the proposed * exception segment will be discarded). *

* The segment is identified by a domainValue into any part of the * baseTimeline segment. * * @param domainValue domain value to teat as a baseTimeline exception. */ public void addBaseTimelineException(long domainValue) { Segment baseSegment = this.baseTimeline.getSegment(domainValue); if (baseSegment.inIncludeSegments()) { // cycle through all the segments contained in the BaseTimeline // exception segment Segment segment = getSegment(baseSegment.getSegmentStart()); while (segment.getSegmentStart() <= baseSegment.getSegmentEnd()) { if (segment.inIncludeSegments()) { // find all consecutive included segments long fromDomainValue = segment.getSegmentStart(); long toDomainValue; do { toDomainValue = segment.getSegmentEnd(); segment.inc(); } while (segment.inIncludeSegments()); // add the interval as an exception addException(fromDomainValue, toDomainValue); } else { // this is not one of our included segment, skip it segment.inc(); } } } } /** * Adds a segment relative to the baseTimeline as an exception. An * exception segment is defined as a segment to exclude from what would * otherwise be considered a valid segment of the timeline. An exception * segment can not be contained inside an already excluded segment. If so, * no action will occure (the proposed exception segment will be discarded). *

* The segment is identified by a domainValue into any part of the segment. * Therefore the segmentStart <= domainValue <= segmentEnd. * * @param date date domain value to treat as a baseTimeline exception */ public void addBaseTimelineException(Date date) { addBaseTimelineException(getTime(date)); } /** * Adds all excluded segments from the BaseTimeline as exceptions to our * timeline. This allows us to combine two timelines for more complex * calculations. * * @param fromBaseDomainValue Start of the range where exclusions will be * extracted. * @param toBaseDomainValue End of the range to process. */ public void addBaseTimelineExclusions(long fromBaseDomainValue, long toBaseDomainValue) { // find first excluded base segment starting fromDomainValue Segment baseSegment = this.baseTimeline.getSegment(fromBaseDomainValue); while (baseSegment.getSegmentStart() <= toBaseDomainValue && !baseSegment.inExcludeSegments()) { baseSegment.inc(); } // cycle over all the base segments groups in the range while (baseSegment.getSegmentStart() <= toBaseDomainValue) { long baseExclusionRangeEnd = baseSegment.getSegmentStart() + this.baseTimeline.getSegmentsExcluded() * this.baseTimeline.getSegmentSize() - 1; // cycle through all the segments contained in the base exclusion // area Segment segment = getSegment(baseSegment.getSegmentStart()); while (segment.getSegmentStart() <= baseExclusionRangeEnd) { if (segment.inIncludeSegments()) { // find all consecutive included segments long fromDomainValue = segment.getSegmentStart(); long toDomainValue; do { toDomainValue = segment.getSegmentEnd(); segment.inc(); } while (segment.inIncludeSegments()); // add the interval as an exception addException(new BaseTimelineSegmentRange( fromDomainValue, toDomainValue)); } else { // this is not one of our included segment, skip it segment.inc(); } } // go to next base segment group baseSegment.inc(this.baseTimeline.getGroupSegmentCount()); } } /** * Returns the number of exception segments wholly contained in the * (fromDomainValue, toDomainValue) interval. * * @param fromMillisecond the beginning of the interval. * @param toMillisecond the end of the interval. * * @return Number of exception segments contained in the interval. */ public long getExceptionSegmentCount(long fromMillisecond, long toMillisecond) { if (toMillisecond < fromMillisecond) { return (0); } int n = 0; for (Iterator iter = this.exceptionSegments.iterator(); iter.hasNext();) { Segment segment = (Segment) iter.next(); Segment intersection = segment.intersect(fromMillisecond, toMillisecond); if (intersection != null) { n += intersection.getSegmentCount(); } } return (n); } /** * Returns a segment that contains a domainValue. If the domainValue is * not contained in the timeline (because it is not contained in the * baseTimeline), a Segment that contains * index + segmentSize*m will be returned for the smallest * m possible. * * @param millisecond index into the segment * * @return A Segment that contains index, or the next possible Segment. */ public Segment getSegment(long millisecond) { return new Segment(millisecond); } /** * Returns a segment that contains a date. For accurate calculations, * the calendar should use TIME_ZONE for its calculation (or any other * similar time zone). * * If the date is not contained in the timeline (because it is not * contained in the baseTimeline), a Segment that contains * date + segmentSize*m will be returned for the smallest * m possible. * * @param date date into the segment * * @return A Segment that contains date, or the next possible Segment. */ public Segment getSegment(Date date) { return (getSegment(getTime(date))); } /** * Convenient method to test equality in two objects, taking into account * nulls. * * @param o first object to compare * @param p second object to compare * * @return true if both objects are equal or both * null, false otherwise. */ private boolean equals(Object o, Object p) { return (o == p || ((o != null) && o.equals(p))); } /** * Returns true if we are equal to the parameter * * @param o Object to verify with us * * @return true or false */ public boolean equals(Object o) { if (o instanceof SegmentedTimeline) { SegmentedTimeline other = (SegmentedTimeline) o; boolean b0 = (this.segmentSize == other.getSegmentSize()); boolean b1 = (this.segmentsIncluded == other.getSegmentsIncluded()); boolean b2 = (this.segmentsExcluded == other.getSegmentsExcluded()); boolean b3 = (this.startTime == other.getStartTime()); boolean b4 = equals(this.exceptionSegments, other.getExceptionSegments()); return b0 && b1 && b2 && b3 && b4; } else { return (false); } } /** * Returns a hash code for this object. * * @return A hash code. */ public int hashCode() { int result = 19; result = 37 * result + (int) (this.segmentSize ^ (this.segmentSize >>> 32)); result = 37 * result + (int) (this.startTime ^ (this.startTime >>> 32)); return result; } /** * Preforms a binary serach in the exceptionSegments sorted array. This * array can contain Segments or SegmentRange objects. * * @param segment the key to be searched for. * * @return index of the search segment, if it is contained in the list; * otherwise, (-(insertion point) - 1). The * insertion point is defined as the point at which the * segment would be inserted into the list: the index of the first * element greater than the key, or list.size(), if all * elements in the list are less than the specified segment. Note * that this guarantees that the return value will be >= 0 if * and only if the key is found. */ private int binarySearchExceptionSegments(Segment segment) { int low = 0; int high = this.exceptionSegments.size() - 1; while (low <= high) { int mid = (low + high) / 2; Segment midSegment = (Segment) this.exceptionSegments.get(mid); // first test for equality (contains or contained) if (segment.contains(midSegment) || midSegment.contains(segment)) { return mid; } if (midSegment.before(segment)) { low = mid + 1; } else if (midSegment.after(segment)) { high = mid - 1; } else { throw new IllegalStateException("Invalid condition."); } } return -(low + 1); // key not found } /** * Special method that handles conversion between the Default Time Zone and * a UTC time zone with no DST. This is needed so all days have the same * size. This method is the prefered way of converting a Data into * milliseconds for usage in this class. * * @param date Date to convert to long. * * @return The milliseconds. */ public long getTime(Date date) { long result = date.getTime(); if (this.adjustForDaylightSaving) { this.workingCalendar.setTime(date); this.workingCalendarNoDST.set( this.workingCalendar.get(Calendar.YEAR), this.workingCalendar.get(Calendar.MONTH), this.workingCalendar.get(Calendar.DATE), this.workingCalendar.get(Calendar.HOUR_OF_DAY), this.workingCalendar.get(Calendar.MINUTE), this.workingCalendar.get(Calendar.SECOND)); this.workingCalendarNoDST.set(Calendar.MILLISECOND, this.workingCalendar.get(Calendar.MILLISECOND)); Date revisedDate = this.workingCalendarNoDST.getTime(); result = revisedDate.getTime(); } return result; } /** * Converts a millisecond value into a {@link Date} object. * * @param value the millisecond value. * * @return The date. */ public Date getDate(long value) { this.workingCalendarNoDST.setTime(new Date(value)); return (this.workingCalendarNoDST.getTime()); } /** * Returns a clone of the timeline. * * @return A clone. * * @throws CloneNotSupportedException ??. */ public Object clone() throws CloneNotSupportedException { SegmentedTimeline clone = (SegmentedTimeline) super.clone(); return clone; } /** * Internal class to represent a valid segment for this timeline. A segment * is valid on a timeline if it is part of its included, excluded or * exception segments. *

* Each segment will know its segment number, segmentStart, segmentEnd and * index inside the segment. */ public class Segment implements Comparable, Cloneable, Serializable { /** The segment number. */ protected long segmentNumber; /** The segment start. */ protected long segmentStart; /** The segment end. */ protected long segmentEnd; /** A reference point within the segment. */ protected long millisecond; /** * Protected constructor only used by sub-classes. */ protected Segment() { // empty } /** * Creates a segment for a given point in time. * * @param millisecond the millisecond (as encoded by java.util.Date). */ protected Segment(long millisecond) { this.segmentNumber = calculateSegmentNumber(millisecond); this.segmentStart = SegmentedTimeline.this.startTime + this.segmentNumber * SegmentedTimeline.this.segmentSize; this.segmentEnd = this.segmentStart + SegmentedTimeline.this.segmentSize - 1; this.millisecond = millisecond; } /** * Calculates the segment number for a given millisecond. * * @param millis the millisecond (as encoded by java.util.Date). * * @return The segment number. */ public long calculateSegmentNumber(long millis) { if (millis >= SegmentedTimeline.this.startTime) { return (millis - SegmentedTimeline.this.startTime) / SegmentedTimeline.this.segmentSize; } else { return ((millis - SegmentedTimeline.this.startTime) / SegmentedTimeline.this.segmentSize) - 1; } } /** * Returns the segment number of this segment. Segments start at 0. * * @return The segment number. */ public long getSegmentNumber() { return this.segmentNumber; } /** * Returns always one (the number of segments contained in this * segment). * * @return The segment count (always 1 for this class). */ public long getSegmentCount() { return 1; } /** * Gets the start of this segment in ms. * * @return The segment start. */ public long getSegmentStart() { return this.segmentStart; } /** * Gets the end of this segment in ms. * * @return The segment end. */ public long getSegmentEnd() { return this.segmentEnd; } /** * Returns the millisecond used to reference this segment (always * between the segmentStart and segmentEnd). * * @return The millisecond. */ public long getMillisecond() { return this.millisecond; } /** * Returns a {@link java.util.Date} that represents the reference point * for this segment. * * @return The date. */ public Date getDate() { return SegmentedTimeline.this.getDate(this.millisecond); } /** * Returns true if a particular millisecond is contained in this * segment. * * @param millis the millisecond to verify. * * @return true if the millisecond is contained in the * segment. */ public boolean contains(long millis) { return (this.segmentStart <= millis && millis <= this.segmentEnd); } /** * Returns true if an interval is contained in this * segment. * * @param from the start of the interval. * @param to the end of the interval. * * @return true if the interval is contained in the * segment. */ public boolean contains(long from, long to) { return (this.segmentStart <= from && to <= this.segmentEnd); } /** * Returns true if a segment is contained in this segment. * * @param segment the segment to test for inclusion * * @return true if the segment is contained in this * segment. */ public boolean contains(Segment segment) { return contains(segment.getSegmentStart(), segment.getSegmentEnd()); } /** * Returns true if this segment is contained in an * interval. * * @param from the start of the interval. * @param to the end of the interval. * * @return true if this segment is contained in the * interval. */ public boolean contained(long from, long to) { return (from <= this.segmentStart && this.segmentEnd <= to); } /** * Returns a segment that is the intersection of this segment and the * interval. * * @param from the start of the interval. * @param to the end of the interval. * * @return A segment. */ public Segment intersect(long from, long to) { if (from <= this.segmentStart && this.segmentEnd <= to) { return this; } else { return null; } } /** * Returns true if this segment is wholly before another * segment. * * @param other the other segment. * * @return A boolean. */ public boolean before(Segment other) { return (this.segmentEnd < other.getSegmentStart()); } /** * Returns true if this segment is wholly after another * segment. * * @param other the other segment. * * @return A boolean. */ public boolean after(Segment other) { return (this.segmentStart > other.getSegmentEnd()); } /** * Tests an object (usually another Segment) for equality * with this segment. * * @param object The other segment to compare with us * * @return true if we are the same segment */ public boolean equals(Object object) { if (object instanceof Segment) { Segment other = (Segment) object; return (this.segmentNumber == other.getSegmentNumber() && this.segmentStart == other.getSegmentStart() && this.segmentEnd == other.getSegmentEnd() && this.millisecond == other.getMillisecond()); } else { return false; } } /** * Returns a copy of ourselves or null if there was an * exception during cloning. * * @return A copy of this segment. */ public Segment copy() { try { return (Segment) this.clone(); } catch (CloneNotSupportedException e) { return null; } } /** * Will compare this Segment with another Segment (from Comparable * interface). * * @param object The other Segment to compare with * * @return -1: this < object, 0: this.equal(object) and * +1: this > object */ public int compareTo(Object object) { Segment other = (Segment) object; if (this.before(other)) { return -1; } else if (this.after(other)) { return +1; } else { return 0; } } /** * Returns true if we are an included segment and we are not an * exception. * * @return true or false. */ public boolean inIncludeSegments() { if (getSegmentNumberRelativeToGroup() < SegmentedTimeline.this.segmentsIncluded) { return !inExceptionSegments(); } else { return false; } } /** * Returns true if we are an excluded segment. * * @return true or false. */ public boolean inExcludeSegments() { return getSegmentNumberRelativeToGroup() >= SegmentedTimeline.this.segmentsIncluded; } /** * Calculate the segment number relative to the segment group. This * will be a number between 0 and segmentsGroup-1. This value is * calculated from the segmentNumber. Special care is taken for * negative segmentNumbers. * * @return The segment number. */ private long getSegmentNumberRelativeToGroup() { long p = (this.segmentNumber % SegmentedTimeline.this.groupSegmentCount); if (p < 0) { p += SegmentedTimeline.this.groupSegmentCount; } return p; } /** * Returns true if we are an exception segment. This is implemented via * a binary search on the exceptionSegments sorted list. * * If the segment is not listed as an exception in our list and we have * a baseTimeline, a check is performed to see if the segment is inside * an excluded segment from our base. If so, it is also considered an * exception. * * @return true if we are an exception segment. */ public boolean inExceptionSegments() { return binarySearchExceptionSegments(this) >= 0; } /** * Increments the internal attributes of this segment by a number of * segments. * * @param n Number of segments to increment. */ public void inc(long n) { this.segmentNumber += n; long m = n * SegmentedTimeline.this.segmentSize; this.segmentStart += m; this.segmentEnd += m; this.millisecond += m; } /** * Increments the internal attributes of this segment by one segment. * The exact time incremented is segmentSize. */ public void inc() { inc(1); } /** * Decrements the internal attributes of this segment by a number of * segments. * * @param n Number of segments to decrement. */ public void dec(long n) { this.segmentNumber -= n; long m = n * SegmentedTimeline.this.segmentSize; this.segmentStart -= m; this.segmentEnd -= m; this.millisecond -= m; } /** * Decrements the internal attributes of this segment by one segment. * The exact time decremented is segmentSize. */ public void dec() { dec(1); } /** * Moves the index of this segment to the beginning if the segment. */ public void moveIndexToStart() { this.millisecond = this.segmentStart; } /** * Moves the index of this segment to the end of the segment. */ public void moveIndexToEnd() { this.millisecond = this.segmentEnd; } } /** * Private internal class to represent a range of segments. This class is * mainly used to store in one object a range of exception segments. This * optimizes certain timelines that use a small segment size (like an * intraday timeline) allowing them to express a day exception as one * SegmentRange instead of multi Segments. */ protected class SegmentRange extends Segment { /** The number of segments in the range. */ private long segmentCount; /** * Creates a SegmentRange between a start and end domain values. * * @param fromMillisecond start of the range * @param toMillisecond end of the range */ public SegmentRange(long fromMillisecond, long toMillisecond) { Segment start = getSegment(fromMillisecond); Segment end = getSegment(toMillisecond); // if (start.getSegmentStart() != fromMillisecond // || end.getSegmentEnd() != toMillisecond) { // throw new IllegalArgumentException("Invalid Segment Range [" // + fromMillisecond + "," + toMillisecond + "]"); // } this.millisecond = fromMillisecond; this.segmentNumber = calculateSegmentNumber(fromMillisecond); this.segmentStart = start.segmentStart; this.segmentEnd = end.segmentEnd; this.segmentCount = (end.getSegmentNumber() - start.getSegmentNumber() + 1); } /** * Returns the number of segments contained in this range. * * @return The segment count. */ public long getSegmentCount() { return this.segmentCount; } /** * Returns a segment that is the intersection of this segment and the * interval. * * @param from the start of the interval. * @param to the end of the interval. * * @return The intersection. */ public Segment intersect(long from, long to) { // Segment fromSegment = getSegment(from); // fromSegment.inc(); // Segment toSegment = getSegment(to); // toSegment.dec(); long start = Math.max(from, this.segmentStart); long end = Math.min(to, this.segmentEnd); // long start = Math.max( // fromSegment.getSegmentStart(), this.segmentStart // ); // long end = Math.min(toSegment.getSegmentEnd(), this.segmentEnd); if (start <= end) { return new SegmentRange(start, end); } else { return null; } } /** * Returns true if all Segments of this SegmentRenge are an included * segment and are not an exception. * * @return true or false. */ public boolean inIncludeSegments() { for (Segment segment = getSegment(this.segmentStart); segment.getSegmentStart() < this.segmentEnd; segment.inc()) { if (!segment.inIncludeSegments()) { return (false); } } return true; } /** * Returns true if we are an excluded segment. * * @return true or false. */ public boolean inExcludeSegments() { for (Segment segment = getSegment(this.segmentStart); segment.getSegmentStart() < this.segmentEnd; segment.inc()) { if (!segment.inExceptionSegments()) { return (false); } } return true; } /** * Not implemented for SegmentRange. Always throws * IllegalArgumentException. * * @param n Number of segments to increment. */ public void inc(long n) { throw new IllegalArgumentException( "Not implemented in SegmentRange"); } } /** * Special SegmentRange that came from the BaseTimeline. */ protected class BaseTimelineSegmentRange extends SegmentRange { /** * Constructor. * * @param fromDomainValue the start value. * @param toDomainValue the end value. */ public BaseTimelineSegmentRange(long fromDomainValue, long toDomainValue) { super(fromDomainValue, toDomainValue); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/StandardTickUnitSource.java0000644000175000017500000001011311173030414030630 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StandardTickUnitSource.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Sep-2003 : Version 1 (DG); * 25-Oct-2007 : Implemented Serializable and equals() method (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import java.text.DecimalFormat; /** * A source that can used by the {@link NumberAxis} class to obtain a * suitable {@link TickUnit}. Instances of this class are {@link Serializable} * from version 1.0.7 onwards. Cloning is not supported, because instances * are immutable. */ public class StandardTickUnitSource implements TickUnitSource, Serializable { /** Constant for log(10.0). */ private static final double LOG_10_VALUE = Math.log(10.0); /** * Default constructor. */ public StandardTickUnitSource() { super(); } /** * Returns a tick unit that is larger than the supplied unit. * * @param unit the unit (null not permitted). * * @return A tick unit that is larger than the supplied unit. */ public TickUnit getLargerTickUnit(TickUnit unit) { double x = unit.getSize(); double log = Math.log(x) / LOG_10_VALUE; double higher = Math.ceil(log); return new NumberTickUnit(Math.pow(10, higher), new DecimalFormat("0.0E0")); } /** * Returns the tick unit in the collection that is greater than or equal * to (in size) the specified unit. * * @param unit the unit (null not permitted). * * @return A unit from the collection. */ public TickUnit getCeilingTickUnit(TickUnit unit) { return getLargerTickUnit(unit); } /** * Returns the tick unit in the collection that is greater than or equal * to the specified size. * * @param size the size. * * @return A unit from the collection. */ public TickUnit getCeilingTickUnit(double size) { double log = Math.log(size) / LOG_10_VALUE; double higher = Math.ceil(log); return new NumberTickUnit(Math.pow(10, higher), new DecimalFormat("0.0E0")); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } return (obj instanceof StandardTickUnitSource); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return 0; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/SubCategoryAxis.java0000644000175000017500000003774111173030414027330 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * SubCategoryAxis.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert; * Contributor(s): Adriaan Joubert; * * Changes * ------- * 12-May-2004 : Version 1 (DG); * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities * --> TextUtilities (DG); * 26-Apr-2005 : Removed logger (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan * Joubert (1277726) (DG); * 30-May-2007 : Added argument check and event notification to * addSubCategory() (DG); * 13-Nov-2008 : Fix NullPointerException when dataset is null - see bug * report 2275695 (DG); * */ package org.jfree.chart.axis; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; /** * A specialised category axis that can display sub-categories. */ public class SubCategoryAxis extends CategoryAxis implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -1279463299793228344L; /** Storage for the sub-categories (these need to be set manually). */ private List subCategories; /** The font for the sub-category labels. */ private Font subLabelFont = new Font("SansSerif", Font.PLAIN, 10); /** The paint for the sub-category labels. */ private transient Paint subLabelPaint = Color.black; /** * Creates a new axis. * * @param label the axis label. */ public SubCategoryAxis(String label) { super(label); this.subCategories = new java.util.ArrayList(); } /** * Adds a sub-category to the axis and sends an {@link AxisChangeEvent} to * all registered listeners. * * @param subCategory the sub-category (null not permitted). */ public void addSubCategory(Comparable subCategory) { if (subCategory == null) { throw new IllegalArgumentException("Null 'subcategory' axis."); } this.subCategories.add(subCategory); notifyListeners(new AxisChangeEvent(this)); } /** * Returns the font used to display the sub-category labels. * * @return The font (never null). * * @see #setSubLabelFont(Font) */ public Font getSubLabelFont() { return this.subLabelFont; } /** * Sets the font used to display the sub-category labels and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * * @see #getSubLabelFont() */ public void setSubLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.subLabelFont = font; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the paint used to display the sub-category labels. * * @return The paint (never null). * * @see #setSubLabelPaint(Paint) */ public Paint getSubLabelPaint() { return this.subLabelPaint; } /** * Sets the paint used to display the sub-category labels and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getSubLabelPaint() */ public void setSubLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.subLabelPaint = paint; notifyListeners(new AxisChangeEvent(this)); } /** * Estimates the space required for the axis, given a specific drawing area. * * @param g2 the graphics device (used to obtain font information). * @param plot the plot that the axis belongs to. * @param plotArea the area within which the axis should be drawn. * @param edge the axis location (top or bottom). * @param space the space already reserved. * * @return The space required to draw the axis. */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { // create a new space object if one wasn't supplied... if (space == null) { space = new AxisSpace(); } // if the axis is not visible, no additional space is required... if (!isVisible()) { return space; } space = super.reserveSpace(g2, plot, plotArea, edge, space); double maxdim = getMaxDim(g2, edge); if (RectangleEdge.isTopOrBottom(edge)) { space.add(maxdim, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { space.add(maxdim, edge); } return space; } /** * Returns the maximum of the relevant dimension (height or width) of the * subcategory labels. * * @param g2 the graphics device. * @param edge the edge. * * @return The maximum dimension. */ private double getMaxDim(Graphics2D g2, RectangleEdge edge) { double result = 0.0; g2.setFont(this.subLabelFont); FontMetrics fm = g2.getFontMetrics(); Iterator iterator = this.subCategories.iterator(); while (iterator.hasNext()) { Comparable subcategory = (Comparable) iterator.next(); String label = subcategory.toString(); Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm); double dim = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { dim = bounds.getWidth(); } else { // must be top or bottom dim = bounds.getHeight(); } result = Math.max(result, dim); } return result; } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (null not permitted). * @param dataArea the area within which the plot is being drawn * (null not permitted). * @param edge the location of the axis (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } // draw the category labels and axis label AxisState state = new AxisState(cursor); state = drawSubCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, plotState); state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); return state; } /** * Draws the category labels and returns the updated axis state. * * @param g2 the graphics device (null not permitted). * @param plotArea the plot area (null not permitted). * @param dataArea the area inside the axes (null not * permitted). * @param edge the axis location (null not permitted). * @param state the axis state (null not permitted). * @param plotState collects information about the plot (null * permitted). * * @return The updated axis state (never null). */ protected AxisState drawSubCategoryLabels(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { if (state == null) { throw new IllegalArgumentException("Null 'state' argument."); } g2.setFont(this.subLabelFont); g2.setPaint(this.subLabelPaint); CategoryPlot plot = (CategoryPlot) getPlot(); int categoryCount = 0; CategoryDataset dataset = plot.getDataset(); if (dataset != null) { categoryCount = dataset.getColumnCount(); } double maxdim = getMaxDim(g2, edge); for (int categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) { double x0 = 0.0; double x1 = 0.0; double y0 = 0.0; double y1 = 0.0; if (edge == RectangleEdge.TOP) { x0 = getCategoryStart(categoryIndex, categoryCount, dataArea, edge); x1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, edge); y1 = state.getCursor(); y0 = y1 - maxdim; } else if (edge == RectangleEdge.BOTTOM) { x0 = getCategoryStart(categoryIndex, categoryCount, dataArea, edge); x1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, edge); y0 = state.getCursor(); y1 = y0 + maxdim; } else if (edge == RectangleEdge.LEFT) { y0 = getCategoryStart(categoryIndex, categoryCount, dataArea, edge); y1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, edge); x1 = state.getCursor(); x0 = x1 - maxdim; } else if (edge == RectangleEdge.RIGHT) { y0 = getCategoryStart(categoryIndex, categoryCount, dataArea, edge); y1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, edge); x0 = state.getCursor(); x1 = x0 + maxdim; } Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); int subCategoryCount = this.subCategories.size(); float width = (float) ((x1 - x0) / subCategoryCount); float height = (float) ((y1 - y0) / subCategoryCount); float xx = 0.0f; float yy = 0.0f; for (int i = 0; i < subCategoryCount; i++) { if (RectangleEdge.isTopOrBottom(edge)) { xx = (float) (x0 + (i + 0.5) * width); yy = (float) area.getCenterY(); } else { xx = (float) area.getCenterX(); yy = (float) (y0 + (i + 0.5) * height); } String label = this.subCategories.get(i).toString(); TextUtilities.drawRotatedString(label, g2, xx, yy, TextAnchor.CENTER, 0.0, TextAnchor.CENTER); } } if (edge.equals(RectangleEdge.TOP)) { double h = maxdim; state.cursorUp(h); } else if (edge.equals(RectangleEdge.BOTTOM)) { double h = maxdim; state.cursorDown(h); } else if (edge == RectangleEdge.LEFT) { double w = maxdim; state.cursorLeft(w); } else if (edge == RectangleEdge.RIGHT) { double w = maxdim; state.cursorRight(w); } return state; } /** * Tests the axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof SubCategoryAxis && super.equals(obj)) { SubCategoryAxis axis = (SubCategoryAxis) obj; if (!this.subCategories.equals(axis.subCategories)) { return false; } if (!this.subLabelFont.equals(axis.subLabelFont)) { return false; } if (!this.subLabelPaint.equals(axis.subLabelPaint)) { return false; } return true; } return false; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.subLabelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.subLabelPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/SymbolAxis.java0000644000175000017500000007433411173030414026345 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * SymbolAxis.java * --------------- * (C) Copyright 2002-2008, by Anthony Boulestreau and Contributors. * * Original Author: Anthony Boulestreau; * Contributor(s): David Gilbert (for Object Refinery Limited); * * * Changes * ------- * 29-Mar-2002 : First version (AB); * 19-Apr-2002 : Updated formatting and import statements (DG); * 21-Jun-2002 : Make change to use the class TickUnit - remove valueToString() * method and add SymbolicTickUnit (AB); * 25-Jun-2002 : Removed redundant code (DG); * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); * 05-Sep-2002 : Updated constructor to reflect changes in the Axis class (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 14-Feb-2003 : Added back missing constructor code (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 14-May-2003 : Renamed HorizontalSymbolicAxis --> SymbolicAxis and merged in * VerticalSymbolicAxis (DG); * 12-Aug-2003 : Fixed bug where refreshTicks() method has different signature * to super class (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 02-Nov-2003 : Added code to avoid overlapping labels (MR); * 07-Nov-2003 : Modified to use new tick classes (DG); * 18-Nov-2003 : Fixed bug where symbols are not being displayed on the * axis (DG); * 24-Nov-2003 : Added fix for gridlines on zooming (bug id 834643) (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 11-Mar-2004 : Modified the way the background grid color is being drawn, see * this thread: * http://www.jfree.org/phpBB2/viewtopic.php?p=22973 (DG); * 16-Mar-2004 : Added plotState to draw() method (DG); * 07-Apr-2004 : Modified string bounds calculation (DG); * 28-Mar-2005 : Renamed autoRangeIncludesZero() --> getAutoRangeIncludesZero() * and autoRangeStickyZero() --> getAutoRangeStickyZero() (DG); * 05-Jul-2005 : Fixed signature on refreshTicks() method - see bug report * 1232264 (DG); * 06-Jul-2005 : Renamed SymbolicAxis --> SymbolAxis, added equals() method, * renamed getSymbolicValue() --> getSymbols(), renamed * symbolicGridPaint --> gridBandPaint, fixed serialization of * gridBandPaint, renamed symbolicGridLinesVisible --> * gridBandsVisible, eliminated symbolicGridLineList (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 28-Feb-2007 : Fixed bug 1669302 (tick label overlap) (DG); * 25-Jul-2007 : Added new field for alternate grid band paint (DG); * 15-Aug-2008 : Use alternate grid band paint when drawing (DG); * */ package org.jfree.chart.axis; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.text.NumberFormat; import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.PaintUtilities; /** * A standard linear value axis that replaces integer values with symbols. */ public class SymbolAxis extends NumberAxis implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7216330468770619716L; /** The default grid band paint. */ public static final Paint DEFAULT_GRID_BAND_PAINT = new Color(232, 234, 232, 128); /** * The default paint for alternate grid bands. * * @since 1.0.7 */ public static final Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT = new Color(0, 0, 0, 0); // transparent /** The list of symbols to display instead of the numeric values. */ private List symbols; /** Flag that indicates whether or not grid bands are visible. */ private boolean gridBandsVisible; /** The paint used to color the grid bands (if the bands are visible). */ private transient Paint gridBandPaint; /** * The paint used to fill the alternate grid bands. * * @since 1.0.7 */ private transient Paint gridBandAlternatePaint; /** * Constructs a symbol axis, using default attribute values where * necessary. * * @param label the axis label (null permitted). * @param sv the list of symbols to display instead of the numeric * values. */ public SymbolAxis(String label, String[] sv) { super(label); this.symbols = Arrays.asList(sv); this.gridBandsVisible = true; this.gridBandPaint = DEFAULT_GRID_BAND_PAINT; this.gridBandAlternatePaint = DEFAULT_GRID_BAND_ALTERNATE_PAINT; setAutoTickUnitSelection(false, false); setAutoRangeStickyZero(false); } /** * Returns an array of the symbols for the axis. * * @return The symbols. */ public String[] getSymbols() { String[] result = new String[this.symbols.size()]; result = (String[]) this.symbols.toArray(result); return result; } /** * Returns true if the grid bands are showing, and * false otherwise. * * @return true if the grid bands are showing, and * false otherwise. * * @see #setGridBandsVisible(boolean) */ public boolean isGridBandsVisible() { return this.gridBandsVisible; } /** * Sets the visibility of the grid bands and notifies registered * listeners that the axis has been modified. * * @param flag the new setting. * * @see #isGridBandsVisible() */ public void setGridBandsVisible(boolean flag) { if (this.gridBandsVisible != flag) { this.gridBandsVisible = flag; notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the paint used to color the grid bands. * * @return The grid band paint (never null). * * @see #setGridBandPaint(Paint) * @see #isGridBandsVisible() */ public Paint getGridBandPaint() { return this.gridBandPaint; } /** * Sets the grid band paint and sends an {@link AxisChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getGridBandPaint() */ public void setGridBandPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.gridBandPaint = paint; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the paint used for alternate grid bands. * * @return The paint (never null). * * @see #setGridBandAlternatePaint(Paint) * @see #getGridBandPaint() * * @since 1.0.7 */ public Paint getGridBandAlternatePaint() { return this.gridBandAlternatePaint; } /** * Sets the paint used for alternate grid bands and sends a * {@link AxisChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getGridBandAlternatePaint() * @see #setGridBandPaint(Paint) * * @since 1.0.7 */ public void setGridBandAlternatePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.gridBandAlternatePaint = paint; notifyListeners(new AxisChangeEvent(this)); } /** * This operation is not supported by this axis. * * @param g2 the graphics device. * @param dataArea the area in which the plot and axes should be drawn. * @param edge the edge along which the axis is drawn. */ protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { throw new UnsupportedOperationException(); } /** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (null not permitted). * @param cursor the cursor location. * @param plotArea the area within which the plot and axes should be drawn * (null not permitted). * @param dataArea the area within which the data should be drawn * (null not permitted). * @param edge the axis location (null not permitted). * @param plotState collects information about the plot * (null permitted). * * @return The axis state (never null). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState info = new AxisState(cursor); if (isVisible()) { info = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); } if (this.gridBandsVisible) { drawGridBands(g2, plotArea, dataArea, edge, info.getTicks()); } return info; } /** * Draws the grid bands. Alternate bands are colored using * gridBandPaint (DEFAULT_GRID_BAND_PAINT by * default). * * @param g2 the graphics device. * @param plotArea the area within which the chart should be drawn. * @param dataArea the area within which the plot should be drawn (a * subset of the drawArea). * @param edge the axis location. * @param ticks the ticks. */ protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, List ticks) { Shape savedClip = g2.getClip(); g2.clip(dataArea); if (RectangleEdge.isTopOrBottom(edge)) { drawGridBandsHorizontal(g2, plotArea, dataArea, true, ticks); } else if (RectangleEdge.isLeftOrRight(edge)) { drawGridBandsVertical(g2, plotArea, dataArea, true, ticks); } g2.setClip(savedClip); } /** * Draws the grid bands for the axis when it is at the top or bottom of * the plot. * * @param g2 the graphics device. * @param plotArea the area within which the chart should be drawn. * @param dataArea the area within which the plot should be drawn * (a subset of the drawArea). * @param firstGridBandIsDark True: the first grid band takes the * color of gridBandPaint. * False: the second grid band takes the * color of gridBandPaint. * @param ticks the ticks. */ protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, boolean firstGridBandIsDark, List ticks) { boolean currentGridBandIsDark = firstGridBandIsDark; double yy = dataArea.getY(); double xx1, xx2; //gets the outline stroke width of the plot double outlineStrokeWidth; if (getPlot().getOutlineStroke() != null) { outlineStrokeWidth = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth(); } else { outlineStrokeWidth = 1d; } Iterator iterator = ticks.iterator(); ValueTick tick; Rectangle2D band; while (iterator.hasNext()) { tick = (ValueTick) iterator.next(); xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, RectangleEdge.BOTTOM); xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, RectangleEdge.BOTTOM); if (currentGridBandIsDark) { g2.setPaint(this.gridBandPaint); } else { g2.setPaint(this.gridBandAlternatePaint); } band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, xx2 - xx1, dataArea.getMaxY() - yy - outlineStrokeWidth); g2.fill(band); currentGridBandIsDark = !currentGridBandIsDark; } g2.setPaintMode(); } /** * Draws the grid bands for the axis when it is at the top or bottom of * the plot. * * @param g2 the graphics device. * @param drawArea the area within which the chart should be drawn. * @param plotArea the area within which the plot should be drawn (a * subset of the drawArea). * @param firstGridBandIsDark True: the first grid band takes the * color of gridBandPaint. * False: the second grid band takes the * color of gridBandPaint. * @param ticks a list of ticks. */ protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, Rectangle2D plotArea, boolean firstGridBandIsDark, List ticks) { boolean currentGridBandIsDark = firstGridBandIsDark; double xx = plotArea.getX(); double yy1, yy2; //gets the outline stroke width of the plot double outlineStrokeWidth; Stroke outlineStroke = getPlot().getOutlineStroke(); if (outlineStroke != null && outlineStroke instanceof BasicStroke) { outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth(); } else { outlineStrokeWidth = 1d; } Iterator iterator = ticks.iterator(); ValueTick tick; Rectangle2D band; while (iterator.hasNext()) { tick = (ValueTick) iterator.next(); yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, RectangleEdge.LEFT); yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, RectangleEdge.LEFT); if (currentGridBandIsDark) { g2.setPaint(this.gridBandPaint); } else { g2.setPaint(this.gridBandAlternatePaint); } band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1, plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1); g2.fill(band); currentGridBandIsDark = !currentGridBandIsDark; } g2.setPaintMode(); } /** * Rescales the axis to ensure that all data is visible. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { // ensure that all the symbols are displayed double upper = this.symbols.size() - 1; double lower = 0; double range = upper - lower; // ensure the autorange is at least in size... double minRange = getAutoRangeMinimumSize(); if (range < minRange) { upper = (upper + lower + minRange) / 2; lower = (upper + lower - minRange) / 2; } // this ensure that the grid bands will be displayed correctly. double upperMargin = 0.5; double lowerMargin = 0.5; if (getAutoRangeIncludesZero()) { if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = 0.0; } else { upper = upper + upperMargin; } if (lower >= 0.0) { lower = 0.0; } else { lower = lower - lowerMargin; } } else { upper = Math.max(0.0, upper + upperMargin); lower = Math.min(0.0, lower - lowerMargin); } } else { if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = Math.min(0.0, upper + upperMargin); } else { upper = upper + upperMargin * range; } if (lower >= 0.0) { lower = Math.max(0.0, lower - lowerMargin); } else { lower = lower - lowerMargin; } } else { upper = upper + upperMargin; lower = lower - lowerMargin; } } setRange(new Range(lower, upper), false, false); } } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the area in which the data should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List ticks = null; if (RectangleEdge.isTopOrBottom(edge)) { ticks = refreshTicksHorizontal(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { ticks = refreshTicksVertical(g2, dataArea, edge); } return ticks; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the data should be drawn. * @param edge the location of the axis. * * @return The ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); double previousDrawnTickLabelPos = 0.0; double previousDrawnTickLabelLength = 0.0; if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double xx = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = xx; previousDrawnTickLabelLength = tickLabelLength; } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } return ticks; } /** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return The ticks. */ protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); double previousDrawnTickLabelPos = 0.0; double previousDrawnTickLabelLength = 0.0; if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = yy; previousDrawnTickLabelLength = tickLabelLength; } TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; if (edge == RectangleEdge.LEFT) { angle = -Math.PI / 2.0; } else { angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } return ticks; } /** * Converts a value to a string, using the list of symbols. * * @param value value to convert. * * @return The symbol. */ public String valueToString(double value) { String strToReturn; try { strToReturn = (String) this.symbols.get((int) value); } catch (IndexOutOfBoundsException ex) { strToReturn = ""; } return strToReturn; } /** * Tests this axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SymbolAxis)) { return false; } SymbolAxis that = (SymbolAxis) obj; if (!this.symbols.equals(that.symbols)) { return false; } if (this.gridBandsVisible != that.gridBandsVisible) { return false; } if (!PaintUtilities.equal(this.gridBandPaint, that.gridBandPaint)) { return false; } if (!PaintUtilities.equal(this.gridBandAlternatePaint, that.gridBandAlternatePaint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.gridBandPaint, stream); SerialUtilities.writePaint(this.gridBandAlternatePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.gridBandPaint = SerialUtilities.readPaint(stream); this.gridBandAlternatePaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/Tick.java0000644000175000017500000001300111173030414025125 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Tick.java * --------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; * * Changes * ------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 12-Sep-2003 : Implemented Cloneable (NB); * 07-Nov-2003 : Added subclasses for particular types of ticks (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; /** * The base class used to represent labelled ticks along an axis. */ public abstract class Tick implements Serializable, Cloneable { /** For serialization. */ private static final long serialVersionUID = 6668230383875149773L; /** A text version of the tick value. */ private String text; /** The text anchor for the tick label. */ private TextAnchor textAnchor; /** The rotation anchor for the tick label. */ private TextAnchor rotationAnchor; /** The rotation angle. */ private double angle; /** * Creates a new tick. * * @param text the formatted version of the tick value. * @param textAnchor the text anchor (null not permitted). * @param rotationAnchor the rotation anchor (null not * permitted). * @param angle the angle. */ public Tick(String text, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { if (textAnchor == null) { throw new IllegalArgumentException("Null 'textAnchor' argument."); } if (rotationAnchor == null) { throw new IllegalArgumentException( "Null 'rotationAnchor' argument." ); } this.text = text; this.textAnchor = textAnchor; this.rotationAnchor = rotationAnchor; this.angle = angle; } /** * Returns the text version of the tick value. * * @return A string (possibly null; */ public String getText() { return this.text; } /** * Returns the text anchor. * * @return The text anchor (never null). */ public TextAnchor getTextAnchor() { return this.textAnchor; } /** * Returns the text anchor that defines the point around which the label is * rotated. * * @return A text anchor (never null). */ public TextAnchor getRotationAnchor() { return this.rotationAnchor; } /** * Returns the angle. * * @return The angle. */ public double getAngle() { return this.angle; } /** * Tests this tick for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Tick) { Tick t = (Tick) obj; if (!ObjectUtilities.equal(this.text, t.text)) { return false; } if (!ObjectUtilities.equal(this.textAnchor, t.textAnchor)) { return false; } if (!ObjectUtilities.equal(this.rotationAnchor, t.rotationAnchor)) { return false; } if (!(this.angle == t.angle)) { return false; } return true; } return false; } /** * Returns a clone of the tick. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { Tick clone = (Tick) super.clone(); return clone; } /** * Returns a string representation of the tick. * * @return A string. */ public String toString() { return this.text; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/TickType.java0000644000175000017500000000650611173030414026003 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * TickType.java * ------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Aug-2007 : Version 1 (DG); * */ package org.jfree.chart.axis; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the tick type (MAJOR or MINOR). * * @since 1.0.7 */ public final class TickType implements Serializable { /** Major tick. */ public static final TickType MAJOR = new TickType("MAJOR"); /** Minor tick. */ public static final TickType MINOR = new TickType("MINOR"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private TickType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof TickType)) { return false; } TickType that = (TickType) obj; if (!this.name.equals(that.name)) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { Object result = null; if (this.equals(TickType.MAJOR)) { result = TickType.MAJOR; } else if (this.equals(TickType.MINOR)) { result = TickType.MINOR; } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/TickUnit.java0000644000175000017500000001316111173030414025774 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * TickUnit.java * ------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Dec-2001 : Added standard header (DG); * 01-May-2002 : Changed the unit size from Number to double (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 05-Sep-2005 : Implemented hashCode(), thanks to Thomas Morgner (DG); * 02-Aug-2007 : Added minorTickCount attribute (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; /** * Base class representing a tick unit. This determines the spacing of the * tick marks on an axis. *

* This class (and any subclasses) should be immutable, the reason being that * ORDERED collections of tick units are maintained and if one instance can be * changed, it may destroy the order of the collection that it belongs to. * In addition, if the implementations are immutable, they can belong to * multiple collections. * * @see ValueAxis */ public abstract class TickUnit implements Comparable, Serializable { /** For serialization. */ private static final long serialVersionUID = 510179855057013974L; /** The size of the tick unit. */ private double size; /** * The number of minor ticks. * * @since 1.0.7 */ private int minorTickCount; /** * Constructs a new tick unit. * * @param size the tick unit size. */ public TickUnit(double size) { this.size = size; } /** * Constructs a new tick unit. * * @param size the tick unit size. * @param minorTickCount the minor tick count. * * @since 1.0.7 */ public TickUnit(double size, int minorTickCount) { this.size = size; this.minorTickCount = minorTickCount; } /** * Returns the size of the tick unit. * * @return The size of the tick unit. */ public double getSize() { return this.size; } /** * Returns the minor tick count. * * @return The minor tick count. * * @since 1.0.7 */ public int getMinorTickCount() { return this.minorTickCount; } /** * Converts the supplied value to a string. *

* Subclasses may implement special formatting by overriding this method. * * @param value the data value. * * @return Value as string. */ public String valueToString(double value) { return String.valueOf(value); } /** * Compares this tick unit to an arbitrary object. * * @param object the object to compare against. * * @return 1 if the size of the other object is less than this, * 0 if both have the same size and -1 this * size is less than the others. */ public int compareTo(Object object) { if (object instanceof TickUnit) { TickUnit other = (TickUnit) object; if (this.size > other.getSize()) { return 1; } else if (this.size < other.getSize()) { return -1; } else { return 0; } } else { return -1; } } /** * Tests this unit for equality with another object. * * @param obj the object. * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TickUnit)) { return false; } TickUnit that = (TickUnit) obj; if (this.size != that.size) { return false; } if (this.minorTickCount != that.minorTickCount) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { long temp = this.size != +0.0d ? Double.doubleToLongBits(this.size) : 0L; return (int) (temp ^ (temp >>> 32)); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/TickUnitSource.java0000644000175000017500000000476211173030414027164 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * TickUnitSource.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Sep-2003 : Version 1 (DG); * */ package org.jfree.chart.axis; /** * An interface used by the {@link DateAxis} and {@link NumberAxis} classes to * obtain a suitable {@link TickUnit}. */ public interface TickUnitSource { /** * Returns a tick unit that is larger than the supplied unit. * * @param unit the unit. * * @return A tick unit that is larger than the supplied unit. */ public TickUnit getLargerTickUnit(TickUnit unit); /** * Returns the tick unit in the collection that is greater than or equal * to (in size) the specified unit. * * @param unit the unit. * * @return A unit from the collection. */ public TickUnit getCeilingTickUnit(TickUnit unit); /** * Returns the tick unit in the collection that is greater than or equal * to the specified size. * * @param size the size. * * @return A unit from the collection. */ public TickUnit getCeilingTickUnit(double size); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/TickUnits.java0000644000175000017500000001502311173030414026156 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * TickUnits.java * -------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Nov-2001 : Version 1 (DG); * 18-Feb-2002 : Fixed bug in getNearestTickUnit (thanks to Mario Inchiosa for * reporting this, SourceForge bug id 518073) (DG); * 25-Feb-2002 : Moved createStandardTickUnits() method from NumberAxis, and * added createIntegerTickUnits() method (DG); * 01-May-2002 : Updated for changes to the TickUnit class (DG); * 18-Sep-2002 : Added standardTickUnit methods which take a Locale * instance (AS); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 23-Sep-2003 : Implemented TickUnitSource interface (DG); * 03-Dec-2003 : Adding null values now throws exceptions (TM); * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * */ package org.jfree.chart.axis; import java.io.Serializable; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * A collection of tick units, used by the {@link DateAxis} and * {@link NumberAxis} classes. */ public class TickUnits implements TickUnitSource, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1134174035901467545L; /** Storage for the tick units. */ private List tickUnits; /** * Constructs a new collection of tick units. */ public TickUnits() { this.tickUnits = new ArrayList(); } /** * Adds a tick unit to the collection. The tick units are maintained in * ascending order. * * @param unit the tick unit to add (null not permitted). */ public void add(TickUnit unit) { if (unit == null) { throw new NullPointerException("Null 'unit' argument."); } this.tickUnits.add(unit); Collections.sort(this.tickUnits); } /** * Returns the number of tick units in this collection. *

* This method is required for the XML writer. * * @return The number of units in this collection. */ public int size() { return this.tickUnits.size(); } /** * Returns the tickunit on the given position. *

* This method is required for the XML writer. * * @param pos the position in the list. * * @return The tickunit. */ public TickUnit get(int pos) { return (TickUnit) this.tickUnits.get(pos); } /** * Returns a tick unit that is larger than the supplied unit. * * @param unit the unit. * * @return A tick unit that is larger than the supplied unit. */ public TickUnit getLargerTickUnit(TickUnit unit) { int index = Collections.binarySearch(this.tickUnits, unit); if (index >= 0) { index = index + 1; } else { index = -index; } return (TickUnit) this.tickUnits.get(Math.min(index, this.tickUnits.size() - 1)); } /** * Returns the tick unit in the collection that is greater than or equal * to (in size) the specified unit. * * @param unit the unit. * * @return A unit from the collection. */ public TickUnit getCeilingTickUnit(TickUnit unit) { int index = Collections.binarySearch(this.tickUnits, unit); if (index >= 0) { return (TickUnit) this.tickUnits.get(index); } else { index = -(index + 1); return (TickUnit) this.tickUnits.get(Math.min(index, this.tickUnits.size() - 1)); } } /** * Returns the tick unit in the collection that is greater than or equal * to the specified size. * * @param size the size. * * @return A unit from the collection. */ public TickUnit getCeilingTickUnit(double size) { return getCeilingTickUnit(new NumberTickUnit(size, NumberFormat.getInstance())); } /** * Returns a clone of the collection. * * @return A clone. * * @throws CloneNotSupportedException if an item in the collection does not * support cloning. */ public Object clone() throws CloneNotSupportedException { TickUnits clone = (TickUnits) super.clone(); clone.tickUnits = new java.util.ArrayList(this.tickUnits); return clone; } /** * Tests an object for equality with this instance. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TickUnits)) { return false; } TickUnits that = (TickUnits) obj; return that.tickUnits.equals(this.tickUnits); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/Timeline.java0000644000175000017500000001325511173030414026014 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * Timeline.java * ------------- * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 23-May-2003 : Version 1 (BK); * 09-Sep-2003 : Changed some method and parameter names (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.axis; import java.util.Date; /** * An interface that defines the contract for a Timeline. *

* A Timeline will present a series of values to be used for an axis. Each * Timeline must provide transformation methods between domain values and * timeline values. In theory many transformations are possible. This interface * has been implemented completely in * {@link org.jfree.chart.axis.SegmentedTimeline}. *

* A timeline can be used as parameter to a * {@link org.jfree.chart.axis.DateAxis} to define the values that this axis * supports. As an example, the {@link org.jfree.chart.axis.SegmentedTimeline} * implements a timeline formed by segments of equal length (ex. days, hours, * minutes) where some segments can be included in the timeline and others * excluded. Therefore timelines like "working days" or "working hours" can be * created where non-working days or non-working hours respectively can be * removed from the timeline, and therefore from the axis. This creates a smooth * plot with equal separation between all included segments. *

* Because Timelines were created mainly for Date related axis, values are * represented as longs instead of doubles. In this case, the domain value is * just the number of milliseconds since January 1, 1970, 00:00:00 GMT as * defined by the getTime() method of {@link java.util.Date}. * * @see org.jfree.chart.axis.SegmentedTimeline * @see org.jfree.chart.axis.DateAxis */ public interface Timeline { /** * Translates a millisecond (as defined by java.util.Date) into an index * along this timeline. * * @param millisecond the millisecond. * * @return A timeline value. */ long toTimelineValue(long millisecond); /** * Translates a date into a value on this timeline. * * @param date the date. * * @return A timeline value */ long toTimelineValue(Date date); /** * Translates a value relative to this timeline into a domain value. The * domain value obtained by this method is not always the same domain value * that could have been supplied to * translateDomainValueToTimelineValue(domainValue). * This is because the original tranformation may not be complete * reversable. * * @see org.jfree.chart.axis.SegmentedTimeline * * @param timelineValue a timeline value. * * @return A domain value. */ long toMillisecond(long timelineValue); /** * Returns true if a value is contained in the timeline values. * * @param millisecond the millisecond. * * @return true if value is contained in the timeline and * false otherwise. */ boolean containsDomainValue(long millisecond); /** * Returns true if a date is contained in the timeline values. * * @param date the date to verify. * * @return true if value is contained in the timeline and * false otherwise. */ boolean containsDomainValue(Date date); /** * Returns true if a range of values are contained in the * timeline. * * @param fromMillisecond the start of the range to verify. * @param toMillisecond the end of the range to verify. * * @return true if the range is contained in the timeline or * false otherwise */ boolean containsDomainRange(long fromMillisecond, long toMillisecond); /** * Returns true if a range of dates are contained in the * timeline. * * @param fromDate the start of the range to verify. * @param toDate the end of the range to verify. * * @return true if the range is contained in the timeline or * false otherwise */ boolean containsDomainRange(Date fromDate, Date toDate); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/ValueAxis.java0000644000175000017500000016756111173030414026161 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * ValueAxis.java * -------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Jonathan Nash; * Nicolas Brodu (for Astrium and EADS Corporate Research * Center); * Peter Kolb (patch 1934255); * Andrew Mickish (patch 1870189); * * Changes * ------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 23-Nov-2001 : Overhauled standard tick unit code (DG); * 04-Dec-2001 : Changed constructors to protected, and tidied up default * values (DG); * 12-Dec-2001 : Fixed vertical gridlines bug (DG); * 16-Jan-2002 : Added an optional crosshair, based on the implementation by * Jonathan Nash (DG); * 23-Jan-2002 : Moved the minimum and maximum values to here from NumberAxis, * and changed the type from Number to double (DG); * 25-Feb-2002 : Added default value for autoRange. Changed autoAdjustRange * from public to protected. Updated import statements (DG); * 23-Apr-2002 : Added setRange() method (DG); * 29-Apr-2002 : Added range adjustment methods (DG); * 13-Jun-2002 : Modified setCrosshairValue() to notify listeners only when the * crosshairs are visible, to avoid unnecessary repaints, as * suggested by Kees Kuip (DG); * 25-Jul-2002 : Moved lower and upper margin attributes from the NumberAxis * class (DG); * 05-Sep-2002 : Updated constructor for changes in Axis class (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 04-Oct-2002 : Moved standardTickUnits from NumberAxis --> ValueAxis (DG); * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); * 19-Nov-2002 : Removed grid settings (now controlled by the plot) (DG); * 27-Nov-2002 : Moved the 'inverted' attributed from NumberAxis to * ValueAxis (DG); * 03-Jan-2003 : Small fix to ensure auto-range minimum is observed * immediately (DG); * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double (DG); * 20-Jan-2003 : Replaced monolithic constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 09-May-2003 : Added AxisLocation parameter to translation methods (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 01-Sep-2003 : Fixed bug 793167 (setMaximumAxisValue exception) (DG); * 02-Sep-2003 : Fixed bug 795366 (zooming on inverted axes) (DG); * 08-Sep-2003 : Completed Serialization support (NB); * 08-Sep-2003 : Renamed get/setMinimumValue --> get/setLowerBound, * and get/setMaximumValue --> get/setUpperBound (DG); * 27-Oct-2003 : Changed DEFAULT_AUTO_RANGE_MINIMUM_SIZE value - see bug ID * 829606 (DG); * 07-Nov-2003 : Changes to tick mechanism (DG); * 06-Jan-2004 : Moved axis line attributes to Axis class (DG); * 21-Jan-2004 : Removed redundant axisLineVisible attribute. Renamed * translateJava2DToValue --> java2DToValue, and * translateValueToJava2D --> valueToJava2D (DG); * 23-Jan-2004 : Fixed setAxisLinePaint() and setAxisLineStroke() which had no * effect (andreas.gawecki@coremedia.com); * 07-Apr-2004 : Changed text bounds calculation (DG); * 26-Apr-2004 : Added getter/setter methods for arrow shapes (DG); * 18-May-2004 : Added methods to set axis range *including* current * margins (DG); * 02-Jun-2004 : Fixed bug in setRangeWithMargins() method (DG); * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities * --> TextUtilities (DG); * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 10-Oct-2006 : Source reformatting (DG); * 22-Mar-2007 : Added new defaultAutoRange attribute (DG); * 02-Aug-2007 : Check for major tick when drawing label (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * 21-Jan-2009 : Updated default behaviour of minor ticks (DG); * 18-Mar-2008 : Added resizeRange2() method which provides more natural * anchored zooming for mouse wheel support (DG); * 26-Mar-2009 : In equals(), only check current range if autoRange is * false (DG); * 30-Mar-2009 : Added pan(double) method (DG); * */ package org.jfree.chart.axis; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.Shape; import java.awt.font.LineMetrics; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * The base class for axes that display value data, where values are measured * using the double primitive. The two key subclasses are * {@link DateAxis} and {@link NumberAxis}. */ public abstract class ValueAxis extends Axis implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3698345477322391456L; /** The default axis range. */ public static final Range DEFAULT_RANGE = new Range(0.0, 1.0); /** The default auto-range value. */ public static final boolean DEFAULT_AUTO_RANGE = true; /** The default inverted flag setting. */ public static final boolean DEFAULT_INVERTED = false; /** The default minimum auto range. */ public static final double DEFAULT_AUTO_RANGE_MINIMUM_SIZE = 0.00000001; /** The default value for the lower margin (0.05 = 5%). */ public static final double DEFAULT_LOWER_MARGIN = 0.05; /** The default value for the upper margin (0.05 = 5%). */ public static final double DEFAULT_UPPER_MARGIN = 0.05; /** * The default lower bound for the axis. * * @deprecated From 1.0.5 onwards, the axis defines a defaultRange * attribute (see {@link #getDefaultAutoRange()}). */ public static final double DEFAULT_LOWER_BOUND = 0.0; /** * The default upper bound for the axis. * * @deprecated From 1.0.5 onwards, the axis defines a defaultRange * attribute (see {@link #getDefaultAutoRange()}). */ public static final double DEFAULT_UPPER_BOUND = 1.0; /** The default auto-tick-unit-selection value. */ public static final boolean DEFAULT_AUTO_TICK_UNIT_SELECTION = true; /** The maximum tick count. */ public static final int MAXIMUM_TICK_COUNT = 500; /** * A flag that controls whether an arrow is drawn at the positive end of * the axis line. */ private boolean positiveArrowVisible; /** * A flag that controls whether an arrow is drawn at the negative end of * the axis line. */ private boolean negativeArrowVisible; /** The shape used for an up arrow. */ private transient Shape upArrow; /** The shape used for a down arrow. */ private transient Shape downArrow; /** The shape used for a left arrow. */ private transient Shape leftArrow; /** The shape used for a right arrow. */ private transient Shape rightArrow; /** A flag that affects the orientation of the values on the axis. */ private boolean inverted; /** The axis range. */ private Range range; /** * Flag that indicates whether the axis automatically scales to fit the * chart data. */ private boolean autoRange; /** The minimum size for the 'auto' axis range (excluding margins). */ private double autoRangeMinimumSize; /** * The default range is used when the dataset is empty and the axis needs * to determine the auto range. * * @since 1.0.5 */ private Range defaultAutoRange; /** * The upper margin percentage. This indicates the amount by which the * maximum axis value exceeds the maximum data value (as a percentage of * the range on the axis) when the axis range is determined automatically. */ private double upperMargin; /** * The lower margin. This is a percentage that indicates the amount by * which the minimum axis value is "less than" the minimum data value when * the axis range is determined automatically. */ private double lowerMargin; /** * If this value is positive, the amount is subtracted from the maximum * data value to determine the lower axis range. This can be used to * provide a fixed "window" on dynamic data. */ private double fixedAutoRange; /** * Flag that indicates whether or not the tick unit is selected * automatically. */ private boolean autoTickUnitSelection; /** The standard tick units for the axis. */ private TickUnitSource standardTickUnits; /** An index into an array of standard tick values. */ private int autoTickIndex; /** * The number of minor ticks per major tick unit. This is an override * field, if the value is > 0 it is used, otherwise the axis refers to the * minorTickCount in the current tickUnit. */ private int minorTickCount; /** A flag indicating whether or not tick labels are rotated to vertical. */ private boolean verticalTickLabels; /** * Constructs a value axis. * * @param label the axis label (null permitted). * @param standardTickUnits the source for standard tick units * (null permitted). */ protected ValueAxis(String label, TickUnitSource standardTickUnits) { super(label); this.positiveArrowVisible = false; this.negativeArrowVisible = false; this.range = DEFAULT_RANGE; this.autoRange = DEFAULT_AUTO_RANGE; this.defaultAutoRange = DEFAULT_RANGE; this.inverted = DEFAULT_INVERTED; this.autoRangeMinimumSize = DEFAULT_AUTO_RANGE_MINIMUM_SIZE; this.lowerMargin = DEFAULT_LOWER_MARGIN; this.upperMargin = DEFAULT_UPPER_MARGIN; this.fixedAutoRange = 0.0; this.autoTickUnitSelection = DEFAULT_AUTO_TICK_UNIT_SELECTION; this.standardTickUnits = standardTickUnits; Polygon p1 = new Polygon(); p1.addPoint(0, 0); p1.addPoint(-2, 2); p1.addPoint(2, 2); this.upArrow = p1; Polygon p2 = new Polygon(); p2.addPoint(0, 0); p2.addPoint(-2, -2); p2.addPoint(2, -2); this.downArrow = p2; Polygon p3 = new Polygon(); p3.addPoint(0, 0); p3.addPoint(-2, -2); p3.addPoint(-2, 2); this.rightArrow = p3; Polygon p4 = new Polygon(); p4.addPoint(0, 0); p4.addPoint(2, -2); p4.addPoint(2, 2); this.leftArrow = p4; this.verticalTickLabels = false; this.minorTickCount = 0; } /** * Returns true if the tick labels should be rotated (to * vertical), and false otherwise. * * @return true or false. * * @see #setVerticalTickLabels(boolean) */ public boolean isVerticalTickLabels() { return this.verticalTickLabels; } /** * Sets the flag that controls whether the tick labels are displayed * vertically (that is, rotated 90 degrees from horizontal). If the flag * is changed, an {@link AxisChangeEvent} is sent to all registered * listeners. * * @param flag the flag. * * @see #isVerticalTickLabels() */ public void setVerticalTickLabels(boolean flag) { if (this.verticalTickLabels != flag) { this.verticalTickLabels = flag; notifyListeners(new AxisChangeEvent(this)); } } /** * Returns a flag that controls whether or not the axis line has an arrow * drawn that points in the positive direction for the axis. * * @return A boolean. * * @see #setPositiveArrowVisible(boolean) */ public boolean isPositiveArrowVisible() { return this.positiveArrowVisible; } /** * Sets a flag that controls whether or not the axis lines has an arrow * drawn that points in the positive direction for the axis, and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #isPositiveArrowVisible() */ public void setPositiveArrowVisible(boolean visible) { this.positiveArrowVisible = visible; notifyListeners(new AxisChangeEvent(this)); } /** * Returns a flag that controls whether or not the axis line has an arrow * drawn that points in the negative direction for the axis. * * @return A boolean. * * @see #setNegativeArrowVisible(boolean) */ public boolean isNegativeArrowVisible() { return this.negativeArrowVisible; } /** * Sets a flag that controls whether or not the axis lines has an arrow * drawn that points in the negative direction for the axis, and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #setNegativeArrowVisible(boolean) */ public void setNegativeArrowVisible(boolean visible) { this.negativeArrowVisible = visible; notifyListeners(new AxisChangeEvent(this)); } /** * Returns a shape that can be displayed as an arrow pointing upwards at * the end of an axis line. * * @return A shape (never null). * * @see #setUpArrow(Shape) */ public Shape getUpArrow() { return this.upArrow; } /** * Sets the shape that can be displayed as an arrow pointing upwards at * the end of an axis line and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param arrow the arrow shape (null not permitted). * * @see #getUpArrow() */ public void setUpArrow(Shape arrow) { if (arrow == null) { throw new IllegalArgumentException("Null 'arrow' argument."); } this.upArrow = arrow; notifyListeners(new AxisChangeEvent(this)); } /** * Returns a shape that can be displayed as an arrow pointing downwards at * the end of an axis line. * * @return A shape (never null). * * @see #setDownArrow(Shape) */ public Shape getDownArrow() { return this.downArrow; } /** * Sets the shape that can be displayed as an arrow pointing downwards at * the end of an axis line and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param arrow the arrow shape (null not permitted). * * @see #getDownArrow() */ public void setDownArrow(Shape arrow) { if (arrow == null) { throw new IllegalArgumentException("Null 'arrow' argument."); } this.downArrow = arrow; notifyListeners(new AxisChangeEvent(this)); } /** * Returns a shape that can be displayed as an arrow pointing left at the * end of an axis line. * * @return A shape (never null). * * @see #setLeftArrow(Shape) */ public Shape getLeftArrow() { return this.leftArrow; } /** * Sets the shape that can be displayed as an arrow pointing left at the * end of an axis line and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param arrow the arrow shape (null not permitted). * * @see #getLeftArrow() */ public void setLeftArrow(Shape arrow) { if (arrow == null) { throw new IllegalArgumentException("Null 'arrow' argument."); } this.leftArrow = arrow; notifyListeners(new AxisChangeEvent(this)); } /** * Returns a shape that can be displayed as an arrow pointing right at the * end of an axis line. * * @return A shape (never null). * * @see #setRightArrow(Shape) */ public Shape getRightArrow() { return this.rightArrow; } /** * Sets the shape that can be displayed as an arrow pointing rightwards at * the end of an axis line and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param arrow the arrow shape (null not permitted). * * @see #getRightArrow() */ public void setRightArrow(Shape arrow) { if (arrow == null) { throw new IllegalArgumentException("Null 'arrow' argument."); } this.rightArrow = arrow; notifyListeners(new AxisChangeEvent(this)); } /** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(getAxisLinePaint()); g2.setStroke(getAxisLineStroke()); g2.draw(axisLine); boolean drawUpOrRight = false; boolean drawDownOrLeft = false; if (this.positiveArrowVisible) { if (this.inverted) { drawDownOrLeft = true; } else { drawUpOrRight = true; } } if (this.negativeArrowVisible) { if (this.inverted) { drawUpOrRight = true; } else { drawDownOrLeft = true; } } if (drawUpOrRight) { double x = 0.0; double y = 0.0; Shape arrow = null; if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { x = dataArea.getMaxX(); y = cursor; arrow = this.rightArrow; } else if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { x = cursor; y = dataArea.getMinY(); arrow = this.upArrow; } // draw the arrow... AffineTransform transformer = new AffineTransform(); transformer.setToTranslation(x, y); Shape shape = transformer.createTransformedShape(arrow); g2.fill(shape); g2.draw(shape); } if (drawDownOrLeft) { double x = 0.0; double y = 0.0; Shape arrow = null; if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { x = dataArea.getMinX(); y = cursor; arrow = this.leftArrow; } else if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { x = cursor; y = dataArea.getMaxY(); arrow = this.downArrow; } // draw the arrow... AffineTransform transformer = new AffineTransform(); transformer.setToTranslation(x, y); Shape shape = transformer.createTransformedShape(arrow); g2.fill(shape); g2.draw(shape); } } /** * Calculates the anchor point for a tick label. * * @param tick the tick. * @param cursor the cursor. * @param dataArea the data area. * @param edge the edge on which the axis is drawn. * * @return The x and y coordinates of the anchor point. */ protected float[] calculateAnchorPoint(ValueTick tick, double cursor, Rectangle2D dataArea, RectangleEdge edge) { RectangleInsets insets = getTickLabelInsets(); float[] result = new float[2]; if (edge == RectangleEdge.TOP) { result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge); result[1] = (float) (cursor - insets.getBottom() - 2.0); } else if (edge == RectangleEdge.BOTTOM) { result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge); result[1] = (float) (cursor + insets.getTop() + 2.0); } else if (edge == RectangleEdge.LEFT) { result[0] = (float) (cursor - insets.getLeft() - 2.0); result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge); } else if (edge == RectangleEdge.RIGHT) { result[0] = (float) (cursor + insets.getRight() + 2.0); result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge); } return result; } /** * Draws the axis line, tick marks and tick mark labels. * * @param g2 the graphics device. * @param cursor the cursor. * @param plotArea the plot area. * @param dataArea the data area. * @param edge the edge that the axis is aligned with. * * @return The width or height used to draw the axis. */ protected AxisState drawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) { AxisState state = new AxisState(cursor); if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); g2.setFont(getTickLabelFont()); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); if (isTickLabelsVisible()) { g2.setPaint(getTickLabelPaint()); float[] anchorPoint = calculateAnchorPoint(tick, cursor, dataArea, edge); TextUtilities.drawRotatedString(tick.getText(), g2, anchorPoint[0], anchorPoint[1], tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor()); } if ((isTickMarksVisible() && tick.getTickType().equals( TickType.MAJOR)) || (isMinorTickMarksVisible() && tick.getTickType().equals(TickType.MINOR))) { double ol = (tick.getTickType().equals(TickType.MINOR)) ? getMinorTickMarkOutsideLength() : getTickMarkOutsideLength(); double il = (tick.getTickType().equals(TickType.MINOR)) ? getMinorTickMarkInsideLength() : getTickMarkInsideLength(); float xx = (float) valueToJava2D(tick.getValue(), dataArea, edge); Line2D mark = null; g2.setStroke(getTickMarkStroke()); g2.setPaint(getTickMarkPaint()); if (edge == RectangleEdge.LEFT) { mark = new Line2D.Double(cursor - ol, xx, cursor + il, xx); } else if (edge == RectangleEdge.RIGHT) { mark = new Line2D.Double(cursor + ol, xx, cursor - il, xx); } else if (edge == RectangleEdge.TOP) { mark = new Line2D.Double(xx, cursor - ol, xx, cursor + il); } else if (edge == RectangleEdge.BOTTOM) { mark = new Line2D.Double(xx, cursor + ol, xx, cursor - il); } g2.draw(mark); } } // need to work out the space used by the tick labels... // so we can update the cursor... double used = 0.0; if (isTickLabelsVisible()) { if (edge == RectangleEdge.LEFT) { used += findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels()); state.cursorLeft(used); } else if (edge == RectangleEdge.RIGHT) { used = findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels()); state.cursorRight(used); } else if (edge == RectangleEdge.TOP) { used = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels()); state.cursorUp(used); } else if (edge == RectangleEdge.BOTTOM) { used = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels()); state.cursorDown(used); } } return state; } /** * Returns the space required to draw the axis. * * @param g2 the graphics device. * @param plot the plot that the axis belongs to. * @param plotArea the area within which the plot should be drawn. * @param edge the axis location. * @param space the space already reserved (for other axes). * * @return The space required to draw the axis (including pre-reserved * space). */ public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { // create a new space object if one wasn't supplied... if (space == null) { space = new AxisSpace(); } // if the axis is not visible, no additional space is required... if (!isVisible()) { return space; } // if the axis has a fixed dimension, return it... double dimension = getFixedDimension(); if (dimension > 0.0) { space.ensureAtLeast(dimension, edge); } // calculate the max size of the tick labels (if visible)... double tickLabelHeight = 0.0; double tickLabelWidth = 0.0; if (isTickLabelsVisible()) { g2.setFont(getTickLabelFont()); List ticks = refreshTicks(g2, new AxisState(), plotArea, edge); if (RectangleEdge.isTopOrBottom(edge)) { tickLabelHeight = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels()); } else if (RectangleEdge.isLeftOrRight(edge)) { tickLabelWidth = findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels()); } } // get the axis label size and update the space object... Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); double labelHeight = 0.0; double labelWidth = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { labelHeight = labelEnclosure.getHeight(); space.add(labelHeight + tickLabelHeight, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { labelWidth = labelEnclosure.getWidth(); space.add(labelWidth + tickLabelWidth, edge); } return space; } /** * A utility method for determining the height of the tallest tick label. * * @param ticks the ticks. * @param g2 the graphics device. * @param drawArea the area within which the plot and axes should be drawn. * @param vertical a flag that indicates whether or not the tick labels * are 'vertical'. * * @return The height of the tallest tick label. */ protected double findMaximumTickLabelHeight(List ticks, Graphics2D g2, Rectangle2D drawArea, boolean vertical) { RectangleInsets insets = getTickLabelInsets(); Font font = getTickLabelFont(); double maxHeight = 0.0; if (vertical) { FontMetrics fm = g2.getFontMetrics(font); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { Tick tick = (Tick) iterator.next(); Rectangle2D labelBounds = TextUtilities.getTextBounds( tick.getText(), g2, fm); if (labelBounds.getWidth() + insets.getTop() + insets.getBottom() > maxHeight) { maxHeight = labelBounds.getWidth() + insets.getTop() + insets.getBottom(); } } } else { LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext()); maxHeight = metrics.getHeight() + insets.getTop() + insets.getBottom(); } return maxHeight; } /** * A utility method for determining the width of the widest tick label. * * @param ticks the ticks. * @param g2 the graphics device. * @param drawArea the area within which the plot and axes should be drawn. * @param vertical a flag that indicates whether or not the tick labels * are 'vertical'. * * @return The width of the tallest tick label. */ protected double findMaximumTickLabelWidth(List ticks, Graphics2D g2, Rectangle2D drawArea, boolean vertical) { RectangleInsets insets = getTickLabelInsets(); Font font = getTickLabelFont(); double maxWidth = 0.0; if (!vertical) { FontMetrics fm = g2.getFontMetrics(font); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { Tick tick = (Tick) iterator.next(); Rectangle2D labelBounds = TextUtilities.getTextBounds( tick.getText(), g2, fm); if (labelBounds.getWidth() + insets.getLeft() + insets.getRight() > maxWidth) { maxWidth = labelBounds.getWidth() + insets.getLeft() + insets.getRight(); } } } else { LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext()); maxWidth = metrics.getHeight() + insets.getTop() + insets.getBottom(); } return maxWidth; } /** * Returns a flag that controls the direction of values on the axis. *

* For a regular axis, values increase from left to right (for a horizontal * axis) and bottom to top (for a vertical axis). When the axis is * 'inverted', the values increase in the opposite direction. * * @return The flag. * * @see #setInverted(boolean) */ public boolean isInverted() { return this.inverted; } /** * Sets a flag that controls the direction of values on the axis, and * notifies registered listeners that the axis has changed. * * @param flag the flag. * * @see #isInverted() */ public void setInverted(boolean flag) { if (this.inverted != flag) { this.inverted = flag; notifyListeners(new AxisChangeEvent(this)); } } /** * Returns the flag that controls whether or not the axis range is * automatically adjusted to fit the data values. * * @return The flag. * * @see #setAutoRange(boolean) */ public boolean isAutoRange() { return this.autoRange; } /** * Sets a flag that determines whether or not the axis range is * automatically adjusted to fit the data, and notifies registered * listeners that the axis has been modified. * * @param auto the new value of the flag. * * @see #isAutoRange() */ public void setAutoRange(boolean auto) { setAutoRange(auto, true); } /** * Sets the auto range attribute. If the notify flag is set, * an {@link AxisChangeEvent} is sent to registered listeners. * * @param auto the flag. * @param notify notify listeners? * * @see #isAutoRange() */ protected void setAutoRange(boolean auto, boolean notify) { if (this.autoRange != auto) { this.autoRange = auto; if (this.autoRange) { autoAdjustRange(); } if (notify) { notifyListeners(new AxisChangeEvent(this)); } } } /** * Returns the minimum size allowed for the axis range when it is * automatically calculated. * * @return The minimum range. * * @see #setAutoRangeMinimumSize(double) */ public double getAutoRangeMinimumSize() { return this.autoRangeMinimumSize; } /** * Sets the auto range minimum size and sends an {@link AxisChangeEvent} * to all registered listeners. * * @param size the size. * * @see #getAutoRangeMinimumSize() */ public void setAutoRangeMinimumSize(double size) { setAutoRangeMinimumSize(size, true); } /** * Sets the minimum size allowed for the axis range when it is * automatically calculated. *

* If requested, an {@link AxisChangeEvent} is forwarded to all registered * listeners. * * @param size the new minimum. * @param notify notify listeners? */ public void setAutoRangeMinimumSize(double size, boolean notify) { if (size <= 0.0) { throw new IllegalArgumentException( "NumberAxis.setAutoRangeMinimumSize(double): must be > 0.0."); } if (this.autoRangeMinimumSize != size) { this.autoRangeMinimumSize = size; if (this.autoRange) { autoAdjustRange(); } if (notify) { notifyListeners(new AxisChangeEvent(this)); } } } /** * Returns the default auto range. * * @return The default auto range (never null). * * @see #setDefaultAutoRange(Range) * * @since 1.0.5 */ public Range getDefaultAutoRange() { return this.defaultAutoRange; } /** * Sets the default auto range and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param range the range (null not permitted). * * @see #getDefaultAutoRange() * * @since 1.0.5 */ public void setDefaultAutoRange(Range range) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } this.defaultAutoRange = range; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the lower margin for the axis, expressed as a percentage of the * axis range. This controls the space added to the lower end of the axis * when the axis range is automatically calculated (it is ignored when the * axis range is set explicitly). The default value is 0.05 (five percent). * * @return The lower margin. * * @see #setLowerMargin(double) */ public double getLowerMargin() { return this.lowerMargin; } /** * Sets the lower margin for the axis (as a percentage of the axis range) * and sends an {@link AxisChangeEvent} to all registered listeners. This * margin is added only when the axis range is auto-calculated - if you set * the axis range manually, the margin is ignored. * * @param margin the margin percentage (for example, 0.05 is five percent). * * @see #getLowerMargin() * @see #setUpperMargin(double) */ public void setLowerMargin(double margin) { this.lowerMargin = margin; if (isAutoRange()) { autoAdjustRange(); } notifyListeners(new AxisChangeEvent(this)); } /** * Returns the upper margin for the axis, expressed as a percentage of the * axis range. This controls the space added to the lower end of the axis * when the axis range is automatically calculated (it is ignored when the * axis range is set explicitly). The default value is 0.05 (five percent). * * @return The upper margin. * * @see #setUpperMargin(double) */ public double getUpperMargin() { return this.upperMargin; } /** * Sets the upper margin for the axis (as a percentage of the axis range) * and sends an {@link AxisChangeEvent} to all registered listeners. This * margin is added only when the axis range is auto-calculated - if you set * the axis range manually, the margin is ignored. * * @param margin the margin percentage (for example, 0.05 is five percent). * * @see #getLowerMargin() * @see #setLowerMargin(double) */ public void setUpperMargin(double margin) { this.upperMargin = margin; if (isAutoRange()) { autoAdjustRange(); } notifyListeners(new AxisChangeEvent(this)); } /** * Returns the fixed auto range. * * @return The length. * * @see #setFixedAutoRange(double) */ public double getFixedAutoRange() { return this.fixedAutoRange; } /** * Sets the fixed auto range for the axis. * * @param length the range length. * * @see #getFixedAutoRange() */ public void setFixedAutoRange(double length) { this.fixedAutoRange = length; if (isAutoRange()) { autoAdjustRange(); } notifyListeners(new AxisChangeEvent(this)); } /** * Returns the lower bound of the axis range. * * @return The lower bound. * * @see #setLowerBound(double) */ public double getLowerBound() { return this.range.getLowerBound(); } /** * Sets the lower bound for the axis range. An {@link AxisChangeEvent} is * sent to all registered listeners. * * @param min the new minimum. * * @see #getLowerBound() */ public void setLowerBound(double min) { if (this.range.getUpperBound() > min) { setRange(new Range(min, this.range.getUpperBound())); } else { setRange(new Range(min, min + 1.0)); } } /** * Returns the upper bound for the axis range. * * @return The upper bound. * * @see #setUpperBound(double) */ public double getUpperBound() { return this.range.getUpperBound(); } /** * Sets the upper bound for the axis range, and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param max the new maximum. * * @see #getUpperBound() */ public void setUpperBound(double max) { if (this.range.getLowerBound() < max) { setRange(new Range(this.range.getLowerBound(), max)); } else { setRange(max - 1.0, max); } } /** * Returns the range for the axis. * * @return The axis range (never null). * * @see #setRange(Range) */ public Range getRange() { return this.range; } /** * Sets the range attribute and sends an {@link AxisChangeEvent} to all * registered listeners. As a side-effect, the auto-range flag is set to * false. * * @param range the range (null not permitted). * * @see #getRange() */ public void setRange(Range range) { // defer argument checking setRange(range, true, true); } /** * Sets the range for the axis, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. As a side-effect, * the auto-range flag is set to false (optional). * * @param range the range (null not permitted). * @param turnOffAutoRange a flag that controls whether or not the auto * range is turned off. * @param notify a flag that controls whether or not listeners are * notified. * * @see #getRange() */ public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } if (turnOffAutoRange) { this.autoRange = false; } this.range = range; if (notify) { notifyListeners(new AxisChangeEvent(this)); } } /** * Sets the axis range and sends an {@link AxisChangeEvent} to all * registered listeners. As a side-effect, the auto-range flag is set to * false. * * @param lower the lower axis limit. * @param upper the upper axis limit. * * @see #getRange() * @see #setRange(Range) */ public void setRange(double lower, double upper) { setRange(new Range(lower, upper)); } /** * Sets the range for the axis (after first adding the current margins to * the specified range) and sends an {@link AxisChangeEvent} to all * registered listeners. * * @param range the range (null not permitted). */ public void setRangeWithMargins(Range range) { setRangeWithMargins(range, true, true); } /** * Sets the range for the axis after first adding the current margins to * the range and, if requested, sends an {@link AxisChangeEvent} to all * registered listeners. As a side-effect, the auto-range flag is set to * false (optional). * * @param range the range (excluding margins, null not * permitted). * @param turnOffAutoRange a flag that controls whether or not the auto * range is turned off. * @param notify a flag that controls whether or not listeners are * notified. */ public void setRangeWithMargins(Range range, boolean turnOffAutoRange, boolean notify) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } setRange(Range.expand(range, getLowerMargin(), getUpperMargin()), turnOffAutoRange, notify); } /** * Sets the axis range (after first adding the current margins to the * range) and sends an {@link AxisChangeEvent} to all registered listeners. * As a side-effect, the auto-range flag is set to false. * * @param lower the lower axis limit. * @param upper the upper axis limit. */ public void setRangeWithMargins(double lower, double upper) { setRangeWithMargins(new Range(lower, upper)); } /** * Sets the axis range, where the new range is 'size' in length, and * centered on 'value'. * * @param value the central value. * @param length the range length. */ public void setRangeAboutValue(double value, double length) { setRange(new Range(value - length / 2, value + length / 2)); } /** * Returns a flag indicating whether or not the tick unit is automatically * selected from a range of standard tick units. * * @return A flag indicating whether or not the tick unit is automatically * selected. * * @see #setAutoTickUnitSelection(boolean) */ public boolean isAutoTickUnitSelection() { return this.autoTickUnitSelection; } /** * Sets a flag indicating whether or not the tick unit is automatically * selected from a range of standard tick units. If the flag is changed, * registered listeners are notified that the chart has changed. * * @param flag the new value of the flag. * * @see #isAutoTickUnitSelection() */ public void setAutoTickUnitSelection(boolean flag) { setAutoTickUnitSelection(flag, true); } /** * Sets a flag indicating whether or not the tick unit is automatically * selected from a range of standard tick units. * * @param flag the new value of the flag. * @param notify notify listeners? * * @see #isAutoTickUnitSelection() */ public void setAutoTickUnitSelection(boolean flag, boolean notify) { if (this.autoTickUnitSelection != flag) { this.autoTickUnitSelection = flag; if (notify) { notifyListeners(new AxisChangeEvent(this)); } } } /** * Returns the source for obtaining standard tick units for the axis. * * @return The source (possibly null). * * @see #setStandardTickUnits(TickUnitSource) */ public TickUnitSource getStandardTickUnits() { return this.standardTickUnits; } /** * Sets the source for obtaining standard tick units for the axis and sends * an {@link AxisChangeEvent} to all registered listeners. The axis will * try to select the smallest tick unit from the source that does not cause * the tick labels to overlap (see also the * {@link #setAutoTickUnitSelection(boolean)} method. * * @param source the source for standard tick units (null * permitted). * * @see #getStandardTickUnits() */ public void setStandardTickUnits(TickUnitSource source) { this.standardTickUnits = source; notifyListeners(new AxisChangeEvent(this)); } /** * Returns the number of minor tick marks to display. * * @return The number of minor tick marks to display. * * @see #setMinorTickCount(int) * * @since 1.0.12 */ public int getMinorTickCount() { return this.minorTickCount; } /** * Sets the number of minor tick marks to display, and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param count the count. * * @see #getMinorTickCount() * * @since 1.0.12 */ public void setMinorTickCount(int count) { this.minorTickCount = count; notifyListeners(new AxisChangeEvent(this)); } /** * Converts a data value to a coordinate in Java2D space, assuming that the * axis runs along one edge of the specified dataArea. *

* Note that it is possible for the coordinate to fall outside the area. * * @param value the data value. * @param area the area for plotting the data. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate. * * @see #java2DToValue(double, Rectangle2D, RectangleEdge) */ public abstract double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge); /** * Converts a length in data coordinates into the corresponding length in * Java2D coordinates. * * @param length the length. * @param area the plot area. * @param edge the edge along which the axis lies. * * @return The length in Java2D coordinates. */ public double lengthToJava2D(double length, Rectangle2D area, RectangleEdge edge) { double zero = valueToJava2D(0.0, area, edge); double l = valueToJava2D(length, area, edge); return Math.abs(l - zero); } /** * Converts a coordinate in Java2D space to the corresponding data value, * assuming that the axis runs along one edge of the specified dataArea. * * @param java2DValue the coordinate in Java2D space. * @param area the area in which the data is plotted. * @param edge the edge along which the axis lies. * * @return The data value. * * @see #valueToJava2D(double, Rectangle2D, RectangleEdge) */ public abstract double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge); /** * Automatically sets the axis range to fit the range of values in the * dataset. Sometimes this can depend on the renderer used as well (for * example, the renderer may "stack" values, requiring an axis range * greater than otherwise necessary). */ protected abstract void autoAdjustRange(); /** * Centers the axis range about the specified value and sends an * {@link AxisChangeEvent} to all registered listeners. * * @param value the center value. */ public void centerRange(double value) { double central = this.range.getCentralValue(); Range adjusted = new Range(this.range.getLowerBound() + value - central, this.range.getUpperBound() + value - central); setRange(adjusted); } /** * Increases or decreases the axis range by the specified percentage about * the central value and sends an {@link AxisChangeEvent} to all registered * listeners. *

* To double the length of the axis range, use 200% (2.0). * To halve the length of the axis range, use 50% (0.5). * * @param percent the resize factor. * * @see #resizeRange(double, double) */ public void resizeRange(double percent) { resizeRange(percent, this.range.getCentralValue()); } /** * Increases or decreases the axis range by the specified percentage about * the specified anchor value and sends an {@link AxisChangeEvent} to all * registered listeners. *

* To double the length of the axis range, use 200% (2.0). * To halve the length of the axis range, use 50% (0.5). * * @param percent the resize factor. * @param anchorValue the new central value after the resize. * * @see #resizeRange(double) */ public void resizeRange(double percent, double anchorValue) { if (percent > 0.0) { double halfLength = this.range.getLength() * percent / 2; Range adjusted = new Range(anchorValue - halfLength, anchorValue + halfLength); setRange(adjusted); } else { setAutoRange(true); } } /** * Increases or decreases the axis range by the specified percentage about * the specified anchor value and sends an {@link AxisChangeEvent} to all * registered listeners. *

* To double the length of the axis range, use 200% (2.0). * To halve the length of the axis range, use 50% (0.5). * * @param percent the resize factor. * @param anchorValue the new central value after the resize. * * @see #resizeRange(double) * * @since 1.0.13 */ public void resizeRange2(double percent, double anchorValue) { if (percent > 0.0) { double left = anchorValue - getLowerBound(); double right = getUpperBound() - anchorValue; Range adjusted = new Range(anchorValue - left * percent, anchorValue + right * percent); setRange(adjusted); } else { setAutoRange(true); } } /** * Zooms in on the current range. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomRange(double lowerPercent, double upperPercent) { double start = this.range.getLowerBound(); double length = this.range.getLength(); Range adjusted = null; if (isInverted()) { adjusted = new Range(start + (length * (1 - upperPercent)), start + (length * (1 - lowerPercent))); } else { adjusted = new Range(start + length * lowerPercent, start + length * upperPercent); } setRange(adjusted); } /** * Slides the axis range by the specified percentage. * * @param percent the percentage. * * @since 1.0.13 */ public void pan(double percent) { Range range = getRange(); double length = range.getLength(); double adj = length * percent; double lower = range.getLowerBound() + adj; double upper = range.getUpperBound() + adj; setRange(lower, upper); } /** * Returns the auto tick index. * * @return The auto tick index. * * @see #setAutoTickIndex(int) */ protected int getAutoTickIndex() { return this.autoTickIndex; } /** * Sets the auto tick index. * * @param index the new value. * * @see #getAutoTickIndex() */ protected void setAutoTickIndex(int index) { this.autoTickIndex = index; } /** * Tests the axis for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ValueAxis)) { return false; } ValueAxis that = (ValueAxis) obj; if (this.positiveArrowVisible != that.positiveArrowVisible) { return false; } if (this.negativeArrowVisible != that.negativeArrowVisible) { return false; } if (this.inverted != that.inverted) { return false; } // if autoRange is true, then the current range is irrelevant if (!this.autoRange && !ObjectUtilities.equal(this.range, that.range)) { return false; } if (this.autoRange != that.autoRange) { return false; } if (this.autoRangeMinimumSize != that.autoRangeMinimumSize) { return false; } if (!this.defaultAutoRange.equals(that.defaultAutoRange)) { return false; } if (this.upperMargin != that.upperMargin) { return false; } if (this.lowerMargin != that.lowerMargin) { return false; } if (this.fixedAutoRange != that.fixedAutoRange) { return false; } if (this.autoTickUnitSelection != that.autoTickUnitSelection) { return false; } if (!ObjectUtilities.equal(this.standardTickUnits, that.standardTickUnits)) { return false; } if (this.verticalTickLabels != that.verticalTickLabels) { return false; } if (this.minorTickCount != that.minorTickCount) { return false; } return super.equals(obj); } /** * Returns a clone of the object. * * @return A clone. * * @throws CloneNotSupportedException if some component of the axis does * not support cloning. */ public Object clone() throws CloneNotSupportedException { ValueAxis clone = (ValueAxis) super.clone(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.upArrow, stream); SerialUtilities.writeShape(this.downArrow, stream); SerialUtilities.writeShape(this.leftArrow, stream); SerialUtilities.writeShape(this.rightArrow, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.upArrow = SerialUtilities.readShape(stream); this.downArrow = SerialUtilities.readShape(stream); this.leftArrow = SerialUtilities.readShape(stream); this.rightArrow = SerialUtilities.readShape(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/ValueTick.java0000644000175000017500000001033011173030414026124 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * ValueTick.java * -------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Nov-2003 : Version 1 (DG); * 02-Aug-2007 : Added tick type attribute (DG); * */ package org.jfree.chart.axis; import org.jfree.ui.TextAnchor; /** * A value tick. */ public abstract class ValueTick extends Tick { /** The value. */ private double value; /** * The tick type (major or minor). * * @since 1.0.7 */ private TickType tickType; /** * Creates a new value tick. * * @param value the value. * @param label the label. * @param textAnchor the part of the label that is aligned to the anchor * point. * @param rotationAnchor defines the rotation point relative to the label. * @param angle the rotation angle (in radians). */ public ValueTick(double value, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { this(TickType.MAJOR, value, label, textAnchor, rotationAnchor, angle); this.value = value; } /** * Creates a new value tick. * * @param tickType the tick type (major or minor). * @param value the value. * @param label the label. * @param textAnchor the part of the label that is aligned to the anchor * point. * @param rotationAnchor defines the rotation point relative to the label. * @param angle the rotation angle (in radians). * * @since 1.0.7 */ public ValueTick(TickType tickType, double value, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { super(label, textAnchor, rotationAnchor, angle); this.value = value; this.tickType = tickType; } /** * Returns the value. * * @return The value. */ public double getValue() { return this.value; } /** * Returns the tick type (major or minor). * * @return The tick type. * * @since 1.0.7 */ public TickType getTickType() { return this.tickType; } /** * Tests this tick for equality with an arbitrary object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ValueTick)) { return false; } ValueTick that = (ValueTick) obj; if (this.value != that.value) { return false; } if (!this.tickType.equals(that.tickType)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/axis/package.html0000644000175000017500000000021111173030414025650 0ustar vincentvincent Axis classes and interfaces. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/0000755000175000017500000000000011216245561023534 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/AbstractBlock.java0000644000175000017500000004700111173030414027106 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * AbstractBlock.java * ------------------ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 02-Feb-2005 : Added accessor methods for margin (DG); * 04-Feb-2005 : Added equals() method and implemented Serializable (DG); * 03-May-2005 : Added null argument checks (DG); * 06-May-2005 : Added convenience methods for setting margin, border and * padding (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 16-Mar-2007 : Changed border from BlockBorder to BlockFrame, updated * equals(), and implemented Cloneable (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A convenience class for creating new classes that implement * the {@link Block} interface. */ public class AbstractBlock implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7689852412141274563L; /** The id for the block. */ private String id; /** The margin around the outside of the block. */ private RectangleInsets margin; /** The frame (or border) for the block. */ private BlockFrame frame; /** The padding between the block content and the border. */ private RectangleInsets padding; /** * The natural width of the block (may be overridden if there are * constraints in sizing). */ private double width; /** * The natural height of the block (may be overridden if there are * constraints in sizing). */ private double height; /** * The current bounds for the block (position of the block in Java2D space). */ private transient Rectangle2D bounds; /** * Creates a new block. */ protected AbstractBlock() { this.id = null; this.width = 0.0; this.height = 0.0; this.bounds = new Rectangle2D.Float(); this.margin = RectangleInsets.ZERO_INSETS; this.frame = BlockBorder.NONE; this.padding = RectangleInsets.ZERO_INSETS; } /** * Returns the id. * * @return The id (possibly null). * * @see #setID(String) */ public String getID() { return this.id; } /** * Sets the id for the block. * * @param id the id (null permitted). * * @see #getID() */ public void setID(String id) { this.id = id; } /** * Returns the natural width of the block, if this is known in advance. * The actual width of the block may be overridden if layout constraints * make this necessary. * * @return The width. * * @see #setWidth(double) */ public double getWidth() { return this.width; } /** * Sets the natural width of the block, if this is known in advance. * * @param width the width (in Java2D units) * * @see #getWidth() */ public void setWidth(double width) { this.width = width; } /** * Returns the natural height of the block, if this is known in advance. * The actual height of the block may be overridden if layout constraints * make this necessary. * * @return The height. * * @see #setHeight(double) */ public double getHeight() { return this.height; } /** * Sets the natural width of the block, if this is known in advance. * * @param height the width (in Java2D units) * * @see #getHeight() */ public void setHeight(double height) { this.height = height; } /** * Returns the margin. * * @return The margin (never null). * * @see #getMargin() */ public RectangleInsets getMargin() { return this.margin; } /** * Sets the margin (use {@link RectangleInsets#ZERO_INSETS} for no * padding). * * @param margin the margin (null not permitted). * * @see #getMargin() */ public void setMargin(RectangleInsets margin) { if (margin == null) { throw new IllegalArgumentException("Null 'margin' argument."); } this.margin = margin; } /** * Sets the margin. * * @param top the top margin. * @param left the left margin. * @param bottom the bottom margin. * @param right the right margin. * * @see #getMargin() */ public void setMargin(double top, double left, double bottom, double right) { setMargin(new RectangleInsets(top, left, bottom, right)); } /** * Returns the border. * * @return The border (never null). * * @deprecated Use {@link #getFrame()} instead. */ public BlockBorder getBorder() { if (this.frame instanceof BlockBorder) { return (BlockBorder) this.frame; } else { return null; } } /** * Sets the border for the block (use {@link BlockBorder#NONE} for * no border). * * @param border the border (null not permitted). * * @see #getBorder() * * @deprecated Use {@link #setFrame(BlockFrame)} instead. */ public void setBorder(BlockBorder border) { setFrame(border); } /** * Sets a black border with the specified line widths. * * @param top the top border line width. * @param left the left border line width. * @param bottom the bottom border line width. * @param right the right border line width. */ public void setBorder(double top, double left, double bottom, double right) { setFrame(new BlockBorder(top, left, bottom, right)); } /** * Returns the current frame (border). * * @return The frame. * * @since 1.0.5 * @see #setFrame(BlockFrame) */ public BlockFrame getFrame() { return this.frame; } /** * Sets the frame (or border). * * @param frame the frame (null not permitted). * * @since 1.0.5 * @see #getFrame() */ public void setFrame(BlockFrame frame) { if (frame == null) { throw new IllegalArgumentException("Null 'frame' argument."); } this.frame = frame; } /** * Returns the padding. * * @return The padding (never null). * * @see #setPadding(RectangleInsets) */ public RectangleInsets getPadding() { return this.padding; } /** * Sets the padding (use {@link RectangleInsets#ZERO_INSETS} for no * padding). * * @param padding the padding (null not permitted). * * @see #getPadding() */ public void setPadding(RectangleInsets padding) { if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } this.padding = padding; } /** * Sets the padding. * * @param top the top padding. * @param left the left padding. * @param bottom the bottom padding. * @param right the right padding. */ public void setPadding(double top, double left, double bottom, double right) { setPadding(new RectangleInsets(top, left, bottom, right)); } /** * Returns the x-offset for the content within the block. * * @return The x-offset. * * @see #getContentYOffset() */ public double getContentXOffset() { return this.margin.getLeft() + this.frame.getInsets().getLeft() + this.padding.getLeft(); } /** * Returns the y-offset for the content within the block. * * @return The y-offset. * * @see #getContentXOffset() */ public double getContentYOffset() { return this.margin.getTop() + this.frame.getInsets().getTop() + this.padding.getTop(); } /** * Arranges the contents of the block, with no constraints, and returns * the block size. * * @param g2 the graphics device. * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2) { return arrange(g2, RectangleConstraint.NONE); } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { Size2D base = new Size2D(getWidth(), getHeight()); return constraint.calculateConstrainedSize(base); } /** * Returns the current bounds of the block. * * @return The bounds. * * @see #setBounds(Rectangle2D) */ public Rectangle2D getBounds() { return this.bounds; } /** * Sets the bounds of the block. * * @param bounds the bounds (null not permitted). * * @see #getBounds() */ public void setBounds(Rectangle2D bounds) { if (bounds == null) { throw new IllegalArgumentException("Null 'bounds' argument."); } this.bounds = bounds; } /** * Calculate the width available for content after subtracting * the margin, border and padding space from the specified fixed * width. * * @param fixedWidth the fixed width. * * @return The available space. * * @see #trimToContentHeight(double) */ protected double trimToContentWidth(double fixedWidth) { double result = this.margin.trimWidth(fixedWidth); result = this.frame.getInsets().trimWidth(result); result = this.padding.trimWidth(result); return Math.max(result, 0.0); } /** * Calculate the height available for content after subtracting * the margin, border and padding space from the specified fixed * height. * * @param fixedHeight the fixed height. * * @return The available space. * * @see #trimToContentWidth(double) */ protected double trimToContentHeight(double fixedHeight) { double result = this.margin.trimHeight(fixedHeight); result = this.frame.getInsets().trimHeight(result); result = this.padding.trimHeight(result); return Math.max(result, 0.0); } /** * Returns a constraint for the content of this block that will result in * the bounds of the block matching the specified constraint. * * @param c the outer constraint (null not permitted). * * @return The content constraint. */ protected RectangleConstraint toContentConstraint(RectangleConstraint c) { if (c == null) { throw new IllegalArgumentException("Null 'c' argument."); } if (c.equals(RectangleConstraint.NONE)) { return c; } double w = c.getWidth(); Range wr = c.getWidthRange(); double h = c.getHeight(); Range hr = c.getHeightRange(); double ww = trimToContentWidth(w); double hh = trimToContentHeight(h); Range wwr = trimToContentWidth(wr); Range hhr = trimToContentHeight(hr); return new RectangleConstraint( ww, wwr, c.getWidthConstraintType(), hh, hhr, c.getHeightConstraintType() ); } private Range trimToContentWidth(Range r) { if (r == null) { return null; } double lowerBound = 0.0; double upperBound = Double.POSITIVE_INFINITY; if (r.getLowerBound() > 0.0) { lowerBound = trimToContentWidth(r.getLowerBound()); } if (r.getUpperBound() < Double.POSITIVE_INFINITY) { upperBound = trimToContentWidth(r.getUpperBound()); } return new Range(lowerBound, upperBound); } private Range trimToContentHeight(Range r) { if (r == null) { return null; } double lowerBound = 0.0; double upperBound = Double.POSITIVE_INFINITY; if (r.getLowerBound() > 0.0) { lowerBound = trimToContentHeight(r.getLowerBound()); } if (r.getUpperBound() < Double.POSITIVE_INFINITY) { upperBound = trimToContentHeight(r.getUpperBound()); } return new Range(lowerBound, upperBound); } /** * Adds the margin, border and padding to the specified content width. * * @param contentWidth the content width. * * @return The adjusted width. */ protected double calculateTotalWidth(double contentWidth) { double result = contentWidth; result = this.padding.extendWidth(result); result = this.frame.getInsets().extendWidth(result); result = this.margin.extendWidth(result); return result; } /** * Adds the margin, border and padding to the specified content height. * * @param contentHeight the content height. * * @return The adjusted height. */ protected double calculateTotalHeight(double contentHeight) { double result = contentHeight; result = this.padding.extendHeight(result); result = this.frame.getInsets().extendHeight(result); result = this.margin.extendHeight(result); return result; } /** * Reduces the specified area by the amount of space consumed * by the margin. * * @param area the area (null not permitted). * * @return The trimmed area. */ protected Rectangle2D trimMargin(Rectangle2D area) { // defer argument checking... this.margin.trim(area); return area; } /** * Reduces the specified area by the amount of space consumed * by the border. * * @param area the area (null not permitted). * * @return The trimmed area. */ protected Rectangle2D trimBorder(Rectangle2D area) { // defer argument checking... this.frame.getInsets().trim(area); return area; } /** * Reduces the specified area by the amount of space consumed * by the padding. * * @param area the area (null not permitted). * * @return The trimmed area. */ protected Rectangle2D trimPadding(Rectangle2D area) { // defer argument checking... this.padding.trim(area); return area; } /** * Draws the border around the perimeter of the specified area. * * @param g2 the graphics device. * @param area the area. */ protected void drawBorder(Graphics2D g2, Rectangle2D area) { this.frame.draw(g2, area); } /** * Tests this block for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractBlock)) { return false; } AbstractBlock that = (AbstractBlock) obj; if (!ObjectUtilities.equal(this.id, that.id)) { return false; } if (!this.frame.equals(that.frame)) { return false; } if (!this.bounds.equals(that.bounds)) { return false; } if (!this.margin.equals(that.margin)) { return false; } if (!this.padding.equals(that.padding)) { return false; } if (this.height != that.height) { return false; } if (this.width != that.width) { return false; } return true; } /** * Returns a clone of this block. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem creating the * clone. */ public Object clone() throws CloneNotSupportedException { AbstractBlock clone = (AbstractBlock) super.clone(); clone.bounds = (Rectangle2D) ShapeUtilities.clone(this.bounds); if (this.frame instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.frame; clone.frame = (BlockFrame) pc.clone(); } return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.bounds, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.bounds = (Rectangle2D) SerialUtilities.readShape(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/Arrangement.java0000644000175000017500000000567711173030414026650 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * Arrangement.java * ---------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 11-Feb-2005 : Modified arrange() method to return Size2D (DG); * 22-Apr-2005 : Reordered arguments in arrange() method (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import org.jfree.ui.Size2D; /** * An object that is responsible for arranging a collection of {@link Block}s * within a {@link BlockContainer}. */ public interface Arrangement { /** * Adds a block and a key which can be used to determine the position of * the block in the arrangement. This method is called by the container * (you don't need to call this method directly) and gives the arrangement * an opportunity to record the details if they are required. * * @param block the block. * @param key the key (null permitted). */ public void add(Block block, Object key); /** * Arranges the blocks within the specified container, subject to the given * constraint. * * @param container the container (null not permitted). * @param g2 the graphics device. * @param constraint the constraint. * * @return The container size after the arrangement. */ public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint); /** * Clears any cached layout information retained by the arrangement. */ public void clear(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/Block.java0000644000175000017500000000727211173030414025430 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------- * Block.java * ---------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 08-Feb-2005 : Added ID (DG); * 20-Apr-2005 : Added a new draw() method that can accept params * and return results (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.ui.Drawable; import org.jfree.ui.Size2D; /** * A block is an arbitrary item that can be drawn (in Java2D space) within a * rectangular area, has a preferred size, and can be arranged by an * {@link Arrangement} manager. */ public interface Block extends Drawable { /** * Returns an ID for the block. * * @return An ID. */ public String getID(); /** * Sets the ID for the block. * * @param id the ID. */ public void setID(String id); /** * Arranges the contents of the block, with no constraints, and returns * the block size. * * @param g2 the graphics device. * * @return The size of the block. */ public Size2D arrange(Graphics2D g2); /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint); /** * Returns the current bounds of the block. * * @return The bounds. */ public Rectangle2D getBounds(); /** * Sets the bounds of the block. * * @param bounds the bounds. */ public void setBounds(Rectangle2D bounds); /** * Draws the block within the specified area. Refer to the documentation * for the implementing class for information about the params * and return value supported. * * @param g2 the graphics device. * @param area the area. * @param params optional parameters (null permitted). * * @return An optional return value (possibly null). */ public Object draw(Graphics2D g2, Rectangle2D area, Object params); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/BlockBorder.java0000644000175000017500000001730011173030414026557 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * BlockBorder.java * ---------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 04-Feb-2005 : Added equals() and implemented Serializable (DG); * 23-Feb-2005 : Added attribute for border color (DG); * 06-May-2005 : Added new convenience constructors (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 16-Mar-2007 : Implemented BlockFrame (DG); * */ package org.jfree.chart.block; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.util.PaintUtilities; /** * A border for a block. This class is immutable. */ public class BlockBorder implements BlockFrame, Serializable { /** For serialization. */ private static final long serialVersionUID = 4961579220410228283L; /** An empty border. */ public static final BlockBorder NONE = new BlockBorder( RectangleInsets.ZERO_INSETS, Color.white); /** The space reserved for the border. */ private RectangleInsets insets; /** The border color. */ private transient Paint paint; /** * Creates a default border. */ public BlockBorder() { this(Color.black); } /** * Creates a new border with the specified color. * * @param paint the color (null not permitted). */ public BlockBorder(Paint paint) { this(new RectangleInsets(1, 1, 1, 1), paint); } /** * Creates a new border with the specified line widths (in black). * * @param top the width of the top border. * @param left the width of the left border. * @param bottom the width of the bottom border. * @param right the width of the right border. */ public BlockBorder(double top, double left, double bottom, double right) { this(new RectangleInsets(top, left, bottom, right), Color.black); } /** * Creates a new border with the specified line widths (in black). * * @param top the width of the top border. * @param left the width of the left border. * @param bottom the width of the bottom border. * @param right the width of the right border. * @param paint the border paint (null not permitted). */ public BlockBorder(double top, double left, double bottom, double right, Paint paint) { this(new RectangleInsets(top, left, bottom, right), paint); } /** * Creates a new border. * * @param insets the border insets (null not permitted). * @param paint the paint (null not permitted). */ public BlockBorder(RectangleInsets insets, Paint paint) { if (insets == null) { throw new IllegalArgumentException("Null 'insets' argument."); } if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.insets = insets; this.paint = paint; } /** * Returns the space reserved for the border. * * @return The space (never null). */ public RectangleInsets getInsets() { return this.insets; } /** * Returns the paint used to draw the border. * * @return The paint (never null). */ public Paint getPaint() { return this.paint; } /** * Draws the border by filling in the reserved space. * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { // this default implementation will just fill the available // border space with a single color double t = this.insets.calculateTopInset(area.getHeight()); double b = this.insets.calculateBottomInset(area.getHeight()); double l = this.insets.calculateLeftInset(area.getWidth()); double r = this.insets.calculateRightInset(area.getWidth()); double x = area.getX(); double y = area.getY(); double w = area.getWidth(); double h = area.getHeight(); g2.setPaint(this.paint); Rectangle2D rect = new Rectangle2D.Double(); if (t > 0.0) { rect.setRect(x, y, w, t); g2.fill(rect); } if (b > 0.0) { rect.setRect(x, y + h - b, w, b); g2.fill(rect); } if (l > 0.0) { rect.setRect(x, y, l, h); g2.fill(rect); } if (r > 0.0) { rect.setRect(x + w - r, y, r, h); g2.fill(rect); } } /** * Tests this border for equality with an arbitrary instance. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BlockBorder)) { return false; } BlockBorder that = (BlockBorder) obj; if (!this.insets.equals(that.insets)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/BlockContainer.java0000644000175000017500000002204111173030414027262 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * BlockContainer.java * ------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 02-Feb-2005 : Added isEmpty() method (DG); * 04-Feb-2005 : Added equals(), clone() and implemented Serializable (DG); * 08-Feb-2005 : Updated for changes in RectangleConstraint (DG); * 20-Apr-2005 : Added new draw() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Perform translation directly on drawing area, not via * Graphics2D (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.ui.Size2D; import org.jfree.util.PublicCloneable; /** * A container for a collection of {@link Block} objects. The container uses * an {@link Arrangement} object to handle the position of each block. */ public class BlockContainer extends AbstractBlock implements Block, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8199508075695195293L; /** The blocks within the container. */ private List blocks; /** The object responsible for laying out the blocks. */ private Arrangement arrangement; /** * Creates a new instance with default settings. */ public BlockContainer() { this(new BorderArrangement()); } /** * Creates a new instance with the specified arrangement. * * @param arrangement the arrangement manager (null not * permitted). */ public BlockContainer(Arrangement arrangement) { if (arrangement == null) { throw new IllegalArgumentException("Null 'arrangement' argument."); } this.arrangement = arrangement; this.blocks = new ArrayList(); } /** * Returns the arrangement (layout) manager for the container. * * @return The arrangement manager (never null). */ public Arrangement getArrangement() { return this.arrangement; } /** * Sets the arrangement (layout) manager. * * @param arrangement the arrangement (null not permitted). */ public void setArrangement(Arrangement arrangement) { if (arrangement == null) { throw new IllegalArgumentException("Null 'arrangement' argument."); } this.arrangement = arrangement; } /** * Returns true if there are no blocks in the container, and * false otherwise. * * @return A boolean. */ public boolean isEmpty() { return this.blocks.isEmpty(); } /** * Returns an unmodifiable list of the {@link Block} objects managed by * this arrangement. * * @return A list of blocks. */ public List getBlocks() { return Collections.unmodifiableList(this.blocks); } /** * Adds a block to the container. * * @param block the block (null permitted). */ public void add(Block block) { add(block, null); } /** * Adds a block to the container. * * @param block the block (null permitted). * @param key the key (null permitted). */ public void add(Block block, Object key) { this.blocks.add(block); this.arrangement.add(block, key); } /** * Clears all the blocks from the container. */ public void clear() { this.blocks.clear(); this.arrangement.clear(); } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { return this.arrangement.arrange(this, g2, constraint); } /** * Draws the container and all the blocks within it. * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params passed on to blocks within the container * (null permitted). * * @return An instance of {@link EntityBlockResult}, or null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { // check if we need to collect chart entities from the container EntityBlockParams ebp = null; StandardEntityCollection sec = null; if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { sec = new StandardEntityCollection(); } } Rectangle2D contentArea = (Rectangle2D) area.clone(); contentArea = trimMargin(contentArea); drawBorder(g2, contentArea); contentArea = trimBorder(contentArea); contentArea = trimPadding(contentArea); Iterator iterator = this.blocks.iterator(); while (iterator.hasNext()) { Block block = (Block) iterator.next(); Rectangle2D bounds = block.getBounds(); Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX() + area.getX(), bounds.getY() + area.getY(), bounds.getWidth(), bounds.getHeight()); Object r = block.draw(g2, drawArea, params); if (sec != null) { if (r instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) r; EntityCollection ec = ebr.getEntityCollection(); sec.addAll(ec); } } } BlockResult result = null; if (sec != null) { result = new BlockResult(); result.setEntityCollection(sec); } return result; } /** * Tests this container for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BlockContainer)) { return false; } if (!super.equals(obj)) { return false; } BlockContainer that = (BlockContainer) obj; if (!this.arrangement.equals(that.arrangement)) { return false; } if (!this.blocks.equals(that.blocks)) { return false; } return true; } /** * Returns a clone of the container. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { BlockContainer clone = (BlockContainer) super.clone(); // TODO : complete this return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/BlockFrame.java0000644000175000017500000000450411173030414026376 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * BlockFrame.java * --------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 16-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.ui.RectangleInsets; import org.jfree.util.PublicCloneable; /** * A block frame is a type of border that can be drawn around the outside of * any {@link AbstractBlock}. Classes that implement this interface should * implement {@link PublicCloneable} OR be immutable. * * @since 1.0.5 */ public interface BlockFrame { /** * Returns the space reserved for the border. * * @return The space (never null). */ public RectangleInsets getInsets(); /** * Draws the border by filling in the reserved space (in black). * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/BlockParams.java0000644000175000017500000001006311173030414026564 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * BlockParams.java * ---------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.block; /** * A standard parameter object that can be passed to the draw() method defined * by the {@link Block} class. */ public class BlockParams implements EntityBlockParams { /** * A flag that controls whether or not the block should generate and * return chart entities for the items it draws. */ private boolean generateEntities; /** * The x-translation (used to enable chart entities to use global * coordinates rather than coordinates that are local to the container * they are within). */ private double translateX; /** * The y-translation (used to enable chart entities to use global * coordinates rather than coordinates that are local to the container * they are within). */ private double translateY; /** * Creates a new instance. */ public BlockParams() { this.translateX = 0.0; this.translateY = 0.0; this.generateEntities = false; } /** * Returns the flag that controls whether or not chart entities are * generated. * * @return A boolean. */ public boolean getGenerateEntities() { return this.generateEntities; } /** * Sets the flag that controls whether or not chart entities are generated. * * @param generate the flag. */ public void setGenerateEntities(boolean generate) { this.generateEntities = generate; } /** * Returns the translation required to convert local x-coordinates back to * the coordinate space of the container. * * @return The x-translation amount. */ public double getTranslateX() { return this.translateX; } /** * Sets the translation required to convert local x-coordinates into the * coordinate space of the container. * * @param x the x-translation amount. */ public void setTranslateX(double x) { this.translateX = x; } /** * Returns the translation required to convert local y-coordinates back to * the coordinate space of the container. * * @return The y-translation amount. */ public double getTranslateY() { return this.translateY; } /** * Sets the translation required to convert local y-coordinates into the * coordinate space of the container. * * @param y the y-translation amount. */ public void setTranslateY(double y) { this.translateY = y; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/BlockResult.java0000644000175000017500000000452611173030414026626 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * BlockResult.java * ---------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.block; import org.jfree.chart.entity.EntityCollection; /** * Used to return results from the draw() method in the {@link Block} * class. */ public class BlockResult implements EntityBlockResult { /** The entities from the block. */ private EntityCollection entities; /** * Creates a new result instance. */ public BlockResult() { this.entities = null; } /** * Returns the collection of entities from the block. * * @return The entities. */ public EntityCollection getEntityCollection() { return this.entities; } /** * Sets the entities for the block. * * @param entities the entities. */ public void setEntityCollection(EntityCollection entities) { this.entities = entities; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/BorderArrangement.java0000644000175000017500000004750611173030414030003 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * BorderArrangement.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 08-Feb-2005 : Updated for changes in RectangleConstraint (DG); * 24-Feb-2005 : Improved arrangeRR() method (DG); * 03-May-2005 : Implemented Serializable and added equals() method (DG); * 13-May-2005 : Fixed bugs in the arrange() method (DG); * 08-Apr-2008 : Fixed bug in arrangeFF() method where width is too small for * left and right blocks (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.Size2D; import org.jfree.util.ObjectUtilities; /** * An arrangement manager that lays out blocks in a similar way to * Swing's BorderLayout class. */ public class BorderArrangement implements Arrangement, Serializable { /** For serialization. */ private static final long serialVersionUID = 506071142274883745L; /** The block (if any) at the center of the layout. */ private Block centerBlock; /** The block (if any) at the top of the layout. */ private Block topBlock; /** The block (if any) at the bottom of the layout. */ private Block bottomBlock; /** The block (if any) at the left of the layout. */ private Block leftBlock; /** The block (if any) at the right of the layout. */ private Block rightBlock; /** * Creates a new instance. */ public BorderArrangement() { } /** * Adds a block to the arrangement manager at the specified edge. * * @param block the block (null permitted). * @param key the edge (an instance of {@link RectangleEdge}) or * null for the center block. */ public void add(Block block, Object key) { if (key == null) { this.centerBlock = block; } else { RectangleEdge edge = (RectangleEdge) key; if (edge == RectangleEdge.TOP) { this.topBlock = block; } else if (edge == RectangleEdge.BOTTOM) { this.bottomBlock = block; } else if (edge == RectangleEdge.LEFT) { this.leftBlock = block; } else if (edge == RectangleEdge.RIGHT) { this.rightBlock = block; } } } /** * Arranges the items in the specified container, subject to the given * constraint. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The block size. */ public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint contentConstraint = container.toContentConstraint(constraint); Size2D contentSize = null; LengthConstraintType w = contentConstraint.getWidthConstraintType(); LengthConstraintType h = contentConstraint.getHeightConstraintType(); if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeNN(container, g2); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { contentSize = arrangeFN(container, g2, constraint.getWidth()); } else if (h == LengthConstraintType.FIXED) { contentSize = arrangeFF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { contentSize = arrangeFR(container, g2, constraint); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.RANGE) { contentSize = arrangeRR(container, constraint.getWidthRange(), constraint.getHeightRange(), g2); } } return new Size2D(container.calculateTotalWidth(contentSize.getWidth()), container.calculateTotalHeight(contentSize.getHeight())); } /** * Performs an arrangement without constraints. * * @param container the container. * @param g2 the graphics device. * * @return The container size after the arrangement. */ protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { double[] w = new double[5]; double[] h = new double[5]; if (this.topBlock != null) { Size2D size = this.topBlock.arrange(g2, RectangleConstraint.NONE); w[0] = size.width; h[0] = size.height; } if (this.bottomBlock != null) { Size2D size = this.bottomBlock.arrange(g2, RectangleConstraint.NONE); w[1] = size.width; h[1] = size.height; } if (this.leftBlock != null) { Size2D size = this.leftBlock.arrange(g2, RectangleConstraint.NONE); w[2] = size.width; h[2] = size.height; } if (this.rightBlock != null) { Size2D size = this.rightBlock.arrange(g2, RectangleConstraint.NONE); w[3] = size.width; h[3] = size.height; } h[2] = Math.max(h[2], h[3]); h[3] = h[2]; if (this.centerBlock != null) { Size2D size = this.centerBlock.arrange(g2, RectangleConstraint.NONE); w[4] = size.width; h[4] = size.height; } double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3])); double centerHeight = Math.max(h[2], Math.max(h[3], h[4])); double height = h[0] + h[1] + centerHeight; if (this.topBlock != null) { this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, width, h[0])); } if (this.bottomBlock != null) { this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, height - h[1], width, h[1])); } if (this.leftBlock != null) { this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], centerHeight)); } if (this.rightBlock != null) { this.rightBlock.setBounds(new Rectangle2D.Double(width - w[3], h[0], w[3], centerHeight)); } if (this.centerBlock != null) { this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], width - w[2] - w[3], centerHeight)); } return new Size2D(width, height); } /** * Performs an arrangement with a fixed width and a range for the height. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The container size after the arrangement. */ protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D size1 = arrangeFN(container, g2, constraint.getWidth()); if (constraint.getHeightRange().contains(size1.getHeight())) { return size1; } else { double h = constraint.getHeightRange().constrain(size1.getHeight()); RectangleConstraint c2 = constraint.toFixedHeight(h); return arrange(container, g2, c2); } } /** * Arranges the container width a fixed width and no constraint on the * height. * * @param container the container. * @param g2 the graphics device. * @param width the fixed width. * * @return The container size after arranging the contents. */ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, double width) { double[] w = new double[5]; double[] h = new double[5]; RectangleConstraint c1 = new RectangleConstraint(width, null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE); if (this.topBlock != null) { Size2D size = this.topBlock.arrange(g2, c1); w[0] = size.width; h[0] = size.height; } if (this.bottomBlock != null) { Size2D size = this.bottomBlock.arrange(g2, c1); w[1] = size.width; h[1] = size.height; } RectangleConstraint c2 = new RectangleConstraint(0.0, new Range(0.0, width), LengthConstraintType.RANGE, 0.0, null, LengthConstraintType.NONE); if (this.leftBlock != null) { Size2D size = this.leftBlock.arrange(g2, c2); w[2] = size.width; h[2] = size.height; } if (this.rightBlock != null) { double maxW = Math.max(width - w[2], 0.0); RectangleConstraint c3 = new RectangleConstraint(0.0, new Range(Math.min(w[2], maxW), maxW), LengthConstraintType.RANGE, 0.0, null, LengthConstraintType.NONE); Size2D size = this.rightBlock.arrange(g2, c3); w[3] = size.width; h[3] = size.height; } h[2] = Math.max(h[2], h[3]); h[3] = h[2]; if (this.centerBlock != null) { RectangleConstraint c4 = new RectangleConstraint(width - w[2] - w[3], null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE); Size2D size = this.centerBlock.arrange(g2, c4); w[4] = size.width; h[4] = size.height; } double height = h[0] + h[1] + Math.max(h[2], Math.max(h[3], h[4])); return arrange(container, g2, new RectangleConstraint(width, height)); } /** * Performs an arrangement with range constraints on both the vertical * and horizontal sides. * * @param container the container. * @param widthRange the allowable range for the container width. * @param heightRange the allowable range for the container height. * @param g2 the graphics device. * * @return The container size. */ protected Size2D arrangeRR(BlockContainer container, Range widthRange, Range heightRange, Graphics2D g2) { double[] w = new double[5]; double[] h = new double[5]; if (this.topBlock != null) { RectangleConstraint c1 = new RectangleConstraint(widthRange, heightRange); Size2D size = this.topBlock.arrange(g2, c1); w[0] = size.width; h[0] = size.height; } if (this.bottomBlock != null) { Range heightRange2 = Range.shift(heightRange, -h[0], false); RectangleConstraint c2 = new RectangleConstraint(widthRange, heightRange2); Size2D size = this.bottomBlock.arrange(g2, c2); w[1] = size.width; h[1] = size.height; } Range heightRange3 = Range.shift(heightRange, -(h[0] + h[1])); if (this.leftBlock != null) { RectangleConstraint c3 = new RectangleConstraint(widthRange, heightRange3); Size2D size = this.leftBlock.arrange(g2, c3); w[2] = size.width; h[2] = size.height; } Range widthRange2 = Range.shift(widthRange, -w[2], false); if (this.rightBlock != null) { RectangleConstraint c4 = new RectangleConstraint(widthRange2, heightRange3); Size2D size = this.rightBlock.arrange(g2, c4); w[3] = size.width; h[3] = size.height; } h[2] = Math.max(h[2], h[3]); h[3] = h[2]; Range widthRange3 = Range.shift(widthRange, -(w[2] + w[3]), false); if (this.centerBlock != null) { RectangleConstraint c5 = new RectangleConstraint(widthRange3, heightRange3); Size2D size = this.centerBlock.arrange(g2, c5); w[4] = size.width; h[4] = size.height; } double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3])); double height = h[0] + h[1] + Math.max(h[2], Math.max(h[3], h[4])); if (this.topBlock != null) { this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, width, h[0])); } if (this.bottomBlock != null) { this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, height - h[1], width, h[1])); } if (this.leftBlock != null) { this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], h[2])); } if (this.rightBlock != null) { this.rightBlock.setBounds(new Rectangle2D.Double(width - w[3], h[0], w[3], h[3])); } if (this.centerBlock != null) { this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], width - w[2] - w[3], height - h[0] - h[1])); } return new Size2D(width, height); } /** * Arranges the items within a container. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The container size after the arrangement. */ protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { double[] w = new double[5]; double[] h = new double[5]; w[0] = constraint.getWidth(); if (this.topBlock != null) { RectangleConstraint c1 = new RectangleConstraint(w[0], null, LengthConstraintType.FIXED, 0.0, new Range(0.0, constraint.getHeight()), LengthConstraintType.RANGE); Size2D size = this.topBlock.arrange(g2, c1); h[0] = size.height; } w[1] = w[0]; if (this.bottomBlock != null) { RectangleConstraint c2 = new RectangleConstraint(w[0], null, LengthConstraintType.FIXED, 0.0, new Range(0.0, constraint.getHeight() - h[0]), LengthConstraintType.RANGE); Size2D size = this.bottomBlock.arrange(g2, c2); h[1] = size.height; } h[2] = constraint.getHeight() - h[1] - h[0]; if (this.leftBlock != null) { RectangleConstraint c3 = new RectangleConstraint(0.0, new Range(0.0, constraint.getWidth()), LengthConstraintType.RANGE, h[2], null, LengthConstraintType.FIXED); Size2D size = this.leftBlock.arrange(g2, c3); w[2] = size.width; } h[3] = h[2]; if (this.rightBlock != null) { RectangleConstraint c4 = new RectangleConstraint(0.0, new Range(0.0, Math.max(constraint.getWidth() - w[2], 0.0)), LengthConstraintType.RANGE, h[2], null, LengthConstraintType.FIXED); Size2D size = this.rightBlock.arrange(g2, c4); w[3] = size.width; } h[4] = h[2]; w[4] = constraint.getWidth() - w[3] - w[2]; RectangleConstraint c5 = new RectangleConstraint(w[4], h[4]); if (this.centerBlock != null) { this.centerBlock.arrange(g2, c5); } if (this.topBlock != null) { this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, w[0], h[0])); } if (this.bottomBlock != null) { this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, h[0] + h[2], w[1], h[1])); } if (this.leftBlock != null) { this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], h[2])); } if (this.rightBlock != null) { this.rightBlock.setBounds(new Rectangle2D.Double(w[2] + w[4], h[0], w[3], h[3])); } if (this.centerBlock != null) { this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], w[4], h[4])); } return new Size2D(constraint.getWidth(), constraint.getHeight()); } /** * Clears the layout. */ public void clear() { this.centerBlock = null; this.topBlock = null; this.bottomBlock = null; this.leftBlock = null; this.rightBlock = null; } /** * Tests this arrangement for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BorderArrangement)) { return false; } BorderArrangement that = (BorderArrangement) obj; if (!ObjectUtilities.equal(this.topBlock, that.topBlock)) { return false; } if (!ObjectUtilities.equal(this.bottomBlock, that.bottomBlock)) { return false; } if (!ObjectUtilities.equal(this.leftBlock, that.leftBlock)) { return false; } if (!ObjectUtilities.equal(this.rightBlock, that.rightBlock)) { return false; } if (!ObjectUtilities.equal(this.centerBlock, that.centerBlock)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/CenterArrangement.java0000644000175000017500000002674211173030414030005 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * CenterArrangement.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 08-Mar-2005 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Set bounds of contained block when arranging (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.List; import org.jfree.ui.Size2D; /** * Arranges a block in the center of its container. This class is immutable. */ public class CenterArrangement implements Arrangement, Serializable { /** For serialization. */ private static final long serialVersionUID = -353308149220382047L; /** * Creates a new instance. */ public CenterArrangement() { } /** * Adds a block to be managed by this instance. This method is usually * called by the {@link BlockContainer}, you shouldn't need to call it * directly. * * @param block the block. * @param key a key that controls the position of the block. */ public void add(Block block, Object key) { // since the flow layout is relatively straightforward, // no information needs to be recorded here } /** * Calculates and sets the bounds of all the items in the specified * container, subject to the given constraint. The Graphics2D * can be used by some items (particularly items containing text) to * calculate sizing parameters. * * @param container the container whose items are being arranged. * @param g2 the graphics device. * @param constraint the size constraint. * * @return The size of the container after arrangement of the contents. */ public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { LengthConstraintType w = constraint.getWidthConstraintType(); LengthConstraintType h = constraint.getHeightConstraintType(); if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { return arrangeNN(container, g2); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { return arrangeFN(container, g2, constraint); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { return arrangeRN(container, g2, constraint); } else if (h == LengthConstraintType.FIXED) { return arrangeRF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { return arrangeRR(container, g2, constraint); } } throw new IllegalArgumentException("Unknown LengthConstraintType."); } /** * Arranges the blocks in the container with a fixed width and no height * constraint. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size. */ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { List blocks = container.getBlocks(); Block b = (Block) blocks.get(0); Size2D s = b.arrange(g2, RectangleConstraint.NONE); double width = constraint.getWidth(); Rectangle2D bounds = new Rectangle2D.Double((width - s.width) / 2.0, 0.0, s.width, s.height); b.setBounds(bounds); return new Size2D((width - s.width) / 2.0, s.height); } /** * Arranges the blocks in the container with a fixed with and a range * constraint on the height. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size following the arrangement. */ protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeFN(container, g2, constraint); if (constraint.getHeightRange().contains(s.height)) { return s; } else { RectangleConstraint c = constraint.toFixedHeight( constraint.getHeightRange().constrain(s.getHeight())); return arrangeFF(container, g2, c); } } /** * Arranges the blocks in the container with the overall height and width * specified as fixed constraints. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size following the arrangement. */ protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // TODO: implement this properly return arrangeFN(container, g2, constraint); } /** * Arranges the blocks with the overall width and height to fit within * specified ranges. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size after the arrangement. */ protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // first arrange without constraints, and see if this fits within // the required ranges... Size2D s1 = arrangeNN(container, g2); if (constraint.getWidthRange().contains(s1.width)) { return s1; // TODO: we didn't check the height yet } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().getUpperBound()); return arrangeFR(container, g2, c); } } /** * Arranges the blocks in the container with a range constraint on the * width and a fixed height. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size following the arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeNF(container, g2, constraint); if (constraint.getWidthRange().contains(s.width)) { return s; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().constrain(s.getWidth())); return arrangeFF(container, g2, c); } } /** * Arranges the block with a range constraint on the width, and no * constraint on the height. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size following the arrangement. */ protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // first arrange without constraints, then see if the width fits // within the required range...if not, call arrangeFN() at max width Size2D s1 = arrangeNN(container, g2); if (constraint.getWidthRange().contains(s1.width)) { return s1; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().getUpperBound()); return arrangeFN(container, g2, c); } } /** * Arranges the blocks without any constraints. This puts all blocks * into a single row. * * @param container the container. * @param g2 the graphics device. * * @return The size after the arrangement. */ protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { List blocks = container.getBlocks(); Block b = (Block) blocks.get(0); Size2D s = b.arrange(g2, RectangleConstraint.NONE); b.setBounds(new Rectangle2D.Double(0.0, 0.0, s.width, s.height)); return new Size2D(s.width, s.height); } /** * Arranges the blocks with no width constraint and a fixed height * constraint. This puts all blocks into a single row. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size after the arrangement. */ protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // TODO: for now we are ignoring the height constraint return arrangeNN(container, g2); } /** * Clears any cached information. */ public void clear() { // no action required. } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CenterArrangement)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/ColorBlock.java0000644000175000017500000001322211173030414026417 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ColorBlock.java * --------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 20-Apr-2005 : Added new draw() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 16-Mar-2007 : Implemented equals() and fixed serialization (DG); * 08-Apr-2008 : Added code for margin, border and padding in draw() * method (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.io.SerialUtilities; import org.jfree.ui.Size2D; import org.jfree.util.PaintUtilities; /** * A block that is filled with a single color. */ public class ColorBlock extends AbstractBlock implements Block { /** For serialization. */ static final long serialVersionUID = 3383866145634010865L; /** The paint. */ private transient Paint paint; /** * Creates a new block. * * @param paint the paint (null not permitted). * @param width the width. * @param height the height. */ public ColorBlock(Paint paint, double width, double height) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; setWidth(width); setHeight(height); } /** * Returns the paint. * * @return The paint (never null). * * @since 1.0.5 */ public Paint getPaint() { return this.paint; } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { return new Size2D(calculateTotalWidth(getWidth()), calculateTotalHeight(getHeight())); } /** * Draws the block. * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { area = trimMargin(area); drawBorder(g2, area); area = trimBorder(area); area = trimPadding(area); g2.setPaint(this.paint); g2.fill(area); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return Always null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { draw(g2, area); return null; } /** * Tests this block for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ColorBlock)) { return false; } ColorBlock that = (ColorBlock) obj; if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/ColumnArrangement.java0000644000175000017500000003351511173030414030016 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * ColumnArrangement.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 04-Feb-2005 : Added equals() and implemented Serializable (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.Size2D; import org.jfree.ui.VerticalAlignment; /** * Arranges blocks in a column layout. This class is immutable. */ public class ColumnArrangement implements Arrangement, Serializable { /** For serialization. */ private static final long serialVersionUID = -5315388482898581555L; /** The horizontal alignment of blocks. */ private HorizontalAlignment horizontalAlignment; /** The vertical alignment of blocks within each row. */ private VerticalAlignment verticalAlignment; /** The horizontal gap between columns. */ private double horizontalGap; /** The vertical gap between items in a column. */ private double verticalGap; /** * Creates a new instance. */ public ColumnArrangement() { } /** * Creates a new instance. * * @param hAlign the horizontal alignment (currently ignored). * @param vAlign the vertical alignment (currently ignored). * @param hGap the horizontal gap. * @param vGap the vertical gap. */ public ColumnArrangement(HorizontalAlignment hAlign, VerticalAlignment vAlign, double hGap, double vGap) { this.horizontalAlignment = hAlign; this.verticalAlignment = vAlign; this.horizontalGap = hGap; this.verticalGap = vGap; } /** * Adds a block to be managed by this instance. This method is usually * called by the {@link BlockContainer}, you shouldn't need to call it * directly. * * @param block the block. * @param key a key that controls the position of the block. */ public void add(Block block, Object key) { // since the flow layout is relatively straightforward, no information // needs to be recorded here } /** * Calculates and sets the bounds of all the items in the specified * container, subject to the given constraint. The Graphics2D * can be used by some items (particularly items containing text) to * calculate sizing parameters. * * @param container the container whose items are being arranged. * @param g2 the graphics device. * @param constraint the size constraint. * * @return The size of the container after arrangement of the contents. */ public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { LengthConstraintType w = constraint.getWidthConstraintType(); LengthConstraintType h = constraint.getHeightConstraintType(); if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { return arrangeNN(container, g2); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.FIXED) { return arrangeFF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not implemented."); } else if (h == LengthConstraintType.FIXED) { return arrangeRF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { return arrangeRR(container, g2, constraint); } } return new Size2D(); // TODO: complete this } /** * Calculates and sets the bounds of all the items in the specified * container, subject to the given constraint. The Graphics2D * can be used by some items (particularly items containing text) to * calculate sizing parameters. * * @param container the container whose items are being arranged. * @param g2 the graphics device. * @param constraint the size constraint. * * @return The container size after the arrangement. */ protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // TODO: implement properly return arrangeNF(container, g2, constraint); } /** * Calculates and sets the bounds of all the items in the specified * container, subject to the given constraint. The Graphics2D * can be used by some items (particularly items containing text) to * calculate sizing parameters. * * @param container the container whose items are being arranged. * @param constraint the size constraint. * @param g2 the graphics device. * * @return The container size after the arrangement. */ protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { List blocks = container.getBlocks(); double height = constraint.getHeight(); if (height <= 0.0) { height = Double.POSITIVE_INFINITY; } double x = 0.0; double y = 0.0; double maxWidth = 0.0; List itemsInColumn = new ArrayList(); for (int i = 0; i < blocks.size(); i++) { Block block = (Block) blocks.get(i); Size2D size = block.arrange(g2, RectangleConstraint.NONE); if (y + size.height <= height) { itemsInColumn.add(block); block.setBounds( new Rectangle2D.Double(x, y, size.width, size.height) ); y = y + size.height + this.verticalGap; maxWidth = Math.max(maxWidth, size.width); } else { if (itemsInColumn.isEmpty()) { // place in this column (truncated) anyway block.setBounds( new Rectangle2D.Double( x, y, size.width, Math.min(size.height, height - y) ) ); y = 0.0; x = x + size.width + this.horizontalGap; } else { // start new column itemsInColumn.clear(); x = x + maxWidth + this.horizontalGap; y = 0.0; maxWidth = size.width; block.setBounds( new Rectangle2D.Double( x, y, size.width, Math.min(size.height, height) ) ); y = size.height + this.verticalGap; itemsInColumn.add(block); } } } return new Size2D(x + maxWidth, constraint.getHeight()); } /** * Arranges a container with range constraints for both the horizontal * and vertical. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size of the container. */ protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // first arrange without constraints, and see if this fits within // the required ranges... Size2D s1 = arrangeNN(container, g2); if (constraint.getHeightRange().contains(s1.height)) { return s1; // TODO: we didn't check the width yet } else { RectangleConstraint c = constraint.toFixedHeight( constraint.getHeightRange().getUpperBound() ); return arrangeRF(container, g2, c); } } /** * Arranges the blocks in the container using a fixed height and a * range for the width. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size of the container after arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeNF(container, g2, constraint); if (constraint.getWidthRange().contains(s.width)) { return s; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().constrain(s.getWidth()) ); return arrangeFF(container, g2, c); } } /** * Arranges the blocks without any constraints. This puts all blocks * into a single column. * * @param container the container. * @param g2 the graphics device. * * @return The size after the arrangement. */ protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { double y = 0.0; double height = 0.0; double maxWidth = 0.0; List blocks = container.getBlocks(); int blockCount = blocks.size(); if (blockCount > 0) { Size2D[] sizes = new Size2D[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { Block block = (Block) blocks.get(i); sizes[i] = block.arrange(g2, RectangleConstraint.NONE); height = height + sizes[i].getHeight(); maxWidth = Math.max(sizes[i].width, maxWidth); block.setBounds( new Rectangle2D.Double( 0.0, y, sizes[i].width, sizes[i].height ) ); y = y + sizes[i].height + this.verticalGap; } if (blockCount > 1) { height = height + this.verticalGap * (blockCount - 1); } if (this.horizontalAlignment != HorizontalAlignment.LEFT) { for (int i = 0; i < blocks.size(); i++) { //Block b = (Block) blocks.get(i); if (this.horizontalAlignment == HorizontalAlignment.CENTER) { //TODO: shift block right by half } else if (this.horizontalAlignment == HorizontalAlignment.RIGHT) { //TODO: shift block over to right } } } } return new Size2D(maxWidth, height); } /** * Clears any cached information. */ public void clear() { // no action required. } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ColumnArrangement)) { return false; } ColumnArrangement that = (ColumnArrangement) obj; if (this.horizontalAlignment != that.horizontalAlignment) { return false; } if (this.verticalAlignment != that.verticalAlignment) { return false; } if (this.horizontalGap != that.horizontalGap) { return false; } if (this.verticalGap != that.verticalGap) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/EmptyBlock.java0000644000175000017500000001020711173030414026437 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * EmptyBlock.java * --------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 04-Feb-2005 : Now cloneable and serializable (DG); * 20-Apr-2005 : Added new draw() method (DG); * 08-Apr-2008 : Added support for margin and border (DG); * 08-May-2008 : Updated arrange() method to recognise * incoming constraint (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.ui.Size2D; import org.jfree.util.PublicCloneable; /** * An empty block with a fixed size. */ public class EmptyBlock extends AbstractBlock implements Block, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4083197869412648579L; /** * Creates a new block with the specified width and height. * * @param width the width. * @param height the height. */ public EmptyBlock(double width, double height) { setWidth(width); setHeight(height); } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { Size2D base = new Size2D(calculateTotalWidth(getWidth()), calculateTotalHeight(getHeight())); return constraint.calculateConstrainedSize(base); } /** * Draws the block. Since the block is empty, there is nothing to draw * except the optional border. * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the block within the specified area. Since the block is empty, * there is nothing to draw except the optional border. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return Always null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = trimMargin(area); drawBorder(g2, area); return null; } /** * Returns a clone of the block. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/EntityBlockParams.java0000644000175000017500000000374111173030414027766 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * EntityBlockParams.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.block; /** * An interface that is used by the draw() method of some {@link Block} * implementations to determine whether or not to generate entities for the * items within the block. */ public interface EntityBlockParams { /** * Returns a flag that controls whether or not the block should return * entities for the items it draws. * * @return A boolean. */ public boolean getGenerateEntities(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/EntityBlockResult.java0000644000175000017500000000363611173030414030024 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * EntityBlockResult.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.block; import org.jfree.chart.entity.EntityCollection; /** * Provides access to the {@link EntityCollection} generated when a block is * drawn. */ public interface EntityBlockResult { /** * Returns the entity collection. * * @return An entity collection (possibly null). */ public EntityCollection getEntityCollection(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/FlowArrangement.java0000644000175000017500000003734411173030414027474 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * FlowArrangement.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 04-Feb-2005 : Implemented equals() and made serializable (DG); * 08-Feb-2005 : Updated for changes in RectangleConstraint (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.Size2D; import org.jfree.ui.VerticalAlignment; /** * Arranges blocks in a flow layout. This class is immutable. */ public class FlowArrangement implements Arrangement, Serializable { /** For serialization. */ private static final long serialVersionUID = 4543632485478613800L; /** The horizontal alignment of blocks. */ private HorizontalAlignment horizontalAlignment; /** The vertical alignment of blocks within each row. */ private VerticalAlignment verticalAlignment; /** The horizontal gap between items within rows. */ private double horizontalGap; /** The vertical gap between rows. */ private double verticalGap; /** * Creates a new instance. */ public FlowArrangement() { this(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 2.0, 2.0); } /** * Creates a new instance. * * @param hAlign the horizontal alignment (currently ignored). * @param vAlign the vertical alignment (currently ignored). * @param hGap the horizontal gap. * @param vGap the vertical gap. */ public FlowArrangement(HorizontalAlignment hAlign, VerticalAlignment vAlign, double hGap, double vGap) { this.horizontalAlignment = hAlign; this.verticalAlignment = vAlign; this.horizontalGap = hGap; this.verticalGap = vGap; } /** * Adds a block to be managed by this instance. This method is usually * called by the {@link BlockContainer}, you shouldn't need to call it * directly. * * @param block the block. * @param key a key that controls the position of the block. */ public void add(Block block, Object key) { // since the flow layout is relatively straightforward, // no information needs to be recorded here } /** * Calculates and sets the bounds of all the items in the specified * container, subject to the given constraint. The Graphics2D * can be used by some items (particularly items containing text) to * calculate sizing parameters. * * @param container the container whose items are being arranged. * @param constraint the size constraint. * @param g2 the graphics device. * * @return The size of the container after arrangement of the contents. */ public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { LengthConstraintType w = constraint.getWidthConstraintType(); LengthConstraintType h = constraint.getHeightConstraintType(); if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { return arrangeNN(container, g2); } else if (h == LengthConstraintType.FIXED) { return arrangeNF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { return arrangeFN(container, g2, constraint); } else if (h == LengthConstraintType.FIXED) { return arrangeFF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { return arrangeFR(container, g2, constraint); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { return arrangeRN(container, g2, constraint); } else if (h == LengthConstraintType.FIXED) { return arrangeRF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { return arrangeRR(container, g2, constraint); } } throw new RuntimeException("Unrecognised constraint type."); } /** * Arranges the blocks in the container with a fixed width and no height * constraint. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size. */ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { List blocks = container.getBlocks(); double width = constraint.getWidth(); double x = 0.0; double y = 0.0; double maxHeight = 0.0; List itemsInRow = new ArrayList(); for (int i = 0; i < blocks.size(); i++) { Block block = (Block) blocks.get(i); Size2D size = block.arrange(g2, RectangleConstraint.NONE); if (x + size.width <= width) { itemsInRow.add(block); block.setBounds( new Rectangle2D.Double(x, y, size.width, size.height) ); x = x + size.width + this.horizontalGap; maxHeight = Math.max(maxHeight, size.height); } else { if (itemsInRow.isEmpty()) { // place in this row (truncated) anyway block.setBounds( new Rectangle2D.Double( x, y, Math.min(size.width, width - x), size.height ) ); x = 0.0; y = y + size.height + this.verticalGap; } else { // start new row itemsInRow.clear(); x = 0.0; y = y + maxHeight + this.verticalGap; maxHeight = size.height; block.setBounds( new Rectangle2D.Double( x, y, Math.min(size.width, width), size.height ) ); x = size.width + this.horizontalGap; itemsInRow.add(block); } } } return new Size2D(constraint.getWidth(), y + maxHeight); } /** * Arranges the blocks in the container with a fixed width and a range * constraint on the height. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size following the arrangement. */ protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeFN(container, g2, constraint); if (constraint.getHeightRange().contains(s.height)) { return s; } else { RectangleConstraint c = constraint.toFixedHeight( constraint.getHeightRange().constrain(s.getHeight()) ); return arrangeFF(container, g2, c); } } /** * Arranges the blocks in the container with the overall height and width * specified as fixed constraints. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size following the arrangement. */ protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // TODO: implement this properly return arrangeFN(container, g2, constraint); } /** * Arranges the blocks with the overall width and height to fit within * specified ranges. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size after the arrangement. */ protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // first arrange without constraints, and see if this fits within // the required ranges... Size2D s1 = arrangeNN(container, g2); if (constraint.getWidthRange().contains(s1.width)) { return s1; // TODO: we didn't check the height yet } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().getUpperBound() ); return arrangeFR(container, g2, c); } } /** * Arranges the blocks in the container with a range constraint on the * width and a fixed height. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size following the arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D s = arrangeNF(container, g2, constraint); if (constraint.getWidthRange().contains(s.width)) { return s; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().constrain(s.getWidth()) ); return arrangeFF(container, g2, c); } } /** * Arranges the block with a range constraint on the width, and no * constraint on the height. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size following the arrangement. */ protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // first arrange without constraints, then see if the width fits // within the required range...if not, call arrangeFN() at max width Size2D s1 = arrangeNN(container, g2); if (constraint.getWidthRange().contains(s1.width)) { return s1; } else { RectangleConstraint c = constraint.toFixedWidth( constraint.getWidthRange().getUpperBound() ); return arrangeFN(container, g2, c); } } /** * Arranges the blocks without any constraints. This puts all blocks * into a single row. * * @param container the container. * @param g2 the graphics device. * * @return The size after the arrangement. */ protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { double x = 0.0; double width = 0.0; double maxHeight = 0.0; List blocks = container.getBlocks(); int blockCount = blocks.size(); if (blockCount > 0) { Size2D[] sizes = new Size2D[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { Block block = (Block) blocks.get(i); sizes[i] = block.arrange(g2, RectangleConstraint.NONE); width = width + sizes[i].getWidth(); maxHeight = Math.max(sizes[i].height, maxHeight); block.setBounds( new Rectangle2D.Double( x, 0.0, sizes[i].width, sizes[i].height ) ); x = x + sizes[i].width + this.horizontalGap; } if (blockCount > 1) { width = width + this.horizontalGap * (blockCount - 1); } if (this.verticalAlignment != VerticalAlignment.TOP) { for (int i = 0; i < blocks.size(); i++) { //Block b = (Block) blocks.get(i); if (this.verticalAlignment == VerticalAlignment.CENTER) { //TODO: shift block down by half } else if (this.verticalAlignment == VerticalAlignment.BOTTOM) { //TODO: shift block down to bottom } } } } return new Size2D(width, maxHeight); } /** * Arranges the blocks with no width constraint and a fixed height * constraint. This puts all blocks into a single row. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size after the arrangement. */ protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { // TODO: for now we are ignoring the height constraint return arrangeNN(container, g2); } /** * Clears any cached information. */ public void clear() { // no action required. } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof FlowArrangement)) { return false; } FlowArrangement that = (FlowArrangement) obj; if (this.horizontalAlignment != that.horizontalAlignment) { return false; } if (this.verticalAlignment != that.verticalAlignment) { return false; } if (this.horizontalGap != that.horizontalGap) { return false; } if (this.verticalGap != that.verticalGap) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/GridArrangement.java0000644000175000017500000003751711173030414027454 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * GridArrangement.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 08-Feb-2005 : Version 1 (DG); * 03-Dec-2008 : Implemented missing methods, and fixed bugs reported in * patch 2370487 (DG); * */ package org.jfree.chart.block; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.ui.Size2D; /** * Arranges blocks in a grid within their container. */ public class GridArrangement implements Arrangement, Serializable { /** For serialization. */ private static final long serialVersionUID = -2563758090144655938L; /** The rows. */ private int rows; /** The columns. */ private int columns; /** * Creates a new grid arrangement. * * @param rows the row count. * @param columns the column count. */ public GridArrangement(int rows, int columns) { this.rows = rows; this.columns = columns; } /** * Adds a block and a key which can be used to determine the position of * the block in the arrangement. This method is called by the container * (you don't need to call this method directly) and gives the arrangement * an opportunity to record the details if they are required. * * @param block the block. * @param key the key (null permitted). */ public void add(Block block, Object key) { // can safely ignore } /** * Arranges the blocks within the specified container, subject to the given * constraint. * * @param container the container (null not permitted). * @param constraint the constraint. * @param g2 the graphics device. * * @return The size following the arrangement. */ public Size2D arrange(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { LengthConstraintType w = constraint.getWidthConstraintType(); LengthConstraintType h = constraint.getHeightConstraintType(); if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { return arrangeNN(container, g2); } else if (h == LengthConstraintType.FIXED) { return arrangeNF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { // find optimum height, then map to range return arrangeNR(container, g2, constraint); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { // find optimum height return arrangeFN(container, g2, constraint); } else if (h == LengthConstraintType.FIXED) { return arrangeFF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { // find optimum height and map to range return arrangeFR(container, g2, constraint); } } else if (w == LengthConstraintType.RANGE) { // find optimum width and map to range if (h == LengthConstraintType.NONE) { // find optimum height return arrangeRN(container, g2, constraint); } else if (h == LengthConstraintType.FIXED) { // fixed width return arrangeRF(container, g2, constraint); } else if (h == LengthConstraintType.RANGE) { return arrangeRR(container, g2, constraint); } } throw new RuntimeException("Should never get to here!"); } /** * Arranges the container with no constraint on the width or height. * * @param container the container (null not permitted). * @param g2 the graphics device. * * @return The size. */ protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { double maxW = 0.0; double maxH = 0.0; List blocks = container.getBlocks(); Iterator iterator = blocks.iterator(); while (iterator.hasNext()) { Block b = (Block) iterator.next(); if (b != null) { Size2D s = b.arrange(g2, RectangleConstraint.NONE); maxW = Math.max(maxW, s.width); maxH = Math.max(maxH, s.height); } } double width = this.columns * maxW; double height = this.rows * maxH; RectangleConstraint c = new RectangleConstraint(width, height); return arrangeFF(container, g2, c); } /** * Arranges the container with a fixed overall width and height. * * @param container the container (null not permitted). * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The size following the arrangement. */ protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { double width = constraint.getWidth() / this.columns; double height = constraint.getHeight() / this.rows; List blocks = container.getBlocks(); for (int c = 0; c < this.columns; c++) { for (int r = 0; r < this.rows; r++) { int index = r * this.columns + c; if (index >= blocks.size()) { break; } Block b = (Block) blocks.get(index); if (b != null) { b.setBounds(new Rectangle2D.Double(c * width, r * height, width, height)); } } } return new Size2D(this.columns * width, this.rows * height); } /** * Arrange with a fixed width and a height within a given range. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint c1 = constraint.toUnconstrainedHeight(); Size2D size1 = arrange(container, g2, c1); if (constraint.getHeightRange().contains(size1.getHeight())) { return size1; } else { double h = constraint.getHeightRange().constrain(size1.getHeight()); RectangleConstraint c2 = constraint.toFixedHeight(h); return arrange(container, g2, c2); } } /** * Arrange with a fixed height and a width within a given range. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint c1 = constraint.toUnconstrainedWidth(); Size2D size1 = arrange(container, g2, c1); if (constraint.getWidthRange().contains(size1.getWidth())) { return size1; } else { double w = constraint.getWidthRange().constrain(size1.getWidth()); RectangleConstraint c2 = constraint.toFixedWidth(w); return arrange(container, g2, c2); } } /** * Arrange with a fixed width and no height constraint. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint c1 = constraint.toUnconstrainedWidth(); Size2D size1 = arrange(container, g2, c1); if (constraint.getWidthRange().contains(size1.getWidth())) { return size1; } else { double w = constraint.getWidthRange().constrain(size1.getWidth()); RectangleConstraint c2 = constraint.toFixedWidth(w); return arrange(container, g2, c2); } } /** * Arrange with a fixed height and no width constraint. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeNR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint c1 = constraint.toUnconstrainedHeight(); Size2D size1 = arrange(container, g2, c1); if (constraint.getHeightRange().contains(size1.getHeight())) { return size1; } else { double h = constraint.getHeightRange().constrain(size1.getHeight()); RectangleConstraint c2 = constraint.toFixedHeight(h); return arrange(container, g2, c2); } } /** * Arrange with ranges for both the width and height constraints. * * @param container the container. * @param constraint the constraint. * @param g2 the graphics device. * * @return The size of the arrangement. */ protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { Size2D size1 = arrange(container, g2, RectangleConstraint.NONE); if (constraint.getWidthRange().contains(size1.getWidth())) { if (constraint.getHeightRange().contains(size1.getHeight())) { return size1; } else { // width is OK, but height must be constrained double h = constraint.getHeightRange().constrain( size1.getHeight()); RectangleConstraint cc = new RectangleConstraint( size1.getWidth(), h); return arrangeFF(container, g2, cc); } } else { if (constraint.getHeightRange().contains(size1.getHeight())) { // height is OK, but width must be constrained double w = constraint.getWidthRange().constrain( size1.getWidth()); RectangleConstraint cc = new RectangleConstraint(w, size1.getHeight()); return arrangeFF(container, g2, cc); } else { double w = constraint.getWidthRange().constrain( size1.getWidth()); double h = constraint.getHeightRange().constrain( size1.getHeight()); RectangleConstraint cc = new RectangleConstraint(w, h); return arrangeFF(container, g2, cc); } } } /** * Arrange with a fixed width and a height within a given range. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size of the arrangement. */ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { double width = constraint.getWidth() / this.columns; RectangleConstraint bc = constraint.toFixedWidth(width); List blocks = container.getBlocks(); double maxH = 0.0; for (int r = 0; r < this.rows; r++) { for (int c = 0; c < this.columns; c++) { int index = r * this.columns + c; if (index >= blocks.size()) { break; } Block b = (Block) blocks.get(index); if (b != null) { Size2D s = b.arrange(g2, bc); maxH = Math.max(maxH, s.getHeight()); } } } RectangleConstraint cc = constraint.toFixedHeight(maxH * this.rows); return arrange(container, g2, cc); } /** * Arrange with a fixed height and no constraint for the width. * * @param container the container. * @param g2 the graphics device. * @param constraint the constraint. * * @return The size of the arrangement. */ protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { double height = constraint.getHeight() / this.rows; RectangleConstraint bc = constraint.toFixedHeight(height); List blocks = container.getBlocks(); double maxW = 0.0; for (int r = 0; r < this.rows; r++) { for (int c = 0; c < this.columns; c++) { int index = r * this.columns + c; if (index >= blocks.size()) { break; } Block b = (Block) blocks.get(index); if (b != null) { Size2D s = b.arrange(g2, bc); maxW = Math.max(maxW, s.getWidth()); } } } RectangleConstraint cc = constraint.toFixedWidth(maxW * this.columns); return arrange(container, g2, cc); } /** * Clears any cached layout information retained by the arrangement. */ public void clear() { // nothing to clear } /** * Compares this layout manager for equality with an arbitrary object. * * @param obj the object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GridArrangement)) { return false; } GridArrangement that = (GridArrangement) obj; if (this.columns != that.columns) { return false; } if (this.rows != that.rows) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/LabelBlock.java0000644000175000017500000003224611173030414026367 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * LabelBlock.java * --------------- * (C) Copyright 2004-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Pierre-Marie Le Biot; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 19-Apr-2005 : Added optional tooltip and URL text items, * draw() method now returns entities if * requested (DG); * 13-May-2005 : Added methods to set the font (DG); * 01-Sep-2005 : Added paint management (PMLB); * Implemented equals() and clone() (PublicCloneable) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Fixed entity area in draw() method (DG); * 16-Mar-2007 : Fixed serialization when using GradientPaint (DG); * 10-Feb-2009 : Added alignment fields (DG); * */ package org.jfree.chart.block; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.io.SerialUtilities; import org.jfree.text.TextBlock; import org.jfree.text.TextBlockAnchor; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.Size2D; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A block containing a label. */ public class LabelBlock extends AbstractBlock implements Block, PublicCloneable { /** For serialization. */ static final long serialVersionUID = 249626098864178017L; /** * The text for the label - retained in case the label needs * regenerating (for example, to change the font). */ private String text; /** The label. */ private TextBlock label; /** The font. */ private Font font; /** The tool tip text (can be null). */ private String toolTipText; /** The URL text (can be null). */ private String urlText; /** The default color. */ public static final Paint DEFAULT_PAINT = Color.black; /** The paint. */ private transient Paint paint; /** * The content alignment point. * * @since 1.0.13 */ private TextBlockAnchor contentAlignmentPoint; /** * The anchor point for the text. * * @since 1.0.13 */ private RectangleAnchor textAnchor; /** * Creates a new label block. * * @param label the label (null not permitted). */ public LabelBlock(String label) { this(label, new Font("SansSerif", Font.PLAIN, 10), DEFAULT_PAINT); } /** * Creates a new label block. * * @param text the text for the label (null not permitted). * @param font the font (null not permitted). */ public LabelBlock(String text, Font font) { this(text, font, DEFAULT_PAINT); } /** * Creates a new label block. * * @param text the text for the label (null not permitted). * @param font the font (null not permitted). * @param paint the paint (null not permitted). */ public LabelBlock(String text, Font font, Paint paint) { this.text = text; this.paint = paint; this.label = TextUtilities.createTextBlock(text, font, this.paint); this.font = font; this.toolTipText = null; this.urlText = null; this.contentAlignmentPoint = TextBlockAnchor.CENTER; this.textAnchor = RectangleAnchor.CENTER; } /** * Returns the font. * * @return The font (never null). * * @see #setFont(Font) */ public Font getFont() { return this.font; } /** * Sets the font and regenerates the label. * * @param font the font (null not permitted). * * @see #getFont() */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.font = font; this.label = TextUtilities.createTextBlock(this.text, font, this.paint); } /** * Returns the paint. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint and regenerates the label. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; this.label = TextUtilities.createTextBlock(this.text, this.font, this.paint); } /** * Returns the tool tip text. * * @return The tool tip text (possibly null). * * @see #setToolTipText(String) */ public String getToolTipText() { return this.toolTipText; } /** * Sets the tool tip text. * * @param text the text (null permitted). * * @see #getToolTipText() */ public void setToolTipText(String text) { this.toolTipText = text; } /** * Returns the URL text. * * @return The URL text (possibly null). * * @see #setURLText(String) */ public String getURLText() { return this.urlText; } /** * Sets the URL text. * * @param text the text (null permitted). * * @see #getURLText() */ public void setURLText(String text) { this.urlText = text; } /** * Returns the content alignment point. * * @return The content alignment point (never null). * * @since 1.0.13 */ public TextBlockAnchor getContentAlignmentPoint() { return this.contentAlignmentPoint; } /** * Sets the content alignment point. * * @param anchor the anchor used to determine the alignment point (never * null). * * @since 1.0.13 */ public void setContentAlignmentPoint(TextBlockAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.contentAlignmentPoint = anchor; } /** * Returns the text anchor (never null). * * @return The text anchor. * * @since 1.0.13 */ public RectangleAnchor getTextAnchor() { return this.textAnchor; } /** * Sets the text anchor. * * @param anchor the anchor (null not permitted). * * @since 1.0.13 */ public void setTextAnchor(RectangleAnchor anchor) { this.textAnchor = anchor; } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { g2.setFont(this.font); Size2D s = this.label.calculateDimensions(g2); return new Size2D(calculateTotalWidth(s.getWidth()), calculateTotalHeight(s.getHeight())); } /** * Draws the block. * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return Always null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = trimMargin(area); drawBorder(g2, area); area = trimBorder(area); area = trimPadding(area); // check if we need to collect chart entities from the container EntityBlockParams ebp = null; StandardEntityCollection sec = null; Shape entityArea = null; if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { sec = new StandardEntityCollection(); entityArea = (Shape) area.clone(); } } g2.setPaint(this.paint); g2.setFont(this.font); Point2D pt = RectangleAnchor.coordinates(area, this.textAnchor); this.label.draw(g2, (float) pt.getX(), (float) pt.getY(), this.contentAlignmentPoint); BlockResult result = null; if (ebp != null && sec != null) { if (this.toolTipText != null || this.urlText != null) { ChartEntity entity = new ChartEntity(entityArea, this.toolTipText, this.urlText); sec.add(entity); result = new BlockResult(); result.setEntityCollection(sec); } } return result; } /** * Tests this LabelBlock for equality with an arbitrary * object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (!(obj instanceof LabelBlock)) { return false; } LabelBlock that = (LabelBlock) obj; if (!this.text.equals(that.text)) { return false; } if (!this.font.equals(that.font)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { return false; } if (!ObjectUtilities.equal(this.urlText, that.urlText)) { return false; } if (!this.contentAlignmentPoint.equals(that.contentAlignmentPoint)) { return false; } if (!this.textAnchor.equals(that.textAnchor)) { return false; } return super.equals(obj); } /** * Returns a clone of this LabelBlock instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/LengthConstraintType.java0000644000175000017500000001010411173030414030512 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * LengthConstraintType.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 08-Feb-2004 : Version 1 (DG); * */ package org.jfree.chart.block; import java.io.ObjectStreamException; import java.io.Serializable; /** * Defines tokens used to indicate a length constraint type. */ public final class LengthConstraintType implements Serializable { /** For serialization. */ private static final long serialVersionUID = -1156658804028142978L; /** NONE. */ public static final LengthConstraintType NONE = new LengthConstraintType("LengthConstraintType.NONE"); /** Range. */ public static final LengthConstraintType RANGE = new LengthConstraintType("RectangleConstraintType.RANGE"); /** FIXED. */ public static final LengthConstraintType FIXED = new LengthConstraintType("LengthConstraintType.FIXED"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private LengthConstraintType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof LengthConstraintType)) { return false; } LengthConstraintType that = (LengthConstraintType) obj; if (!this.name.equals(that.toString())) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(LengthConstraintType.NONE)) { return LengthConstraintType.NONE; } else if (this.equals(LengthConstraintType.RANGE)) { return LengthConstraintType.RANGE; } else if (this.equals(LengthConstraintType.FIXED)) { return LengthConstraintType.FIXED; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/LineBorder.java0000644000175000017500000001622211173030414026416 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * LineBorder.java * --------------- * (C) Copyright 2007, 2008, by Christo Zietsman and Contributors. * * Original Author: Christo Zietsman; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 16-Mar-2007 : Version 1, contributed by Christo Zietsman with * modifications by DG (DG); * 13-Jun-2007 : Don't draw if area doesn't have positive dimensions (DG); * */ package org.jfree.chart.block; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A line border for any {@link AbstractBlock}. * * @since 1.0.5 */ public class LineBorder implements BlockFrame, Serializable { /** For serialization. */ static final long serialVersionUID = 4630356736707233924L; /** The line color. */ private transient Paint paint; /** The line stroke. */ private transient Stroke stroke; /** The insets. */ private RectangleInsets insets; /** * Creates a default border. */ public LineBorder() { this(Color.black, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); } /** * Creates a new border with the specified color. * * @param paint the color (null not permitted). * @param stroke the border stroke (null not permitted). * @param insets the insets (null not permitted). */ public LineBorder(Paint paint, Stroke stroke, RectangleInsets insets) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } if (insets == null) { throw new IllegalArgumentException("Null 'insets' argument."); } this.paint = paint; this.stroke = stroke; this.insets = insets; } /** * Returns the paint. * * @return The paint (never null). */ public Paint getPaint() { return this.paint; } /** * Returns the insets. * * @return The insets (never null). */ public RectangleInsets getInsets() { return this.insets; } /** * Returns the stroke. * * @return The stroke (never null). */ public Stroke getStroke() { return this.stroke; } /** * Draws the border by filling in the reserved space (in black). * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { double w = area.getWidth(); double h = area.getHeight(); // if the area has zero height or width, we shouldn't draw anything if (w <= 0.0 || h <= 0.0) { return; } double t = this.insets.calculateTopInset(h); double b = this.insets.calculateBottomInset(h); double l = this.insets.calculateLeftInset(w); double r = this.insets.calculateRightInset(w); double x = area.getX(); double y = area.getY(); double x0 = x + l / 2.0; double x1 = x + w - r / 2.0; double y0 = y + h - b / 2.0; double y1 = y + t / 2.0; g2.setPaint(getPaint()); g2.setStroke(getStroke()); Line2D line = new Line2D.Double(); if (t > 0.0) { line.setLine(x0, y1, x1, y1); g2.draw(line); } if (b > 0.0) { line.setLine(x0, y0, x1, y0); g2.draw(line); } if (l > 0.0) { line.setLine(x0, y0, x0, y1); g2.draw(line); } if (r > 0.0) { line.setLine(x1, y0, x1, y1); g2.draw(line); } } /** * Tests this border for equality with an arbitrary instance. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LineBorder)) { return false; } LineBorder that = (LineBorder) obj; if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!this.insets.equals(that.insets)) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.stroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/RectangleConstraint.java0000644000175000017500000002757311173030414030355 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * RectangleConstraint.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 02-Feb-2005 : Added toString() method (DG); * 08-Feb-2005 : Separated height and width constraints (DG); * 13-May-2005 : Added convenience constructor and new methods for * transforming constraints (DG); * */ package org.jfree.chart.block; import org.jfree.data.Range; import org.jfree.ui.Size2D; /** * A description of a constraint for resizing a rectangle. Constraints are * immutable. */ public class RectangleConstraint { /** * An instance representing no constraint. */ public static final RectangleConstraint NONE = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 0.0, null, LengthConstraintType.NONE); /** The width. */ private double width; /** The width range. */ private Range widthRange; /** The width constraint type. */ private LengthConstraintType widthConstraintType; /** The fixed or maximum height. */ private double height; private Range heightRange; /** The constraint type. */ private LengthConstraintType heightConstraintType; /** * Creates a new "fixed width and height" instance. * * @param w the fixed width. * @param h the fixed height. */ public RectangleConstraint(double w, double h) { this(w, null, LengthConstraintType.FIXED, h, null, LengthConstraintType.FIXED); } /** * Creates a new "range width and height" instance. * * @param w the width range. * @param h the height range. */ public RectangleConstraint(Range w, Range h) { this(0.0, w, LengthConstraintType.RANGE, 0.0, h, LengthConstraintType.RANGE); } /** * Creates a new constraint with a range for the width and a * fixed height. * * @param w the width range. * @param h the fixed height. */ public RectangleConstraint(Range w, double h) { this(0.0, w, LengthConstraintType.RANGE, h, null, LengthConstraintType.FIXED); } /** * Creates a new constraint with a fixed width and a range for * the height. * * @param w the fixed width. * @param h the height range. */ public RectangleConstraint(double w, Range h) { this(w, null, LengthConstraintType.FIXED, 0.0, h, LengthConstraintType.RANGE); } /** * Creates a new constraint. * * @param w the fixed or maximum width. * @param widthRange the width range. * @param widthConstraintType the width type. * @param h the fixed or maximum height. * @param heightRange the height range. * @param heightConstraintType the height type. */ public RectangleConstraint(double w, Range widthRange, LengthConstraintType widthConstraintType, double h, Range heightRange, LengthConstraintType heightConstraintType) { if (widthConstraintType == null) { throw new IllegalArgumentException("Null 'widthType' argument."); } if (heightConstraintType == null) { throw new IllegalArgumentException("Null 'heightType' argument."); } this.width = w; this.widthRange = widthRange; this.widthConstraintType = widthConstraintType; this.height = h; this.heightRange = heightRange; this.heightConstraintType = heightConstraintType; } /** * Returns the fixed width. * * @return The width. */ public double getWidth() { return this.width; } /** * Returns the width range. * * @return The range (possibly null). */ public Range getWidthRange() { return this.widthRange; } /** * Returns the constraint type. * * @return The constraint type (never null). */ public LengthConstraintType getWidthConstraintType() { return this.widthConstraintType; } /** * Returns the fixed height. * * @return The height. */ public double getHeight() { return this.height; } /** * Returns the width range. * * @return The range (possibly null). */ public Range getHeightRange() { return this.heightRange; } /** * Returns the constraint type. * * @return The constraint type (never null). */ public LengthConstraintType getHeightConstraintType() { return this.heightConstraintType; } /** * Returns a constraint that matches this one on the height attributes, * but has no width constraint. * * @return A new constraint. */ public RectangleConstraint toUnconstrainedWidth() { if (this.widthConstraintType == LengthConstraintType.NONE) { return this; } else { return new RectangleConstraint(this.width, this.widthRange, LengthConstraintType.NONE, this.height, this.heightRange, this.heightConstraintType); } } /** * Returns a constraint that matches this one on the width attributes, * but has no height constraint. * * @return A new constraint. */ public RectangleConstraint toUnconstrainedHeight() { if (this.heightConstraintType == LengthConstraintType.NONE) { return this; } else { return new RectangleConstraint(this.width, this.widthRange, this.widthConstraintType, 0.0, this.heightRange, LengthConstraintType.NONE); } } /** * Returns a constraint that matches this one on the height attributes, * but has a fixed width constraint. * * @param width the fixed width. * * @return A new constraint. */ public RectangleConstraint toFixedWidth(double width) { return new RectangleConstraint(width, this.widthRange, LengthConstraintType.FIXED, this.height, this.heightRange, this.heightConstraintType); } /** * Returns a constraint that matches this one on the width attributes, * but has a fixed height constraint. * * @param height the fixed height. * * @return A new constraint. */ public RectangleConstraint toFixedHeight(double height) { return new RectangleConstraint(this.width, this.widthRange, this.widthConstraintType, height, this.heightRange, LengthConstraintType.FIXED); } /** * Returns a constraint that matches this one on the height attributes, * but has a range width constraint. * * @param range the width range (null not permitted). * * @return A new constraint. */ public RectangleConstraint toRangeWidth(Range range) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } return new RectangleConstraint(range.getUpperBound(), range, LengthConstraintType.RANGE, this.height, this.heightRange, this.heightConstraintType); } /** * Returns a constraint that matches this one on the width attributes, * but has a range height constraint. * * @param range the height range (null not permitted). * * @return A new constraint. */ public RectangleConstraint toRangeHeight(Range range) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } return new RectangleConstraint(this.width, this.widthRange, this.widthConstraintType, range.getUpperBound(), range, LengthConstraintType.RANGE); } /** * Returns a string representation of this instance, mostly used for * debugging purposes. * * @return A string. */ public String toString() { return "RectangleConstraint[" + this.widthConstraintType.toString() + ": width=" + this.width + ", height=" + this.height + "]"; } /** * Returns the new size that reflects the constraints defined by this * instance. * * @param base the base size. * * @return The constrained size. */ public Size2D calculateConstrainedSize(Size2D base) { Size2D result = new Size2D(); if (this.widthConstraintType == LengthConstraintType.NONE) { result.width = base.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.RANGE) { result.width = this.widthRange.constrain(base.width); if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } else if (this.widthConstraintType == LengthConstraintType.FIXED) { result.width = this.width; if (this.heightConstraintType == LengthConstraintType.NONE) { result.height = base.height; } else if (this.heightConstraintType == LengthConstraintType.RANGE) { result.height = this.heightRange.constrain(base.height); } else if (this.heightConstraintType == LengthConstraintType.FIXED) { result.height = this.height; } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/block/package.html0000644000175000017500000000031711173030414026005 0ustar vincentvincent Blocks and layout classes used extensively by the {@link org.jfree.chart.title.LegendTitle} class. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/demo/0000755000175000017500000000000011216245561023366 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/demo/BarChartDemo1.java0000644000175000017500000001623411173030414026602 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * BarChartDemo1.java * ------------------ * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 09-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.demo; import java.awt.Color; import java.awt.Dimension; import java.awt.GradientPaint; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; /** * A simple demonstration application showing how to create a bar chart. */ public class BarChartDemo1 extends ApplicationFrame { /** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo1(String title) { super(title); CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); } /** * Returns a sample dataset. * * @return The dataset. */ private static CategoryDataset createDataset() { // row keys... String series1 = "First"; String series2 = "Second"; String series3 = "Third"; // column keys... String category1 = "Category 1"; String category2 = "Category 2"; String category3 = "Category 3"; String category4 = "Category 4"; String category5 = "Category 5"; // create the dataset... DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, category1); dataset.addValue(4.0, series1, category2); dataset.addValue(3.0, series1, category3); dataset.addValue(5.0, series1, category4); dataset.addValue(5.0, series1, category5); dataset.addValue(5.0, series2, category1); dataset.addValue(7.0, series2, category2); dataset.addValue(6.0, series2, category3); dataset.addValue(8.0, series2, category4); dataset.addValue(4.0, series2, category5); dataset.addValue(4.0, series3, category1); dataset.addValue(3.0, series3, category2); dataset.addValue(2.0, series3, category3); dataset.addValue(3.0, series3, category4); dataset.addValue(6.0, series3, category5); return dataset; } /** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart( "Bar Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { BarChartDemo1 demo = new BarChartDemo1("Bar Chart Demo 1"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/demo/PieChartDemo1.java0000644000175000017500000001100411173030414026601 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * PieChartDemo1.java * ------------------ * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 09-Mar-2005 : Version 1, copied from the demo collection that ships with * the JFreeChart Developer Guide (DG); * */ package org.jfree.chart.demo; import javax.swing.JPanel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; /** * A simple demonstration application showing how to create a pie chart using * data from a {@link DefaultPieDataset}. */ public class PieChartDemo1 extends ApplicationFrame { /** * Default constructor. * * @param title the frame title. */ public PieChartDemo1(String title) { super(title); setContentPane(createDemoPanel()); } /** * Creates a sample dataset. * * @return A sample dataset. */ private static PieDataset createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); return dataset; } /** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; } /** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createChart(createDataset()); return new ChartPanel(chart); } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** PieChartDemo1 demo = new PieChartDemo1("Pie Chart Demo 1"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java0000644000175000017500000001725711173030414030155 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TimeSeriesChartDemo1.java * ------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 09-Mar-2005 : Version 1, copied from the demo collection that ships with * the JFreeChart Developer Guide (DG); * */ package org.jfree.chart.demo; import java.awt.Color; import java.text.SimpleDateFormat; import javax.swing.JPanel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.time.Month; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.XYDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RectangleInsets; import org.jfree.ui.RefineryUtilities; /** * An example of a time series chart. For the most part, default settings are * used, except that the renderer is modified to show filled shapes (as well as * lines) at each data point. */ public class TimeSeriesChartDemo1 extends ApplicationFrame { /** * A demonstration application showing how to create a simple time series * chart. This example uses monthly data. * * @param title the frame title. */ public TimeSeriesChartDemo1(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); } /** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; } /** * Creates a dataset, consisting of two series of monthly data. * * @return The dataset. */ private static XYDataset createDataset() { TimeSeries s1 = new TimeSeries("L&G European Index Trust"); s1.add(new Month(2, 2001), 181.8); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); // ****************************************************************** // More than 150 demo applications are included with the JFreeChart // Developer Guide...for more information, see: // // > http://www.object-refinery.com/jfreechart/guide.html // // ****************************************************************** TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; } /** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createChart(createDataset()); ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); return panel; } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { TimeSeriesChartDemo1 demo = new TimeSeriesChartDemo1( "Time Series Chart Demo 1"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/demo/package.html0000644000175000017500000000070011173030414025633 0ustar vincentvincent Some basic demos to get you started. A large range of demo applications is available for download (including source code) with the JFreeChart Developer Guide. For more information, see:

* In designing the panel, we need to be aware that subclasses of Plot will * need to implement subclasses of PlotPropertyEditPanel - so we need to * leave one or two 'slots' where the subclasses can extend the user * interface. * * @param plot the plot, which should be changed. */ public DefaultPlotEditor(Plot plot) { this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); if (plot instanceof CategoryPlot) { this.plotOrientation = ((CategoryPlot) plot).getOrientation(); } else if (plot instanceof XYPlot) { this.plotOrientation = ((XYPlot) plot).getOrientation(); } if (plot instanceof CategoryPlot) { CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; this.drawLines = BooleanUtilities.valueOf( r.getBaseLinesVisible()); this.drawShapes = BooleanUtilities.valueOf( r.getBaseShapesVisible()); } } else if (plot instanceof XYPlot) { XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); this.drawShapes = BooleanUtilities.valueOf( r.getBaseShapesVisible()); } } setLayout(new BorderLayout()); this.availableStrokeSamples = new StrokeSample[4]; this.availableStrokeSamples[0] = new StrokeSample(null); this.availableStrokeSamples[1] = new StrokeSample( new BasicStroke(1.0f)); this.availableStrokeSamples[2] = new StrokeSample( new BasicStroke(2.0f)); this.availableStrokeSamples[3] = new StrokeSample( new BasicStroke(3.0f)); // create a panel for the settings... JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":"))); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder( localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); // interior.add(new JLabel(localizationResources.getString("Insets"))); // JButton button = new JButton( // localizationResources.getString("Edit...") // ); // button.setActionCommand("Insets"); // button.addActionListener(this); // // this.insetsTextField = new InsetsTextField(this.plotInsets); // this.insetsTextField.setEnabled(false); // interior.add(this.insetsTextField); // interior.add(button); interior.add(new JLabel(localizationResources.getString( "Outline_stroke"))); JButton button = new JButton(localizationResources.getString( "Select...")); button.setActionCommand("OutlineStroke"); button.addActionListener(this); interior.add(this.outlineStrokeSample); interior.add(button); interior.add(new JLabel(localizationResources.getString( "Outline_Paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("OutlinePaint"); button.addActionListener(this); interior.add(this.outlinePaintSample); interior.add(button); interior.add(new JLabel(localizationResources.getString( "Background_paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(this.backgroundPaintSample); interior.add(button); if (this.plotOrientation != null) { boolean isVertical = this.plotOrientation.equals( PlotOrientation.VERTICAL); int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL; interior.add(new JLabel(localizationResources.getString( "Orientation"))); this.orientationCombo = new JComboBox(orientationNames); this.orientationCombo.setSelectedIndex(index); this.orientationCombo.setActionCommand("Orientation"); this.orientationCombo.addActionListener(this); interior.add(new JPanel()); interior.add(this.orientationCombo); } if (this.drawLines != null) { interior.add(new JLabel(localizationResources.getString( "Draw_lines"))); this.drawLinesCheckBox = new JCheckBox(); this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); this.drawLinesCheckBox.setActionCommand("DrawLines"); this.drawLinesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawLinesCheckBox); } if (this.drawShapes != null) { interior.add(new JLabel(localizationResources.getString( "Draw_shapes"))); this.drawShapesCheckBox = new JCheckBox(); this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); this.drawShapesCheckBox.setActionCommand("DrawShapes"); this.drawShapesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawShapesCheckBox); } general.add(interior, BorderLayout.NORTH); JPanel appearance = new JPanel(new BorderLayout()); appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); appearance.add(general, BorderLayout.NORTH); JTabbedPane tabs = new JTabbedPane(); tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance( domainAxis); if (this.domainAxisPropertyPanel != null) { this.domainAxisPropertyPanel.setBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Domain_Axis"), this.domainAxisPropertyPanel); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); if (this.rangeAxisPropertyPanel != null) { this.rangeAxisPropertyPanel.setBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Range_Axis"), this.rangeAxisPropertyPanel); } //dmo: added this panel for colorbar control. (start dmo additions) ColorBar colorBar = null; if (plot instanceof ContourPlot) { colorBar = ((ContourPlot) plot).getColorBar(); } this.colorBarAxisPropertyPanel = DefaultColorBarEditor.getInstance( colorBar); if (this.colorBarAxisPropertyPanel != null) { this.colorBarAxisPropertyPanel.setBorder( BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Color_Bar"), this.colorBarAxisPropertyPanel); } //dmo: (end dmo additions) tabs.add(localizationResources.getString("Appearance"), appearance); panel.add(tabs); add(panel); } /** * Returns the current plot insets. * * @return The current plot insets. */ public RectangleInsets getPlotInsets() { if (this.plotInsets == null) { this.plotInsets = new RectangleInsets(0.0, 0.0, 0.0, 0.0); } return this.plotInsets; } /** * Returns the current background paint. * * @return The current background paint. */ public Paint getBackgroundPaint() { return this.backgroundPaintSample.getPaint(); } /** * Returns the current outline stroke. * * @return The current outline stroke (possibly null). */ public Stroke getOutlineStroke() { return this.outlineStrokeSample.getStroke(); } /** * Returns the current outline paint. * * @return The current outline paint. */ public Paint getOutlinePaint() { return this.outlinePaintSample.getPaint(); } /** * Returns a reference to the panel for editing the properties of the * domain axis. * * @return A reference to a panel. */ public DefaultAxisEditor getDomainAxisPropertyEditPanel() { return this.domainAxisPropertyPanel; } /** * Returns a reference to the panel for editing the properties of the * range axis. * * @return A reference to a panel. */ public DefaultAxisEditor getRangeAxisPropertyEditPanel() { return this.rangeAxisPropertyPanel; } /** * Handles user actions generated within the panel. * @param event the event */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("BackgroundPaint")) { attemptBackgroundPaintSelection(); } else if (command.equals("OutlineStroke")) { attemptOutlineStrokeSelection(); } else if (command.equals("OutlinePaint")) { attemptOutlinePaintSelection(); } // else if (command.equals("Insets")) { // editInsets(); // } else if (command.equals("Orientation")) { attemptOrientationSelection(); } else if (command.equals("DrawLines")) { attemptDrawLinesSelection(); } else if (command.equals("DrawShapes")) { attemptDrawShapesSelection(); } } /** * Allow the user to change the background paint. */ private void attemptBackgroundPaintSelection() { Color c; c = JColorChooser.showDialog(this, localizationResources.getString( "Background_Color"), Color.blue); if (c != null) { this.backgroundPaintSample.setPaint(c); } } /** * Allow the user to change the outline stroke. */ private void attemptOutlineStrokeSelection() { StrokeChooserPanel panel = new StrokeChooserPanel( this.outlineStrokeSample, this.availableStrokeSamples); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Stroke_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.outlineStrokeSample.setStroke(panel.getSelectedStroke()); } } /** * Allow the user to change the outline paint. We use JColorChooser, so * the user can only choose colors (a subset of all possible paints). */ private void attemptOutlinePaintSelection() { Color c; c = JColorChooser.showDialog(this, localizationResources.getString( "Outline_Color"), Color.blue); if (c != null) { this.outlinePaintSample.setPaint(c); } } // /** // * Allow the user to edit the individual insets' values. // */ // private void editInsets() { // InsetsChooserPanel panel = new InsetsChooserPanel(this.plotInsets); // int result = JOptionPane.showConfirmDialog( // this, panel, localizationResources.getString("Edit_Insets"), // JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE // ); // // if (result == JOptionPane.OK_OPTION) { // this.plotInsets = panel.getInsets(); // this.insetsTextField.setInsets(this.plotInsets); // } // // } // /** * Allow the user to modify the plot orientation if this is an editor for a * CategoryPlot or a XYPlot. */ private void attemptOrientationSelection() { int index = this.orientationCombo.getSelectedIndex(); if (index == ORIENTATION_VERTICAL) { this.plotOrientation = PlotOrientation.VERTICAL; } else { this.plotOrientation = PlotOrientation.HORIZONTAL; } } /** * Allow the user to modify whether or not lines are drawn between data * points by LineAndShapeRenderers and * StandardXYItemRenderers. */ private void attemptDrawLinesSelection() { this.drawLines = BooleanUtilities.valueOf( this.drawLinesCheckBox.isSelected()); } /** * Allow the user to modify whether or not shapes are drawn at data points * by LineAndShapeRenderers and StandardXYItemRenderers. */ private void attemptDrawShapesSelection() { this.drawShapes = BooleanUtilities.valueOf( this.drawShapesCheckBox.isSelected()); } /** * Updates the plot properties to match the properties defined on the panel. * * @param plot The plot. */ public void updatePlotProperties(Plot plot) { // set the plot properties... plot.setOutlinePaint(getOutlinePaint()); plot.setOutlineStroke(getOutlineStroke()); plot.setBackgroundPaint(getBackgroundPaint()); plot.setInsets(getPlotInsets()); // then the axis properties... if (this.domainAxisPropertyPanel != null) { Axis domainAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; domainAxis = p.getDomainAxis(); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; domainAxis = p.getDomainAxis(); } if (domainAxis != null) { this.domainAxisPropertyPanel.setAxisProperties(domainAxis); } } if (this.rangeAxisPropertyPanel != null) { Axis rangeAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; rangeAxis = p.getRangeAxis(); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; rangeAxis = p.getRangeAxis(); } if (rangeAxis != null) { this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis); } } if (this.plotOrientation != null) { if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; p.setOrientation(this.plotOrientation); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; p.setOrientation(this.plotOrientation); } } if (this.drawLines != null) { if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; CategoryItemRenderer r = p.getRenderer(); if (r instanceof LineAndShapeRenderer) { ((LineAndShapeRenderer) r).setLinesVisible( this.drawLines.booleanValue()); } } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; XYItemRenderer r = p.getRenderer(); if (r instanceof StandardXYItemRenderer) { ((StandardXYItemRenderer) r).setPlotLines( this.drawLines.booleanValue()); } } } if (this.drawShapes != null) { if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; CategoryItemRenderer r = p.getRenderer(); if (r instanceof LineAndShapeRenderer) { ((LineAndShapeRenderer) r).setShapesVisible( this.drawShapes.booleanValue()); } } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; XYItemRenderer r = p.getRenderer(); if (r instanceof StandardXYItemRenderer) { ((StandardXYItemRenderer) r).setBaseShapesVisible( this.drawShapes.booleanValue()); } } } //dmo: added this panel for colorbar control. (start dmo additions) if (this.colorBarAxisPropertyPanel != null) { ColorBar colorBar = null; if (plot instanceof ContourPlot) { ContourPlot p = (ContourPlot) plot; colorBar = p.getColorBar(); } if (colorBar != null) { this.colorBarAxisPropertyPanel.setAxisProperties(colorBar); } } //dmo: (end dmo additions) } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultTitleEditor.java0000644000175000017500000002423111173030414030321 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DefaultTitleEditor.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Arnaud Lelievre; * Daniel Gredler; * * Changes * ------- * 24-Nov-2005 : Version 1, based on TitlePropertyEditPanel.java (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.editor; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import org.jfree.chart.JFreeChart; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.layout.LCBLayout; import org.jfree.ui.FontChooserPanel; import org.jfree.ui.FontDisplayField; import org.jfree.ui.PaintSample; /** * A panel for editing the properties of a chart title. */ class DefaultTitleEditor extends JPanel implements ActionListener { /** Whether or not to display the title on the chart. */ private boolean showTitle; /** The checkbox to indicate whether or not to display the title. */ private JCheckBox showTitleCheckBox; /** A field for displaying/editing the title text. */ private JTextField titleField; /** The font used to draw the title. */ private Font titleFont; /** A field for displaying a description of the title font. */ private JTextField fontfield; /** The button to use to select a new title font. */ private JButton selectFontButton; /** The paint (color) used to draw the title. */ private PaintSample titlePaint; /** The button to use to select a new paint (color) to draw the title. */ private JButton selectPaintButton; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Standard constructor: builds a panel for displaying/editing the * properties of the specified title. * * @param title the title, which should be changed. */ public DefaultTitleEditor(Title title) { TextTitle t = (title != null ? (TextTitle) title : new TextTitle(localizationResources.getString("Title"))); this.showTitle = (title != null); this.titleFont = t.getFont(); this.titleField = new JTextField(t.getText()); this.titlePaint = new PaintSample(t.getPaint()); setLayout(new BorderLayout()); JPanel general = new JPanel(new BorderLayout()); general.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), localizationResources.getString("General") ) ); JPanel interior = new JPanel(new LCBLayout(4)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Show_Title"))); this.showTitleCheckBox = new JCheckBox(); this.showTitleCheckBox.setSelected(this.showTitle); this.showTitleCheckBox.setActionCommand("ShowTitle"); this.showTitleCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.showTitleCheckBox); JLabel titleLabel = new JLabel(localizationResources.getString("Text")); interior.add(titleLabel); interior.add(this.titleField); interior.add(new JPanel()); JLabel fontLabel = new JLabel(localizationResources.getString("Font")); this.fontfield = new FontDisplayField(this.titleFont); this.selectFontButton = new JButton( localizationResources.getString("Select...") ); this.selectFontButton.setActionCommand("SelectFont"); this.selectFontButton.addActionListener(this); interior.add(fontLabel); interior.add(this.fontfield); interior.add(this.selectFontButton); JLabel colorLabel = new JLabel( localizationResources.getString("Color") ); this.selectPaintButton = new JButton( localizationResources.getString("Select...") ); this.selectPaintButton.setActionCommand("SelectPaint"); this.selectPaintButton.addActionListener(this); interior.add(colorLabel); interior.add(this.titlePaint); interior.add(this.selectPaintButton); this.enableOrDisableControls(); general.add(interior); add(general, BorderLayout.NORTH); } /** * Returns the title text entered in the panel. * * @return The title text entered in the panel. */ public String getTitleText() { return this.titleField.getText(); } /** * Returns the font selected in the panel. * * @return The font selected in the panel. */ public Font getTitleFont() { return this.titleFont; } /** * Returns the paint selected in the panel. * * @return The paint selected in the panel. */ public Paint getTitlePaint() { return this.titlePaint.getPaint(); } /** * Handles button clicks by passing control to an appropriate handler * method. * * @param event the event */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("SelectFont")) { attemptFontSelection(); } else if (command.equals("SelectPaint")) { attemptPaintSelection(); } else if (command.equals("ShowTitle")) { attemptModifyShowTitle(); } } /** * Presents a font selection dialog to the user. */ public void attemptFontSelection() { FontChooserPanel panel = new FontChooserPanel(this.titleFont); int result = JOptionPane.showConfirmDialog( this, panel, localizationResources.getString("Font_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE ); if (result == JOptionPane.OK_OPTION) { this.titleFont = panel.getSelectedFont(); this.fontfield.setText( this.titleFont.getFontName() + " " + this.titleFont.getSize() ); } } /** * Allow the user the opportunity to select a Paint object. For now, we * just use the standard color chooser - all colors are Paint objects, but * not all Paint objects are colors (later we can implement a more general * Paint chooser). */ public void attemptPaintSelection() { Paint p = this.titlePaint.getPaint(); Color defaultColor = (p instanceof Color ? (Color) p : Color.blue); Color c = JColorChooser.showDialog( this, localizationResources.getString("Title_Color"), defaultColor ); if (c != null) { this.titlePaint.setPaint(c); } } /** * Allow the user the opportunity to change whether the title is * displayed on the chart or not. */ private void attemptModifyShowTitle() { this.showTitle = this.showTitleCheckBox.isSelected(); this.enableOrDisableControls(); } /** * If we are supposed to show the title, the controls are enabled. * If we are not supposed to show the title, the controls are disabled. */ private void enableOrDisableControls() { boolean enabled = (this.showTitle == true); this.titleField.setEnabled(enabled); this.selectFontButton.setEnabled(enabled); this.selectPaintButton.setEnabled(enabled); } /** * Sets the properties of the specified title to match the properties * defined on this panel. * * @param chart the chart whose title is to be modified. */ public void setTitleProperties(JFreeChart chart) { if (this.showTitle) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(getTitleFont()); title.setPaint(getTitlePaint()); } else { chart.setTitle((TextTitle) null); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle.properties0000644000175000017500000000340611173030414031622 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # \:=: Appearance=Appearance Auto-adjust_range=Auto-adjust range: Background=Background: Background_Color=Background Color Background_paint=Background paint: Color=Color: Color_Bar=Color Bar Domain_Axis=Domain Axis Draw_anti-aliased=Draw anti-aliased Draw_lines=Draw Lines: Draw_shapes=Draw Shapes: Edit...=Edit... Edit_Insets=Edit Insets Font=Font: Font_Selection=Font Selection General=General: Grid_Color=Grid Color Insets=Insets: Invert_Palette=Invert Palette: Label=Label: Label_Color=Label Color Label_Insets=Label Insets: Legend=Legend Maximum_range_value=Maximum range value: Minimum_range_value=Minimum range value: No_editor_implemented=No editor implemented Orientation=Orientation: Other=Other Outline=Outline: Outline_Color=Outline Color Outline_stroke=Outline stroke: Outline_Paint=Outline paint: Paint=Paint: Palette_Selection=Palette Selection Palette=Palette: Pen_Stroke_Selection=Pen/Stroke Selection Plot=Plot Range=Range Range_Axis=Range Axis Select...=Select... Series_Label_Color=Series Label Color Series_label_font=Series label font: Series_label_paint=Series label paint: Series_Outline_Paint=Series Outline Paint: Series_Outline_Stroke=Series Outline Stroke: Series_Paint=Series Paint: Series_Stroke=Series Stroke: Show_Legend=Show Legend: Show_tick_labels=Show tick labels Show_tick_marks=Show tick marks Show_Title=Show Title: Set_palette...=Set palette... Step_Palette=Step Palette: Stroke_Selection=Stroke Selection Text=Text: Ticks=Ticks Tick_label_font=Tick label font: Tick_Label_Insets=Tick Label Insets: Title=Title Title_Color=Title Color libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_de.properties0000644000175000017500000000407611173030414032276 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file - german version # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt); # \:=: Appearance=Darstellung Auto-adjust_range=Autojustage des Wertebereichs: Background=Hintergrund: Background_Color=Hintergrundfarbe Background_paint=Hintergrundfarbe: Color=Farbe: Color_Bar=Farbleiste Domain_Axis=Rubrikenachse Draw_anti-aliased=Zeichnung gl\u00e4tten Draw_lines=Zeichne Linien: Draw_shapes=Zeichne Formen: Edit...=Bearbeiten... Edit_Insets=Seitenr\u00e4nder bearbeiten Font=Schrift: Font_Selection=Schriftwahl General=Allgemein: Grid_Color=Gitterfarbe Insets=R\u00e4nder: Invert_Palette=Palette invertieren: Label=Beschriftung: Label_Color=Beschriftungsfarbe Label_Insets=Beschriftungsr\u00e4nder: Legend=Legende Maximum_range_value=Maximalwert: Minimum_range_value=Minimalwert: No_editor_implemented=Kein Editor verf\u00fcgbar Orientation=Orientierung: Other=Sonstiges Outline=Rahmenlinien: Outline_Color=Rahmenfarbe Outline_stroke=Rahmenart: Outline_Paint=Rahmenfarbe: Paint=Farbe: Palette_Selection=Farbauswahl Palette=Palette: Pen_Stroke_Selection=Linienst\u00e4rke w\u00e4hlen Plot=Diagramm Range=Wertebereich Range_Axis=Werteachse Select...=Ausw\u00e4hlen... Series_Label_Color=Farbe der Datenreihenbeschriftung Series_label_font=Schrift der Datenreihenbeschriftung: Series_label_paint=Farbe der Datenreihenbeschriftung: Series_Outline_Paint=Farbe der Datenreihenrahmen: Series_Outline_Stroke=Art der Datenreihenrahmen: Series_Paint=Datenreihenfarbe: Series_Stroke=Datenreihenrahmen: Show_Legend=Legende anzeigen: Show_tick_labels=Beschriftungen zeichnen Show_tick_marks=Markierungen zeichnen Show_Title=\u00dcberschrift anzeigen: Set_palette...=Palette w\u00e4hlen... Step_Palette=Step Palette: Stroke_Selection=Linienauswahl Text=Text: Ticks=Markierungen Tick_label_font=Markierungsschift: Tick_Label_Insets=Markierungsr\u00e4nder: Title=\u00dcberschrift Title_Color=Titelfarbe libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_es.properties0000644000175000017500000000474711173030414032322 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file - spanish version # # Changes (from 16-Dec-2003) # -------------------------- # 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo # 14-Oct-2004 : Revised by: Leopoldo Federico P�rtile (Grupo de Procesamiento Digital de Im�genes) # Universidad Tecnol�gica Nacional - Facultad Regional Resistencia, Argentina \:=\ : Appearance=Apariencia Auto-adjust_range=Ejes auto-ajustables : Background=Fondo : Background_Color=Color de fondo Background_paint=Color de fondo : Color=Color : Color_Bar=Color de la barra Domain_Axis=Eje de las abcisas Draw_anti-aliased=Anti-aliasing Draw_lines=Dibujar l\u00edneas: Draw_shapes=Draw figuras: Edit...=Editar... Edit_Insets=Regular la posici\u00F3n Font=Fuente : Font_Selection=Selecci\u00F3n de fuente General=General : Grid_Color=Color de la rejilla Insets=Posici\u00F3n : Invert_Palette=Invertir la paleta : Label=Etiqueta : Label_Color=Color de la etiqueta Label_Insets=Posici\u00F3n de la etiqueta : Legend=Leyenda Maximum_range_value=Valor m\u00E3ximo del eje : Minimum_range_value=Valor m\u00EDnimo del eje : No_editor_implemented=Editor no disponble Orientation=Orientaci\u00F3n: Other=Otro Outline=Borde : Outline_Paint=Color del borde : Outline_Color=Color del borde Outline_stroke=Estilo del trazo del borde : Paint=Color : Palette=Paleta : Palette_Selection=Selecci\u00F3n de la paleta Pen_Stroke_Selection=Selecci\u00F3n del trazo Plot=Trazo Range=Intervalo Range_Axis=Eje de ordenadas Select...=Seleccionar... Series_Label_Color=Color de la etiqueta de las series Series_label_font=Fuente de la etiqueta de las series : Series_label_paint=Color de la etiqueta de las series : Series_Outline_Paint=Color del borde de las series : Series_Outline_Stroke=Estilo del trazo del borde : Series_Paint=Color de las series : Series_Stroke=Estilo del trazo de las series : Show_Legend=Mostrar leyenda: Show_tick_labels=Visualizar etiquetas de graduaci\u00F3n de escala Show_tick_marks=Visualizar marcas de graduaci\u00F3n de escala Show_Title=Mostrar t\u00EDtulo Set_palette...=Escoja la paleta... Step_Palette=Paso de paleta : Stroke_Selection=Selecci\u00F3n del trazo Text=Texto : Tick_label_font=Fuente de las etiquetas de graduaci\u00F3n de escala : Tick_Label_Insets=Posici\u00F3n de las etiquetas de graduaci\u00F3n de escala : Ticks=Etiquetas de graduaci\u00F3n de escala Title=T\u00EDtulo Title_Color=Color del t\u00EDtulo libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_fr.properties0000644000175000017500000000424311173030414032311 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file - french version # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # \:=\ : Appearance=G\u00E9n\u00E9ral Auto-adjust_range=R\u00E9glage automatique de l'\u00E9chelle : Background=Fond : Background_Color=Couleur du fond Background_paint=Couleur du fond : Color=Couleur : Color_Bar=Couleur de la barre Domain_Axis=Axe des abcisses Draw_anti-aliased=Anti-aliasing Edit...=Edition... Edit_Insets=R\u00E9gler la position Font=Police : Font_Selection=S\u00E9lection de la police General=G\u00E9n\u00E9ral : Grid_Color=Couleur de la grille Insets=Position : Invert_Palette=Inversion de la palette : Label=Etiquette : Label_Color=Couleur de l'\u00E9tiquette Label_Insets=Position de l'\u00E9tiquette : Legend=L\u00E9gende Maximum_range_value=Valeur maximum de l'axe : Minimum_range_value=Valeur minimum de l'axe : No_editor_implemented=Aucun \u00E9diteur disponible Other=Autre Outline=Bordure : Outline_Paint=Couleur de la bordure : Outline_Color=Outline Color Outline_stroke=Bordure : Paint=Couleur : Palette=Palette : Palette_Selection=Selection de la palette Pen_Stroke_Selection=S\u00E9lection du style de trait Plot=Trac\u00E9 Range=Echelle Range_Axis=Axe des ordonn\u00E9es Select...=S\u00E9lectionner... Series_Label_Color=S\u00E9lection de la couleur de l'\u00E9tiquette Series_label_font=Police de l'\u00E9tiquette de s\u00E9rie : Series_label_paint=Couleur de l'\u00E9tiquette de s\u00E9rie : Series_Outline_Paint=Couleur de bordure de la s\u00E9rie : Series_Outline_Stroke=Style du trait de bordure de la s\u00E9rie : Series_Paint=Couleur de la s\u00E9rie : Series_Stroke=Style du trait de la s\u00E9rie : Show_tick_labels=Afficher les \u00E9tiquettes de graduation Show_tick_marks=Afficher les rep\u00E8res de graduation Set_palette...=Choix de palette... Step_Palette=Changement de palette : Stroke_Selection=S\u00E9lection du style de trait Text=Texte : Tick_label_font=Police des \u00E9tiquettes de graduation : Tick_Label_Insets=Position des \u00E9tiquettes de graduation : Ticks=Etiquettes de graduation Title_Color=Couleur du titre libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_nl.properties0000644000175000017500000000353311173030414032314 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 24-Mar-2003 : Translated into Dutch # 31-Aug-2003 : Initial version (AL); # \:=: Appearance=Uiterlijk Auto-adjust_range=Bereik automatisch bepalen Background=Achtergrond Background_Color=Achtergrondkleur # "Paint" translated sounds a bit silly IMHO. Since at present only single, # opaque colors are selectable anyway, lets just call it that -- color. Background_paint=Achtergrondkleur: Color=Kleur: Color_Bar=Kleurbalk Domain_Axis=Domein as Draw_anti-aliased=Kartelrandjes maskeren (anti-aliasing) Edit...=Wijzig... Edit_Insets=Wijzig marges Font=Lettertype: Font_Selection=Lettertype keuze General=Algemeen: Grid_Color=Rasterkleur Insets=Marges: Invert_Palette=Palet inverteren: Label=Label: Label_Color=Labelkleur Label_Insets=Labelmarges: Legend=Legenda Maximum_range_value=Hoogste waarde: Minimum_range_value=Laagste waarde: No_editor_implemented=Geen editor beschikbaar Other=Overig Outline=Rand: Outline_Color=Randkleur Outline_stroke=Rand stijl: Outline_Paint=Randkleur: Paint=Kleur: Palette_Selection=Paletkleuze Palette=Palet: Pen_Stroke_Selection=Pen/Stijl Keuze Plot=Diagram Range=Bereik Range_Axis=Gegevens as Select...=Selecteer... Series_Label_Color=Kleur serienaam Series_label_font=Lettertype serienaam: Series_label_paint=Kleur serienaam: Series_Outline_Paint=Kleur serie-rand: Series_Outline_Stroke=Stijl serie-rand: Series_Paint=Kleur v.d. serie: Series_Stroke=Stijl v.d. serie: Show_tick_labels=Toon waarde-labels Show_tick_marks=Toon waarde-streepjes Set_palette...=Kies palet... Step_Palette=Stap palet: Stroke_Selection=Stijlkeuze Text=Tekst: Ticks=Waarde-streepjes Tick_label_font=Lettertype waarde-labes: Tick_Label_Insets=Waarde-label marges: Title_Color=Kleur titel libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_pl.properties0000644000175000017500000000361211173030414032314 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file # # Changes (from 15-Mar-2004) # -------------------------- # 15-Mar-2004 : Initial version (Kuba Duda); # \:=: Appearance=Wygl\u0105d Auto-adjust_range=Automatycznie dostosuj zakres: Background=T\u0142o: Background_Color=Kolor t\u0142a Background_paint=Wype\u0142nienie t\u0142a: Color=Kolor: Color_Bar=Pasek kolor\u00f3w Domain_Axis=O\u015b domeny Draw_anti-aliased=Wyg\u0142adzaj kraw\u0119dzie Edit...=Edytuj... Edit_Insets=Edytuj wstawki Font=Czcionka: Font_Selection=Wyb\u00f3r czcionki General=Og\u00f3lne: Grid_Color=Kolor siatki Insets=Wstawki: Invert_Palette=Odwr\u00f3\u0107 palet\u0119: Label=Etykieta: Label_Color=Kolor etykiet Label_Insets=Wstawki etykiet: Legend=Legenda Maximum_range_value=Maksymalna warto\u015b\u0107 zakresu: Minimum_range_value=Minimalna warto\u015b\u0107 zakresu: No_editor_implemented=Edytor nie zaimplementowany Other=Inne Outline=Obrys: Outline_Color=Kolor konturu Outline_stroke=Obrys konturu: Outline_Paint=wype\u0142nienie konturu: Paint=Wype\u0142nienie: Palette_Selection=Wyb\u00f3r palety Palette=Paleta: Pen_Stroke_Selection=Wyb\u00f3r pi\u00f3ra/obrysu Plot=Wykres Range=Zakres Range_Axis=O\u015b zakresu Select...=Wybierz... Series_Label_Color=Kolor etykiety serii Series_label_font=Czcionka etykiety serii: Series_label_paint=Wype\u0142nienie etykiety serii: Series_Outline_Paint=Wype\u0142nienie obrysu serii: Series_Outline_Stroke=Kolor obrysu serii: Series_Paint=Wype\u0142nienie serii: Series_Stroke=Kolor serii: Show_tick_labels=Pokazuj etykiety skali Show_tick_marks=Pokazuj znaczniki skali Set_palette...=Wybierz palet\u0119... Step_Palette=Paleta krokowa: Stroke_Selection=Wyb\u00f3r obrysu Text=Tekst: Ticks=Podzia\u0142ka Tick_label_font=Czcionka etykiet podzia\u0142ki: Tick_Label_Insets=Wstawki etykiet podzia\u0142ki: Title_Color=Kolor tytu\u0142u libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_pt_BR.properties0000644000175000017500000000425311173030414032711 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version # # Changes (from 24-May-2007) # -------------------------- # 24-May-2007 : Initial version (Leonardo Alves Machado) # \:=\ : Appearance=Geral Auto-adjust_range=Eixos auto-ajust\u00E1veis : Background=Fundo : Background_Color=Cor de fundo Background_paint=Cor de fundo : Color=Cor : Color_Bar=Cor da barra Domain_Axis=Eixo das abcissas Draw_anti-aliased=Anti-aliasing Edit...=Editar... Edit_Insets=Regular a posi\u00E7\u00E3o Font=Fonte : Font_Selection=Sele\u00E7\u00E3o da fonte General=Geral : Grid_Color=Cor da grade Insets=Posi\u00E7\u00E3o : Invert_Palette=Inverter o palete : Label=R\u00F3tulo : Label_Color=Cor do r\u00F3tulo Label_Insets=Posi\u00E7\u00E3o do r\u00F3tulo : Legend=Legenda Maximum_range_value=Valor m\u00E1ximo do eixo : Minimum_range_value=Valor m\u00EDnimo do eixo : No_editor_implemented=Editor n\u00E3o dispon\u00EDvel Other=Outro Outline=Borda : Outline_Paint=Cor da borda : Outline_Color=Cor da borda Outline_stroke=Estilo do tra\u00E7o da borda : Paint=Cor : Palette=Palete : Palette_Selection=Sele\u00E7\u00E3o do palete Pen_Stroke_Selection=Sele\u00E7\u00E3o de tra\u00E7o Plot=Tra\u00E7o Range=Intervalo Range_Axis=Eixo das ordenadas Select...=Selecionar... Series_Label_Color=Cor do r\u00F3tulo das s\u00E9ries Series_label_font=Fonte do r\u00F3tulo das s\u00E9ries : Series_label_paint=Cor do r\u00F3tulo das s\u00E9ries : Series_Outline_Paint=Cor da borda das s\u00E9ries : Series_Outline_Stroke=Estilo do tra\u00E7o da borda : Series_Paint=Cor da s\u00E9ries : Series_Stroke=Estilo do tra\u00E7o das s\u00E9ries : Show_tick_labels=Visualizar r\u00F3tulos de gradua\u00E7\u00E3o de escala Show_tick_marks=Visualizar marcas de gradua\u00E7\u00E3o de escala Set_palette...=Escolha do palete... Step_Palette=Espaçamento do palete : Stroke_Selection=Sele\u00E7\u00E3o do tra\u00E7o Text=Texto : Tick_label_font=Fonte dos r\u00F3tulos de gradua\u00E7\u00E3o de escala : Tick_Label_Insets=Posi\u00E7\u00E3o dos r\u00F3tulos de gradua\u00E7\u00E3o de escala : Ticks=R\u00F3tulos de gradua\u00E7\u00E3o de escala Title_Color=Cor do t\u00EDtulo libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_pt_PT.properties0000644000175000017500000000421411173030414032726 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version # # Changes (from 09-Set-2003) # -------------------------- # 09-Set-2003 : Initial version (Eduardo Ramalho); # \:=\ : Appearance=Geral Auto-adjust_range=Eixos auto-ajust\u00E1veis : Background=Fundo : Background_Color=Cor de fundo Background_paint=Cor de fundo : Color=Cor : Color_Bar=Cor da barra Domain_Axis=Eixo das abcissas Draw_anti-aliased=Anti-aliasing Edit...=Editar... Edit_Insets=Regular a posi\u00E7\u00E3o Font=Fonte : Font_Selection=Selec\u00E7\u00E3o da fonte General=Geral : Grid_Color=Cor da grelha Insets=Posi\u00E7\u00E3o : Invert_Palette=Inverter a paleta : Label=Etiqueta : Label_Color=Cor da etiqueta Label_Insets=Posi\u00E7\u00E3o da etiqueta : Legend=Legenda Maximum_range_value=Valor m\u00E1ximo do eixo : Minimum_range_value=Valor m\u00EDnimo do eixo : No_editor_implemented=Editor n\u00E3o dispon\u00EDvel Other=Outro Outline=Borda : Outline_Paint=Cor da borda : Outline_Color=Cor da borda Outline_stroke=Estilo do tra\u00E7o da borda : Paint=Cor : Palette=Palete : Palette_Selection=Selec\u00E7\u00E3o da palete Pen_Stroke_Selection=Selec\u00E7\u00E3o de tra\u00E7o Plot=Tra\u00E7o Range=Intervalo Range_Axis=Eixo das ordenadas Select...=Seleccionar... Series_Label_Color=Cor da etiqueta das s\u00E9ries Series_label_font=Fonte da etiqueta das s\u00E9ries : Series_label_paint=Cor da etiqueta das s\u00E9ries : Series_Outline_Paint=Cor da borda das s\u00E9ries : Series_Outline_Stroke=Estilo do tra\u00E7o da borda : Series_Paint=Cor da s\u00E9ries : Series_Stroke=Estilo do tra\u00E7o das s\u00E9ries : Show_tick_labels=Visualizar etiquetas de gradua\u00E7\u00E3o de escala Show_tick_marks=Visualizar marcas de gradua\u00E7\u00E3o de escala Set_palette...=Escolha de palete... Step_Palette=Changement de palette : Stroke_Selection=Selec\u00E7\u00E3o do tra\u00E7o Text=Texto : Tick_label_font=Fonte das etiquetas de gradua\u00E7\u00E3o de escala : Tick_Label_Insets=Posi\u00E7\u00E3o das etiquetas de gradua\u00E7\u00E3o de escala : Ticks=Etiquetas de gradua\u00E7\u00E3o de escala Title_Color=Cor do t\u00EDtulo libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_ru.properties0000644000175000017500000001136611173030414032334 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file # # Changes (from 10-Nov-2003) # -------------------------- # 10-Nov-2003 : Initial version (AL); # \:=: Appearance=\u0412\u0438\u0434 Auto-adjust_range=\u0410\u0432\u0442\u0440\u043e\u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430: Background=\u0424\u043e\u043d: Background_Color=\u0426\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 Background_paint=\u0424\u043e\u043d\u043e\u0432\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a: Color=\u0426\u0432\u0435\u0442: Color_Bar=\u0426\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0433\u0440\u0443\u0433 Domain_Axis=\u041e\u0441\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 Draw_anti-aliased=\u0410\u043d\u0442\u0438-\u0430\u043b\u0438\u0430\u0441\u0438\u043d\u0433 Edit...=\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c... Edit_Insets=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432 Font=\u0428\u0440\u0438\u0444\u0442: Font_Selection=\u0412\u044b\u0431\u043e\u0440 \u0448\u0440\u0438\u0444\u0442\u0430 General=\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435: Grid_Color=\u0426\u0432\u0435\u0442 \u0441\u0435\u0442\u043a\u0438 Insets=\u041e\u0442\u0441\u0442\u0443\u043f\u044b: Invert_Palette=\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043b\u0438\u0442\u0440\u0443: Label=\u041c\u0435\u0442\u043a\u0430: Label_Color=\u0426\u0432\u0435\u0442 \u043c\u0435\u0442\u043a\u0438 Label_Insets=\u041e\u0442\u0441\u0442\u0443\u043f\u044b \u043c\u0435\u0442\u043a\u0438: Legend=\u041b\u0435\u0433\u0435\u043d\u0434\u0430 Maximum_range_value=\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: Minimum_range_value=\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: No_editor_implemented=\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 Other=\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e Outline=\u0420\u0430\u043c\u043a\u0430: Outline_Color=\u0426\u0432\u0435\u0442 \u0440\u0430\u043c\u043a\u0438 Outline_stroke=\u0421\u0442\u0438\u043b\u044c \u0440\u0430\u043c\u043a\u0438: Outline_Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430 \u0440\u0430\u043c\u043a\u0438: Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430: Palette_Selection=\u0412\u044b\u0431\u043e\u0440 \u043f\u0430\u043b\u0438\u0442\u0440\u044b Palette=\u041f\u0430\u043b\u0438\u0442\u0440\u0430: Pen_Stroke_Selection=\u0412\u044b\u0431\u043e\u0440 \u041a\u0430\u0440\u0430\u043d\u0434\u0430\u0448/\u0428\u0442\u0440\u0438\u0445 Plot=\u0413\u0440\u0430\u0444\u0438\u043a Range=\u041e\u0431\u043b\u0430\u0441\u0442\u044c Range_Axis=\u041e\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Select...=\u0412\u044b\u0431\u043e\u0440... Series_Label_Color=\u0426\u0432\u0435\u0442 \u043c\u0435\u0442\u043a\u0438 \u0441\u0435\u0440\u0438\u0438 Series_label_font=\u0428\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043a\u0438 \u0441\u0435\u0440\u0438\u0438: Series_label_paint=\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043a\u0438 \u0441\u0435\u0440\u0438\u0438: Series_Outline_Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430 \u0440\u0430\u043c\u043a\u0438 \u0441\u0435\u0440\u0438\u0438: Series_Outline_Stroke=\u0428\u0442\u0440\u0438\u0445\u043e\u0432\u0430\u044f \u0440\u0430\u043c\u043a\u0430 \u0441\u0435\u0440\u0438\u0438: Series_Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430 \u0441\u0435\u0440\u0438\u0438: Series_Stroke=\u0428\u0442\u0440\u0438\u0445\u0438 \u0441\u0435\u0440\u0438\u0438: Show_tick_labels=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u0435\u0432\u044b\u0435 \u043e\u0442\u043c\u0435\u0442\u043a\u0438 Show_tick_marks=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u0435\u0432\u044b\u0435 \u0448\u0442\u0440\u0438\u0445\u0438 Set_palette...=\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043b\u0438\u0442\u0440\u0443... Step_Palette=\u0428\u0430\u0433 \u043f\u0430\u043b\u0438\u0442\u0440\u044b: Stroke_Selection=\u0412\u044b\u0431\u043e\u0440 \u0448\u0442\u0440\u0438\u0445\u0430 Text=\u0422\u0435\u043a\u0441\u0442: Ticks=\u041e\u0442\u043c\u0435\u0442\u043a\u0438 Tick_label_font=\u0428\u0440\u0438\u0444\u0442 \u043e\u0442\u043c\u0435\u0442\u043a\u0438: Tick_Label_Insets=\u041e\u0442\u0441\u0442\u0443\u043f\u044b \u043e\u0442\u043c\u0435\u0442\u043e\u043a: Title_Color=\u0426\u0432\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/LocalizationBundle_zh_CN.properties0000644000175000017500000000461411173030414032705 0ustar vincentvincent# org.jfree.chart.ui.ui ResourceBundle properties file # # Changes # ------- # 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495; # \:=: Appearance=\u5916\u89c2 Auto-adjust_range=\u81ea\u52a8\u8c03\u8282\u8303\u56f4: Background=\u80cc\u666f: Background_Color=\u80cc\u666f\u8272 Background_paint=\u80cc\u666f\u586b\u5145: Color=\u989c\u8272: Color_Bar=\u8272\u5f69\u6761 Domain_Axis=\u9879\u76ee\u8f74 Draw_anti-aliased=\u7ed8\u5236\u53cd\u6df7\u6dc6 Draw_lines=\u753b\u7ebf: Draw_shapes=\u753b\u5f62\u72b6: Edit...=\u7f16\u8f91... Edit_Insets=\u7f16\u8f91\u5d4c\u5165 Font=\u5b57\u4f53: Font_Selection=\u5b57\u4f53\u9009\u62e9 General=\u7efc\u5408: Grid_Color=\u7f51\u683c\u989c\u8272 Insets=\u63d2\u56fe: Invert_Palette=\u53cd\u8f6c\u8c03\u8272\u677f: Label=\u6807\u7b7e: Label_Color=\u6807\u7b7e\u989c\u8272 Label_Insets=\u6807\u7b7e\u63d2\u56fe: Legend=\u56fe\u4f8b Maximum_range_value=\u6700\u5927\u503c: Minimum_range_value=\u6700\u5c0f\u503c: No_editor_implemented=\u6ca1\u6709\u53ef\u6267\u884c\u7684\u7f16\u8f91\u5668 Orientation=\u65b9\u5411: Other=\u5176\u4ed6 Outline=\u8f6e\u5ed3: Outline_Color=\u8f6e\u5ed3\u989c\u8272 Outline_stroke=\u8f6e\u5ed3\u7ebf\u6761: Outline_Paint=\u8f6e\u5ed3\u586b\u5145: Paint=\u586b\u5145: Palette_Selection=\u8c03\u8272\u677f\u9009\u62e9 Palette=\u8c03\u8272\u677f: Pen_Stroke_Selection=\u753b\u7b14/\u7ebf\u578b \u9009\u62e9 Plot=\u56fe Range=\u8303\u56f4 Range_Axis=\u8303\u56f4\u8f74 Select...=\u9009\u62e9... Series_Label_Color=\u5e8f\u5217\u6807\u7b7e\u8272 Series_label_font=\u5e8f\u5217\u6807\u7b7e\u5b57\u4f53: Series_label_paint=\u5e8f\u5217\u6807\u7b7e\u586b\u5145: Series_Outline_Paint=\u5e8f\u5217\u8f6e\u5ed3\u586b\u5145: Series_Outline_Stroke=\u5e8f\u5217\u8f6e\u5ed3\u7ebf\u578b: Series_Paint=\u5e8f\u5217\u586b\u5145: Series_Stroke=\u5e8f\u5217\u7ebf\u578b: Show_Legend=\u663e\u793a\u56fe\u4f8b: Show_tick_labels=\u663e\u793a\u523b\u5ea6\u6807\u7b7e Show_tick_marks=\u663e\u793a\u6807\u7b7e\u8bb0\u53f7 Show_Title=\u663e\u793a\u6807\u9898: Set_palette...=\u8bbe\u7f6e\u8c03\u8272\u677f... Step_Palette=Step \u8c03\u8272\u677f: Stroke_Selection=\u7ebf\u578b\u9009\u62e9 Text=\u6b63\u6587: Ticks=\u523b\u5ea6\u7ebf Tick_label_font=\u523b\u5ea6\u6807\u7b7e\u5b57\u4f53: Tick_Label_Insets=\u523b\u5ea6\u6807\u7b7e\u63d2\u56fe: Title=\u6807\u9898 Title_Color=\u6807\u9898\u989c\u8272 libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/PaletteChooserPanel.java0000644000175000017500000000604011173030414030463 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * PaletteChooserPanel.java * ------------------------ * (C) Copyright 2002-2008, by David M. O'Donnell. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 27-Jan-2003 : Added standard header (DG); * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.editor; import java.awt.BorderLayout; import javax.swing.JComboBox; import javax.swing.JPanel; import org.jfree.chart.plot.ColorPalette; import org.jfree.chart.plot.RainbowPalette; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * A component for choosing a palette from a list of available palettes. * * @deprecated This class is no longer supported. If you are creating * contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ class PaletteChooserPanel extends JPanel { /** A combo for selecting the stroke. */ private JComboBox selector; /** * Constructor. * * @param current the current palette sample. * @param available an array of 'available' palette samples. */ public PaletteChooserPanel(PaletteSample current, PaletteSample[] available) { setLayout(new BorderLayout()); this.selector = new JComboBox(available); this.selector.setSelectedItem(current); this.selector.setRenderer(new PaletteSample(new RainbowPalette())); add(this.selector); } /** * Returns the selected palette. * * @return The selected palette. */ public ColorPalette getSelectedPalette() { PaletteSample sample = (PaletteSample) this.selector.getSelectedItem(); return sample.getPalette(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/PaletteSample.java0000644000175000017500000001254111173030414027325 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * PaletteSample.java * ------------------ * (C) Copyright 2002-2008, by David M. O'Donnell. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 21-Jan-2003 : Added standard header (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.editor; import java.awt.BasicStroke; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.RenderingHints; import java.awt.geom.Line2D; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.ListCellRenderer; import org.jfree.chart.plot.ColorPalette; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * A panel that displays a palette sample. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class PaletteSample extends JComponent implements ListCellRenderer { /** The palette being displayed. */ private ColorPalette palette; /** The preferred size of the component; */ private Dimension preferredSize; /** * Creates a new sample. * * @param palette the palette. */ public PaletteSample(ColorPalette palette) { this.palette = palette; this.preferredSize = new Dimension(80, 18); } /** * Returns a list cell renderer for the stroke, so the sample can be * displayed in a list or combo. * * @param list the list component. * @param value the value. * @param index the index. * @param isSelected a flag that indicates whether or not the item is * selected. * @param cellHasFocus a flag that indicates whether or not the cell has * the focus. * * @return The renderer. */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof PaletteSample) { PaletteSample in = (PaletteSample) value; setPalette(in.getPalette()); } return this; } /** * Returns the current palette object being displayed. * * @return The palette. */ public ColorPalette getPalette() { return this.palette; } /** * Returns the preferred size of the component. * * @return The preferred size. */ public Dimension getPreferredSize() { return this.preferredSize; } /** * Draws the sample. * * @param g the graphics device. */ public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); Dimension size = getSize(); Insets insets = getInsets(); double ww = size.getWidth() - insets.left - insets.right; double hh = size.getHeight() - insets.top - insets.bottom; g2.setStroke(new BasicStroke(1.0f)); double y1 = insets.top; double y2 = y1 + hh; double xx = insets.left; Line2D line = new Line2D.Double(); int count = 0; while (xx <= insets.left + ww) { count++; line.setLine(xx, y1, xx, y2); g2.setPaint(this.palette.getColor(count)); g2.draw(line); xx += 1; } } /** * Sets the palette object being displayed. * * @param palette the palette. */ public void setPalette(ColorPalette palette) { this.palette = palette; this.repaint(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/package.html0000644000175000017500000000030011173030414026171 0ustar vincentvincent Provides a simple (but so far incomplete) framework for editing chart properties. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/0000755000175000017500000000000011216245561024244 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/EncoderUtil.java0000644000175000017500000001671511173030414027325 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * EncoderUtil.java * ---------------- * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): -; * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.encoders; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; /** * A collection of utility methods for encoding images and returning them as a * byte[] or writing them directly to an OutputStream. */ public class EncoderUtil { /** * Encode the image in a specific format. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * * @return The byte[] that is the encoded image. * @throws IOException */ public static byte[] encode(BufferedImage image, String format) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format); return imageEncoder.encode(image); } /** * Encode the image in a specific format. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param encodeAlpha Whether to encode alpha transparency (not supported * by all ImageEncoders). * @return The byte[] that is the encoded image. * @throws IOException */ public static byte[] encode(BufferedImage image, String format, boolean encodeAlpha) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format, encodeAlpha); return imageEncoder.encode(image); } /** * Encode the image in a specific format. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param quality The quality to use for the image encoding (not supported * by all ImageEncoders). * @return The byte[] that is the encoded image. * @throws IOException */ public static byte[] encode(BufferedImage image, String format, float quality) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format, quality); return imageEncoder.encode(image); } /** * Encode the image in a specific format. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param quality The quality to use for the image encoding (not supported * by all ImageEncoders). * @param encodeAlpha Whether to encode alpha transparency (not supported * by all ImageEncoders). * @return The byte[] that is the encoded image. * @throws IOException */ public static byte[] encode(BufferedImage image, String format, float quality, boolean encodeAlpha) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format, quality, encodeAlpha); return imageEncoder.encode(image); } /** * Encode the image in a specific format and write it to an OutputStream. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param outputStream The OutputStream to write the encoded image to. * @throws IOException */ public static void writeBufferedImage(BufferedImage image, String format, OutputStream outputStream) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format); imageEncoder.encode(image, outputStream); } /** * Encode the image in a specific format and write it to an OutputStream. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param outputStream The OutputStream to write the encoded image to. * @param quality The quality to use for the image encoding (not * supported by all ImageEncoders). * @throws IOException */ public static void writeBufferedImage(BufferedImage image, String format, OutputStream outputStream, float quality) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format, quality); imageEncoder.encode(image, outputStream); } /** * Encode the image in a specific format and write it to an OutputStream. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param outputStream The OutputStream to write the encoded image to. * @param encodeAlpha Whether to encode alpha transparency (not * supported by all ImageEncoders). * @throws IOException */ public static void writeBufferedImage(BufferedImage image, String format, OutputStream outputStream, boolean encodeAlpha) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format, encodeAlpha); imageEncoder.encode(image, outputStream); } /** * Encode the image in a specific format and write it to an OutputStream. * * @param image The image to be encoded. * @param format The {@link ImageFormat} to use. * @param outputStream The OutputStream to write the encoded image to. * @param quality The quality to use for the image encoding (not * supported by all ImageEncoders). * @param encodeAlpha Whether to encode alpha transparency (not supported * by all ImageEncoders). * @throws IOException */ public static void writeBufferedImage(BufferedImage image, String format, OutputStream outputStream, float quality, boolean encodeAlpha) throws IOException { ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format, quality, encodeAlpha); imageEncoder.encode(image, outputStream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/ImageEncoder.java0000644000175000017500000000651711173030414027431 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ImageEncoder.java * ----------------- * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): -; * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.encoders; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; /** * Interface for abstracting different types of image encoders. */ public interface ImageEncoder { /** * Encodes an image in a particular format. * * @param bufferedImage The image to be encoded. * * @return The byte[] that is the encoded image. * * @throws IOException */ public byte[] encode(BufferedImage bufferedImage) throws IOException; /** * Encodes an image in a particular format and writes it to an OutputStream. * * @param bufferedImage The image to be encoded. * @param outputStream The OutputStream to write the encoded image to. * @throws IOException */ public void encode(BufferedImage bufferedImage, OutputStream outputStream) throws IOException; /** * Get the quality of the image encoding. * * @return A float representing the quality. */ public float getQuality(); /** * Set the quality of the image encoding (not supported by all * ImageEncoders). * * @param quality A float representing the quality. */ public void setQuality(float quality); /** * Get whether the encoder should encode alpha transparency. * * @return Whether the encoder is encoding alpha transparency. */ public boolean isEncodingAlpha(); /** * Set whether the encoder should encode alpha transparency (not * supported by all ImageEncoders). * * @param encodingAlpha Whether the encoder should encode alpha * transparency. */ public void setEncodingAlpha(boolean encodingAlpha); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/ImageEncoderFactory.java0000644000175000017500000001405311173030414030753 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * ImageEncoderFactory.java * ------------------------ * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 01-Nov-2005 : Now using ImageIO for JPEG encoding, so we no longer have a * dependency on com.sun.* which isn't available on all * implementations (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.encoders; import java.util.Hashtable; /** * Factory class for returning {@link ImageEncoder}s for different * {@link ImageFormat}s. */ public class ImageEncoderFactory { /** Storage for the encoders. */ private static Hashtable encoders = null; static { init(); } /** * Sets up default encoders (uses Sun PNG Encoder if JDK 1.4+ and the * SunPNGEncoderAdapter class is available). */ private static void init() { encoders = new Hashtable(); encoders.put("jpeg", "org.jfree.chart.encoders.SunJPEGEncoderAdapter"); try { // Test for being run under JDK 1.4+ Class.forName("javax.imageio.ImageIO"); // Test for JFreeChart being compiled under JDK 1.4+ Class.forName("org.jfree.chart.encoders.SunPNGEncoderAdapter"); encoders.put("png", "org.jfree.chart.encoders.SunPNGEncoderAdapter"); encoders.put("jpeg", "org.jfree.chart.encoders.SunJPEGEncoderAdapter"); } catch (ClassNotFoundException e) { encoders.put("png", "org.jfree.chart.encoders.KeypointPNGEncoderAdapter"); } } /** * Used to set additional encoders or replace default ones. * * @param format The image format name. * @param imageEncoderClassName The name of the ImageEncoder class. */ public static void setImageEncoder(String format, String imageEncoderClassName) { encoders.put(format, imageEncoderClassName); } /** * Used to retrieve an ImageEncoder for a specific image format. * * @param format The image format required. * * @return The ImageEncoder or null if none available. */ public static ImageEncoder newInstance(String format) { ImageEncoder imageEncoder = null; String className = (String) encoders.get(format); if (className == null) { throw new IllegalArgumentException("Unsupported image format - " + format); } try { Class imageEncoderClass = Class.forName(className); imageEncoder = (ImageEncoder) imageEncoderClass.newInstance(); } catch (Exception e) { throw new IllegalArgumentException(e.toString()); } return imageEncoder; } /** * Used to retrieve an ImageEncoder for a specific image format. * * @param format The image format required. * @param quality The quality to be set before returning. * * @return The ImageEncoder or null if none available. */ public static ImageEncoder newInstance(String format, float quality) { ImageEncoder imageEncoder = newInstance(format); imageEncoder.setQuality(quality); return imageEncoder; } /** * Used to retrieve an ImageEncoder for a specific image format. * * @param format The image format required. * @param encodingAlpha Sets whether alpha transparency should be encoded. * * @return The ImageEncoder or null if none available. */ public static ImageEncoder newInstance(String format, boolean encodingAlpha) { ImageEncoder imageEncoder = newInstance(format); imageEncoder.setEncodingAlpha(encodingAlpha); return imageEncoder; } /** * Used to retrieve an ImageEncoder for a specific image format. * * @param format The image format required. * @param quality The quality to be set before returning. * @param encodingAlpha Sets whether alpha transparency should be encoded. * * @return The ImageEncoder or null if none available. */ public static ImageEncoder newInstance(String format, float quality, boolean encodingAlpha) { ImageEncoder imageEncoder = newInstance(format); imageEncoder.setQuality(quality); imageEncoder.setEncodingAlpha(encodingAlpha); return imageEncoder; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/ImageFormat.java0000644000175000017500000000376311173030414027302 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ImageFormat.java * ---------------- * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): -; * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.encoders; /** * Interface used for referencing different image formats. */ public interface ImageFormat { /** Portable Network Graphics - lossless */ public static String PNG = "png"; /** Joint Photographic Experts Group format - lossy */ public static String JPEG = "jpeg"; /** Graphics Interchange Format - lossless, but 256 colour restriction */ public static String GIF = "gif"; } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/KeypointPNGEncoderAdapter.java0000644000175000017500000001157111173030414032053 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * KeypointPNGEncoderAdapter.java * ------------------------------ * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): -; * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.encoders; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import com.keypoint.PngEncoder; /** * Adapter class for the Keypoint PNG Encoder. The ImageEncoderFactory will * only return a reference to this class by default if the library has been * compiled under a JDK < 1.4 or is being run using a JDK < 1.4. */ public class KeypointPNGEncoderAdapter implements ImageEncoder { /** The quality setting. */ private int quality = 9; /** Encode alpha? */ private boolean encodingAlpha = false; /** * Get the quality of the image encoding. The underlying encoder uses int * values: 0 for no compression, and values 1 through 9 for various levels * of compression (1 is best speed, 9 is best compression). * * @return A float representing the quality. */ public float getQuality() { return this.quality; } /** * Set the quality of the image encoding (supported). The underlying * encoder uses int values: 0 for no compression, and values 1 through 9 * for various levels of compression (1 is best speed, 9 is best * compression). * * @param quality A float representing the quality. */ public void setQuality(float quality) { this.quality = (int) quality; } /** * Get whether the encoder should encode alpha transparency. * * @return Whether the encoder is encoding alpha transparency. */ public boolean isEncodingAlpha() { return this.encodingAlpha; } /** * Set whether the encoder should encode alpha transparency (supported). * * @param encodingAlpha Whether the encoder should encode alpha * transparency. */ public void setEncodingAlpha(boolean encodingAlpha) { this.encodingAlpha = encodingAlpha; } /** * Encodes an image in PNG format. * * @param bufferedImage The image to be encoded. * @return The byte[] that is the encoded image. * @throws IOException */ public byte[] encode(BufferedImage bufferedImage) throws IOException { if (bufferedImage == null) { throw new IllegalArgumentException("Null 'image' argument."); } PngEncoder encoder = new PngEncoder(bufferedImage, this.encodingAlpha, 0, this.quality); return encoder.pngEncode(); } /** * Encodes an image in PNG format and writes it to an * OutputStream. * * @param bufferedImage The image to be encoded. * @param outputStream The OutputStream to write the encoded image to. * @throws IOException */ public void encode(BufferedImage bufferedImage, OutputStream outputStream) throws IOException { if (bufferedImage == null) { throw new IllegalArgumentException("Null 'image' argument."); } if (outputStream == null) { throw new IllegalArgumentException("Null 'outputStream' argument."); } PngEncoder encoder = new PngEncoder(bufferedImage, this.encodingAlpha, 0, this.quality); outputStream.write(encoder.pngEncode()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java0000644000175000017500000001444011173030414031115 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * SunJPEGEncoderAdapter.java * -------------------------- * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 01-Nov-2005 : To remove the dependency on non-supported APIs, use ImageIO * instead of com.sun.image.codec.jpeg.JPEGImageEncoder - this * adapter will only be available on JDK 1.4 or later (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Pass quality setting to ImageIO. Also increased default * value to 0.95 (DG); * */ package org.jfree.chart.encoders; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriter; import javax.imageio.stream.ImageOutputStream; /** * Adapter class for the Sun JPEG Encoder. The {@link ImageEncoderFactory} * will only return a reference to this class by default if the library has * been compiled under a JDK 1.4+ and is being run using a JRE 1.4+. */ public class SunJPEGEncoderAdapter implements ImageEncoder { /** The quality setting (in the range 0.0f to 1.0f). */ private float quality = 0.95f; /** * Creates a new SunJPEGEncoderAdapter instance. */ public SunJPEGEncoderAdapter() { } /** * Returns the quality of the image encoding, which is a number in the * range 0.0f to 1.0f (higher values give better quality output, but larger * file sizes). The default value is 0.95f. * * @return A float representing the quality, in the range 0.0f to 1.0f. * * @see #setQuality(float) */ public float getQuality() { return this.quality; } /** * Set the quality of the image encoding. * * @param quality A float representing the quality (in the range 0.0f to * 1.0f). * * @see #getQuality() */ public void setQuality(float quality) { if (quality < 0.0f || quality > 1.0f) { throw new IllegalArgumentException( "The 'quality' must be in the range 0.0f to 1.0f"); } this.quality = quality; } /** * Returns false always, indicating that this encoder does not * encode alpha transparency. * * @return false. */ public boolean isEncodingAlpha() { return false; } /** * Set whether the encoder should encode alpha transparency (this is not * supported for JPEG, so this method does nothing). * * @param encodingAlpha ignored. */ public void setEncodingAlpha(boolean encodingAlpha) { // No op } /** * Encodes an image in JPEG format. * * @param bufferedImage the image to be encoded (null not * permitted). * * @return The byte[] that is the encoded image. * * @throws IOException if there is an I/O problem. * @throws NullPointerException if bufferedImage is * null. */ public byte[] encode(BufferedImage bufferedImage) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); encode(bufferedImage, outputStream); return outputStream.toByteArray(); } /** * Encodes an image in JPEG format and writes it to an output stream. * * @param bufferedImage the image to be encoded (null not * permitted). * @param outputStream the OutputStream to write the encoded image to * (null not permitted). * * @throws IOException if there is an I/O problem. * @throws NullPointerException if bufferedImage is * null. */ public void encode(BufferedImage bufferedImage, OutputStream outputStream) throws IOException { if (bufferedImage == null) { throw new IllegalArgumentException("Null 'image' argument."); } if (outputStream == null) { throw new IllegalArgumentException("Null 'outputStream' argument."); } Iterator iterator = ImageIO.getImageWritersByFormatName("jpeg"); ImageWriter writer = (ImageWriter) iterator.next(); ImageWriteParam p = writer.getDefaultWriteParam(); p.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); p.setCompressionQuality(this.quality); ImageOutputStream ios = ImageIO.createImageOutputStream(outputStream); writer.setOutput(ios); writer.write(null, new IIOImage(bufferedImage, null, null), p); ios.flush(); writer.dispose(); ios.close(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/SunPNGEncoderAdapter.java0000644000175000017500000001032511173030414031012 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * SunPNGEncoderAdapter.java * ------------------------- * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): -; * * Changes * ------- * 01-Aug-2004 : Initial version (RA); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.encoders; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import javax.imageio.ImageIO; /** * Adapter class for the Sun PNG Encoder. The ImageEncoderFactory will only * return a reference to this class by default if the library has been compiled * under a JDK 1.4+ and is being run using a JDK 1.4+. */ public class SunPNGEncoderAdapter implements ImageEncoder { /** * Get the quality of the image encoding (always 0.0). * * @return A float representing the quality. */ public float getQuality() { return 0.0f; } /** * Set the quality of the image encoding (not supported in this * ImageEncoder). * * @param quality A float representing the quality. */ public void setQuality(float quality) { // No op } /** * Get whether the encoder should encode alpha transparency (always false). * * @return Whether the encoder is encoding alpha transparency. */ public boolean isEncodingAlpha() { return false; } /** * Set whether the encoder should encode alpha transparency (not * supported in this ImageEncoder). * * @param encodingAlpha Whether the encoder should encode alpha * transparency. */ public void setEncodingAlpha(boolean encodingAlpha) { // No op } /** * Encodes an image in PNG format. * * @param bufferedImage The image to be encoded. * * @return The byte[] that is the encoded image. * * @throws IOException */ public byte[] encode(BufferedImage bufferedImage) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); encode(bufferedImage, outputStream); return outputStream.toByteArray(); } /** * Encodes an image in PNG format and writes it to an OutputStream. * * @param bufferedImage The image to be encoded. * @param outputStream The OutputStream to write the encoded image to. * @throws IOException */ public void encode(BufferedImage bufferedImage, OutputStream outputStream) throws IOException { if (bufferedImage == null) { throw new IllegalArgumentException("Null 'image' argument."); } if (outputStream == null) { throw new IllegalArgumentException("Null 'outputStream' argument."); } ImageIO.write(bufferedImage, ImageFormat.PNG, outputStream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/encoders/package.html0000644000175000017500000000026211173030414026514 0ustar vincentvincent Classes related to the encoding of charts to different image formats. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/0000755000175000017500000000000011216245561023756 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/AxisEntity.java0000644000175000017500000001445411173030414026721 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * AxisEntity.java * ---------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: Peter Kolb; * Contributor(s): ; * * Changes: * -------- * 15-Feb-2009 : Version 1 (PK); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.Axis; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; /** * A class that captures information about an Axis of a chart. * * @since 1.0.13 */ public class AxisEntity extends ChartEntity { /** For serialization. */ private static final long serialVersionUID = -4445994133561919083L; //same as for ChartEntity! /** The axis for the entity. */ private Axis axis; /** * Creates a new axis entity. * * @param area the area (null not permitted). * @param axis the axis (null not permitted). */ public AxisEntity(Shape area, Axis axis) { // defer argument checks... this(area, axis, null); } /** * Creates a new axis entity. * * @param area the area (null not permitted). * @param axis the axis (null not permitted). * @param toolTipText the tool tip text (null permitted). */ public AxisEntity(Shape area, Axis axis, String toolTipText) { // defer argument checks... this(area, axis, toolTipText, null); } /** * Creates a new axis entity. * * @param area the area (null not permitted). * @param axis the axis (null not permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text for HTML image maps (null * permitted). */ public AxisEntity(Shape area, Axis axis, String toolTipText, String urlText) { super(area, toolTipText, urlText); if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } this.axis = axis; } /** * Returns the axis that occupies the entity area. * * @return The axis (never null). */ public Axis getAxis() { return this.axis; } /** * Returns a string representation of the chart entity, useful for * debugging. * * @return A string. */ public String toString() { StringBuffer buf = new StringBuffer("AxisEntity: "); buf.append("tooltip = "); buf.append(getToolTipText()); return buf.toString(); } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AxisEntity)) { return false; } AxisEntity that = (AxisEntity) obj; if (!getArea().equals(that.getArea())) { return false; } if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { return false; } if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { return false; } if (!(this.axis.equals(that.axis))) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 39; result = HashUtilities.hashCode(result, getToolTipText()); result = HashUtilities.hashCode(result, getURLText()); return result; } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * entity. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(getArea(), stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); setArea(SerialUtilities.readShape(stream)); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/CategoryItemEntity.java0000644000175000017500000002706211173030414030410 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * CategoryItemEntity.java * ----------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Christian W. Zuckschwerdt; * * Changes: * -------- * 23-May-2002 : Version 1 (DG); * 12-Jun-2002 : Added Javadoc comments (DG); * 26-Jun-2002 : Added getImageMapAreaTag() method (DG); * 05-Aug-2002 : Added new constructor to populate URLText * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 30-Jul-2003 : Added CategoryDataset reference (CZ); * 20-May-2004 : Added equals() and clone() methods, and implemented * Serializable (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-May-2007 : Updated to use row and column keys to identify item (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.Serializable; import org.jfree.data.category.CategoryDataset; import org.jfree.util.ObjectUtilities; /** * A chart entity that represents one item within a category plot. */ public class CategoryItemEntity extends ChartEntity implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8657249457902337349L; /** The dataset. */ private CategoryDataset dataset; /** * The series (zero-based index). * * @deprecated As of 1.0.6, this field is redundant as you can derive the * index from the rowKey field. */ private int series; /** * The category. * * @deprecated As of 1.0.6, this field is deprecated in favour of the * columnKey field. */ private Object category; /** * The category index. * * @deprecated As of 1.0.6, this field is redundant as you can derive the * index from the columnKey field. */ private int categoryIndex; /** * The row key. * * @since 1.0.6 */ private Comparable rowKey; /** * The column key. * * @since 1.0.6 */ private Comparable columnKey; /** * Creates a new category item entity. * * @param area the area (null not permitted). * @param toolTipText the tool tip text. * @param urlText the URL text for HTML image maps. * @param dataset the dataset. * @param series the series (zero-based index). * @param category the category. * @param categoryIndex the category index. * * @deprecated As of 1.0.6, use {@link #CategoryItemEntity(Shape, String, * String, CategoryDataset, Comparable, Comparable)}. */ public CategoryItemEntity(Shape area, String toolTipText, String urlText, CategoryDataset dataset, int series, Object category, int categoryIndex) { super(area, toolTipText, urlText); if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } this.dataset = dataset; this.series = series; this.category = category; this.categoryIndex = categoryIndex; this.rowKey = dataset.getRowKey(series); this.columnKey = dataset.getColumnKey(categoryIndex); } /** * Creates a new entity instance for an item in the specified dataset. * * @param area the 'hotspot' area (null not permitted). * @param toolTipText the tool tip text. * @param urlText the URL text. * @param dataset the dataset (null not permitted). * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @since 1.0.6 */ public CategoryItemEntity(Shape area, String toolTipText, String urlText, CategoryDataset dataset, Comparable rowKey, Comparable columnKey) { super(area, toolTipText, urlText); if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } this.dataset = dataset; this.rowKey = rowKey; this.columnKey = columnKey; // populate the deprecated fields this.series = dataset.getRowIndex(rowKey); this.category = columnKey; this.categoryIndex = dataset.getColumnIndex(columnKey); } /** * Returns the dataset this entity refers to. This can be used to * differentiate between items in a chart that displays more than one * dataset. * * @return The dataset (never null). * * @see #setDataset(CategoryDataset) */ public CategoryDataset getDataset() { return this.dataset; } /** * Sets the dataset this entity refers to. * * @param dataset the dataset (null not permitted). * * @see #getDataset() */ public void setDataset(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } this.dataset = dataset; } /** * Returns the row key. * * @return The row key (never null). * * @since 1.0.6 * * @see #setRowKey(Comparable) */ public Comparable getRowKey() { return this.rowKey; } /** * Sets the row key. * * @param rowKey the row key (null not permitted). * * @since 1.0.6 * * @see #getRowKey() */ public void setRowKey(Comparable rowKey) { this.rowKey = rowKey; // update the deprecated field this.series = this.dataset.getRowIndex(rowKey); } /** * Returns the column key. * * @return The column key (never null). * * @since 1.0.6 * * @see #setColumnKey(Comparable) */ public Comparable getColumnKey() { return this.columnKey; } /** * Sets the column key. * * @param columnKey the column key (null not permitted). * * @since 1.0.6 * * @see #getColumnKey() */ public void setColumnKey(Comparable columnKey) { this.columnKey = columnKey; // update the deprecated fields this.category = columnKey; this.categoryIndex = this.dataset.getColumnIndex(columnKey); } /** * Returns the series index. * * @return The series index. * * @see #setSeries(int) * * @deprecated As of 1.0.6, you can derive this information from the * {@link #getRowKey()} method. */ public int getSeries() { return this.series; } /** * Sets the series index. * * @param series the series index (zero-based). * * @see #getSeries() * * @deprecated As of 1.0.6, you should use {@link #setRowKey(Comparable)} * to designate the series. */ public void setSeries(int series) { this.series = series; } /** * Returns the category. * * @return The category (possibly null). * * @see #setCategory(Object) * * @deprecated The return type for this method should be * Comparable, so it has been deprecated as of * version 1.0.6 and replaced by {@link #getColumnKey()}. */ public Object getCategory() { return this.category; } /** * Sets the category. * * @param category the category (null permitted). * * @see #getCategory() * * @deprecated As of version 1.0.6, use {@link #setColumnKey(Comparable)}. */ public void setCategory(Object category) { this.category = category; } /** * Returns the category index. * * @return The index. * * @see #setCategoryIndex(int) * * @deprecated As of 1.0.6, you can derive this information from the * {@link #getColumnKey()} method. */ public int getCategoryIndex() { return this.categoryIndex; } /** * Sets the category index. * * @param index the category index. * * @see #getCategoryIndex() * * @deprecated As of 1.0.6, use {@link #setColumnKey(Comparable)} to * designate the category. */ public void setCategoryIndex(int index) { this.categoryIndex = index; } /** * Returns a string representing this object (useful for debugging * purposes). * * @return A string (never null). */ public String toString() { return "CategoryItemEntity: rowKey=" + this.rowKey + ", columnKey=" + this.columnKey + ", dataset=" + this.dataset; } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryItemEntity)) { return false; } CategoryItemEntity that = (CategoryItemEntity) obj; if (!this.rowKey.equals(that.rowKey)) { return false; } if (!this.columnKey.equals(that.columnKey)) { return false; } if (!ObjectUtilities.equal(this.dataset, that.dataset)) { return false; } // check the deprecated fields if (this.categoryIndex != that.categoryIndex) { return false; } if (this.series != that.series) { return false; } if (!ObjectUtilities.equal(this.category, that.category)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/CategoryLabelEntity.java0000644000175000017500000000755011173030414030531 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CategoryLabelEntity.java * ------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Oct-2006 : Version 1 (DG); * 13-Nov-2007 : Added equals() and hashCode() methods (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.CategoryAxis; import org.jfree.util.ObjectUtilities; /** * An entity to represent the labels on a {@link CategoryAxis}. * * @since 1.0.3 */ public class CategoryLabelEntity extends TickLabelEntity { /** The category key. */ private Comparable key; /** * Creates a new entity. * * @param key the category key. * @param area the hotspot. * @param toolTipText the tool tip text. * @param urlText the URL text. */ public CategoryLabelEntity(Comparable key, Shape area, String toolTipText, String urlText) { super(area, toolTipText, urlText); this.key = key; } /** * Returns the category key. * * @return The category key. */ public Comparable getKey() { return this.key; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryLabelEntity)) { return false; } CategoryLabelEntity that = (CategoryLabelEntity) obj; if (!ObjectUtilities.equal(this.key, that.key)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = HashUtilities.hashCode(result, this.key); return result; } /** * Returns a string representation of this entity. This is primarily * useful for debugging. * * @return A string representation of this entity. */ public String toString() { StringBuffer buf = new StringBuffer("CategoryLabelEntity: "); buf.append("category="); buf.append(this.key); buf.append(", tooltip=" + getToolTipText()); buf.append(", url=" + getURLText()); return buf.toString(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/ChartEntity.java0000644000175000017500000003561711173030414027062 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ChartEntity.java * ---------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Xavier Poinsard; * Robert Fuller; * * Changes: * -------- * 23-May-2002 : Version 1 (DG); * 12-Jun-2002 : Added Javadoc comments (DG); * 26-Jun-2002 : Added methods for image maps (DG); * 05-Aug-2002 : Added constructor and accessors for URL support in image maps * Added getImageMapAreaTag() - previously in subclasses (RA); * 05-Sep-2002 : Added getImageMapAreaTag(boolean) to support OverLIB for * tooltips http://www.bosrup.com/web/overlib (RA); * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Oct-2002 : Changed getImageMapAreaTag to use title instead of alt * attribute so HTML image maps now work in Mozilla and Opera as * well as Internet Explorer (RA); * 13-Mar-2003 : Change getImageMapAreaTag to only return a tag when there is a * tooltip or URL, as suggested by Xavier Poinsard (see Feature * Request 688079) (DG); * 12-Aug-2003 : Added support for custom image maps using * ToolTipTagFragmentGenerator and URLTagFragmentGenerator (RA); * 02-Sep-2003 : Incorporated fix (791901) submitted by Robert Fuller (DG); * 19-May-2004 : Added equals() method and implemented Cloneable and * Serializable (DG); * 29-Sep-2004 : Implemented PublicCloneable (DG); * 13-Jan-2005 : Fixed for compliance with XHTML 1.0 (DG); * 18-Apr-2005 : Use StringBuffer (DG); * 20-Apr-2005 : Added toString() implementation (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Feb-2007 : API doc update (DG); * 13-Nov-2007 : Reorganised equals(), implemented hashCode (DG); * 04-Dec-2007 : Added 'nohref' attribute in getImageMapAreaTag() method, to * fix bug 1460195 (DG); * 04-Dec-2007 : Escape the toolTipText and urlText in getImageMapAreaTag() to * prevent special characters corrupting the HTML (DG); * 05-Dec-2007 : Previous change reverted - let the tool tip and url tag * generators handle filtering / escaping (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.awt.geom.PathIterator; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator; import org.jfree.chart.imagemap.URLTagFragmentGenerator; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A class that captures information about some component of a chart (a bar, * line etc). */ public class ChartEntity implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4445994133561919083L; /** The area occupied by the entity (in Java 2D space). */ private transient Shape area; /** The tool tip text for the entity. */ private String toolTipText; /** The URL text for the entity. */ private String urlText; /** * Creates a new chart entity. * * @param area the area (null not permitted). */ public ChartEntity(Shape area) { // defer argument checks... this(area, null); } /** * Creates a new chart entity. * * @param area the area (null not permitted). * @param toolTipText the tool tip text (null permitted). */ public ChartEntity(Shape area, String toolTipText) { // defer argument checks... this(area, toolTipText, null); } /** * Creates a new entity. * * @param area the area (null not permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text for HTML image maps (null * permitted). */ public ChartEntity(Shape area, String toolTipText, String urlText) { if (area == null) { throw new IllegalArgumentException("Null 'area' argument."); } this.area = area; this.toolTipText = toolTipText; this.urlText = urlText; } /** * Returns the area occupied by the entity (in Java 2D space). * * @return The area (never null). */ public Shape getArea() { return this.area; } /** * Sets the area for the entity. *

* This class conveys information about chart entities back to a client. * Setting this area doesn't change the entity (which has already been * drawn). * * @param area the area (null not permitted). */ public void setArea(Shape area) { if (area == null) { throw new IllegalArgumentException("Null 'area' argument."); } this.area = area; } /** * Returns the tool tip text for the entity. Be aware that this text * may have been generated from user supplied data, so for security * reasons some form of filtering should be applied before incorporating * this text into any HTML output. * * @return The tool tip text (possibly null). */ public String getToolTipText() { return this.toolTipText; } /** * Sets the tool tip text. * * @param text the text (null permitted). */ public void setToolTipText(String text) { this.toolTipText = text; } /** * Returns the URL text for the entity. Be aware that this text * may have been generated from user supplied data, so some form of * filtering should be applied before this "URL" is used in any output. * * @return The URL text (possibly null). */ public String getURLText() { return this.urlText; } /** * Sets the URL text. * * @param text the text (null permitted). */ public void setURLText(String text) { this.urlText = text; } /** * Returns a string describing the entity area. This string is intended * for use in an AREA tag when generating an image map. * * @return The shape type (never null). */ public String getShapeType() { if (this.area instanceof Rectangle2D) { return "rect"; } else { return "poly"; } } /** * Returns the shape coordinates as a string. * * @return The shape coordinates (never null). */ public String getShapeCoords() { if (this.area instanceof Rectangle2D) { return getRectCoords((Rectangle2D) this.area); } else { return getPolyCoords(this.area); } } /** * Returns a string containing the coordinates (x1, y1, x2, y2) for a given * rectangle. This string is intended for use in an image map. * * @param rectangle the rectangle (null not permitted). * * @return Upper left and lower right corner of a rectangle. */ private String getRectCoords(Rectangle2D rectangle) { if (rectangle == null) { throw new IllegalArgumentException("Null 'rectangle' argument."); } int x1 = (int) rectangle.getX(); int y1 = (int) rectangle.getY(); int x2 = x1 + (int) rectangle.getWidth(); int y2 = y1 + (int) rectangle.getHeight(); // fix by rfuller if (x2 == x1) { x2++; } if (y2 == y1) { y2++; } // end fix by rfuller return x1 + "," + y1 + "," + x2 + "," + y2; } /** * Returns a string containing the coordinates for a given shape. This * string is intended for use in an image map. * * @param shape the shape (null not permitted). * * @return The coordinates for a given shape as string. */ private String getPolyCoords(Shape shape) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } StringBuffer result = new StringBuffer(); boolean first = true; float[] coords = new float[6]; PathIterator pi = shape.getPathIterator(null, 1.0); while (!pi.isDone()) { pi.currentSegment(coords); if (first) { first = false; result.append((int) coords[0]); result.append(",").append((int) coords[1]); } else { result.append(","); result.append((int) coords[0]); result.append(","); result.append((int) coords[1]); } pi.next(); } return result.toString(); } /** * Returns an HTML image map tag for this entity. The returned fragment * should be XHTML 1.0 compliant. * * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (null not permitted * if this entity contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (null not permitted if * this entity has a URL). * * @return The HTML tag. */ public String getImageMapAreaTag( ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { StringBuffer tag = new StringBuffer(); boolean hasURL = (this.urlText == null ? false : !this.urlText.equals("")); boolean hasToolTip = (this.toolTipText == null ? false : !this.toolTipText.equals("")); if (hasURL || hasToolTip) { tag.append(""); } return tag.toString(); } /** * Returns a string representation of the chart entity, useful for * debugging. * * @return A string. */ public String toString() { StringBuffer buf = new StringBuffer("ChartEntity: "); buf.append("tooltip = "); buf.append(this.toolTipText); return buf.toString(); } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ChartEntity)) { return false; } ChartEntity that = (ChartEntity) obj; if (!this.area.equals(that.area)) { return false; } if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { return false; } if (!ObjectUtilities.equal(this.urlText, that.urlText)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 37; result = HashUtilities.hashCode(result, this.toolTipText); result = HashUtilities.hashCode(result, this.urlText); return result; } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * entity. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.area, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.area = SerialUtilities.readShape(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/ContourEntity.java0000644000175000017500000001030411173030414027434 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * ContourEntity.java * ------------------ * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 20-May-2004 : Added equals() and clone() methods and implemented * Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.Serializable; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * Represents an item on a contour chart. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class ContourEntity extends ChartEntity implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1249570520505992847L; /** Holds the index into the dataset for this entity. */ private int index = -1; /** * Constructor for ContourEntity. * * @param area the area. * @param toolTipText the tooltip text. */ public ContourEntity(Shape area, String toolTipText) { super(area, toolTipText); } /** * Constructor for ContourEntity. * * @param area the area. * @param toolTipText the tooltip text. * @param urlText the URL text. */ public ContourEntity(Shape area, String toolTipText, String urlText) { super(area, toolTipText, urlText); } /** * Returns the index. * * @return The index. */ public int getIndex() { return this.index; } /** * Sets the index. * * @param index the index. */ public void setIndex(int index) { this.index = index; } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof ContourEntity && super.equals(obj)) { ContourEntity ce = (ContourEntity) obj; if (this.index != ce.index) { return false; } return true; } return false; } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/EntityCollection.java0000644000175000017500000000672511173030414030112 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * EntityCollection.java * --------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-May-2002 : Version 1 (DG); * 25-Jun-2002 : Removed unnecessary import (DG); * 26-Jun-2002 : Added iterator() method (DG); * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 30-Jan-2004 : Added a method to add a collection of entities. * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 18-Jan-2005 : Added getEntity() and getEntityCount() methods (DG); * */ package org.jfree.chart.entity; import java.util.Collection; import java.util.Iterator; /** * This interface defines the methods used to access an ordered list of * {@link ChartEntity} objects. */ public interface EntityCollection { /** * Clears all entities. */ public void clear(); /** * Adds an entity to the collection. * * @param entity the entity (null not permitted). */ public void add(ChartEntity entity); /** * Adds the entities from another collection to this collection. * * @param collection the other collection. */ public void addAll(EntityCollection collection); /** * Returns an entity whose area contains the specified point. * * @param x the x coordinate. * @param y the y coordinate. * * @return The entity. */ public ChartEntity getEntity(double x, double y); /** * Returns an entity from the collection. * * @param index the index (zero-based). * * @return An entity. */ public ChartEntity getEntity(int index); /** * Returns the entity count. * * @return The entity count. */ public int getEntityCount(); /** * Returns the entities in an unmodifiable collection. * * @return The entities. */ public Collection getEntities(); /** * Returns an iterator for the entities in the collection. * * @return An iterator. */ public Iterator iterator(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/JFreeChartEntity.java0000644000175000017500000001461111173030414027765 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * JFreeChartEntity.java * -------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: Peter Kolb; * Contributor(s): ; * * Changes: * -------- * 15-Feb-2009 : Version 1 (PK); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.JFreeChart; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; /** * A class that captures information about an entire chart. * * @since 1.0.13 */ public class JFreeChartEntity extends ChartEntity { /** For serialization. */ private static final long serialVersionUID = -4445994133561919083L; //same as for ChartEntity! /** The chart. */ private JFreeChart chart; /** * Creates a new chart entity. * * @param area the area (null not permitted). * @param chart the chart (null not permitted). */ public JFreeChartEntity(Shape area, JFreeChart chart) { // defer argument checks... this(area, chart, null); } /** * Creates a new chart entity. * * @param area the area (null not permitted). * @param chart the chart (null not permitted). * @param toolTipText the tool tip text (null permitted). */ public JFreeChartEntity(Shape area, JFreeChart chart, String toolTipText) { // defer argument checks... this(area, chart, toolTipText, null); } /** * Creates a new chart entity. * * @param area the area (null not permitted). * @param chart the chart (null not permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text for HTML image maps (null * permitted). */ public JFreeChartEntity(Shape area, JFreeChart chart, String toolTipText, String urlText) { super(area, toolTipText, urlText); if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } this.chart = chart; } /** * Returns the chart that occupies the entity area. * * @return The chart (never null). */ public JFreeChart getChart() { return this.chart; } /** * Returns a string representation of the chart entity, useful for * debugging. * * @return A string. */ public String toString() { StringBuffer buf = new StringBuffer("JFreeChartEntity: "); buf.append("tooltip = "); buf.append(getToolTipText()); return buf.toString(); } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof JFreeChartEntity)) { return false; } JFreeChartEntity that = (JFreeChartEntity) obj; if (!getArea().equals(that.getArea())) { return false; } if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { return false; } if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { return false; } if (!(this.chart.equals(that.chart))) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 39; result = HashUtilities.hashCode(result, getToolTipText()); result = HashUtilities.hashCode(result, getURLText()); return result; } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * entity. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(getArea(), stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); setArea(SerialUtilities.readShape(stream)); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/LegendItemEntity.java0000644000175000017500000001327411173030414030031 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * LegendItemEntity.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Jun-2003 : Version 1 (DG); * 20-May-2004 : Added equals() method and implemented Cloneable and * Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-May-2007 : Added dataset and seriesKey fields (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.Serializable; import org.jfree.data.general.Dataset; import org.jfree.util.ObjectUtilities; /** * An entity that represents an item within a legend. */ public class LegendItemEntity extends ChartEntity implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7435683933545666702L; /** * The dataset. * * @since 1.0.6 */ private Dataset dataset; /** * The series key. * * @since 1.0.6 */ private Comparable seriesKey; /** The series index. */ private int seriesIndex; /** * Creates a legend item entity. * * @param area the area. */ public LegendItemEntity(Shape area) { super(area); } /** * Returns a reference to the dataset that this legend item is derived * from. * * @return The dataset. * * @since 1.0.6 * * @see #setDataset(Dataset) */ public Dataset getDataset() { return this.dataset; } /** * Sets a reference to the dataset that this legend item is derived from. * * @param dataset the dataset. * * @since 1.0.6 */ public void setDataset(Dataset dataset) { this.dataset = dataset; } /** * Returns the series key that identifies the legend item. * * @return The series key. * * @since 1.0.6 * * @see #setSeriesKey(Comparable) */ public Comparable getSeriesKey() { return this.seriesKey; } /** * Sets the key for the series. * * @param key the key. * * @since 1.0.6 * * @see #getSeriesKey() */ public void setSeriesKey(Comparable key) { this.seriesKey = key; } /** * Returns the series index. * * @return The series index. * * @see #setSeriesIndex(int) * * @deprecated As of 1.0.6, use the {@link #getSeriesKey()} method. */ public int getSeriesIndex() { return this.seriesIndex; } /** * Sets the series index. * * @param index the series index. * * @see #getSeriesIndex() * * @deprecated As of 1.0.6, use the {@link #setSeriesKey(Comparable)} * method. */ public void setSeriesIndex(int index) { this.seriesIndex = index; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LegendItemEntity)) { return false; } LegendItemEntity that = (LegendItemEntity) obj; if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey)) { return false; } if (this.seriesIndex != that.seriesIndex) { return false; } if (!ObjectUtilities.equal(this.dataset, that.dataset)) { return false; } return super.equals(obj); } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * object. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Returns a string representing this object (useful for debugging * purposes). * * @return A string (never null). */ public String toString() { return "LegendItemEntity: seriesKey=" + this.seriesKey + ", dataset=" + this.dataset; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/PieSectionEntity.java0000644000175000017500000001656111173030414030060 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * PieSectionEntity.java * --------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Christian W. Zuckschwerdt; * * Changes: * -------- * 23-May-2002 : Version 1 (DG); * 12-Jun-2002 : Added Javadoc comments (DG); * 26-Jun-2002 : Added method to generate AREA tag for image map * generation (DG); * 05-Aug-2002 : Added new constructor to populate URLText * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 07-Mar-2003 : Added pie index attribute, since the PiePlot class can create * multiple pie plots within one chart. Also renamed 'category' * --> 'sectionKey' and changed the class from Object --> * Comparable (DG); * 30-Jul-2003 : Added PieDataset reference (CZ); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 13-Nov-2007 : Implemented equals() and hashCode() (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.data.general.PieDataset; import org.jfree.util.ObjectUtilities; /** * A chart entity that represents one section within a pie plot. */ public class PieSectionEntity extends ChartEntity implements Serializable { /** For serialization. */ private static final long serialVersionUID = 9199892576531984162L; /** The dataset. */ private PieDataset dataset; /** The pie index. */ private int pieIndex; /** The section index. */ private int sectionIndex; /** The section key. */ private Comparable sectionKey; /** * Creates a new pie section entity. * * @param area the area. * @param dataset the pie dataset. * @param pieIndex the pie index (zero-based). * @param sectionIndex the section index (zero-based). * @param sectionKey the section key. * @param toolTipText the tool tip text. * @param urlText the URL text for HTML image maps. */ public PieSectionEntity(Shape area, PieDataset dataset, int pieIndex, int sectionIndex, Comparable sectionKey, String toolTipText, String urlText) { super(area, toolTipText, urlText); this.dataset = dataset; this.pieIndex = pieIndex; this.sectionIndex = sectionIndex; this.sectionKey = sectionKey; } /** * Returns the dataset this entity refers to. * * @return The dataset. * * @see #setDataset(PieDataset) */ public PieDataset getDataset() { return this.dataset; } /** * Sets the dataset this entity refers to. * * @param dataset the dataset. * * @see #getDataset() */ public void setDataset(PieDataset dataset) { this.dataset = dataset; } /** * Returns the pie index. For a regular pie chart, the section index is 0. * For a pie chart containing multiple pie plots, the pie index is the row * or column index from which the pie data is extracted. * * @return The pie index. * * @see #setPieIndex(int) */ public int getPieIndex() { return this.pieIndex; } /** * Sets the pie index. * * @param index the new index value. * * @see #getPieIndex() */ public void setPieIndex(int index) { this.pieIndex = index; } /** * Returns the section index. * * @return The section index. * * @see #setSectionIndex(int) */ public int getSectionIndex() { return this.sectionIndex; } /** * Sets the section index. * * @param index the section index. * * @see #getSectionIndex() */ public void setSectionIndex(int index) { this.sectionIndex = index; } /** * Returns the section key. * * @return The section key. * * @see #setSectionKey(Comparable) */ public Comparable getSectionKey() { return this.sectionKey; } /** * Sets the section key. * * @param key the section key. * * @see #getSectionKey() */ public void setSectionKey(Comparable key) { this.sectionKey = key; } /** * Tests this entity for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieSectionEntity)) { return false; } PieSectionEntity that = (PieSectionEntity) obj; if (!ObjectUtilities.equal(this.dataset, that.dataset)) { return false; } if (this.pieIndex != that.pieIndex) { return false; } if (this.sectionIndex != that.sectionIndex) { return false; } if (!ObjectUtilities.equal(this.sectionKey, that.sectionKey)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = HashUtilities.hashCode(result, this.pieIndex); result = HashUtilities.hashCode(result, this.sectionIndex); return result; } /** * Returns a string representing the entity. * * @return A string representing the entity. */ public String toString() { return "PieSection: " + this.pieIndex + ", " + this.sectionIndex + "(" + this.sectionKey.toString() + ")"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/PlotEntity.java0000644000175000017500000001437411173030414026734 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * PlotEntity.java * --------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: Peter Kolb; * Contributor(s): ; * * Changes: * -------- * 15-Feb-2009 : Version 1 (PK); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.plot.Plot; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; /** * A class that captures information about a plot. * * @since 1.0.13 */ public class PlotEntity extends ChartEntity { /** For serialization. */ private static final long serialVersionUID = -4445994133561919083L; //same as for ChartEntity! /** The plot. */ private Plot plot; /** * Creates a new plot entity. * * @param area the area (null not permitted). * @param plot the plot (null not permitted). */ public PlotEntity(Shape area, Plot plot) { // defer argument checks... this(area, plot, null); } /** * Creates a new plot entity. * * @param area the area (null not permitted). * @param plot the plot (null not permitted). * @param toolTipText the tool tip text (null permitted). */ public PlotEntity(Shape area, Plot plot, String toolTipText) { // defer argument checks... this(area, plot, toolTipText, null); } /** * Creates a new plot entity. * * @param area the area (null not permitted). * @param plot the plot (null not permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text for HTML image maps (null * permitted). */ public PlotEntity(Shape area, Plot plot, String toolTipText, String urlText) { super(area, toolTipText, urlText); if (plot == null) { throw new IllegalArgumentException("Null 'plot' argument."); } this.plot = plot; } /** * Returns the plot that occupies the entity area. * * @return The plot (never null). */ public Plot getPlot() { return this.plot; } /** * Returns a string representation of the plot entity, useful for * debugging. * * @return A string. */ public String toString() { StringBuffer buf = new StringBuffer("PlotEntity: "); buf.append("tooltip = "); buf.append(getToolTipText()); return buf.toString(); } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PlotEntity)) { return false; } PlotEntity that = (PlotEntity) obj; if (!getArea().equals(that.getArea())) { return false; } if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { return false; } if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { return false; } if (!(this.plot.equals(that.plot))) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 39; result = HashUtilities.hashCode(result, getToolTipText()); result = HashUtilities.hashCode(result, getURLText()); return result; } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * entity. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(getArea(), stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); setArea(SerialUtilities.readShape(stream)); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/StandardEntityCollection.java0000644000175000017500000001464311173030414031571 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * StandardEntityCollection.java * ----------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-May-2002 : Version 1 (DG); * 26-Jun-2002 : Added iterator() method (DG); * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 19-May-2004 : Implemented Serializable (DG); * 29-Sep-2004 : Renamed addEntity() --> add() and addEntities() * --> addAll() (DG); * 19-Jan-2005 : Changed storage from Collection --> List (DG); * 20-May-2005 : Fixed bug 1113521 - inefficiency in getEntity() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Dec-2006 : Implemented PublicCloneable and fixed clone() method (DG); * */ package org.jfree.chart.entity; import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A standard implementation of the {@link EntityCollection} interface. */ public class StandardEntityCollection implements EntityCollection, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5384773031184897047L; /** Storage for the entities. */ private List entities; /** * Constructs a new entity collection (initially empty). */ public StandardEntityCollection() { this.entities = new java.util.ArrayList(); } /** * Returns the number of entities in the collection. * * @return The entity count. */ public int getEntityCount() { return this.entities.size(); } /** * Returns a chart entity from the collection. * * @param index the entity index. * * @return The entity. * * @see #add(ChartEntity) */ public ChartEntity getEntity(int index) { return (ChartEntity) this.entities.get(index); } /** * Clears all the entities from the collection. */ public void clear() { this.entities.clear(); } /** * Adds an entity to the collection. * * @param entity the entity (null not permitted). */ public void add(ChartEntity entity) { if (entity == null) { throw new IllegalArgumentException("Null 'entity' argument."); } this.entities.add(entity); } /** * Adds all the entities from the specified collection. * * @param collection the collection of entities (null not * permitted). */ public void addAll(EntityCollection collection) { this.entities.addAll(collection.getEntities()); } /** * Returns the last entity in the list with an area that encloses the * specified coordinates, or null if there is no such entity. * * @param x the x coordinate. * @param y the y coordinate. * * @return The entity (possibly null). */ public ChartEntity getEntity(double x, double y) { int entityCount = this.entities.size(); for (int i = entityCount - 1; i >= 0; i--) { ChartEntity entity = (ChartEntity) this.entities.get(i); if (entity.getArea().contains(x, y)) { return entity; } } return null; } /** * Returns the entities in an unmodifiable collection. * * @return The entities. */ public Collection getEntities() { return Collections.unmodifiableCollection(this.entities); } /** * Returns an iterator for the entities in the collection. * * @return An iterator. */ public Iterator iterator() { return this.entities.iterator(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof StandardEntityCollection) { StandardEntityCollection that = (StandardEntityCollection) obj; return ObjectUtilities.equal(this.entities, that.entities); } return false; } /** * Returns a clone of this entity collection. * * @return A clone. * * @throws CloneNotSupportedException if the object cannot be cloned. */ public Object clone() throws CloneNotSupportedException { StandardEntityCollection clone = (StandardEntityCollection) super.clone(); clone.entities = new java.util.ArrayList(this.entities.size()); for (int i = 0; i < this.entities.size(); i++) { ChartEntity entity = (ChartEntity) this.entities.get(i); clone.entities.add(entity.clone()); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/TickLabelEntity.java0000644000175000017500000000453111173030414027642 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * TickLabelEntity.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 16-Mar-2004 : Version 1 (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.Serializable; /** * A chart entity representing a tick label. */ public class TickLabelEntity extends ChartEntity implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 681583956588092095L; /** * Creates a new entity. * * @param area the area (null not permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text for HTML image maps (null * permitted). */ public TickLabelEntity(Shape area, String toolTipText, String urlText) { super(area, toolTipText, urlText); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/TitleEntity.java0000644000175000017500000001451311173030414027072 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * TitleEntity.java * ---------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: Peter Kolb; * Contributor(s): ; * * Changes: * -------- * 15-Feb-2009 : Version 1 (PK); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.HashUtilities; import org.jfree.chart.title.Title; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; /** * A class that captures information about a Title of a chart. * * @since 1.0.13 */ public class TitleEntity extends ChartEntity { /** For serialization. */ private static final long serialVersionUID = -4445994133561919083L; //same as for ChartEntity! /** The Title for the entity. */ private Title title; /** * Creates a new chart entity. * * @param area the area (null not permitted). * @param title the title (null not permitted). */ public TitleEntity(Shape area, Title title) { // defer argument checks... this(area, title, null); } /** * Creates a new chart entity. * * @param area the area (null not permitted). * @param title the title (null not permitted). * @param toolTipText the tool tip text (null permitted). */ public TitleEntity(Shape area, Title title, String toolTipText) { // defer argument checks... this(area, title, toolTipText, null); } /** * Creates a new entity. * * @param area the area (null not permitted). * @param title the title (null not permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text for HTML image maps (null * permitted). */ public TitleEntity(Shape area, Title title, String toolTipText, String urlText) { super(area, toolTipText, urlText); if (title == null) { throw new IllegalArgumentException("Null 'title' argument."); } this.title = title; } /** * Returns the title that occupies the entity area. * * @return The title (never null). */ public Title getTitle() { return this.title; } /** * Returns a string representation of the chart entity, useful for * debugging. * * @return A string. */ public String toString() { StringBuffer buf = new StringBuffer("TitleEntity: "); buf.append("tooltip = "); buf.append(getToolTipText()); return buf.toString(); } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TitleEntity)) { return false; } TitleEntity that = (TitleEntity) obj; if (!getArea().equals(that.getArea())) { return false; } if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { return false; } if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { return false; } if (!(this.title.equals(that.title))) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 41; result = HashUtilities.hashCode(result, getToolTipText()); result = HashUtilities.hashCode(result, getURLText()); return result; } /** * Returns a clone of the entity. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * entity. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(getArea(), stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); setArea(SerialUtilities.readShape(stream)); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/XYAnnotationEntity.java0000644000175000017500000000673611173030414030414 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYAnnotationEntity.java * ----------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 29-Sep-2004 : Version 1 (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import java.io.Serializable; /** * A chart entity that represents an annotation on an * {@link org.jfree.chart.plot.XYPlot}. */ public class XYAnnotationEntity extends ChartEntity implements Serializable { /** For serialization. */ private static final long serialVersionUID = 2340334068383660799L; /** The renderer index. */ private int rendererIndex; /** * Creates a new entity. * * @param hotspot the area. * @param rendererIndex the rendererIndex (zero-based index). * @param toolTipText the tool tip text. * @param urlText the URL text for HTML image maps. */ public XYAnnotationEntity(Shape hotspot, int rendererIndex, String toolTipText, String urlText) { super(hotspot, toolTipText, urlText); this.rendererIndex = rendererIndex; } /** * Returns the renderer index. * * @return The renderer index. */ public int getRendererIndex() { return this.rendererIndex; } /** * Sets the renderer index. * * @param index the item index (zero-based). */ public void setRendererIndex(int index) { this.rendererIndex = index; } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof XYAnnotationEntity)) { return false; } XYAnnotationEntity that = (XYAnnotationEntity) obj; if (this.rendererIndex != that.rendererIndex) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/XYItemEntity.java0000644000175000017500000001240411173030414027165 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * XYItemEntity.java * ----------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Christian W. Zuckschwerdt; * * Changes: * -------- * 23-May-2002 : Version 1 (DG); * 12-Jun-2002 : Added accessor methods and Javadoc comments (DG); * 26-Jun-2002 : Added getImageMapAreaTag() method (DG); * 05-Aug-2002 : Added new constructor to populate URLText * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 30-Jun-2003 : Added XYDataset reference (CZ); * 20-May-2004 : Added equals() and clone() methods and implemented * Serializable (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * */ package org.jfree.chart.entity; import java.awt.Shape; import org.jfree.data.xy.XYDataset; /** * A chart entity that represents one item within an * {@link org.jfree.chart.plot.XYPlot}. */ public class XYItemEntity extends ChartEntity { /** For serialization. */ private static final long serialVersionUID = -3870862224880283771L; /** The dataset. */ private transient XYDataset dataset; /** The series. */ private int series; /** The item. */ private int item; /** * Creates a new entity. * * @param area the area. * @param dataset the dataset. * @param series the series (zero-based index). * @param item the item (zero-based index). * @param toolTipText the tool tip text. * @param urlText the URL text for HTML image maps. */ public XYItemEntity(Shape area, XYDataset dataset, int series, int item, String toolTipText, String urlText) { super(area, toolTipText, urlText); this.dataset = dataset; this.series = series; this.item = item; } /** * Returns the dataset this entity refers to. * * @return The dataset. */ public XYDataset getDataset() { return this.dataset; } /** * Sets the dataset this entity refers to. * * @param dataset the dataset. */ public void setDataset(XYDataset dataset) { this.dataset = dataset; } /** * Returns the series index. * * @return The series index. */ public int getSeriesIndex() { return this.series; } /** * Sets the series index. * * @param series the series index (zero-based). */ public void setSeriesIndex(int series) { this.series = series; } /** * Returns the item index. * * @return The item index. */ public int getItem() { return this.item; } /** * Sets the item index. * * @param item the item index (zero-based). */ public void setItem(int item) { this.item = item; } /** * Tests the entity for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof XYItemEntity && super.equals(obj)) { XYItemEntity ie = (XYItemEntity) obj; if (this.series != ie.series) { return false; } if (this.item != ie.item) { return false; } return true; } return false; } /** * Returns a string representation of this instance, useful for debugging * purposes. * * @return A string. */ public String toString() { return "XYItemEntity: series = " + getSeriesIndex() + ", item = " + getItem() + ", dataset = " + getDataset(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/entity/package.html0000644000175000017500000000025111173030414026224 0ustar vincentvincent Classes representing components of (or entities in) a chart. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/0000755000175000017500000000000011216245561023563 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/AxisChangeEvent.java0000644000175000017500000000452211173030414027434 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * AxisChangeEvent.java * -------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.chart.event; import org.jfree.chart.axis.Axis; /** * A change event that encapsulates information about a change to an axis. */ public class AxisChangeEvent extends ChartChangeEvent { /** The axis that generated the change event. */ private Axis axis; /** * Creates a new AxisChangeEvent. * * @param axis the axis that generated the event. */ public AxisChangeEvent(Axis axis) { super(axis); this.axis = axis; } /** * Returns the axis that generated the event. * * @return The axis that generated the event. */ public Axis getAxis() { return this.axis; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/AxisChangeListener.java0000644000175000017500000000462211173030414030141 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * AxisChangeEvent.java * -------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * 14-Oct-2002 : Now extends EventListener (DG); * */ package org.jfree.chart.event; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of changes to an axis. *

* The Plot class implements this interface, and automatically registers with * its axes (if any). Any axis changes are passed on by the plot as a plot * change event. This is part of the notification mechanism that ensures that * charts are redrawn whenever changes are made to any chart component. * */ public interface AxisChangeListener extends EventListener { /** * Receives notification of an axis change event. * * @param event the event. */ public void axisChanged(AxisChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/ChartChangeEvent.java0000644000175000017500000001014111173030414027563 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ChartChangeEvent.java * --------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * Change event type names (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 18-Feb-2005 : Changed the type from int to ChartChangeEventType (DG); * */ package org.jfree.chart.event; import java.util.EventObject; import org.jfree.chart.JFreeChart; /** * A change event that encapsulates information about a change to a chart. */ public class ChartChangeEvent extends EventObject { /** The type of event. */ private ChartChangeEventType type; /** The chart that generated the event. */ private JFreeChart chart; /** * Creates a new chart change event. * * @param source the source of the event (could be the chart, a title, * an axis etc.) */ public ChartChangeEvent(Object source) { this(source, null, ChartChangeEventType.GENERAL); } /** * Creates a new chart change event. * * @param source the source of the event (could be the chart, a title, an * axis etc.) * @param chart the chart that generated the event. */ public ChartChangeEvent(Object source, JFreeChart chart) { this(source, chart, ChartChangeEventType.GENERAL); } /** * Creates a new chart change event. * * @param source the source of the event (could be the chart, a title, an axis etc.) * @param chart the chart that generated the event. * @param type the type of event. */ public ChartChangeEvent(Object source, JFreeChart chart, ChartChangeEventType type) { super(source); this.chart = chart; this.type = type; } /** * Returns the chart that generated the change event. * * @return The chart that generated the change event. */ public JFreeChart getChart() { return this.chart; } /** * Sets the chart that generated the change event. * * @param chart the chart that generated the event. */ public void setChart(JFreeChart chart) { this.chart = chart; } /** * Returns the event type. * * @return The event type. */ public ChartChangeEventType getType() { return this.type; } /** * Sets the event type. * * @param type the event type. */ public void setType(ChartChangeEventType type) { this.type = type; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/ChartChangeEventType.java0000644000175000017500000001024011173030414030425 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ChartChangeEventType.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 18-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.event; import java.io.ObjectStreamException; import java.io.Serializable; /** * Defines tokens used to indicate an event type. */ public final class ChartChangeEventType implements Serializable { /** For serialization. */ private static final long serialVersionUID = 5481917022435735602L; /** GENERAL. */ public static final ChartChangeEventType GENERAL = new ChartChangeEventType("ChartChangeEventType.GENERAL"); /** NEW_DATASET. */ public static final ChartChangeEventType NEW_DATASET = new ChartChangeEventType("ChartChangeEventType.NEW_DATASET"); /** DATASET_UPDATED. */ public static final ChartChangeEventType DATASET_UPDATED = new ChartChangeEventType("ChartChangeEventType.DATASET_UPDATED"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private ChartChangeEventType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ChartChangeEventType)) { return false; } ChartChangeEventType that = (ChartChangeEventType) obj; if (!this.name.equals(that.toString())) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(ChartChangeEventType.GENERAL)) { return ChartChangeEventType.GENERAL; } else if (this.equals(ChartChangeEventType.NEW_DATASET)) { return ChartChangeEventType.NEW_DATASET; } else if (this.equals(ChartChangeEventType.DATASET_UPDATED)) { return ChartChangeEventType.DATASET_UPDATED; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/ChartChangeListener.java0000644000175000017500000000451111173030414030273 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * ChartChangeListener.java * ------------------------ * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 14-Oct-2002 : Now extends java.util.EventListener (DG); * */ package org.jfree.chart.event; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of chart events. *

* The {@link org.jfree.chart.ChartPanel} class registers itself with the * chart it displays, and whenever the chart changes, the panel redraws itself. * */ public interface ChartChangeListener extends EventListener { /** * Receives notification of a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/ChartProgressEvent.java0000644000175000017500000000737511173030414030221 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * ChartProgressEvent.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Jan-2003 : Version 1 (DG); * */ package org.jfree.chart.event; import org.jfree.chart.JFreeChart; /** * An event that contains information about the drawing progress of a chart. */ public class ChartProgressEvent extends java.util.EventObject { /** Indicates drawing has started. */ public static final int DRAWING_STARTED = 1; /** Indicates drawing has finished. */ public static final int DRAWING_FINISHED = 2; /** The type of event. */ private int type; /** The percentage of completion. */ private int percent; /** The chart that generated the event. */ private JFreeChart chart; /** * Creates a new chart change event. * * @param source the source of the event (could be the chart, a title, an * axis etc.) * @param chart the chart that generated the event. * @param type the type of event. * @param percent the percentage of completion. */ public ChartProgressEvent(Object source, JFreeChart chart, int type, int percent) { super(source); this.chart = chart; this.type = type; } /** * Returns the chart that generated the change event. * * @return The chart that generated the change event. */ public JFreeChart getChart() { return this.chart; } /** * Sets the chart that generated the change event. * * @param chart the chart that generated the event. */ public void setChart(JFreeChart chart) { this.chart = chart; } /** * Returns the event type. * * @return The event type. */ public int getType() { return this.type; } /** * Sets the event type. * * @param type the event type. */ public void setType(int type) { this.type = type; } /** * Returns the percentage complete. * * @return The percentage complete. */ public int getPercent() { return this.percent; } /** * Sets the percentage complete. * * @param percent the percentage. */ public void setPercent(int percent) { this.percent = percent; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/ChartProgressListener.java0000644000175000017500000000375111173030414030717 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * ChartProgressListener.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 14-Jan-2003 : Version 1 (DG); * */ package org.jfree.chart.event; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of chart progress events. */ public interface ChartProgressListener extends EventListener { /** * Receives notification of a chart progress event. * * @param event the event. */ public void chartProgress(ChartProgressEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/MarkerChangeEvent.java0000644000175000017500000000467011173030414027755 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * MarkerChangeEvent.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Sep-2006 : Version 1 (DG); * */ package org.jfree.chart.event; import org.jfree.chart.plot.Marker; /** * An event that can be forwarded to any {@link MarkerChangeListener} to * signal a change to a {@link Marker}. * * @since 1.0.3 */ public class MarkerChangeEvent extends ChartChangeEvent { /** The plot that generated the event. */ private Marker marker; /** * Creates a new MarkerChangeEvent instance. * * @param marker the marker that triggered the event (null * not permitted). * * @since 1.0.3 */ public MarkerChangeEvent(Marker marker) { super(marker); this.marker = marker; } /** * Returns the marker that triggered the event. * * @return The marker that triggered the event (never null). * * @since 1.0.3 */ public Marker getMarker() { return this.marker; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/MarkerChangeListener.java0000644000175000017500000000403411173030414030453 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * MarkerChangeListener.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Sep-2006 : Version 1 (DG); * */ package org.jfree.chart.event; import java.util.EventListener; import org.jfree.chart.plot.Marker; /** * The interface that must be supported by classes that wish to receive * notification of changes to a {@link Marker}. * * @since 1.0.3 */ public interface MarkerChangeListener extends EventListener { /** * Receives notification of a marker change event. * * @param event the event. * * @since 1.0.3 */ public void markerChanged(MarkerChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/OverlayChangeEvent.java0000644000175000017500000000365411173030414030156 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * OverlayChangeEvent.java * ----------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 09-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.event; import java.util.EventObject; import org.jfree.chart.panel.Overlay; /** * A change event for an {@link Overlay}. * * @since 1.0.13 */ public class OverlayChangeEvent extends EventObject { /** * Creates a new change event. * * @param source the event source. */ public OverlayChangeEvent(Object source) { super(source); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/OverlayChangeListener.java0000644000175000017500000000371111173030414030654 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * OverlayChangeListener.java * -------------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 09-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.event; import java.util.EventListener; import org.jfree.chart.panel.Overlay; /** * A listener for changes to an {@link Overlay}. * * @since 1.0.13 */ public interface OverlayChangeListener extends EventListener { /** * This method is called to notify a listener of a change event. * * @param event the event. */ public void overlayChanged(OverlayChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/PlotChangeEvent.java0000644000175000017500000000475011173030414027451 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PlotChangeEvent.java * -------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 17-Jan-2003 : Moved plot classes to a separate package (DG); * */ package org.jfree.chart.event; import org.jfree.chart.plot.Plot; /** * An event that can be forwarded to any * {@link org.jfree.chart.event.PlotChangeListener} to signal a change to a * plot. */ public class PlotChangeEvent extends ChartChangeEvent { /** The plot that generated the event. */ private Plot plot; /** * Creates a new PlotChangeEvent. * * @param plot the plot that generated the event. */ public PlotChangeEvent(Plot plot) { super(plot); this.plot = plot; } /** * Returns the plot that generated the event. * * @return The plot that generated the event. */ public Plot getPlot() { return this.plot; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/PlotChangeListener.java0000644000175000017500000000423111173030414030147 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * PlotChangeListener.java * ----------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 14-Oct-2002 : Now extends EventListener (DG); * */ package org.jfree.chart.event; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of changes to a plot. * */ public interface PlotChangeListener extends EventListener { /** * Receives notification of a plot change event. * * @param event the event. */ public void plotChanged(PlotChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/RendererChangeEvent.java0000644000175000017500000000674211173030414030304 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * RendererChangeEvent.java * ------------------------ * (C) Copyright 2003-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Oct-2003 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 04-Apr-2007 : Fixed typo in API docs (DG); * 26-Mar-2009 : Added flag to signal visible series change (DG); * */ package org.jfree.chart.event; /** * An event that can be forwarded to any {@link RendererChangeListener} to * signal a change to a renderer. */ public class RendererChangeEvent extends ChartChangeEvent { /** The renderer that generated the event. */ private Object renderer; /** * A flag that indicates whether this event relates to a change in the * series visibility. If so, the receiver (if it is a plot) may want to * update the axis bounds. * * @since 1.0.13 */ private boolean seriesVisibilityChanged; /** * Creates a new event. * * @param renderer the renderer that generated the event. */ public RendererChangeEvent(Object renderer) { this(renderer, false); } /** * Creates a new event. * * @param renderer the renderer that generated the event. * @param seriesVisibilityChanged a flag that indicates whether or not * the event relates to a change in the series visibility flags. */ public RendererChangeEvent(Object renderer, boolean seriesVisibilityChanged) { super(renderer); this.renderer = renderer; this.seriesVisibilityChanged = seriesVisibilityChanged; } /** * Returns the renderer that generated the event. * * @return The renderer that generated the event. */ public Object getRenderer() { return this.renderer; } /** * Returns the flag that indicates whether or not the event relates to * a change in series visibility. * * @return A boolean. * * @since 1.0.13 */ public boolean getSeriesVisibilityChanged() { return this.seriesVisibilityChanged; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/RendererChangeListener.java0000644000175000017500000000377611173030414031014 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * RendererChangeListener.java * --------------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Oct-2003 : Added standard source header. Fixed DOS encoding problem (DG); * */ package org.jfree.chart.event; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of changes to a renderer. * */ public interface RendererChangeListener extends EventListener { /** * Receives notification of a renderer change event. * * @param event the event. */ public void rendererChanged(RendererChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/TitleChangeEvent.java0000644000175000017500000000506611173030414027615 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * TitleChangeEvent.java * --------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 22-Jun-2001) * -------------------------- * 22-Jun-2001 : Changed Title to AbstractTitle while incorporating * David Berry's changes (DG); * 24-Aug-2001 : Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Jan-2004 : Renamed AbstractTitle --> Title and moved to new package (DG); * */ package org.jfree.chart.event; import org.jfree.chart.title.Title; /** * A change event that encapsulates information about a change to a chart title. */ public class TitleChangeEvent extends ChartChangeEvent { /** The chart title that generated the event. */ private Title title; /** * Default constructor. * * @param title the chart title that generated the event. */ public TitleChangeEvent(Title title) { super(title); this.title = title; } /** * Returns the title that generated the event. * * @return The title that generated the event. */ public Title getTitle() { return this.title; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/TitleChangeListener.java0000644000175000017500000000425511173030414030320 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * TitleChangeListener.java * ------------------------ * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Updated header (DG); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 14-Oct-2002 : Now extends EventListener (DG); * */ package org.jfree.chart.event; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of changes to a chart title. * */ public interface TitleChangeListener extends EventListener { /** * Receives notification of a chart title change event. * * @param event the event. */ public void titleChanged(TitleChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/event/package.html0000644000175000017500000000044011173030414026031 0ustar vincentvincent Event classes and listener interfaces, used to provide a change notification mechanism so that charts are automatically redrawn whenever changes are made to any chart component. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/0000755000175000017500000000000011216245561024222 5ustar vincentvincent././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerat0000644000175000017500000000644211173030414033461 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------------- * DynamicDriveToolTipTagFragmentGenerator.java * -------------------------------------------- * (C) Copyright 2003-2009, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * Fawad Halim - bug 2690293; * * Changes * ------- * 12-Aug-2003 : Version 1 (RA); * 04-Dec-2007 : Escape tool tip text to fix bug 1400917 (DG); * 19-Mar-2009 : Escape apostrophes - see bug 2690293 with fix by FH (DG); * */ package org.jfree.chart.imagemap; /** * Generates tooltips using the Dynamic Drive DHTML Tip Message * library (http://www.dynamicdrive.com). */ public class DynamicDriveToolTipTagFragmentGenerator implements ToolTipTagFragmentGenerator { /** The title, empty string not to display */ protected String title = ""; /** The style number */ protected int style = 1; /** * Blank constructor. */ public DynamicDriveToolTipTagFragmentGenerator() { super(); } /** * Creates a new generator with specific title and style settings. * * @param title title for use in all tooltips, use empty String not to * display a title. * @param style style number, see http://www.dynamicdrive.com for more * information. */ public DynamicDriveToolTipTagFragmentGenerator(String title, int style) { this.title = title; this.style = style; } /** * Generates a tooltip string to go in an HTML image map. * * @param toolTipText the tooltip. * * @return The formatted HTML area tag attribute(s). */ public String generateToolTipFragment(String toolTipText) { return " onMouseOver=\"return stm(['" + ImageMapUtilities.javascriptEscape(this.title) + "','" + ImageMapUtilities.javascriptEscape(toolTipText) + "'],Style[" + this.style + "]);\"" + " onMouseOut=\"return htm();\""; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/ImageMapUtilities.java0000644000175000017500000002477011173030414030442 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * ImageMapUtilities.java * ---------------------- * (C) Copyright 2004-2009, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * Fawad Halim - bug 2690293; * * Changes * ------- * 02-Aug-2004 : Initial version (RA); * 13-Jan-2005 : Renamed ImageMapUtilities (DG); * 19-Jan-2005 : Reversed order of tags for chart entities to get correct * layering (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Feb-2006 : API doc updates (DG); * 04-Dec-2007 : Added htmlEscape() method, and escape 'name' in * getImageMap() (DG); * 19-Mar-2009 : Added javascriptEscape() method - see bug 2690293 by FH (DG); * 25-Mar-2009 : Reimplemented javascriptEscape() (DG); * */ package org.jfree.chart.imagemap; import java.io.IOException; import java.io.PrintWriter; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.util.StringUtils; /** * Collection of utility methods related to producing image maps. * Functionality was originally in {@link org.jfree.chart.ChartUtilities}. */ public class ImageMapUtilities { /** * Writes an image map to an output stream. * * @param writer the writer (null not permitted). * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * * @throws java.io.IOException if there are any I/O errors. */ public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info) throws IOException { // defer argument checking... ImageMapUtilities.writeImageMap(writer, name, info, new StandardToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator()); } /** * Writes an image map to an output stream. * * @param writer the writer (null not permitted). * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * @param useOverLibForToolTips whether to use OverLIB for tooltips * (http://www.bosrup.com/web/overlib/). * * @throws java.io.IOException if there are any I/O errors. */ public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info, boolean useOverLibForToolTips) throws IOException { ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null; if (useOverLibForToolTips) { toolTipTagFragmentGenerator = new OverLIBToolTipTagFragmentGenerator(); } else { toolTipTagFragmentGenerator = new StandardToolTipTagFragmentGenerator(); } ImageMapUtilities.writeImageMap(writer, name, info, toolTipTagFragmentGenerator, new StandardURLTagFragmentGenerator()); } /** * Writes an image map to an output stream. * * @param writer the writer (null not permitted). * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (null not permitted * if info contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (null not permitted if * info contains URLs). * * @throws java.io.IOException if there are any I/O errors. */ public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) throws IOException { writer.println(ImageMapUtilities.getImageMap(name, info, toolTipTagFragmentGenerator, urlTagFragmentGenerator)); } /** * Creates an image map element that complies with the XHTML 1.0 * specification. * * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * * @return The map element. */ public static String getImageMap(String name, ChartRenderingInfo info) { return ImageMapUtilities.getImageMap(name, info, new StandardToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator()); } /** * Creates an image map element that complies with the XHTML 1.0 * specification. * * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (null not permitted * if info contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (null not permitted if * info contains URLs). * * @return The map tag. */ public static String getImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(StringUtils.getLineSeparator()); EntityCollection entities = info.getEntityCollection(); if (entities != null) { int count = entities.getEntityCount(); for (int i = count - 1; i >= 0; i--) { ChartEntity entity = entities.getEntity(i); if (entity.getToolTipText() != null || entity.getURLText() != null) { String area = entity.getImageMapAreaTag( toolTipTagFragmentGenerator, urlTagFragmentGenerator); if (area.length() > 0) { sb.append(area); sb.append(StringUtils.getLineSeparator()); } } } } sb.append(""); return sb.toString(); } /** * Returns a string that is equivalent to the input string, but with * special characters converted to HTML escape sequences. * * @param input the string to escape (null not permitted). * * @return A string with characters escaped. * * @since 1.0.9 */ public static String htmlEscape(String input) { if (input == null) { throw new IllegalArgumentException("Null 'input' argument."); } StringBuffer result = new StringBuffer(); int length = input.length(); for (int i = 0; i < length; i++) { char c = input.charAt(i); if (c == '&') { result.append("&"); } else if (c == '\"') { result.append("""); } else if (c == '<') { result.append("<"); } else if (c == '>') { result.append(">"); } else if (c == '\'') { result.append("'"); } else if (c == '\\') { result.append("\"); } else { result.append(c); } } return result.toString(); } /** * Returns a string that is equivalent to the input string, but with * special characters converted to JavaScript escape sequences. * * @param input the string to escape (null not permitted). * * @return A string with characters escaped. * * @since 1.0.13 */ public static String javascriptEscape(String input) { if (input == null) { throw new IllegalArgumentException("Null 'input' argument."); } StringBuffer result = new StringBuffer(); int length = input.length(); for (int i = 0; i < length; i++) { char c = input.charAt(i); if (c == '\"') { result.append("\\\""); } else if (c == '\'') { result.append("\\'"); } else if (c == '\\') { result.append("\\\\"); } else { result.append(c); } } return result.toString(); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.ja0000644000175000017500000000507211173030414033275 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------- * OverLibToolTipTagFragmentGenerator.java * --------------------------------------- * (C) Copyright 2003-2009, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * Fawad Halim - bug 2690293; * * Changes * ------- * 12-Aug-2003 : Version 1 (RA); * 04-Dec-2007 : Escape tool tip text to fix bug 1400917 (DG); * 19-Mar-2009 : Escape apostrophes - see bug 2690293 with fix by FH (DG); * */ package org.jfree.chart.imagemap; /** * Generates tooltips using the OverLIB library * (http://www.bosrup.com/web/overlib/). */ public class OverLIBToolTipTagFragmentGenerator implements ToolTipTagFragmentGenerator { /** * Creates a new instance. */ public OverLIBToolTipTagFragmentGenerator() { super(); } /** * Generates a tooltip string to go in an HTML image map. * * @param toolTipText the tooltip text. * * @return The formatted HTML area tag attribute(s). */ public String generateToolTipFragment(String toolTipText) { return " onMouseOver=\"return overlib('" + ImageMapUtilities.javascriptEscape(toolTipText) + "');\" onMouseOut=\"return nd();\""; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.j0000644000175000017500000000455211173030414033434 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------- * StandardToolTipTagFragmentGenerator.java * ---------------------------------------- * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes * ------- * 12-Aug-2003 : Version 1 (RA); * 04-Dec-2007 : Escape tool tip text to fix bug 1400917 (DG); * */ package org.jfree.chart.imagemap; /** * Generates tooltips using the HTML title attribute for image map area tags. */ public class StandardToolTipTagFragmentGenerator implements ToolTipTagFragmentGenerator { /** * Creates a new instance. */ public StandardToolTipTagFragmentGenerator() { super(); } /** * Generates a tooltip string to go in an HTML image map. * * @param toolTipText the tooltip. * * @return The formatted HTML area tag attribute(s). */ public String generateToolTipFragment(String toolTipText) { return " title=\"" + ImageMapUtilities.htmlEscape(toolTipText) + "\" alt=\"\""; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java0000644000175000017500000000457711173030414033203 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * StandardURLTagFragmentGenerator.java * ------------------------------------ * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes * ------- * 12-Aug-2003 : Version 1 (RA); * 04-Dec-2007 : Encode URL text to fix bug 1400917 (DG); * 13-Dec-2007 : Revert change from 04-Dec-2007 (DG); * */ package org.jfree.chart.imagemap; /** * Generates URLs using the HTML href attribute for image map area tags. */ public class StandardURLTagFragmentGenerator implements URLTagFragmentGenerator { /** * Creates a new instance. */ public StandardURLTagFragmentGenerator() { super(); } /** * Generates a URL string to go in an HTML image map. * * @param urlText the URL text (fully escaped). * * @return The formatted text */ public String generateURLFragment(String urlText) { // the URL text should already have been escaped by the URL generator return " href=\"" + urlText + "\""; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.java0000644000175000017500000000470611173030414032444 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * ToolTipTagFragmentGenerator.java * -------------------------------- * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * * Changes * ------- * 12-Aug-2003 : Version 1 (RA); * 05-Dec-2007 : Updated API docs (DG); * */ package org.jfree.chart.imagemap; /** * Interface for generating the tooltip fragment of an HTML image map area tag. * The fragment should be XHTML 1.0 compliant. */ public interface ToolTipTagFragmentGenerator { /** * Generates a tooltip string to go in an HTML image map. To allow for * varying standards compliance among browsers, this method is expected * to return an 'alt' attribute IN ADDITION TO whatever it does to create * the tooltip (often a 'title' attribute). *

* Note that the toolTipText may have been generated from * user-defined data, so care should be taken to filter/escape any * characters that may corrupt the HTML tag. * * @param toolTipText the tooltip. * * @return The formatted HTML area tag attribute(s). */ public String generateToolTipFragment(String toolTipText); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/URLTagFragmentGenerator.java0000644000175000017500000000470311173030414031511 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * URLTagFragmentGenerator.java * ---------------------------- * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * * Changes * ------- * 12-Aug-2003 : Version 1 (RA); * 13-Dec-2007 : Updated API docs (DG); * */ package org.jfree.chart.imagemap; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.PieURLGenerator; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.chart.urls.XYZURLGenerator; /** * Interface for generating the URL fragment of an HTML image map area tag. */ public interface URLTagFragmentGenerator { /** * Generates a URL string to go in an HTML image map. *

* Note that the urlText will be created by a URL generator * (such as {@link CategoryURLGenerator}, {@link PieURLGenerator}, * {@link XYURLGenerator} or {@link XYZURLGenerator}) and that generator is * responsible for ensuring that the URL text is correctly escaped. * * @param urlText the URL text (fully escaped). * * @return The formatted HTML area tag attribute(s). */ public String generateURLFragment(String urlText); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/imagemap/package.html0000644000175000017500000000032111173030414026466 0ustar vincentvincent Classes, including {@link org.jfree.chart.imagemap.ImageMapUtilities}, for creating HTML image maps. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/0000755000175000017500000000000011216245561023704 5ustar vincentvincent././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java0000644000175000017500000002677011173030414033441 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------- * AbstractCategoryItemLabelGenerator.java * --------------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1, distilled from StandardCategoryLabelGenerator (DG); * 31-Jan-2005 : Added methods to return row and column labels (DG); * 17-May-2005 : Added percentage to item array (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Added new constructor (DG); * 23-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.MessageFormat; import java.text.NumberFormat; import org.jfree.chart.HashUtilities; import org.jfree.data.DataUtilities; import org.jfree.data.category.CategoryDataset; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A base class that can be used to create a label or tooltip generator that * can be assigned to a * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. */ public abstract class AbstractCategoryItemLabelGenerator implements PublicCloneable, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7108591260223293197L; /** * The label format string used by a MessageFormat object to * combine the standard items: {0} = series name, {1} = category, * {2} = value, {3} = value as a percentage of the column total. */ private String labelFormat; /** The string used to represent a null value. */ private String nullValueString; /** * A number formatter used to preformat the value before it is passed to * the MessageFormat object. */ private NumberFormat numberFormat; /** * A date formatter used to preformat the value before it is passed to the * MessageFormat object. */ private DateFormat dateFormat; /** * A number formatter used to preformat the percentage value before it is * passed to the MessageFormat object. */ private NumberFormat percentFormat; /** * Creates a label generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). */ protected AbstractCategoryItemLabelGenerator(String labelFormat, NumberFormat formatter) { this(labelFormat, formatter, NumberFormat.getPercentInstance()); } /** * Creates a label generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). * @param percentFormatter the percent formatter (null not * permitted). * * @since 1.0.2 */ protected AbstractCategoryItemLabelGenerator(String labelFormat, NumberFormat formatter, NumberFormat percentFormatter) { if (labelFormat == null) { throw new IllegalArgumentException("Null 'labelFormat' argument."); } if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } if (percentFormatter == null) { throw new IllegalArgumentException( "Null 'percentFormatter' argument."); } this.labelFormat = labelFormat; this.numberFormat = formatter; this.percentFormat = percentFormatter; this.dateFormat = null; this.nullValueString = "-"; } /** * Creates a label generator with the specified date formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the date formatter (null not permitted). */ protected AbstractCategoryItemLabelGenerator(String labelFormat, DateFormat formatter) { if (labelFormat == null) { throw new IllegalArgumentException("Null 'labelFormat' argument."); } if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.labelFormat = labelFormat; this.numberFormat = null; this.percentFormat = NumberFormat.getPercentInstance(); this.dateFormat = formatter; this.nullValueString = "-"; } /** * Generates a label for the specified row. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * * @return The label. */ public String generateRowLabel(CategoryDataset dataset, int row) { return dataset.getRowKey(row).toString(); } /** * Generates a label for the specified row. * * @param dataset the dataset (null not permitted). * @param column the column index (zero-based). * * @return The label. */ public String generateColumnLabel(CategoryDataset dataset, int column) { return dataset.getColumnKey(column).toString(); } /** * Returns the label format string. * * @return The label format string (never null). */ public String getLabelFormat() { return this.labelFormat; } /** * Returns the number formatter. * * @return The number formatter (possibly null). */ public NumberFormat getNumberFormat() { return this.numberFormat; } /** * Returns the date formatter. * * @return The date formatter (possibly null). */ public DateFormat getDateFormat() { return this.dateFormat; } /** * Generates a for the specified item. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The label (possibly null). */ protected String generateLabelString(CategoryDataset dataset, int row, int column) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } String result = null; Object[] items = createItemArray(dataset, row, column); result = MessageFormat.format(this.labelFormat, items); return result; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The items (never null). */ protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[4]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (value != null) { if (this.numberFormat != null) { result[2] = this.numberFormat.format(value); } else if (this.dateFormat != null) { result[2] = this.dateFormat.format(value); } } else { result[2] = this.nullValueString; } if (value != null) { double total = DataUtilities.calculateColumnTotal(dataset, column); double percent = value.doubleValue() / total; result[3] = this.percentFormat.format(percent); } return result; } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractCategoryItemLabelGenerator)) { return false; } AbstractCategoryItemLabelGenerator that = (AbstractCategoryItemLabelGenerator) obj; if (!this.labelFormat.equals(that.labelFormat)) { return false; } if (!ObjectUtilities.equal(this.dateFormat, that.dateFormat)) { return false; } if (!ObjectUtilities.equal(this.numberFormat, that.numberFormat)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.labelFormat); result = HashUtilities.hashCode(result, this.nullValueString); result = HashUtilities.hashCode(result, this.dateFormat); result = HashUtilities.hashCode(result, this.numberFormat); result = HashUtilities.hashCode(result, this.percentFormat); return result; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { AbstractCategoryItemLabelGenerator clone = (AbstractCategoryItemLabelGenerator) super.clone(); if (this.numberFormat != null) { clone.numberFormat = (NumberFormat) this.numberFormat.clone(); } if (this.dateFormat != null) { clone.dateFormat = (DateFormat) this.dateFormat.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/AbstractPieItemLabelGenerator.java0000644000175000017500000002042411173030414032367 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * AbstractPieItemLabelGenerator.java * ---------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Nov-2004 : Version 1, draws out code from StandardPieItemLabelGenerator * and StandardPieToolTipGenerator (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Fixed bug 1480978, a problem in the clone() method (DG); * 23-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.MessageFormat; import java.text.NumberFormat; import org.jfree.chart.HashUtilities; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.PieDataset; /** * A base class used for generating pie chart item labels. */ public class AbstractPieItemLabelGenerator implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7347703325267846275L; /** The label format string. */ private String labelFormat; /** A number formatter for the value. */ private NumberFormat numberFormat; /** A number formatter for the percentage. */ private NumberFormat percentFormat; /** * Creates an item label generator using the specified number formatters. * * @param labelFormat the label format string (null not * permitted). * @param numberFormat the format object for the values (null * not permitted). * @param percentFormat the format object for the percentages * (null not permitted). */ protected AbstractPieItemLabelGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat) { if (labelFormat == null) { throw new IllegalArgumentException("Null 'labelFormat' argument."); } if (numberFormat == null) { throw new IllegalArgumentException("Null 'numberFormat' argument."); } if (percentFormat == null) { throw new IllegalArgumentException( "Null 'percentFormat' argument."); } this.labelFormat = labelFormat; this.numberFormat = numberFormat; this.percentFormat = percentFormat; } /** * Returns the label format string. * * @return The label format string (never null). */ public String getLabelFormat() { return this.labelFormat; } /** * Returns the number formatter. * * @return The formatter (never null). */ public NumberFormat getNumberFormat() { return this.numberFormat; } /** * Returns the percent formatter. * * @return The formatter (never null). */ public NumberFormat getPercentFormat() { return this.percentFormat; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. The returned array * contains four values: *

    *
  • result[0] = the section key converted to a String;
  • *
  • result[1] = the formatted data value;
  • *
  • result[2] = the formatted percentage (of the total);
  • *
  • result[3] = the formatted total value.
  • *
* * @param dataset the dataset (null not permitted). * @param key the key (null not permitted). * * @return The items (never null). */ protected Object[] createItemArray(PieDataset dataset, Comparable key) { Object[] result = new Object[4]; double total = DatasetUtilities.calculatePieDatasetTotal(dataset); result[0] = key.toString(); Number value = dataset.getValue(key); if (value != null) { result[1] = this.numberFormat.format(value); } else { result[1] = "null"; } double percent = 0.0; if (value != null) { double v = value.doubleValue(); if (v > 0.0) { percent = v / total; } } result[2] = this.percentFormat.format(percent); result[3] = this.numberFormat.format(total); return result; } /** * Generates a label for a pie section. * * @param dataset the dataset (null not permitted). * @param key the section key (null not permitted). * * @return The label (possibly null). */ protected String generateSectionLabel(PieDataset dataset, Comparable key) { String result = null; if (dataset != null) { Object[] items = createItemArray(dataset, key); result = MessageFormat.format(this.labelFormat, items); } return result; } /** * Tests the generator for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractPieItemLabelGenerator)) { return false; } AbstractPieItemLabelGenerator that = (AbstractPieItemLabelGenerator) obj; if (!this.labelFormat.equals(that.labelFormat)) { return false; } if (!this.numberFormat.equals(that.numberFormat)) { return false; } if (!this.percentFormat.equals(that.percentFormat)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.labelFormat); result = HashUtilities.hashCode(result, this.numberFormat); result = HashUtilities.hashCode(result, this.percentFormat); return result; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { AbstractPieItemLabelGenerator clone = (AbstractPieItemLabelGenerator) super.clone(); if (this.numberFormat != null) { clone.numberFormat = (NumberFormat) this.numberFormat.clone(); } if (this.percentFormat != null) { clone.percentFormat = (NumberFormat) this.percentFormat.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java0000644000175000017500000003167011173030414032217 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * AbstractXYItemLabelGenerator.java * --------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Feb-2004 : Version 1 (DG); * 12-May-2004 : Moved default tool tip format to * StandardXYToolTipGenerator (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 08-Oct-2004 : Modified createItemArray() method to handle null values (DG); * 10-Jan-2005 : Updated createItemArray() to use x, y primitives if * possible (DG); * ------------- JFREECHART 1.0.x -------------------------------------------- * 26-Jan-2006 : Minor API doc update (DG); * 25-Jan-2007 : Added new constructor and fixed bug in clone() method (DG); * 16-Oct-2007 : Removed redundant code (DG); * 23-Nov-2007 : Implemented hashCode() (DG); * 26-May-2008 : Added accessor methods for nullYString and updated equals() * method (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.MessageFormat; import java.text.NumberFormat; import java.util.Date; import org.jfree.chart.HashUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.util.ObjectUtilities; /** * A base class for creating item label generators. */ public class AbstractXYItemLabelGenerator implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5869744396278660636L; /** The item label format string. */ private String formatString; /** A number formatter for the x value. */ private NumberFormat xFormat; /** A date formatter for the x value. */ private DateFormat xDateFormat; /** A formatter for the y value. */ private NumberFormat yFormat; /** A date formatter for the y value. */ private DateFormat yDateFormat; /** The string used to represent 'null' for the y-value. */ private String nullYString = "null"; /** * Creates an item label generator using default number formatters. */ protected AbstractXYItemLabelGenerator() { this("{2}", NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()); } /** * Creates an item label generator using the specified number formatters. * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ protected AbstractXYItemLabelGenerator(String formatString, NumberFormat xFormat, NumberFormat yFormat) { if (formatString == null) { throw new IllegalArgumentException("Null 'formatString' argument."); } if (xFormat == null) { throw new IllegalArgumentException("Null 'xFormat' argument."); } if (yFormat == null) { throw new IllegalArgumentException("Null 'yFormat' argument."); } this.formatString = formatString; this.xFormat = xFormat; this.yFormat = yFormat; } /** * Creates an item label generator using the specified number formatters. * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * permitted). * @param yFormat the format object for the y values (null * not permitted). */ protected AbstractXYItemLabelGenerator(String formatString, DateFormat xFormat, NumberFormat yFormat) { this(formatString, NumberFormat.getInstance(), yFormat); this.xDateFormat = xFormat; } /** * Creates an item label generator using the specified formatters (a * number formatter for the x-values and a date formatter for the * y-values). * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * permitted). * @param yFormat the format object for the y values (null * not permitted). * * @since 1.0.4 */ protected AbstractXYItemLabelGenerator(String formatString, NumberFormat xFormat, DateFormat yFormat) { this(formatString, xFormat, NumberFormat.getInstance()); this.yDateFormat = yFormat; } /** * Creates an item label generator using the specified number formatters. * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * permitted). * @param yFormat the format object for the y values (null * not permitted). */ protected AbstractXYItemLabelGenerator(String formatString, DateFormat xFormat, DateFormat yFormat) { this(formatString, NumberFormat.getInstance(), NumberFormat.getInstance()); this.xDateFormat = xFormat; this.yDateFormat = yFormat; } /** * Returns the format string (this controls the overall structure of the * label). * * @return The format string (never null). */ public String getFormatString() { return this.formatString; } /** * Returns the number formatter for the x-values. * * @return The number formatter (possibly null). */ public NumberFormat getXFormat() { return this.xFormat; } /** * Returns the date formatter for the x-values. * * @return The date formatter (possibly null). */ public DateFormat getXDateFormat() { return this.xDateFormat; } /** * Returns the number formatter for the y-values. * * @return The number formatter (possibly null). */ public NumberFormat getYFormat() { return this.yFormat; } /** * Returns the date formatter for the y-values. * * @return The date formatter (possibly null). */ public DateFormat getYDateFormat() { return this.yDateFormat; } /** * Generates a label string for an item in the dataset. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The label (possibly null). */ public String generateLabelString(XYDataset dataset, int series, int item) { String result = null; Object[] items = createItemArray(dataset, series, item); result = MessageFormat.format(this.formatString, items); return result; } /** * Returns the string representing a null value. * * @return The string representing a null value. * * @since 1.0.10 */ public String getNullYString() { return this.nullYString; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return An array of three items from the dataset formatted as * String objects (never null). */ protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[3]; result[0] = dataset.getSeriesKey(series).toString(); double x = dataset.getXValue(series, item); if (this.xDateFormat != null) { result[1] = this.xDateFormat.format(new Date((long) x)); } else { result[1] = this.xFormat.format(x); } double y = dataset.getYValue(series, item); if (Double.isNaN(y) && dataset.getY(series, item) == null) { result[2] = this.nullYString; } else { if (this.yDateFormat != null) { result[2] = this.yDateFormat.format(new Date((long) y)); } else { result[2] = this.yFormat.format(y); } } return result; } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractXYItemLabelGenerator)) { return false; } AbstractXYItemLabelGenerator that = (AbstractXYItemLabelGenerator) obj; if (!this.formatString.equals(that.formatString)) { return false; } if (!ObjectUtilities.equal(this.xFormat, that.xFormat)) { return false; } if (!ObjectUtilities.equal(this.xDateFormat, that.xDateFormat)) { return false; } if (!ObjectUtilities.equal(this.yFormat, that.yFormat)) { return false; } if (!ObjectUtilities.equal(this.yDateFormat, that.yDateFormat)) { return false; } if (!this.nullYString.equals(that.nullYString)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.formatString); result = HashUtilities.hashCode(result, this.xFormat); result = HashUtilities.hashCode(result, this.xDateFormat); result = HashUtilities.hashCode(result, this.yFormat); result = HashUtilities.hashCode(result, this.yDateFormat); return result; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { AbstractXYItemLabelGenerator clone = (AbstractXYItemLabelGenerator) super.clone(); if (this.xFormat != null) { clone.xFormat = (NumberFormat) this.xFormat.clone(); } if (this.yFormat != null) { clone.yFormat = (NumberFormat) this.yFormat.clone(); } if (this.xDateFormat != null) { clone.xDateFormat = (DateFormat) this.xDateFormat.clone(); } if (this.yDateFormat != null) { clone.yDateFormat = (DateFormat) this.yDateFormat.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/BoxAndWhiskerToolTipGenerator.java0000644000175000017500000001243711173030414032437 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * BoxAndWhiskerToolTipGenerator.java * ------------------------------------ * (C) Copyright 2004-2008, by David Browning and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Jun-2004 : Version 1 (DG); * 23-Mar-2005 : Implemented PublicCloneable (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.MessageFormat; import java.text.NumberFormat; import org.jfree.data.category.CategoryDataset; import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; import org.jfree.util.PublicCloneable; /** * An item label generator for plots that use data from a * {@link BoxAndWhiskerCategoryDataset}. *

* The tooltip text and item label text are composed using a * {@link java.text.MessageFormat} object, that can aggregate some or all of * the following string values into a message. * * * * * * * * * *
0Series Name
1X (value or date)
2Mean
3Median
4Minimum
5Maximum
6Quartile 1
7Quartile 3
*/ public class BoxAndWhiskerToolTipGenerator extends StandardCategoryToolTipGenerator implements CategoryToolTipGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6076837753823076334L; /** The default tooltip format string. */ public static final String DEFAULT_TOOL_TIP_FORMAT = "X: {1} Mean: {2} Median: {3} Min: {4} Max: {5} Q1: {6} Q3: {7} "; /** * Creates a default tool tip generator. */ public BoxAndWhiskerToolTipGenerator() { super(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getInstance()); } /** * Creates a tool tip formatter. * * @param format the tool tip format string. * @param formatter the formatter. */ public BoxAndWhiskerToolTipGenerator(String format, NumberFormat formatter) { super(format, formatter); } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(CategoryDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getRowKey(series); Number y = dataset.getValue(series, item); NumberFormat formatter = getNumberFormat(); result[1] = formatter.format(y); if (dataset instanceof BoxAndWhiskerCategoryDataset) { BoxAndWhiskerCategoryDataset d = (BoxAndWhiskerCategoryDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof BoxAndWhiskerToolTipGenerator) { return super.equals(obj); } return false; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGenerator.java0000644000175000017500000001451511173030414032717 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * BoxAndWhiskerXYToolTipGenerator.java * ------------------------------------ * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 28-Aug-2003 : Updated for changes in dataset API (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 27-Feb-2004 : Renamed BoxAndWhiskerItemLabelGenerator --> * BoxAndWhiskerXYItemLabelGenerator, and modified to use * MessageFormat (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.MessageFormat; import java.text.NumberFormat; import java.util.Date; import org.jfree.data.statistics.BoxAndWhiskerXYDataset; import org.jfree.data.xy.XYDataset; /** * An item label generator for plots that use data from a * {@link BoxAndWhiskerXYDataset}. *

* The tooltip text and item label text are composed using a * {@link java.text.MessageFormat} object, that can aggregate some or all of * the following string values into a message. * * * * * * * * * *
0Series Name
1X (value or date)
2Mean
3Median
4Minimum
5Maximum
6Quartile 1
7Quartile 3
*/ public class BoxAndWhiskerXYToolTipGenerator extends StandardXYToolTipGenerator implements XYToolTipGenerator, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2648775791161459710L; /** The default tooltip format string. */ public static final String DEFAULT_TOOL_TIP_FORMAT = "X: {1} Mean: {2} Median: {3} Min: {4} Max: {5} Q1: {6} Q3: {7} "; /** * Creates a default item label generator. */ public BoxAndWhiskerXYToolTipGenerator() { super(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getInstance(), NumberFormat.getInstance()); } /** * Creates a new item label generator. If the date formatter is not * null, the x-values will be formatted as dates. * * @param toolTipFormat the tool tip format string (null not * permitted). * @param numberFormat the number formatter (null not * permitted). * @param dateFormat the date formatter (null permitted). */ public BoxAndWhiskerXYToolTipGenerator(String toolTipFormat, DateFormat dateFormat, NumberFormat numberFormat) { super(toolTipFormat, dateFormat, numberFormat); } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(XYDataset dataset, int series, int item) { Object[] result = new Object[8]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); if (getXDateFormat() != null) { result[1] = getXDateFormat().format(new Date(x.longValue())); } else { result[1] = getXFormat().format(x); } NumberFormat formatter = getYFormat(); if (dataset instanceof BoxAndWhiskerXYDataset) { BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; result[2] = formatter.format(d.getMeanValue(series, item)); result[3] = formatter.format(d.getMedianValue(series, item)); result[4] = formatter.format(d.getMinRegularValue(series, item)); result[5] = formatter.format(d.getMaxRegularValue(series, item)); result[6] = formatter.format(d.getQ1Value(series, item)); result[7] = formatter.format(d.getQ3Value(series, item)); } return result; } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BoxAndWhiskerXYToolTipGenerator)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java0000644000175000017500000002224511173030414031645 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * BubbleXYItemLabelGenerator.java * ------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Dec-2005 : Version 1, based on StandardXYZToolTipGenerator (DG); * 26-Jan-2006 : Renamed StandardXYZItemLabelGenerator * --> BubbleXYItemLabelGenerator (DG); * 23-Nov-2007 : Implemented hashCode() (DG); * 23-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.MessageFormat; import java.text.NumberFormat; import org.jfree.chart.HashUtilities; import org.jfree.chart.renderer.xy.XYBubbleRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An item label generator defined for use with the {@link XYBubbleRenderer} * class, or any other class that uses an {@link XYZDataset}. * * @since 1.0.1 */ public class BubbleXYItemLabelGenerator extends AbstractXYItemLabelGenerator implements XYItemLabelGenerator, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -8458568928021240922L; /** The default item label format. */ public static final String DEFAULT_FORMAT_STRING = "{3}"; /** * A number formatter for the z value - if this is null, then * zDateFormat must be non-null. */ private NumberFormat zFormat; /** * A date formatter for the z-value - if this is null, then zFormat must be * non-null. */ private DateFormat zDateFormat; /** * Creates a new tool tip generator using default number formatters for the * x, y and z-values. */ public BubbleXYItemLabelGenerator() { this(DEFAULT_FORMAT_STRING, NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()); } /** * Constructs a new tool tip generator using the specified number * formatters. * * @param formatString the format string. * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). * @param zFormat the format object for the z values (null * not permitted). */ public BubbleXYItemLabelGenerator(String formatString, NumberFormat xFormat, NumberFormat yFormat, NumberFormat zFormat) { super(formatString, xFormat, yFormat); if (zFormat == null) { throw new IllegalArgumentException("Null 'zFormat' argument."); } this.zFormat = zFormat; } /** * Constructs a new item label generator using the specified date * formatters. * * @param formatString the format string. * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). * @param zFormat the format object for the z values (null * not permitted). */ public BubbleXYItemLabelGenerator(String formatString, DateFormat xFormat, DateFormat yFormat, DateFormat zFormat) { super(formatString, xFormat, yFormat); if (zFormat == null) { throw new IllegalArgumentException("Null 'zFormat' argument."); } this.zDateFormat = zFormat; } /** * Returns the number formatter for the z-values. * * @return The number formatter (possibly null). */ public NumberFormat getZFormat() { return this.zFormat; } /** * Returns the date formatter for the z-values. * * @return The date formatter (possibly null). */ public DateFormat getZDateFormat() { return this.zDateFormat; } /** * Generates an item label for a particular item within a series. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The item label (possibly null). */ public String generateLabel(XYDataset dataset, int series, int item) { return generateLabelString(dataset, series, item); } /** * Generates a label string for an item in the dataset. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The label (possibly null). */ public String generateLabelString(XYDataset dataset, int series, int item) { String result = null; Object[] items = null; if (dataset instanceof XYZDataset) { items = createItemArray((XYZDataset) dataset, series, item); } else { items = createItemArray(dataset, series, item); } result = MessageFormat.format(getFormatString(), items); return result; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(XYZDataset dataset, int series, int item) { Object[] result = new Object[4]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); DateFormat xf = getXDateFormat(); if (xf != null) { result[1] = xf.format(x); } else { result[1] = getXFormat().format(x); } Number y = dataset.getY(series, item); DateFormat yf = getYDateFormat(); if (yf != null) { result[2] = yf.format(y); } else { result[2] = getYFormat().format(y); } Number z = dataset.getZ(series, item); if (this.zDateFormat != null) { result[3] = this.zDateFormat.format(z); } else { result[3] = this.zFormat.format(z); } return result; } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BubbleXYItemLabelGenerator)) { return false; } if (!super.equals(obj)) { return false; } BubbleXYItemLabelGenerator that = (BubbleXYItemLabelGenerator) obj; if (!ObjectUtilities.equal(this.zFormat, that.zFormat)) { return false; } if (!ObjectUtilities.equal(this.zDateFormat, that.zDateFormat)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int h = super.hashCode(); h = HashUtilities.hashCode(h, this.zFormat); h = HashUtilities.hashCode(h, this.zDateFormat); return h; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/CategoryItemLabelGenerator.java0000644000175000017500000001043411173030414031743 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * CategoryItemLabelGenerator.java * ------------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 16-Jan-2002 : Completed Javadocs (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Method now specifies category index (DG); * 05-Nov-2002 : Replaced reference to CategoryDataset with TableDataset (DG); * 21-Jan-2003 : TableDataset merged with CategoryDataset (DG); * 10-Apr-2003 : Changed CategoryDataset --> KeyedValues2DDataset (DG); * 01-May-2003 : Added generateValueLabel() method (with a plan to renaming * this interface to reflect its more general use) (DG); * 09-Jun-2003 : Renamed CategoryToolTipGenerator * --> CategoryItemLabelGenerator (DG); * 13-Aug-2003 : Added clone() method (DG); * 12-Feb-2004 : Removed clone() method (DG); * 15-Apr-2004 : Moved generateToolTip() method into CategoryToolTipGenerator * interface (DG); * 11-May-2004 : Renamed CategoryItemLabelGenerator * --> CategoryLabelGenerator (DG); * 31-Jan-2005 : Added generateRowLabel() and generateColumnLabel() * methods (DG); * 20-Apr-2005 : Reverted name change of 11-May-2004 (DG); * */ package org.jfree.chart.labels; import org.jfree.data.category.CategoryDataset; /** * A category item label generator is an object that can be assigned to a * {@link org.jfree.chart.renderer.category.CategoryItemRenderer} and that * assumes responsibility for creating text items to be used as labels for the * items in a {@link org.jfree.chart.plot.CategoryPlot}. *

* To assist with cloning charts, classes that implement this interface should * also implement the {@link org.jfree.util.PublicCloneable} interface. */ public interface CategoryItemLabelGenerator { /** * Generates a label for the specified row. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * * @return The label. */ public String generateRowLabel(CategoryDataset dataset, int row); /** * Generates a label for the specified row. * * @param dataset the dataset (null not permitted). * @param column the column index (zero-based). * * @return The label. */ public String generateColumnLabel(CategoryDataset dataset, int column); /** * Generates a label for the specified item. The label is typically a * formatted version of the data value, but any text can be used. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The label (possibly null). */ public String generateLabel(CategoryDataset dataset, int row, int column); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/CategorySeriesLabelGenerator.java0000644000175000017500000000472111173030414032301 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * CategorySeriesLabelGenerator.java * --------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Apr-2005 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Nov-2006 : Updated API docs (DG); * */ package org.jfree.chart.labels; import org.jfree.data.category.CategoryDataset; /** * A generator that creates labels for the series in a {@link CategoryDataset}. *

* Classes that implement this interface should be either (a) immutable, or * (b) cloneable via the PublicCloneable interface (defined in * the JCommon class library). This provides a mechanism for the referring * renderer to clone the generator if necessary. */ public interface CategorySeriesLabelGenerator { /** * Generates a label for the specified series. * * @param dataset the dataset (null not permitted). * @param series the series index. * * @return A series label. */ public String generateLabel(CategoryDataset dataset, int series); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/CategoryToolTipGenerator.java0000644000175000017500000000540011173030414031474 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * CategoryToolTipGenerator.java * ----------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Apr-2004 : Separated tool tip method from CategoryItemLabelGenerator * interface (DG); * */ package org.jfree.chart.labels; import org.jfree.data.category.CategoryDataset; /** * A category tool tip generator is an object that can be assigned to a * {@link org.jfree.chart.renderer.category.CategoryItemRenderer} and that * assumes responsibility for creating text items to be used as tooltips for the * items in a {@link org.jfree.chart.plot.CategoryPlot}. *

* To assist with cloning charts, classes that implement this interface should * also implement the org.jfree.util.PublicCloneable interface (in * JCommon). */ public interface CategoryToolTipGenerator { /** * Generates the tool tip text for an item in a dataset. Note: in the * current dataset implementation, each row is a series, and each column * contains values for a particular category. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The tooltip text (possibly null). */ public String generateToolTip(CategoryDataset dataset, int row, int column); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/ContourToolTipGenerator.java0000644000175000017500000000475211173030414031361 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * ContourToolTipGenerator.java * ---------------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 23-Jan-2003 : Added standard header (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Deprecated (DG); * */ package org.jfree.chart.labels; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.contour.ContourDataset; /** * Interface for a tooltip generator for plots that use data from a * {@link ContourDataset}. * * @deprecated This interface is no longer supported (as of version 1.0.4). * If you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public interface ContourToolTipGenerator { /** * Generates a tooltip text item for a particular item within a series. * * @param dataset the dataset. * @param item the item index (zero-based). * * @return The tooltip text. */ public String generateToolTip(ContourDataset dataset, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/CrosshairLabelGenerator.java0000644000175000017500000000377211173030414031313 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * CrosshairLabelGenerator.java * ---------------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 13-Feb-2009 : Version 1 (DG); * */ package org.jfree.chart.labels; import org.jfree.chart.plot.Crosshair; /** * A label generator for crosshairs. * * @since 1.0.13 */ public interface CrosshairLabelGenerator { /** * Returns a string that can be used as the label for a crosshair. * * @param crosshair the crosshair (null not permitted). * * @return The label (possibly null). */ public String generateLabel(Crosshair crosshair); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/CustomXYToolTipGenerator.java0000644000175000017500000001412611173030414031457 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * CustomXYItemLabelGenerator.java * ------------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson (RA); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 21-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 17-Nov-2003 : Implemented PublicCloneable (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.util.List; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A tool tip generator that stores custom tooltips. The dataset passed into * the generateToolTip method is ignored. */ public class CustomXYToolTipGenerator implements XYToolTipGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8636030004670141362L; /** Storage for the tooltip lists. */ private List toolTipSeries = new java.util.ArrayList(); /** * Default constructor. */ public CustomXYToolTipGenerator() { super(); } /** * Returns the number of tool tip lists stored by the renderer. * * @return The list count. */ public int getListCount() { return this.toolTipSeries.size(); } /** * Returns the number of tool tips in a given list. * * @param list the list index (zero based). * * @return The tooltip count. */ public int getToolTipCount(int list) { int result = 0; List tooltips = (List) this.toolTipSeries.get(list); if (tooltips != null) { result = tooltips.size(); } return result; } /** * Returns the tool tip text for an item. * * @param series the series index. * @param item the item index. * * @return The tool tip text. */ public String getToolTipText(int series, int item) { String result = null; if (series < getListCount()) { List tooltips = (List) this.toolTipSeries.get(series); if (tooltips != null) { if (item < tooltips.size()) { result = (String) tooltips.get(item); } } } return result; } /** * Adds a list of tooltips for a series. * * @param toolTips the list of tool tips. */ public void addToolTipSeries(List toolTips) { this.toolTipSeries.add(toolTips); } /** * Generates a tool tip text item for a particular item within a series. * * @param data the dataset (ignored in this implementation). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The tooltip text. */ public String generateToolTip(XYDataset data, int series, int item) { return getToolTipText(series, item); } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { CustomXYToolTipGenerator clone = (CustomXYToolTipGenerator) super.clone(); if (this.toolTipSeries != null) { clone.toolTipSeries = new java.util.ArrayList(this.toolTipSeries); } return clone; } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof CustomXYToolTipGenerator) { CustomXYToolTipGenerator generator = (CustomXYToolTipGenerator) obj; boolean result = true; for (int series = 0; series < getListCount(); series++) { for (int item = 0; item < getToolTipCount(series); item++) { String t1 = getToolTipText(series, item); String t2 = generator.getToolTipText(series, item); if (t1 != null) { result = result && t1.equals(t2); } else { result = result && (t2 == null); } } } return result; } return false; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/HighLowItemLabelGenerator.java0000644000175000017500000002013711173030414031530 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * HighLowItemLabelGenerator.java * ------------------------------ * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): David Basten; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 16-Jan-2002 : Completed Javadocs (DG); * 23-Apr-2002 : Added date to the tooltip string (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 21-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 17-Nov-2003 : Implemented PublicCloneable (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 25-May-2004 : Added number formatter (see patch 890496) (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator (DG); * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import java.util.Date; import org.jfree.chart.HashUtilities; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A standard item label generator for plots that use data from a * {@link OHLCDataset}. */ public class HighLowItemLabelGenerator implements XYItemLabelGenerator, XYToolTipGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5617111754832211830L; /** The date formatter. */ private DateFormat dateFormatter; /** The number formatter. */ private NumberFormat numberFormatter; /** * Creates an item label generator using the default date and number * formats. */ public HighLowItemLabelGenerator() { this(DateFormat.getInstance(), NumberFormat.getInstance()); } /** * Creates a tool tip generator using the supplied date formatter. * * @param dateFormatter the date formatter (null not * permitted). * @param numberFormatter the number formatter (null not * permitted). */ public HighLowItemLabelGenerator(DateFormat dateFormatter, NumberFormat numberFormatter) { if (dateFormatter == null) { throw new IllegalArgumentException( "Null 'dateFormatter' argument."); } if (numberFormatter == null) { throw new IllegalArgumentException( "Null 'numberFormatter' argument."); } this.dateFormatter = dateFormatter; this.numberFormatter = numberFormatter; } /** * Generates a tooltip text item for a particular item within a series. * * @param dataset the dataset. * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The tooltip text. */ public String generateToolTip(XYDataset dataset, int series, int item) { String result = null; if (dataset instanceof OHLCDataset) { OHLCDataset d = (OHLCDataset) dataset; Number high = d.getHigh(series, item); Number low = d.getLow(series, item); Number open = d.getOpen(series, item); Number close = d.getClose(series, item); Number x = d.getX(series, item); result = d.getSeriesKey(series).toString(); if (x != null) { Date date = new Date(x.longValue()); result = result + "--> Date=" + this.dateFormatter.format(date); if (high != null) { result = result + " High=" + this.numberFormatter.format(high.doubleValue()); } if (low != null) { result = result + " Low=" + this.numberFormatter.format(low.doubleValue()); } if (open != null) { result = result + " Open=" + this.numberFormatter.format(open.doubleValue()); } if (close != null) { result = result + " Close=" + this.numberFormatter.format(close.doubleValue()); } } } return result; } /** * Generates a label for the specified item. The label is typically a * formatted version of the data value, but any text can be used. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param category the category index (zero-based). * * @return The label (possibly null). */ public String generateLabel(XYDataset dataset, int series, int category) { return null; //TODO: implement this method properly } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { HighLowItemLabelGenerator clone = (HighLowItemLabelGenerator) super.clone(); if (this.dateFormatter != null) { clone.dateFormatter = (DateFormat) this.dateFormatter.clone(); } if (this.numberFormatter != null) { clone.numberFormatter = (NumberFormat) this.numberFormatter.clone(); } return clone; } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof HighLowItemLabelGenerator)) { return false; } HighLowItemLabelGenerator generator = (HighLowItemLabelGenerator) obj; if (!this.dateFormatter.equals(generator.dateFormatter)) { return false; } if (!this.numberFormatter.equals(generator.numberFormatter)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.dateFormatter); result = HashUtilities.hashCode(result, this.numberFormatter); return result; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/IntervalCategoryItemLabelGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/IntervalCategoryItemLabelGenerator.java0000644000175000017500000001217411173030414033453 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------- * IntervalCategoryItemLabelGenerator.java * --------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1, split from IntervalCategoryItemLabelGenerator (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.util.PublicCloneable; /** * A label generator for plots that use data from an * {@link IntervalCategoryDataset}. */ public class IntervalCategoryItemLabelGenerator extends StandardCategoryItemLabelGenerator implements CategoryItemLabelGenerator, PublicCloneable, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5056909225610630529L; /** The default format string. */ public static final String DEFAULT_LABEL_FORMAT_STRING = "({0}, {1}) = {3} - {4}"; /** * Creates a new generator with a default number formatter. */ public IntervalCategoryItemLabelGenerator() { super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance()); } /** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). */ public IntervalCategoryItemLabelGenerator(String labelFormat, NumberFormat formatter) { super(labelFormat, formatter); } /** * Creates a new generator with the specified date formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the date formatter (null not permitted). */ public IntervalCategoryItemLabelGenerator(String labelFormat, DateFormat formatter) { super(labelFormat, formatter); } /** * Creates the array of items that can be passed to the * MessageFormat class for creating labels. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The items (never null). */ protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[5]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (getNumberFormat() != null) { result[2] = getNumberFormat().format(value); } else if (getDateFormat() != null) { result[2] = getDateFormat().format(value); } if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; Number start = icd.getStartValue(row, column); Number end = icd.getEndValue(row, column); if (getNumberFormat() != null) { result[3] = getNumberFormat().format(start); result[4] = getNumberFormat().format(end); } else if (getDateFormat() != null) { result[3] = getDateFormat().format(start); result[4] = getDateFormat().format(end); } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java0000644000175000017500000001275411173030414033213 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * IntervalCategoryToolTipGenerator.java * ------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1, split from IntervalCategoryItemLabelGenerator (DG); * 08-Oct-2008 : Override equals() method (DG); * */ package org.jfree.chart.labels; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; /** * A tooltip generator for plots that use data from an * {@link IntervalCategoryDataset}. */ public class IntervalCategoryToolTipGenerator extends StandardCategoryToolTipGenerator { /** For serialization. */ private static final long serialVersionUID = -3853824986520333437L; /** The default format string. */ public static final String DEFAULT_TOOL_TIP_FORMAT_STRING = "({0}, {1}) = {3} - {4}"; /** * Creates a new generator with a default number formatter. */ public IntervalCategoryToolTipGenerator() { super(DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); } /** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). */ public IntervalCategoryToolTipGenerator(String labelFormat, NumberFormat formatter) { super(labelFormat, formatter); } /** * Creates a new generator with the specified date formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the date formatter (null not permitted). */ public IntervalCategoryToolTipGenerator(String labelFormat, DateFormat formatter) { super(labelFormat, formatter); } /** * Creates the array of items that can be passed to the * MessageFormat class for creating labels. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The items (never null). */ protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[5]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (getNumberFormat() != null) { result[2] = getNumberFormat().format(value); } else if (getDateFormat() != null) { result[2] = getDateFormat().format(value); } if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; Number start = icd.getStartValue(row, column); Number end = icd.getEndValue(row, column); if (getNumberFormat() != null) { result[3] = getNumberFormat().format(start); result[4] = getNumberFormat().format(end); } else if (getDateFormat() != null) { result[3] = getDateFormat().format(start); result[4] = getDateFormat().format(end); } } return result; } /** * Tests this tool tip generator for equality with an arbitrary * object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof IntervalCategoryToolTipGenerator)) { return false; } // no fields to test return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/IntervalXYItemLabelGenerator.java0000644000175000017500000002234211173030414032234 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * IntervalXYItemLabelGenerator.java * --------------------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-May-2008 : Version 1 (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.MessageFormat; import java.text.NumberFormat; import java.util.Date; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * An item label generator for datasets that implement the * {@link IntervalXYDataset} interface. * * @since 1.0.10 */ public class IntervalXYItemLabelGenerator extends AbstractXYItemLabelGenerator implements XYItemLabelGenerator, Cloneable, PublicCloneable, Serializable { /** The default item label format. */ public static final String DEFAULT_ITEM_LABEL_FORMAT = "{5} - {6}"; /** * Creates an item label generator using default number formatters. */ public IntervalXYItemLabelGenerator() { this(DEFAULT_ITEM_LABEL_FORMAT, NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()); } /** * Creates an item label generator using the specified number formatters. * * @param formatString the item label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public IntervalXYItemLabelGenerator(String formatString, NumberFormat xFormat, NumberFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates an item label generator using the specified formatters. * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public IntervalXYItemLabelGenerator(String formatString, DateFormat xFormat, NumberFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates an item label generator using the specified formatters (a * number formatter for the x-values and a date formatter for the * y-values). * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * permitted). * @param yFormat the format object for the y values (null * not permitted). */ public IntervalXYItemLabelGenerator(String formatString, NumberFormat xFormat, DateFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates a label generator using the specified date formatters. * * @param formatString the label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public IntervalXYItemLabelGenerator(String formatString, DateFormat xFormat, DateFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return An array of seven items from the dataset formatted as * String objects (never null). */ protected Object[] createItemArray(XYDataset dataset, int series, int item) { IntervalXYDataset intervalDataset = null; if (dataset instanceof IntervalXYDataset) { intervalDataset = (IntervalXYDataset) dataset; } Object[] result = new Object[7]; result[0] = dataset.getSeriesKey(series).toString(); double x = dataset.getXValue(series, item); double xs = x; double xe = x; double y = dataset.getYValue(series, item); double ys = y; double ye = y; if (intervalDataset != null) { xs = intervalDataset.getStartXValue(series, item); xe = intervalDataset.getEndXValue(series, item); ys = intervalDataset.getStartYValue(series, item); ye = intervalDataset.getEndYValue(series, item); } DateFormat xdf = getXDateFormat(); if (xdf != null) { result[1] = xdf.format(new Date((long) x)); result[2] = xdf.format(new Date((long) xs)); result[3] = xdf.format(new Date((long) xe)); } else { NumberFormat xnf = getXFormat(); result[1] = xnf.format(x); result[2] = xnf.format(xs); result[3] = xnf.format(xe); } NumberFormat ynf = getYFormat(); DateFormat ydf = getYDateFormat(); if (Double.isNaN(y) && dataset.getY(series, item) == null) { result[4] = getNullYString(); } else { if (ydf != null) { result[4] = ydf.format(new Date((long) y)); } else { result[4] = ynf.format(y); } } if (Double.isNaN(ys) && intervalDataset.getStartY(series, item) == null) { result[5] = getNullYString(); } else { if (ydf != null) { result[5] = ydf.format(new Date((long) ys)); } else { result[5] = ynf.format(ys); } } if (Double.isNaN(ye) && intervalDataset.getEndY(series, item) == null) { result[6] = getNullYString(); } else { if (ydf != null) { result[6] = ydf.format(new Date((long) ye)); } else { result[6] = ynf.format(ye); } } return result; } /** * Generates the item label text for an item in a dataset. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The label text (possibly null). */ public String generateLabel(XYDataset dataset, int series, int item) { return generateLabelString(dataset, series, item); } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof IntervalXYItemLabelGenerator)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/ItemLabelAnchor.java0000644000175000017500000002300211173030414027524 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ItemLabelAnchor.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2003 : Version 1 (DG); * 19-Feb-2004 : Moved to org.jfree.chart.labels package, added readResolve() * method (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * */ package org.jfree.chart.labels; import java.io.ObjectStreamException; import java.io.Serializable; /** * An enumeration of the positions that a value label can take, relative to an * item in a {@link org.jfree.chart.plot.CategoryPlot}. */ public final class ItemLabelAnchor implements Serializable { /** For serialization. */ private static final long serialVersionUID = -1233101616128695658L; /** CENTER. */ public static final ItemLabelAnchor CENTER = new ItemLabelAnchor("ItemLabelAnchor.CENTER"); /** INSIDE1. */ public static final ItemLabelAnchor INSIDE1 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1"); /** INSIDE2. */ public static final ItemLabelAnchor INSIDE2 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2"); /** INSIDE3. */ public static final ItemLabelAnchor INSIDE3 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3"); /** INSIDE4. */ public static final ItemLabelAnchor INSIDE4 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4"); /** INSIDE5. */ public static final ItemLabelAnchor INSIDE5 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5"); /** INSIDE6. */ public static final ItemLabelAnchor INSIDE6 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6"); /** INSIDE7. */ public static final ItemLabelAnchor INSIDE7 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7"); /** INSIDE8. */ public static final ItemLabelAnchor INSIDE8 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8"); /** INSIDE9. */ public static final ItemLabelAnchor INSIDE9 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9"); /** INSIDE10. */ public static final ItemLabelAnchor INSIDE10 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10"); /** INSIDE11. */ public static final ItemLabelAnchor INSIDE11 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11"); /** INSIDE12. */ public static final ItemLabelAnchor INSIDE12 = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12"); /** OUTSIDE1. */ public static final ItemLabelAnchor OUTSIDE1 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1"); /** OUTSIDE2. */ public static final ItemLabelAnchor OUTSIDE2 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2"); /** OUTSIDE3. */ public static final ItemLabelAnchor OUTSIDE3 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3"); /** OUTSIDE4. */ public static final ItemLabelAnchor OUTSIDE4 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4"); /** OUTSIDE5. */ public static final ItemLabelAnchor OUTSIDE5 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5"); /** OUTSIDE6. */ public static final ItemLabelAnchor OUTSIDE6 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6"); /** OUTSIDE7. */ public static final ItemLabelAnchor OUTSIDE7 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7"); /** OUTSIDE8. */ public static final ItemLabelAnchor OUTSIDE8 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8"); /** OUTSIDE9. */ public static final ItemLabelAnchor OUTSIDE9 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9"); /** OUTSIDE10. */ public static final ItemLabelAnchor OUTSIDE10 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10"); /** OUTSIDE11. */ public static final ItemLabelAnchor OUTSIDE11 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11"); /** OUTSIDE12. */ public static final ItemLabelAnchor OUTSIDE12 = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private ItemLabelAnchor(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param o the other object. * * @return A boolean. */ public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ItemLabelAnchor)) { return false; } ItemLabelAnchor order = (ItemLabelAnchor) o; if (!this.name.equals(order.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { ItemLabelAnchor result = null; if (this.equals(ItemLabelAnchor.CENTER)) { result = ItemLabelAnchor.CENTER; } else if (this.equals(ItemLabelAnchor.INSIDE1)) { result = ItemLabelAnchor.INSIDE1; } else if (this.equals(ItemLabelAnchor.INSIDE2)) { result = ItemLabelAnchor.INSIDE2; } else if (this.equals(ItemLabelAnchor.INSIDE3)) { result = ItemLabelAnchor.INSIDE3; } else if (this.equals(ItemLabelAnchor.INSIDE4)) { result = ItemLabelAnchor.INSIDE4; } else if (this.equals(ItemLabelAnchor.INSIDE5)) { result = ItemLabelAnchor.INSIDE5; } else if (this.equals(ItemLabelAnchor.INSIDE6)) { result = ItemLabelAnchor.INSIDE6; } else if (this.equals(ItemLabelAnchor.INSIDE7)) { result = ItemLabelAnchor.INSIDE7; } else if (this.equals(ItemLabelAnchor.INSIDE8)) { result = ItemLabelAnchor.INSIDE8; } else if (this.equals(ItemLabelAnchor.INSIDE9)) { result = ItemLabelAnchor.INSIDE9; } else if (this.equals(ItemLabelAnchor.INSIDE10)) { result = ItemLabelAnchor.INSIDE10; } else if (this.equals(ItemLabelAnchor.INSIDE11)) { result = ItemLabelAnchor.INSIDE11; } else if (this.equals(ItemLabelAnchor.INSIDE12)) { result = ItemLabelAnchor.INSIDE12; } else if (this.equals(ItemLabelAnchor.OUTSIDE1)) { result = ItemLabelAnchor.OUTSIDE1; } else if (this.equals(ItemLabelAnchor.OUTSIDE2)) { result = ItemLabelAnchor.OUTSIDE2; } else if (this.equals(ItemLabelAnchor.OUTSIDE3)) { result = ItemLabelAnchor.OUTSIDE3; } else if (this.equals(ItemLabelAnchor.OUTSIDE4)) { result = ItemLabelAnchor.OUTSIDE4; } else if (this.equals(ItemLabelAnchor.OUTSIDE5)) { result = ItemLabelAnchor.OUTSIDE5; } else if (this.equals(ItemLabelAnchor.OUTSIDE6)) { result = ItemLabelAnchor.OUTSIDE6; } else if (this.equals(ItemLabelAnchor.OUTSIDE7)) { result = ItemLabelAnchor.OUTSIDE7; } else if (this.equals(ItemLabelAnchor.OUTSIDE8)) { result = ItemLabelAnchor.OUTSIDE8; } else if (this.equals(ItemLabelAnchor.OUTSIDE9)) { result = ItemLabelAnchor.OUTSIDE9; } else if (this.equals(ItemLabelAnchor.OUTSIDE10)) { result = ItemLabelAnchor.OUTSIDE10; } else if (this.equals(ItemLabelAnchor.OUTSIDE11)) { result = ItemLabelAnchor.OUTSIDE11; } else if (this.equals(ItemLabelAnchor.OUTSIDE12)) { result = ItemLabelAnchor.OUTSIDE12; } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/ItemLabelPosition.java0000644000175000017500000001425211173030414030125 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * ItemLabelPosition.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Oct-2003 : Version 1 (DG); * 19-Feb-2004 : Moved to org.jfree.chart.labels, updated Javadocs and argument * checking (DG); * 26-Feb-2004 : Added new constructor (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import org.jfree.ui.TextAnchor; /** * The attributes that control the position of the label for each data item on * a chart. Instances of this class are immutable. */ public class ItemLabelPosition implements Serializable { /** For serialization. */ private static final long serialVersionUID = 5845390630157034499L; /** The item label anchor point. */ private ItemLabelAnchor itemLabelAnchor; /** The text anchor. */ private TextAnchor textAnchor; /** The rotation anchor. */ private TextAnchor rotationAnchor; /** The rotation angle. */ private double angle; /** * Creates a new position record with default settings. */ public ItemLabelPosition() { this(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0); } /** * Creates a new position record (with zero rotation). * * @param itemLabelAnchor the item label anchor (null not * permitted). * @param textAnchor the text anchor (null not permitted). */ public ItemLabelPosition(ItemLabelAnchor itemLabelAnchor, TextAnchor textAnchor) { this(itemLabelAnchor, textAnchor, TextAnchor.CENTER, 0.0); } /** * Creates a new position record. The item label anchor is a point * relative to the data item (dot, bar or other visual item) on a chart. * The item label is aligned by aligning the text anchor with the * item label anchor. * * @param itemLabelAnchor the item label anchor (null not * permitted). * @param textAnchor the text anchor (null not permitted). * @param rotationAnchor the rotation anchor (null not * permitted). * @param angle the rotation angle (in radians). */ public ItemLabelPosition(ItemLabelAnchor itemLabelAnchor, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { if (itemLabelAnchor == null) { throw new IllegalArgumentException( "Null 'itemLabelAnchor' argument."); } if (textAnchor == null) { throw new IllegalArgumentException("Null 'textAnchor' argument."); } if (rotationAnchor == null) { throw new IllegalArgumentException( "Null 'rotationAnchor' argument."); } this.itemLabelAnchor = itemLabelAnchor; this.textAnchor = textAnchor; this.rotationAnchor = rotationAnchor; this.angle = angle; } /** * Returns the item label anchor. * * @return The item label anchor (never null). */ public ItemLabelAnchor getItemLabelAnchor() { return this.itemLabelAnchor; } /** * Returns the text anchor. * * @return The text anchor (never null). */ public TextAnchor getTextAnchor() { return this.textAnchor; } /** * Returns the rotation anchor point. * * @return The rotation anchor point (never null). */ public TextAnchor getRotationAnchor() { return this.rotationAnchor; } /** * Returns the angle of rotation for the label. * * @return The angle (in radians). */ public double getAngle() { return this.angle; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ItemLabelPosition)) { return false; } ItemLabelPosition that = (ItemLabelPosition) obj; if (!this.itemLabelAnchor.equals(that.itemLabelAnchor)) { return false; } if (!this.textAnchor.equals(that.textAnchor)) { return false; } if (!this.rotationAnchor.equals(that.rotationAnchor)) { return false; } if (this.angle != that.angle) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java0000644000175000017500000002005411173030414032575 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * MultipleXYSeriesLabelGenerator.java * ----------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Nov-2004 : Version 1 (DG); * 18-Apr-2005 : Use StringBuffer (DG); * 20-Feb-2007 : Fixed for equals() and cloning() (DG); * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.MessageFormat; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import org.jfree.chart.HashUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A series label generator for plots that use data from * an {@link org.jfree.data.xy.XYDataset}. */ public class MultipleXYSeriesLabelGenerator implements XYSeriesLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 138976236941898560L; /** The default item label format. */ public static final String DEFAULT_LABEL_FORMAT = "{0}"; /** The format pattern for the initial part of the label. */ private String formatPattern; /** The format pattern for additional labels. */ private String additionalFormatPattern; /** Storage for the additional series labels. */ private Map seriesLabelLists; /** * Creates an item label generator using default number formatters. */ public MultipleXYSeriesLabelGenerator() { this(DEFAULT_LABEL_FORMAT); } /** * Creates a new series label generator. * * @param format the format pattern (null not permitted). */ public MultipleXYSeriesLabelGenerator(String format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.formatPattern = format; this.additionalFormatPattern = "\n{0}"; this.seriesLabelLists = new HashMap(); } /** * Adds an extra label for the specified series. * * @param series the series index. * @param label the label. */ public void addSeriesLabel(int series, String label) { Integer key = new Integer(series); List labelList = (List) this.seriesLabelLists.get(key); if (labelList == null) { labelList = new java.util.ArrayList(); this.seriesLabelLists.put(key, labelList); } labelList.add(label); } /** * Clears the extra labels for the specified series. * * @param series the series index. */ public void clearSeriesLabels(int series) { Integer key = new Integer(series); this.seriesLabelLists.put(key, null); } /** * Generates a label for the specified series. This label will be * used for the chart legend. * * @param dataset the dataset (null not permitted). * @param series the series. * * @return A series label. */ public String generateLabel(XYDataset dataset, int series) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } StringBuffer label = new StringBuffer(); label.append(MessageFormat.format(this.formatPattern, createItemArray(dataset, series))); Integer key = new Integer(series); List extraLabels = (List) this.seriesLabelLists.get(key); if (extraLabels != null) { Object[] temp = new Object[1]; for (int i = 0; i < extraLabels.size(); i++) { temp[0] = extraLabels.get(i); String labelAddition = MessageFormat.format( this.additionalFormatPattern, temp); label.append(labelAddition); } } return label.toString(); } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(XYDataset dataset, int series) { Object[] result = new Object[1]; result[0] = dataset.getSeriesKey(series).toString(); return result; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { MultipleXYSeriesLabelGenerator clone = (MultipleXYSeriesLabelGenerator) super.clone(); clone.seriesLabelLists = new HashMap(); Set keys = this.seriesLabelLists.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Object key = iterator.next(); Object entry = this.seriesLabelLists.get(key); Object toAdd = entry; if (entry instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) entry; toAdd = pc.clone(); } clone.seriesLabelLists.put(key, toAdd); } return clone; } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MultipleXYSeriesLabelGenerator)) { return false; } MultipleXYSeriesLabelGenerator that = (MultipleXYSeriesLabelGenerator) obj; if (!this.formatPattern.equals(that.formatPattern)) { return false; } if (!this.additionalFormatPattern.equals( that.additionalFormatPattern)) { return false; } if (!this.seriesLabelLists.equals(that.seriesLabelLists)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.formatPattern); result = HashUtilities.hashCode(result, this.additionalFormatPattern); result = HashUtilities.hashCode(result, this.seriesLabelLists); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/PieSectionLabelGenerator.java0000644000175000017500000001053311173030414031411 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * PieSectionLabelGenerator.java * ----------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 16-Jan-2002 : Completed Javadocs (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 30-Oct-2002 : Category is now a Comparable instance (DG); * 07-Mar-2003 : Changed to KeyedValuesDataset and added pieIndex * parameter (DG); * 21-Mar-2003 : Updated Javadocs (DG); * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); * 13-Aug-2003 : Added clone() method (DG); * 19-Aug-2003 : Renamed PieToolTipGenerator --> PieItemLabelGenerator (DG); * 11-Nov-2003 : Removed clone() method (DG); * 30-Jan-2004 : Added generateSectionLabel() method (DG); * 15-Apr-2004 : Moved generateToolTip() method into separate interface and * renamed this interface PieSectionLabelGenerator (DG); * */ package org.jfree.chart.labels; import java.awt.Font; import java.awt.Paint; import java.awt.font.TextAttribute; import java.text.AttributedString; import org.jfree.data.general.PieDataset; /** * Interface for a label generator for plots that use data from * a {@link PieDataset}. */ public interface PieSectionLabelGenerator { /** * Generates a label for a pie section. * * @param dataset the dataset (null not permitted). * @param key the section key (null not permitted). * * @return The label (possibly null). */ public String generateSectionLabel(PieDataset dataset, Comparable key); /** * Generates an attributed label for the specified series, or * null if no attributed label is available (in which case, * the string returned by * {@link #generateSectionLabel(PieDataset, Comparable)} will * provide the fallback). Only certain attributes are recognised by the * code that ultimately displays the labels: *

    *
  • {@link TextAttribute#FONT}: will set the font;
  • *
  • {@link TextAttribute#POSTURE}: a value of * {@link TextAttribute#POSTURE_OBLIQUE} will add {@link Font#ITALIC} to * the current font;
  • *
  • {@link TextAttribute#WEIGHT}: a value of * {@link TextAttribute#WEIGHT_BOLD} will add {@link Font#BOLD} to the * current font;
  • *
  • {@link TextAttribute#FOREGROUND}: this will set the {@link Paint} * for the current
  • *
  • {@link TextAttribute#SUPERSCRIPT}: the values * {@link TextAttribute#SUPERSCRIPT_SUB} and * {@link TextAttribute#SUPERSCRIPT_SUPER} are recognised.
  • *
* * @param dataset the dataset. * @param key the key. * * @return An attributed label (possibly null). */ public AttributedString generateAttributedSectionLabel(PieDataset dataset, Comparable key); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/PieToolTipGenerator.java0000644000175000017500000000441211173030414030436 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * PieToolTipGenerator.java * ------------------------ * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Apr-2004 : Version 1, split from PieItemLabelGenerator (DG); * */ package org.jfree.chart.labels; import org.jfree.data.general.PieDataset; /** * A tool tip generator that is used by the * {@link org.jfree.chart.plot.PiePlot} class. */ public interface PieToolTipGenerator { /** * Generates a tool tip text item for the specified item in the dataset. * This method can return null to indicate that no tool tip * should be displayed for an item. * * @param dataset the dataset (null not permitted). * @param key the section key (null not permitted). * * @return The tool tip text (possibly null). */ public String generateToolTip(PieDataset dataset, Comparable key); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java0000644000175000017500000001272111173030414033425 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------- * StandardCategoryItemLabelGenerator.java * --------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1 (DG); * 20-Apr-2005 : Renamed StandardCategoryLabelGenerator * --> StandardCategoryItemLabelGenerator (DG); * ------------- JFREECHART 1.0.0 --------------------------------------------- * 03-May-2005 : Added equals() implementation, to fix bug 1481087 (DG); */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.category.CategoryDataset; import org.jfree.util.PublicCloneable; /** * A standard label generator that can be used with a * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. */ public class StandardCategoryItemLabelGenerator extends AbstractCategoryItemLabelGenerator implements CategoryItemLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3499701401211412882L; /** The default format string. */ public static final String DEFAULT_LABEL_FORMAT_STRING = "{2}"; /** * Creates a new generator with a default number formatter. */ public StandardCategoryItemLabelGenerator() { super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance()); } /** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). */ public StandardCategoryItemLabelGenerator(String labelFormat, NumberFormat formatter) { super(labelFormat, formatter); } /** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). * @param percentFormatter the percent formatter (null not * permitted). * * @since 1.0.2 */ public StandardCategoryItemLabelGenerator(String labelFormat, NumberFormat formatter, NumberFormat percentFormatter) { super(labelFormat, formatter, percentFormatter); } /** * Creates a new generator with the specified date formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the date formatter (null not permitted). */ public StandardCategoryItemLabelGenerator(String labelFormat, DateFormat formatter) { super(labelFormat, formatter); } /** * Generates the label for an item in a dataset. Note: in the current * dataset implementation, each row is a series, and each column contains * values for a particular category. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The label (possibly null). */ public String generateLabel(CategoryDataset dataset, int row, int column) { return generateLabelString(dataset, row, column); } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true if this generator is equal to * obj, and false otherwise. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardCategoryItemLabelGenerator)) { return false; } return super.equals(obj); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.ja0000644000175000017500000001256511173030414033440 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------------- * StandardCategorySeriesLabelGenerator.java * ----------------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Apr-2005 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Fixed equals() method (bug 1481102) (DG); * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.MessageFormat; import org.jfree.chart.HashUtilities; import org.jfree.data.category.CategoryDataset; import org.jfree.util.PublicCloneable; /** * A standard series label generator for plots that use data from * a {@link org.jfree.data.category.CategoryDataset}. */ public class StandardCategorySeriesLabelGenerator implements CategorySeriesLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 4630760091523940820L; /** The default item label format. */ public static final String DEFAULT_LABEL_FORMAT = "{0}"; /** The format pattern. */ private String formatPattern; /** * Creates a default series label generator (uses * {@link #DEFAULT_LABEL_FORMAT}). */ public StandardCategorySeriesLabelGenerator() { this(DEFAULT_LABEL_FORMAT); } /** * Creates a new series label generator. * * @param format the format pattern (null not permitted). */ public StandardCategorySeriesLabelGenerator(String format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.formatPattern = format; } /** * Generates a label for the specified series. * * @param dataset the dataset (null not permitted). * @param series the series. * * @return A series label. */ public String generateLabel(CategoryDataset dataset, int series) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } String label = MessageFormat.format(this.formatPattern, createItemArray(dataset, series)); return label; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(CategoryDataset dataset, int series) { Object[] result = new Object[1]; result[0] = dataset.getRowKey(series).toString(); return result; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardCategorySeriesLabelGenerator)) { return false; } StandardCategorySeriesLabelGenerator that = (StandardCategorySeriesLabelGenerator) obj; if (!this.formatPattern.equals(that.formatPattern)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.formatPattern); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardCategoryToolTipGenerator.java0000644000175000017500000001116411173030414033161 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * StandardCategoryToolTipGenerator.java * ------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Added equals() method to fix bug 1481087 (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.category.CategoryDataset; /** * A standard tool tip generator that can be used with a * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. */ public class StandardCategoryToolTipGenerator extends AbstractCategoryItemLabelGenerator implements CategoryToolTipGenerator, Serializable { /** For serialization. */ private static final long serialVersionUID = -6768806592218710764L; /** The default format string. */ public static final String DEFAULT_TOOL_TIP_FORMAT_STRING = "({0}, {1}) = {2}"; /** * Creates a new generator with a default number formatter. */ public StandardCategoryToolTipGenerator() { super(DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); } /** * Creates a new generator with the specified number formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the number formatter (null not permitted). */ public StandardCategoryToolTipGenerator(String labelFormat, NumberFormat formatter) { super(labelFormat, formatter); } /** * Creates a new generator with the specified date formatter. * * @param labelFormat the label format string (null not * permitted). * @param formatter the date formatter (null not permitted). */ public StandardCategoryToolTipGenerator(String labelFormat, DateFormat formatter) { super(labelFormat, formatter); } /** * Generates the tool tip text for an item in a dataset. Note: in the * current dataset implementation, each row is a series, and each column * contains values for a particular category. * * @param dataset the dataset (null not permitted). * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The tooltip text (possibly null). */ public String generateToolTip(CategoryDataset dataset, int row, int column) { return generateLabelString(dataset, row, column); } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardCategoryToolTipGenerator)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardContourToolTipGenerator.java0000644000175000017500000001106611173030414033036 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * StandardContourToolTipGenerator.java * ------------------------------------ * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 23-Jan-2003 : Added standard header (DG); * 21-Mar-2003 : Implemented Serializable (DG); * 15-Jul-2004 : Switched the getZ() and getZValue() methods (DG); * 19-Jan-2005 : Now accesses primitives only from dataset (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.contour.ContourDataset; /** * A standard tooltip generator for plots that use data from an * {@link ContourDataset}. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class StandardContourToolTipGenerator implements ContourToolTipGenerator, Serializable { /** For serialization. */ private static final long serialVersionUID = -1881659351247502711L; /** The number formatter. */ private DecimalFormat valueForm = new DecimalFormat("##.###"); /** * Generates a tooltip text item for a particular item within a series. * * @param data the dataset. * @param item the item index (zero-based). * * @return The tooltip text. */ public String generateToolTip(ContourDataset data, int item) { double x = data.getXValue(0, item); double y = data.getYValue(0, item); double z = data.getZValue(0, item); String xString = null; if (data.isDateAxis(0)) { SimpleDateFormat formatter = new java.text.SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); StringBuffer strbuf = new StringBuffer(); strbuf = formatter.format( new Date((long) x), strbuf, new java.text.FieldPosition(0) ); xString = strbuf.toString(); } else { xString = this.valueForm.format(x); } if (!Double.isNaN(z)) { return "X: " + xString + ", Y: " + this.valueForm.format(y) + ", Z: " + this.valueForm.format(z); } else { return "X: " + xString + ", Y: " + this.valueForm.format(y) + ", Z: no data"; } } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardContourToolTipGenerator)) { return false; } StandardContourToolTipGenerator that = (StandardContourToolTipGenerator) obj; if (this.valueForm != null) { return this.valueForm.equals(that.valueForm); } return false; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java0000644000175000017500000001153111173030414032764 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * DefaultCrosshairLabelGenerator.java * ----------------------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 13-Feb-2009 : Version 1 (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.MessageFormat; import java.text.NumberFormat; import org.jfree.chart.plot.Crosshair; /** * A default label generator. * * @since 1.0.13 */ public class StandardCrosshairLabelGenerator implements CrosshairLabelGenerator, Serializable { /** The label format string. */ private String labelTemplate; /** A number formatter for the value. */ private NumberFormat numberFormat; /** * Creates a new instance with default attributes. */ public StandardCrosshairLabelGenerator() { this("{0}", NumberFormat.getNumberInstance()); } /** * Creates a new instance with the specified attributes. * * @param labelTemplate the label template (null not * permitted). * @param numberFormat the number formatter (null not * permitted). */ public StandardCrosshairLabelGenerator(String labelTemplate, NumberFormat numberFormat) { super(); if (labelTemplate == null) { throw new IllegalArgumentException( "Null 'labelTemplate' argument."); } if (numberFormat == null) { throw new IllegalArgumentException( "Null 'numberFormat' argument."); } this.labelTemplate = labelTemplate; this.numberFormat = numberFormat; } /** * Returns the label template string. * * @return The label template string (never null). */ public String getLabelTemplate() { return this.labelTemplate; } /** * Returns the number formatter. * * @return The formatter (never null). */ public NumberFormat getNumberFormat() { return this.numberFormat; } /** * Returns a string that can be used as the label for a crosshair. * * @param crosshair the crosshair (null not permitted). * * @return The label (possibly null). */ public String generateLabel(Crosshair crosshair) { Object[] v = new Object[] { this.numberFormat.format( crosshair.getValue()) }; String result = MessageFormat.format(this.labelTemplate, v); return result; } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardCrosshairLabelGenerator)) { return false; } StandardCrosshairLabelGenerator that = (StandardCrosshairLabelGenerator) obj; if (!this.labelTemplate.equals(that.labelTemplate)) { return false; } if (!this.numberFormat.equals(that.numberFormat)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code for this instance. */ public int hashCode() { return this.labelTemplate.hashCode(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java0000644000175000017500000002213211173030414033070 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * StandardPieSectionLabelGenerator.java * ------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Nov-2004 : Version 1, derived from StandardPieItemLabelGenerator (DG); * 29-Jul-2005 : Removed unused generateToolTip() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Modified DEFAULT_SECTION_LABEL_FORMAT (DG); * 10-Jan-2007 : Include attributedLabels in equals() test (DG); * 10-Jul-2007 : Added constructors with locale parameter (DG); * 23-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.chart.labels; import java.awt.Font; import java.awt.Paint; import java.awt.font.TextAttribute; import java.io.Serializable; import java.text.AttributedString; import java.text.NumberFormat; import java.util.Locale; import org.jfree.data.general.PieDataset; import org.jfree.util.ObjectList; import org.jfree.util.PublicCloneable; /** * A standard item label generator for plots that use data from a * {@link PieDataset}. *

* For the label format, use {0} where the pie section key should be inserted, * {1} for the absolute section value and {2} for the percent amount of the pie * section, e.g. "{0} = {1} ({2})" will display as * apple = 120 (5%). */ public class StandardPieSectionLabelGenerator extends AbstractPieItemLabelGenerator implements PieSectionLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3064190563760203668L; /** The default section label format. */ public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0}"; /** * An optional list of attributed labels (instances of AttributedString). */ private ObjectList attributedLabels; /** * Creates a new section label generator using * {@link #DEFAULT_SECTION_LABEL_FORMAT} as the label format string, and * platform default number and percentage formatters. */ public StandardPieSectionLabelGenerator() { this(DEFAULT_SECTION_LABEL_FORMAT, NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()); } /** * Creates a new instance for the specified locale. * * @param locale the local (null not permitted). * * @since 1.0.7 */ public StandardPieSectionLabelGenerator(Locale locale) { this(DEFAULT_SECTION_LABEL_FORMAT, locale); } /** * Creates a new section label generator using the specified label format * string, and platform default number and percentage formatters. * * @param labelFormat the label format (null not permitted). */ public StandardPieSectionLabelGenerator(String labelFormat) { this(labelFormat, NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()); } /** * Creates a new instance for the specified locale. * * @param labelFormat the label format (null not permitted). * @param locale the local (null not permitted). * * @since 1.0.7 */ public StandardPieSectionLabelGenerator(String labelFormat, Locale locale) { this(labelFormat, NumberFormat.getNumberInstance(locale), NumberFormat.getPercentInstance(locale)); } /** * Creates an item label generator using the specified number formatters. * * @param labelFormat the label format string (null not * permitted). * @param numberFormat the format object for the values (null * not permitted). * @param percentFormat the format object for the percentages * (null not permitted). */ public StandardPieSectionLabelGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat) { super(labelFormat, numberFormat, percentFormat); this.attributedLabels = new ObjectList(); } /** * Returns the attributed label for a section, or null if none * is defined. * * @param section the section index. * * @return The attributed label. */ public AttributedString getAttributedLabel(int section) { return (AttributedString) this.attributedLabels.get(section); } /** * Sets the attributed label for a section. * * @param section the section index. * @param label the label (null permitted). */ public void setAttributedLabel(int section, AttributedString label) { this.attributedLabels.set(section, label); } /** * Generates a label for a pie section. * * @param dataset the dataset (null not permitted). * @param key the section key (null not permitted). * * @return The label (possibly null). */ public String generateSectionLabel(PieDataset dataset, Comparable key) { return super.generateSectionLabel(dataset, key); } /** * Generates an attributed label for the specified series, or * null if no attributed label is available (in which case, * the string returned by * {@link #generateSectionLabel(PieDataset, Comparable)} will * provide the fallback). Only certain attributes are recognised by the * code that ultimately displays the labels: *

    *
  • {@link TextAttribute#FONT}: will set the font;
  • *
  • {@link TextAttribute#POSTURE}: a value of * {@link TextAttribute#POSTURE_OBLIQUE} will add {@link Font#ITALIC} to * the current font;
  • *
  • {@link TextAttribute#WEIGHT}: a value of * {@link TextAttribute#WEIGHT_BOLD} will add {@link Font#BOLD} to the * current font;
  • *
  • {@link TextAttribute#FOREGROUND}: this will set the {@link Paint} * for the current
  • *
  • {@link TextAttribute#SUPERSCRIPT}: the values * {@link TextAttribute#SUPERSCRIPT_SUB} and * {@link TextAttribute#SUPERSCRIPT_SUPER} are recognised.
  • *
* * @param dataset the dataset (null not permitted). * @param key the key. * * @return An attributed label (possibly null). */ public AttributedString generateAttributedSectionLabel(PieDataset dataset, Comparable key) { return getAttributedLabel(dataset.getIndex(key)); } /** * Tests the generator for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardPieSectionLabelGenerator)) { return false; } StandardPieSectionLabelGenerator that = (StandardPieSectionLabelGenerator) obj; if (!this.attributedLabels.equals(that.attributedLabels)) { return false; } if (!super.equals(obj)) { return false; } return true; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardPieToolTipGenerator.java0000644000175000017500000001450511173030414032123 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * StandardPieToolTipGenerator.java * -------------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Andreas Schroeder; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 16-Jan-2002 : Completed Javadocs (DG); * 29-Aug-2002 : Changed to format numbers using default locale (RA); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 30-Oct-2002 : Changed PieToolTipGenerator interface (DG); * 21-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 19-Aug-2003 : Renamed StandardPieToolTipGenerator --> * StandardPieItemLabelGenerator (DG); * 10-Mar-2004 : Modified to use MessageFormat class (DG); * 31-Mar-2004 : Added javadocs for the MessageFormat usage (AS); * 15-Apr-2004 : Split PieItemLabelGenerator interface into * PieSectionLabelGenerator and PieToolTipGenerator (DG); * 25-Nov-2004 : Moved some code into abstract super class (DG); * 29-Jul-2005 : Removed implementation of PieSectionLabelGenerator * interface (DG); * 10-Jul-2007 : Added constructors with locale argument (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.NumberFormat; import java.util.Locale; import org.jfree.data.general.PieDataset; import org.jfree.util.PublicCloneable; /** * A standard item label generator for plots that use data from a * {@link PieDataset}. *

* For the label format, use {0} where the pie section key should be inserted, * {1} for the absolute section value and {2} for the percent amount of the pie * section, e.g. "{0} = {1} ({2})" will display as * apple = 120 (5%). */ public class StandardPieToolTipGenerator extends AbstractPieItemLabelGenerator implements PieToolTipGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2995304200445733779L; /** The default tooltip format. */ public static final String DEFAULT_TOOLTIP_FORMAT = "{0}: ({1}, {2})"; /** * The default section label format. * * @deprecated As of 1.0.7, use {@link #DEFAULT_TOOLTIP_FORMAT} instead. */ public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0} = {1}"; /** * Creates an item label generator using default number formatters. */ public StandardPieToolTipGenerator() { this(DEFAULT_TOOLTIP_FORMAT); } /** * Creates a pie tool tip generator for the specified locale, using the * default format string. * * @param locale the locale (null not permitted). * * @since 1.0.7 */ public StandardPieToolTipGenerator(Locale locale) { this(DEFAULT_TOOLTIP_FORMAT, locale); } /** * Creates a pie tool tip generator for the default locale. * * @param labelFormat the label format (null not permitted). */ public StandardPieToolTipGenerator(String labelFormat) { this(labelFormat, Locale.getDefault()); } /** * Creates a pie tool tip generator for the specified locale. * * @param labelFormat the label format (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.7 */ public StandardPieToolTipGenerator(String labelFormat, Locale locale) { this(labelFormat, NumberFormat.getNumberInstance(locale), NumberFormat.getPercentInstance(locale)); } /** * Creates an item label generator using the specified number formatters. * * @param labelFormat the label format string (null not * permitted). * @param numberFormat the format object for the values (null * not permitted). * @param percentFormat the format object for the percentages * (null not permitted). */ public StandardPieToolTipGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat) { super(labelFormat, numberFormat, percentFormat); } /** * Generates a tool tip text item for one section in a pie chart. * * @param dataset the dataset (null not permitted). * @param key the section key (null not permitted). * * @return The tool tip text (possibly null). */ public String generateToolTip(PieDataset dataset, Comparable key) { return generateSectionLabel(dataset, key); } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java0000644000175000017500000001653711173030414032221 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * StandardXYItemLabelGenerator.java * --------------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 16-Jan-2002 : Completed Javadocs (DG); * 02-Apr-2002 : Modified to handle null y-values (DG); * 09-Apr-2002 : Added formatting objects for the x and y values (DG); * 30-May-2002 : Added series name to standard tool tip (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 23-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 17-Nov-2003 : Implemented PublicCloneable (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator and * StandardXYToolTipGenerator --> * StandardXYItemLabelGenerator (DG); * 26-Feb-2004 : Modified to use MessageFormat (DG); * 27-Feb-2004 : Added abstract superclass (DG); * 11-May-2004 : Split into StandardXYToolTipGenerator and * StandardXYLabelGenerator (DG); * 20-Apr-2005 : Renamed StandardXYLabelGenerator * --> StandardXYItemLabelGenerator (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 25-Jan-2007 : Added new constructor - see bug 1624067 (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A standard item label generator for plots that use data from an * {@link org.jfree.data.xy.XYDataset}. */ public class StandardXYItemLabelGenerator extends AbstractXYItemLabelGenerator implements XYItemLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7807668053171837925L; /** The default item label format. */ public static final String DEFAULT_ITEM_LABEL_FORMAT = "{2}"; /** * Creates an item label generator using default number formatters. */ public StandardXYItemLabelGenerator() { this(DEFAULT_ITEM_LABEL_FORMAT, NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()); } /** * Creates an item label generator using the specified number formatters. * * @param formatString the item label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public StandardXYItemLabelGenerator(String formatString, NumberFormat xFormat, NumberFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates an item label generator using the specified formatters. * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public StandardXYItemLabelGenerator(String formatString, DateFormat xFormat, NumberFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates an item label generator using the specified formatters (a * number formatter for the x-values and a date formatter for the * y-values). * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * permitted). * @param yFormat the format object for the y values (null * not permitted). * * @since 1.0.4 */ public StandardXYItemLabelGenerator(String formatString, NumberFormat xFormat, DateFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates a label generator using the specified date formatters. * * @param formatString the label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public StandardXYItemLabelGenerator(String formatString, DateFormat xFormat, DateFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Generates the item label text for an item in a dataset. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The label text (possibly null). */ public String generateLabel(XYDataset dataset, int series, int item) { return generateLabelString(dataset, series, item); } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYItemLabelGenerator)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java0000644000175000017500000001317011173030414032543 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * StandardXYSeriesLabelGenerator.java * ----------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Nov-2004 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Nov-2006 : Fixed equals() method and updated API docs (DG); * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.MessageFormat; import org.jfree.chart.HashUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A standard series label generator for plots that use data from * an {@link org.jfree.data.xy.XYDataset}. *

* This class implements PublicCloneable by mistake but we retain * this for the sake of backward compatibility. */ public class StandardXYSeriesLabelGenerator implements XYSeriesLabelGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1916017081848400024L; /** The default item label format. */ public static final String DEFAULT_LABEL_FORMAT = "{0}"; /** The format pattern. */ private String formatPattern; /** * Creates a default series label generator (uses * {@link #DEFAULT_LABEL_FORMAT}). */ public StandardXYSeriesLabelGenerator() { this(DEFAULT_LABEL_FORMAT); } /** * Creates a new series label generator. * * @param format the format pattern (null not permitted). */ public StandardXYSeriesLabelGenerator(String format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.formatPattern = format; } /** * Generates a label for the specified series. This label will be * used for the chart legend. * * @param dataset the dataset (null not permitted). * @param series the series. * * @return A series label. */ public String generateLabel(XYDataset dataset, int series) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } String label = MessageFormat.format( this.formatPattern, createItemArray(dataset, series) ); return label; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(XYDataset dataset, int series) { Object[] result = new Object[1]; result[0] = dataset.getSeriesKey(series).toString(); return result; } /** * Returns an independent copy of the generator. This is unnecessary, * because instances are immutable anyway, but we retain this * behaviour for backwards compatibility. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYSeriesLabelGenerator)) { return false; } StandardXYSeriesLabelGenerator that = (StandardXYSeriesLabelGenerator) obj; if (!this.formatPattern.equals(that.formatPattern)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; result = HashUtilities.hashCode(result, this.formatPattern); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardXYToolTipGenerator.java0000644000175000017500000001551511173030414031750 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * StandardXYToolTipGenerator.java * ------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-May-2004 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 25-Jan-2007 : Added new constructor - see bug 1624067 (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A standard tool tip generator for use with an * {@link org.jfree.chart.renderer.xy.XYItemRenderer}. */ public class StandardXYToolTipGenerator extends AbstractXYItemLabelGenerator implements XYToolTipGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3564164459039540784L; /** The default tooltip format. */ public static final String DEFAULT_TOOL_TIP_FORMAT = "{0}: ({1}, {2})"; /** * Returns a tool tip generator that formats the x-values as dates and the * y-values as numbers. * * @return A tool tip generator (never null). */ public static StandardXYToolTipGenerator getTimeSeriesInstance() { return new StandardXYToolTipGenerator(DEFAULT_TOOL_TIP_FORMAT, DateFormat.getInstance(), NumberFormat.getInstance()); } /** * Creates a tool tip generator using default number formatters. */ public StandardXYToolTipGenerator() { this(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance()); } /** * Creates a tool tip generator using the specified number formatters. * * @param formatString the item label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public StandardXYToolTipGenerator(String formatString, NumberFormat xFormat, NumberFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates a tool tip generator using the specified number formatters. * * @param formatString the label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public StandardXYToolTipGenerator(String formatString, DateFormat xFormat, NumberFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates a tool tip generator using the specified formatters (a * number formatter for the x-values and a date formatter for the * y-values). * * @param formatString the item label format string (null * not permitted). * @param xFormat the format object for the x values (null * permitted). * @param yFormat the format object for the y values (null * not permitted). * * @since 1.0.4 */ public StandardXYToolTipGenerator(String formatString, NumberFormat xFormat, DateFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Creates a tool tip generator using the specified date formatters. * * @param formatString the label format string (null not * permitted). * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). */ public StandardXYToolTipGenerator(String formatString, DateFormat xFormat, DateFormat yFormat) { super(formatString, xFormat, yFormat); } /** * Generates the tool tip text for an item in a dataset. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The tooltip text (possibly null). */ public String generateToolTip(XYDataset dataset, int series, int item) { return generateLabelString(dataset, series, item); } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYToolTipGenerator)) { return false; } return super.equals(obj); } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/StandardXYZToolTipGenerator.java0000644000175000017500000002134311173030414032076 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * StandardXYZToolTipGenerator.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2003 : Version 1, split from StandardXYZItemLabelGenerator (DG); * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import java.text.DateFormat; import java.text.MessageFormat; import java.text.NumberFormat; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; import org.jfree.util.ObjectUtilities; /** * A standard item label generator for use with {@link XYZDataset} data. Each * value can be formatted as a number or as a date. */ public class StandardXYZToolTipGenerator extends StandardXYToolTipGenerator implements XYZToolTipGenerator, Serializable { /** For serialization. */ private static final long serialVersionUID = -2961577421889473503L; /** The default tooltip format. */ public static final String DEFAULT_TOOL_TIP_FORMAT = "{0}: ({1}, {2}, {3})"; /** * A number formatter for the z value - if this is null, then zDateFormat * must be non-null. */ private NumberFormat zFormat; /** * A date formatter for the z-value - if this is null, then zFormat must be * non-null. */ private DateFormat zDateFormat; /** * Creates a new tool tip generator using default number formatters for the * x, y and z-values. */ public StandardXYZToolTipGenerator() { this( DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance() ); } /** * Constructs a new tool tip generator using the specified number * formatters. * * @param formatString the format string. * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). * @param zFormat the format object for the z values (null * not permitted). */ public StandardXYZToolTipGenerator(String formatString, NumberFormat xFormat, NumberFormat yFormat, NumberFormat zFormat) { super(formatString, xFormat, yFormat); if (zFormat == null) { throw new IllegalArgumentException("Null 'zFormat' argument."); } this.zFormat = zFormat; } /** * Constructs a new tool tip generator using the specified date formatters. * * @param formatString the format string. * @param xFormat the format object for the x values (null * not permitted). * @param yFormat the format object for the y values (null * not permitted). * @param zFormat the format object for the z values (null * not permitted). */ public StandardXYZToolTipGenerator(String formatString, DateFormat xFormat, DateFormat yFormat, DateFormat zFormat) { super(formatString, xFormat, yFormat); if (zFormat == null) { throw new IllegalArgumentException("Null 'zFormat' argument."); } this.zDateFormat = zFormat; } // TODO: add constructors for combinations of number and date formatters. /** * Returns the number formatter for the z-values. * * @return The number formatter (possibly null). */ public NumberFormat getZFormat() { return this.zFormat; } /** * Returns the date formatter for the z-values. * * @return The date formatter (possibly null). */ public DateFormat getZDateFormat() { return this.zDateFormat; } /** * Generates a tool tip text item for a particular item within a series. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The tooltip text (possibly null). */ public String generateToolTip(XYZDataset dataset, int series, int item) { return generateLabelString(dataset, series, item); } /** * Generates a label string for an item in the dataset. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The label (possibly null). */ public String generateLabelString(XYDataset dataset, int series, int item) { String result = null; Object[] items = createItemArray((XYZDataset) dataset, series, item); result = MessageFormat.format(getFormatString(), items); return result; } /** * Creates the array of items that can be passed to the * {@link MessageFormat} class for creating labels. * * @param dataset the dataset (null not permitted). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The items (never null). */ protected Object[] createItemArray(XYZDataset dataset, int series, int item) { Object[] result = new Object[4]; result[0] = dataset.getSeriesKey(series).toString(); Number x = dataset.getX(series, item); DateFormat xf = getXDateFormat(); if (xf != null) { result[1] = xf.format(x); } else { result[1] = getXFormat().format(x); } Number y = dataset.getY(series, item); DateFormat yf = getYDateFormat(); if (yf != null) { result[2] = yf.format(y); } else { result[2] = getYFormat().format(y); } Number z = dataset.getZ(series, item); if (this.zDateFormat != null) { result[3] = this.zDateFormat.format(z); } else { result[3] = this.zFormat.format(z); } return result; } /** * Tests this object for equality with an arbitrary object. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYZToolTipGenerator)) { return false; } if (!super.equals(obj)) { return false; } StandardXYZToolTipGenerator that = (StandardXYZToolTipGenerator) obj; if (!ObjectUtilities.equal(this.zFormat, that.zFormat)) { return false; } if (!ObjectUtilities.equal(this.zDateFormat, that.zDateFormat)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/SymbolicXYItemLabelGenerator.java0000644000175000017500000001355211173030414032234 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * SymbolicXYItemLabelGenerator.java * --------------------------------- * (C) Copyright 2001-2008, by Anthony Boulestreau and Contributors. * * Original Author: Anthony Boulestreau; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 29-Mar-2002 : Version 1, contributed by Anthony Boulestreau (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 23-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 17-Nov-2003 : Implemented PublicCloneable (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 19-Jan-2005 : Now accesses primitives only from dataset (DG); * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); * */ package org.jfree.chart.labels; import java.io.Serializable; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XisSymbolic; import org.jfree.data.xy.YisSymbolic; import org.jfree.util.PublicCloneable; /** * A standard item label generator for plots that use data from an * {@link XYDataset}. */ public class SymbolicXYItemLabelGenerator implements XYItemLabelGenerator, XYToolTipGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3963400354475494395L; /** * Generates a tool tip text item for a particular item within a series. * * @param data the dataset. * @param series the series number (zero-based index). * @param item the item number (zero-based index). * * @return The tool tip text (possibly null). */ public String generateToolTip(XYDataset data, int series, int item) { String xStr, yStr; if (data instanceof YisSymbolic) { yStr = ((YisSymbolic) data).getYSymbolicValue(series, item); } else { double y = data.getYValue(series, item); yStr = Double.toString(round(y, 2)); } if (data instanceof XisSymbolic) { xStr = ((XisSymbolic) data).getXSymbolicValue(series, item); } else if (data instanceof TimeSeriesCollection) { RegularTimePeriod p = ((TimeSeriesCollection) data).getSeries(series) .getTimePeriod(item); xStr = p.toString(); } else { double x = data.getXValue(series, item); xStr = Double.toString(round(x, 2)); } return "X: " + xStr + ", Y: " + yStr; } /** * Generates a label for the specified item. The label is typically a * formatted version of the data value, but any text can be used. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param category the category index (zero-based). * * @return The label (possibly null). */ public String generateLabel(XYDataset dataset, int series, int category) { return null; //TODO: implement this method properly } /** * Round a double value. * * @param value the value. * @param nb the exponent. * * @return The rounded value. */ private static double round(double value, int nb) { if (nb <= 0) { return Math.floor(value + 0.5d); } double p = Math.pow(10, nb); double tempval = Math.floor(value * p + 0.5d); return tempval / p; } /** * Returns an independent copy of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof SymbolicXYItemLabelGenerator) { return true; } return false; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 127; return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/XYItemLabelGenerator.java0000644000175000017500000000524211173030414030527 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYItemLabelGenerator.java * ------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 16-Jan-2002 : Completed Javadocs (DG); * 13-Jun-2002 : Correction to Javadoc comments (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 15-Apr-2004 : Moved the generateToolTip() method to a separate * interface (DG); * 11-May-2004 : Renamed XYItemLabelGenerator --> XYLabelGenerator (DG); * 20-Apr-2005 : Reverted name change of 11-May-2004 (DG); * */ package org.jfree.chart.labels; import org.jfree.data.xy.XYDataset; /** * Interface for a label generator for plots that use data from an * {@link XYDataset}. */ public interface XYItemLabelGenerator { /** * Generates a label for the specified item. The label is typically a * formatted version of the data value, but any text can be used. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The label (possibly null). */ public String generateLabel(XYDataset dataset, int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/XYSeriesLabelGenerator.java0000644000175000017500000000472311173030414031066 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XYSeriesLabelGenerator.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Nov-2004 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Nov-2006 : Updated API docs (DG); * */ package org.jfree.chart.labels; import org.jfree.data.xy.XYDataset; /** * A generator that creates labels for the series in an {@link XYDataset}. *

* Classes that implement this interface should be either (a) immutable, or * (b) cloneable via the PublicCloneable interface (defined in * the JCommon class library). This provides a mechanism for the referring * renderer to clone the generator if necessary. */ public interface XYSeriesLabelGenerator { /** * Generates a label for the specified series. This label will be * used for the chart legend. * * @param dataset the dataset (null not permitted). * @param series the series. * * @return A series label. */ public String generateLabel(XYDataset dataset, int series); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/XYToolTipGenerator.java0000644000175000017500000000440511173030414030263 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYToolTipGenerator.java * ----------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Apr-2004 : Extracted the generateToolTip() method from the * XYItemLabelGenerator interface and put it into this new * interface (DG); * */ package org.jfree.chart.labels; import org.jfree.data.xy.XYDataset; /** * Interface for a tooltip generator for plots that use data from an * {@link XYDataset}. */ public interface XYToolTipGenerator { /** * Generates the tooltip text for the specified item. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The tooltip text (possibly null). */ public String generateToolTip(XYDataset dataset, int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/XYZToolTipGenerator.java0000644000175000017500000000446411173030414030422 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYZToolTipGenerator.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Feb-2003 : Version 1 (DG); * 25-Feb-2004 : Renamed XYZToolTipGenerator --> XYZItemLabelGenerator (DG); * 11-May-2004 : Reverted to XYZToolTipGenerator (DG); * */ package org.jfree.chart.labels; import org.jfree.data.xy.XYZDataset; /** * Interface for a tooltip generator for plots that use data from an * {@link XYZDataset}. */ public interface XYZToolTipGenerator extends XYToolTipGenerator { /** * Generates a tool tip text item for a particular item within a series. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The tooltip text (possibly null). */ public String generateToolTip(XYZDataset dataset, int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/labels/package.html0000644000175000017500000000027311173030414026156 0ustar vincentvincent Generators and other classes used for the display of item labels and tooltips. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/0000755000175000017500000000000011216245561023676 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/ArrowNeedle.java0000644000175000017500000001301611173030414026740 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ArrowNeedle.java * ---------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Added hashCode() implementation (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.HashUtilities; /** * A needle in the shape of an arrow. */ public class ArrowNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -5334056511213782357L; /** * A flag controlling whether or not there is an arrow at the top of the * needle. */ private boolean isArrowAtTop = true; /** * Constructs a new arrow needle. * * @param isArrowAtTop a flag that controls whether or not there is an * arrow at the top of the needle. */ public ArrowNeedle(boolean isArrowAtTop) { this.isArrowAtTop = isArrowAtTop; } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { Line2D shape = new Line2D.Float(); Shape d = null; float x = (float) (plotArea.getMinX() + (plotArea.getWidth() / 2)); float minY = (float) plotArea.getMinY(); float maxY = (float) plotArea.getMaxY(); shape.setLine(x, minY, x, maxY); GeneralPath shape1 = new GeneralPath(); if (this.isArrowAtTop) { shape1.moveTo(x, minY); minY += 4 * getSize(); } else { shape1.moveTo(x, maxY); minY = maxY - 4 * getSize(); } shape1.lineTo(x + getSize(), minY); shape1.lineTo(x - getSize(), minY); shape1.closePath(); if ((rotate != null) && (angle != 0)) { getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); d = getTransform().createTransformedShape(shape); } else { d = shape; } defaultDisplay(g2, d); if ((rotate != null) && (angle != 0)) { d = getTransform().createTransformedShape(shape1); } else { d = shape1; } defaultDisplay(g2, d); } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ArrowNeedle)) { return false; } if (!super.equals(obj)) { return false; } ArrowNeedle that = (ArrowNeedle) obj; if (this.isArrowAtTop != that.isArrowAtTop) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = HashUtilities.hashCode(result, this.isArrowAtTop); return result; } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the ArrowNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/LineNeedle.java0000644000175000017500000001001711173030414026533 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * LineNeedle.java * --------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Added hashCode() implementation (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle that is represented by a line. */ public class LineNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 6215321387896748945L; /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { Line2D shape = new Line2D.Double(); double x = plotArea.getMinX() + (plotArea.getWidth() / 2); shape.setLine(x, plotArea.getMinY(), x, plotArea.getMaxY()); Shape s = shape; if ((rotate != null) && (angle != 0)) { /// we have rotation getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); s = getTransform().createTransformedShape(s); } defaultDisplay(g2, s); } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LineNeedle)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the LineNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/LongNeedle.java0000644000175000017500000001342611173030414026552 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * LongNeedle.java * --------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 16-Mar-2004 : Implemented Rotation; * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle that is represented by a long line. */ public class LongNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4319985779783688159L; /** * Default constructor. */ public LongNeedle() { super(); setRotateY(0.8); } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { GeneralPath shape1 = new GeneralPath(); GeneralPath shape2 = new GeneralPath(); GeneralPath shape3 = new GeneralPath(); float minX = (float) plotArea.getMinX(); float minY = (float) plotArea.getMinY(); float maxX = (float) plotArea.getMaxX(); float maxY = (float) plotArea.getMaxY(); //float midX = (float) (minX + (plotArea.getWidth() * getRotateX())); //float midY = (float) (minY + (plotArea.getHeight() * getRotateY())); float midX = (float) (minX + (plotArea.getWidth() * 0.5)); float midY = (float) (minY + (plotArea.getHeight() * 0.8)); float y = maxY - (2 * (maxY - midY)); if (y < minY) { y = minY; } shape1.moveTo(minX, midY); shape1.lineTo(midX, minY); shape1.lineTo(midX, y); shape1.closePath(); shape2.moveTo(maxX, midY); shape2.lineTo(midX, minY); shape2.lineTo(midX, y); shape2.closePath(); shape3.moveTo(minX, midY); shape3.lineTo(midX, maxY); shape3.lineTo(maxX, midY); shape3.lineTo(midX, y); shape3.closePath(); Shape s1 = shape1; Shape s2 = shape2; Shape s3 = shape3; if ((rotate != null) && (angle != 0)) { /// we have rotation huston, please spin me getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); s1 = shape1.createTransformedShape(transform); s2 = shape2.createTransformedShape(transform); s3 = shape3.createTransformedShape(transform); } if (getHighlightPaint() != null) { g2.setPaint(getHighlightPaint()); g2.fill(s3); } if (getFillPaint() != null) { g2.setPaint(getFillPaint()); g2.fill(s1); g2.fill(s2); } if (getOutlinePaint() != null) { g2.setStroke(getOutlineStroke()); g2.setPaint(getOutlinePaint()); g2.draw(s1); g2.draw(s2); g2.draw(s3); } } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LongNeedle)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the LongNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/MeterNeedle.java0000644000175000017500000002771011173030414026730 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * MeterNeedle.java * ---------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * Nicolas Brodu (for Astrium and EADS Corporate Research * Center); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 07-Nov-2002 : Fixed errors reported by Checkstyle (DG); * 01-Sep-2003 : Implemented Serialization (NB); * 16-Mar-2004 : Changed transform from private to protected (BRS); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * The base class used to represent the needle on a * {@link org.jfree.chart.plot.CompassPlot}. */ public abstract class MeterNeedle implements Serializable { /** For serialization. */ private static final long serialVersionUID = 5203064851510951052L; /** The outline paint. */ private transient Paint outlinePaint = Color.black; /** The outline stroke. */ private transient Stroke outlineStroke = new BasicStroke(2); /** The fill paint. */ private transient Paint fillPaint = null; /** The highlight paint. */ private transient Paint highlightPaint = null; /** The size. */ private int size = 5; /** Scalar to aply to locate the rotation x point. */ private double rotateX = 0.5; /** Scalar to aply to locate the rotation y point. */ private double rotateY = 0.5; /** A transform. */ protected static AffineTransform transform = new AffineTransform(); /** * Creates a new needle. */ public MeterNeedle() { this(null, null, null); } /** * Creates a new needle. * * @param outline the outline paint (null permitted). * @param fill the fill paint (null permitted). * @param highlight the highlight paint (null permitted). */ public MeterNeedle(Paint outline, Paint fill, Paint highlight) { this.fillPaint = fill; this.highlightPaint = highlight; this.outlinePaint = outline; } /** * Returns the outline paint. * * @return The outline paint. */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint. * * @param p the new paint. */ public void setOutlinePaint(Paint p) { if (p != null) { this.outlinePaint = p; } } /** * Returns the outline stroke. * * @return The outline stroke. */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the outline stroke. * * @param s the new stroke. */ public void setOutlineStroke(Stroke s) { if (s != null) { this.outlineStroke = s; } } /** * Returns the fill paint. * * @return The fill paint. */ public Paint getFillPaint() { return this.fillPaint; } /** * Sets the fill paint. * * @param p the fill paint. */ public void setFillPaint(Paint p) { if (p != null) { this.fillPaint = p; } } /** * Returns the highlight paint. * * @return The highlight paint. */ public Paint getHighlightPaint() { return this.highlightPaint; } /** * Sets the highlight paint. * * @param p the highlight paint. */ public void setHighlightPaint(Paint p) { if (p != null) { this.highlightPaint = p; } } /** * Returns the scalar used for determining the rotation x value. * * @return The x rotate scalar. */ public double getRotateX() { return this.rotateX; } /** * Sets the rotateX value. * * @param x the new value. */ public void setRotateX(double x) { this.rotateX = x; } /** * Sets the rotateY value. * * @param y the new value. */ public void setRotateY(double y) { this.rotateY = y; } /** * Returns the scalar used for determining the rotation y value. * * @return The y rotate scalar. */ public double getRotateY() { return this.rotateY; } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. */ public void draw(Graphics2D g2, Rectangle2D plotArea) { draw(g2, plotArea, 0); } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param angle the angle. */ public void draw(Graphics2D g2, Rectangle2D plotArea, double angle) { Point2D.Double pt = new Point2D.Double(); pt.setLocation( plotArea.getMinX() + this.rotateX * plotArea.getWidth(), plotArea.getMinY() + this.rotateY * plotArea.getHeight() ); draw(g2, plotArea, pt, angle); } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { Paint savePaint = g2.getColor(); Stroke saveStroke = g2.getStroke(); drawNeedle(g2, plotArea, rotate, Math.toRadians(angle)); g2.setStroke(saveStroke); g2.setPaint(savePaint); } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected abstract void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle); /** * Displays a shape. * * @param g2 the graphics device. * @param shape the shape. */ protected void defaultDisplay(Graphics2D g2, Shape shape) { if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(shape); } if (this.outlinePaint != null) { g2.setStroke(this.outlineStroke); g2.setPaint(this.outlinePaint); g2.draw(shape); } } /** * Returns the size. * * @return The size. */ public int getSize() { return this.size; } /** * Sets the size. * * @param pixels the new size. */ public void setSize(int pixels) { this.size = pixels; } /** * Returns the transform. * * @return The transform. */ public AffineTransform getTransform() { return MeterNeedle.transform; } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MeterNeedle)) { return false; } MeterNeedle that = (MeterNeedle) obj; if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } if (!PaintUtilities.equal(this.highlightPaint, that.highlightPaint)) { return false; } if (this.size != that.size) { return false; } if (this.rotateX != that.rotateX) { return false; } if (this.rotateY != that.rotateY) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = HashUtilities.hashCode(193, this.fillPaint); result = HashUtilities.hashCode(result, this.highlightPaint); result = HashUtilities.hashCode(result, this.outlinePaint); result = HashUtilities.hashCode(result, this.outlineStroke); result = HashUtilities.hashCode(result, this.rotateX); result = HashUtilities.hashCode(result, this.rotateY); result = HashUtilities.hashCode(result, this.size); return result; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writePaint(this.fillPaint, stream); SerialUtilities.writePaint(this.highlightPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.outlineStroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.fillPaint = SerialUtilities.readPaint(stream); this.highlightPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/MiddlePinNeedle.java0000644000175000017500000001154311173030414027516 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * MiddlePinNeedle.java * -------------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle that is drawn as a pin shape. */ public class MiddlePinNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 6237073996403125310L; /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { Area shape; GeneralPath pointer = new GeneralPath(); int minY = (int) (plotArea.getMinY()); //int maxX = (int) (plotArea.getMaxX()); int maxY = (int) (plotArea.getMaxY()); int midY = ((maxY - minY) / 2) + minY; int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2)); //int midY = (int) (plotArea.getMinY() + (plotArea.getHeight() / 2)); int lenX = (int) (plotArea.getWidth() / 10); if (lenX < 2) { lenX = 2; } pointer.moveTo(midX - lenX, midY - lenX); pointer.lineTo(midX + lenX, midY - lenX); pointer.lineTo(midX, minY); pointer.closePath(); lenX = 4 * lenX; Ellipse2D circle = new Ellipse2D.Double(midX - lenX / 2, midY - lenX, lenX, lenX); shape = new Area(circle); shape.add(new Area(pointer)); if ((rotate != null) && (angle != 0)) { /// we have rotation getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); shape.transform(getTransform()); } defaultDisplay(g2, shape); } /** * Tests another object for equality with this object. * * @param object the object to test. * * @return A boolean. */ public boolean equals(Object object) { if (object == null) { return false; } if (object == this) { return true; } if (super.equals(object) && object instanceof MiddlePinNeedle) { return true; } return false; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the MiddlePinNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/PinNeedle.java0000644000175000017500000001137611173030414026403 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * PinNeedle.java * -------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle that is drawn as a pin shape. */ public class PinNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3787089953079863373L; /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { Area shape; GeneralPath pointer = new GeneralPath(); int minY = (int) (plotArea.getMinY()); //int maxX = (int) (plotArea.getMaxX()); int maxY = (int) (plotArea.getMaxY()); int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2)); //int midY = (int) (plotArea.getMinY() + (plotArea.getHeight() / 2)); int lenX = (int) (plotArea.getWidth() / 10); if (lenX < 2) { lenX = 2; } pointer.moveTo(midX - lenX, maxY - lenX); pointer.lineTo(midX + lenX, maxY - lenX); pointer.lineTo(midX, minY + lenX); pointer.closePath(); lenX = 4 * lenX; Ellipse2D circle = new Ellipse2D.Double(midX - lenX / 2, plotArea.getMaxY() - lenX, lenX, lenX); shape = new Area(circle); shape.add(new Area(pointer)); if ((rotate != null) && (angle != 0)) { /// we have rotation getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); shape.transform(getTransform()); } defaultDisplay(g2, shape); } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PinNeedle)) { return false; } if (!super.equals(obj)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the PinNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/PlumNeedle.java0000644000175000017500000001065311173030414026567 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * PlumNeedle.java * --------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.geom.Arc2D; import java.awt.geom.Area; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle for use with the {@link org.jfree.chart.plot.CompassPlot} class. */ public class PlumNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3082660488660600718L; /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { Arc2D shape = new Arc2D.Double(Arc2D.PIE); double radius = plotArea.getHeight(); double halfX = plotArea.getWidth() / 2; double diameter = 2 * radius; shape.setFrame(plotArea.getMinX() + halfX - radius , plotArea.getMinY() - radius, diameter, diameter); radius = Math.toDegrees(Math.asin(halfX / radius)); shape.setAngleStart(270 - radius); shape.setAngleExtent(2 * radius); Area s = new Area(shape); if ((rotate != null) && (angle != 0)) { /// we have rotation houston, please spin me getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); s.transform(getTransform()); } defaultDisplay(g2, s); } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PlumNeedle)) { return false; } if (!super.equals(obj)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the PlumNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/PointerNeedle.java0000644000175000017500000001213211173030414027264 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * PointerNeedle.java * ------------------ * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle in the shape of a pointer, for use with the * {@link org.jfree.chart.plot.CompassPlot} class. */ public class PointerNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4744677345334729606L; /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { GeneralPath shape1 = new GeneralPath(); GeneralPath shape2 = new GeneralPath(); float minX = (float) plotArea.getMinX(); float minY = (float) plotArea.getMinY(); float maxX = (float) plotArea.getMaxX(); float maxY = (float) plotArea.getMaxY(); float midX = (float) (minX + (plotArea.getWidth() / 2)); float midY = (float) (minY + (plotArea.getHeight() / 2)); shape1.moveTo(minX, midY); shape1.lineTo(midX, minY); shape1.lineTo(maxX, midY); shape1.closePath(); shape2.moveTo(minX, midY); shape2.lineTo(midX, maxY); shape2.lineTo(maxX, midY); shape2.closePath(); if ((rotate != null) && (angle != 0)) { /// we have rotation huston, please spin me getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); shape1.transform(getTransform()); shape2.transform(getTransform()); } if (getFillPaint() != null) { g2.setPaint(getFillPaint()); g2.fill(shape1); } if (getHighlightPaint() != null) { g2.setPaint(getHighlightPaint()); g2.fill(shape2); } if (getOutlinePaint() != null) { g2.setStroke(getOutlineStroke()); g2.setPaint(getOutlinePaint()); g2.draw(shape1); g2.draw(shape2); } } /** * Tests another object for equality with this object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PointerNeedle)) { return false; } if (!super.equals(obj)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the PointerNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/ShipNeedle.java0000644000175000017500000001062411173030414026553 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ShipNeedle.java * --------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 09-Sep-2003 : Added equals() method (DG); * 08-Jun-2005 : Implemented Cloneable (DG); * 22-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle in the shape of a ship, for use with the * {@link org.jfree.chart.plot.CompassPlot} class. */ public class ShipNeedle extends MeterNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 149554868169435612L; /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { GeneralPath shape = new GeneralPath(); shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5, Arc2D.OPEN), true); shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5, Arc2D.OPEN), true); shape.closePath(); getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY()); getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3); shape.transform(getTransform()); if ((rotate != null) && (angle != 0)) { /// we have rotation getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); shape.transform(getTransform()); } defaultDisplay(g2, shape); } /** * Tests another object for equality with this object. * * @param object the object to test. * * @return A boolean. */ public boolean equals(Object object) { if (object == null) { return false; } if (object == this) { return true; } if (super.equals(object) && object instanceof ShipNeedle) { return true; } return false; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } /** * Returns a clone of this needle. * * @return A clone. * * @throws CloneNotSupportedException if the ShipNeedle * cannot be cloned (in theory, this should not happen). */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/WindNeedle.java0000644000175000017500000000777411173030414026565 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * WindNeedle.java * --------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 09-Sep-2003 : Added equals() method (DG); * 22-Nov-2007 : Implemented hashCode() (DG) * */ package org.jfree.chart.needle; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A needle that indicates wind direction, for use with the * {@link org.jfree.chart.plot.CompassPlot} class. */ public class WindNeedle extends ArrowNeedle implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2861061368907167834L; /** * Default constructor. */ public WindNeedle() { super(false); // isArrowAtTop } /** * Draws the needle. * * @param g2 the graphics device. * @param plotArea the plot area. * @param rotate the rotation point. * @param angle the angle. */ protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, double angle) { super.drawNeedle(g2, plotArea, rotate, angle); if ((rotate != null) && (plotArea != null)) { int spacing = getSize() * 3; Rectangle2D newArea = new Rectangle2D.Double(); Point2D newRotate = rotate; newArea.setRect(plotArea.getMinX() - spacing, plotArea.getMinY(), plotArea.getWidth(), plotArea.getHeight()); super.drawNeedle(g2, newArea, newRotate, angle); newArea.setRect(plotArea.getMinX() + spacing, plotArea.getMinY(), plotArea.getWidth(), plotArea.getHeight()); super.drawNeedle(g2, newArea, newRotate, angle); } } /** * Tests another object for equality with this object. * * @param object the object to test. * * @return A boolean. */ public boolean equals(Object object) { if (object == null) { return false; } if (object == this) { return true; } if (super.equals(object) && object instanceof WindNeedle) { return true; } return false; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return super.hashCode(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/needle/package.html0000644000175000017500000000033011173030414026142 0ustar vincentvincent A range of objects that can be used to represent the needle on a {@link org.jfree.chart.plot.CompassPlot}. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/panel/0000755000175000017500000000000011216245561023541 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/panel/AbstractOverlay.java0000644000175000017500000001003311173030414027475 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * AbstractOverlay.java * -------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 09-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.panel; import javax.swing.event.EventListenerList; import org.jfree.chart.ChartPanel; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.OverlayChangeEvent; import org.jfree.chart.event.OverlayChangeListener; /** * A base class for implementing overlays for a {@link ChartPanel}. * * @since 1.0.13 */ public class AbstractOverlay { /** Storage for registered change listeners. */ private transient EventListenerList changeListeners; /** * Default constructor. */ public AbstractOverlay() { this.changeListeners = new EventListenerList(); } /** * Registers an object for notification of changes to the overlay. * * @param listener the listener (null not permitted). * * @see #removeChangeListener(OverlayChangeListener) */ public void addChangeListener(OverlayChangeListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.changeListeners.add(OverlayChangeListener.class, listener); } /** * Deregisters an object for notification of changes to the overlay. * * @param listener the listener (null not permitted) * * @see #addChangeListener(OverlayChangeListener) */ public void removeChangeListener(OverlayChangeListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.changeListeners.remove(OverlayChangeListener.class, listener); } /** * Sends a default {@link ChartChangeEvent} to all registered listeners. *

* This method is for convenience only. */ public void fireOverlayChanged() { OverlayChangeEvent event = new OverlayChangeEvent(this); notifyListeners(event); } /** * Sends a {@link ChartChangeEvent} to all registered listeners. * * @param event information about the event that triggered the * notification. */ protected void notifyListeners(OverlayChangeEvent event) { Object[] listeners = this.changeListeners.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == OverlayChangeListener.class) { ((OverlayChangeListener) listeners[i + 1]).overlayChanged( event); } } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/panel/CrosshairOverlay.java0000644000175000017500000004765111173030414027707 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * CrosshairOverlay.java * --------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 09-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.panel; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.Crosshair; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An overlay for a {@link ChartPanel} that draws crosshairs on a plot. * * @since 1.0.13 */ public class CrosshairOverlay extends AbstractOverlay implements Overlay, PropertyChangeListener, PublicCloneable, Cloneable, Serializable { /** Storage for the crosshairs along the x-axis. */ private List xCrosshairs; /** Storage for the crosshairs along the y-axis. */ private List yCrosshairs; /** * Default constructor. */ public CrosshairOverlay() { super(); this.xCrosshairs = new java.util.ArrayList(); this.yCrosshairs = new java.util.ArrayList(); } /** * Adds a crosshair against the domain axis. * * @param crosshair the crosshair. */ public void addDomainCrosshair(Crosshair crosshair) { if (crosshair == null) { throw new IllegalArgumentException("Null 'crosshair' argument."); } this.xCrosshairs.add(crosshair); crosshair.addPropertyChangeListener(this); } public void removeDomainCrosshair(Crosshair crosshair) { if (crosshair == null) { throw new IllegalArgumentException("Null 'crosshair' argument."); } if (this.xCrosshairs.remove(crosshair)) { crosshair.removePropertyChangeListener(this); fireOverlayChanged(); } } public void clearDomainCrosshairs() { if (this.xCrosshairs.isEmpty()) { return; // nothing to do } List crosshairs = getDomainCrosshairs(); for (int i = 0; i < crosshairs.size(); i++) { Crosshair c = (Crosshair) crosshairs.get(i); this.xCrosshairs.remove(c); c.removePropertyChangeListener(this); } fireOverlayChanged(); } public List getDomainCrosshairs() { return new ArrayList(this.xCrosshairs); } /** * Adds a crosshair against the range axis. * * @param crosshair the crosshair. */ public void addRangeCrosshair(Crosshair crosshair) { if (crosshair == null) { throw new IllegalArgumentException("Null 'crosshair' argument."); } this.yCrosshairs.add(crosshair); crosshair.addPropertyChangeListener(this); } public void removeRangeCrosshair(Crosshair crosshair) { if (crosshair == null) { throw new IllegalArgumentException("Null 'crosshair' argument."); } if (this.yCrosshairs.remove(crosshair)) { crosshair.removePropertyChangeListener(this); fireOverlayChanged(); } } public void clearRangeCrosshairs() { if (this.yCrosshairs.isEmpty()) { return; // nothing to do } List crosshairs = getRangeCrosshairs(); for (int i = 0; i < crosshairs.size(); i++) { Crosshair c = (Crosshair) crosshairs.get(i); this.yCrosshairs.remove(c); c.removePropertyChangeListener(this); } fireOverlayChanged(); } public List getRangeCrosshairs() { return new ArrayList(this.yCrosshairs); } /** * Receives a property change event (typically a change in one of the * crosshairs). * * @param e the event. */ public void propertyChange(PropertyChangeEvent e) { fireOverlayChanged(); } /** * Paints the crosshairs in the layer. * * @param g2 the graphics target. * @param chartPanel the chart panel. */ public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); Iterator iterator = this.xCrosshairs.iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double x = ch.getValue(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawVerticalCrosshair(g2, dataArea, xx, ch); } else { drawHorizontalCrosshair(g2, dataArea, xx, ch); } } } ValueAxis yAxis = plot.getRangeAxis(); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); iterator = this.yCrosshairs.iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double y = ch.getValue(); double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawHorizontalCrosshair(g2, dataArea, yy, ch); } else { drawVerticalCrosshair(g2, dataArea, yy, ch); } } } g2.setClip(savedClip); } /** * Draws a crosshair horizontally across the plot. * * @param g2 the graphics target. * @param dataArea the data area. * @param y the y-value in Java2D space. * @param crosshair the crosshair. */ protected void drawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea, double y, Crosshair crosshair) { if (y >= dataArea.getMinY() && y <= dataArea.getMaxY()) { Line2D line = new Line2D.Double(dataArea.getMinX(), y, dataArea.getMaxX(), y); Paint savedPaint = g2.getPaint(); Stroke savedStroke = g2.getStroke(); g2.setPaint(crosshair.getPaint()); g2.setStroke(crosshair.getStroke()); g2.draw(line); if (crosshair.isLabelVisible()) { String label = crosshair.getLabelGenerator().generateLabel( crosshair); RectangleAnchor anchor = crosshair.getLabelAnchor(); Point2D pt = calculateLabelPoint(line, anchor, 5, 5); float xx = (float) pt.getX(); float yy = (float) pt.getY(); TextAnchor alignPt = textAlignPtForLabelAnchorH(anchor); Shape hotspot = TextUtilities.calculateRotatedStringBounds( label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); if (!dataArea.contains(hotspot.getBounds2D())) { anchor = flipAnchorV(anchor); pt = calculateLabelPoint(line, anchor, 5, 5); xx = (float) pt.getX(); yy = (float) pt.getY(); alignPt = textAlignPtForLabelAnchorH(anchor); hotspot = TextUtilities.calculateRotatedStringBounds( label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); } g2.setPaint(crosshair.getLabelBackgroundPaint()); g2.fill(hotspot); g2.setPaint(crosshair.getLabelOutlinePaint()); g2.draw(hotspot); TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt); } g2.setPaint(savedPaint); g2.setStroke(savedStroke); } } /** * Draws a crosshair vertically on the plot. * * @param g2 the graphics target. * @param dataArea the data area. * @param x the x-value in Java2D space. * @param crosshair the crosshair. */ protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea, double x, Crosshair crosshair) { if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) { Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, dataArea.getMaxY()); Paint savedPaint = g2.getPaint(); Stroke savedStroke = g2.getStroke(); g2.setPaint(crosshair.getPaint()); g2.setStroke(crosshair.getStroke()); g2.draw(line); if (crosshair.isLabelVisible()) { String label = crosshair.getLabelGenerator().generateLabel( crosshair); RectangleAnchor anchor = crosshair.getLabelAnchor(); Point2D pt = calculateLabelPoint(line, anchor, 5, 5); float xx = (float) pt.getX(); float yy = (float) pt.getY(); TextAnchor alignPt = textAlignPtForLabelAnchorV(anchor); Shape hotspot = TextUtilities.calculateRotatedStringBounds( label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); if (!dataArea.contains(hotspot.getBounds2D())) { anchor = flipAnchorH(anchor); pt = calculateLabelPoint(line, anchor, 5, 5); xx = (float) pt.getX(); yy = (float) pt.getY(); alignPt = textAlignPtForLabelAnchorV(anchor); hotspot = TextUtilities.calculateRotatedStringBounds( label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); } g2.setPaint(crosshair.getLabelBackgroundPaint()); g2.fill(hotspot); g2.setPaint(crosshair.getLabelOutlinePaint()); g2.draw(hotspot); TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt); } g2.setPaint(savedPaint); g2.setStroke(savedStroke); } } /** * Calculates the anchor point for a label. * * @param line the line for the crosshair. * @param anchor the anchor point. * @param deltaX the x-offset. * @param deltaY the y-offset. * * @return The anchor point. */ private Point2D calculateLabelPoint(Line2D line, RectangleAnchor anchor, double deltaX, double deltaY) { double x = 0.0; double y = 0.0; boolean left = (anchor == RectangleAnchor.BOTTOM_LEFT || anchor == RectangleAnchor.LEFT || anchor == RectangleAnchor.TOP_LEFT); boolean right = (anchor == RectangleAnchor.BOTTOM_RIGHT || anchor == RectangleAnchor.RIGHT || anchor == RectangleAnchor.TOP_RIGHT); boolean top = (anchor == RectangleAnchor.TOP_LEFT || anchor == RectangleAnchor.TOP || anchor == RectangleAnchor.TOP_RIGHT); boolean bottom = (anchor == RectangleAnchor.BOTTOM_LEFT || anchor == RectangleAnchor.BOTTOM || anchor == RectangleAnchor.BOTTOM_RIGHT); Rectangle rect = line.getBounds(); Point2D pt = RectangleAnchor.coordinates(rect, anchor); // we expect the line to be vertical or horizontal if (line.getX1() == line.getX2()) { // vertical x = line.getX1(); y = (line.getY1() + line.getY2()) / 2.0; if (left) { x = x - deltaX; } if (right) { x = x + deltaX; } if (top) { y = Math.min(line.getY1(), line.getY2()) + deltaY; } if (bottom) { y = Math.max(line.getY1(), line.getY2()) - deltaY; } } else { // horizontal x = (line.getX1() + line.getX2()) / 2.0; y = line.getY1(); if (left) { x = Math.min(line.getX1(), line.getX2()) + deltaX; } if (right) { x = Math.max(line.getX1(), line.getX2()) - deltaX; } if (top) { y = y - deltaY; } if (bottom) { y = y + deltaY; } } return new Point2D.Double(x, y); } /** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorV(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.TOP_RIGHT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.BOTTOM_LEFT; } return result; } /** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorH(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.BOTTOM_LEFT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.TOP_RIGHT; } return result; } private RectangleAnchor flipAnchorH(RectangleAnchor anchor) { RectangleAnchor result = anchor; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = RectangleAnchor.TOP_RIGHT; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = RectangleAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = RectangleAnchor.RIGHT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = RectangleAnchor.LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = RectangleAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = RectangleAnchor.BOTTOM_LEFT; } return result; } private RectangleAnchor flipAnchorV(RectangleAnchor anchor) { RectangleAnchor result = anchor; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = RectangleAnchor.BOTTOM_LEFT; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = RectangleAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = RectangleAnchor.BOTTOM; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = RectangleAnchor.TOP; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = RectangleAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = RectangleAnchor.TOP_RIGHT; } return result; } /** * Tests this overlay for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CrosshairOverlay)) { return false; } CrosshairOverlay that = (CrosshairOverlay) obj; if (!this.xCrosshairs.equals(that.xCrosshairs)) { return false; } if (!this.yCrosshairs.equals(that.yCrosshairs)) { return false; } return true; } /** * Returns a clone of this instance. * * @return A clone of this instance. * * @throws java.lang.CloneNotSupportedException if there is some problem * with the cloning. */ public Object clone() throws CloneNotSupportedException { CrosshairOverlay clone = (CrosshairOverlay) super.clone(); clone.xCrosshairs = (List) ObjectUtilities.deepClone(this.xCrosshairs); clone.yCrosshairs = (List) ObjectUtilities.deepClone(this.yCrosshairs); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/panel/Overlay.java0000644000175000017500000000455211173030414026022 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * Overlay.java * ------------ * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 09-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.panel; import java.awt.Graphics2D; import org.jfree.chart.ChartPanel; import org.jfree.chart.event.OverlayChangeListener; /** * Defines the interface for an overlay that can be added to a * {@link ChartPanel}. * * @since 1.0.13 */ public interface Overlay { /** * Paints the crosshairs in the layer. * * @param g2 the graphics target. * @param chartPanel the chart panel. */ public void paintOverlay(Graphics2D g2, ChartPanel chartPanel); /** * Registers a change listener with the overlay. * * @param listener the listener. */ public void addChangeListener(OverlayChangeListener listener); /** * Deregisters a listener from the overlay. * * @param listener the listener. */ public void removeChangeListener(OverlayChangeListener listener); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/panel/package.html0000644000175000017500000000025511173030414026013 0ustar vincentvincent Classes related to the {@link org.jfree.chart.ChartPanel} class. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/0000755000175000017500000000000011216245562023421 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/0000755000175000017500000000000011216245562024332 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/AbstractDialLayer.java0000644000175000017500000001522111173030414030516 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * AbstractDialLayer.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Nov-2006 : Version 1 (DG); * 17-Nov-2006 : Added visible flag (DG); * 16-Oct-2007 : Implemented equals() and clone() (DG); * */ package org.jfree.chart.plot.dial; import java.io.IOException; import java.io.ObjectInputStream; import java.util.Arrays; import java.util.EventListener; import java.util.List; import javax.swing.event.EventListenerList; import org.jfree.chart.HashUtilities; /** * A base class that can be used to implement a {@link DialLayer}. It includes * an event notification mechanism. * * @since 1.0.7 */ public abstract class AbstractDialLayer implements DialLayer { /** A flag that controls whether or not the layer is visible. */ private boolean visible; /** Storage for registered listeners. */ private transient EventListenerList listenerList; /** * Creates a new instance. */ protected AbstractDialLayer() { this.visible = true; this.listenerList = new EventListenerList(); } /** * Returns true if this layer is visible (should be displayed), * and false otherwise. * * @return A boolean. * * @see #setVisible(boolean) */ public boolean isVisible() { return this.visible; } /** * Sets the flag that determines whether or not this layer is drawn by * the plot, and sends a {@link DialLayerChangeEvent} to all registered * listeners. * * @param visible the flag. * * @see #isVisible() */ public void setVisible(boolean visible) { this.visible = visible; notifyListeners(new DialLayerChangeEvent(this)); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractDialLayer)) { return false; } AbstractDialLayer that = (AbstractDialLayer) obj; return this.visible == that.visible; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 23; result = HashUtilities.hashCode(result, this.visible); return result; } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning this * instance. */ public Object clone() throws CloneNotSupportedException { AbstractDialLayer clone = (AbstractDialLayer) super.clone(); // we don't clone the listeners clone.listenerList = new EventListenerList(); return clone; } /** * Registers an object for notification of changes to the dial layer. * * @param listener the object that is being registered. * * @see #removeChangeListener(DialLayerChangeListener) */ public void addChangeListener(DialLayerChangeListener listener) { this.listenerList.add(DialLayerChangeListener.class, listener); } /** * Deregisters an object for notification of changes to the dial layer. * * @param listener the object to deregister. * * @see #addChangeListener(DialLayerChangeListener) */ public void removeChangeListener(DialLayerChangeListener listener) { this.listenerList.remove(DialLayerChangeListener.class, listener); } /** * Returns true if the specified object is registered with * the dataset as a listener. Most applications won't need to call this * method, it exists mainly for use by unit testing code. * * @param listener the listener. * * @return A boolean. */ public boolean hasListener(EventListener listener) { List list = Arrays.asList(this.listenerList.getListenerList()); return list.contains(listener); } /** * Notifies all registered listeners that the dial layer has changed. * The {@link DialLayerChangeEvent} provides information about the change. * * @param event information about the change to the axis. */ protected void notifyListeners(DialLayerChangeEvent event) { Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == DialLayerChangeListener.class) { ((DialLayerChangeListener) listeners[i + 1]).dialLayerChanged( event); } } } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.listenerList = new EventListenerList(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/ArcDialFrame.java0000644000175000017500000003733211173030414027445 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ArcDialFrame.java * ----------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 08-Mar-2007 : Fix in hashCode() (DG); * 17-Oct-2007 : Updated equals() (DG); * 24-Oct-2007 : Added argument checks and API docs, and renamed * StandardDialFrame --> ArcDialFrame (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A standard frame for the {@link DialPlot} class. * * @since 1.0.7 */ public class ArcDialFrame extends AbstractDialLayer implements DialFrame, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -4089176959553523499L; /** * The color used for the front of the panel. This field is transient * because it requires special handling for serialization. */ private transient Paint backgroundPaint; /** * The color used for the border around the window. This field is transient * because it requires special handling for serialization. */ private transient Paint foregroundPaint; /** * The stroke for drawing the frame outline. This field is transient * because it requires special handling for serialization. */ private transient Stroke stroke; /** * The start angle. */ private double startAngle; /** * The end angle. */ private double extent; /** The inner radius, relative to the framing rectangle. */ private double innerRadius; /** The outer radius, relative to the framing rectangle. */ private double outerRadius; /** * Creates a new instance of ArcDialFrame that spans * 180 degrees. */ public ArcDialFrame() { this(0, 180); } /** * Creates a new instance of ArcDialFrame that spans * the arc specified. * * @param startAngle the startAngle (in degrees). * @param extent the extent of the arc (in degrees, counter-clockwise). */ public ArcDialFrame(double startAngle, double extent) { this.backgroundPaint = Color.gray; this.foregroundPaint = new Color(100, 100, 150); this.stroke = new BasicStroke(2.0f); this.innerRadius = 0.25; this.outerRadius = 0.75; this.startAngle = startAngle; this.extent = extent; } /** * Returns the background paint (never null). * * @return The background paint. * * @see #setBackgroundPaint(Paint) */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBackgroundPaint() */ public void setBackgroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.backgroundPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the foreground paint. * * @return The foreground paint (never null). * * @see #setForegroundPaint(Paint) */ public Paint getForegroundPaint() { return this.foregroundPaint; } /** * Sets the foreground paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getForegroundPaint() */ public void setForegroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.foregroundPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the stroke. * * @return The stroke (never null). * * @see #setStroke(Stroke) */ public Stroke getStroke() { return this.stroke; } /** * Sets the stroke and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getStroke() */ public void setStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.stroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the inner radius, relative to the framing rectangle. * * @return The inner radius. * * @see #setInnerRadius(double) */ public double getInnerRadius() { return this.innerRadius; } /** * Sets the inner radius and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param radius the inner radius. * * @see #getInnerRadius() */ public void setInnerRadius(double radius) { if (radius < 0.0) { throw new IllegalArgumentException("Negative 'radius' argument."); } this.innerRadius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the outer radius, relative to the framing rectangle. * * @return The outer radius. * * @see #setOuterRadius(double) */ public double getOuterRadius() { return this.outerRadius; } /** * Sets the outer radius and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param radius the outer radius. * * @see #getOuterRadius() */ public void setOuterRadius(double radius) { if (radius < 0.0) { throw new IllegalArgumentException("Negative 'radius' argument."); } this.outerRadius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the start angle. * * @return The start angle. * * @see #setStartAngle(double) */ public double getStartAngle() { return this.startAngle; } /** * Sets the start angle and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param angle the angle. * * @see #getStartAngle() */ public void setStartAngle(double angle) { this.startAngle = angle; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the extent. * * @return The extent. * * @see #setExtent(double) */ public double getExtent() { return this.extent; } /** * Sets the extent and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param extent the extent. * * @see #getExtent() */ public void setExtent(double extent) { this.extent = extent; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the shape for the window for this dial. Some dial layers will * request that their drawing be clipped within this window. * * @param frame the reference frame (null not permitted). * * @return The shape of the dial's window. */ public Shape getWindow(Rectangle2D frame) { Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame, this.innerRadius, this.innerRadius); Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame, this.outerRadius, this.outerRadius); Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle, this.extent, Arc2D.OPEN); Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle + this.extent, -this.extent, Arc2D.OPEN); GeneralPath p = new GeneralPath(); Point2D point1 = inner.getStartPoint(); p.moveTo((float) point1.getX(), (float) point1.getY()); p.append(inner, true); p.append(outer, true); p.closePath(); return p; } /** * Returns the outer window. * * @param frame the frame. * * @return The outer window. */ protected Shape getOuterWindow(Rectangle2D frame) { double radiusMargin = 0.02; double angleMargin = 1.5; Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame, this.innerRadius - radiusMargin, this.innerRadius - radiusMargin); Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame, this.outerRadius + radiusMargin, this.outerRadius + radiusMargin); Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle - angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN); Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle + angleMargin + this.extent, -this.extent - 2 * angleMargin, Arc2D.OPEN); GeneralPath p = new GeneralPath(); Point2D point1 = inner.getStartPoint(); p.moveTo((float) point1.getX(), (float) point1.getY()); p.append(inner, true); p.append(outer, true); p.closePath(); return p; } /** * Draws the frame. * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame. * @param view the dial's view rectangle. */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Shape window = getWindow(frame); Shape outerWindow = getOuterWindow(frame); Area area1 = new Area(outerWindow); Area area2 = new Area(window); area1.subtract(area2); g2.setPaint(Color.lightGray); g2.fill(area1); g2.setStroke(this.stroke); g2.setPaint(this.foregroundPaint); g2.draw(window); g2.draw(outerWindow); } /** * Returns false to indicate that this dial layer is not * clipped to the dial window. * * @return false. */ public boolean isClippedToWindow() { return false; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ArcDialFrame)) { return false; } ArcDialFrame that = (ArcDialFrame) obj; if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) { return false; } if (this.startAngle != that.startAngle) { return false; } if (this.extent != that.extent) { return false; } if (this.innerRadius != that.innerRadius) { return false; } if (this.outerRadius != that.outerRadius) { return false; } if (!this.stroke.equals(that.stroke)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.startAngle); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.extent); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.innerRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.outerRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + HashUtilities.hashCodeForPaint( this.backgroundPaint); result = 37 * result + HashUtilities.hashCodeForPaint( this.foregroundPaint); result = 37 * result + this.stroke.hashCode(); return result; } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if any attribute of this instance * cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.backgroundPaint, stream); SerialUtilities.writePaint(this.foregroundPaint, stream); SerialUtilities.writeStroke(this.stroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.backgroundPaint = SerialUtilities.readPaint(stream); this.foregroundPaint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialBackground.java0000644000175000017500000002104611173030414030037 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * DialBackground.java * ------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 16-Oct-2007 : The equals() method needs to call super.equals() (DG); * */ package org.jfree.chart.plot.dial; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A regular dial layer that can be used to draw the background for a dial. * * @since 1.0.7 */ public class DialBackground extends AbstractDialLayer implements DialLayer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -9019069533317612375L; /** * The background paint. This field is transient because serialization * requires special handling. */ private transient Paint paint; /** * The transformer used when the background paint is an instance of * GradientPaint. */ private GradientPaintTransformer gradientPaintTransformer; /** * Creates a new instance of DialBackground. The * default background paint is Color.white. */ public DialBackground() { this(Color.white); } /** * Creates a new instance of DialBackground. The * * @param paint the paint (null not permitted). * * @throws IllegalArgumentException if paint is * null. */ public DialBackground(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; this.gradientPaintTransformer = new StandardGradientPaintTransformer(); } /** * Returns the paint used to fill the background. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint for the dial background and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the transformer used to adjust the coordinates of any * GradientPaint instance used for the background paint. * * @return The transformer (never null). * * @see #setGradientPaintTransformer(GradientPaintTransformer) */ public GradientPaintTransformer getGradientPaintTransformer() { return this.gradientPaintTransformer; } /** * Sets the transformer used to adjust the coordinates of any * GradientPaint instance used for the background paint, and * sends a {@link DialLayerChangeEvent} to all registered listeners. * * @param t the transformer (null not permitted). * * @see #getGradientPaintTransformer() */ public void setGradientPaintTransformer(GradientPaintTransformer t) { if (t == null) { throw new IllegalArgumentException("Null 't' argument."); } this.gradientPaintTransformer = t; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Draws the background to the specified graphics device. If the dial * frame specifies a window, the clipping region will already have been * set to this window before this method is called. * * @param g2 the graphics device (null not permitted). * @param plot the plot (ignored here). * @param frame the dial frame (ignored here). * @param view the view rectangle (null not permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Paint p = this.paint; if (p instanceof GradientPaint) { p = this.gradientPaintTransformer.transform((GradientPaint) p, view); } g2.setPaint(p); g2.fill(view); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialBackground)) { return false; } DialBackground that = (DialBackground) obj; if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!this.gradientPaintTransformer.equals( that.gradientPaintTransformer)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); result = 37 * result + this.gradientPaintTransformer.hashCode(); return result; } /** * Returns a clone of this instance. * * @return The clone. * * @throws CloneNotSupportedException if some attribute of this instance * cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialCap.java0000644000175000017500000002474611173030414026475 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * DialCap.java * ------------ * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 17-Oct-2007 : Updated equals() method (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A regular dial layer that can be used to draw a cap over the center of * the dial (the base of the dial pointer(s)). * * @since 1.0.7 */ public class DialCap extends AbstractDialLayer implements DialLayer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -2929484264982524463L; /** * The radius of the cap, as a percentage of the framing rectangle. */ private double radius; /** * The fill paint. This field is transient because it requires special * handling for serialization. */ private transient Paint fillPaint; /** * The paint used to draw the cap outline (this should never be * null). This field is transient because it requires * special handling for serialization. */ private transient Paint outlinePaint; /** * The stroke used to draw the cap outline (this should never be * null). This field is transient because it requires * special handling for serialization. */ private transient Stroke outlineStroke; /** * Creates a new instance of StandardDialBackground. The * default background paint is Color.white. */ public DialCap() { this.radius = 0.05; this.fillPaint = Color.white; this.outlinePaint = Color.black; this.outlineStroke = new BasicStroke(2.0f); } /** * Returns the radius of the cap, as a percentage of the dial's framing * rectangle. * * @return The radius. * * @see #setRadius(double) */ public double getRadius() { return this.radius; } /** * Sets the radius of the cap, as a percentage of the dial's framing * rectangle, and sends a {@link DialLayerChangeEvent} to all registered * listeners. * * @param radius the radius (must be greater than zero). * * @see #getRadius() */ public void setRadius(double radius) { if (radius <= 0.0) { throw new IllegalArgumentException("Requires radius > 0.0."); } this.radius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint used to fill the cap. * * @return The paint (never null). * * @see #setFillPaint(Paint) */ public Paint getFillPaint() { return this.fillPaint; } /** * Sets the paint for the cap background and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getFillPaint() */ public void setFillPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.fillPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint used to draw the outline of the cap. * * @return The paint (never null). * * @see #setOutlinePaint(Paint) */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the paint used to draw the outline of the cap and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getOutlinePaint() */ public void setOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.outlinePaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the stroke used to draw the outline of the cap. * * @return The stroke (never null). * * @see #setOutlineStroke(Stroke) */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the stroke used to draw the outline of the cap and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getOutlineStroke() */ public void setOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.outlineStroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Draws the background to the specified graphics device. If the dial * frame specifies a window, the clipping region will already have been * set to this window before this method is called. * * @param g2 the graphics device (null not permitted). * @param plot the plot (ignored here). * @param frame the dial frame (ignored here). * @param view the view rectangle (null not permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint(this.fillPaint); Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), f.getHeight()); g2.fill(e); g2.setPaint(this.outlinePaint); g2.setStroke(this.outlineStroke); g2.draw(e); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialCap)) { return false; } DialCap that = (DialCap) obj; if (this.radius != that.radius) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!this.outlineStroke.equals(that.outlineStroke)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; result = 37 * result + HashUtilities.hashCodeForPaint(this.fillPaint); result = 37 * result + HashUtilities.hashCodeForPaint( this.outlinePaint); result = 37 * result + this.outlineStroke.hashCode(); return result; } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if some attribute of the cap cannot * be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.fillPaint, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.fillPaint = SerialUtilities.readPaint(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialFrame.java0000644000175000017500000000461711173030414027017 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * DialFrame.java * -------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial; import java.awt.Shape; import java.awt.geom.Rectangle2D; import java.io.Serializable; /** * A dial frame is the face plate for a dial plot - it is always drawn last. * JFreeChart includes a couple of implementations of this interface * ({@link StandardDialFrame} and {@link ArcDialFrame}). *

* Classes that implement this interface should be {@link Serializable}, * otherwise chart serialization may fail. * * @since 1.0.7 */ public interface DialFrame extends DialLayer { /** * Returns the shape of the viewing window for the dial, or * null if the dial is completely open. Other layers in the * plot will rely on their drawing to be clipped within this window. * * @param frame the reference frame for the dial. * * @return The window. */ public Shape getWindow(Rectangle2D frame); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialLayer.java0000644000175000017500000000762211173030414027040 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * DialLayer.java * -------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.EventListener; /** * A dial layer draws itself within a reference frame. The view frame is a * subset of the reference frame, and defines the area that is actually * visible. *

* Classes that implement this interface should be {@link Serializable}, * otherwise chart serialization may fail. * * @since 1.0.7 */ public interface DialLayer { /** * Returns a flag that indicates whether or not the layer is visible. * * @return A boolean. */ public boolean isVisible(); /** * Registers a listener with this layer, so that it receives notification * of changes to this layer. * * @param listener the listener. */ public void addChangeListener(DialLayerChangeListener listener); /** * Deregisters a listener, so that it no longer receives notification of * changes to this layer. * * @param listener the listener. */ public void removeChangeListener(DialLayerChangeListener listener); /** * Returns true if the specified listener is currently * registered with the this layer. * * @param listener the listener. * * @return A boolean. */ public boolean hasListener(EventListener listener); /** * Returns true if the drawing should be clipped to the * dial window (which is defined by the {@link DialFrame}), and * false otherwise. * * @return A boolean. */ public boolean isClippedToWindow(); /** * Draws the content of this layer. * * @param g2 the graphics target (null not permitted). * @param plot the plot (typically this should not be null, * but for a layer that doesn't need to reference the plot, it may * be permitted). * @param frame the reference frame for the dial's geometry * (null not permitted). This is typically larger than * the visible area of the dial (see the next parameter). * @param view the visible area for the dial (null not * permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialLayerChangeEvent.java0000644000175000017500000000451011173030414031141 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * DialLayerChangeEvent.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial; import org.jfree.chart.event.ChartChangeEvent; /** * An event that can be forwarded to any {@link DialLayerChangeListener} to * signal a change to a {@link DialLayer}. * * @since 1.0.7 */ public class DialLayerChangeEvent extends ChartChangeEvent { /** The dial layer that generated the event. */ private DialLayer layer; /** * Creates a new instance. * * @param layer the dial layer that generated the event. */ public DialLayerChangeEvent(DialLayer layer) { super(layer); this.layer = layer; } /** * Returns the layer that generated the event. * * @return The layer that generated the event. */ public DialLayer getDialLayer() { return this.layer; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialLayerChangeListener.java0000644000175000017500000000410611173030414031646 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DialLayerChangeListener.java * ---------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial; import java.util.EventListener; /** * The interface via which an object is notified of changes to a * {@link DialLayer}. The {@link DialPlot} class listens for changes to its * layers in this way. * * @since 1.0.7 */ public interface DialLayerChangeListener extends EventListener { /** * A call-back method for receiving notification of a change to a * {@link DialLayer}. * * @param event the event. */ public void dialLayerChanged(DialLayerChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialPlot.java0000644000175000017500000006234111173030414026701 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * DialPlot.java * ------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 08-Mar-2007 : Fix in hashCode() (DG); * 17-Oct-2007 : Fixed listener registration/deregistration bugs (DG); * 24-Oct-2007 : Maintain pointers in their own list, so they can be * drawn after other layers (DG); * 15-Feb-2007 : Fixed clipping bug (1873160) (DG); * */ package org.jfree.chart.plot.dial; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Iterator; import java.util.List; import org.jfree.chart.JFreeChart; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.PlotState; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.ValueDataset; import org.jfree.util.ObjectList; import org.jfree.util.ObjectUtilities; /** * A dial plot composed of user-definable layers. * The example shown here is generated by the DialDemo2.java * program included in the JFreeChart Demo Collection: *

* DialPlotSample.png * * @since 1.0.7 */ public class DialPlot extends Plot implements DialLayerChangeListener { /** * The background layer (optional). */ private DialLayer background; /** * The needle cap (optional). */ private DialLayer cap; /** * The dial frame. */ private DialFrame dialFrame; /** * The dataset(s) for the dial plot. */ private ObjectList datasets; /** * The scale(s) for the dial plot. */ private ObjectList scales; /** Storage for keys that map datasets to scales. */ private ObjectList datasetToScaleMap; /** * The drawing layers for the dial plot. */ private List layers; /** * The pointer(s) for the dial. */ private List pointers; /** * The x-coordinate for the view window. */ private double viewX; /** * The y-coordinate for the view window. */ private double viewY; /** * The width of the view window, expressed as a percentage. */ private double viewW; /** * The height of the view window, expressed as a percentage. */ private double viewH; /** * Creates a new instance of DialPlot. */ public DialPlot() { this(null); } /** * Creates a new instance of DialPlot. * * @param dataset the dataset (null permitted). */ public DialPlot(ValueDataset dataset) { this.background = null; this.cap = null; this.dialFrame = new ArcDialFrame(); this.datasets = new ObjectList(); if (dataset != null) { setDataset(dataset); } this.scales = new ObjectList(); this.datasetToScaleMap = new ObjectList(); this.layers = new java.util.ArrayList(); this.pointers = new java.util.ArrayList(); this.viewX = 0.0; this.viewY = 0.0; this.viewW = 1.0; this.viewH = 1.0; } /** * Returns the background. * * @return The background (possibly null). * * @see #setBackground(DialLayer) */ public DialLayer getBackground() { return this.background; } /** * Sets the background layer and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param background the background layer (null permitted). * * @see #getBackground() */ public void setBackground(DialLayer background) { if (this.background != null) { this.background.removeChangeListener(this); } this.background = background; if (background != null) { background.addChangeListener(this); } fireChangeEvent(); } /** * Returns the cap. * * @return The cap (possibly null). * * @see #setCap(DialLayer) */ public DialLayer getCap() { return this.cap; } /** * Sets the cap and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param cap the cap (null permitted). * * @see #getCap() */ public void setCap(DialLayer cap) { if (this.cap != null) { this.cap.removeChangeListener(this); } this.cap = cap; if (cap != null) { cap.addChangeListener(this); } fireChangeEvent(); } /** * Returns the dial's frame. * * @return The dial's frame (never null). * * @see #setDialFrame(DialFrame) */ public DialFrame getDialFrame() { return this.dialFrame; } /** * Sets the dial's frame and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param frame the frame (null not permitted). * * @see #getDialFrame() */ public void setDialFrame(DialFrame frame) { if (frame == null) { throw new IllegalArgumentException("Null 'frame' argument."); } this.dialFrame.removeChangeListener(this); this.dialFrame = frame; frame.addChangeListener(this); fireChangeEvent(); } /** * Returns the x-coordinate of the viewing rectangle. This is specified * in the range 0.0 to 1.0, relative to the dial's framing rectangle. * * @return The x-coordinate of the viewing rectangle. * * @see #setView(double, double, double, double) */ public double getViewX() { return this.viewX; } /** * Returns the y-coordinate of the viewing rectangle. This is specified * in the range 0.0 to 1.0, relative to the dial's framing rectangle. * * @return The y-coordinate of the viewing rectangle. * * @see #setView(double, double, double, double) */ public double getViewY() { return this.viewY; } /** * Returns the width of the viewing rectangle. This is specified * in the range 0.0 to 1.0, relative to the dial's framing rectangle. * * @return The width of the viewing rectangle. * * @see #setView(double, double, double, double) */ public double getViewWidth() { return this.viewW; } /** * Returns the height of the viewing rectangle. This is specified * in the range 0.0 to 1.0, relative to the dial's framing rectangle. * * @return The height of the viewing rectangle. * * @see #setView(double, double, double, double) */ public double getViewHeight() { return this.viewH; } /** * Sets the viewing rectangle, relative to the dial's framing rectangle, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param x the x-coordinate (in the range 0.0 to 1.0). * @param y the y-coordinate (in the range 0.0 to 1.0). * @param w the width (in the range 0.0 to 1.0). * @param h the height (in the range 0.0 to 1.0). * * @see #getViewX() * @see #getViewY() * @see #getViewWidth() * @see #getViewHeight() */ public void setView(double x, double y, double w, double h) { this.viewX = x; this.viewY = y; this.viewW = w; this.viewH = h; fireChangeEvent(); } /** * Adds a layer to the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param layer the layer (null not permitted). */ public void addLayer(DialLayer layer) { if (layer == null) { throw new IllegalArgumentException("Null 'layer' argument."); } this.layers.add(layer); layer.addChangeListener(this); fireChangeEvent(); } /** * Returns the index for the specified layer. * * @param layer the layer (null not permitted). * * @return The layer index. */ public int getLayerIndex(DialLayer layer) { if (layer == null) { throw new IllegalArgumentException("Null 'layer' argument."); } return this.layers.indexOf(layer); } /** * Removes the layer at the specified index and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the index. */ public void removeLayer(int index) { DialLayer layer = (DialLayer) this.layers.get(index); if (layer != null) { layer.removeChangeListener(this); } this.layers.remove(index); fireChangeEvent(); } /** * Removes the specified layer and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param layer the layer (null not permitted). */ public void removeLayer(DialLayer layer) { // defer argument checking removeLayer(getLayerIndex(layer)); } /** * Adds a pointer to the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param pointer the pointer (null not permitted). */ public void addPointer(DialPointer pointer) { if (pointer == null) { throw new IllegalArgumentException("Null 'pointer' argument."); } this.pointers.add(pointer); pointer.addChangeListener(this); fireChangeEvent(); } /** * Returns the index for the specified pointer. * * @param pointer the pointer (null not permitted). * * @return The pointer index. */ public int getPointerIndex(DialPointer pointer) { if (pointer == null) { throw new IllegalArgumentException("Null 'pointer' argument."); } return this.pointers.indexOf(pointer); } /** * Removes the pointer at the specified index and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the index. */ public void removePointer(int index) { DialPointer pointer = (DialPointer) this.pointers.get(index); if (pointer != null) { pointer.removeChangeListener(this); } this.pointers.remove(index); fireChangeEvent(); } /** * Removes the specified pointer and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param pointer the pointer (null not permitted). */ public void removePointer(DialPointer pointer) { // defer argument checking removeLayer(getPointerIndex(pointer)); } /** * Returns the dial pointer that is associated with the specified * dataset, or null. * * @param datasetIndex the dataset index. * * @return The pointer. */ public DialPointer getPointerForDataset(int datasetIndex) { DialPointer result = null; Iterator iterator = this.pointers.iterator(); while (iterator.hasNext()) { DialPointer p = (DialPointer) iterator.next(); if (p.getDatasetIndex() == datasetIndex) { return p; } } return result; } /** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly null). */ public ValueDataset getDataset() { return getDataset(0); } /** * Returns the dataset at the given index. * * @param index the dataset index. * * @return The dataset (possibly null). */ public ValueDataset getDataset(int index) { ValueDataset result = null; if (this.datasets.size() > index) { result = (ValueDataset) this.datasets.get(index); } return result; } /** * Sets the dataset for the plot, replacing the existing dataset, if there * is one, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param dataset the dataset (null permitted). */ public void setDataset(ValueDataset dataset) { setDataset(0, dataset); } /** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (null permitted). */ public void setDataset(int index, ValueDataset dataset) { ValueDataset existing = (ValueDataset) this.datasets.get(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the number of datasets. * * @return The number of datasets. */ public int getDatasetCount() { return this.datasets.size(); } /** * Draws the plot. This method is usually called by the {@link JFreeChart} * instance that manages the plot. * * @param g2 the graphics target. * @param area the area in which the plot should be drawn. * @param anchor the anchor point (typically the last point that the * mouse clicked on, null is permitted). * @param parentState the state for the parent plot (if any). * @param info used to collect plot rendering info (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { Shape origClip = g2.getClip(); g2.setClip(area); // first, expand the viewing area into a drawing frame Rectangle2D frame = viewToFrame(area); // draw the background if there is one... if (this.background != null && this.background.isVisible()) { if (this.background.isClippedToWindow()) { Shape savedClip = g2.getClip(); g2.clip(this.dialFrame.getWindow(frame)); this.background.draw(g2, this, frame, area); g2.setClip(savedClip); } else { this.background.draw(g2, this, frame, area); } } Iterator iterator = this.layers.iterator(); while (iterator.hasNext()) { DialLayer current = (DialLayer) iterator.next(); if (current.isVisible()) { if (current.isClippedToWindow()) { Shape savedClip = g2.getClip(); g2.clip(this.dialFrame.getWindow(frame)); current.draw(g2, this, frame, area); g2.setClip(savedClip); } else { current.draw(g2, this, frame, area); } } } // draw the pointers iterator = this.pointers.iterator(); while (iterator.hasNext()) { DialPointer current = (DialPointer) iterator.next(); if (current.isVisible()) { if (current.isClippedToWindow()) { Shape savedClip = g2.getClip(); g2.clip(this.dialFrame.getWindow(frame)); current.draw(g2, this, frame, area); g2.setClip(savedClip); } else { current.draw(g2, this, frame, area); } } } // draw the cap if there is one... if (this.cap != null && this.cap.isVisible()) { if (this.cap.isClippedToWindow()) { Shape savedClip = g2.getClip(); g2.clip(this.dialFrame.getWindow(frame)); this.cap.draw(g2, this, frame, area); g2.setClip(savedClip); } else { this.cap.draw(g2, this, frame, area); } } if (this.dialFrame.isVisible()) { this.dialFrame.draw(g2, this, frame, area); } g2.setClip(origClip); } /** * Returns the frame surrounding the specified view rectangle. * * @param view the view rectangle (null not permitted). * * @return The frame rectangle. */ private Rectangle2D viewToFrame(Rectangle2D view) { double width = view.getWidth() / this.viewW; double height = view.getHeight() / this.viewH; double x = view.getX() - (width * this.viewX); double y = view.getY() - (height * this.viewY); return new Rectangle2D.Double(x, y, width, height); } /** * Returns the value from the specified dataset. * * @param datasetIndex the dataset index. * * @return The data value. */ public double getValue(int datasetIndex) { double result = Double.NaN; ValueDataset dataset = getDataset(datasetIndex); if (dataset != null) { Number n = dataset.getValue(); if (n != null) { result = n.doubleValue(); } } return result; } /** * Adds a dial scale to the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param index the scale index. * @param scale the scale (null not permitted). */ public void addScale(int index, DialScale scale) { if (scale == null) { throw new IllegalArgumentException("Null 'scale' argument."); } DialScale existing = (DialScale) this.scales.get(index); if (existing != null) { removeLayer(existing); } this.layers.add(scale); this.scales.set(index, scale); scale.addChangeListener(this); fireChangeEvent(); } /** * Returns the scale at the given index. * * @param index the scale index. * * @return The scale (possibly null). */ public DialScale getScale(int index) { DialScale result = null; if (this.scales.size() > index) { result = (DialScale) this.scales.get(index); } return result; } /** * Maps a dataset to a particular scale. * * @param index the dataset index (zero-based). * @param scaleIndex the scale index (zero-based). */ public void mapDatasetToScale(int index, int scaleIndex) { this.datasetToScaleMap.set(index, new Integer(scaleIndex)); fireChangeEvent(); } /** * Returns the dial scale for a specific dataset. * * @param datasetIndex the dataset index. * * @return The dial scale. */ public DialScale getScaleForDataset(int datasetIndex) { DialScale result = (DialScale) this.scales.get(0); Integer scaleIndex = (Integer) this.datasetToScaleMap.get(datasetIndex); if (scaleIndex != null) { result = getScale(scaleIndex.intValue()); } return result; } /** * A utility method that computes a rectangle using relative radius values. * * @param rect the reference rectangle (null not permitted). * @param radiusW the width radius (must be > 0.0) * @param radiusH the height radius. * * @return A new rectangle. */ public static Rectangle2D rectangleByRadius(Rectangle2D rect, double radiusW, double radiusH) { if (rect == null) { throw new IllegalArgumentException("Null 'rect' argument."); } double x = rect.getCenterX(); double y = rect.getCenterY(); double w = rect.getWidth() * radiusW; double h = rect.getHeight() * radiusH; return new Rectangle2D.Double(x - w / 2.0, y - h / 2.0, w, h); } /** * Receives notification when a layer has changed, and responds by * forwarding a {@link PlotChangeEvent} to all registered listeners. * * @param event the event. */ public void dialLayerChanged(DialLayerChangeEvent event) { fireChangeEvent(); } /** * Tests this DialPlot instance for equality with an * arbitrary object. The plot's dataset(s) is (are) not included in * the test. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialPlot)) { return false; } DialPlot that = (DialPlot) obj; if (!ObjectUtilities.equal(this.background, that.background)) { return false; } if (!ObjectUtilities.equal(this.cap, that.cap)) { return false; } if (!this.dialFrame.equals(that.dialFrame)) { return false; } if (this.viewX != that.viewX) { return false; } if (this.viewY != that.viewY) { return false; } if (this.viewW != that.viewW) { return false; } if (this.viewH != that.viewH) { return false; } if (!this.layers.equals(that.layers)) { return false; } if (!this.pointers.equals(that.pointers)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; result = 37 * result + ObjectUtilities.hashCode(this.background); result = 37 * result + ObjectUtilities.hashCode(this.cap); result = 37 * result + this.dialFrame.hashCode(); long temp = Double.doubleToLongBits(this.viewX); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.viewY); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.viewW); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.viewH); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns the plot type. * * @return "DialPlot" */ public String getPlotType() { return "DialPlot"; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialPointer.java0000644000175000017500000004663011173030414027406 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * DialPointer.java * ---------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 17-Oct-2007 : Added equals() overrides (DG); * 24-Oct-2007 : Implemented PublicCloneable, changed default radius, * and added argument checks (DG); * 23-Nov-2007 : Added fillPaint and outlinePaint attributes to * DialPointer.Pointer (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A base class for the pointer in a {@link DialPlot}. * * @since 1.0.7 */ public abstract class DialPointer extends AbstractDialLayer implements DialLayer, Cloneable, PublicCloneable, Serializable { /** The needle radius. */ double radius; /** * The dataset index for the needle. */ int datasetIndex; /** * Creates a new DialPointer instance. */ protected DialPointer() { this(0); } /** * Creates a new pointer for the specified dataset. * * @param datasetIndex the dataset index. */ protected DialPointer(int datasetIndex) { this.radius = 0.9; this.datasetIndex = datasetIndex; } /** * Returns the dataset index that the pointer maps to. * * @return The dataset index. * * @see #getDatasetIndex() */ public int getDatasetIndex() { return this.datasetIndex; } /** * Sets the dataset index for the pointer and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param index the index. * * @see #getDatasetIndex() */ public void setDatasetIndex(int index) { this.datasetIndex = index; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the radius of the pointer, as a percentage of the dial's * framing rectangle. * * @return The radius. * * @see #setRadius(double) */ public double getRadius() { return this.radius; } /** * Sets the radius of the pointer and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param radius the radius. * * @see #getRadius() */ public void setRadius(double radius) { this.radius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Checks this instance for equality with an arbitrary object. * * @param obj the object (null not permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialPointer)) { return false; } DialPointer that = (DialPointer) obj; if (this.datasetIndex != that.datasetIndex) { return false; } if (this.radius != that.radius) { return false; } return super.equals(obj); } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result = 23; result = HashUtilities.hashCode(result, this.radius); return result; } /** * Returns a clone of the pointer. * * @return a clone. * * @throws CloneNotSupportedException if one of the attributes cannot * be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * A dial pointer that draws a thin line (like a pin). */ public static class Pin extends DialPointer { /** For serialization. */ static final long serialVersionUID = -8445860485367689750L; /** The paint. */ private transient Paint paint; /** The stroke. */ private transient Stroke stroke; /** * Creates a new instance. */ public Pin() { this(0); } /** * Creates a new instance. * * @param datasetIndex the dataset index. */ public Pin(int datasetIndex) { super(datasetIndex); this.paint = Color.red; this.stroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); } /** * Returns the paint. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the stroke. * * @return The stroke (never null). * * @see #setStroke(Stroke) */ public Stroke getStroke() { return this.stroke; } /** * Sets the stroke and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getStroke() */ public void setStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.stroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Draws the pointer. * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame. * @param view the dial's view. */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint(this.paint); g2.setStroke(this.stroke); Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, this.radius, this.radius); double value = plot.getValue(this.datasetIndex); DialScale scale = plot.getScaleForDataset(this.datasetIndex); double angle = scale.valueToAngle(value); Arc2D arc = new Arc2D.Double(arcRect, angle, 0, Arc2D.OPEN); Point2D pt = arc.getEndPoint(); Line2D line = new Line2D.Double(frame.getCenterX(), frame.getCenterY(), pt.getX(), pt.getY()); g2.draw(line); } /** * Tests this pointer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialPointer.Pin)) { return false; } DialPointer.Pin that = (DialPointer.Pin) obj; if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!this.stroke.equals(that.stroke)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = HashUtilities.hashCode(result, this.paint); result = HashUtilities.hashCode(result, this.stroke); return result; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.stroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); } } /** * A dial pointer. */ public static class Pointer extends DialPointer { /** For serialization. */ static final long serialVersionUID = -4180500011963176960L; /** * The radius that defines the width of the pointer at the base. */ private double widthRadius; /** * The fill paint. * * @since 1.0.8 */ private transient Paint fillPaint; /** * The outline paint. * * @since 1.0.8 */ private transient Paint outlinePaint; /** * Creates a new instance. */ public Pointer() { this(0); } /** * Creates a new instance. * * @param datasetIndex the dataset index. */ public Pointer(int datasetIndex) { super(datasetIndex); this.widthRadius = 0.05; this.fillPaint = Color.gray; this.outlinePaint = Color.black; } /** * Returns the width radius. * * @return The width radius. * * @see #setWidthRadius(double) */ public double getWidthRadius() { return this.widthRadius; } /** * Sets the width radius and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param radius the radius * * @see #getWidthRadius() */ public void setWidthRadius(double radius) { this.widthRadius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the fill paint. * * @return The paint (never null). * * @see #setFillPaint(Paint) * * @since 1.0.8 */ public Paint getFillPaint() { return this.fillPaint; } /** * Sets the fill paint and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getFillPaint() * * @since 1.0.8 */ public void setFillPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.fillPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the outline paint. * * @return The paint (never null). * * @see #setOutlinePaint(Paint) * * @since 1.0.8 */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getOutlinePaint() * * @since 1.0.8 */ public void setOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.outlinePaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Draws the pointer. * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame. * @param view the dial's view. */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { g2.setPaint(Color.blue); g2.setStroke(new BasicStroke(1.0f)); Rectangle2D lengthRect = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Rectangle2D widthRect = DialPlot.rectangleByRadius(frame, this.widthRadius, this.widthRadius); double value = plot.getValue(this.datasetIndex); DialScale scale = plot.getScaleForDataset(this.datasetIndex); double angle = scale.valueToAngle(value); Arc2D arc1 = new Arc2D.Double(lengthRect, angle, 0, Arc2D.OPEN); Point2D pt1 = arc1.getEndPoint(); Arc2D arc2 = new Arc2D.Double(widthRect, angle - 90.0, 180.0, Arc2D.OPEN); Point2D pt2 = arc2.getStartPoint(); Point2D pt3 = arc2.getEndPoint(); Arc2D arc3 = new Arc2D.Double(widthRect, angle - 180.0, 0.0, Arc2D.OPEN); Point2D pt4 = arc3.getStartPoint(); GeneralPath gp = new GeneralPath(); gp.moveTo((float) pt1.getX(), (float) pt1.getY()); gp.lineTo((float) pt2.getX(), (float) pt2.getY()); gp.lineTo((float) pt4.getX(), (float) pt4.getY()); gp.lineTo((float) pt3.getX(), (float) pt3.getY()); gp.closePath(); g2.setPaint(this.fillPaint); g2.fill(gp); g2.setPaint(this.outlinePaint); Line2D line = new Line2D.Double(frame.getCenterX(), frame.getCenterY(), pt1.getX(), pt1.getY()); g2.draw(line); line.setLine(pt2, pt3); g2.draw(line); line.setLine(pt3, pt1); g2.draw(line); line.setLine(pt2, pt1); g2.draw(line); line.setLine(pt2, pt4); g2.draw(line); line.setLine(pt3, pt4); g2.draw(line); } /** * Tests this pointer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialPointer.Pointer)) { return false; } DialPointer.Pointer that = (DialPointer.Pointer) obj; if (this.widthRadius != that.widthRadius) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = HashUtilities.hashCode(result, this.widthRadius); result = HashUtilities.hashCode(result, this.fillPaint); result = HashUtilities.hashCode(result, this.outlinePaint); return result; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.fillPaint, stream); SerialUtilities.writePaint(this.outlinePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.fillPaint = SerialUtilities.readPaint(stream); this.outlinePaint = SerialUtilities.readPaint(stream); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialScale.java0000644000175000017500000000452211173030414027007 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * DialScale.java * -------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 17-Oct-2007 : Made this an extension of the DialLayer interface (DG); * */ package org.jfree.chart.plot.dial; /** * A dial scale is a specialised layer that has the ability to convert data * values into angles. * * @since 1.0.7 */ public interface DialScale extends DialLayer { /** * Converts a data value to an angle (in degrees, using the same * specification as Java's Arc2D class). * * @param value the data value. * * @return The angle in degrees. * * @see #angleToValue(double) */ public double valueToAngle(double value); /** * Converts an angle (in degrees) to a data value. * * @param angle the angle (in degrees). * * @return The data value. * * @see #valueToAngle(double) */ public double angleToValue(double angle); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialTextAnnotation.java0000644000175000017500000003030511173030414030735 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DialTextAnnotation.java * ----------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 08-Mar-2007 : Fix in hashCode() (DG); * 17-Oct-2007 : Updated equals() (DG); * 24-Oct-2007 : Added getAnchor() and setAnchor() methods (DG); * */ package org.jfree.chart.plot.dial; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Arc2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.TextAnchor; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A text annotation for a {@link DialPlot}. * * @since 1.0.7 */ public class DialTextAnnotation extends AbstractDialLayer implements DialLayer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 3065267524054428071L; /** The label text. */ private String label; /** The font. */ private Font font; /** * The paint for the label. This field is transient because it requires * special handling for serialization. */ private transient Paint paint; /** The angle that defines the anchor point for the annotation. */ private double angle; /** The radius that defines the anchor point for the annotation. */ private double radius; /** The text anchor to be aligned to the annotation's anchor point. */ private TextAnchor anchor; /** * Creates a new instance of DialTextAnnotation. * * @param label the label (null not permitted). */ public DialTextAnnotation(String label) { if (label == null) { throw new IllegalArgumentException("Null 'label' argument."); } this.angle = -90.0; this.radius = 0.3; this.font = new Font("Dialog", Font.BOLD, 14); this.paint = Color.black; this.label = label; this.anchor = TextAnchor.TOP_CENTER; } /** * Returns the label text. * * @return The label text (never nullnull not permitted). * * @see #getLabel() */ public void setLabel(String label) { if (label == null) { throw new IllegalArgumentException("Null 'label' argument."); } this.label = label; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the font used to display the label. * * @return The font (never null). * * @see #setFont(Font) */ public Font getFont() { return this.font; } /** * Sets the font used to display the label and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * * @see #getFont() */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.font = font; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint used to display the label. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint used to display the label and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the angle used to calculate the anchor point. * * @return The angle (in degrees). * * @see #setAngle(double) * @see #getRadius() */ public double getAngle() { return this.angle; } /** * Sets the angle used to calculate the anchor point and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param angle the angle (in degrees). * * @see #getAngle() * @see #setRadius(double) */ public void setAngle(double angle) { this.angle = angle; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the radius used to calculate the anchor point. This is * specified as a percentage relative to the dial's framing rectangle. * * @return The radius. * * @see #setRadius(double) * @see #getAngle() */ public double getRadius() { return this.radius; } /** * Sets the radius used to calculate the anchor point and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param radius the radius (as a percentage of the dial's framing * rectangle). * * @see #getRadius() * @see #setAngle(double) */ public void setRadius(double radius) { if (radius < 0.0) { throw new IllegalArgumentException( "The 'radius' cannot be negative."); } this.radius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the text anchor point that will be aligned to the position * specified by {@link #getAngle()} and {@link #getRadius()}. * * @return The anchor point. * * @see #setAnchor(TextAnchor) */ public TextAnchor getAnchor() { return this.anchor; } /** * Sets the text anchor point and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param anchor the anchor point (null not permitted). * * @see #getAnchor() */ public void setAnchor(TextAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.anchor = anchor; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Draws the background to the specified graphics device. If the dial * frame specifies a window, the clipping region will already have been * set to this window before this method is called. * * @param g2 the graphics device (null not permitted). * @param plot the plot (ignored here). * @param frame the dial frame (ignored here). * @param view the view rectangle (null not permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { // work out the anchor point Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN); Point2D pt = arc.getStartPoint(); g2.setPaint(this.paint); g2.setFont(this.font); TextUtilities.drawAlignedString(this.label, g2, (float) pt.getX(), (float) pt.getY(), this.anchor); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialTextAnnotation)) { return false; } DialTextAnnotation that = (DialTextAnnotation) obj; if (!this.label.equals(that.label)) { return false; } if (!this.font.equals(that.font)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (this.radius != that.radius) { return false; } if (this.angle != that.angle) { return false; } if (!this.anchor.equals(that.anchor)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); result = 37 * result + this.font.hashCode(); result = 37 * result + this.label.hashCode(); result = 37 * result + this.anchor.hashCode(); long temp = Double.doubleToLongBits(this.angle); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.radius); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a clone of this instance. * * @return The clone. * * @throws CloneNotSupportedException if some attribute of this instance * cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/DialValueIndicator.java0000644000175000017500000005117411173030414030676 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DialValueIndicator.java * ----------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 17-Oct-2007 : Updated equals() (DG); * 24-Oct-2007 : Added default constructor and missing event notification (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.text.DecimalFormat; import java.text.NumberFormat; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.ui.TextAnchor; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A value indicator for a {@link DialPlot}. * * @since 1.0.7 */ public class DialValueIndicator extends AbstractDialLayer implements DialLayer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 803094354130942585L; /** The dataset index. */ private int datasetIndex; /** The angle that defines the anchor point. */ private double angle; /** The radius that defines the anchor point. */ private double radius; /** The frame anchor. */ private RectangleAnchor frameAnchor; /** The template value. */ private Number templateValue; /** The formatter. */ private NumberFormat formatter; /** The font. */ private Font font; /** The paint. */ private transient Paint paint; /** The background paint. */ private transient Paint backgroundPaint; /** The outline stroke. */ private transient Stroke outlineStroke; /** The outline paint. */ private transient Paint outlinePaint; /** The insets. */ private RectangleInsets insets; /** The value anchor. */ private RectangleAnchor valueAnchor; /** The text anchor for displaying the value. */ private TextAnchor textAnchor; /** * Creates a new instance of DialValueIndicator. */ public DialValueIndicator() { this(0); } /** * Creates a new instance of DialValueIndicator. * * @param datasetIndex the dataset index. */ public DialValueIndicator(int datasetIndex) { this.datasetIndex = datasetIndex; this.angle = -90.0; this.radius = 0.3; this.frameAnchor = RectangleAnchor.CENTER; this.templateValue = new Double(100.0); this.formatter = new DecimalFormat("0.0"); this.font = new Font("Dialog", Font.BOLD, 14); this.paint = Color.black; this.backgroundPaint = Color.white; this.outlineStroke = new BasicStroke(1.0f); this.outlinePaint = Color.blue; this.insets = new RectangleInsets(4, 4, 4, 4); this.valueAnchor = RectangleAnchor.RIGHT; this.textAnchor = TextAnchor.CENTER_RIGHT; } /** * Returns the index of the dataset from which this indicator fetches its * current value. * * @return The dataset index. * * @see #setDatasetIndex(int) */ public int getDatasetIndex() { return this.datasetIndex; } /** * Sets the dataset index and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param index the index. * * @see #getDatasetIndex() */ public void setDatasetIndex(int index) { this.datasetIndex = index; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the angle for the anchor point. The angle is specified in * degrees using the same orientation as Java's Arc2D class. * * @return The angle (in degrees). * * @see #setAngle(double) */ public double getAngle() { return this.angle; } /** * Sets the angle for the anchor point and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param angle the angle (in degrees). * * @see #getAngle() */ public void setAngle(double angle) { this.angle = angle; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the radius. * * @return The radius. * * @see #setRadius(double) */ public double getRadius() { return this.radius; } /** * Sets the radius and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param radius the radius. * * @see #getRadius() */ public void setRadius(double radius) { this.radius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the frame anchor. * * @return The frame anchor. * * @see #setFrameAnchor(RectangleAnchor) */ public RectangleAnchor getFrameAnchor() { return this.frameAnchor; } /** * Sets the frame anchor and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param anchor the anchor (null not permitted). * * @see #getFrameAnchor() */ public void setFrameAnchor(RectangleAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.frameAnchor = anchor; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the template value. * * @return The template value (never null). * * @see #setTemplateValue(Number) */ public Number getTemplateValue() { return this.templateValue; } /** * Sets the template value and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param value the value (null not permitted). * * @see #setTemplateValue(Number) */ public void setTemplateValue(Number value) { if (value == null) { throw new IllegalArgumentException("Null 'value' argument."); } this.templateValue = value; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the formatter used to format the value. * * @return The formatter (never null). * * @see #setNumberFormat(NumberFormat) */ public NumberFormat getNumberFormat() { return this.formatter; } /** * Sets the formatter used to format the value and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param formatter the formatter (null not permitted). * * @see #getNumberFormat() */ public void setNumberFormat(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.formatter = formatter; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the font. * * @return The font (never null). * * @see #getFont() */ public Font getFont() { return this.font; } /** * Sets the font and sends a {@link DialLayerChangeEvent} to all registered * listeners. * * @param font the font (null not permitted). */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.font = font; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the background paint. * * @return The background paint. * * @see #setBackgroundPaint(Paint) */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBackgroundPaint() */ public void setBackgroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.backgroundPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the outline stroke. * * @return The outline stroke (never null). * * @see #setOutlineStroke(Stroke) */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the outline stroke and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getOutlineStroke() */ public void setOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.outlineStroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the outline paint. * * @return The outline paint (never null). * * @see #setOutlinePaint(Paint) */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getOutlinePaint() */ public void setOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.outlinePaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the insets. * * @return The insets (never null). * * @see #setInsets(RectangleInsets) */ public RectangleInsets getInsets() { return this.insets; } /** * Sets the insets and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param insets the insets (null not permitted). * * @see #getInsets() */ public void setInsets(RectangleInsets insets) { if (insets == null) { throw new IllegalArgumentException("Null 'insets' argument."); } this.insets = insets; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the value anchor. * * @return The value anchor (never null). * * @see #setValueAnchor(RectangleAnchor) */ public RectangleAnchor getValueAnchor() { return this.valueAnchor; } /** * Sets the value anchor and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param anchor the anchor (null not permitted). * * @see #getValueAnchor() */ public void setValueAnchor(RectangleAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.valueAnchor = anchor; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the text anchor. * * @return The text anchor (never null). * * @see #setTextAnchor(TextAnchor) */ public TextAnchor getTextAnchor() { return this.textAnchor; } /** * Sets the text anchor and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param anchor the anchor (null not permitted). * * @see #getTextAnchor() */ public void setTextAnchor(TextAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.textAnchor = anchor; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Draws the background to the specified graphics device. If the dial * frame specifies a window, the clipping region will already have been * set to this window before this method is called. * * @param g2 the graphics device (null not permitted). * @param plot the plot (ignored here). * @param frame the dial frame (ignored here). * @param view the view rectangle (null not permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { // work out the anchor point Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN); Point2D pt = arc.getStartPoint(); // calculate the bounds of the template value FontMetrics fm = g2.getFontMetrics(this.font); String s = this.formatter.format(this.templateValue); Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm); // align this rectangle to the frameAnchor Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D( tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(), this.frameAnchor); // add the insets Rectangle2D fb = this.insets.createOutsetRectangle(bounds); // draw the background g2.setPaint(this.backgroundPaint); g2.fill(fb); // draw the border g2.setStroke(this.outlineStroke); g2.setPaint(this.outlinePaint); g2.draw(fb); // now find the text anchor point double value = plot.getValue(this.datasetIndex); String valueStr = this.formatter.format(value); Point2D pt2 = RectangleAnchor.coordinates(bounds, this.valueAnchor); g2.setPaint(this.paint); g2.setFont(this.font); TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(), (float) pt2.getY(), this.textAnchor); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DialValueIndicator)) { return false; } DialValueIndicator that = (DialValueIndicator) obj; if (this.datasetIndex != that.datasetIndex) { return false; } if (this.angle != that.angle) { return false; } if (this.radius != that.radius) { return false; } if (!this.frameAnchor.equals(that.frameAnchor)) { return false; } if (!this.templateValue.equals(that.templateValue)) { return false; } if (!this.font.equals(that.font)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (!this.outlineStroke.equals(that.outlineStroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!this.insets.equals(that.insets)) { return false; } if (!this.valueAnchor.equals(that.valueAnchor)) { return false; } if (!this.textAnchor.equals(that.textAnchor)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); result = 37 * result + HashUtilities.hashCodeForPaint( this.backgroundPaint); result = 37 * result + HashUtilities.hashCodeForPaint( this.outlinePaint); result = 37 * result + this.outlineStroke.hashCode(); return result; } /** * Returns a clone of this instance. * * @return The clone. * * @throws CloneNotSupportedException if some attribute of this instance * cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writePaint(this.backgroundPaint, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.backgroundPaint = SerialUtilities.readPaint(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/StandardDialFrame.java0000644000175000017500000002612311173030414030474 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * StandardDialFrame.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 08-Mar-2007 : Fix in hashCode() (DG); * 29-Oct-2007 : Renamed StandardDialFrame (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A simple circular frame for the {@link DialPlot} class. * * @since 1.0.7 */ public class StandardDialFrame extends AbstractDialLayer implements DialFrame, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 1016585407507121596L; /** The outer radius, relative to the framing rectangle. */ private double radius; /** * The color used for the front of the panel. This field is transient * because it requires special handling for serialization. */ private transient Paint backgroundPaint; /** * The color used for the border around the window. This field is transient * because it requires special handling for serialization. */ private transient Paint foregroundPaint; /** * The stroke for drawing the frame outline. This field is transient * because it requires special handling for serialization. */ private transient Stroke stroke; /** * Creates a new instance of StandardDialFrame. */ public StandardDialFrame() { this.backgroundPaint = Color.gray; this.foregroundPaint = Color.black; this.stroke = new BasicStroke(2.0f); this.radius = 0.95; } /** * Returns the radius, relative to the framing rectangle. * * @return The radius. * * @see #setRadius(double) */ public double getRadius() { return this.radius; } /** * Sets the radius and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param radius the radius (must be positive). * * @see #getRadius() */ public void setRadius(double radius) { if (radius <= 0) { throw new IllegalArgumentException( "The 'radius' must be positive."); } this.radius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the background paint. * * @return The background paint (never null). * * @see #setBackgroundPaint(Paint) */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBackgroundPaint() */ public void setBackgroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.backgroundPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the foreground paint. * * @return The foreground paint (never null). * * @see #setForegroundPaint(Paint) */ public Paint getForegroundPaint() { return this.foregroundPaint; } /** * Sets the foreground paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getForegroundPaint() */ public void setForegroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.foregroundPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the stroke for the frame. * * @return The stroke (never null). * * @see #setStroke(Stroke) */ public Stroke getStroke() { return this.stroke; } /** * Sets the stroke and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getStroke() */ public void setStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.stroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the shape for the window for this dial. Some dial layers will * request that their drawing be clipped within this window. * * @param frame the reference frame (null not permitted). * * @return The shape of the dial's window. */ public Shape getWindow(Rectangle2D frame) { Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius); return new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), f.getHeight()); } /** * Returns false to indicate that this dial layer is not * clipped to the dial window. * * @return A boolean. */ public boolean isClippedToWindow() { return false; } /** * Draws the frame. This method is called by the {@link DialPlot} class, * you shouldn't need to call it directly. * * @param g2 the graphics target (null not permitted). * @param plot the plot (null not permitted). * @param frame the frame (null not permitted). * @param view the view (null not permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Shape window = getWindow(frame); Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02, this.radius + 0.02); Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), f.getHeight()); Area area = new Area(e); Area area2 = new Area(window); area.subtract(area2); g2.setPaint(this.backgroundPaint); g2.fill(area); g2.setStroke(this.stroke); g2.setPaint(this.foregroundPaint); g2.draw(window); g2.draw(e); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardDialFrame)) { return false; } StandardDialFrame that = (StandardDialFrame) obj; if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) { return false; } if (this.radius != that.radius) { return false; } if (!this.stroke.equals(that.stroke)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.radius); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + HashUtilities.hashCodeForPaint( this.backgroundPaint); result = 37 * result + HashUtilities.hashCodeForPaint( this.foregroundPaint); result = 37 * result + this.stroke.hashCode(); return result; } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if any of the frame's attributes * cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.backgroundPaint, stream); SerialUtilities.writePaint(this.foregroundPaint, stream); SerialUtilities.writeStroke(this.stroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.backgroundPaint = SerialUtilities.readPaint(stream); this.foregroundPaint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/StandardDialRange.java0000644000175000017500000003155511173030414030503 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * StandardDialRange.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 08-Mar-2007 : Fix in hashCode() (DG); * 17-Oct-2007 : Removed increment attribute (DG); * 24-Oct-2007 : Added scaleIndex (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Arc2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A layer that draws a range highlight on a dial plot. * * @since 1.0.7 */ public class StandardDialRange extends AbstractDialLayer implements DialLayer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 345515648249364904L; /** The scale index. */ private int scaleIndex; /** The minimum data value for the scale. */ private double lowerBound; /** The maximum data value for the scale. */ private double upperBound; /** * The paint used to draw the range highlight. This field is transient * because it requires special handling for serialization. */ private transient Paint paint; /** * The factor (in the range 0.0 to 1.0) that determines the inside limit * of the range highlight. */ private double innerRadius; /** * The factor (in the range 0.0 to 1.0) that determines the outside limit * of the range highlight. */ private double outerRadius; /** * Creates a new instance of StandardDialRange. */ public StandardDialRange() { this(0.0, 100.0, Color.white); } /** * Creates a new instance of StandardDialRange. * * @param lower the lower bound. * @param upper the upper bound. * @param paint the paint (null not permitted). */ public StandardDialRange(double lower, double upper, Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.scaleIndex = 0; this.lowerBound = lower; this.upperBound = upper; this.innerRadius = 0.48; this.outerRadius = 0.52; this.paint = paint; } /** * Returns the scale index. * * @return The scale index. * * @see #setScaleIndex(int) */ public int getScaleIndex() { return this.scaleIndex; } /** * Sets the scale index and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param index the scale index. * * @see #getScaleIndex() */ public void setScaleIndex(int index) { this.scaleIndex = index; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the lower bound (a data value) of the dial range. * * @return The lower bound of the dial range. * * @see #setLowerBound(double) */ public double getLowerBound() { return this.lowerBound; } /** * Sets the lower bound of the dial range and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param bound the lower bound. * * @see #getLowerBound() */ public void setLowerBound(double bound) { if (bound >= this.upperBound) { throw new IllegalArgumentException( "Lower bound must be less than upper bound."); } this.lowerBound = bound; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the upper bound of the dial range. * * @return The upper bound. * * @see #setUpperBound(double) */ public double getUpperBound() { return this.upperBound; } /** * Sets the upper bound of the dial range and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param bound the upper bound. * * @see #getUpperBound() */ public void setUpperBound(double bound) { if (bound <= this.lowerBound) { throw new IllegalArgumentException( "Lower bound must be less than upper bound."); } this.upperBound = bound; notifyListeners(new DialLayerChangeEvent(this)); } /** * Sets the bounds for the range and sends a {@link DialLayerChangeEvent} * to all registered listeners. * * @param lower the lower bound. * @param upper the upper bound. */ public void setBounds(double lower, double upper) { if (lower >= upper) { throw new IllegalArgumentException( "Lower must be less than upper."); } this.lowerBound = lower; this.upperBound = upper; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint used to highlight the range. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint used to highlight the range and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the inner radius. * * @return The inner radius. * * @see #setInnerRadius(double) */ public double getInnerRadius() { return this.innerRadius; } /** * Sets the inner radius and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param radius the radius. * * @see #getInnerRadius() */ public void setInnerRadius(double radius) { this.innerRadius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the outer radius. * * @return The outer radius. * * @see #setOuterRadius(double) */ public double getOuterRadius() { return this.outerRadius; } /** * Sets the outer radius and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param radius the radius. * * @see #getOuterRadius() */ public void setOuterRadius(double radius) { this.outerRadius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Draws the range. * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame (in Java2D space). * @param view the dial's view rectangle (in Java2D space). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame, this.innerRadius, this.innerRadius); Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame, this.outerRadius, this.outerRadius); DialScale scale = plot.getScale(this.scaleIndex); if (scale == null) { throw new RuntimeException("No scale for scaleIndex = " + this.scaleIndex); } double angleMin = scale.valueToAngle(this.lowerBound); double angleMax = scale.valueToAngle(this.upperBound); Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin, angleMax - angleMin, Arc2D.OPEN); Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax, angleMin - angleMax, Arc2D.OPEN); g2.setPaint(this.paint); g2.setStroke(new BasicStroke(2.0f)); g2.draw(arcInner); g2.draw(arcOuter); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardDialRange)) { return false; } StandardDialRange that = (StandardDialRange) obj; if (this.scaleIndex != that.scaleIndex) { return false; } if (this.lowerBound != that.lowerBound) { return false; } if (this.upperBound != that.upperBound) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (this.innerRadius != that.innerRadius) { return false; } if (this.outerRadius != that.outerRadius) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return The hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.lowerBound); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.upperBound); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.innerRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.outerRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); return result; } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if any of the attributes of this * instance cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/StandardDialScale.java0000644000175000017500000007702711173030414030502 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * StandardDialScale.java * ---------------------- * (C) Copyright 2006-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 17-Nov-2006 : Added flags for tick label visibility (DG); * 24-Oct-2007 : Added tick label formatter (DG); * 19-Nov-2007 : Added some missing accessor methods (DG); * 27-Feb-2009 : Fixed bug 2617557: tickLabelPaint ignored (DG); * */ package org.jfree.chart.plot.dial; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.text.DecimalFormat; import java.text.NumberFormat; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.TextAnchor; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A scale for a {@link DialPlot}. * * @since 1.0.7 */ public class StandardDialScale extends AbstractDialLayer implements DialScale, Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 3715644629665918516L; /** The minimum data value for the scale. */ private double lowerBound; /** The maximum data value for the scale. */ private double upperBound; /** * The start angle for the scale display, in degrees (using the same * encoding as Arc2D). */ private double startAngle; /** The extent of the scale display. */ private double extent; /** * The factor (in the range 0.0 to 1.0) that determines the outside limit * of the tick marks. */ private double tickRadius; /** * The increment (in data units) between major tick marks. */ private double majorTickIncrement; /** * The factor that is subtracted from the tickRadius to determine the * inner point of the major ticks. */ private double majorTickLength; /** * The paint to use for major tick marks. This field is transient because * it requires special handling for serialization. */ private transient Paint majorTickPaint; /** * The stroke to use for major tick marks. This field is transient because * it requires special handling for serialization. */ private transient Stroke majorTickStroke; /** * The number of minor ticks between each major tick. */ private int minorTickCount; /** * The factor that is subtracted from the tickRadius to determine the * inner point of the minor ticks. */ private double minorTickLength; /** * The paint to use for minor tick marks. This field is transient because * it requires special handling for serialization. */ private transient Paint minorTickPaint; /** * The stroke to use for minor tick marks. This field is transient because * it requires special handling for serialization. */ private transient Stroke minorTickStroke; /** * The tick label offset. */ private double tickLabelOffset; /** * The tick label font. */ private Font tickLabelFont; /** * A flag that controls whether or not the tick labels are * displayed. */ private boolean tickLabelsVisible; /** * The number formatter for the tick labels. */ private NumberFormat tickLabelFormatter; /** * A flag that controls whether or not the first tick label is * displayed. */ private boolean firstTickLabelVisible; /** * The tick label paint. This field is transient because it requires * special handling for serialization. */ private transient Paint tickLabelPaint; /** * Creates a new instance of DialScale. */ public StandardDialScale() { this(0.0, 100.0, 175, -170, 10.0, 4); } /** * Creates a new instance. * * @param lowerBound the lower bound of the scale. * @param upperBound the upper bound of the scale. * @param startAngle the start angle (in degrees, using the same * orientation as Java's Arc2D class). * @param extent the extent (in degrees, counter-clockwise). * @param majorTickIncrement the interval between major tick marks * @param minorTickCount the number of minor ticks between major tick * marks. */ public StandardDialScale(double lowerBound, double upperBound, double startAngle, double extent, double majorTickIncrement, int minorTickCount) { this.startAngle = startAngle; this.extent = extent; this.lowerBound = lowerBound; this.upperBound = upperBound; this.tickRadius = 0.70; this.tickLabelsVisible = true; this.tickLabelFormatter = new DecimalFormat("0.0"); this.firstTickLabelVisible = true; this.tickLabelFont = new Font("Dialog", Font.BOLD, 16); this.tickLabelPaint = Color.blue; this.tickLabelOffset = 0.10; this.majorTickIncrement = majorTickIncrement; this.majorTickLength = 0.04; this.majorTickPaint = Color.black; this.majorTickStroke = new BasicStroke(3.0f); this.minorTickCount = minorTickCount; this.minorTickLength = 0.02; this.minorTickPaint = Color.black; this.minorTickStroke = new BasicStroke(1.0f); } /** * Returns the lower bound for the scale. * * @return The lower bound for the scale. * * @see #setLowerBound(double) * * @since 1.0.8 */ public double getLowerBound() { return this.lowerBound; } /** * Sets the lower bound for the scale and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param lower the lower bound. * * @see #getLowerBound() * * @since 1.0.8 */ public void setLowerBound(double lower) { this.lowerBound = lower; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the upper bound for the scale. * * @return The upper bound for the scale. * * @see #setUpperBound(double) * * @since 1.0.8 */ public double getUpperBound() { return this.upperBound; } /** * Sets the upper bound for the scale and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param upper the upper bound. * * @see #getUpperBound() * * @since 1.0.8 */ public void setUpperBound(double upper) { this.upperBound = upper; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the start angle for the scale (in degrees using the same * orientation as Java's Arc2D class). * * @return The start angle. * * @see #setStartAngle(double) */ public double getStartAngle() { return this.startAngle; } /** * Sets the start angle for the scale and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param angle the angle (in degrees). * * @see #getStartAngle() */ public void setStartAngle(double angle) { this.startAngle = angle; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the extent. * * @return The extent. * * @see #setExtent(double) */ public double getExtent() { return this.extent; } /** * Sets the extent and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param extent the extent. * * @see #getExtent() */ public void setExtent(double extent) { this.extent = extent; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the radius (as a percentage of the maximum space available) of * the outer limit of the tick marks. * * @return The tick radius. * * @see #setTickRadius(double) */ public double getTickRadius() { return this.tickRadius; } /** * Sets the tick radius and sends a {@link DialLayerChangeEvent} to all * registered listeners. * * @param radius the radius. * * @see #getTickRadius() */ public void setTickRadius(double radius) { if (radius <= 0.0) { throw new IllegalArgumentException( "The 'radius' must be positive."); } this.tickRadius = radius; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the increment (in data units) between major tick labels. * * @return The increment between major tick labels. * * @see #setMajorTickIncrement(double) */ public double getMajorTickIncrement() { return this.majorTickIncrement; } /** * Sets the increment (in data units) between major tick labels and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param increment the increment. * * @see #getMajorTickIncrement() */ public void setMajorTickIncrement(double increment) { if (increment <= 0.0) { throw new IllegalArgumentException( "The 'increment' must be positive."); } this.majorTickIncrement = increment; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the length factor for the major tick marks. The value is * subtracted from the tick radius to determine the inner starting point * for the tick marks. * * @return The length factor. * * @see #setMajorTickLength(double) */ public double getMajorTickLength() { return this.majorTickLength; } /** * Sets the length factor for the major tick marks and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param length the length. * * @see #getMajorTickLength() */ public void setMajorTickLength(double length) { if (length < 0.0) { throw new IllegalArgumentException("Negative 'length' argument."); } this.majorTickLength = length; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the major tick paint. * * @return The major tick paint (never null). * * @see #setMajorTickPaint(Paint) */ public Paint getMajorTickPaint() { return this.majorTickPaint; } /** * Sets the major tick paint and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getMajorTickPaint() */ public void setMajorTickPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.majorTickPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the stroke used to draw the major tick marks. * * @return The stroke (never null). * * @see #setMajorTickStroke(Stroke) */ public Stroke getMajorTickStroke() { return this.majorTickStroke; } /** * Sets the stroke used to draw the major tick marks and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getMajorTickStroke() */ public void setMajorTickStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.majorTickStroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the number of minor tick marks between major tick marks. * * @return The number of minor tick marks between major tick marks. * * @see #setMinorTickCount(int) */ public int getMinorTickCount() { return this.minorTickCount; } /** * Sets the number of minor tick marks between major tick marks and sends * a {@link DialLayerChangeEvent} to all registered listeners. * * @param count the count. * * @see #getMinorTickCount() */ public void setMinorTickCount(int count) { if (count < 0) { throw new IllegalArgumentException( "The 'count' cannot be negative."); } this.minorTickCount = count; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the length factor for the minor tick marks. The value is * subtracted from the tick radius to determine the inner starting point * for the tick marks. * * @return The length factor. * * @see #setMinorTickLength(double) */ public double getMinorTickLength() { return this.minorTickLength; } /** * Sets the length factor for the minor tick marks and sends * a {@link DialLayerChangeEvent} to all registered listeners. * * @param length the length. * * @see #getMinorTickLength() */ public void setMinorTickLength(double length) { if (length < 0.0) { throw new IllegalArgumentException("Negative 'length' argument."); } this.minorTickLength = length; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint used to draw the minor tick marks. * * @return The paint (never null). * * @see #setMinorTickPaint(Paint) */ public Paint getMinorTickPaint() { return this.minorTickPaint; } /** * Sets the paint used to draw the minor tick marks and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getMinorTickPaint() */ public void setMinorTickPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.minorTickPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the stroke used to draw the minor tick marks. * * @return The paint (never null). * * @see #setMinorTickStroke(Stroke) * * @since 1.0.8 */ public Stroke getMinorTickStroke() { return this.minorTickStroke; } /** * Sets the stroke used to draw the minor tick marks and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getMinorTickStroke() * * @since 1.0.8 */ public void setMinorTickStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.minorTickStroke = stroke; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the tick label offset. * * @return The tick label offset. * * @see #setTickLabelOffset(double) */ public double getTickLabelOffset() { return this.tickLabelOffset; } /** * Sets the tick label offset and sends a {@link DialLayerChangeEvent} to * all registered listeners. * * @param offset the offset. * * @see #getTickLabelOffset() */ public void setTickLabelOffset(double offset) { this.tickLabelOffset = offset; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the font used to draw the tick labels. * * @return The font (never null). * * @see #setTickLabelFont(Font) */ public Font getTickLabelFont() { return this.tickLabelFont; } /** * Sets the font used to display the tick labels and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * * @see #getTickLabelFont() */ public void setTickLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.tickLabelFont = font; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the paint used to draw the tick labels. * * @return The paint (null not permitted). * * @see #setTickLabelPaint(Paint) */ public Paint getTickLabelPaint() { return this.tickLabelPaint; } /** * Sets the paint used to draw the tick labels and sends a * {@link DialLayerChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). */ public void setTickLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.tickLabelPaint = paint; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true if the tick labels should be displayed, * and false otherwise. * * @return A boolean. * * @see #setTickLabelsVisible(boolean) */ public boolean getTickLabelsVisible() { return this.tickLabelsVisible; } /** * Sets the flag that controls whether or not the tick labels are * displayed, and sends a {@link DialLayerChangeEvent} to all registered * listeners. * * @param visible the new flag value. * * @see #getTickLabelsVisible() */ public void setTickLabelsVisible(boolean visible) { this.tickLabelsVisible = visible; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns the number formatter used to convert the tick label values to * strings. * * @return The formatter (never null). * * @see #setTickLabelFormatter(NumberFormat) */ public NumberFormat getTickLabelFormatter() { return this.tickLabelFormatter; } /** * Sets the number formatter used to convert the tick label values to * strings, and sends a {@link DialLayerChangeEvent} to all registered * listeners. * * @param formatter the formatter (null not permitted). * * @see #getTickLabelFormatter() */ public void setTickLabelFormatter(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.tickLabelFormatter = formatter; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns a flag that controls whether or not the first tick label is * visible. * * @return A boolean. * * @see #setFirstTickLabelVisible(boolean) */ public boolean getFirstTickLabelVisible() { return this.firstTickLabelVisible; } /** * Sets a flag that controls whether or not the first tick label is * visible, and sends a {@link DialLayerChangeEvent} to all registered * listeners. * * @param visible the new flag value. * * @see #getFirstTickLabelVisible() */ public void setFirstTickLabelVisible(boolean visible) { this.firstTickLabelVisible = visible; notifyListeners(new DialLayerChangeEvent(this)); } /** * Returns true to indicate that this layer should be * clipped within the dial window. * * @return true. */ public boolean isClippedToWindow() { return true; } /** * Draws the scale on the dial plot. * * @param g2 the graphics target (null not permitted). * @param plot the dial plot (null not permitted). * @param frame the reference frame that is used to construct the * geometry of the plot (null not permitted). * @param view the visible part of the plot (null not * permitted). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, this.tickRadius, this.tickRadius); Rectangle2D arcRectMajor = DialPlot.rectangleByRadius(frame, this.tickRadius - this.majorTickLength, this.tickRadius - this.majorTickLength); Rectangle2D arcRectMinor = arcRect; if (this.minorTickCount > 0 && this.minorTickLength > 0.0) { arcRectMinor = DialPlot.rectangleByRadius(frame, this.tickRadius - this.minorTickLength, this.tickRadius - this.minorTickLength); } Rectangle2D arcRectForLabels = DialPlot.rectangleByRadius(frame, this.tickRadius - this.tickLabelOffset, this.tickRadius - this.tickLabelOffset); boolean firstLabel = true; Arc2D arc = new Arc2D.Double(); Line2D workingLine = new Line2D.Double(); for (double v = this.lowerBound; v <= this.upperBound; v += this.majorTickIncrement) { arc.setArc(arcRect, this.startAngle, valueToAngle(v) - this.startAngle, Arc2D.OPEN); Point2D pt0 = arc.getEndPoint(); arc.setArc(arcRectMajor, this.startAngle, valueToAngle(v) - this.startAngle, Arc2D.OPEN); Point2D pt1 = arc.getEndPoint(); g2.setPaint(this.majorTickPaint); g2.setStroke(this.majorTickStroke); workingLine.setLine(pt0, pt1); g2.draw(workingLine); arc.setArc(arcRectForLabels, this.startAngle, valueToAngle(v) - this.startAngle, Arc2D.OPEN); Point2D pt2 = arc.getEndPoint(); if (this.tickLabelsVisible) { if (!firstLabel || this.firstTickLabelVisible) { g2.setFont(this.tickLabelFont); g2.setPaint(this.tickLabelPaint); TextUtilities.drawAlignedString( this.tickLabelFormatter.format(v), g2, (float) pt2.getX(), (float) pt2.getY(), TextAnchor.CENTER); } } firstLabel = false; // now do the minor tick marks if (this.minorTickCount > 0 && this.minorTickLength > 0.0) { double minorTickIncrement = this.majorTickIncrement / (this.minorTickCount + 1); for (int i = 0; i < this.minorTickCount; i++) { double vv = v + ((i + 1) * minorTickIncrement); if (vv >= this.upperBound) { break; } double angle = valueToAngle(vv); arc.setArc(arcRect, this.startAngle, angle - this.startAngle, Arc2D.OPEN); pt0 = arc.getEndPoint(); arc.setArc(arcRectMinor, this.startAngle, angle - this.startAngle, Arc2D.OPEN); Point2D pt3 = arc.getEndPoint(); g2.setStroke(this.minorTickStroke); g2.setPaint(this.minorTickPaint); workingLine.setLine(pt0, pt3); g2.draw(workingLine); } } } } /** * Converts a data value to an angle against this scale. * * @param value the data value. * * @return The angle (in degrees, using the same specification as Java's * Arc2D class). * * @see #angleToValue(double) */ public double valueToAngle(double value) { double range = this.upperBound - this.lowerBound; double unit = this.extent / range; return this.startAngle + unit * (value - this.lowerBound); } /** * Converts the given angle to a data value, based on this scale. * * @param angle the angle. * * @return The data value. * * @see #valueToAngle(double) */ public double angleToValue(double angle) { return Double.NaN; // FIXME } /** * Tests this StandardDialScale for equality with an arbitrary * object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardDialScale)) { return false; } StandardDialScale that = (StandardDialScale) obj; if (this.lowerBound != that.lowerBound) { return false; } if (this.upperBound != that.upperBound) { return false; } if (this.startAngle != that.startAngle) { return false; } if (this.extent != that.extent) { return false; } if (this.tickRadius != that.tickRadius) { return false; } if (this.majorTickIncrement != that.majorTickIncrement) { return false; } if (this.majorTickLength != that.majorTickLength) { return false; } if (!PaintUtilities.equal(this.majorTickPaint, that.majorTickPaint)) { return false; } if (!this.majorTickStroke.equals(that.majorTickStroke)) { return false; } if (this.minorTickCount != that.minorTickCount) { return false; } if (this.minorTickLength != that.minorTickLength) { return false; } if (!PaintUtilities.equal(this.minorTickPaint, that.minorTickPaint)) { return false; } if (!this.minorTickStroke.equals(that.minorTickStroke)) { return false; } if (this.tickLabelsVisible != that.tickLabelsVisible) { return false; } if (this.tickLabelOffset != that.tickLabelOffset) { return false; } if (!this.tickLabelFont.equals(that.tickLabelFont)) { return false; } if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; // lowerBound long temp = Double.doubleToLongBits(this.lowerBound); result = 37 * result + (int) (temp ^ (temp >>> 32)); // upperBound temp = Double.doubleToLongBits(this.upperBound); result = 37 * result + (int) (temp ^ (temp >>> 32)); // startAngle temp = Double.doubleToLongBits(this.startAngle); result = 37 * result + (int) (temp ^ (temp >>> 32)); // extent temp = Double.doubleToLongBits(this.extent); result = 37 * result + (int) (temp ^ (temp >>> 32)); // tickRadius temp = Double.doubleToLongBits(this.tickRadius); result = 37 * result + (int) (temp ^ (temp >>> 32)); // majorTickIncrement // majorTickLength // majorTickPaint // majorTickStroke // minorTickCount // minorTickLength // minorTickPaint // minorTickStroke // tickLabelOffset // tickLabelFont // tickLabelsVisible // tickLabelFormatter // firstTickLabelsVisible return result; } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if this instance is not cloneable. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.majorTickPaint, stream); SerialUtilities.writeStroke(this.majorTickStroke, stream); SerialUtilities.writePaint(this.minorTickPaint, stream); SerialUtilities.writeStroke(this.minorTickStroke, stream); SerialUtilities.writePaint(this.tickLabelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.majorTickPaint = SerialUtilities.readPaint(stream); this.majorTickStroke = SerialUtilities.readStroke(stream); this.minorTickPaint = SerialUtilities.readPaint(stream); this.minorTickStroke = SerialUtilities.readStroke(stream); this.tickLabelPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/dial/package.html0000644000175000017500000000021511173030414026577 0ustar vincentvincent Classes for creating dial plots. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/AbstractPieLabelDistributor.java0000644000175000017500000000665711173030414031664 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * AbstractPieLabelDistributor.java * -------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Jun-2007 : Version 1 (DG); * */ package org.jfree.chart.plot; import java.io.Serializable; import java.util.List; /** * A base class for handling the distribution of pie section labels. Create * your own subclass and set it using the * {@link PiePlot#setLabelDistributor(AbstractPieLabelDistributor)} method * if you want to customise the label distribution. */ public abstract class AbstractPieLabelDistributor implements Serializable { /** The label records. */ protected List labels; /** * Creates a new instance. */ public AbstractPieLabelDistributor() { this.labels = new java.util.ArrayList(); } /** * Returns a label record from the list. * * @param index the index. * * @return The label record. */ public PieLabelRecord getPieLabelRecord(int index) { return (PieLabelRecord) this.labels.get(index); } /** * Adds a label record. * * @param record the label record (null not permitted). */ public void addPieLabelRecord(PieLabelRecord record) { if (record == null) { throw new IllegalArgumentException("Null 'record' argument."); } this.labels.add(record); } /** * Returns the number of items in the list. * * @return The item count. */ public int getItemCount() { return this.labels.size(); } /** * Clears the list of labels. */ public void clear() { this.labels.clear(); } /** * Called by the {@link PiePlot} class. Implementations should distribute * the labels in this.labels then return. * * @param minY the y-coordinate for the top of the label area. * @param height the height of the label area. */ public abstract void distributeLabels(double minY, double height); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CategoryCrosshairState.java0000644000175000017500000001314711173030414030714 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryCrosshairState.java * --------------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.plot; import java.awt.geom.Point2D; import org.jfree.chart.renderer.category.CategoryItemRenderer; /** * Represents state information for the crosshairs in a {@link CategoryPlot}. * An instance of this class is created at the start of the rendering process, * and updated as each data item is rendered. At the end of the rendering * process, this class holds the row key, column key and value for the * crosshair location. * * @since 1.0.11 */ public class CategoryCrosshairState extends CrosshairState { /** * The row key for the crosshair point. */ private Comparable rowKey; /** * The column key for the crosshair point. */ private Comparable columnKey; /** * Creates a new instance. */ public CategoryCrosshairState() { this.rowKey = null; this.columnKey = null; } /** * Returns the row key. * * @return The row key. */ public Comparable getRowKey() { return this.rowKey; } /** * Sets the row key. * * @param key the row key. */ public void setRowKey(Comparable key) { this.rowKey = key; } /** * Returns the column key. * * @return The column key. */ public Comparable getColumnKey() { return this.columnKey; } /** * Sets the column key. * * @param key the key. */ public void setColumnKey(Comparable key) { this.columnKey = key; } /** * Evaluates a data point from a {@link CategoryItemRenderer} and if it is * the closest to the anchor point it becomes the new crosshair point. * * @param rowKey the row key. * @param columnKey the column key. * @param value y coordinate (measured against the range axis). * @param datasetIndex the dataset index for this point. * @param transX x translated into Java2D space. * @param transY y translated into Java2D space. * @param orientation the plot orientation. */ public void updateCrosshairPoint(Comparable rowKey, Comparable columnKey, double value, int datasetIndex, double transX, double transY, PlotOrientation orientation) { Point2D anchor = getAnchor(); if (anchor != null) { double xx = anchor.getX(); double yy = anchor.getY(); if (orientation == PlotOrientation.HORIZONTAL) { double temp = yy; yy = xx; xx = temp; } double d = (transX - xx) * (transX - xx) + (transY - yy) * (transY - yy); if (d < getCrosshairDistance()) { this.rowKey = rowKey; this.columnKey = columnKey; setCrosshairY(value); setDatasetIndex(datasetIndex); setCrosshairDistance(d); } } } /** * Updates only the crosshair row and column keys (this is for the case * where the range crosshair does NOT lock onto the nearest data value). * * @param rowKey the row key. * @param columnKey the column key. * @param datasetIndex the dataset axis index. * @param transX the translated x-value. * @param orientation the plot orientation. */ public void updateCrosshairX(Comparable rowKey, Comparable columnKey, int datasetIndex, double transX, PlotOrientation orientation) { Point2D anchor = getAnchor(); if (anchor != null) { double anchorX = anchor.getX(); if (orientation == PlotOrientation.HORIZONTAL) { anchorX = anchor.getY(); } double d = Math.abs(transX - anchorX); if (d < getCrosshairDistance()) { this.rowKey = rowKey; this.columnKey = columnKey; setDatasetIndex(datasetIndex); setCrosshairDistance(d); } } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CategoryMarker.java0000644000175000017500000001331511173030414027174 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CategoryMarker.java * ------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; * * Changes * ------- * 20-May-2005 : Version 1 (DG); * 19-Aug-2005 : Implemented equals(), fixed bug in constructor (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Sep-2006 : Added MarkerChangeListener support (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.awt.Stroke; import java.io.Serializable; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.ui.LengthAdjustmentType; /** * A marker for a category. *

* Note that for serialization to work correctly, the category key must be an * instance of a serializable class. * * @see CategoryPlot#addDomainMarker(CategoryMarker) */ public class CategoryMarker extends Marker implements Cloneable, Serializable { /** The category key. */ private Comparable key; /** * A hint that the marker should be drawn as a line rather than a region. */ private boolean drawAsLine = false; /** * Creates a new category marker for the specified category. * * @param key the category key. */ public CategoryMarker(Comparable key) { this(key, Color.gray, new BasicStroke(1.0f)); } /** * Creates a new category marker. * * @param key the key. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). */ public CategoryMarker(Comparable key, Paint paint, Stroke stroke) { this(key, paint, stroke, paint, stroke, 1.0f); } /** * Creates a new category marker. * * @param key the key. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). * @param outlinePaint the outline paint (null permitted). * @param outlineStroke the outline stroke (null permitted). * @param alpha the alpha transparency. */ public CategoryMarker(Comparable key, Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha) { super(paint, stroke, outlinePaint, outlineStroke, alpha); this.key = key; setLabelOffsetType(LengthAdjustmentType.EXPAND); } /** * Returns the key. * * @return The key. */ public Comparable getKey() { return this.key; } /** * Sets the key and sends a {@link MarkerChangeEvent} to all registered * listeners. * * @param key the key (null not permitted). * * @since 1.0.3 */ public void setKey(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.key = key; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the flag that controls whether the marker is drawn as a region * or a line. * * @return A line. */ public boolean getDrawAsLine() { return this.drawAsLine; } /** * Sets the flag that controls whether the marker is drawn as a region or * as a line, and sends a {@link MarkerChangeEvent} to all registered * listeners. * * @param drawAsLine the flag. */ public void setDrawAsLine(boolean drawAsLine) { this.drawAsLine = drawAsLine; notifyListeners(new MarkerChangeEvent(this)); } /** * Tests the marker for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof CategoryMarker)) { return false; } if (!super.equals(obj)) { return false; } CategoryMarker that = (CategoryMarker) obj; if (!this.key.equals(that.key)) { return false; } if (this.drawAsLine != that.drawAsLine) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CategoryPlot.java0000644000175000017500000052562411173030414026704 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * CategoryPlot.java * ----------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Jeremy Bowman; * Arnaud Lelievre; * Richard West, Advanced Micro Devices, Inc.; * Ulrich Voigt - patch 2686040; * Peter Kolb - patch 2603321; * * Changes * ------- * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); * 18-Sep-2001 : Updated header (DG); * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 23-Oct-2001 : Changed intro and trail gaps on bar plots to use percentage of * available space rather than a fixed number of units (DG); * 12-Dec-2001 : Changed constructors to protected (DG); * 13-Dec-2001 : Added tooltips (DG); * 16-Jan-2002 : Increased maximum intro and trail gap percents, plus added * some argument checking code. Thanks to Taoufik Romdhane for * suggesting this (DG); * 05-Feb-2002 : Added accessor methods for the tooltip generator, incorporated * alpha-transparency for Plot and subclasses (DG); * 06-Mar-2002 : Updated import statements (DG); * 14-Mar-2002 : Renamed BarPlot.java --> CategoryPlot.java, and changed code * to use the CategoryItemRenderer interface (DG); * 22-Mar-2002 : Dropped the getCategories() method (DG); * 23-Apr-2002 : Moved the dataset from the JFreeChart class to the Plot * class (DG); * 29-Apr-2002 : New methods to support printing values at the end of bars, * contributed by Jeremy Bowman (DG); * 11-May-2002 : New methods for label visibility and overlaid plot support, * contributed by Jeremy Bowman (DG); * 06-Jun-2002 : Removed the tooltip generator, this is now stored with the * renderer. Moved constants into the CategoryPlotConstants * interface. Updated Javadoc comments (DG); * 10-Jun-2002 : Overridden datasetChanged() method to update the upper and * lower bound on the range axis (if necessary), updated * Javadocs (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 20-Aug-2002 : Changed the constructor for Marker (DG); * 28-Aug-2002 : Added listener notification to setDomainAxis() and * setRangeAxis() (DG); * 23-Sep-2002 : Added getLegendItems() method and fixed errors reported by * Checkstyle (DG); * 28-Oct-2002 : Changes to the CategoryDataset interface (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 07-Nov-2002 : Renamed labelXXX as valueLabelXXX (DG); * 18-Nov-2002 : Added grid settings for both domain and range axis (previously * these were set in the axes) (DG); * 19-Nov-2002 : Added axis location parameters to constructor (DG); * 17-Jan-2003 : Moved to com.jrefinery.chart.plot package (DG); * 14-Feb-2003 : Fixed bug in auto-range calculation for secondary axis (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 02-May-2003 : Moved render() method up from subclasses. Added secondary * range markers. Added an attribute to control the dataset * rendering order. Added a drawAnnotations() method. Changed * the axis location from an int to an AxisLocation (DG); * 07-May-2003 : Merged HorizontalCategoryPlot and VerticalCategoryPlot into * this class (DG); * 02-Jun-2003 : Removed check for range axis compatibility (DG); * 04-Jul-2003 : Added a domain gridline position attribute (DG); * 21-Jul-2003 : Moved DrawingSupplier to Plot superclass (DG); * 19-Aug-2003 : Added equals() method and implemented Cloneable (DG); * 01-Sep-2003 : Fixed bug 797466 (no change event when secondary dataset * changes) (DG); * 02-Sep-2003 : Fixed bug 795209 (wrong dataset checked in render2 method) and * 790407 (initialise method) (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 08-Sep-2003 : Fixed bug (wrong secondary range axis being used). Changed * ValueAxis API (DG); * 10-Sep-2003 : Fixed bug in setRangeAxis() method (DG); * 15-Sep-2003 : Fixed two bugs in serialization, implemented * PublicCloneable (DG); * 23-Oct-2003 : Added event notification for changes to renderer (DG); * 26-Nov-2003 : Fixed bug (849645) in clearRangeMarkers() method (DG); * 03-Dec-2003 : Modified draw method to accept anchor (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 10-Mar-2004 : Fixed bug in axis range calculation when secondary renderer is * stacked (DG); * 12-May-2004 : Added fixed legend items (DG); * 19-May-2004 : Added check for null legend item from renderer (DG); * 02-Jun-2004 : Updated the DatasetRenderingOrder class (DG); * 05-Nov-2004 : Renamed getDatasetsMappedToRangeAxis() * --> datasetsMappedToRangeAxis(), and ensured that returned * list doesn't contain null datasets (DG); * 12-Nov-2004 : Implemented new Zoomable interface (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() in * CategoryItemRenderer (DG); * 04-May-2005 : Fixed serialization of range markers (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 20-May-2005 : Added setDomainAxes() and setRangeAxes() methods, as per * RFE 1183100 (DG); * 01-Jun-2005 : Upon deserialization, register plot as a listener with its * axes, dataset(s) and renderer(s) - see patch 1209475 (DG); * 02-Jun-2005 : Added support for domain markers (DG); * 06-Jun-2005 : Fixed equals() method for use with GradientPaint (DG); * 09-Jun-2005 : Added setRenderers(), as per RFE 1183100 (DG); * 16-Jun-2005 : Added getDomainAxisCount() and getRangeAxisCount() methods, to * match XYPlot (see RFE 1220495) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Jan-2006 : Added configureRangeAxes() to rendererChanged(), since the * renderer might influence the axis range (DG); * 27-Jan-2006 : Added various null argument checks (DG); * 18-Aug-2006 : Added getDatasetCount() method, plus a fix for bug drawing * category labels, thanks to Adriaan Joubert (1277726) (DG); * 05-Sep-2006 : Added MarkerChangeEvent support (DG); * 30-Oct-2006 : Added getDomainAxisIndex(), datasetsMappedToDomainAxis() and * getCategoriesForAxis() methods (DG); * 22-Nov-2006 : Fire PlotChangeEvent from setColumnRenderingOrder() and * setRowRenderingOrder() (DG); * 29-Nov-2006 : Fix for bug 1605207 (IntervalMarker exceeds bounds of data * area) (DG); * 26-Feb-2007 : Fix for bug 1669218 (setDomainAxisLocation() notify argument * ignored) (DG); * 13-Mar-2007 : Added null argument checks for setRangeCrosshairPaint() and * setRangeCrosshairStroke(), fixed clipping for * annotations (DG); * 07-Jun-2007 : Override drawBackground() for new GradientPaint handling (DG); * 10-Jul-2007 : Added getRangeAxisIndex(ValueAxis) method (DG); * 24-Sep-2007 : Implemented new zoom methods (DG); * 25-Oct-2007 : Added some argument checks (DG); * 05-Nov-2007 : Applied patch 1823697, by Richard West, for removal of domain * and range markers (DG); * 14-Nov-2007 : Added missing event notifications (DG); * 25-Mar-2008 : Added new methods with optional notification - see patch * 1913751 (DG); * 07-Apr-2008 : Fixed NPE in removeDomainMarker() and * removeRangeMarker() (DG); * 23-Apr-2008 : Fixed equals() and clone() methods (DG); * 26-Jun-2008 : Fixed crosshair support (DG); * 10-Jul-2008 : Fixed outline visibility for 3D renderers (DG); * 12-Aug-2008 : Added rendererCount() method (DG); * 25-Nov-2008 : Added facility to map datasets to multiples axes (DG); * 15-Dec-2008 : Cleaned up grid drawing methods (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 21-Jan-2009 : Added rangeMinorGridlinesVisible flag (DG); * 18-Mar-2009 : Modified anchored zoom behaviour (DG); * 19-Mar-2009 : Implemented Pannable interface - see patch 2686040 (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import java.util.TreeMap; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.annotations.CategoryAnnotation; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.AxisCollection; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.CategoryAnchor; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.TickType; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.axis.ValueTick; import org.jfree.chart.event.ChartChangeEventType; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.CategoryItemRendererState; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.Dataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.io.SerialUtilities; import org.jfree.ui.Layer; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectList; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; import org.jfree.util.SortOrder; /** * A general plotting class that uses data from a {@link CategoryDataset} and * renders each data item using a {@link CategoryItemRenderer}. */ public class CategoryPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable, RendererChangeListener, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3537691700434728188L; /** * The default visibility of the grid lines plotted against the domain * axis. */ public static final boolean DEFAULT_DOMAIN_GRIDLINES_VISIBLE = false; /** * The default visibility of the grid lines plotted against the range * axis. */ public static final boolean DEFAULT_RANGE_GRIDLINES_VISIBLE = true; /** The default grid line stroke. */ public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] {2.0f, 2.0f}, 0.0f); /** The default grid line paint. */ public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; /** The default value label font. */ public static final Font DEFAULT_VALUE_LABEL_FONT = new Font("SansSerif", Font.PLAIN, 10); /** * The default crosshair visibility. * * @since 1.0.5 */ public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false; /** * The default crosshair stroke. * * @since 1.0.5 */ public static final Stroke DEFAULT_CROSSHAIR_STROKE = DEFAULT_GRIDLINE_STROKE; /** * The default crosshair paint. * * @since 1.0.5 */ public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** The plot orientation. */ private PlotOrientation orientation; /** The offset between the data area and the axes. */ private RectangleInsets axisOffset; /** Storage for the domain axes. */ private ObjectList domainAxes; /** Storage for the domain axis locations. */ private ObjectList domainAxisLocations; /** * A flag that controls whether or not the shared domain axis is drawn * (only relevant when the plot is being used as a subplot). */ private boolean drawSharedDomainAxis; /** Storage for the range axes. */ private ObjectList rangeAxes; /** Storage for the range axis locations. */ private ObjectList rangeAxisLocations; /** Storage for the datasets. */ private ObjectList datasets; /** Storage for keys that map datasets to domain axes. */ private TreeMap datasetToDomainAxesMap; /** Storage for keys that map datasets to range axes. */ private TreeMap datasetToRangeAxesMap; /** Storage for the renderers. */ private ObjectList renderers; /** The dataset rendering order. */ private DatasetRenderingOrder renderingOrder = DatasetRenderingOrder.REVERSE; /** * Controls the order in which the columns are traversed when rendering the * data items. */ private SortOrder columnRenderingOrder = SortOrder.ASCENDING; /** * Controls the order in which the rows are traversed when rendering the * data items. */ private SortOrder rowRenderingOrder = SortOrder.ASCENDING; /** * A flag that controls whether the grid-lines for the domain axis are * visible. */ private boolean domainGridlinesVisible; /** The position of the domain gridlines relative to the category. */ private CategoryAnchor domainGridlinePosition; /** The stroke used to draw the domain grid-lines. */ private transient Stroke domainGridlineStroke; /** The paint used to draw the domain grid-lines. */ private transient Paint domainGridlinePaint; /** * A flag that controls whether or not the zero baseline against the range * axis is visible. * * @since 1.0.13 */ private boolean rangeZeroBaselineVisible; /** * The stroke used for the zero baseline against the range axis. * * @since 1.0.13 */ private transient Stroke rangeZeroBaselineStroke; /** * The paint used for the zero baseline against the range axis. * * @since 1.0.13 */ private transient Paint rangeZeroBaselinePaint; /** * A flag that controls whether the grid-lines for the range axis are * visible. */ private boolean rangeGridlinesVisible; /** The stroke used to draw the range axis grid-lines. */ private transient Stroke rangeGridlineStroke; /** The paint used to draw the range axis grid-lines. */ private transient Paint rangeGridlinePaint; /** * A flag that controls whether or not gridlines are shown for the minor * tick values on the primary range axis. * * @since 1.0.13 */ private boolean rangeMinorGridlinesVisible; /** * The stroke used to draw the range minor grid-lines. * * @since 1.0.13 */ private transient Stroke rangeMinorGridlineStroke; /** * The paint used to draw the range minor grid-lines. * * @since 1.0.13 */ private transient Paint rangeMinorGridlinePaint; /** The anchor value. */ private double anchorValue; /** * The index for the dataset that the crosshairs are linked to (this * determines which axes the crosshairs are plotted against). * * @since 1.0.11 */ private int crosshairDatasetIndex; /** * A flag that controls the visibility of the domain crosshair. * * @since 1.0.11 */ private boolean domainCrosshairVisible; /** * The row key for the crosshair point. * * @since 1.0.11 */ private Comparable domainCrosshairRowKey; /** * The column key for the crosshair point. * * @since 1.0.11 */ private Comparable domainCrosshairColumnKey; /** * The stroke used to draw the domain crosshair if it is visible. * * @since 1.0.11 */ private transient Stroke domainCrosshairStroke; /** * The paint used to draw the domain crosshair if it is visible. * * @since 1.0.11 */ private transient Paint domainCrosshairPaint; /** A flag that controls whether or not a range crosshair is drawn. */ private boolean rangeCrosshairVisible; /** The range crosshair value. */ private double rangeCrosshairValue; /** The pen/brush used to draw the crosshair (if any). */ private transient Stroke rangeCrosshairStroke; /** The color used to draw the crosshair (if any). */ private transient Paint rangeCrosshairPaint; /** * A flag that controls whether or not the crosshair locks onto actual * data points. */ private boolean rangeCrosshairLockedOnData = true; /** A map containing lists of markers for the domain axes. */ private Map foregroundDomainMarkers; /** A map containing lists of markers for the domain axes. */ private Map backgroundDomainMarkers; /** A map containing lists of markers for the range axes. */ private Map foregroundRangeMarkers; /** A map containing lists of markers for the range axes. */ private Map backgroundRangeMarkers; /** * A (possibly empty) list of annotations for the plot. The list should * be initialised in the constructor and never allowed to be * null. */ private List annotations; /** * The weight for the plot (only relevant when the plot is used as a subplot * within a combined plot). */ private int weight; /** The fixed space for the domain axis. */ private AxisSpace fixedDomainAxisSpace; /** The fixed space for the range axis. */ private AxisSpace fixedRangeAxisSpace; /** * An optional collection of legend items that can be returned by the * getLegendItems() method. */ private LegendItemCollection fixedLegendItems; /** * A flag that controls whether or not panning is enabled for the * range axis/axes. * * @since 1.0.13 */ private boolean rangePannable; /** * Default constructor. */ public CategoryPlot() { this(null, null, null, null); } /** * Creates a new plot. * * @param dataset the dataset (null permitted). * @param domainAxis the domain axis (null permitted). * @param rangeAxis the range axis (null permitted). * @param renderer the item renderer (null permitted). * */ public CategoryPlot(CategoryDataset dataset, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; // allocate storage for dataset, axes and renderers this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.renderers = new ObjectList(); this.datasets = new ObjectList(); this.datasets.set(0, dataset); if (dataset != null) { dataset.addChangeListener(this); } this.axisOffset = RectangleInsets.ZERO_INSETS; setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT, false); setRangeAxisLocation(AxisLocation.TOP_OR_LEFT, false); this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); domainAxis.addChangeListener(this); } this.drawSharedDomainAxis = false; this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); rangeAxis.addChangeListener(this); } configureDomainAxes(); configureRangeAxes(); this.domainGridlinesVisible = DEFAULT_DOMAIN_GRIDLINES_VISIBLE; this.domainGridlinePosition = CategoryAnchor.MIDDLE; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = Color.black; this.rangeZeroBaselineStroke = new BasicStroke(0.5f); this.rangeGridlinesVisible = DEFAULT_RANGE_GRIDLINES_VISIBLE; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeMinorGridlinePaint = Color.white; this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.anchorValue = 0.0; this.domainCrosshairVisible = false; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.annotations = new java.util.ArrayList(); this.rangePannable = false; } /** * Returns a string describing the type of plot. * * @return The type. */ public String getPlotType() { return localizationResources.getString("Category_Plot"); } /** * Returns the orientation of the plot. * * @return The orientation of the plot (never null). * * @see #setOrientation(PlotOrientation) */ public PlotOrientation getOrientation() { return this.orientation; } /** * Sets the orientation for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param orientation the orientation (null not permitted). * * @see #getOrientation() */ public void setOrientation(PlotOrientation orientation) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } this.orientation = orientation; fireChangeEvent(); } /** * Returns the axis offset. * * @return The axis offset (never null). * * @see #setAxisOffset(RectangleInsets) */ public RectangleInsets getAxisOffset() { return this.axisOffset; } /** * Sets the axis offsets (gap between the data area and the axes) and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param offset the offset (null not permitted). * * @see #getAxisOffset() */ public void setAxisOffset(RectangleInsets offset) { if (offset == null) { throw new IllegalArgumentException("Null 'offset' argument."); } this.axisOffset = offset; fireChangeEvent(); } /** * Returns the domain axis for the plot. If the domain axis for this plot * is null, then the method will return the parent plot's * domain axis (if there is a parent plot). * * @return The domain axis (null permitted). * * @see #setDomainAxis(CategoryAxis) */ public CategoryAxis getDomainAxis() { return getDomainAxis(0); } /** * Returns a domain axis. * * @param index the axis index. * * @return The axis (null possible). * * @see #setDomainAxis(int, CategoryAxis) */ public CategoryAxis getDomainAxis(int index) { CategoryAxis result = null; if (index < this.domainAxes.size()) { result = (CategoryAxis) this.domainAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) parent; result = cp.getDomainAxis(index); } } return result; } /** * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis (null permitted). * * @see #getDomainAxis() */ public void setDomainAxis(CategoryAxis axis) { setDomainAxis(0, axis); } /** * Sets a domain axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param axis the axis (null permitted). * * @see #getDomainAxis(int) */ public void setDomainAxis(int index, CategoryAxis axis) { setDomainAxis(index, axis, true); } /** * Sets a domain axis and, if requested, sends a {@link PlotChangeEvent} to * all registered listeners. * * @param index the axis index. * @param axis the axis (null permitted). * @param notify notify listeners? */ public void setDomainAxis(int index, CategoryAxis axis, boolean notify) { CategoryAxis existing = (CategoryAxis) this.domainAxes.get(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.domainAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } if (notify) { fireChangeEvent(); } } /** * Sets the domain axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (null not permitted). * * @see #setRangeAxes(ValueAxis[]) */ public void setDomainAxes(CategoryAxis[] axes) { for (int i = 0; i < axes.length; i++) { setDomainAxis(i, axes[i], false); } fireChangeEvent(); } /** * Returns the index of the specified axis, or -1 if the axis * is not assigned to the plot. * * @param axis the axis (null not permitted). * * @return The axis index. * * @see #getDomainAxis(int) * @see #getRangeAxisIndex(ValueAxis) * * @since 1.0.3 */ public int getDomainAxisIndex(CategoryAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } return this.domainAxes.indexOf(axis); } /** * Returns the domain axis location for the primary domain axis. * * @return The location (never null). * * @see #getRangeAxisLocation() */ public AxisLocation getDomainAxisLocation() { return getDomainAxisLocation(0); } /** * Returns the location for a domain axis. * * @param index the axis index. * * @return The location. * * @see #setDomainAxisLocation(int, AxisLocation) */ public AxisLocation getDomainAxisLocation(int index) { AxisLocation result = null; if (index < this.domainAxisLocations.size()) { result = (AxisLocation) this.domainAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getDomainAxisLocation(0)); } return result; } /** * Sets the location of the domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param location the axis location (null not permitted). * * @see #getDomainAxisLocation() * @see #setDomainAxisLocation(int, AxisLocation) */ public void setDomainAxisLocation(AxisLocation location) { // delegate... setDomainAxisLocation(0, location, true); } /** * Sets the location of the domain axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the axis location (null not permitted). * @param notify a flag that controls whether listeners are notified. */ public void setDomainAxisLocation(AxisLocation location, boolean notify) { // delegate... setDomainAxisLocation(0, location, notify); } /** * Sets the location for a domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param index the axis index. * @param location the location. * * @see #getDomainAxisLocation(int) * @see #setRangeAxisLocation(int, AxisLocation) */ public void setDomainAxisLocation(int index, AxisLocation location) { // delegate... setDomainAxisLocation(index, location, true); } /** * Sets the location for a domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param index the axis index. * @param location the location. * @param notify notify listeners? * * @since 1.0.5 * * @see #getDomainAxisLocation(int) * @see #setRangeAxisLocation(int, AxisLocation, boolean) */ public void setDomainAxisLocation(int index, AxisLocation location, boolean notify) { if (index == 0 && location == null) { throw new IllegalArgumentException( "Null 'location' for index 0 not permitted."); } this.domainAxisLocations.set(index, location); if (notify) { fireChangeEvent(); } } /** * Returns the domain axis edge. This is derived from the axis location * and the plot orientation. * * @return The edge (never null). */ public RectangleEdge getDomainAxisEdge() { return getDomainAxisEdge(0); } /** * Returns the edge for a domain axis. * * @param index the axis index. * * @return The edge (never null). */ public RectangleEdge getDomainAxisEdge(int index) { RectangleEdge result = null; AxisLocation location = getDomainAxisLocation(index); if (location != null) { result = Plot.resolveDomainAxisLocation(location, this.orientation); } else { result = RectangleEdge.opposite(getDomainAxisEdge(0)); } return result; } /** * Returns the number of domain axes. * * @return The axis count. */ public int getDomainAxisCount() { return this.domainAxes.size(); } /** * Clears the domain axes from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. */ public void clearDomainAxes() { for (int i = 0; i < this.domainAxes.size(); i++) { CategoryAxis axis = (CategoryAxis) this.domainAxes.get(i); if (axis != null) { axis.removeChangeListener(this); } } this.domainAxes.clear(); fireChangeEvent(); } /** * Configures the domain axes. */ public void configureDomainAxes() { for (int i = 0; i < this.domainAxes.size(); i++) { CategoryAxis axis = (CategoryAxis) this.domainAxes.get(i); if (axis != null) { axis.configure(); } } } /** * Returns the range axis for the plot. If the range axis for this plot is * null, then the method will return the parent plot's range axis (if there * is a parent plot). * * @return The range axis (possibly null). */ public ValueAxis getRangeAxis() { return getRangeAxis(0); } /** * Returns a range axis. * * @param index the axis index. * * @return The axis (null possible). */ public ValueAxis getRangeAxis(int index) { ValueAxis result = null; if (index < this.rangeAxes.size()) { result = (ValueAxis) this.rangeAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) parent; result = cp.getRangeAxis(index); } } return result; } /** * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis (null permitted). */ public void setRangeAxis(ValueAxis axis) { setRangeAxis(0, axis); } /** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param index the axis index. * @param axis the axis. */ public void setRangeAxis(int index, ValueAxis axis) { setRangeAxis(index, axis, true); } /** * Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to * all registered listeners. * * @param index the axis index. * @param axis the axis. * @param notify notify listeners? */ public void setRangeAxis(int index, ValueAxis axis, boolean notify) { ValueAxis existing = (ValueAxis) this.rangeAxes.get(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.rangeAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } if (notify) { fireChangeEvent(); } } /** * Sets the range axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (null not permitted). * * @see #setDomainAxes(CategoryAxis[]) */ public void setRangeAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setRangeAxis(i, axes[i], false); } fireChangeEvent(); } /** * Returns the index of the specified axis, or -1 if the axis * is not assigned to the plot. * * @param axis the axis (null not permitted). * * @return The axis index. * * @see #getRangeAxis(int) * @see #getDomainAxisIndex(CategoryAxis) * * @since 1.0.7 */ public int getRangeAxisIndex(ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } int result = this.rangeAxes.indexOf(axis); if (result < 0) { // try the parent plot Plot parent = getParent(); if (parent instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) parent; result = p.getRangeAxisIndex(axis); } } return result; } /** * Returns the range axis location. * * @return The location (never null). */ public AxisLocation getRangeAxisLocation() { return getRangeAxisLocation(0); } /** * Returns the location for a range axis. * * @param index the axis index. * * @return The location. * * @see #setRangeAxisLocation(int, AxisLocation) */ public AxisLocation getRangeAxisLocation(int index) { AxisLocation result = null; if (index < this.rangeAxisLocations.size()) { result = (AxisLocation) this.rangeAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getRangeAxisLocation(0)); } return result; } /** * Sets the location of the range axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param location the location (null not permitted). * * @see #setRangeAxisLocation(AxisLocation, boolean) * @see #setDomainAxisLocation(AxisLocation) */ public void setRangeAxisLocation(AxisLocation location) { // defer argument checking... setRangeAxisLocation(location, true); } /** * Sets the location of the range axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the location (null not permitted). * @param notify notify listeners? * * @see #setDomainAxisLocation(AxisLocation, boolean) */ public void setRangeAxisLocation(AxisLocation location, boolean notify) { setRangeAxisLocation(0, location, notify); } /** * Sets the location for a range axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param index the axis index. * @param location the location. * * @see #getRangeAxisLocation(int) * @see #setRangeAxisLocation(int, AxisLocation, boolean) */ public void setRangeAxisLocation(int index, AxisLocation location) { setRangeAxisLocation(index, location, true); } /** * Sets the location for a range axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param index the axis index. * @param location the location. * @param notify notify listeners? * * @see #getRangeAxisLocation(int) * @see #setDomainAxisLocation(int, AxisLocation, boolean) */ public void setRangeAxisLocation(int index, AxisLocation location, boolean notify) { if (index == 0 && location == null) { throw new IllegalArgumentException( "Null 'location' for index 0 not permitted."); } this.rangeAxisLocations.set(index, location); if (notify) { fireChangeEvent(); } } /** * Returns the edge where the primary range axis is located. * * @return The edge (never null). */ public RectangleEdge getRangeAxisEdge() { return getRangeAxisEdge(0); } /** * Returns the edge for a range axis. * * @param index the axis index. * * @return The edge. */ public RectangleEdge getRangeAxisEdge(int index) { AxisLocation location = getRangeAxisLocation(index); RectangleEdge result = Plot.resolveRangeAxisLocation(location, this.orientation); if (result == null) { result = RectangleEdge.opposite(getRangeAxisEdge(0)); } return result; } /** * Returns the number of range axes. * * @return The axis count. */ public int getRangeAxisCount() { return this.rangeAxes.size(); } /** * Clears the range axes from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. */ public void clearRangeAxes() { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { axis.removeChangeListener(this); } } this.rangeAxes.clear(); fireChangeEvent(); } /** * Configures the range axes. */ public void configureRangeAxes() { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { axis.configure(); } } } /** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly null). * * @see #setDataset(CategoryDataset) */ public CategoryDataset getDataset() { return getDataset(0); } /** * Returns the dataset at the given index. * * @param index the dataset index. * * @return The dataset (possibly null). * * @see #setDataset(int, CategoryDataset) */ public CategoryDataset getDataset(int index) { CategoryDataset result = null; if (this.datasets.size() > index) { result = (CategoryDataset) this.datasets.get(index); } return result; } /** * Sets the dataset for the plot, replacing the existing dataset, if there * is one. This method also calls the * {@link #datasetChanged(DatasetChangeEvent)} method, which adjusts the * axis ranges if necessary and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param dataset the dataset (null permitted). * * @see #getDataset() */ public void setDataset(CategoryDataset dataset) { setDataset(0, dataset); } /** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (null permitted). * * @see #getDataset(int) */ public void setDataset(int index, CategoryDataset dataset) { CategoryDataset existing = (CategoryDataset) this.datasets.get(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the number of datasets. * * @return The number of datasets. * * @since 1.0.2 */ public int getDatasetCount() { return this.datasets.size(); } /** * Returns the index of the specified dataset, or -1 if the * dataset does not belong to the plot. * * @param dataset the dataset (null not permitted). * * @return The index. * * @since 1.0.11 */ public int indexOf(CategoryDataset dataset) { int result = -1; for (int i = 0; i < this.datasets.size(); i++) { if (dataset == this.datasets.get(i)) { result = i; break; } } return result; } /** * Maps a dataset to a particular domain axis. * * @param index the dataset index (zero-based). * @param axisIndex the axis index (zero-based). * * @see #getDomainAxisForDataset(int) */ public void mapDatasetToDomainAxis(int index, int axisIndex) { List axisIndices = new java.util.ArrayList(1); axisIndices.add(new Integer(axisIndex)); mapDatasetToDomainAxes(index, axisIndices); } /** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices (null permitted). * * @since 1.0.12 */ public void mapDatasetToDomainAxes(int index, List axisIndices) { if (index < 0) { throw new IllegalArgumentException("Requires 'index' >= 0."); } checkAxisIndices(axisIndices); Integer key = new Integer(index); this.datasetToDomainAxesMap.put(key, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); } /** * This method is used to perform argument checking on the list of * axis indices passed to mapDatasetToDomainAxes() and * mapDatasetToRangeAxes(). * * @param indices the list of indices (null permitted). */ private void checkAxisIndices(List indices) { // axisIndices can be: // 1. null; // 2. non-empty, containing only Integer objects that are unique. if (indices == null) { return; // OK } int count = indices.size(); if (count == 0) { throw new IllegalArgumentException("Empty list not permitted."); } HashSet set = new HashSet(); for (int i = 0; i < count; i++) { Object item = indices.get(i); if (!(item instanceof Integer)) { throw new IllegalArgumentException( "Indices must be Integer instances."); } if (set.contains(item)) { throw new IllegalArgumentException("Indices must be unique."); } set.add(item); } } /** * Returns the domain axis for a dataset. You can change the axis for a * dataset using the {@link #mapDatasetToDomainAxis(int, int)} method. * * @param index the dataset index. * * @return The domain axis. * * @see #mapDatasetToDomainAxis(int, int) */ public CategoryAxis getDomainAxisForDataset(int index) { if (index < 0) { throw new IllegalArgumentException("Negative 'index'."); } CategoryAxis axis = null; List axisIndices = (List) this.datasetToDomainAxesMap.get( new Integer(index)); if (axisIndices != null) { // the first axis in the list is used for data <--> Java2D Integer axisIndex = (Integer) axisIndices.get(0); axis = getDomainAxis(axisIndex.intValue()); } else { axis = getDomainAxis(0); } return axis; } /** * Maps a dataset to a particular range axis. * * @param index the dataset index (zero-based). * @param axisIndex the axis index (zero-based). * * @see #getRangeAxisForDataset(int) */ public void mapDatasetToRangeAxis(int index, int axisIndex) { List axisIndices = new java.util.ArrayList(1); axisIndices.add(new Integer(axisIndex)); mapDatasetToRangeAxes(index, axisIndices); } /** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices (null permitted). * * @since 1.0.12 */ public void mapDatasetToRangeAxes(int index, List axisIndices) { if (index < 0) { throw new IllegalArgumentException("Requires 'index' >= 0."); } checkAxisIndices(axisIndices); Integer key = new Integer(index); this.datasetToRangeAxesMap.put(key, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); } /** * Returns the range axis for a dataset. You can change the axis for a * dataset using the {@link #mapDatasetToRangeAxis(int, int)} method. * * @param index the dataset index. * * @return The range axis. * * @see #mapDatasetToRangeAxis(int, int) */ public ValueAxis getRangeAxisForDataset(int index) { if (index < 0) { throw new IllegalArgumentException("Negative 'index'."); } ValueAxis axis = null; List axisIndices = (List) this.datasetToRangeAxesMap.get( new Integer(index)); if (axisIndices != null) { // the first axis in the list is used for data <--> Java2D Integer axisIndex = (Integer) axisIndices.get(0); axis = getRangeAxis(axisIndex.intValue()); } else { axis = getRangeAxis(0); } return axis; } /** * Returns the number of renderer slots for this plot. * * @return The number of renderer slots. * * @since 1.0.11 */ public int getRendererCount() { return this.renderers.size(); } /** * Returns a reference to the renderer for the plot. * * @return The renderer. * * @see #setRenderer(CategoryItemRenderer) */ public CategoryItemRenderer getRenderer() { return getRenderer(0); } /** * Returns the renderer at the given index. * * @param index the renderer index. * * @return The renderer (possibly null). * * @see #setRenderer(int, CategoryItemRenderer) */ public CategoryItemRenderer getRenderer(int index) { CategoryItemRenderer result = null; if (this.renderers.size() > index) { result = (CategoryItemRenderer) this.renderers.get(index); } return result; } /** * Sets the renderer at index 0 (sometimes referred to as the "primary" * renderer) and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param renderer the renderer (null permitted. * * @see #getRenderer() */ public void setRenderer(CategoryItemRenderer renderer) { setRenderer(0, renderer, true); } /** * Sets the renderer at index 0 (sometimes referred to as the "primary" * renderer) and, if requested, sends a {@link PlotChangeEvent} to all * registered listeners. *

* You can set the renderer to null, but this is not * recommended because: *

    *
  • no data will be displayed;
  • *
  • the plot background will not be painted;
  • *
* * @param renderer the renderer (null permitted). * @param notify notify listeners? * * @see #getRenderer() */ public void setRenderer(CategoryItemRenderer renderer, boolean notify) { setRenderer(0, renderer, notify); } /** * Sets the renderer at the specified index and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the index. * @param renderer the renderer (null permitted). * * @see #getRenderer(int) * @see #setRenderer(int, CategoryItemRenderer, boolean) */ public void setRenderer(int index, CategoryItemRenderer renderer) { setRenderer(index, renderer, true); } /** * Sets a renderer. A {@link PlotChangeEvent} is sent to all registered * listeners. * * @param index the index. * @param renderer the renderer (null permitted). * @param notify notify listeners? * * @see #getRenderer(int) */ public void setRenderer(int index, CategoryItemRenderer renderer, boolean notify) { // stop listening to the existing renderer... CategoryItemRenderer existing = (CategoryItemRenderer) this.renderers.get(index); if (existing != null) { existing.removeChangeListener(this); } // register the new renderer... this.renderers.set(index, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } configureDomainAxes(); configureRangeAxes(); if (notify) { fireChangeEvent(); } } /** * Sets the renderers for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param renderers the renderers. */ public void setRenderers(CategoryItemRenderer[] renderers) { for (int i = 0; i < renderers.length; i++) { setRenderer(i, renderers[i], false); } fireChangeEvent(); } /** * Returns the renderer for the specified dataset. If the dataset doesn't * belong to the plot, this method will return null. * * @param dataset the dataset (null permitted). * * @return The renderer (possibly null). */ public CategoryItemRenderer getRendererForDataset(CategoryDataset dataset) { CategoryItemRenderer result = null; for (int i = 0; i < this.datasets.size(); i++) { if (this.datasets.get(i) == dataset) { result = (CategoryItemRenderer) this.renderers.get(i); break; } } return result; } /** * Returns the index of the specified renderer, or -1 if the * renderer is not assigned to this plot. * * @param renderer the renderer (null permitted). * * @return The renderer index. */ public int getIndexOf(CategoryItemRenderer renderer) { return this.renderers.indexOf(renderer); } /** * Returns the dataset rendering order. * * @return The order (never null). * * @see #setDatasetRenderingOrder(DatasetRenderingOrder) */ public DatasetRenderingOrder getDatasetRenderingOrder() { return this.renderingOrder; } /** * Sets the rendering order and sends a {@link PlotChangeEvent} to all * registered listeners. By default, the plot renders the primary dataset * last (so that the primary dataset overlays the secondary datasets). You * can reverse this if you want to. * * @param order the rendering order (null not permitted). * * @see #getDatasetRenderingOrder() */ public void setDatasetRenderingOrder(DatasetRenderingOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.renderingOrder = order; fireChangeEvent(); } /** * Returns the order in which the columns are rendered. The default value * is SortOrder.ASCENDING. * * @return The column rendering order (never nullnull not permitted). * * @see #getColumnRenderingOrder() * @see #setRowRenderingOrder(SortOrder) */ public void setColumnRenderingOrder(SortOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.columnRenderingOrder = order; fireChangeEvent(); } /** * Returns the order in which the rows should be rendered. The default * value is SortOrder.ASCENDING. * * @return The order (never null). * * @see #setRowRenderingOrder(SortOrder) */ public SortOrder getRowRenderingOrder() { return this.rowRenderingOrder; } /** * Sets the row order in which the items in each dataset should be * rendered and sends a {@link PlotChangeEvent} to all registered * listeners. Note that this affects the order in which items are drawn, * NOT their position in the chart. * * @param order the order (null not permitted). * * @see #getRowRenderingOrder() * @see #setColumnRenderingOrder(SortOrder) */ public void setRowRenderingOrder(SortOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.rowRenderingOrder = order; fireChangeEvent(); } /** * Returns the flag that controls whether the domain grid-lines are visible. * * @return The true or false. * * @see #setDomainGridlinesVisible(boolean) */ public boolean isDomainGridlinesVisible() { return this.domainGridlinesVisible; } /** * Sets the flag that controls whether or not grid-lines are drawn against * the domain axis. *

* If the flag value changes, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isDomainGridlinesVisible() */ public void setDomainGridlinesVisible(boolean visible) { if (this.domainGridlinesVisible != visible) { this.domainGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the position used for the domain gridlines. * * @return The gridline position (never null). * * @see #setDomainGridlinePosition(CategoryAnchor) */ public CategoryAnchor getDomainGridlinePosition() { return this.domainGridlinePosition; } /** * Sets the position used for the domain gridlines and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param position the position (null not permitted). * * @see #getDomainGridlinePosition() */ public void setDomainGridlinePosition(CategoryAnchor position) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } this.domainGridlinePosition = position; fireChangeEvent(); } /** * Returns the stroke used to draw grid-lines against the domain axis. * * @return The stroke (never null). * * @see #setDomainGridlineStroke(Stroke) */ public Stroke getDomainGridlineStroke() { return this.domainGridlineStroke; } /** * Sets the stroke used to draw grid-lines against the domain axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getDomainGridlineStroke() */ public void setDomainGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' not permitted."); } this.domainGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint used to draw grid-lines against the domain axis. * * @return The paint (never null). * * @see #setDomainGridlinePaint(Paint) */ public Paint getDomainGridlinePaint() { return this.domainGridlinePaint; } /** * Sets the paint used to draw the grid-lines (if any) against the domain * axis and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getDomainGridlinePaint() */ public void setDomainGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainGridlinePaint = paint; fireChangeEvent(); } /** * Returns a flag that controls whether or not a zero baseline is * displayed for the range axis. * * @return A boolean. * * @see #setRangeZeroBaselineVisible(boolean) * * @since 1.0.13 */ public boolean isRangeZeroBaselineVisible() { return this.rangeZeroBaselineVisible; } /** * Sets the flag that controls whether or not the zero baseline is * displayed for the range axis, and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param visible the flag. * * @see #isRangeZeroBaselineVisible() * * @since 1.0.13 */ public void setRangeZeroBaselineVisible(boolean visible) { this.rangeZeroBaselineVisible = visible; fireChangeEvent(); } /** * Returns the stroke used for the zero baseline against the range axis. * * @return The stroke (never null). * * @see #setRangeZeroBaselineStroke(Stroke) * * @since 1.0.13 */ public Stroke getRangeZeroBaselineStroke() { return this.rangeZeroBaselineStroke; } /** * Sets the stroke for the zero baseline for the range axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getRangeZeroBaselineStroke() * * @since 1.0.13 */ public void setRangeZeroBaselineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeZeroBaselineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the zero baseline (if any) plotted against the * range axis. * * @return The paint (never null). * * @see #setRangeZeroBaselinePaint(Paint) * * @since 1.0.13 */ public Paint getRangeZeroBaselinePaint() { return this.rangeZeroBaselinePaint; } /** * Sets the paint for the zero baseline plotted against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeZeroBaselinePaint() * * @since 1.0.13 */ public void setRangeZeroBaselinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeZeroBaselinePaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether the range grid-lines are visible. * * @return The flag. * * @see #setRangeGridlinesVisible(boolean) */ public boolean isRangeGridlinesVisible() { return this.rangeGridlinesVisible; } /** * Sets the flag that controls whether or not grid-lines are drawn against * the range axis. If the flag changes value, a {@link PlotChangeEvent} is * sent to all registered listeners. * * @param visible the new value of the flag. * * @see #isRangeGridlinesVisible() */ public void setRangeGridlinesVisible(boolean visible) { if (this.rangeGridlinesVisible != visible) { this.rangeGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke used to draw the grid-lines against the range axis. * * @return The stroke (never null). * * @see #setRangeGridlineStroke(Stroke) */ public Stroke getRangeGridlineStroke() { return this.rangeGridlineStroke; } /** * Sets the stroke used to draw the grid-lines against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getRangeGridlineStroke() */ public void setRangeGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint used to draw the grid-lines against the range axis. * * @return The paint (never null). * * @see #setRangeGridlinePaint(Paint) */ public Paint getRangeGridlinePaint() { return this.rangeGridlinePaint; } /** * Sets the paint used to draw the grid lines against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeGridlinePaint() */ public void setRangeGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeGridlinePaint = paint; fireChangeEvent(); } /** * Returns true if the range axis minor grid is visible, and * false otherwise. * * @return A boolean. * * @see #setRangeMinorGridlinesVisible(boolean) * * @since 1.0.13 */ public boolean isRangeMinorGridlinesVisible() { return this.rangeMinorGridlinesVisible; } /** * Sets the flag that controls whether or not the range axis minor grid * lines are visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isRangeMinorGridlinesVisible() * * @since 1.0.13 */ public void setRangeMinorGridlinesVisible(boolean visible) { if (this.rangeMinorGridlinesVisible != visible) { this.rangeMinorGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the minor grid lines (if any) plotted against the * range axis. * * @return The stroke (never null). * * @see #setRangeMinorGridlineStroke(Stroke) * * @since 1.0.13 */ public Stroke getRangeMinorGridlineStroke() { return this.rangeMinorGridlineStroke; } /** * Sets the stroke for the minor grid lines plotted against the range axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getRangeMinorGridlineStroke() * * @since 1.0.13 */ public void setRangeMinorGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeMinorGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the minor grid lines (if any) plotted against the * range axis. * * @return The paint (never null). * * @see #setRangeMinorGridlinePaint(Paint) * * @since 1.0.13 */ public Paint getRangeMinorGridlinePaint() { return this.rangeMinorGridlinePaint; } /** * Sets the paint for the minor grid lines plotted against the range axis * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeMinorGridlinePaint() * * @since 1.0.13 */ public void setRangeMinorGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeMinorGridlinePaint = paint; fireChangeEvent(); } /** * Returns the fixed legend items, if any. * * @return The legend items (possibly null). * * @see #setFixedLegendItems(LegendItemCollection) */ public LegendItemCollection getFixedLegendItems() { return this.fixedLegendItems; } /** * Sets the fixed legend items for the plot. Leave this set to * null if you prefer the legend items to be created * automatically. * * @param items the legend items (null permitted). * * @see #getFixedLegendItems() */ public void setFixedLegendItems(LegendItemCollection items) { this.fixedLegendItems = items; fireChangeEvent(); } /** * Returns the legend items for the plot. By default, this method creates * a legend item for each series in each of the datasets. You can change * this behaviour by overriding this method. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = this.fixedLegendItems; if (result == null) { result = new LegendItemCollection(); // get the legend items for the datasets... int count = this.datasets.size(); for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { CategoryDataset dataset = getDataset(datasetIndex); if (dataset != null) { CategoryItemRenderer renderer = getRenderer(datasetIndex); if (renderer != null) { int seriesCount = dataset.getRowCount(); for (int i = 0; i < seriesCount; i++) { LegendItem item = renderer.getLegendItem( datasetIndex, i); if (item != null) { result.add(item); } } } } } } return result; } /** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click (in Java2D space). * @param y y-coordinate of the click (in Java2D space). * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { // set the anchor value for the range axis... double java2D = 0.0; if (this.orientation == PlotOrientation.HORIZONTAL) { java2D = x; } else if (this.orientation == PlotOrientation.VERTICAL) { java2D = y; } RectangleEdge edge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), this.orientation); double value = getRangeAxis().java2DToValue( java2D, info.getDataArea(), edge); setAnchorValue(value); setRangeCrosshairValue(value); } } /** * Zooms (in or out) on the plot's value axis. *

* If the value 0.0 is passed in as the zoom percent, the auto-range * calculation for the axis is restored (which sets the range to include * the minimum and maximum data values, thus displaying all the data). * * @param percent the zoom amount. */ public void zoom(double percent) { if (percent > 0.0) { double range = getRangeAxis().getRange().getLength(); double scaledRange = range * percent; getRangeAxis().setRange(this.anchorValue - scaledRange / 2.0, this.anchorValue + scaledRange / 2.0); } else { getRangeAxis().setAutoRange(true); } } /** * Receives notification of a change to the plot's dataset. *

* The range axis bounds will be recalculated if necessary. * * @param event information about the event (not used here). */ public void datasetChanged(DatasetChangeEvent event) { int count = this.rangeAxes.size(); for (int axisIndex = 0; axisIndex < count; axisIndex++) { ValueAxis yAxis = getRangeAxis(axisIndex); if (yAxis != null) { yAxis.configure(); } } if (getParent() != null) { getParent().datasetChanged(event); } else { PlotChangeEvent e = new PlotChangeEvent(this); e.setType(ChartChangeEventType.DATASET_UPDATED); notifyListeners(e); } } /** * Receives notification of a renderer change event. * * @param event the event. */ public void rendererChanged(RendererChangeEvent event) { Plot parent = getParent(); if (parent != null) { if (parent instanceof RendererChangeListener) { RendererChangeListener rcl = (RendererChangeListener) parent; rcl.rendererChanged(event); } else { // this should never happen with the existing code, but throw // an exception in case future changes make it possible... throw new RuntimeException( "The renderer has changed and I don't know what to do!"); } } else { configureRangeAxes(); PlotChangeEvent e = new PlotChangeEvent(this); notifyListeners(e); } } /** * Adds a marker for display (in the foreground) against the domain axis and * sends a {@link PlotChangeEvent} to all registered listeners. Typically a * marker will be drawn by the renderer as a line perpendicular to the * domain axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * * @see #removeDomainMarker(Marker) */ public void addDomainMarker(CategoryMarker marker) { addDomainMarker(marker, Layer.FOREGROUND); } /** * Adds a marker for display against the domain axis and sends a * {@link PlotChangeEvent} to all registered listeners. Typically a marker * will be drawn by the renderer as a line perpendicular to the domain * axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background) (null * not permitted). * * @see #removeDomainMarker(Marker, Layer) */ public void addDomainMarker(CategoryMarker marker, Layer layer) { addDomainMarker(0, marker, layer); } /** * Adds a marker for display by a particular renderer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to a domain axis, however this is entirely up to the renderer. * * @param index the renderer index. * @param marker the marker (null not permitted). * @param layer the layer (null not permitted). * * @see #removeDomainMarker(int, Marker, Layer) */ public void addDomainMarker(int index, CategoryMarker marker, Layer layer) { addDomainMarker(index, marker, layer, true); } /** * Adds a marker for display by a particular renderer and, if requested, * sends a {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to a domain axis, however this is entirely up to the renderer. * * @param index the renderer index. * @param marker the marker (null not permitted). * @param layer the layer (null not permitted). * @param notify notify listeners? * * @since 1.0.10 * * @see #removeDomainMarker(int, Marker, Layer, boolean) */ public void addDomainMarker(int index, CategoryMarker marker, Layer layer, boolean notify) { if (marker == null) { throw new IllegalArgumentException("Null 'marker' not permitted."); } if (layer == null) { throw new IllegalArgumentException("Null 'layer' not permitted."); } Collection markers; if (layer == Layer.FOREGROUND) { markers = (Collection) this.foregroundDomainMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.foregroundDomainMarkers.put(new Integer(index), markers); } markers.add(marker); } else if (layer == Layer.BACKGROUND) { markers = (Collection) this.backgroundDomainMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.backgroundDomainMarkers.put(new Integer(index), markers); } markers.add(marker); } marker.addChangeListener(this); if (notify) { fireChangeEvent(); } } /** * Clears all the domain markers for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. * * @see #clearRangeMarkers() */ public void clearDomainMarkers() { if (this.backgroundDomainMarkers != null) { Set keys = this.backgroundDomainMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearDomainMarkers(key.intValue()); } this.backgroundDomainMarkers.clear(); } if (this.foregroundDomainMarkers != null) { Set keys = this.foregroundDomainMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearDomainMarkers(key.intValue()); } this.foregroundDomainMarkers.clear(); } fireChangeEvent(); } /** * Returns the list of domain markers (read only) for the specified layer. * * @param layer the layer (foreground or background). * * @return The list of domain markers. */ public Collection getDomainMarkers(Layer layer) { return getDomainMarkers(0, layer); } /** * Returns a collection of domain markers for a particular renderer and * layer. * * @param index the renderer index. * @param layer the layer. * * @return A collection of markers (possibly null). */ public Collection getDomainMarkers(int index, Layer layer) { Collection result = null; Integer key = new Integer(index); if (layer == Layer.FOREGROUND) { result = (Collection) this.foregroundDomainMarkers.get(key); } else if (layer == Layer.BACKGROUND) { result = (Collection) this.backgroundDomainMarkers.get(key); } if (result != null) { result = Collections.unmodifiableCollection(result); } return result; } /** * Clears all the domain markers for the specified renderer. * * @param index the renderer index. * * @see #clearRangeMarkers(int) */ public void clearDomainMarkers(int index) { Integer key = new Integer(index); if (this.backgroundDomainMarkers != null) { Collection markers = (Collection) this.backgroundDomainMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } if (this.foregroundDomainMarkers != null) { Collection markers = (Collection) this.foregroundDomainMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } fireChangeEvent(); } /** * Removes a marker for the domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param marker the marker. * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeDomainMarker(Marker marker) { return removeDomainMarker(marker, Layer.FOREGROUND); } /** * Removes a marker for the domain axis in the specified layer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeDomainMarker(Marker marker, Layer layer) { return removeDomainMarker(0, marker, layer); } /** * Removes a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeDomainMarker(int index, Marker marker, Layer layer) { return removeDomainMarker(index, marker, layer, true); } /** * Removes a marker for a specific dataset/renderer and, if requested, * sends a {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * @param notify notify listeners? * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.10 */ public boolean removeDomainMarker(int index, Marker marker, Layer layer, boolean notify) { ArrayList markers; if (layer == Layer.FOREGROUND) { markers = (ArrayList) this.foregroundDomainMarkers.get(new Integer( index)); } else { markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer( index)); } if (markers == null) { return false; } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); } return removed; } /** * Adds a marker for display (in the foreground) against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. Typically a * marker will be drawn by the renderer as a line perpendicular to the * range axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * * @see #removeRangeMarker(Marker) */ public void addRangeMarker(Marker marker) { addRangeMarker(marker, Layer.FOREGROUND); } /** * Adds a marker for display against the range axis and sends a * {@link PlotChangeEvent} to all registered listeners. Typically a marker * will be drawn by the renderer as a line perpendicular to the range axis, * however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background) (null * not permitted). * * @see #removeRangeMarker(Marker, Layer) */ public void addRangeMarker(Marker marker, Layer layer) { addRangeMarker(0, marker, layer); } /** * Adds a marker for display by a particular renderer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to a range axis, however this is entirely up to the renderer. * * @param index the renderer index. * @param marker the marker. * @param layer the layer. * * @see #removeRangeMarker(int, Marker, Layer) */ public void addRangeMarker(int index, Marker marker, Layer layer) { addRangeMarker(index, marker, layer, true); } /** * Adds a marker for display by a particular renderer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to a range axis, however this is entirely up to the renderer. * * @param index the renderer index. * @param marker the marker. * @param layer the layer. * @param notify notify listeners? * * @since 1.0.10 * * @see #removeRangeMarker(int, Marker, Layer, boolean) */ public void addRangeMarker(int index, Marker marker, Layer layer, boolean notify) { Collection markers; if (layer == Layer.FOREGROUND) { markers = (Collection) this.foregroundRangeMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.foregroundRangeMarkers.put(new Integer(index), markers); } markers.add(marker); } else if (layer == Layer.BACKGROUND) { markers = (Collection) this.backgroundRangeMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.backgroundRangeMarkers.put(new Integer(index), markers); } markers.add(marker); } marker.addChangeListener(this); if (notify) { fireChangeEvent(); } } /** * Clears all the range markers for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. * * @see #clearDomainMarkers() */ public void clearRangeMarkers() { if (this.backgroundRangeMarkers != null) { Set keys = this.backgroundRangeMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearRangeMarkers(key.intValue()); } this.backgroundRangeMarkers.clear(); } if (this.foregroundRangeMarkers != null) { Set keys = this.foregroundRangeMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearRangeMarkers(key.intValue()); } this.foregroundRangeMarkers.clear(); } fireChangeEvent(); } /** * Returns the list of range markers (read only) for the specified layer. * * @param layer the layer (foreground or background). * * @return The list of range markers. * * @see #getRangeMarkers(int, Layer) */ public Collection getRangeMarkers(Layer layer) { return getRangeMarkers(0, layer); } /** * Returns a collection of range markers for a particular renderer and * layer. * * @param index the renderer index. * @param layer the layer. * * @return A collection of markers (possibly null). */ public Collection getRangeMarkers(int index, Layer layer) { Collection result = null; Integer key = new Integer(index); if (layer == Layer.FOREGROUND) { result = (Collection) this.foregroundRangeMarkers.get(key); } else if (layer == Layer.BACKGROUND) { result = (Collection) this.backgroundRangeMarkers.get(key); } if (result != null) { result = Collections.unmodifiableCollection(result); } return result; } /** * Clears all the range markers for the specified renderer. * * @param index the renderer index. * * @see #clearDomainMarkers(int) */ public void clearRangeMarkers(int index) { Integer key = new Integer(index); if (this.backgroundRangeMarkers != null) { Collection markers = (Collection) this.backgroundRangeMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } if (this.foregroundRangeMarkers != null) { Collection markers = (Collection) this.foregroundRangeMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } fireChangeEvent(); } /** * Removes a marker for the range axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param marker the marker. * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 * * @see #addRangeMarker(Marker) */ public boolean removeRangeMarker(Marker marker) { return removeRangeMarker(marker, Layer.FOREGROUND); } /** * Removes a marker for the range axis in the specified layer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 * * @see #addRangeMarker(Marker, Layer) */ public boolean removeRangeMarker(Marker marker, Layer layer) { return removeRangeMarker(0, marker, layer); } /** * Removes a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 * * @see #addRangeMarker(int, Marker, Layer) */ public boolean removeRangeMarker(int index, Marker marker, Layer layer) { return removeRangeMarker(index, marker, layer, true); } /** * Removes a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * @param notify notify listeners. * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.10 * * @see #addRangeMarker(int, Marker, Layer, boolean) */ public boolean removeRangeMarker(int index, Marker marker, Layer layer, boolean notify) { if (marker == null) { throw new IllegalArgumentException("Null 'marker' argument."); } ArrayList markers; if (layer == Layer.FOREGROUND) { markers = (ArrayList) this.foregroundRangeMarkers.get(new Integer( index)); } else { markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer( index)); } if (markers == null) { return false; } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); } return removed; } /** * Returns the flag that controls whether or not the domain crosshair is * displayed by the plot. * * @return A boolean. * * @since 1.0.11 * * @see #setDomainCrosshairVisible(boolean) */ public boolean isDomainCrosshairVisible() { return this.domainCrosshairVisible; } /** * Sets the flag that controls whether or not the domain crosshair is * displayed by the plot, and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param flag the new flag value. * * @since 1.0.11 * * @see #isDomainCrosshairVisible() * @see #setRangeCrosshairVisible(boolean) */ public void setDomainCrosshairVisible(boolean flag) { if (this.domainCrosshairVisible != flag) { this.domainCrosshairVisible = flag; fireChangeEvent(); } } /** * Returns the row key for the domain crosshair. * * @return The row key. * * @since 1.0.11 */ public Comparable getDomainCrosshairRowKey() { return this.domainCrosshairRowKey; } /** * Sets the row key for the domain crosshair and sends a * {PlotChangeEvent} to all registered listeners. * * @param key the key. * * @since 1.0.11 */ public void setDomainCrosshairRowKey(Comparable key) { setDomainCrosshairRowKey(key, true); } /** * Sets the row key for the domain crosshair and, if requested, sends a * {PlotChangeEvent} to all registered listeners. * * @param key the key. * @param notify notify listeners? * * @since 1.0.11 */ public void setDomainCrosshairRowKey(Comparable key, boolean notify) { this.domainCrosshairRowKey = key; if (notify) { fireChangeEvent(); } } /** * Returns the column key for the domain crosshair. * * @return The column key. * * @since 1.0.11 */ public Comparable getDomainCrosshairColumnKey() { return this.domainCrosshairColumnKey; } /** * Sets the column key for the domain crosshair and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param key the key. * * @since 1.0.11 */ public void setDomainCrosshairColumnKey(Comparable key) { setDomainCrosshairColumnKey(key, true); } /** * Sets the column key for the domain crosshair and, if requested, sends * a {@link PlotChangeEvent} to all registered listeners. * * @param key the key. * @param notify notify listeners? * * @since 1.0.11 */ public void setDomainCrosshairColumnKey(Comparable key, boolean notify) { this.domainCrosshairColumnKey = key; if (notify) { fireChangeEvent(); } } /** * Returns the dataset index for the crosshair. * * @return The dataset index. * * @since 1.0.11 */ public int getCrosshairDatasetIndex() { return this.crosshairDatasetIndex; } /** * Sets the dataset index for the crosshair and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the index. * * @since 1.0.11 */ public void setCrosshairDatasetIndex(int index) { setCrosshairDatasetIndex(index, true); } /** * Sets the dataset index for the crosshair and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the index. * @param notify notify listeners? * * @since 1.0.11 */ public void setCrosshairDatasetIndex(int index, boolean notify) { this.crosshairDatasetIndex = index; if (notify) { fireChangeEvent(); } } /** * Returns the paint used to draw the domain crosshair. * * @return The paint (never null). * * @since 1.0.11 * * @see #setDomainCrosshairPaint(Paint) * @see #getDomainCrosshairStroke() */ public Paint getDomainCrosshairPaint() { return this.domainCrosshairPaint; } /** * Sets the paint used to draw the domain crosshair. * * @param paint the paint (null not permitted). * * @since 1.0.11 * * @see #getDomainCrosshairPaint() */ public void setDomainCrosshairPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainCrosshairPaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the domain crosshair. * * @return The stroke (never null). * * @since 1.0.11 * * @see #setDomainCrosshairStroke(Stroke) * @see #getDomainCrosshairPaint() */ public Stroke getDomainCrosshairStroke() { return this.domainCrosshairStroke; } /** * Sets the stroke used to draw the domain crosshair, and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @since 1.0.11 * * @see #getDomainCrosshairStroke() */ public void setDomainCrosshairStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.domainCrosshairStroke = stroke; } /** * Returns a flag indicating whether or not the range crosshair is visible. * * @return The flag. * * @see #setRangeCrosshairVisible(boolean) */ public boolean isRangeCrosshairVisible() { return this.rangeCrosshairVisible; } /** * Sets the flag indicating whether or not the range crosshair is visible. * * @param flag the new value of the flag. * * @see #isRangeCrosshairVisible() */ public void setRangeCrosshairVisible(boolean flag) { if (this.rangeCrosshairVisible != flag) { this.rangeCrosshairVisible = flag; fireChangeEvent(); } } /** * Returns a flag indicating whether or not the crosshair should "lock-on" * to actual data values. * * @return The flag. * * @see #setRangeCrosshairLockedOnData(boolean) */ public boolean isRangeCrosshairLockedOnData() { return this.rangeCrosshairLockedOnData; } /** * Sets the flag indicating whether or not the range crosshair should * "lock-on" to actual data values, and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param flag the flag. * * @see #isRangeCrosshairLockedOnData() */ public void setRangeCrosshairLockedOnData(boolean flag) { if (this.rangeCrosshairLockedOnData != flag) { this.rangeCrosshairLockedOnData = flag; fireChangeEvent(); } } /** * Returns the range crosshair value. * * @return The value. * * @see #setRangeCrosshairValue(double) */ public double getRangeCrosshairValue() { return this.rangeCrosshairValue; } /** * Sets the range crosshair value and, if the crosshair is visible, sends * a {@link PlotChangeEvent} to all registered listeners. * * @param value the new value. * * @see #getRangeCrosshairValue() */ public void setRangeCrosshairValue(double value) { setRangeCrosshairValue(value, true); } /** * Sets the range crosshair value and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners (but only if the * crosshair is visible). * * @param value the new value. * @param notify a flag that controls whether or not listeners are * notified. * * @see #getRangeCrosshairValue() */ public void setRangeCrosshairValue(double value, boolean notify) { this.rangeCrosshairValue = value; if (isRangeCrosshairVisible() && notify) { fireChangeEvent(); } } /** * Returns the pen-style (Stroke) used to draw the crosshair * (if visible). * * @return The crosshair stroke (never null). * * @see #setRangeCrosshairStroke(Stroke) * @see #isRangeCrosshairVisible() * @see #getRangeCrosshairPaint() */ public Stroke getRangeCrosshairStroke() { return this.rangeCrosshairStroke; } /** * Sets the pen-style (Stroke) used to draw the range * crosshair (if visible), and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param stroke the new crosshair stroke (null not * permitted). * * @see #getRangeCrosshairStroke() */ public void setRangeCrosshairStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeCrosshairStroke = stroke; fireChangeEvent(); } /** * Returns the paint used to draw the range crosshair. * * @return The paint (never null). * * @see #setRangeCrosshairPaint(Paint) * @see #isRangeCrosshairVisible() * @see #getRangeCrosshairStroke() */ public Paint getRangeCrosshairPaint() { return this.rangeCrosshairPaint; } /** * Sets the paint used to draw the range crosshair (if visible) and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeCrosshairPaint() */ public void setRangeCrosshairPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeCrosshairPaint = paint; fireChangeEvent(); } /** * Returns the list of annotations. * * @return The list of annotations (never null). * * @see #addAnnotation(CategoryAnnotation) * @see #clearAnnotations() */ public List getAnnotations() { return this.annotations; } /** * Adds an annotation to the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param annotation the annotation (null not permitted). * * @see #removeAnnotation(CategoryAnnotation) */ public void addAnnotation(CategoryAnnotation annotation) { addAnnotation(annotation, true); } /** * Adds an annotation to the plot and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param annotation the annotation (null not permitted). * @param notify notify listeners? * * @since 1.0.10 */ public void addAnnotation(CategoryAnnotation annotation, boolean notify) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } this.annotations.add(annotation); if (notify) { fireChangeEvent(); } } /** * Removes an annotation from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param annotation the annotation (null not permitted). * * @return A boolean (indicates whether or not the annotation was removed). * * @see #addAnnotation(CategoryAnnotation) */ public boolean removeAnnotation(CategoryAnnotation annotation) { return removeAnnotation(annotation, true); } /** * Removes an annotation from the plot and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param annotation the annotation (null not permitted). * @param notify notify listeners? * * @return A boolean (indicates whether or not the annotation was removed). * * @since 1.0.10 */ public boolean removeAnnotation(CategoryAnnotation annotation, boolean notify) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } boolean removed = this.annotations.remove(annotation); if (removed && notify) { fireChangeEvent(); } return removed; } /** * Clears all the annotations and sends a {@link PlotChangeEvent} to all * registered listeners. */ public void clearAnnotations() { this.annotations.clear(); fireChangeEvent(); } /** * Calculates the space required for the domain axis/axes. * * @param g2 the graphics device. * @param plotArea the plot area. * @param space a carrier for the result (null permitted). * * @return The required space. */ protected AxisSpace calculateDomainAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) { if (space == null) { space = new AxisSpace(); } // reserve some space for the domain axis... if (this.fixedDomainAxisSpace != null) { if (this.orientation == PlotOrientation.HORIZONTAL) { space.ensureAtLeast( this.fixedDomainAxisSpace.getLeft(), RectangleEdge.LEFT); space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), RectangleEdge.RIGHT); } else if (this.orientation == PlotOrientation.VERTICAL) { space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), RectangleEdge.TOP); space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), RectangleEdge.BOTTOM); } } else { // reserve space for the primary domain axis... RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( getDomainAxisLocation(), this.orientation); if (this.drawSharedDomainAxis) { space = getDomainAxis().reserveSpace(g2, this, plotArea, domainEdge, space); } // reserve space for any domain axes... for (int i = 0; i < this.domainAxes.size(); i++) { Axis xAxis = (Axis) this.domainAxes.get(i); if (xAxis != null) { RectangleEdge edge = getDomainAxisEdge(i); space = xAxis.reserveSpace(g2, this, plotArea, edge, space); } } } return space; } /** * Calculates the space required for the range axis/axes. * * @param g2 the graphics device. * @param plotArea the plot area. * @param space a carrier for the result (null permitted). * * @return The required space. */ protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) { if (space == null) { space = new AxisSpace(); } // reserve some space for the range axis... if (this.fixedRangeAxisSpace != null) { if (this.orientation == PlotOrientation.HORIZONTAL) { space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), RectangleEdge.TOP); space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), RectangleEdge.BOTTOM); } else if (this.orientation == PlotOrientation.VERTICAL) { space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), RectangleEdge.LEFT); space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), RectangleEdge.RIGHT); } } else { // reserve space for the range axes (if any)... for (int i = 0; i < this.rangeAxes.size(); i++) { Axis yAxis = (Axis) this.rangeAxes.get(i); if (yAxis != null) { RectangleEdge edge = getRangeAxisEdge(i); space = yAxis.reserveSpace(g2, this, plotArea, edge, space); } } } return space; } /** * Calculates the space required for the axes. * * @param g2 the graphics device. * @param plotArea the plot area. * * @return The space required for the axes. */ protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) { AxisSpace space = new AxisSpace(); space = calculateRangeAxisSpace(g2, plotArea, space); space = calculateDomainAxisSpace(g2, plotArea, space); return space; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). *

* At your option, you may supply an instance of {@link PlotRenderingInfo}. * If you do, it will be populated with information about the drawing, * including various plot dimensions and tooltip info. * * @param g2 the graphics device. * @param area the area within which the plot (including axes) should * be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param state collects info as the chart is drawn (possibly * null). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo state) { // if the plot area is too small, just return... boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } // record the plot area... if (state == null) { // if the incoming state is null, no information will be passed // back to the caller - but we create a temporary state to record // the plot area, since that is used later by the axes state = new PlotRenderingInfo(null); } state.setPlotArea(area); // adjust the drawing area for the plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); // calculate the data area... AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); state.setDataArea(dataArea); createAndAddEntity((Rectangle2D) dataArea.clone(), state, null, null); // if there is a renderer, it draws the background, otherwise use the // default background... if (getRenderer() != null) { getRenderer().drawBackground(g2, this, dataArea); } else { drawBackground(g2, dataArea); } Map axisStateMap = drawAxes(g2, area, dataArea, state); // the anchor point is typically the point where the mouse last // clicked - the crosshairs will be driven off this point... if (anchor != null && !dataArea.contains(anchor)) { anchor = ShapeUtilities.getPointInRectangle(anchor.getX(), anchor.getY(), dataArea); } CategoryCrosshairState crosshairState = new CategoryCrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); // specify the anchor X and Y coordinates in Java2D space, for the // cases where these are not updated during rendering (i.e. no lock // on data) crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (getOrientation() == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setRowKey(getDomainCrosshairRowKey()); crosshairState.setColumnKey(getDomainCrosshairColumnKey()); crosshairState.setCrosshairY(getRangeCrosshairValue()); // don't let anyone draw outside the data area Shape savedClip = g2.getClip(); g2.clip(dataArea); drawDomainGridlines(g2, dataArea); AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = (AxisState) parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } // draw the markers... for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } // now render data items... boolean foundData = false; // set up the alpha-transparency... Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, getForegroundAlpha())); DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { for (int i = 0; i < this.datasets.size(); i++) { foundData = render(g2, dataArea, i, state, crosshairState) || foundData; } } else { // DatasetRenderingOrder.REVERSE for (int i = this.datasets.size() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, state, crosshairState) || foundData; } } // draw the foreground markers... for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } // draw the annotations (if any)... drawAnnotations(g2, dataArea); g2.setClip(savedClip); g2.setComposite(originalComposite); if (!foundData) { drawNoDataMessage(g2, dataArea); } int datasetIndex = crosshairState.getDatasetIndex(); setCrosshairDatasetIndex(datasetIndex, false); // draw domain crosshair if required... Comparable rowKey = crosshairState.getRowKey(); Comparable columnKey = crosshairState.getColumnKey(); setDomainCrosshairRowKey(rowKey, false); setDomainCrosshairColumnKey(columnKey, false); if (isDomainCrosshairVisible() && columnKey != null) { Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, this.orientation, datasetIndex, rowKey, columnKey, stroke, paint); } // draw range crosshair if required... ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (getOrientation() == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, getOrientation(), y, yAxis, stroke, paint); } // draw an outline around the plot area... if (isOutlineVisible()) { if (getRenderer() != null) { getRenderer().drawOutline(g2, this, dataArea); } else { drawOutline(g2, dataArea); } } } /** * Draws the plot background (the background color and/or image). *

* This method will be called during the chart drawing process and is * declared public so that it can be accessed by the renderers used by * certain subclasses. You shouldn't need to call this method directly. * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. */ public void drawBackground(Graphics2D g2, Rectangle2D area) { fillBackground(g2, area, this.orientation); drawBackgroundImage(g2, area); } /** * A utility method for drawing the plot's axes. * * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the data area. * @param plotState collects information about the plot (null * permitted). * * @return A map containing the axis states. */ protected Map drawAxes(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, PlotRenderingInfo plotState) { AxisCollection axisCollection = new AxisCollection(); // add domain axes to lists... for (int index = 0; index < this.domainAxes.size(); index++) { CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(index); if (xAxis != null) { axisCollection.add(xAxis, getDomainAxisEdge(index)); } } // add range axes to lists... for (int index = 0; index < this.rangeAxes.size(); index++) { ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(index); if (yAxis != null) { axisCollection.add(yAxis, getRangeAxisEdge(index)); } } Map axisStateMap = new HashMap(); // draw the top axes double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset( dataArea.getHeight()); Iterator iterator = axisCollection.getAxesAtTop().iterator(); while (iterator.hasNext()) { Axis axis = (Axis) iterator.next(); if (axis != null) { AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.TOP, plotState); cursor = axisState.getCursor(); axisStateMap.put(axis, axisState); } } // draw the bottom axes cursor = dataArea.getMaxY() + this.axisOffset.calculateBottomOutset(dataArea.getHeight()); iterator = axisCollection.getAxesAtBottom().iterator(); while (iterator.hasNext()) { Axis axis = (Axis) iterator.next(); if (axis != null) { AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, plotState); cursor = axisState.getCursor(); axisStateMap.put(axis, axisState); } } // draw the left axes cursor = dataArea.getMinX() - this.axisOffset.calculateLeftOutset(dataArea.getWidth()); iterator = axisCollection.getAxesAtLeft().iterator(); while (iterator.hasNext()) { Axis axis = (Axis) iterator.next(); if (axis != null) { AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, plotState); cursor = axisState.getCursor(); axisStateMap.put(axis, axisState); } } // draw the right axes cursor = dataArea.getMaxX() + this.axisOffset.calculateRightOutset(dataArea.getWidth()); iterator = axisCollection.getAxesAtRight().iterator(); while (iterator.hasNext()) { Axis axis = (Axis) iterator.next(); if (axis != null) { AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.RIGHT, plotState); cursor = axisState.getCursor(); axisStateMap.put(axis, axisState); } } return axisStateMap; } /** * Draws a representation of a dataset within the dataArea region using the * appropriate renderer. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param index the dataset and renderer index. * @param info an optional object for collection dimension information. * @param crosshairState a state object for tracking crosshair info * (null permitted). * * @return A boolean that indicates whether or not real data was found. * * @since 1.0.11 */ public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, PlotRenderingInfo info, CategoryCrosshairState crosshairState) { boolean foundData = false; CategoryDataset currentDataset = getDataset(index); CategoryItemRenderer renderer = getRenderer(index); CategoryAxis domainAxis = getDomainAxisForDataset(index); ValueAxis rangeAxis = getRangeAxisForDataset(index); boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset); if (hasData && renderer != null) { foundData = true; CategoryItemRendererState state = renderer.initialise(g2, dataArea, this, index, info); state.setCrosshairState(crosshairState); int columnCount = currentDataset.getColumnCount(); int rowCount = currentDataset.getRowCount(); int passCount = renderer.getPassCount(); for (int pass = 0; pass < passCount; pass++) { if (this.columnRenderingOrder == SortOrder.ASCENDING) { for (int column = 0; column < columnCount; column++) { if (this.rowRenderingOrder == SortOrder.ASCENDING) { for (int row = 0; row < rowCount; row++) { renderer.drawItem(g2, state, dataArea, this, domainAxis, rangeAxis, currentDataset, row, column, pass); } } else { for (int row = rowCount - 1; row >= 0; row--) { renderer.drawItem(g2, state, dataArea, this, domainAxis, rangeAxis, currentDataset, row, column, pass); } } } } else { for (int column = columnCount - 1; column >= 0; column--) { if (this.rowRenderingOrder == SortOrder.ASCENDING) { for (int row = 0; row < rowCount; row++) { renderer.drawItem(g2, state, dataArea, this, domainAxis, rangeAxis, currentDataset, row, column, pass); } } else { for (int row = rowCount - 1; row >= 0; row--) { renderer.drawItem(g2, state, dataArea, this, domainAxis, rangeAxis, currentDataset, row, column, pass); } } } } } } return foundData; } /** * Draws the domain gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) { if (!isDomainGridlinesVisible()) { return; } CategoryAnchor anchor = getDomainGridlinePosition(); RectangleEdge domainAxisEdge = getDomainAxisEdge(); CategoryDataset dataset = getDataset(); if (dataset == null) { return; } CategoryAxis axis = getDomainAxis(); if (axis != null) { int columnCount = dataset.getColumnCount(); for (int c = 0; c < columnCount; c++) { double xx = axis.getCategoryJava2DCoordinate(anchor, c, columnCount, dataArea, domainAxisEdge); CategoryItemRenderer renderer1 = getRenderer(); if (renderer1 != null) { renderer1.drawDomainGridline(g2, this, dataArea, xx); } } } } /** * Draws the range gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param ticks the ticks. * * @see #drawDomainGridlines(Graphics2D, Rectangle2D) */ protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // draw the range grid lines, if any... if (!isRangeGridlinesVisible() && !isRangeMinorGridlinesVisible()) { return; } // no axis, no gridlines... ValueAxis axis = getRangeAxis(); if (axis == null) { return; } // no renderer, no gridlines... CategoryItemRenderer r = getRenderer(); if (r == null) { return; } Stroke gridStroke = null; Paint gridPaint = null; boolean paintLine = false; Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { paintLine = false; ValueTick tick = (ValueTick) iterator.next(); if ((tick.getTickType() == TickType.MINOR) && isRangeMinorGridlinesVisible()) { gridStroke = getRangeMinorGridlineStroke(); gridPaint = getRangeMinorGridlinePaint(); paintLine = true; } else if ((tick.getTickType() == TickType.MAJOR) && isRangeGridlinesVisible()) { gridStroke = getRangeGridlineStroke(); gridPaint = getRangeGridlinePaint(); paintLine = true; } if (((tick.getValue() != 0.0) || !isRangeZeroBaselineVisible()) && paintLine) { // the method we want isn't in the CategoryItemRenderer // interface... if (r instanceof AbstractCategoryItemRenderer) { AbstractCategoryItemRenderer aci = (AbstractCategoryItemRenderer) r; aci.drawRangeLine(g2, this, axis, dataArea, tick.getValue(), gridPaint, gridStroke); } else { // we'll have to use the method in the interface, but // this doesn't have the paint and stroke settings... r.drawRangeGridline(g2, this, axis, dataArea, tick.getValue()); } } } } /** * Draws a base line across the chart at value zero on the range axis. * * @param g2 the graphics device. * @param area the data area. * * @see #setRangeZeroBaselineVisible(boolean) * * @since 1.0.13 */ protected void drawZeroRangeBaseline(Graphics2D g2, Rectangle2D area) { if (!isRangeZeroBaselineVisible()) { return; } CategoryItemRenderer r = getRenderer(); if (r instanceof AbstractCategoryItemRenderer) { AbstractCategoryItemRenderer aci = (AbstractCategoryItemRenderer) r; aci.drawRangeLine(g2, this, getRangeAxis(), area, 0.0, this.rangeZeroBaselinePaint, this.rangeZeroBaselineStroke); } else { r.drawRangeGridline(g2, this, getRangeAxis(), area, 0.0); } } /** * Draws the annotations. * * @param g2 the graphics device. * @param dataArea the data area. */ protected void drawAnnotations(Graphics2D g2, Rectangle2D dataArea) { if (getAnnotations() != null) { Iterator iterator = getAnnotations().iterator(); while (iterator.hasNext()) { CategoryAnnotation annotation = (CategoryAnnotation) iterator.next(); annotation.draw(g2, this, dataArea, getDomainAxis(), getRangeAxis()); } } } /** * Draws the domain markers (if any) for an axis and layer. This method is * typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). * * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer) */ protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { CategoryItemRenderer r = getRenderer(index); if (r == null) { return; } Collection markers = getDomainMarkers(index, layer); CategoryAxis axis = getDomainAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { CategoryMarker marker = (CategoryMarker) iterator.next(); r.drawDomainMarker(g2, this, axis, marker, dataArea); } } } /** * Draws the range markers (if any) for an axis and layer. This method is * typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). * * @see #drawDomainMarkers(Graphics2D, Rectangle2D, int, Layer) */ protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { CategoryItemRenderer r = getRenderer(index); if (r == null) { return; } Collection markers = getRangeMarkers(index, layer); ValueAxis axis = getRangeAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawRangeMarker(g2, this, axis, marker, dataArea); } } } /** * Utility method for drawing a line perpendicular to the range axis (used * for crosshairs). * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param value the data value. * @param stroke the line stroke (null not permitted). * @param paint the line paint (null not permitted). */ protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { double java2D = getRangeAxis().valueToJava2D(value, dataArea, getRangeAxisEdge()); Line2D line = null; if (this.orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, dataArea.getMaxY()); } else if (this.orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), java2D, dataArea.getMaxX(), java2D); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } /** * Draws a domain crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param datasetIndex the dataset index. * @param rowKey the row key. * @param columnKey the column key. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @see #drawRangeCrosshair(Graphics2D, Rectangle2D, PlotOrientation, * double, ValueAxis, Stroke, Paint) * * @since 1.0.11 */ protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, int datasetIndex, Comparable rowKey, Comparable columnKey, Stroke stroke, Paint paint) { CategoryDataset dataset = getDataset(datasetIndex); CategoryAxis axis = getDomainAxisForDataset(datasetIndex); CategoryItemRenderer renderer = getRenderer(datasetIndex); Line2D line = null; if (orientation == PlotOrientation.VERTICAL) { double xx = renderer.getItemMiddle(rowKey, columnKey, dataset, axis, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = renderer.getItemMiddle(rowKey, columnKey, dataset, axis, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } /** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @see #drawDomainCrosshair(Graphics2D, Rectangle2D, PlotOrientation, int, * Comparable, Comparable, Stroke, Paint) * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } /** * Returns the range of data values that will be plotted against the range * axis. If the dataset is null, this method returns * null. * * @param axis the axis. * * @return The data range. */ public Range getDataRange(ValueAxis axis) { Range result = null; List mappedDatasets = new ArrayList(); int rangeIndex = this.rangeAxes.indexOf(axis); if (rangeIndex >= 0) { mappedDatasets.addAll(datasetsMappedToRangeAxis(rangeIndex)); } else if (axis == getRangeAxis()) { mappedDatasets.addAll(datasetsMappedToRangeAxis(0)); } // iterate through the datasets that map to the axis and get the union // of the ranges. Iterator iterator = mappedDatasets.iterator(); while (iterator.hasNext()) { CategoryDataset d = (CategoryDataset) iterator.next(); CategoryItemRenderer r = getRendererForDataset(d); if (r != null) { result = Range.combine(result, r.findRangeBounds(d)); } } return result; } /** * Returns a list of the datasets that are mapped to the axis with the * specified index. * * @param axisIndex the axis index. * * @return The list (possibly empty, but never null). * * @since 1.0.3 */ private List datasetsMappedToDomainAxis(int axisIndex) { Integer key = new Integer(axisIndex); List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { List mappedAxes = (List) this.datasetToDomainAxesMap.get( new Integer(i)); CategoryDataset dataset = (CategoryDataset) this.datasets.get(i); if (mappedAxes == null) { if (key.equals(ZERO)) { if (dataset != null) { result.add(dataset); } } } else { if (mappedAxes.contains(key)) { if (dataset != null) { result.add(dataset); } } } } return result; } /** * A utility method that returns a list of datasets that are mapped to a * given range axis. * * @param index the axis index. * * @return A list of datasets. */ private List datasetsMappedToRangeAxis(int index) { Integer key = new Integer(index); List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { List mappedAxes = (List) this.datasetToRangeAxesMap.get( new Integer(i)); if (mappedAxes == null) { if (key.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxes.contains(key)) { result.add(this.datasets.get(i)); } } } return result; } /** * Returns the weight for this plot when it is used as a subplot within a * combined plot. * * @return The weight. * * @see #setWeight(int) */ public int getWeight() { return this.weight; } /** * Sets the weight for the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param weight the weight. * * @see #getWeight() */ public void setWeight(int weight) { this.weight = weight; fireChangeEvent(); } /** * Returns the fixed domain axis space. * * @return The fixed domain axis space (possibly null). * * @see #setFixedDomainAxisSpace(AxisSpace) */ public AxisSpace getFixedDomainAxisSpace() { return this.fixedDomainAxisSpace; } /** * Sets the fixed domain axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). * * @see #getFixedDomainAxisSpace() */ public void setFixedDomainAxisSpace(AxisSpace space) { setFixedDomainAxisSpace(space, true); } /** * Sets the fixed domain axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). * @param notify notify listeners? * * @see #getFixedDomainAxisSpace() * * @since 1.0.7 */ public void setFixedDomainAxisSpace(AxisSpace space, boolean notify) { this.fixedDomainAxisSpace = space; if (notify) { fireChangeEvent(); } } /** * Returns the fixed range axis space. * * @return The fixed range axis space (possibly null). * * @see #setFixedRangeAxisSpace(AxisSpace) */ public AxisSpace getFixedRangeAxisSpace() { return this.fixedRangeAxisSpace; } /** * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). * * @see #getFixedRangeAxisSpace() */ public void setFixedRangeAxisSpace(AxisSpace space) { setFixedRangeAxisSpace(space, true); } /** * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). * @param notify notify listeners? * * @see #getFixedRangeAxisSpace() * * @since 1.0.7 */ public void setFixedRangeAxisSpace(AxisSpace space, boolean notify) { this.fixedRangeAxisSpace = space; if (notify) { fireChangeEvent(); } } /** * Returns a list of the categories in the plot's primary dataset. * * @return A list of the categories in the plot's primary dataset. * * @see #getCategoriesForAxis(CategoryAxis) */ public List getCategories() { List result = null; if (getDataset() != null) { result = Collections.unmodifiableList(getDataset().getColumnKeys()); } return result; } /** * Returns a list of the categories that should be displayed for the * specified axis. * * @param axis the axis (null not permitted) * * @return The categories. * * @since 1.0.3 */ public List getCategoriesForAxis(CategoryAxis axis) { List result = new ArrayList(); int axisIndex = this.domainAxes.indexOf(axis); List datasets = datasetsMappedToDomainAxis(axisIndex); Iterator iterator = datasets.iterator(); while (iterator.hasNext()) { CategoryDataset dataset = (CategoryDataset) iterator.next(); // add the unique categories from this dataset for (int i = 0; i < dataset.getColumnCount(); i++) { Comparable category = dataset.getColumnKey(i); if (!result.contains(category)) { result.add(category); } } } return result; } /** * Returns the flag that controls whether or not the shared domain axis is * drawn for each subplot. * * @return A boolean. * * @see #setDrawSharedDomainAxis(boolean) */ public boolean getDrawSharedDomainAxis() { return this.drawSharedDomainAxis; } /** * Sets the flag that controls whether the shared domain axis is drawn when * this plot is being used as a subplot. * * @param draw a boolean. * * @see #getDrawSharedDomainAxis() */ public void setDrawSharedDomainAxis(boolean draw) { this.drawSharedDomainAxis = draw; fireChangeEvent(); } /** * Returns false always, because the plot cannot be panned * along the domain axis/axes. * * @return A boolean. * * @since 1.0.13 */ public boolean isDomainPannable() { return false; } /** * Returns true if panning is enabled for the range axes, * and false otherwise. * * @return A boolean. * * @since 1.0.13 */ public boolean isRangePannable() { return this.rangePannable; } /** * Sets the flag that enables or disables panning of the plot along * the range axes. * * @param pannable the new flag value. * * @since 1.0.13 */ public void setRangePannable(boolean pannable) { this.rangePannable = pannable; } /** * Pans the domain axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panDomainAxes(double percent, PlotRenderingInfo info, Point2D source) { // do nothing, because the plot is not pannable along the domain axes } /** * Pans the range axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panRangeAxes(double percent, PlotRenderingInfo info, Point2D source) { if (!isRangePannable()) { return; } int rangeAxisCount = getRangeAxisCount(); for (int i = 0; i < rangeAxisCount; i++) { ValueAxis axis = getRangeAxis(i); if (axis == null) { continue; } double length = axis.getRange().getLength(); double adj = percent * length; if (axis.isInverted()) { adj = -adj; } axis.setRange(axis.getLowerBound() + adj, axis.getUpperBound() + adj); } } /** * Returns false to indicate that the domain axes are not * zoomable. * * @return A boolean. * * @see #isRangeZoomable() */ public boolean isDomainZoomable() { return false; } /** * Returns true to indicate that the range axes are zoomable. * * @return A boolean. * * @see #isDomainZoomable() */ public boolean isRangeZoomable() { return true; } /** * This method does nothing, because CategoryPlot doesn't * support zooming on the domain. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D space) for the zoom. */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source) { // can't zoom domain axis } /** * This method does nothing, because CategoryPlot doesn't * support zooming on the domain. * * @param lowerPercent the lower bound. * @param upperPercent the upper bound. * @param state the plot state. * @param source the source point (in Java2D space) for the zoom. */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source) { // can't zoom domain axis } /** * This method does nothing, because CategoryPlot doesn't * support zooming on the domain. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { // can't zoom domain axis } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D space) for the zoom. */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source) { // delegate to other method zoomRangeAxes(factor, state, source, false); } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point. * @param useAnchor a flag that controls whether or not the source point * is used for the zoom anchor. * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { // perform the zoom on each range axis for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); if (rangeAxis != null) { if (useAnchor) { // get the relevant source coordinate given the plot // orientation double sourceY = source.getY(); if (this.orientation == PlotOrientation.HORIZONTAL) { sourceY = source.getX(); } double anchorY = rangeAxis.java2DToValue(sourceY, info.getDataArea(), getRangeAxisEdge()); rangeAxis.resizeRange2(factor, anchorY); } else { rangeAxis.resizeRange(factor); } } } } /** * Zooms in on the range axes. * * @param lowerPercent the lower bound. * @param upperPercent the upper bound. * @param state the plot state. * @param source the source point (in Java2D space) for the zoom. */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source) { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); if (rangeAxis != null) { rangeAxis.zoomRange(lowerPercent, upperPercent); } } } /** * Returns the anchor value. * * @return The anchor value. * * @see #setAnchorValue(double) */ public double getAnchorValue() { return this.anchorValue; } /** * Sets the anchor value and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param value the anchor value. * * @see #getAnchorValue() */ public void setAnchorValue(double value) { setAnchorValue(value, true); } /** * Sets the anchor value and, if requested, sends a {@link PlotChangeEvent} * to all registered listeners. * * @param value the value. * @param notify notify listeners? * * @see #getAnchorValue() */ public void setAnchorValue(double value, boolean notify) { this.anchorValue = value; if (notify) { fireChangeEvent(); } } /** * Tests the plot for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryPlot)) { return false; } CategoryPlot that = (CategoryPlot) obj; if (this.orientation != that.orientation) { return false; } if (!ObjectUtilities.equal(this.axisOffset, that.axisOffset)) { return false; } if (!this.domainAxes.equals(that.domainAxes)) { return false; } if (!this.domainAxisLocations.equals(that.domainAxisLocations)) { return false; } if (this.drawSharedDomainAxis != that.drawSharedDomainAxis) { return false; } if (!this.rangeAxes.equals(that.rangeAxes)) { return false; } if (!this.rangeAxisLocations.equals(that.rangeAxisLocations)) { return false; } if (!ObjectUtilities.equal(this.datasetToDomainAxesMap, that.datasetToDomainAxesMap)) { return false; } if (!ObjectUtilities.equal(this.datasetToRangeAxesMap, that.datasetToRangeAxesMap)) { return false; } if (!ObjectUtilities.equal(this.renderers, that.renderers)) { return false; } if (this.renderingOrder != that.renderingOrder) { return false; } if (this.columnRenderingOrder != that.columnRenderingOrder) { return false; } if (this.rowRenderingOrder != that.rowRenderingOrder) { return false; } if (this.domainGridlinesVisible != that.domainGridlinesVisible) { return false; } if (this.domainGridlinePosition != that.domainGridlinePosition) { return false; } if (!ObjectUtilities.equal(this.domainGridlineStroke, that.domainGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.domainGridlinePaint, that.domainGridlinePaint)) { return false; } if (this.rangeGridlinesVisible != that.rangeGridlinesVisible) { return false; } if (!ObjectUtilities.equal(this.rangeGridlineStroke, that.rangeGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.rangeGridlinePaint, that.rangeGridlinePaint)) { return false; } if (this.anchorValue != that.anchorValue) { return false; } if (this.rangeCrosshairVisible != that.rangeCrosshairVisible) { return false; } if (this.rangeCrosshairValue != that.rangeCrosshairValue) { return false; } if (!ObjectUtilities.equal(this.rangeCrosshairStroke, that.rangeCrosshairStroke)) { return false; } if (!PaintUtilities.equal(this.rangeCrosshairPaint, that.rangeCrosshairPaint)) { return false; } if (this.rangeCrosshairLockedOnData != that.rangeCrosshairLockedOnData) { return false; } if (!ObjectUtilities.equal(this.foregroundDomainMarkers, that.foregroundDomainMarkers)) { return false; } if (!ObjectUtilities.equal(this.backgroundDomainMarkers, that.backgroundDomainMarkers)) { return false; } if (!ObjectUtilities.equal(this.foregroundRangeMarkers, that.foregroundRangeMarkers)) { return false; } if (!ObjectUtilities.equal(this.backgroundRangeMarkers, that.backgroundRangeMarkers)) { return false; } if (!ObjectUtilities.equal(this.annotations, that.annotations)) { return false; } if (this.weight != that.weight) { return false; } if (!ObjectUtilities.equal(this.fixedDomainAxisSpace, that.fixedDomainAxisSpace)) { return false; } if (!ObjectUtilities.equal(this.fixedRangeAxisSpace, that.fixedRangeAxisSpace)) { return false; } if (!ObjectUtilities.equal(this.fixedLegendItems, that.fixedLegendItems)) { return false; } if (this.domainCrosshairVisible != that.domainCrosshairVisible) { return false; } if (this.crosshairDatasetIndex != that.crosshairDatasetIndex) { return false; } if (!ObjectUtilities.equal(this.domainCrosshairColumnKey, that.domainCrosshairColumnKey)) { return false; } if (!ObjectUtilities.equal(this.domainCrosshairRowKey, that.domainCrosshairRowKey)) { return false; } if (!PaintUtilities.equal(this.domainCrosshairPaint, that.domainCrosshairPaint)) { return false; } if (!ObjectUtilities.equal(this.domainCrosshairStroke, that.domainCrosshairStroke)) { return false; } if (this.rangeMinorGridlinesVisible != that.rangeMinorGridlinesVisible) { return false; } if (!PaintUtilities.equal(this.rangeMinorGridlinePaint, that.rangeMinorGridlinePaint)) { return false; } if (!ObjectUtilities.equal(this.rangeMinorGridlineStroke, that.rangeMinorGridlineStroke)) { return false; } if (this.rangeZeroBaselineVisible != that.rangeZeroBaselineVisible) { return false; } if (!PaintUtilities.equal(this.rangeZeroBaselinePaint, that.rangeZeroBaselinePaint)) { return false; } if (!ObjectUtilities.equal(this.rangeZeroBaselineStroke, that.rangeZeroBaselineStroke)) { return false; } return super.equals(obj); } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if the cloning is not supported. */ public Object clone() throws CloneNotSupportedException { CategoryPlot clone = (CategoryPlot) super.clone(); clone.domainAxes = new ObjectList(); for (int i = 0; i < this.domainAxes.size(); i++) { CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(i); if (xAxis != null) { CategoryAxis clonedAxis = (CategoryAxis) xAxis.clone(); clone.setDomainAxis(i, clonedAxis); } } clone.domainAxisLocations = (ObjectList) this.domainAxisLocations.clone(); clone.rangeAxes = new ObjectList(); for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(i); if (yAxis != null) { ValueAxis clonedAxis = (ValueAxis) yAxis.clone(); clone.setRangeAxis(i, clonedAxis); } } clone.rangeAxisLocations = (ObjectList) this.rangeAxisLocations.clone(); clone.datasets = (ObjectList) this.datasets.clone(); for (int i = 0; i < clone.datasets.size(); i++) { CategoryDataset dataset = clone.getDataset(i); if (dataset != null) { dataset.addChangeListener(clone); } } clone.datasetToDomainAxesMap = new TreeMap(); clone.datasetToDomainAxesMap.putAll(this.datasetToDomainAxesMap); clone.datasetToRangeAxesMap = new TreeMap(); clone.datasetToRangeAxesMap.putAll(this.datasetToRangeAxesMap); clone.renderers = (ObjectList) this.renderers.clone(); if (this.fixedDomainAxisSpace != null) { clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone( this.fixedDomainAxisSpace); } if (this.fixedRangeAxisSpace != null) { clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone( this.fixedRangeAxisSpace); } clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); clone.foregroundDomainMarkers = cloneMarkerMap( this.foregroundDomainMarkers); clone.backgroundDomainMarkers = cloneMarkerMap( this.backgroundDomainMarkers); clone.foregroundRangeMarkers = cloneMarkerMap( this.foregroundRangeMarkers); clone.backgroundRangeMarkers = cloneMarkerMap( this.backgroundRangeMarkers); if (this.fixedLegendItems != null) { clone.fixedLegendItems = (LegendItemCollection) this.fixedLegendItems.clone(); } return clone; } /** * A utility method to clone the marker maps. * * @param map the map to clone. * * @return A clone of the map. * * @throws CloneNotSupportedException if there is some problem cloning the * map. */ private Map cloneMarkerMap(Map map) throws CloneNotSupportedException { Map clone = new HashMap(); Set keys = map.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Object key = iterator.next(); List entry = (List) map.get(key); Object toAdd = ObjectUtilities.deepClone(entry); clone.put(key, toAdd); } return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.domainGridlineStroke, stream); SerialUtilities.writePaint(this.domainGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); SerialUtilities.writePaint(this.rangeGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeCrosshairStroke, stream); SerialUtilities.writePaint(this.rangeCrosshairPaint, stream); SerialUtilities.writeStroke(this.domainCrosshairStroke, stream); SerialUtilities.writePaint(this.domainCrosshairPaint, stream); SerialUtilities.writeStroke(this.rangeMinorGridlineStroke, stream); SerialUtilities.writePaint(this.rangeMinorGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeZeroBaselineStroke, stream); SerialUtilities.writePaint(this.rangeZeroBaselinePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.domainGridlineStroke = SerialUtilities.readStroke(stream); this.domainGridlinePaint = SerialUtilities.readPaint(stream); this.rangeGridlineStroke = SerialUtilities.readStroke(stream); this.rangeGridlinePaint = SerialUtilities.readPaint(stream); this.rangeCrosshairStroke = SerialUtilities.readStroke(stream); this.rangeCrosshairPaint = SerialUtilities.readPaint(stream); this.domainCrosshairStroke = SerialUtilities.readStroke(stream); this.domainCrosshairPaint = SerialUtilities.readPaint(stream); this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream); this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream); this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream); this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream); for (int i = 0; i < this.domainAxes.size(); i++) { CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(i); if (xAxis != null) { xAxis.setPlot(this); xAxis.addChangeListener(this); } } for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(i); if (yAxis != null) { yAxis.setPlot(this); yAxis.addChangeListener(this); } } int datasetCount = this.datasets.size(); for (int i = 0; i < datasetCount; i++) { Dataset dataset = (Dataset) this.datasets.get(i); if (dataset != null) { dataset.addChangeListener(this); } } int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { CategoryItemRenderer renderer = (CategoryItemRenderer) this.renderers.get(i); if (renderer != null) { renderer.addChangeListener(this); } } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ColorPalette.java0000644000175000017500000003104011173030414026645 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ColorPalette.java * ----------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 14-Aug-2003 : Implemented Cloneable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.plot; import java.awt.Color; import java.awt.Paint; import java.io.Serializable; import java.util.Arrays; import org.jfree.chart.axis.ValueTick; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * Defines palette used by {@link ContourPlot}. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public abstract class ColorPalette implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -9029901853079622051L; /** The min z-axis value. */ protected double minZ = -1; /** The max z-axis value. */ protected double maxZ = -1; /** Red components. */ protected int[] r; /** Green components. */ protected int[] g; /** Blue components. */ protected int[] b; /** Tick values are stored for use with stepped palette. */ protected double[] tickValues = null; /** Logscale? */ protected boolean logscale = false; /** Inverse palette (ie, min and max colors are reversed). */ protected boolean inverse = false; /** The palette name. */ protected String paletteName = null; /** Controls whether palette colors are stepped (not continuous). */ protected boolean stepped = false; /** Constant for converting loge to log10. */ protected static final double log10 = Math.log(10); /** * Default contructor. */ public ColorPalette() { super(); } /** * Returns the color associated with a value. * * @param value the value. * * @return The color. */ public Paint getColor(double value) { int izV = (int) (253 * (value - this.minZ) / (this.maxZ - this.minZ)) + 2; return new Color(this.r[izV], this.g[izV], this.b[izV]); } /** * Returns a color. * * @param izV the index into the palette (zero based). * * @return The color. */ public Color getColor(int izV) { return new Color(this.r[izV], this.g[izV], this.b[izV]); } /** * Returns Color by mapping a given value to a linear palette. * * @param value the value. * * @return The color. */ public Color getColorLinear(double value) { int izV = 0; if (this.stepped) { int index = Arrays.binarySearch(this.tickValues, value); if (index < 0) { index = -1 * index - 2; } if (index < 0) { // For the case were the first tick is greater // than minZ value = this.minZ; } else { value = this.tickValues[index]; } } izV = (int) (253 * (value - this.minZ) / (this.maxZ - this.minZ)) + 2; izV = Math.min(izV, 255); izV = Math.max(izV, 2); return getColor(izV); } /** * Returns Color by mapping a given value to a common log palette. * * @param value the value. * * @return The color. */ public Color getColorLog(double value) { int izV = 0; double minZtmp = this.minZ; double maxZtmp = this.maxZ; if (this.minZ <= 0.0) { // negatives = true; this.maxZ = maxZtmp - minZtmp + 1; this.minZ = 1; value = value - minZtmp + 1; } double minZlog = Math.log(this.minZ) / log10; double maxZlog = Math.log(this.maxZ) / log10; value = Math.log(value) / log10; // value = Math.pow(10,value); if (this.stepped) { int numSteps = this.tickValues.length; int steps = 256 / (numSteps - 1); izV = steps * (int) (numSteps * (value - minZlog) / (maxZlog - minZlog)) + 2; // izV = steps*numSteps*(int)((value/minZ)/(maxZlog-minZlog)) + 2; } else { izV = (int) (253 * (value - minZlog) / (maxZlog - minZlog)) + 2; } izV = Math.min(izV, 255); izV = Math.max(izV, 2); this.minZ = minZtmp; this.maxZ = maxZtmp; return getColor(izV); } /** * Returns the maximum Z value. * * @return The value. */ public double getMaxZ() { return this.maxZ; } /** * Returns the minimum Z value. * * @return The value. */ public double getMinZ() { return this.minZ; } /** * Returns Paint by mapping a given value to a either a linear or common * log palette as controlled by the value logscale. * * @param value the value. * * @return The paint. */ public Paint getPaint(double value) { if (isLogscale()) { return getColorLog(value); } else { return getColorLinear(value); } } /** * Returns the palette name. * * @return The palette name. */ public String getPaletteName () { return this.paletteName; } /** * Returns the tick values. * * @return The tick values. */ public double[] getTickValues() { return this.tickValues; } /** * Called to initialize the palette's color indexes */ public abstract void initialize(); /** * Inverts Palette */ public void invertPalette() { int[] red = new int[256]; int[] green = new int[256]; int[] blue = new int[256]; for (int i = 0; i < 256; i++) { red[i] = this.r[i]; green[i] = this.g[i]; blue[i] = this.b[i]; } for (int i = 2; i < 256; i++) { this.r[i] = red[257 - i]; this.g[i] = green[257 - i]; this.b[i] = blue[257 - i]; } } /** * Returns the inverse flag. * * @return The flag. */ public boolean isInverse () { return this.inverse; } /** * Returns the log-scale flag. * * @return The flag. */ public boolean isLogscale() { return this.logscale; } /** * Returns the 'is-stepped' flag. * * @return The flag. */ public boolean isStepped () { return this.stepped; } /** * Sets the inverse flag. * * @param inverse the new value. */ public void setInverse (boolean inverse) { this.inverse = inverse; initialize(); if (inverse) { invertPalette(); } return; } /** * Sets the 'log-scale' flag. * * @param logscale the new value. */ public void setLogscale(boolean logscale) { this.logscale = logscale; } /** * Sets the maximum Z value. * * @param newMaxZ the new value. */ public void setMaxZ(double newMaxZ) { this.maxZ = newMaxZ; } /** * Sets the minimum Z value. * * @param newMinZ the new value. */ public void setMinZ(double newMinZ) { this.minZ = newMinZ; } /** * Sets the palette name. * * @param paletteName the name. */ public void setPaletteName (String paletteName) { //String oldValue = this.paletteName; this.paletteName = paletteName; return; } /** * Sets the stepped flag. * * @param stepped the flag. */ public void setStepped (boolean stepped) { this.stepped = stepped; return; } /** * Sets the tick values. * * @param newTickValues the tick values. */ public void setTickValues(double[] newTickValues) { this.tickValues = newTickValues; } /** * Store ticks. Required when doing stepped axis * * @param ticks the ticks. */ public void setTickValues(java.util.List ticks) { this.tickValues = new double[ticks.size()]; for (int i = 0; i < this.tickValues.length; i++) { this.tickValues[i] = ((ValueTick) ticks.get(i)).getValue(); } } /** * Tests an object for equality with this instance. * * @param o the object to test. * * @return A boolean. */ public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ColorPalette)) { return false; } ColorPalette colorPalette = (ColorPalette) o; if (this.inverse != colorPalette.inverse) { return false; } if (this.logscale != colorPalette.logscale) { return false; } if (this.maxZ != colorPalette.maxZ) { return false; } if (this.minZ != colorPalette.minZ) { return false; } if (this.stepped != colorPalette.stepped) { return false; } if (!Arrays.equals(this.b, colorPalette.b)) { return false; } if (!Arrays.equals(this.g, colorPalette.g)) { return false; } if (this.paletteName != null ? !this.paletteName.equals(colorPalette.paletteName) : colorPalette.paletteName != null) { return false; } if (!Arrays.equals(this.r, colorPalette.r)) { return false; } if (!Arrays.equals(this.tickValues, colorPalette.tickValues)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; long temp; temp = Double.doubleToLongBits(this.minZ); result = (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.maxZ); result = 29 * result + (int) (temp ^ (temp >>> 32)); result = 29 * result + (this.logscale ? 1 : 0); result = 29 * result + (this.inverse ? 1 : 0); result = 29 * result + (this.paletteName != null ? this.paletteName.hashCode() : 0); result = 29 * result + (this.stepped ? 1 : 0); return result; } /** * Returns a clone of the palette. * * @return A clone. * * @throws CloneNotSupportedException never. */ public Object clone() throws CloneNotSupportedException { ColorPalette clone = (ColorPalette) super.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java0000644000175000017500000006022111173030414031460 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * CombinedDomainCategoryPlot.java * ------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; * * Changes: * -------- * 16-May-2003 : Version 1 (DG); * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); * 19-Aug-2003 : Added equals() method, implemented Cloneable and * Serializable (DG); * 11-Sep-2003 : Fix cloning support (subplots) (NB); * 15-Sep-2003 : Implemented PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 17-Sep-2003 : Updated handling of 'clicks' (DG); * 04-May-2004 : Added getter/setter methods for 'gap' attribute (DG); * 12-Nov-2004 : Implemented the Zoomable interface (DG); * 25-Nov-2004 : Small update to clone() implementation (DG); * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend * items if set (DG); * 05-May-2005 : Updated draw() method parameters (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Sep-2006 : Updated API docs (DG); * 30-Oct-2006 : Added new getCategoriesForAxis() override (DG); * 17-Apr-2007 : Added null argument checks to findSubplot() (DG); * 14-Nov-2007 : Updated setFixedRangeAxisSpaceForSubplots() method (DG); * 27-Mar-2008 : Add documentation for getDataRange() method (DG); * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); * 26-Jun-2008 : Fixed crosshair support (DG); * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as * required (DG); * */ package org.jfree.chart.plot; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; /** * A combined category plot where the domain axis is shared. */ public class CombinedDomainCategoryPlot extends CategoryPlot implements PlotChangeListener { /** For serialization. */ private static final long serialVersionUID = 8207194522653701572L; /** Storage for the subplot references. */ private List subplots; /** The gap between subplots. */ private double gap; /** Temporary storage for the subplot areas. */ private transient Rectangle2D[] subplotAreas; // TODO: move the above to the plot state /** * Default constructor. */ public CombinedDomainCategoryPlot() { this(new CategoryAxis()); } /** * Creates a new plot. * * @param domainAxis the shared domain axis (null not * permitted). */ public CombinedDomainCategoryPlot(CategoryAxis domainAxis) { super(null, domainAxis, null, null); this.subplots = new java.util.ArrayList(); this.gap = 5.0; } /** * Returns the space between subplots. * * @return The gap (in Java2D units). */ public double getGap() { return this.gap; } /** * Sets the amount of space between subplots and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param gap the gap between subplots (in Java2D units). */ public void setGap(double gap) { this.gap = gap; fireChangeEvent(); } /** * Adds a subplot to the combined chart and sends a {@link PlotChangeEvent} * to all registered listeners. *

* The domain axis for the subplot will be set to null. You * must ensure that the subplot has a non-null range axis. * * @param subplot the subplot (null not permitted). */ public void add(CategoryPlot subplot) { add(subplot, 1); } /** * Adds a subplot to the combined chart and sends a {@link PlotChangeEvent} * to all registered listeners. *

* The domain axis for the subplot will be set to null. You * must ensure that the subplot has a non-null range axis. * * @param subplot the subplot (null not permitted). * @param weight the weight (must be >= 1). */ public void add(CategoryPlot subplot, int weight) { if (subplot == null) { throw new IllegalArgumentException("Null 'subplot' argument."); } if (weight < 1) { throw new IllegalArgumentException("Require weight >= 1."); } subplot.setParent(this); subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); subplot.setDomainAxis(null); subplot.setOrientation(getOrientation()); subplot.addChangeListener(this); this.subplots.add(subplot); CategoryAxis axis = getDomainAxis(); if (axis != null) { axis.configure(); } fireChangeEvent(); } /** * Removes a subplot from the combined chart. Potentially, this removes * some unique categories from the overall union of the datasets...so the * domain axis is reconfigured, then a {@link PlotChangeEvent} is sent to * all registered listeners. * * @param subplot the subplot (null not permitted). */ public void remove(CategoryPlot subplot) { if (subplot == null) { throw new IllegalArgumentException("Null 'subplot' argument."); } int position = -1; int size = this.subplots.size(); int i = 0; while (position == -1 && i < size) { if (this.subplots.get(i) == subplot) { position = i; } i++; } if (position != -1) { this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); CategoryAxis domain = getDomainAxis(); if (domain != null) { domain.configure(); } fireChangeEvent(); } } /** * Returns the list of subplots. The returned list may be empty, but is * never null. * * @return An unmodifiable list of subplots. */ public List getSubplots() { if (this.subplots != null) { return Collections.unmodifiableList(this.subplots); } else { return Collections.EMPTY_LIST; } } /** * Returns the subplot (if any) that contains the (x, y) point (specified * in Java2D space). * * @param info the chart rendering info (null not permitted). * @param source the source point (null not permitted). * * @return A subplot (possibly null). */ public CategoryPlot findSubplot(PlotRenderingInfo info, Point2D source) { if (info == null) { throw new IllegalArgumentException("Null 'info' argument."); } if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } CategoryPlot result = null; int subplotIndex = info.getSubplotIndex(source); if (subplotIndex >= 0) { result = (CategoryPlot) this.subplots.get(subplotIndex); } return result; } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source) { zoomRangeAxes(factor, info, source, false); } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). * @param useAnchor zoom about the anchor point? */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { // delegate 'info' and 'source' argument checks... CategoryPlot subplot = findSubplot(info, source); if (subplot != null) { subplot.zoomRangeAxes(factor, info, source, useAnchor); } else { // if the source point doesn't fall within a subplot, we do the // zoom on all subplots... Iterator iterator = getSubplots().iterator(); while (iterator.hasNext()) { subplot = (CategoryPlot) iterator.next(); subplot.zoomRangeAxes(factor, info, source, useAnchor); } } } /** * Zooms in on the range axes. * * @param lowerPercent the lower bound. * @param upperPercent the upper bound. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { // delegate 'info' and 'source' argument checks... CategoryPlot subplot = findSubplot(info, source); if (subplot != null) { subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); } else { // if the source point doesn't fall within a subplot, we do the // zoom on all subplots... Iterator iterator = getSubplots().iterator(); while (iterator.hasNext()) { subplot = (CategoryPlot) iterator.next(); subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); } } } /** * Calculates the space required for the axes. * * @param g2 the graphics device. * @param plotArea the plot area. * * @return The space required for the axes. */ protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) { AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedDomainAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.HORIZONTAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.VERTICAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { CategoryAxis categoryAxis = getDomainAxis(); RectangleEdge categoryEdge = Plot.resolveDomainAxisLocation( getDomainAxisLocation(), orientation); if (categoryAxis != null) { space = categoryAxis.reserveSpace(g2, this, plotArea, categoryEdge, space); } else { if (getDrawSharedDomainAxis()) { space = getDomainAxis().reserveSpace(g2, this, plotArea, categoryEdge, space); } } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); int totalWeight = 0; for (int i = 0; i < n; i++) { CategoryPlot sub = (CategoryPlot) this.subplots.get(i); totalWeight += sub.getWeight(); } this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.VERTICAL) { usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); } for (int i = 0; i < n; i++) { CategoryPlot plot = (CategoryPlot) this.subplots.get(i); // calculate sub-plot area if (orientation == PlotOrientation.HORIZONTAL) { double w = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.VERTICAL) { double h = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; } AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, this.subplotAreas[i], null); space.ensureAtLeast(subSpace); } return space; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). Will perform all the placement calculations for each of the * sub-plots and then tell these to draw themselves. * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) * should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects information about the drawing (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); area.setRect(area.getX() + insets.getLeft(), area.getY() + insets.getTop(), area.getWidth() - insets.getLeft() - insets.getRight(), area.getHeight() - insets.getTop() - insets.getBottom()); // calculate the data area... setFixedRangeAxisSpaceForSubplots(null); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); // set the width and height of non-shared axis of all sub-plots setFixedRangeAxisSpaceForSubplots(space); // draw the shared axis CategoryAxis axis = getDomainAxis(); RectangleEdge domainEdge = getDomainAxisEdge(); double cursor = RectangleEdge.coordinate(dataArea, domainEdge); AxisState axisState = axis.draw(g2, cursor, area, dataArea, domainEdge, info); if (parentState == null) { parentState = new PlotState(); } parentState.getSharedAxisStates().put(axis, axisState); // draw all the subplots for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot plot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = null; if (info != null) { subplotInfo = new PlotRenderingInfo(info.getOwner()); info.addSubplotInfo(subplotInfo); } Point2D subAnchor = null; if (anchor != null && this.subplotAreas[i].contains(anchor)) { subAnchor = anchor; } plot.draw(g2, this.subplotAreas[i], subAnchor, parentState, subplotInfo); } if (info != null) { info.setDataArea(dataArea); } } /** * Sets the size (width or height, depending on the orientation of the * plot) for the range axis of each subplot. * * @param space the space (null permitted). */ protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { CategoryPlot plot = (CategoryPlot) iterator.next(); plot.setFixedRangeAxisSpace(space, false); } } /** * Sets the orientation of the plot (and all subplots). * * @param orientation the orientation (null not permitted). */ public void setOrientation(PlotOrientation orientation) { super.setOrientation(orientation); Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { CategoryPlot plot = (CategoryPlot) iterator.next(); plot.setOrientation(orientation); } } /** * Returns a range representing the extent of the data values in this plot * (obtained from the subplots) that will be rendered against the specified * axis. NOTE: This method is intended for internal JFreeChart use, and * is public only so that code in the axis classes can call it. Since, * for this class, the domain axis is a {@link CategoryAxis} * (not a ValueAxisnull permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CombinedDomainCategoryPlot)) { return false; } CombinedDomainCategoryPlot that = (CombinedDomainCategoryPlot) obj; if (this.gap != that.gap) { return false; } if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } return super.equals(obj); } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { CombinedDomainCategoryPlot result = (CombinedDomainCategoryPlot) super.clone(); result.subplots = (List) ObjectUtilities.deepClone(this.subplots); for (Iterator it = result.subplots.iterator(); it.hasNext();) { Plot child = (Plot) it.next(); child.setParent(result); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CombinedDomainXYPlot.java0000644000175000017500000006336011173030414030252 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CombinedDomainXYPlot.java * ------------------------- * (C) Copyright 2001-2008, by Bill Kelemen and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): David Gilbert (for Object Refinery Limited); * Anthony Boulestreau; * David Basten; * Kevin Frechette (for ISTI); * Nicolas Brodu; * Petr Kubanek (bug 1606205); * * Changes: * -------- * 06-Dec-2001 : Version 1 (BK); * 12-Dec-2001 : Removed unnecessary 'throws' clause from constructor (DG); * 18-Dec-2001 : Added plotArea attribute and get/set methods (BK); * 22-Dec-2001 : Fixed bug in chartChanged with multiple combinations of * CombinedPlots (BK); * 08-Jan-2002 : Moved to new package com.jrefinery.chart.combination (DG); * 25-Feb-2002 : Updated import statements (DG); * 28-Feb-2002 : Readded "this.plotArea = plotArea" that was deleted from * draw() method (BK); * 26-Mar-2002 : Added an empty zoom method (this method needs to be written so * that combined plots will support zooming (DG); * 29-Mar-2002 : Changed the method createCombinedAxis adding the creation of * OverlaidSymbolicAxis and CombinedSymbolicAxis(AB); * 23-Apr-2002 : Renamed CombinedPlot-->MultiXYPlot, and simplified the * structure (DG); * 23-May-2002 : Renamed (again) MultiXYPlot-->CombinedXYPlot (DG); * 19-Jun-2002 : Added get/setGap() methods suggested by David Basten (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 16-Jul-2002 : Draws shared axis after subplots (to fix missing gridlines), * added overrides of 'setSeriesPaint()' and 'setXYItemRenderer()' * that pass changes down to subplots (KF); * 09-Oct-2002 : Added add(XYPlot) method (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 16-May-2003 : Renamed CombinedXYPlot --> CombinedDomainXYPlot (DG); * 04-Aug-2003 : Removed leftover code that was causing domain axis drawing * problem (DG); * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); * 21-Aug-2003 : Implemented Cloneable (DG); * 11-Sep-2003 : Fix cloning support (subplots) (NB); * 15-Sep-2003 : Fixed error in cloning (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 17-Sep-2003 : Updated handling of 'clicks' (DG); * 12-Nov-2004 : Implemented the new Zoomable interface (DG); * 25-Nov-2004 : Small update to clone() implementation (DG); * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend * items if set (DG); * 05-May-2005 : Removed unused draw() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 23-Aug-2006 : Override setFixedRangeAxisSpace() to update subplots (DG); * 06-Feb-2007 : Fixed bug 1606205, draw shared axis after subplots (DG); * 23-Mar-2007 : Reverted previous patch (bug fix 1606205) (DG); * 17-Apr-2007 : Added null argument checks to findSubplot() (DG); * 27-Nov-2007 : Modified setFixedRangeAxisSpaceForSubplots() so as not to * trigger change event in subplots (DG); * 28-Jan-2008 : Reset fixed range axis space in subplots for each call to * draw() (DG); * 27-Mar-2008 : Add documentation for getDataRange() method (DG); * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as * required (DG); * */ package org.jfree.chart.plot; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; /** * An extension of {@link XYPlot} that contains multiple subplots that share a * common domain axis. */ public class CombinedDomainXYPlot extends XYPlot implements PlotChangeListener { /** For serialization. */ private static final long serialVersionUID = -7765545541261907383L; /** Storage for the subplot references. */ private List subplots; /** The gap between subplots. */ private double gap = 5.0; /** Temporary storage for the subplot areas. */ private transient Rectangle2D[] subplotAreas; // TODO: the subplot areas needs to be moved out of the plot into the plot // state /** * Default constructor. */ public CombinedDomainXYPlot() { this(new NumberAxis()); } /** * Creates a new combined plot that shares a domain axis among multiple * subplots. * * @param domainAxis the shared axis. */ public CombinedDomainXYPlot(ValueAxis domainAxis) { super( null, // no data in the parent plot domainAxis, null, // no range axis null // no rendereer ); this.subplots = new java.util.ArrayList(); } /** * Returns a string describing the type of plot. * * @return The type of plot. */ public String getPlotType() { return "Combined_Domain_XYPlot"; } /** * Sets the orientation for the plot (also changes the orientation for all * the subplots to match). * * @param orientation the orientation (null not allowed). */ public void setOrientation(PlotOrientation orientation) { super.setOrientation(orientation); Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); plot.setOrientation(orientation); } } /** * Returns a range representing the extent of the data values in this plot * (obtained from the subplots) that will be rendered against the specified * axis. NOTE: This method is intended for internal JFreeChart use, and * is public only so that code in the axis classes can call it. Since * only the domain axis is shared between subplots, the JFreeChart code * will only call this method for the domain values (although this is not * checked/enforced). * * @param axis the axis. * * @return The range (possibly null). */ public Range getDataRange(ValueAxis axis) { Range result = null; if (this.subplots != null) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot subplot = (XYPlot) iterator.next(); result = Range.combine(result, subplot.getDataRange(axis)); } } return result; } /** * Returns the gap between subplots, measured in Java2D units. * * @return The gap (in Java2D units). */ public double getGap() { return this.gap; } /** * Sets the amount of space between subplots and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param gap the gap between subplots (in Java2D units). */ public void setGap(double gap) { this.gap = gap; fireChangeEvent(); } /** * Adds a subplot (with a default 'weight' of 1) and sends a * {@link PlotChangeEvent} to all registered listeners. *

* The domain axis for the subplot will be set to null. You * must ensure that the subplot has a non-null range axis. * * @param subplot the subplot (null not permitted). */ public void add(XYPlot subplot) { // defer argument checking add(subplot, 1); } /** * Adds a subplot with the specified weight and sends a * {@link PlotChangeEvent} to all registered listeners. The weight * determines how much space is allocated to the subplot relative to all * the other subplots. *

* The domain axis for the subplot will be set to null. You * must ensure that the subplot has a non-null range axis. * * @param subplot the subplot (null not permitted). * @param weight the weight (must be >= 1). */ public void add(XYPlot subplot, int weight) { if (subplot == null) { throw new IllegalArgumentException("Null 'subplot' argument."); } if (weight <= 0) { throw new IllegalArgumentException("Require weight >= 1."); } // store the plot and its weight subplot.setParent(this); subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0), false); subplot.setDomainAxis(null); subplot.addChangeListener(this); this.subplots.add(subplot); ValueAxis axis = getDomainAxis(); if (axis != null) { axis.configure(); } fireChangeEvent(); } /** * Removes a subplot from the combined chart and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param subplot the subplot (null not permitted). */ public void remove(XYPlot subplot) { if (subplot == null) { throw new IllegalArgumentException(" Null 'subplot' argument."); } int position = -1; int size = this.subplots.size(); int i = 0; while (position == -1 && i < size) { if (this.subplots.get(i) == subplot) { position = i; } i++; } if (position != -1) { this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); ValueAxis domain = getDomainAxis(); if (domain != null) { domain.configure(); } fireChangeEvent(); } } /** * Returns the list of subplots. The returned list may be empty, but is * never null. * * @return An unmodifiable list of subplots. */ public List getSubplots() { if (this.subplots != null) { return Collections.unmodifiableList(this.subplots); } else { return Collections.EMPTY_LIST; } } /** * Calculates the axis space required. * * @param g2 the graphics device. * @param plotArea the plot area. * * @return The space. */ protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) { AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedDomainAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.HORIZONTAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.VERTICAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { ValueAxis xAxis = getDomainAxis(); RectangleEdge xEdge = Plot.resolveDomainAxisLocation( getDomainAxisLocation(), orientation); if (xAxis != null) { space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space); } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); int totalWeight = 0; for (int i = 0; i < n; i++) { XYPlot sub = (XYPlot) this.subplots.get(i); totalWeight += sub.getWeight(); } this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.VERTICAL) { usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); } for (int i = 0; i < n; i++) { XYPlot plot = (XYPlot) this.subplots.get(i); // calculate sub-plot area if (orientation == PlotOrientation.HORIZONTAL) { double w = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.VERTICAL) { double h = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; } AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, this.subplotAreas[i], null); space.ensureAtLeast(subSpace); } return space; } /** * Draws the plot within the specified area on a graphics device. * * @param g2 the graphics device. * @param area the plot area (in Java2D space). * @param anchor an anchor point in Java2D space (null * permitted). * @param parentState the state from the parent plot, if there is one * (null permitted). * @param info collects chart drawing information (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); setFixedRangeAxisSpaceForSubplots(null); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); // set the width and height of non-shared axis of all sub-plots setFixedRangeAxisSpaceForSubplots(space); // draw the shared axis ValueAxis axis = getDomainAxis(); RectangleEdge edge = getDomainAxisEdge(); double cursor = RectangleEdge.coordinate(dataArea, edge); AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info); if (parentState == null) { parentState = new PlotState(); } parentState.getSharedAxisStates().put(axis, axisState); // draw all the subplots for (int i = 0; i < this.subplots.size(); i++) { XYPlot plot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = null; if (info != null) { subplotInfo = new PlotRenderingInfo(info.getOwner()); info.addSubplotInfo(subplotInfo); } plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo); } if (info != null) { info.setDataArea(dataArea); } } /** * Returns a collection of legend items for the plot. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = getFixedLegendItems(); if (result == null) { result = new LegendItemCollection(); if (this.subplots != null) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); LegendItemCollection more = plot.getLegendItems(); result.addAll(more); } } } return result; } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source) { zoomRangeAxes(factor, info, source, false); } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). * @param useAnchor use source point as zoom anchor? */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { // delegate 'state' and 'source' argument checks... XYPlot subplot = findSubplot(state, source); if (subplot != null) { subplot.zoomRangeAxes(factor, state, source, useAnchor); } else { // if the source point doesn't fall within a subplot, we do the // zoom on all subplots... Iterator iterator = getSubplots().iterator(); while (iterator.hasNext()) { subplot = (XYPlot) iterator.next(); subplot.zoomRangeAxes(factor, state, source, useAnchor); } } } /** * Zooms in on the range axes. * * @param lowerPercent the lower bound. * @param upperPercent the upper bound. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { // delegate 'info' and 'source' argument checks... XYPlot subplot = findSubplot(info, source); if (subplot != null) { subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); } else { // if the source point doesn't fall within a subplot, we do the // zoom on all subplots... Iterator iterator = getSubplots().iterator(); while (iterator.hasNext()) { subplot = (XYPlot) iterator.next(); subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); } } } /** * Returns the subplot (if any) that contains the (x, y) point (specified * in Java2D space). * * @param info the chart rendering info (null not permitted). * @param source the source point (null not permitted). * * @return A subplot (possibly null). */ public XYPlot findSubplot(PlotRenderingInfo info, Point2D source) { if (info == null) { throw new IllegalArgumentException("Null 'info' argument."); } if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } XYPlot result = null; int subplotIndex = info.getSubplotIndex(source); if (subplotIndex >= 0) { result = (XYPlot) this.subplots.get(subplotIndex); } return result; } /** * Sets the item renderer FOR ALL SUBPLOTS. Registered listeners are * notified that the plot has been modified. *

* Note: usually you will want to set the renderer independently for each * subplot, which is NOT what this method does. * * @param renderer the new renderer. */ public void setRenderer(XYItemRenderer renderer) { super.setRenderer(renderer); // not strictly necessary, since the // renderer set for the // parent plot is not used Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); plot.setRenderer(renderer); } } /** * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). */ public void setFixedRangeAxisSpace(AxisSpace space) { super.setFixedRangeAxisSpace(space); setFixedRangeAxisSpaceForSubplots(space); fireChangeEvent(); } /** * Sets the size (width or height, depending on the orientation of the * plot) for the domain axis of each subplot. * * @param space the space. */ protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); plot.setFixedRangeAxisSpace(space, false); } } /** * Handles a 'click' on the plot by updating the anchor values. * * @param x x-coordinate, where the click occured. * @param y y-coordinate, where the click occured. * @param info object containing information about the plot dimensions. */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { XYPlot subplot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } } /** * Receives a {@link PlotChangeEvent} and responds by notifying all * listeners. * * @param event the event. */ public void plotChanged(PlotChangeEvent event) { notifyListeners(event); } /** * Tests this plot for equality with another object. * * @param obj the other object. * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CombinedDomainXYPlot)) { return false; } CombinedDomainXYPlot that = (CombinedDomainXYPlot) obj; if (this.gap != that.gap) { return false; } if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } return super.equals(obj); } /** * Returns a clone of the annotation. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { CombinedDomainXYPlot result = (CombinedDomainXYPlot) super.clone(); result.subplots = (List) ObjectUtilities.deepClone(this.subplots); for (Iterator it = result.subplots.iterator(); it.hasNext();) { Plot child = (Plot) it.next(); child.setParent(result); } // after setting up all the subplots, the shared domain axis may need // reconfiguring ValueAxis domainAxis = result.getDomainAxis(); if (domainAxis != null) { domainAxis.configure(); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java0000644000175000017500000004714011173030414031312 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CombinedRangeCategoryPlot.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; * * Changes: * -------- * 16-May-2003 : Version 1 (DG); * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); * 19-Aug-2003 : Implemented Cloneable (DG); * 11-Sep-2003 : Fix cloning support (subplots) (NB); * 15-Sep-2003 : Implemented PublicCloneable. Fixed errors in cloning and * serialization (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 17-Sep-2003 : Updated handling of 'clicks' (DG); * 04-May-2004 : Added getter/setter methods for 'gap' attributes (DG); * 12-Nov-2004 : Implements the new Zoomable interface (DG); * 25-Nov-2004 : Small update to clone() implementation (DG); * 21-Feb-2005 : Fixed bug in remove() method (id = 1121172) (DG); * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend * items if set (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 14-Nov-2007 : Updated setFixedDomainAxisSpaceForSubplots() method (DG); * 27-Mar-2008 : Add documentation for getDataRange() method (DG); * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 26-Jun-2008 : Fixed crosshair support (DG); * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as * required (DG); * */ package org.jfree.chart.plot; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; /** * A combined category plot where the range axis is shared. */ public class CombinedRangeCategoryPlot extends CategoryPlot implements PlotChangeListener { /** For serialization. */ private static final long serialVersionUID = 7260210007554504515L; /** Storage for the subplot references. */ private List subplots; /** The gap between subplots. */ private double gap; /** Temporary storage for the subplot areas. */ private transient Rectangle2D[] subplotArea; // TODO: move to plot state /** * Default constructor. */ public CombinedRangeCategoryPlot() { this(new NumberAxis()); } /** * Creates a new plot. * * @param rangeAxis the shared range axis. */ public CombinedRangeCategoryPlot(ValueAxis rangeAxis) { super(null, null, rangeAxis, null); this.subplots = new java.util.ArrayList(); this.gap = 5.0; } /** * Returns the space between subplots. * * @return The gap (in Java2D units). */ public double getGap() { return this.gap; } /** * Sets the amount of space between subplots and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param gap the gap between subplots (in Java2D units). */ public void setGap(double gap) { this.gap = gap; fireChangeEvent(); } /** * Adds a subplot (with a default 'weight' of 1) and sends a * {@link PlotChangeEvent} to all registered listeners. *

* You must ensure that the subplot has a non-null domain axis. The range * axis for the subplot will be set to null. * * @param subplot the subplot (null not permitted). */ public void add(CategoryPlot subplot) { // defer argument checking add(subplot, 1); } /** * Adds a subplot and sends a {@link PlotChangeEvent} to all registered * listeners. *

* You must ensure that the subplot has a non-null domain axis. The range * axis for the subplot will be set to null. * * @param subplot the subplot (null not permitted). * @param weight the weight (must be >= 1). */ public void add(CategoryPlot subplot, int weight) { if (subplot == null) { throw new IllegalArgumentException("Null 'subplot' argument."); } if (weight <= 0) { throw new IllegalArgumentException("Require weight >= 1."); } // store the plot and its weight subplot.setParent(this); subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); subplot.setRangeAxis(null); subplot.setOrientation(getOrientation()); subplot.addChangeListener(this); this.subplots.add(subplot); // configure the range axis... ValueAxis axis = getRangeAxis(); if (axis != null) { axis.configure(); } fireChangeEvent(); } /** * Removes a subplot from the combined chart. * * @param subplot the subplot (null not permitted). */ public void remove(CategoryPlot subplot) { if (subplot == null) { throw new IllegalArgumentException(" Null 'subplot' argument."); } int position = -1; int size = this.subplots.size(); int i = 0; while (position == -1 && i < size) { if (this.subplots.get(i) == subplot) { position = i; } i++; } if (position != -1) { this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); ValueAxis range = getRangeAxis(); if (range != null) { range.configure(); } ValueAxis range2 = getRangeAxis(1); if (range2 != null) { range2.configure(); } fireChangeEvent(); } } /** * Returns the list of subplots. The returned list may be empty, but is * never null. * * @return An unmodifiable list of subplots. */ public List getSubplots() { if (this.subplots != null) { return Collections.unmodifiableList(this.subplots); } else { return Collections.EMPTY_LIST; } } /** * Calculates the space required for the axes. * * @param g2 the graphics device. * @param plotArea the plot area. * * @return The space required for the axes. */ protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) { AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedRangeAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.VERTICAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.HORIZONTAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { ValueAxis valueAxis = getRangeAxis(); RectangleEdge valueEdge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), orientation); if (valueAxis != null) { space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space); } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); int totalWeight = 0; for (int i = 0; i < n; i++) { CategoryPlot sub = (CategoryPlot) this.subplots.get(i); totalWeight += sub.getWeight(); } // calculate plotAreas of all sub-plots, maximum vertical/horizontal // axis width/height this.subplotArea = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.VERTICAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); } for (int i = 0; i < n; i++) { CategoryPlot plot = (CategoryPlot) this.subplots.get(i); // calculate sub-plot area if (orientation == PlotOrientation.VERTICAL) { double w = usableSize * plot.getWeight() / totalWeight; this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.HORIZONTAL) { double h = usableSize * plot.getWeight() / totalWeight; this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; } AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotArea[i], null); space.ensureAtLeast(subSpace); } return space; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). Will perform all the placement calculations for each * sub-plots and then tell these to draw themselves. * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) * should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the parent state. * @param info collects information about the drawing (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); // calculate the data area... AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); // set the width and height of non-shared axis of all sub-plots setFixedDomainAxisSpaceForSubplots(space); // draw the shared axis ValueAxis axis = getRangeAxis(); RectangleEdge rangeEdge = getRangeAxisEdge(); double cursor = RectangleEdge.coordinate(dataArea, rangeEdge); AxisState state = axis.draw(g2, cursor, area, dataArea, rangeEdge, info); if (parentState == null) { parentState = new PlotState(); } parentState.getSharedAxisStates().put(axis, state); // draw all the charts for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot plot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = null; if (info != null) { subplotInfo = new PlotRenderingInfo(info.getOwner()); info.addSubplotInfo(subplotInfo); } Point2D subAnchor = null; if (anchor != null && this.subplotArea[i].contains(anchor)) { subAnchor = anchor; } plot.draw(g2, this.subplotArea[i], subAnchor, parentState, subplotInfo); } if (info != null) { info.setDataArea(dataArea); } } /** * Sets the orientation for the plot (and all the subplots). * * @param orientation the orientation. */ public void setOrientation(PlotOrientation orientation) { super.setOrientation(orientation); Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { CategoryPlot plot = (CategoryPlot) iterator.next(); plot.setOrientation(orientation); } } /** * Returns a range representing the extent of the data values in this plot * (obtained from the subplots) that will be rendered against the specified * axis. NOTE: This method is intended for internal JFreeChart use, and * is public only so that code in the axis classes can call it. Since * only the range axis is shared between subplots, the JFreeChart code * will only call this method for the range values (although this is not * checked/enforced). * * @param axis the axis. * * @return The range. */ public Range getDataRange(ValueAxis axis) { Range result = null; if (this.subplots != null) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { CategoryPlot subplot = (CategoryPlot) iterator.next(); result = Range.combine(result, subplot.getDataRange(axis)); } } return result; } /** * Returns a collection of legend items for the plot. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = getFixedLegendItems(); if (result == null) { result = new LegendItemCollection(); if (this.subplots != null) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { CategoryPlot plot = (CategoryPlot) iterator.next(); LegendItemCollection more = plot.getLegendItems(); result.addAll(more); } } } return result; } /** * Sets the size (width or height, depending on the orientation of the * plot) for the domain axis of each subplot. * * @param space the space. */ protected void setFixedDomainAxisSpaceForSubplots(AxisSpace space) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { CategoryPlot plot = (CategoryPlot) iterator.next(); plot.setFixedDomainAxisSpace(space, false); } } /** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click. * @param y y-coordinate of the click. * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { CategoryPlot subplot = (CategoryPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } } /** * Receives a {@link PlotChangeEvent} and responds by notifying all * listeners. * * @param event the event. */ public void plotChanged(PlotChangeEvent event) { notifyListeners(event); } /** * Tests the plot for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CombinedRangeCategoryPlot)) { return false; } CombinedRangeCategoryPlot that = (CombinedRangeCategoryPlot) obj; if (this.gap != that.gap) { return false; } if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } return super.equals(obj); } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { CombinedRangeCategoryPlot result = (CombinedRangeCategoryPlot) super.clone(); result.subplots = (List) ObjectUtilities.deepClone(this.subplots); for (Iterator it = result.subplots.iterator(); it.hasNext();) { Plot child = (Plot) it.next(); child.setParent(result); } // after setting up all the subplots, the shared range axis may need // reconfiguring ValueAxis rangeAxis = result.getRangeAxis(); if (rangeAxis != null) { rangeAxis.configure(); } return result; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); // the range axis is deserialized before the subplots, so its value // range is likely to be incorrect... ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { rangeAxis.configure(); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CombinedRangeXYPlot.java0000644000175000017500000006127211173030414030077 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CombinedRangeXYPlot.java * ------------------------ * (C) Copyright 2001-2008, by Bill Kelemen and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): David Gilbert (for Object Refinery Limited); * Anthony Boulestreau; * David Basten; * Kevin Frechette (for ISTI); * Arnaud Lelievre; * Nicolas Brodu; * Petr Kubanek (bug 1606205); * * Changes: * -------- * 06-Dec-2001 : Version 1 (BK); * 12-Dec-2001 : Removed unnecessary 'throws' clause from constructor (DG); * 18-Dec-2001 : Added plotArea attribute and get/set methods (BK); * 22-Dec-2001 : Fixed bug in chartChanged with multiple combinations of * CombinedPlots (BK); * 08-Jan-2002 : Moved to new package com.jrefinery.chart.combination (DG); * 25-Feb-2002 : Updated import statements (DG); * 28-Feb-2002 : Readded "this.plotArea = plotArea" that was deleted from * draw() method (BK); * 26-Mar-2002 : Added an empty zoom method (this method needs to be written * so that combined plots will support zooming (DG); * 29-Mar-2002 : Changed the method createCombinedAxis adding the creation of * OverlaidSymbolicAxis and CombinedSymbolicAxis(AB); * 23-Apr-2002 : Renamed CombinedPlot-->MultiXYPlot, and simplified the * structure (DG); * 23-May-2002 : Renamed (again) MultiXYPlot-->CombinedXYPlot (DG); * 19-Jun-2002 : Added get/setGap() methods suggested by David Basten (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 16-Jul-2002 : Draws shared axis after subplots (to fix missing gridlines), * added overrides of 'setSeriesPaint()' and 'setXYItemRenderer()' * that pass changes down to subplots (KF); * 09-Oct-2002 : Added add(XYPlot) method (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 16-May-2003 : Renamed CombinedXYPlot --> CombinedRangeXYPlot (DG); * 26-Jun-2003 : Fixed bug 755547 (DG); * 16-Jul-2003 : Removed getSubPlots() method (duplicate of getSubplots()) (DG); * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); * 21-Aug-2003 : Implemented Cloneable (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 11-Sep-2003 : Fix cloning support (subplots) (NB); * 15-Sep-2003 : Fixed error in cloning (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 17-Sep-2003 : Updated handling of 'clicks' (DG); * 12-Nov-2004 : Implements the new Zoomable interface (DG); * 25-Nov-2004 : Small update to clone() implementation (DG); * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend * items if set (DG); * 05-May-2005 : Removed unused draw() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Sep-2006 : Updated API docs (DG); * 06-Feb-2007 : Fixed bug 1606205, draw shared axis after subplots (DG); * 23-Mar-2007 : Reverted previous patch (DG); * 17-Apr-2007 : Added null argument checks to findSubplot() (DG); * 18-Jul-2007 : Fixed bug in removeSubplot (DG); * 27-Nov-2007 : Modified setFixedDomainAxisSpaceForSubplots() so as not to * trigger change events in subplots (DG); * 27-Mar-2008 : Add documentation for getDataRange() method (DG); * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as * required (DG); * */ package org.jfree.chart.plot; import java.awt.Graphics2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; /** * An extension of {@link XYPlot} that contains multiple subplots that share a * common range axis. */ public class CombinedRangeXYPlot extends XYPlot implements PlotChangeListener { /** For serialization. */ private static final long serialVersionUID = -5177814085082031168L; /** Storage for the subplot references. */ private List subplots; /** The gap between subplots. */ private double gap = 5.0; /** Temporary storage for the subplot areas. */ private transient Rectangle2D[] subplotAreas; /** * Default constructor. */ public CombinedRangeXYPlot() { this(new NumberAxis()); } /** * Creates a new plot. * * @param rangeAxis the shared axis. */ public CombinedRangeXYPlot(ValueAxis rangeAxis) { super(null, // no data in the parent plot null, rangeAxis, null); this.subplots = new java.util.ArrayList(); } /** * Returns a string describing the type of plot. * * @return The type of plot. */ public String getPlotType() { return localizationResources.getString("Combined_Range_XYPlot"); } /** * Returns the space between subplots. * * @return The gap */ public double getGap() { return this.gap; } /** * Sets the amount of space between subplots. * * @param gap the gap between subplots */ public void setGap(double gap) { this.gap = gap; } /** * Adds a subplot, with a default 'weight' of 1. *

* You must ensure that the subplot has a non-null domain axis. The range * axis for the subplot will be set to null. * * @param subplot the subplot. */ public void add(XYPlot subplot) { add(subplot, 1); } /** * Adds a subplot with a particular weight (greater than or equal to one). * The weight determines how much space is allocated to the subplot * relative to all the other subplots. *

* You must ensure that the subplot has a non-null domain axis. The range * axis for the subplot will be set to null. * * @param subplot the subplot. * @param weight the weight (must be 1 or greater). */ public void add(XYPlot subplot, int weight) { // verify valid weight if (weight <= 0) { String msg = "The 'weight' must be positive."; throw new IllegalArgumentException(msg); } // store the plot and its weight subplot.setParent(this); subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); subplot.setRangeAxis(null); subplot.addChangeListener(this); this.subplots.add(subplot); configureRangeAxes(); fireChangeEvent(); } /** * Removes a subplot from the combined chart. * * @param subplot the subplot (null not permitted). */ public void remove(XYPlot subplot) { if (subplot == null) { throw new IllegalArgumentException(" Null 'subplot' argument."); } int position = -1; int size = this.subplots.size(); int i = 0; while (position == -1 && i < size) { if (this.subplots.get(i) == subplot) { position = i; } i++; } if (position != -1) { this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); configureRangeAxes(); fireChangeEvent(); } } /** * Returns the list of subplots. The returned list may be empty, but is * never null. * * @return An unmodifiable list of subplots. */ public List getSubplots() { if (this.subplots != null) { return Collections.unmodifiableList(this.subplots); } else { return Collections.EMPTY_LIST; } } /** * Calculates the space required for the axes. * * @param g2 the graphics device. * @param plotArea the plot area. * * @return The space required for the axes. */ protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) { AxisSpace space = new AxisSpace(); PlotOrientation orientation = getOrientation(); // work out the space required by the domain axis... AxisSpace fixed = getFixedRangeAxisSpace(); if (fixed != null) { if (orientation == PlotOrientation.VERTICAL) { space.setLeft(fixed.getLeft()); space.setRight(fixed.getRight()); } else if (orientation == PlotOrientation.HORIZONTAL) { space.setTop(fixed.getTop()); space.setBottom(fixed.getBottom()); } } else { ValueAxis valueAxis = getRangeAxis(); RectangleEdge valueEdge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), orientation ); if (valueAxis != null) { space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, space); } } Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); int totalWeight = 0; for (int i = 0; i < n; i++) { XYPlot sub = (XYPlot) this.subplots.get(i); totalWeight += sub.getWeight(); } // calculate plotAreas of all sub-plots, maximum vertical/horizontal // axis width/height this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); double usableSize = 0.0; if (orientation == PlotOrientation.VERTICAL) { usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); } else if (orientation == PlotOrientation.HORIZONTAL) { usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); } for (int i = 0; i < n; i++) { XYPlot plot = (XYPlot) this.subplots.get(i); // calculate sub-plot area if (orientation == PlotOrientation.VERTICAL) { double w = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.HORIZONTAL) { double h = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; } AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, this.subplotAreas[i], null); space.ensureAtLeast(subSpace); } return space; } /** * Draws the plot within the specified area on a graphics device. * * @param g2 the graphics device. * @param area the plot area (in Java2D space). * @param anchor an anchor point in Java2D space (null * permitted). * @param parentState the state from the parent plot, if there is one * (null permitted). * @param info collects chart drawing information (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); //this.axisOffset.trim(dataArea); // set the width and height of non-shared axis of all sub-plots setFixedDomainAxisSpaceForSubplots(space); // draw the shared axis ValueAxis axis = getRangeAxis(); RectangleEdge edge = getRangeAxisEdge(); double cursor = RectangleEdge.coordinate(dataArea, edge); AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info); if (parentState == null) { parentState = new PlotState(); } parentState.getSharedAxisStates().put(axis, axisState); // draw all the charts for (int i = 0; i < this.subplots.size(); i++) { XYPlot plot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = null; if (info != null) { subplotInfo = new PlotRenderingInfo(info.getOwner()); info.addSubplotInfo(subplotInfo); } plot.draw(g2, this.subplotAreas[i], anchor, parentState, subplotInfo); } if (info != null) { info.setDataArea(dataArea); } } /** * Returns a collection of legend items for the plot. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = getFixedLegendItems(); if (result == null) { result = new LegendItemCollection(); if (this.subplots != null) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); LegendItemCollection more = plot.getLegendItems(); result.addAll(more); } } } return result; } /** * Multiplies the range on the domain axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source) { zoomDomainAxes(factor, info, source, false); } /** * Multiplies the range on the domain axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). * @param useAnchor zoom about the anchor point? */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { // delegate 'info' and 'source' argument checks... XYPlot subplot = findSubplot(info, source); if (subplot != null) { subplot.zoomDomainAxes(factor, info, source, useAnchor); } else { // if the source point doesn't fall within a subplot, we do the // zoom on all subplots... Iterator iterator = getSubplots().iterator(); while (iterator.hasNext()) { subplot = (XYPlot) iterator.next(); subplot.zoomDomainAxes(factor, info, source, useAnchor); } } } /** * Zooms in on the domain axes. * * @param lowerPercent the lower bound. * @param upperPercent the upper bound. * @param info the plot rendering info (null not permitted). * @param source the source point (null not permitted). */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { // delegate 'info' and 'source' argument checks... XYPlot subplot = findSubplot(info, source); if (subplot != null) { subplot.zoomDomainAxes(lowerPercent, upperPercent, info, source); } else { // if the source point doesn't fall within a subplot, we do the // zoom on all subplots... Iterator iterator = getSubplots().iterator(); while (iterator.hasNext()) { subplot = (XYPlot) iterator.next(); subplot.zoomDomainAxes(lowerPercent, upperPercent, info, source); } } } /** * Returns the subplot (if any) that contains the (x, y) point (specified * in Java2D space). * * @param info the chart rendering info (null not permitted). * @param source the source point (null not permitted). * * @return A subplot (possibly null). */ public XYPlot findSubplot(PlotRenderingInfo info, Point2D source) { if (info == null) { throw new IllegalArgumentException("Null 'info' argument."); } if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } XYPlot result = null; int subplotIndex = info.getSubplotIndex(source); if (subplotIndex >= 0) { result = (XYPlot) this.subplots.get(subplotIndex); } return result; } /** * Sets the item renderer FOR ALL SUBPLOTS. Registered listeners are * notified that the plot has been modified. *

* Note: usually you will want to set the renderer independently for each * subplot, which is NOT what this method does. * * @param renderer the new renderer. */ public void setRenderer(XYItemRenderer renderer) { super.setRenderer(renderer); // not strictly necessary, since the // renderer set for the // parent plot is not used Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); plot.setRenderer(renderer); } } /** * Sets the orientation for the plot (and all its subplots). * * @param orientation the orientation. */ public void setOrientation(PlotOrientation orientation) { super.setOrientation(orientation); Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); plot.setOrientation(orientation); } } /** * Returns a range representing the extent of the data values in this plot * (obtained from the subplots) that will be rendered against the specified * axis. NOTE: This method is intended for internal JFreeChart use, and * is public only so that code in the axis classes can call it. Since * only the range axis is shared between subplots, the JFreeChart code * will only call this method for the range values (although this is not * checked/enforced). * * @param axis the axis. * * @return The range. */ public Range getDataRange(ValueAxis axis) { Range result = null; if (this.subplots != null) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot subplot = (XYPlot) iterator.next(); result = Range.combine(result, subplot.getDataRange(axis)); } } return result; } /** * Sets the space (width or height, depending on the orientation of the * plot) for the domain axis of each subplot. * * @param space the space. */ protected void setFixedDomainAxisSpaceForSubplots(AxisSpace space) { Iterator iterator = this.subplots.iterator(); while (iterator.hasNext()) { XYPlot plot = (XYPlot) iterator.next(); plot.setFixedDomainAxisSpace(space, false); } } /** * Handles a 'click' on the plot by updating the anchor values... * * @param x x-coordinate, where the click occured. * @param y y-coordinate, where the click occured. * @param info object containing information about the plot dimensions. */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { for (int i = 0; i < this.subplots.size(); i++) { XYPlot subplot = (XYPlot) this.subplots.get(i); PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); subplot.handleClick(x, y, subplotInfo); } } } /** * Receives a {@link PlotChangeEvent} and responds by notifying all * listeners. * * @param event the event. */ public void plotChanged(PlotChangeEvent event) { notifyListeners(event); } /** * Tests this plot for equality with another object. * * @param obj the other object. * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CombinedRangeXYPlot)) { return false; } CombinedRangeXYPlot that = (CombinedRangeXYPlot) obj; if (this.gap != that.gap) { return false; } if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } return super.equals(obj); } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { CombinedRangeXYPlot result = (CombinedRangeXYPlot) super.clone(); result.subplots = (List) ObjectUtilities.deepClone(this.subplots); for (Iterator it = result.subplots.iterator(); it.hasNext();) { Plot child = (Plot) it.next(); child.setParent(result); } // after setting up all the subplots, the shared range axis may need // reconfiguring ValueAxis rangeAxis = result.getRangeAxis(); if (rangeAxis != null) { rangeAxis.configure(); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CompassPlot.java0000644000175000017500000007001411173030414026520 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * CompassPlot.java * ---------------- * (C) Copyright 2002-2008, by the Australian Antarctic Division and * Contributors. * * Original Author: Bryan Scott (for the Australian Antarctic Division); * Contributor(s): David Gilbert (for Object Refinery Limited); * Arnaud Lelievre; * * Changes: * -------- * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); * 23-Jan-2003 : Removed one constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 27-Mar-2003 : Changed MeterDataset to ValueDataset (DG); * 21-Aug-2003 : Implemented Cloneable (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 09-Sep-2003 : Changed Color --> Paint (DG); * 15-Sep-2003 : Added null data value check (bug report 805009) (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 16-Mar-2004 : Added support for revolutionDistance to enable support for * other units than degrees. * 16-Mar-2004 : Enabled LongNeedle to rotate about center. * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 17-Apr-2005 : Fixed bug in clone() method (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * 16-Jun-2005 : Renamed getData() --> getDatasets() and * addData() --> addDataset() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Mar-2007 : Fixed serialization (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Stroke; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Arrays; import java.util.ResourceBundle; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.needle.ArrowNeedle; import org.jfree.chart.needle.LineNeedle; import org.jfree.chart.needle.LongNeedle; import org.jfree.chart.needle.MeterNeedle; import org.jfree.chart.needle.MiddlePinNeedle; import org.jfree.chart.needle.PinNeedle; import org.jfree.chart.needle.PlumNeedle; import org.jfree.chart.needle.PointerNeedle; import org.jfree.chart.needle.ShipNeedle; import org.jfree.chart.needle.WindNeedle; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.general.DefaultValueDataset; import org.jfree.data.general.ValueDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A specialised plot that draws a compass to indicate a direction based on the * value from a {@link ValueDataset}. */ public class CompassPlot extends Plot implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 6924382802125527395L; /** The default label font. */ public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", Font.BOLD, 10); /** A constant for the label type. */ public static final int NO_LABELS = 0; /** A constant for the label type. */ public static final int VALUE_LABELS = 1; /** The label type (NO_LABELS, VALUE_LABELS). */ private int labelType; /** The label font. */ private Font labelFont; /** A flag that controls whether or not a border is drawn. */ private boolean drawBorder = false; /** The rose highlight paint. */ private transient Paint roseHighlightPaint = Color.black; /** The rose paint. */ private transient Paint rosePaint = Color.yellow; /** The rose center paint. */ private transient Paint roseCenterPaint = Color.white; /** The compass font. */ private Font compassFont = new Font("Arial", Font.PLAIN, 10); /** A working shape. */ private transient Ellipse2D circle1; /** A working shape. */ private transient Ellipse2D circle2; /** A working area. */ private transient Area a1; /** A working area. */ private transient Area a2; /** A working shape. */ private transient Rectangle2D rect1; /** An array of value datasets. */ private ValueDataset[] datasets = new ValueDataset[1]; /** An array of needles. */ private MeterNeedle[] seriesNeedle = new MeterNeedle[1]; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** * The count to complete one revolution. Can be arbitrarily set * For degrees (the default) it is 360, for radians this is 2*Pi, etc */ protected double revolutionDistance = 360; /** * Default constructor. */ public CompassPlot() { this(new DefaultValueDataset()); } /** * Constructs a new compass plot. * * @param dataset the dataset for the plot (null permitted). */ public CompassPlot(ValueDataset dataset) { super(); if (dataset != null) { this.datasets[0] = dataset; dataset.addChangeListener(this); } this.circle1 = new Ellipse2D.Double(); this.circle2 = new Ellipse2D.Double(); this.rect1 = new Rectangle2D.Double(); setSeriesNeedle(0); } /** * Returns the label type. Defined by the constants: {@link #NO_LABELS} * and {@link #VALUE_LABELS}. * * @return The label type. * * @see #setLabelType(int) */ public int getLabelType() { // FIXME: this attribute is never used - deprecate? return this.labelType; } /** * Sets the label type (either {@link #NO_LABELS} or {@link #VALUE_LABELS}. * * @param type the type. * * @see #getLabelType() */ public void setLabelType(int type) { // FIXME: this attribute is never used - deprecate? if ((type != NO_LABELS) && (type != VALUE_LABELS)) { throw new IllegalArgumentException( "MeterPlot.setLabelType(int): unrecognised type."); } if (this.labelType != type) { this.labelType = type; fireChangeEvent(); } } /** * Returns the label font. * * @return The label font. * * @see #setLabelFont(Font) */ public Font getLabelFont() { // FIXME: this attribute is not used - deprecate? return this.labelFont; } /** * Sets the label font and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param font the new label font. * * @see #getLabelFont() */ public void setLabelFont(Font font) { // FIXME: this attribute is not used - deprecate? if (font == null) { throw new IllegalArgumentException("Null 'font' not allowed."); } this.labelFont = font; fireChangeEvent(); } /** * Returns the paint used to fill the outer circle of the compass. * * @return The paint (never null). * * @see #setRosePaint(Paint) */ public Paint getRosePaint() { return this.rosePaint; } /** * Sets the paint used to fill the outer circle of the compass, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRosePaint() */ public void setRosePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rosePaint = paint; fireChangeEvent(); } /** * Returns the paint used to fill the inner background area of the * compass. * * @return The paint (never null). * * @see #setRoseCenterPaint(Paint) */ public Paint getRoseCenterPaint() { return this.roseCenterPaint; } /** * Sets the paint used to fill the inner background area of the compass, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRoseCenterPaint() */ public void setRoseCenterPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.roseCenterPaint = paint; fireChangeEvent(); } /** * Returns the paint used to draw the circles, symbols and labels on the * compass. * * @return The paint (never null). * * @see #setRoseHighlightPaint(Paint) */ public Paint getRoseHighlightPaint() { return this.roseHighlightPaint; } /** * Sets the paint used to draw the circles, symbols and labels of the * compass, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRoseHighlightPaint() */ public void setRoseHighlightPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.roseHighlightPaint = paint; fireChangeEvent(); } /** * Returns a flag that controls whether or not a border is drawn. * * @return The flag. * * @see #setDrawBorder(boolean) */ public boolean getDrawBorder() { return this.drawBorder; } /** * Sets a flag that controls whether or not a border is drawn. * * @param status the flag status. * * @see #getDrawBorder() */ public void setDrawBorder(boolean status) { this.drawBorder = status; fireChangeEvent(); } /** * Sets the series paint. * * @param series the series index. * @param paint the paint. * * @see #setSeriesOutlinePaint(int, Paint) */ public void setSeriesPaint(int series, Paint paint) { // super.setSeriesPaint(series, paint); if ((series >= 0) && (series < this.seriesNeedle.length)) { this.seriesNeedle[series].setFillPaint(paint); } } /** * Sets the series outline paint. * * @param series the series index. * @param p the paint. * * @see #setSeriesPaint(int, Paint) */ public void setSeriesOutlinePaint(int series, Paint p) { if ((series >= 0) && (series < this.seriesNeedle.length)) { this.seriesNeedle[series].setOutlinePaint(p); } } /** * Sets the series outline stroke. * * @param series the series index. * @param stroke the stroke. * * @see #setSeriesOutlinePaint(int, Paint) */ public void setSeriesOutlineStroke(int series, Stroke stroke) { if ((series >= 0) && (series < this.seriesNeedle.length)) { this.seriesNeedle[series].setOutlineStroke(stroke); } } /** * Sets the needle type. * * @param type the type. * * @see #setSeriesNeedle(int, int) */ public void setSeriesNeedle(int type) { setSeriesNeedle(0, type); } /** * Sets the needle for a series. The needle type is one of the following: *

    *
  • 0 = {@link ArrowNeedle};
  • *
  • 1 = {@link LineNeedle};
  • *
  • 2 = {@link LongNeedle};
  • *
  • 3 = {@link PinNeedle};
  • *
  • 4 = {@link PlumNeedle};
  • *
  • 5 = {@link PointerNeedle};
  • *
  • 6 = {@link ShipNeedle};
  • *
  • 7 = {@link WindNeedle};
  • *
  • 8 = {@link ArrowNeedle};
  • *
  • 9 = {@link MiddlePinNeedle};
  • *
* @param index the series index. * @param type the needle type. * * @see #setSeriesNeedle(int) */ public void setSeriesNeedle(int index, int type) { switch (type) { case 0: setSeriesNeedle(index, new ArrowNeedle(true)); setSeriesPaint(index, Color.red); this.seriesNeedle[index].setHighlightPaint(Color.white); break; case 1: setSeriesNeedle(index, new LineNeedle()); break; case 2: MeterNeedle longNeedle = new LongNeedle(); longNeedle.setRotateY(0.5); setSeriesNeedle(index, longNeedle); break; case 3: setSeriesNeedle(index, new PinNeedle()); break; case 4: setSeriesNeedle(index, new PlumNeedle()); break; case 5: setSeriesNeedle(index, new PointerNeedle()); break; case 6: setSeriesPaint(index, null); setSeriesOutlineStroke(index, new BasicStroke(3)); setSeriesNeedle(index, new ShipNeedle()); break; case 7: setSeriesPaint(index, Color.blue); setSeriesNeedle(index, new WindNeedle()); break; case 8: setSeriesNeedle(index, new ArrowNeedle(true)); break; case 9: setSeriesNeedle(index, new MiddlePinNeedle()); break; default: throw new IllegalArgumentException("Unrecognised type."); } } /** * Sets the needle for a series and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the series index. * @param needle the needle. */ public void setSeriesNeedle(int index, MeterNeedle needle) { if ((needle != null) && (index < this.seriesNeedle.length)) { this.seriesNeedle[index] = needle; } fireChangeEvent(); } /** * Returns an array of dataset references for the plot. * * @return The dataset for the plot, cast as a ValueDataset. * * @see #addDataset(ValueDataset) */ public ValueDataset[] getDatasets() { return this.datasets; } /** * Adds a dataset to the compass. * * @param dataset the new dataset (null ignored). * * @see #addDataset(ValueDataset, MeterNeedle) */ public void addDataset(ValueDataset dataset) { addDataset(dataset, null); } /** * Adds a dataset to the compass. * * @param dataset the new dataset (null ignored). * @param needle the needle (null permitted). */ public void addDataset(ValueDataset dataset, MeterNeedle needle) { if (dataset != null) { int i = this.datasets.length + 1; ValueDataset[] t = new ValueDataset[i]; MeterNeedle[] p = new MeterNeedle[i]; i = i - 2; for (; i >= 0; --i) { t[i] = this.datasets[i]; p[i] = this.seriesNeedle[i]; } i = this.datasets.length; t[i] = dataset; p[i] = ((needle != null) ? needle : p[i - 1]); ValueDataset[] a = this.datasets; MeterNeedle[] b = this.seriesNeedle; this.datasets = t; this.seriesNeedle = p; for (--i; i >= 0; --i) { a[i] = null; b[i] = null; } dataset.addChangeListener(this); } } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { int outerRadius = 0; int innerRadius = 0; int x1, y1, x2, y2; double a; if (info != null) { info.setPlotArea(area); } // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); // draw the background if (this.drawBorder) { drawBackground(g2, area); } int midX = (int) (area.getWidth() / 2); int midY = (int) (area.getHeight() / 2); int radius = midX; if (midY < midX) { radius = midY; } --radius; int diameter = 2 * radius; midX += (int) area.getMinX(); midY += (int) area.getMinY(); this.circle1.setFrame(midX - radius, midY - radius, diameter, diameter); this.circle2.setFrame( midX - radius + 15, midY - radius + 15, diameter - 30, diameter - 30 ); g2.setPaint(this.rosePaint); this.a1 = new Area(this.circle1); this.a2 = new Area(this.circle2); this.a1.subtract(this.a2); g2.fill(this.a1); g2.setPaint(this.roseCenterPaint); x1 = diameter - 30; g2.fillOval(midX - radius + 15, midY - radius + 15, x1, x1); g2.setPaint(this.roseHighlightPaint); g2.drawOval(midX - radius, midY - radius, diameter, diameter); x1 = diameter - 20; g2.drawOval(midX - radius + 10, midY - radius + 10, x1, x1); x1 = diameter - 30; g2.drawOval(midX - radius + 15, midY - radius + 15, x1, x1); x1 = diameter - 80; g2.drawOval(midX - radius + 40, midY - radius + 40, x1, x1); outerRadius = radius - 20; innerRadius = radius - 32; for (int w = 0; w < 360; w += 15) { a = Math.toRadians(w); x1 = midX - ((int) (Math.sin(a) * innerRadius)); x2 = midX - ((int) (Math.sin(a) * outerRadius)); y1 = midY - ((int) (Math.cos(a) * innerRadius)); y2 = midY - ((int) (Math.cos(a) * outerRadius)); g2.drawLine(x1, y1, x2, y2); } g2.setPaint(this.roseHighlightPaint); innerRadius = radius - 26; outerRadius = 7; for (int w = 45; w < 360; w += 90) { a = Math.toRadians(w); x1 = midX - ((int) (Math.sin(a) * innerRadius)); y1 = midY - ((int) (Math.cos(a) * innerRadius)); g2.fillOval(x1 - outerRadius, y1 - outerRadius, 2 * outerRadius, 2 * outerRadius); } /// Squares for (int w = 0; w < 360; w += 90) { a = Math.toRadians(w); x1 = midX - ((int) (Math.sin(a) * innerRadius)); y1 = midY - ((int) (Math.cos(a) * innerRadius)); Polygon p = new Polygon(); p.addPoint(x1 - outerRadius, y1); p.addPoint(x1, y1 + outerRadius); p.addPoint(x1 + outerRadius, y1); p.addPoint(x1, y1 - outerRadius); g2.fillPolygon(p); } /// Draw N, S, E, W innerRadius = radius - 42; Font f = getCompassFont(radius); g2.setFont(f); g2.drawString("N", midX - 5, midY - innerRadius + f.getSize()); g2.drawString("S", midX - 5, midY + innerRadius - 5); g2.drawString("W", midX - innerRadius + 5, midY + 5); g2.drawString("E", midX + innerRadius - f.getSize(), midY + 5); // plot the data (unless the dataset is null)... y1 = radius / 2; x1 = radius / 6; Rectangle2D needleArea = new Rectangle2D.Double( (midX - x1), (midY - y1), (2 * x1), (2 * y1) ); int x = this.seriesNeedle.length; int current = 0; double value = 0; int i = (this.datasets.length - 1); for (; i >= 0; --i) { ValueDataset data = this.datasets[i]; if (data != null && data.getValue() != null) { value = (data.getValue().doubleValue()) % this.revolutionDistance; value = value / this.revolutionDistance * 360; current = i % x; this.seriesNeedle[current].draw(g2, needleArea, value); } } if (this.drawBorder) { drawOutline(g2, area); } } /** * Returns a short string describing the type of plot. * * @return A string describing the plot. */ public String getPlotType() { return localizationResources.getString("Compass_Plot"); } /** * Returns the legend items for the plot. For now, no legend is available * - this method returns null. * * @return The legend items. */ public LegendItemCollection getLegendItems() { return null; } /** * No zooming is implemented for compass plot, so this method is empty. * * @param percent the zoom amount. */ public void zoom(double percent) { // no zooming possible } /** * Returns the font for the compass, adjusted for the size of the plot. * * @param radius the radius. * * @return The font. */ protected Font getCompassFont(int radius) { float fontSize = radius / 10.0f; if (fontSize < 8) { fontSize = 8; } Font newFont = this.compassFont.deriveFont(fontSize); return newFont; } /** * Tests an object for equality with this plot. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CompassPlot)) { return false; } if (!super.equals(obj)) { return false; } CompassPlot that = (CompassPlot) obj; if (this.labelType != that.labelType) { return false; } if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { return false; } if (this.drawBorder != that.drawBorder) { return false; } if (!PaintUtilities.equal(this.roseHighlightPaint, that.roseHighlightPaint)) { return false; } if (!PaintUtilities.equal(this.rosePaint, that.rosePaint)) { return false; } if (!PaintUtilities.equal(this.roseCenterPaint, that.roseCenterPaint)) { return false; } if (!ObjectUtilities.equal(this.compassFont, that.compassFont)) { return false; } if (!Arrays.equals(this.seriesNeedle, that.seriesNeedle)) { return false; } if (getRevolutionDistance() != that.getRevolutionDistance()) { return false; } return true; } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { CompassPlot clone = (CompassPlot) super.clone(); if (this.circle1 != null) { clone.circle1 = (Ellipse2D) this.circle1.clone(); } if (this.circle2 != null) { clone.circle2 = (Ellipse2D) this.circle2.clone(); } if (this.a1 != null) { clone.a1 = (Area) this.a1.clone(); } if (this.a2 != null) { clone.a2 = (Area) this.a2.clone(); } if (this.rect1 != null) { clone.rect1 = (Rectangle2D) this.rect1.clone(); } clone.datasets = (ValueDataset[]) this.datasets.clone(); clone.seriesNeedle = (MeterNeedle[]) this.seriesNeedle.clone(); // clone share data sets => add the clone as listener to the dataset for (int i = 0; i < this.datasets.length; ++i) { if (clone.datasets[i] != null) { clone.datasets[i].addChangeListener(clone); } } return clone; } /** * Sets the count to complete one revolution. Can be arbitrarily set * For degrees (the default) it is 360, for radians this is 2*Pi, etc * * @param size the count to complete one revolution. * * @see #getRevolutionDistance() */ public void setRevolutionDistance(double size) { if (size > 0) { this.revolutionDistance = size; } } /** * Gets the count to complete one revolution. * * @return The count to complete one revolution. * * @see #setRevolutionDistance(double) */ public double getRevolutionDistance() { return this.revolutionDistance; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.rosePaint, stream); SerialUtilities.writePaint(this.roseCenterPaint, stream); SerialUtilities.writePaint(this.roseHighlightPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.rosePaint = SerialUtilities.readPaint(stream); this.roseCenterPaint = SerialUtilities.readPaint(stream); this.roseHighlightPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ContourPlot.java0000644000175000017500000017011411173030414026546 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ContourPlot.java * ---------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * Arnaud Lelievre; * Nicolas Brodu; * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 14-Jan-2003 : Added crosshair attributes (DG); * 23-Jan-2003 : Removed two constructors (DG); * 21-Mar-2003 : Bug fix 701744 (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 09-Jul-2003 : Changed ColorBar from extending axis classes to enclosing * them (DG); * 05-Aug-2003 : Applied changes in bug report 780298 (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 11-Sep-2003 : Cloning support (NB); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 17-Jan-2004 : Removed references to DefaultContourDataset class, replaced * with ContourDataset interface (with changes to the interface). * See bug 741048 (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 06-Oct-2004 : Updated for changes in DatasetUtilities class (DG); * 11-Nov-2004 : Renamed zoom methods to match ValueAxisPlot interface (DG); * 25-Nov-2004 : Small update to clone() implementation (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 16-Jun-2005 : Added default constructor (DG); * 01-Sep-2005 : Moved dataAreaRatio from Plot to here (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.Serializable; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import org.jfree.chart.ClipPath; import org.jfree.chart.annotations.XYAnnotation; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.ColorBar; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.ContourEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.ContourToolTipGenerator; import org.jfree.chart.labels.StandardContourToolTipGenerator; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.data.contour.ContourDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; /** * A class for creating shaded contours. * * @deprecated This plot is no longer supported, please use {@link XYPlot} with * an {@link XYBlockRenderer}. */ public class ContourPlot extends Plot implements ContourValuePlot, ValueAxisPlot, PropertyChangeListener, Serializable, Cloneable { /** For serialization. */ private static final long serialVersionUID = 7861072556590502247L; /** The default insets. */ protected static final RectangleInsets DEFAULT_INSETS = new RectangleInsets(2.0, 2.0, 100.0, 10.0); /** The domain axis (used for the x-values). */ private ValueAxis domainAxis; /** The range axis (used for the y-values). */ private ValueAxis rangeAxis; /** The dataset. */ private ContourDataset dataset; /** The colorbar axis (used for the z-values). */ private ColorBar colorBar = null; /** The color bar location. */ private RectangleEdge colorBarLocation; /** A flag that controls whether or not a domain crosshair is drawn..*/ private boolean domainCrosshairVisible; /** The domain crosshair value. */ private double domainCrosshairValue; /** The pen/brush used to draw the crosshair (if any). */ private transient Stroke domainCrosshairStroke; /** The color used to draw the crosshair (if any). */ private transient Paint domainCrosshairPaint; /** * A flag that controls whether or not the crosshair locks onto actual data * points. */ private boolean domainCrosshairLockedOnData = true; /** A flag that controls whether or not a range crosshair is drawn..*/ private boolean rangeCrosshairVisible; /** The range crosshair value. */ private double rangeCrosshairValue; /** The pen/brush used to draw the crosshair (if any). */ private transient Stroke rangeCrosshairStroke; /** The color used to draw the crosshair (if any). */ private transient Paint rangeCrosshairPaint; /** * A flag that controls whether or not the crosshair locks onto actual data * points. */ private boolean rangeCrosshairLockedOnData = true; /** * Defines dataArea rectangle as the ratio formed from dividing height by * width (of the dataArea). Modifies plot area calculations. * ratio>0 will attempt to layout the plot so that the * dataArea.height/dataArea.width = ratio. * ratio<0 will attempt to layout the plot so that the * dataArea.height/dataArea.width in plot units (not java2D units as when * ratio>0) = -1.*ratio. */ //dmo private double dataAreaRatio = 0.0; //zero when the parameter is not set /** A list of markers (optional) for the domain axis. */ private List domainMarkers; /** A list of markers (optional) for the range axis. */ private List rangeMarkers; /** A list of annotations (optional) for the plot. */ private List annotations; /** The tool tip generator. */ private ContourToolTipGenerator toolTipGenerator; /** The URL text generator. */ private XYURLGenerator urlGenerator; /** * Controls whether data are render as filled rectangles or rendered as * points */ private boolean renderAsPoints = false; /** * Size of points rendered when renderAsPoints = true. Size is relative to * dataArea */ private double ptSizePct = 0.05; /** Contains the a ClipPath to "trim" the contours. */ private transient ClipPath clipPath = null; /** Set to Paint to represent missing values. */ private transient Paint missingPaint = null; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** * Creates a new plot with no dataset or axes. */ public ContourPlot() { this(null, null, null, null); } /** * Constructs a contour plot with the specified axes (other attributes take * default values). * * @param dataset The dataset. * @param domainAxis The domain axis. * @param rangeAxis The range axis. * @param colorBar The z-axis axis. */ public ContourPlot(ContourDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar) { super(); this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this); } this.domainAxis = domainAxis; if (domainAxis != null) { domainAxis.setPlot(this); domainAxis.addChangeListener(this); } this.rangeAxis = rangeAxis; if (rangeAxis != null) { rangeAxis.setPlot(this); rangeAxis.addChangeListener(this); } this.colorBar = colorBar; if (colorBar != null) { colorBar.getAxis().setPlot(this); colorBar.getAxis().addChangeListener(this); colorBar.configure(this); } this.colorBarLocation = RectangleEdge.LEFT; this.toolTipGenerator = new StandardContourToolTipGenerator(); } /** * Returns the color bar location. * * @return The color bar location. */ public RectangleEdge getColorBarLocation() { return this.colorBarLocation; } /** * Sets the color bar location and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param edge the location. */ public void setColorBarLocation(RectangleEdge edge) { this.colorBarLocation = edge; fireChangeEvent(); } /** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly null). */ public ContourDataset getDataset() { return this.dataset; } /** * Sets the dataset for the plot, replacing the existing dataset if there * is one. * * @param dataset the dataset (null permitted). */ public void setDataset(ContourDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... ContourDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the domain axis for the plot. * * @return The domain axis. */ public ValueAxis getDomainAxis() { ValueAxis result = this.domainAxis; return result; } /** * Sets the domain axis for the plot (this must be compatible with the plot * type or an exception is thrown). * * @param axis The new axis. */ public void setDomainAxis(ValueAxis axis) { if (isCompatibleDomainAxis(axis)) { if (axis != null) { axis.setPlot(this); axis.addChangeListener(this); } // plot is likely registered as a listener with the existing axis... if (this.domainAxis != null) { this.domainAxis.removeChangeListener(this); } this.domainAxis = axis; fireChangeEvent(); } } /** * Returns the range axis for the plot. * * @return The range axis. */ public ValueAxis getRangeAxis() { ValueAxis result = this.rangeAxis; return result; } /** * Sets the range axis for the plot. *

* An exception is thrown if the new axis and the plot are not mutually * compatible. * * @param axis The new axis (null permitted). */ public void setRangeAxis(ValueAxis axis) { if (axis != null) { axis.setPlot(this); axis.addChangeListener(this); } // plot is likely registered as a listener with the existing axis... if (this.rangeAxis != null) { this.rangeAxis.removeChangeListener(this); } this.rangeAxis = axis; fireChangeEvent(); } /** * Sets the colorbar for the plot. * * @param axis The new axis (null permitted). */ public void setColorBarAxis(ColorBar axis) { this.colorBar = axis; fireChangeEvent(); } /** * Returns the data area ratio. * * @return The ratio. */ public double getDataAreaRatio() { return this.dataAreaRatio; } /** * Sets the data area ratio. * * @param ratio the ratio. */ public void setDataAreaRatio(double ratio) { this.dataAreaRatio = ratio; } /** * Adds a marker for the domain axis. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param marker the marker. */ public void addDomainMarker(Marker marker) { if (this.domainMarkers == null) { this.domainMarkers = new java.util.ArrayList(); } this.domainMarkers.add(marker); fireChangeEvent(); } /** * Clears all the domain markers. */ public void clearDomainMarkers() { if (this.domainMarkers != null) { this.domainMarkers.clear(); fireChangeEvent(); } } /** * Adds a marker for the range axis. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param marker The marker. */ public void addRangeMarker(Marker marker) { if (this.rangeMarkers == null) { this.rangeMarkers = new java.util.ArrayList(); } this.rangeMarkers.add(marker); fireChangeEvent(); } /** * Clears all the range markers. */ public void clearRangeMarkers() { if (this.rangeMarkers != null) { this.rangeMarkers.clear(); fireChangeEvent(); } } /** * Adds an annotation to the plot. * * @param annotation the annotation. */ public void addAnnotation(XYAnnotation annotation) { if (this.annotations == null) { this.annotations = new java.util.ArrayList(); } this.annotations.add(annotation); fireChangeEvent(); } /** * Clears all the annotations. */ public void clearAnnotations() { if (this.annotations != null) { this.annotations.clear(); fireChangeEvent(); } } /** * Checks the compatibility of a domain axis, returning true if the axis is * compatible with the plot, and false otherwise. * * @param axis The proposed axis. * * @return true if the axis is compatible with the plot. */ public boolean isCompatibleDomainAxis(ValueAxis axis) { return true; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). *

* The optional info argument collects information about the * rendering of the plot (dimensions, tooltip information etc). Just pass * in null if you do not need this information. * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) * should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects chart drawing information (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // if the plot area is too small, just return... boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } // record the plot area... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D estimatedDataArea = space.shrink(area, null); AxisSpace space2 = new AxisSpace(); space2 = this.colorBar.reserveSpace(g2, this, area, estimatedDataArea, this.colorBarLocation, space2); Rectangle2D adjustedPlotArea = space2.shrink(area, null); Rectangle2D dataArea = space.shrink(adjustedPlotArea, null); Rectangle2D colorBarArea = space2.reserved(area, this.colorBarLocation); // additional dataArea modifications if (getDataAreaRatio() != 0.0) { //check whether modification is double ratio = getDataAreaRatio(); Rectangle2D tmpDataArea = (Rectangle2D) dataArea.clone(); double h = tmpDataArea.getHeight(); double w = tmpDataArea.getWidth(); if (ratio > 0) { // ratio represents pixels if (w * ratio <= h) { h = ratio * w; } else { w = h / ratio; } } else { // ratio represents axis units ratio *= -1.0; double xLength = getDomainAxis().getRange().getLength(); double yLength = getRangeAxis().getRange().getLength(); double unitRatio = yLength / xLength; ratio = unitRatio * ratio; if (w * ratio <= h) { h = ratio * w; } else { w = h / ratio; } } dataArea.setRect(tmpDataArea.getX() + tmpDataArea.getWidth() / 2 - w / 2, tmpDataArea.getY(), w, h); } if (info != null) { info.setDataArea(dataArea); } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); // draw the plot background... drawBackground(g2, dataArea); double cursor = dataArea.getMaxY(); if (this.domainAxis != null) { this.domainAxis.draw(g2, cursor, adjustedPlotArea, dataArea, RectangleEdge.BOTTOM, info); } if (this.rangeAxis != null) { cursor = dataArea.getMinX(); this.rangeAxis.draw(g2, cursor, adjustedPlotArea, dataArea, RectangleEdge.LEFT, info); } if (this.colorBar != null) { cursor = 0.0; cursor = this.colorBar.draw(g2, cursor, adjustedPlotArea, dataArea, colorBarArea, this.colorBarLocation); } Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); render(g2, dataArea, info, crosshairState); if (this.domainMarkers != null) { Iterator iterator = this.domainMarkers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); drawDomainMarker(g2, this, getDomainAxis(), marker, dataArea); } } if (this.rangeMarkers != null) { Iterator iterator = this.rangeMarkers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); drawRangeMarker(g2, this, getRangeAxis(), marker, dataArea); } } // TO DO: these annotations only work with XYPlot, see if it is possible to // make ContourPlot a subclass of XYPlot (DG); // // draw the annotations... // if (this.annotations != null) { // Iterator iterator = this.annotations.iterator(); // while (iterator.hasNext()) { // Annotation annotation = (Annotation) iterator.next(); // if (annotation instanceof XYAnnotation) { // XYAnnotation xya = (XYAnnotation) annotation; // // get the annotation to draw itself... // xya.draw(g2, this, dataArea, getDomainAxis(), // getRangeAxis()); // } // } // } g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } /** * Draws a representation of the data within the dataArea region, using the * current renderer. *

* The info and crosshairState arguments may be * null. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension information. * @param crosshairState an optional object for collecting crosshair info. */ public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState) { // now get the data and plot it (the visual representation will depend // on the renderer that has been set)... ContourDataset data = getDataset(); if (data != null) { ColorBar zAxis = getColorBar(); if (this.clipPath != null) { GeneralPath clipper = getClipPath().draw(g2, dataArea, this.domainAxis, this.rangeAxis); if (this.clipPath.isClip()) { g2.clip(clipper); } } if (this.renderAsPoints) { pointRenderer(g2, dataArea, info, this, this.domainAxis, this.rangeAxis, zAxis, data, crosshairState); } else { contourRenderer(g2, dataArea, info, this, this.domainAxis, this.rangeAxis, zAxis, data, crosshairState); } // draw vertical crosshair if required... setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { drawVerticalLine(g2, dataArea, getDomainCrosshairValue(), getDomainCrosshairStroke(), getDomainCrosshairPaint()); } // draw horizontal crosshair if required... setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { drawHorizontalLine(g2, dataArea, getRangeCrosshairValue(), getRangeCrosshairStroke(), getRangeCrosshairPaint()); } } else if (this.clipPath != null) { getClipPath().draw(g2, dataArea, this.domainAxis, this.rangeAxis); } } /** * Fills the plot. * * @param g2 the graphics device. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param horizontalAxis the domain (horizontal) axis. * @param verticalAxis the range (vertical) axis. * @param colorBar the color bar axis. * @param data the dataset. * @param crosshairState information about crosshairs on a plot. */ public void contourRenderer(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, ContourPlot plot, ValueAxis horizontalAxis, ValueAxis verticalAxis, ColorBar colorBar, ContourDataset data, CrosshairState crosshairState) { // setup for collecting optional entity info... Rectangle2D.Double entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } Rectangle2D.Double rect = null; rect = new Rectangle2D.Double(); //turn off anti-aliasing when filling rectangles Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // get the data points Number[] xNumber = data.getXValues(); Number[] yNumber = data.getYValues(); Number[] zNumber = data.getZValues(); double[] x = new double[xNumber.length]; double[] y = new double[yNumber.length]; for (int i = 0; i < x.length; i++) { x[i] = xNumber[i].doubleValue(); y[i] = yNumber[i].doubleValue(); } int[] xIndex = data.indexX(); int[] indexX = data.getXIndices(); boolean vertInverted = ((NumberAxis) verticalAxis).isInverted(); boolean horizInverted = false; if (horizontalAxis instanceof NumberAxis) { horizInverted = ((NumberAxis) horizontalAxis).isInverted(); } double transX = 0.0; double transXm1 = 0.0; double transXp1 = 0.0; double transDXm1 = 0.0; double transDXp1 = 0.0; double transDX = 0.0; double transY = 0.0; double transYm1 = 0.0; double transYp1 = 0.0; double transDYm1 = 0.0; double transDYp1 = 0.0; double transDY = 0.0; int iMax = xIndex[xIndex.length - 1]; for (int k = 0; k < x.length; k++) { int i = xIndex[k]; if (indexX[i] == k) { // this is a new column if (i == 0) { transX = horizontalAxis.valueToJava2D(x[k], dataArea, RectangleEdge.BOTTOM); transXm1 = transX; transXp1 = horizontalAxis.valueToJava2D( x[indexX[i + 1]], dataArea, RectangleEdge.BOTTOM); transDXm1 = Math.abs(0.5 * (transX - transXm1)); transDXp1 = Math.abs(0.5 * (transX - transXp1)); } else if (i == iMax) { transX = horizontalAxis.valueToJava2D(x[k], dataArea, RectangleEdge.BOTTOM); transXm1 = horizontalAxis.valueToJava2D(x[indexX[i - 1]], dataArea, RectangleEdge.BOTTOM); transXp1 = transX; transDXm1 = Math.abs(0.5 * (transX - transXm1)); transDXp1 = Math.abs(0.5 * (transX - transXp1)); } else { transX = horizontalAxis.valueToJava2D(x[k], dataArea, RectangleEdge.BOTTOM); transXp1 = horizontalAxis.valueToJava2D(x[indexX[i + 1]], dataArea, RectangleEdge.BOTTOM); transDXm1 = transDXp1; transDXp1 = Math.abs(0.5 * (transX - transXp1)); } if (horizInverted) { transX -= transDXp1; } else { transX -= transDXm1; } transDX = transDXm1 + transDXp1; transY = verticalAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT); transYm1 = transY; if (k + 1 == y.length) { continue; } transYp1 = verticalAxis.valueToJava2D(y[k + 1], dataArea, RectangleEdge.LEFT); transDYm1 = Math.abs(0.5 * (transY - transYm1)); transDYp1 = Math.abs(0.5 * (transY - transYp1)); } else if ((i < indexX.length - 1 && indexX[i + 1] - 1 == k) || k == x.length - 1) { // end of column transY = verticalAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT); transYm1 = verticalAxis.valueToJava2D(y[k - 1], dataArea, RectangleEdge.LEFT); transYp1 = transY; transDYm1 = Math.abs(0.5 * (transY - transYm1)); transDYp1 = Math.abs(0.5 * (transY - transYp1)); } else { transY = verticalAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT); transYp1 = verticalAxis.valueToJava2D(y[k + 1], dataArea, RectangleEdge.LEFT); transDYm1 = transDYp1; transDYp1 = Math.abs(0.5 * (transY - transYp1)); } if (vertInverted) { transY -= transDYm1; } else { transY -= transDYp1; } transDY = transDYm1 + transDYp1; rect.setRect(transX, transY, transDX, transDY); if (zNumber[k] != null) { g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue())); g2.fill(rect); } else if (this.missingPaint != null) { g2.setPaint(this.missingPaint); g2.fill(rect); } entityArea = rect; // add an entity for the item... if (entities != null) { String tip = ""; if (getToolTipGenerator() != null) { tip = this.toolTipGenerator.generateToolTip(data, k); } // Shape s = g2.getClip(); // if (s.contains(rect) || s.intersects(rect)) { String url = null; // if (getURLGenerator() != null) { //dmo: look at this later // url = getURLGenerator().generateURL(data, series, item); // } // Unlike XYItemRenderer, we need to clone entityArea since it // reused. ContourEntity entity = new ContourEntity( (Rectangle2D.Double) entityArea.clone(), tip, url); entity.setIndex(k); entities.add(entity); // } } // do we need to update the crosshair values? if (plot.isDomainCrosshairLockedOnData()) { if (plot.isRangeCrosshairLockedOnData()) { // both axes crosshairState.updateCrosshairPoint(x[k], y[k], transX, transY, PlotOrientation.VERTICAL); } else { // just the horizontal axis... crosshairState.updateCrosshairX(transX); } } else { if (plot.isRangeCrosshairLockedOnData()) { // just the vertical axis... crosshairState.updateCrosshairY(transY); } } } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias); return; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain (horizontal) axis. * @param rangeAxis the range (vertical) axis. * @param colorBar the color bar axis. * @param data the dataset. * @param crosshairState information about crosshairs on a plot. */ public void pointRenderer(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, ContourPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, ColorBar colorBar, ContourDataset data, CrosshairState crosshairState) { // setup for collecting optional entity info... RectangularShape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } // Rectangle2D.Double rect = null; // rect = new Rectangle2D.Double(); RectangularShape rect = new Ellipse2D.Double(); //turn off anti-aliasing when filling rectangles Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); // if (tooltips!=null) tooltips.clearToolTips(); // reset collection // get the data points Number[] xNumber = data.getXValues(); Number[] yNumber = data.getYValues(); Number[] zNumber = data.getZValues(); double[] x = new double[xNumber.length]; double[] y = new double[yNumber.length]; for (int i = 0; i < x.length; i++) { x[i] = xNumber[i].doubleValue(); y[i] = yNumber[i].doubleValue(); } double transX = 0.0; double transDX = 0.0; double transY = 0.0; double transDY = 0.0; double size = dataArea.getWidth() * this.ptSizePct; for (int k = 0; k < x.length; k++) { transX = domainAxis.valueToJava2D(x[k], dataArea, RectangleEdge.BOTTOM) - 0.5 * size; transY = rangeAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT) - 0.5 * size; transDX = size; transDY = size; rect.setFrame(transX, transY, transDX, transDY); if (zNumber[k] != null) { g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue())); g2.fill(rect); } else if (this.missingPaint != null) { g2.setPaint(this.missingPaint); g2.fill(rect); } entityArea = rect; // add an entity for the item... if (entities != null) { String tip = null; if (getToolTipGenerator() != null) { tip = this.toolTipGenerator.generateToolTip(data, k); } String url = null; // if (getURLGenerator() != null) { //dmo: look at this later // url = getURLGenerator().generateURL(data, series, item); // } // Unlike XYItemRenderer, we need to clone entityArea since it // reused. ContourEntity entity = new ContourEntity( (RectangularShape) entityArea.clone(), tip, url); entity.setIndex(k); entities.add(entity); } // do we need to update the crosshair values? if (plot.isDomainCrosshairLockedOnData()) { if (plot.isRangeCrosshairLockedOnData()) { // both axes crosshairState.updateCrosshairPoint(x[k], y[k], transX, transY, PlotOrientation.VERTICAL); } else { // just the horizontal axis... crosshairState.updateCrosshairX(transX); } } else { if (plot.isRangeCrosshairLockedOnData()) { // just the vertical axis... crosshairState.updateCrosshairY(transY); } } } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias); return; } /** * Utility method for drawing a crosshair on the chart (if required). * * @param g2 The graphics device. * @param dataArea The data area. * @param value The coordinate, where to draw the line. * @param stroke The stroke to use. * @param paint The paint to use. */ protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { double xx = getDomainAxis().valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } /** * Utility method for drawing a crosshair on the chart (if required). * * @param g2 The graphics device. * @param dataArea The data area. * @param value The coordinate, where to draw the line. * @param stroke The stroke to use. * @param paint The paint to use. */ protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { double yy = getRangeAxis().valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } /** * Handles a 'click' on the plot by updating the anchor values... * * @param x x-coordinate, where the click occured. * @param y y-coordinate, where the click occured. * @param info An object for collection dimension information. */ public void handleClick(int x, int y, PlotRenderingInfo info) { /* // set the anchor value for the horizontal axis... ValueAxis hva = getDomainAxis(); if (hva != null) { double hvalue = hva.translateJava2DtoValue( (float) x, info.getDataArea() ); hva.setAnchorValue(hvalue); setDomainCrosshairValue(hvalue); } // set the anchor value for the vertical axis... ValueAxis vva = getRangeAxis(); if (vva != null) { double vvalue = vva.translateJava2DtoValue( (float) y, info.getDataArea() ); vva.setAnchorValue(vvalue); setRangeCrosshairValue(vvalue); } */ } /** * Zooms the axis ranges by the specified percentage about the anchor point. * * @param percent The amount of the zoom. */ public void zoom(double percent) { if (percent > 0) { // double range = this.domainAxis.getRange().getLength(); // double scaledRange = range * percent; // domainAxis.setAnchoredRange(scaledRange); // range = this.rangeAxis.getRange().getLength(); // scaledRange = range * percent; // rangeAxis.setAnchoredRange(scaledRange); } else { getRangeAxis().setAutoRange(true); getDomainAxis().setAutoRange(true); } } /** * Returns the plot type as a string. * * @return A short string describing the type of plot. */ public String getPlotType() { return localizationResources.getString("Contour_Plot"); } /** * Returns the range for an axis. * * @param axis the axis. * * @return The range for an axis. */ public Range getDataRange(ValueAxis axis) { if (this.dataset == null) { return null; } Range result = null; if (axis == getDomainAxis()) { result = DatasetUtilities.findDomainBounds(this.dataset); } else if (axis == getRangeAxis()) { result = DatasetUtilities.findRangeBounds(this.dataset); } return result; } /** * Returns the range for the Contours. * * @return The range for the Contours (z-axis). */ public Range getContourDataRange() { Range result = null; ContourDataset data = getDataset(); if (data != null) { Range h = getDomainAxis().getRange(); Range v = getRangeAxis().getRange(); result = this.visibleRange(data, h, v); } return result; } /** * Notifies all registered listeners of a property change. *

* One source of property change events is the plot's renderer. * * @param event Information about the property change. */ public void propertyChange(PropertyChangeEvent event) { fireChangeEvent(); } /** * Receives notification of a change to the plot's dataset. *

* The chart reacts by passing on a chart change event to all registered * listeners. * * @param event Information about the event (not used here). */ public void datasetChanged(DatasetChangeEvent event) { if (this.domainAxis != null) { this.domainAxis.configure(); } if (this.rangeAxis != null) { this.rangeAxis.configure(); } if (this.colorBar != null) { this.colorBar.configure(this); } super.datasetChanged(event); } /** * Returns the colorbar. * * @return The colorbar. */ public ColorBar getColorBar() { return this.colorBar; } /** * Returns a flag indicating whether or not the domain crosshair is visible. * * @return The flag. */ public boolean isDomainCrosshairVisible() { return this.domainCrosshairVisible; } /** * Sets the flag indicating whether or not the domain crosshair is visible. * * @param flag the new value of the flag. */ public void setDomainCrosshairVisible(boolean flag) { if (this.domainCrosshairVisible != flag) { this.domainCrosshairVisible = flag; fireChangeEvent(); } } /** * Returns a flag indicating whether or not the crosshair should "lock-on" * to actual data values. * * @return The flag. */ public boolean isDomainCrosshairLockedOnData() { return this.domainCrosshairLockedOnData; } /** * Sets the flag indicating whether or not the domain crosshair should * "lock-on" to actual data values. * * @param flag the flag. */ public void setDomainCrosshairLockedOnData(boolean flag) { if (this.domainCrosshairLockedOnData != flag) { this.domainCrosshairLockedOnData = flag; fireChangeEvent(); } } /** * Returns the domain crosshair value. * * @return The value. */ public double getDomainCrosshairValue() { return this.domainCrosshairValue; } /** * Sets the domain crosshair value. *

* Registered listeners are notified that the plot has been modified, but * only if the crosshair is visible. * * @param value the new value. */ public void setDomainCrosshairValue(double value) { setDomainCrosshairValue(value, true); } /** * Sets the domain crosshair value. *

* Registered listeners are notified that the axis has been modified, but * only if the crosshair is visible. * * @param value the new value. * @param notify a flag that controls whether or not listeners are * notified. */ public void setDomainCrosshairValue(double value, boolean notify) { this.domainCrosshairValue = value; if (isDomainCrosshairVisible() && notify) { fireChangeEvent(); } } /** * Returns the Stroke used to draw the crosshair (if visible). * * @return The crosshair stroke. */ public Stroke getDomainCrosshairStroke() { return this.domainCrosshairStroke; } /** * Sets the Stroke used to draw the crosshairs (if visible) and notifies * registered listeners that the axis has been modified. * * @param stroke the new crosshair stroke. */ public void setDomainCrosshairStroke(Stroke stroke) { this.domainCrosshairStroke = stroke; fireChangeEvent(); } /** * Returns the domain crosshair color. * * @return The crosshair color. */ public Paint getDomainCrosshairPaint() { return this.domainCrosshairPaint; } /** * Sets the Paint used to color the crosshairs (if visible) and notifies * registered listeners that the axis has been modified. * * @param paint the new crosshair paint. */ public void setDomainCrosshairPaint(Paint paint) { this.domainCrosshairPaint = paint; fireChangeEvent(); } /** * Returns a flag indicating whether or not the range crosshair is visible. * * @return The flag. */ public boolean isRangeCrosshairVisible() { return this.rangeCrosshairVisible; } /** * Sets the flag indicating whether or not the range crosshair is visible. * * @param flag the new value of the flag. */ public void setRangeCrosshairVisible(boolean flag) { if (this.rangeCrosshairVisible != flag) { this.rangeCrosshairVisible = flag; fireChangeEvent(); } } /** * Returns a flag indicating whether or not the crosshair should "lock-on" * to actual data values. * * @return The flag. */ public boolean isRangeCrosshairLockedOnData() { return this.rangeCrosshairLockedOnData; } /** * Sets the flag indicating whether or not the range crosshair should * "lock-on" to actual data values. * * @param flag the flag. */ public void setRangeCrosshairLockedOnData(boolean flag) { if (this.rangeCrosshairLockedOnData != flag) { this.rangeCrosshairLockedOnData = flag; fireChangeEvent(); } } /** * Returns the range crosshair value. * * @return The value. */ public double getRangeCrosshairValue() { return this.rangeCrosshairValue; } /** * Sets the domain crosshair value. *

* Registered listeners are notified that the plot has been modified, but * only if the crosshair is visible. * * @param value the new value. */ public void setRangeCrosshairValue(double value) { setRangeCrosshairValue(value, true); } /** * Sets the range crosshair value. *

* Registered listeners are notified that the axis has been modified, but * only if the crosshair is visible. * * @param value the new value. * @param notify a flag that controls whether or not listeners are * notified. */ public void setRangeCrosshairValue(double value, boolean notify) { this.rangeCrosshairValue = value; if (isRangeCrosshairVisible() && notify) { fireChangeEvent(); } } /** * Returns the Stroke used to draw the crosshair (if visible). * * @return The crosshair stroke. */ public Stroke getRangeCrosshairStroke() { return this.rangeCrosshairStroke; } /** * Sets the Stroke used to draw the crosshairs (if visible) and notifies * registered listeners that the axis has been modified. * * @param stroke the new crosshair stroke. */ public void setRangeCrosshairStroke(Stroke stroke) { this.rangeCrosshairStroke = stroke; fireChangeEvent(); } /** * Returns the range crosshair color. * * @return The crosshair color. */ public Paint getRangeCrosshairPaint() { return this.rangeCrosshairPaint; } /** * Sets the Paint used to color the crosshairs (if visible) and notifies * registered listeners that the axis has been modified. * * @param paint the new crosshair paint. */ public void setRangeCrosshairPaint(Paint paint) { this.rangeCrosshairPaint = paint; fireChangeEvent(); } /** * Returns the tool tip generator. * * @return The tool tip generator (possibly null). */ public ContourToolTipGenerator getToolTipGenerator() { return this.toolTipGenerator; } /** * Sets the tool tip generator. * * @param generator the tool tip generator (null permitted). */ public void setToolTipGenerator(ContourToolTipGenerator generator) { //Object oldValue = this.toolTipGenerator; this.toolTipGenerator = generator; } /** * Returns the URL generator for HTML image maps. * * @return The URL generator (possibly null). */ public XYURLGenerator getURLGenerator() { return this.urlGenerator; } /** * Sets the URL generator for HTML image maps. * * @param urlGenerator the URL generator (null permitted). */ public void setURLGenerator(XYURLGenerator urlGenerator) { //Object oldValue = this.urlGenerator; this.urlGenerator = urlGenerator; } /** * Draws a vertical line on the chart to represent a 'range marker'. * * @param g2 the graphics device. * @param plot the plot. * @param domainAxis the domain axis. * @param marker the marker line. * @param dataArea the axis data area. */ public void drawDomainMarker(Graphics2D g2, ContourPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = domainAxis.getRange(); if (!range.contains(value)) { return; } double x = domainAxis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, dataArea.getMaxY()); Paint paint = marker.getOutlinePaint(); Stroke stroke = marker.getOutlineStroke(); g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); g2.draw(line); } } /** * Draws a horizontal line across the chart to represent a 'range marker'. * * @param g2 the graphics device. * @param plot the plot. * @param rangeAxis the range axis. * @param marker the marker line. * @param dataArea the axis data area. */ public void drawRangeMarker(Graphics2D g2, ContourPlot plot, ValueAxis rangeAxis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = rangeAxis.getRange(); if (!range.contains(value)) { return; } double y = rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), y, dataArea.getMaxX(), y); Paint paint = marker.getOutlinePaint(); Stroke stroke = marker.getOutlineStroke(); g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); g2.draw(line); } } /** * Returns the clipPath. * @return ClipPath */ public ClipPath getClipPath() { return this.clipPath; } /** * Sets the clipPath. * @param clipPath The clipPath to set */ public void setClipPath(ClipPath clipPath) { this.clipPath = clipPath; } /** * Returns the ptSizePct. * @return double */ public double getPtSizePct() { return this.ptSizePct; } /** * Returns the renderAsPoints. * @return boolean */ public boolean isRenderAsPoints() { return this.renderAsPoints; } /** * Sets the ptSizePct. * @param ptSizePct The ptSizePct to set */ public void setPtSizePct(double ptSizePct) { this.ptSizePct = ptSizePct; } /** * Sets the renderAsPoints. * @param renderAsPoints The renderAsPoints to set */ public void setRenderAsPoints(boolean renderAsPoints) { this.renderAsPoints = renderAsPoints; } /** * Receives notification of a change to one of the plot's axes. * * @param event information about the event. */ public void axisChanged(AxisChangeEvent event) { Object source = event.getSource(); if (source.equals(this.rangeAxis) || source.equals(this.domainAxis)) { ColorBar cba = this.colorBar; if (this.colorBar.getAxis().isAutoRange()) { cba.getAxis().configure(); } } super.axisChanged(event); } /** * Returns the visible z-range. * * @param data the dataset. * @param x the x range. * @param y the y range. * * @return The range. */ public Range visibleRange(ContourDataset data, Range x, Range y) { Range range = null; range = data.getZValueRange(x, y); return range; } /** * Returns the missingPaint. * @return Paint */ public Paint getMissingPaint() { return this.missingPaint; } /** * Sets the missingPaint. * * @param paint the missingPaint to set. */ public void setMissingPaint(Paint paint) { this.missingPaint = paint; } /** * Multiplies the range on the domain axis/axes by the specified factor * (to be implemented). * * @param x the x-coordinate (in Java2D space). * @param y the y-coordinate (in Java2D space). * @param factor the zoom factor. */ public void zoomDomainAxes(double x, double y, double factor) { // TODO: to be implemented } /** * Zooms the domain axes (not yet implemented). * * @param x the x-coordinate (in Java2D space). * @param y the y-coordinate (in Java2D space). * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomDomainAxes(double x, double y, double lowerPercent, double upperPercent) { // TODO: to be implemented } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param x the x-coordinate (in Java2D space). * @param y the y-coordinate (in Java2D space). * @param factor the zoom factor. */ public void zoomRangeAxes(double x, double y, double factor) { // TODO: to be implemented } /** * Zooms the range axes (not yet implemented). * * @param x the x-coordinate (in Java2D space). * @param y the y-coordinate (in Java2D space). * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. */ public void zoomRangeAxes(double x, double y, double lowerPercent, double upperPercent) { // TODO: to be implemented } /** * Returns false. * * @return A boolean. */ public boolean isDomainZoomable() { return false; } /** * Returns false. * * @return A boolean. */ public boolean isRangeZoomable() { return false; } /** * Extends plot cloning to this plot type * @see org.jfree.chart.plot.Plot#clone() */ public Object clone() throws CloneNotSupportedException { ContourPlot clone = (ContourPlot) super.clone(); if (this.domainAxis != null) { clone.domainAxis = (ValueAxis) this.domainAxis.clone(); clone.domainAxis.setPlot(clone); clone.domainAxis.addChangeListener(clone); } if (this.rangeAxis != null) { clone.rangeAxis = (ValueAxis) this.rangeAxis.clone(); clone.rangeAxis.setPlot(clone); clone.rangeAxis.addChangeListener(clone); } if (clone.dataset != null) { clone.dataset.addChangeListener(clone); } if (this.colorBar != null) { clone.colorBar = (ColorBar) this.colorBar.clone(); } clone.domainMarkers = (List) ObjectUtilities.deepClone( this.domainMarkers); clone.rangeMarkers = (List) ObjectUtilities.deepClone( this.rangeMarkers); clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); if (this.clipPath != null) { clone.clipPath = (ClipPath) this.clipPath.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ContourPlotUtilities.java0000644000175000017500000000531311173030414030440 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ContourPlotUtilities.java * ------------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 22-Jul-2003 : Made this class abstract as there is no need to instantiate * it (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.Range; import org.jfree.data.contour.ContourDataset; import org.jfree.data.contour.DefaultContourDataset; /** * Some utility methods for the {@link ContourPlot} class. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public abstract class ContourPlotUtilities { /** * Returns the visible z-range. * * @param data the dataset. * @param x the x range. * @param y the y range. * * @return The range. */ public static Range visibleRange(ContourDataset data, Range x, Range y) { Range range = null; range = ((DefaultContourDataset) data).getZValueRange(x, y); return range; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ContourValuePlot.java0000644000175000017500000000417311173030414027544 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ContourValuePlot.java * --------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.Range; /** * An interface defining methods related to contour plots. * * @deprecated This interface is no longer supported (as of version 1.0.4). * If you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public interface ContourValuePlot { /** * Returns the range of data values to be plotted. * * @return The range. */ public Range getContourDataRange(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/Crosshair.java0000644000175000017500000005160211173030414026213 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * Crosshair.java * -------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 13-Feb-2009 : Version 1 (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Stroke; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.labels.CrosshairLabelGenerator; import org.jfree.chart.labels.StandardCrosshairLabelGenerator; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A crosshair for display on a plot. * * @since 1.0.13 */ public class Crosshair implements Cloneable, PublicCloneable, Serializable { /** Flag controlling visibility. */ private boolean visible; /** The crosshair value. */ private double value; /** The paint for the crosshair line. */ private transient Paint paint; /** The stroke for the crosshair line. */ private transient Stroke stroke; /** * A flag that controls whether or not the crosshair has a label * visible. */ private boolean labelVisible; /** * The label anchor. */ private RectangleAnchor labelAnchor; /** A label generator. */ private CrosshairLabelGenerator labelGenerator; /** * The x-offset in Java2D units. */ private double labelXOffset; /** * The y-offset in Java2D units. */ private double labelYOffset; /** * The label font. */ private Font labelFont; /** * The label paint. */ private transient Paint labelPaint; /** * The label background paint. */ private transient Paint labelBackgroundPaint; /** A flag that controls the visibility of the label outline. */ private boolean labelOutlineVisible; /** The label outline stroke. */ private transient Stroke labelOutlineStroke; /** The label outline paint. */ private transient Paint labelOutlinePaint; /** Property change support. */ private transient PropertyChangeSupport pcs; /** * Creates a new crosshair with value 0.0. */ public Crosshair() { this(0.0); } /** * Creates a new crosshair with the specified value. * * @param value the value. */ public Crosshair(double value) { this(value, Color.black, new BasicStroke(1.0f)); } /** * Creates a new crosshair value with the specified value and line style. * * @param value the value. * @param paint the line paint (null not permitted). * @param stroke the line stroke (null not permitted). */ public Crosshair(double value, Paint paint, Stroke stroke) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.visible = true; this.value = value; this.paint = paint; this.stroke = stroke; this.labelVisible = false; this.labelGenerator = new StandardCrosshairLabelGenerator(); this.labelAnchor = RectangleAnchor.BOTTOM_LEFT; this.labelXOffset = 3.0; this.labelYOffset = 3.0; this.labelFont = new Font("Tahoma", Font.PLAIN, 12); this.labelPaint = Color.black; this.labelBackgroundPaint = new Color(0, 0, 255, 63); this.labelOutlineVisible = true; this.labelOutlinePaint = Color.black; this.labelOutlineStroke = new BasicStroke(0.5f); this.pcs = new PropertyChangeSupport(this); } /** * Returns the flag that indicates whether or not the crosshair is * currently visible. * * @return A boolean. */ public boolean isVisible() { return this.visible; } /** * Sets the flag that controls the visibility of the crosshair and sends * a proerty change event (with the name 'visible') to all registered * listeners. * * @param visible the new flag value. */ public void setVisible(boolean visible) { boolean old = this.visible; this.visible = visible; this.pcs.firePropertyChange("visible", old, visible); } /** * Returns the crosshair value. * * @return The crosshair value. */ public double getValue() { return this.value; } /** * Sets the crosshair value and sends a property change event with the name * 'value' to all registered listeners. * * @param value the value. */ public void setValue(double value) { Double oldValue = new Double(this.value); this.value = value; this.pcs.firePropertyChange("value", oldValue, new Double(value)); } /** * Returns the paint for the crosshair line. * * @return The paint (never null). */ public Paint getPaint() { return this.paint; } /** * Sets the paint for the crosshair line and sends a property change event * with the name "paint" to all registered listeners. * * @param paint the paint (null not permitted). */ public void setPaint(Paint paint) { Paint old = this.paint; this.paint = paint; this.pcs.firePropertyChange("paint", old, paint); } /** * Returns the stroke for the crosshair line. * * @return The stroke (never null). */ public Stroke getStroke() { return this.stroke; } /** * Sets the stroke for the crosshair line and sends a property change event * with the name "stroke" to all registered listeners. * * @param stroke the stroke (null not permitted). */ public void setStroke(Stroke stroke) { Stroke old = this.stroke; this.stroke = stroke; this.pcs.firePropertyChange("stroke", old, stroke); } /** * Returns the flag that controls whether or not a label is drawn for * this crosshair. * * @return A boolean. */ public boolean isLabelVisible() { return this.labelVisible; } /** * Sets the flag that controls whether or not a label is drawn for the * crosshair and sends a property change event (with the name * 'labelVisible') to all registered listeners. * * @param visible the new flag value. */ public void setLabelVisible(boolean visible) { boolean old = this.labelVisible; this.labelVisible = visible; this.pcs.firePropertyChange("labelVisible", old, visible); } /** * Returns the crosshair label generator. * * @return The label crosshair generator (never null). */ public CrosshairLabelGenerator getLabelGenerator() { return this.labelGenerator; } /** * Sets the crosshair label generator and sends a property change event * (with the name 'labelGenerator') to all registered listeners. * * @param generator the new generator (null not permitted). */ public void setLabelGenerator(CrosshairLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } CrosshairLabelGenerator old = this.labelGenerator; this.labelGenerator = generator; this.pcs.firePropertyChange("labelGenerator", old, generator); } /** * Returns the label anchor point. * * @return the label anchor point (never null. */ public RectangleAnchor getLabelAnchor() { return this.labelAnchor; } /** * Sets the label anchor point and sends a property change event (with the * name 'labelAnchor') to all registered listeners. * * @param anchor the anchor (null not permitted). */ public void setLabelAnchor(RectangleAnchor anchor) { RectangleAnchor old = this.labelAnchor; this.labelAnchor = anchor; this.pcs.firePropertyChange("labelAnchor", old, anchor); } /** * Returns the x-offset for the label (in Java2D units). * * @return The x-offset. */ public double getLabelXOffset() { return this.labelXOffset; } /** * Sets the x-offset and sends a property change event (with the name * 'labelXOffset') to all registered listeners. * * @param offset the new offset. */ public void setLabelXOffset(double offset) { Double old = new Double(this.labelXOffset); this.labelXOffset = offset; this.pcs.firePropertyChange("labelXOffset", old, new Double(offset)); } /** * Returns the y-offset for the label (in Java2D units). * * @return The y-offset. */ public double getLabelYOffset() { return this.labelYOffset; } /** * Sets the y-offset and sends a property change event (with the name * 'labelYOffset') to all registered listeners. * * @param offset the new offset. */ public void setLabelYOffset(double offset) { Double old = new Double(this.labelYOffset); this.labelYOffset = offset; this.pcs.firePropertyChange("labelYOffset", old, new Double(offset)); } /** * Returns the label font. * * @return The label font (never null). */ public Font getLabelFont() { return this.labelFont; } /** * Sets the label font and sends a property change event (with the name * 'labelFont') to all registered listeners. * * @param font the font (null not permitted). */ public void setLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } Font old = this.labelFont; this.labelFont = font; this.pcs.firePropertyChange("labelFont", old, font); } /** * Returns the label paint. * * @return The label paint (never null). */ public Paint getLabelPaint() { return this.labelPaint; } /** * Sets the label paint and sends a property change event (with the name * 'labelPaint') to all registered listeners. * * @param paint the paint (null not permitted). */ public void setLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } Paint old = this.labelPaint; this.labelPaint = paint; this.pcs.firePropertyChange("labelPaint", old, paint); } /** * Returns the label background paint. * * @return The label background paint (possibly null). */ public Paint getLabelBackgroundPaint() { return this.labelBackgroundPaint; } /** * Sets the label background paint and sends a property change event with * the name 'labelBackgroundPaint') to all registered listeners. * * @param paint the paint (null permitted). */ public void setLabelBackgroundPaint(Paint paint) { Paint old = this.labelBackgroundPaint; this.labelBackgroundPaint = paint; this.pcs.firePropertyChange("labelBackgroundPaint", old, paint); } /** * Returns the flag that controls the visibility of the label outline. * * @return A boolean. */ public boolean isLabelOutlineVisible() { return this.labelOutlineVisible; } /** * Sets the flag that controls the visibility of the label outlines and * sends a property change event (with the name "labelOutlineVisible") to * all registered listeners. * * @param visible the new flag value. */ public void setLabelOutlineVisible(boolean visible) { boolean old = this.labelOutlineVisible; this.labelOutlineVisible = visible; this.pcs.firePropertyChange("labelOutlineVisible", old, visible); } /** * Returns the label outline paint. * * @return The label outline paint (never null). */ public Paint getLabelOutlinePaint() { return this.labelOutlinePaint; } /** * Sets the label outline paint and sends a property change event (with the * name "labelOutlinePaint") to all registered listeners. * * @param paint the paint (null not permitted). */ public void setLabelOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } Paint old = this.labelOutlinePaint; this.labelOutlinePaint = paint; this.pcs.firePropertyChange("labelOutlinePaint", old, paint); } /** * Returns the label outline stroke. * * @return The label outline stroke (never null). */ public Stroke getLabelOutlineStroke() { return this.labelOutlineStroke; } /** * Sets the label outline stroke and sends a property change event (with * the name 'labelOutlineStroke') to all registered listeners. * * @param stroke the stroke (null not permitted). */ public void setLabelOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } Stroke old = this.labelOutlineStroke; this.labelOutlineStroke = stroke; this.pcs.firePropertyChange("labelOutlineStroke", old, stroke); } /** * Tests this crosshair for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Crosshair)) { return false; } Crosshair that = (Crosshair) obj; if (this.visible != that.visible) { return false; } if (this.value != that.value) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!this.stroke.equals(that.stroke)) { return false; } if (this.labelVisible != that.labelVisible) { return false; } if (!this.labelGenerator.equals(that.labelGenerator)) { return false; } if (!this.labelAnchor.equals(that.labelAnchor)) { return false; } if (this.labelXOffset != that.labelXOffset) { return false; } if (this.labelYOffset != that.labelYOffset) { return false; } if (!this.labelFont.equals(that.labelFont)) { return false; } if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { return false; } if (!PaintUtilities.equal(this.labelBackgroundPaint, that.labelBackgroundPaint)) { return false; } if (this.labelOutlineVisible != that.labelOutlineVisible) { return false; } if (!PaintUtilities.equal(this.labelOutlinePaint, that.labelOutlinePaint)) { return false; } if (!this.labelOutlineStroke.equals(that.labelOutlineStroke)) { return false; } return true; // can't find any difference } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 7; hash = HashUtilities.hashCode(hash, this.visible); hash = HashUtilities.hashCode(hash, this.value); hash = HashUtilities.hashCode(hash, this.paint); hash = HashUtilities.hashCode(hash, this.stroke); hash = HashUtilities.hashCode(hash, this.labelVisible); hash = HashUtilities.hashCode(hash, this.labelAnchor); hash = HashUtilities.hashCode(hash, this.labelGenerator); hash = HashUtilities.hashCode(hash, this.labelXOffset); hash = HashUtilities.hashCode(hash, this.labelYOffset); hash = HashUtilities.hashCode(hash, this.labelFont); hash = HashUtilities.hashCode(hash, this.labelPaint); hash = HashUtilities.hashCode(hash, this.labelBackgroundPaint); hash = HashUtilities.hashCode(hash, this.labelOutlineVisible); hash = HashUtilities.hashCode(hash, this.labelOutlineStroke); hash = HashUtilities.hashCode(hash, this.labelOutlinePaint); return hash; } /** * Returns an independent copy of this instance. * * @return An independent copy of this instance. * * @throws java.lang.CloneNotSupportedException */ public Object clone() throws CloneNotSupportedException { // FIXME: clone generator return super.clone(); } /** * Adds a property change listener. * * @param l the listener. */ public void addPropertyChangeListener(PropertyChangeListener l) { this.pcs.addPropertyChangeListener(l); } /** * Removes a property change listener. * * @param l the listener. */ public void removePropertyChangeListener(PropertyChangeListener l) { this.pcs.removePropertyChangeListener(l); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.stroke, stream); SerialUtilities.writePaint(this.labelPaint, stream); SerialUtilities.writePaint(this.labelBackgroundPaint, stream); SerialUtilities.writeStroke(this.labelOutlineStroke, stream); SerialUtilities.writePaint(this.labelOutlinePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); this.labelPaint = SerialUtilities.readPaint(stream); this.labelBackgroundPaint = SerialUtilities.readPaint(stream); this.labelOutlineStroke = SerialUtilities.readStroke(stream); this.labelOutlinePaint = SerialUtilities.readPaint(stream); this.pcs = new PropertyChangeSupport(this); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/CrosshairState.java0000644000175000017500000003747311173030414027226 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CrosshairState.java * ------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 24-Jan-2002 : Version 1 (DG); * 05-Mar-2002 : Added Javadoc comments (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 19-Sep-2003 : Modified crosshair distance calculation (DG); * 04-Dec-2003 : Crosshair anchor point now stored outside chart since it is * dependent on the display target (DG); * 25-Feb-2004 : Replaced CrosshairInfo --> CrosshairState (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Oct-2006 : Fixed initialisation of CrosshairState - see bug report * 1565168 (DG); * 06-Feb-2007 : Added new fields and methods to fix bug 1086307 (DG); * 26-Jun-2008 : Now tracks dataset index (DG); * */ package org.jfree.chart.plot; import java.awt.geom.Point2D; /** * Maintains state information about crosshairs on a plot between successive * calls to the renderer's draw method. This class is used internally by * JFreeChart - it is not intended for external use. */ public class CrosshairState { /** * A flag that controls whether the distance is calculated in data space * or Java2D space. */ private boolean calculateDistanceInDataSpace = false; /** The x-value (in data space) for the anchor point. */ private double anchorX; /** The y-value (in data space) for the anchor point. */ private double anchorY; /** The anchor point in Java2D space - if null, don't update crosshair. */ private Point2D anchor; /** The x-value for the current crosshair point. */ private double crosshairX; /** The y-value for the current crosshair point. */ private double crosshairY; /** * The dataset index that the crosshair point relates to (this determines * the axes that the crosshairs will be plotted against). * * @since 1.0.11 */ private int datasetIndex; /** * The index of the domain axis that the crosshair x-value is measured * against. * * @since 1.0.4 */ private int domainAxisIndex; /** * The index of the range axis that the crosshair y-value is measured * against. * * @since 1.0.4 */ private int rangeAxisIndex; /** * The smallest distance (so far) between the anchor point and a data * point. */ private double distance; /** * Creates a new CrosshairState instance that calculates * distance in Java2D space. */ public CrosshairState() { this(false); } /** * Creates a new CrosshairState instance. * * @param calculateDistanceInDataSpace a flag that controls whether the * distance is calculated in data * space or Java2D space. */ public CrosshairState(boolean calculateDistanceInDataSpace) { this.calculateDistanceInDataSpace = calculateDistanceInDataSpace; } /** * Returns the distance between the anchor point and the current crosshair * point. * * @return The distance. * * @see #setCrosshairDistance(double) * @since 1.0.3 */ public double getCrosshairDistance() { return this.distance; } /** * Sets the distance between the anchor point and the current crosshair * point. As each data point is processed, its distance to the anchor * point is compared with this value and, if it is closer, the data point * becomes the new crosshair point. * * @param distance the distance. * * @see #getCrosshairDistance() */ public void setCrosshairDistance(double distance) { this.distance = distance; } /** * Evaluates a data point and if it is the closest to the anchor point it * becomes the new crosshair point. *

* To understand this method, you need to know the context in which it will * be called. An instance of this class is passed to an * {@link org.jfree.chart.renderer.xy.XYItemRenderer} as * each data point is plotted. As the point is plotted, it is passed to * this method to see if it should be the new crosshair point. * * @param x x coordinate (measured against the domain axis). * @param y y coordinate (measured against the range axis). * @param transX x translated into Java2D space. * @param transY y translated into Java2D space. * @param orientation the plot orientation. * * @deprecated Use {@link #updateCrosshairPoint(double, double, int, int, * double, double, PlotOrientation)}. See bug report 1086307. */ public void updateCrosshairPoint(double x, double y, double transX, double transY, PlotOrientation orientation) { updateCrosshairPoint(x, y, 0, 0, transX, transY, orientation); } /** * Evaluates a data point and if it is the closest to the anchor point it * becomes the new crosshair point. *

* To understand this method, you need to know the context in which it will * be called. An instance of this class is passed to an * {@link org.jfree.chart.renderer.xy.XYItemRenderer} as * each data point is plotted. As the point is plotted, it is passed to * this method to see if it should be the new crosshair point. * * @param x x coordinate (measured against the domain axis). * @param y y coordinate (measured against the range axis). * @param domainAxisIndex the index of the domain axis for this point. * @param rangeAxisIndex the index of the range axis for this point. * @param transX x translated into Java2D space. * @param transY y translated into Java2D space. * @param orientation the plot orientation. * * @since 1.0.4 */ public void updateCrosshairPoint(double x, double y, int domainAxisIndex, int rangeAxisIndex, double transX, double transY, PlotOrientation orientation) { if (this.anchor != null) { double d = 0.0; if (this.calculateDistanceInDataSpace) { d = (x - this.anchorX) * (x - this.anchorX) + (y - this.anchorY) * (y - this.anchorY); } else { double xx = this.anchor.getX(); double yy = this.anchor.getY(); if (orientation == PlotOrientation.HORIZONTAL) { double temp = yy; yy = xx; xx = temp; } d = (transX - xx) * (transX - xx) + (transY - yy) * (transY - yy); } if (d < this.distance) { this.crosshairX = x; this.crosshairY = y; this.domainAxisIndex = domainAxisIndex; this.rangeAxisIndex = rangeAxisIndex; this.distance = d; } } } /** * Evaluates an x-value and if it is the closest to the anchor x-value it * becomes the new crosshair value. *

* Used in cases where only the x-axis is numerical. * * @param candidateX x position of the candidate for the new crosshair * point. * * @deprecated Use {@link #updateCrosshairX(double, int)}. See bug report * 1086307. */ public void updateCrosshairX(double candidateX) { updateCrosshairX(candidateX, 0); } /** * Evaluates an x-value and if it is the closest to the anchor x-value it * becomes the new crosshair value. *

* Used in cases where only the x-axis is numerical. * * @param candidateX x position of the candidate for the new crosshair * point. * @param domainAxisIndex the index of the domain axis for this x-value. * * @since 1.0.4 */ public void updateCrosshairX(double candidateX, int domainAxisIndex) { double d = Math.abs(candidateX - this.anchorX); if (d < this.distance) { this.crosshairX = candidateX; this.domainAxisIndex = domainAxisIndex; this.distance = d; } } /** * Evaluates a y-value and if it is the closest to the anchor y-value it * becomes the new crosshair value. *

* Used in cases where only the y-axis is numerical. * * @param candidateY y position of the candidate for the new crosshair * point. * * @deprecated Use {@link #updateCrosshairY(double, int)}. See bug report * 1086307. */ public void updateCrosshairY(double candidateY) { updateCrosshairY(candidateY, 0); } /** * Evaluates a y-value and if it is the closest to the anchor y-value it * becomes the new crosshair value. *

* Used in cases where only the y-axis is numerical. * * @param candidateY y position of the candidate for the new crosshair * point. * @param rangeAxisIndex the index of the range axis for this y-value. * * @since 1.0.4 */ public void updateCrosshairY(double candidateY, int rangeAxisIndex) { double d = Math.abs(candidateY - this.anchorY); if (d < this.distance) { this.crosshairY = candidateY; this.rangeAxisIndex = rangeAxisIndex; this.distance = d; } } /** * Returns the anchor point. * * @return The anchor point. * * @see #setAnchor(Point2D) * * @since 1.0.3 */ public Point2D getAnchor() { return this.anchor; } /** * Sets the anchor point. This is usually the mouse click point in a chart * panel, and the crosshair point will often be the data item that is * closest to the anchor point. *

* Note that the x and y coordinates (in data space) are not updated by * this method - the caller is responsible for ensuring that this happens * in sync. * * @param anchor the anchor point (null permitted). * * @see #getAnchor() */ public void setAnchor(Point2D anchor) { this.anchor = anchor; } /** * Returns the x-coordinate (in data space) for the anchor point. * * @return The x-coordinate of the anchor point. * * @since 1.0.3 */ public double getAnchorX() { return this.anchorX; } /** * Sets the x-coordinate (in data space) for the anchor point. Note that * this does NOT update the anchor itself - the caller is responsible for * ensuring this is done in sync. * * @param x the x-coordinate. * * @since 1.0.3 */ public void setAnchorX(double x) { this.anchorX = x; } /** * Returns the y-coordinate (in data space) for the anchor point. * * @return The y-coordinate of teh anchor point. * * @since 1.0.3 */ public double getAnchorY() { return this.anchorY; } /** * Sets the y-coordinate (in data space) for the anchor point. Note that * this does NOT update the anchor itself - the caller is responsible for * ensuring this is done in sync. * * @param y the y-coordinate. * * @since 1.0.3 */ public void setAnchorY(double y) { this.anchorY = y; } /** * Get the x-value for the crosshair point. * * @return The x position of the crosshair point. * * @see #setCrosshairX(double) */ public double getCrosshairX() { return this.crosshairX; } /** * Sets the x coordinate for the crosshair. This is the coordinate in data * space measured against the domain axis. * * @param x the coordinate. * * @see #getCrosshairX() * @see #setCrosshairY(double) * @see #updateCrosshairPoint(double, double, double, double, * PlotOrientation) */ public void setCrosshairX(double x) { this.crosshairX = x; } /** * Get the y-value for the crosshair point. This is the coordinate in data * space measured against the range axis. * * @return The y position of the crosshair point. * * @see #setCrosshairY(double) */ public double getCrosshairY() { return this.crosshairY; } /** * Sets the y coordinate for the crosshair. * * @param y the y coordinate. * * @see #getCrosshairY() * @see #setCrosshairX(double) * @see #updateCrosshairPoint(double, double, double, double, * PlotOrientation) */ public void setCrosshairY(double y) { this.crosshairY = y; } /** * Returns the dataset index that the crosshair values relate to. The * dataset is mapped to specific axes, and this is how the crosshairs are * mapped also. * * @return The dataset index. * * @see #setDatasetIndex(int) * * @since 1.0.11 */ public int getDatasetIndex() { return this.datasetIndex; } /** * Sets the dataset index that the current crosshair values relate to. * * @param index the dataset index. * * @see #getDatasetIndex() * * @since 1.0.11 */ public void setDatasetIndex(int index) { this.datasetIndex = index; } /** * Returns the domain axis index for the crosshair x-value. * * @return The domain axis index. * * @since 1.0.4 * * @deprecated As of version 1.0.11, the domain axis should be determined * using the dataset index. */ public int getDomainAxisIndex() { return this.domainAxisIndex; } /** * Returns the range axis index for the crosshair y-value. * * @return The range axis index. * * @since 1.0.4 * * @deprecated As of version 1.0.11, the domain axis should be determined * using the dataset index. */ public int getRangeAxisIndex() { return this.rangeAxisIndex; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/DatasetRenderingOrder.java0000644000175000017500000001043611173030414030475 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DatasetRenderingOrder.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-May-2003 : Version 1 (DG); * 02-Jun-2004 : Changed 'STANDARD' --> 'FORWARD' (DG); * 21-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.plot; import java.io.ObjectStreamException; import java.io.Serializable; /** * Defines the tokens that indicate the rendering order for datasets in a * {@link org.jfree.chart.plot.CategoryPlot} or an * {@link org.jfree.chart.plot.XYPlot}. */ public final class DatasetRenderingOrder implements Serializable { /** For serialization. */ private static final long serialVersionUID = -600593412366385072L; /** * Render datasets in the order 0, 1, 2, ..., N-1, where N is the number * of datasets. */ public static final DatasetRenderingOrder FORWARD = new DatasetRenderingOrder("DatasetRenderingOrder.FORWARD"); /** * Render datasets in the order N-1, N-2, ..., 2, 1, 0, where N is the * number of datasets. */ public static final DatasetRenderingOrder REVERSE = new DatasetRenderingOrder("DatasetRenderingOrder.REVERSE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private DatasetRenderingOrder(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string (never null). */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DatasetRenderingOrder)) { return false; } DatasetRenderingOrder order = (DatasetRenderingOrder) obj; if (!this.name.equals(order.toString())) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(DatasetRenderingOrder.FORWARD)) { return DatasetRenderingOrder.FORWARD; } else if (this.equals(DatasetRenderingOrder.REVERSE)) { return DatasetRenderingOrder.REVERSE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/DefaultDrawingSupplier.java0000644000175000017500000004320711173030414030704 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * DefaultDrawingSupplier.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Jeremy Bowman; * * Changes * ------- * 16-Jan-2003 : Version 1 (DG); * 17-Jan-2003 : Added stroke method, renamed DefaultPaintSupplier * --> DefaultDrawingSupplier (DG) * 27-Jan-2003 : Incorporated code from SeriesShapeFactory, originally * contributed by Jeremy Bowman (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Jun-2007 : Added fillPaintSequence (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Arrays; import org.jfree.chart.ChartColor; import org.jfree.io.SerialUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A default implementation of the {@link DrawingSupplier} interface. All * {@link Plot} instances have a new instance of this class installed by * default. */ public class DefaultDrawingSupplier implements DrawingSupplier, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7339847061039422538L; /** The default fill paint sequence. */ public static final Paint[] DEFAULT_PAINT_SEQUENCE = ChartColor.createDefaultPaintArray(); /** The default outline paint sequence. */ public static final Paint[] DEFAULT_OUTLINE_PAINT_SEQUENCE = new Paint[] { Color.lightGray}; /** The default fill paint sequence. */ public static final Paint[] DEFAULT_FILL_PAINT_SEQUENCE = new Paint[] { Color.white}; /** The default stroke sequence. */ public static final Stroke[] DEFAULT_STROKE_SEQUENCE = new Stroke[] { new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL)}; /** The default outline stroke sequence. */ public static final Stroke[] DEFAULT_OUTLINE_STROKE_SEQUENCE = new Stroke[] {new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL)}; /** The default shape sequence. */ public static final Shape[] DEFAULT_SHAPE_SEQUENCE = createStandardSeriesShapes(); /** The paint sequence. */ private transient Paint[] paintSequence; /** The current paint index. */ private int paintIndex; /** The outline paint sequence. */ private transient Paint[] outlinePaintSequence; /** The current outline paint index. */ private int outlinePaintIndex; /** The fill paint sequence. */ private transient Paint[] fillPaintSequence; /** The current fill paint index. */ private int fillPaintIndex; /** The stroke sequence. */ private transient Stroke[] strokeSequence; /** The current stroke index. */ private int strokeIndex; /** The outline stroke sequence. */ private transient Stroke[] outlineStrokeSequence; /** The current outline stroke index. */ private int outlineStrokeIndex; /** The shape sequence. */ private transient Shape[] shapeSequence; /** The current shape index. */ private int shapeIndex; /** * Creates a new supplier, with default sequences for fill paint, outline * paint, stroke and shapes. */ public DefaultDrawingSupplier() { this(DEFAULT_PAINT_SEQUENCE, DEFAULT_FILL_PAINT_SEQUENCE, DEFAULT_OUTLINE_PAINT_SEQUENCE, DEFAULT_STROKE_SEQUENCE, DEFAULT_OUTLINE_STROKE_SEQUENCE, DEFAULT_SHAPE_SEQUENCE); } /** * Creates a new supplier. * * @param paintSequence the fill paint sequence. * @param outlinePaintSequence the outline paint sequence. * @param strokeSequence the stroke sequence. * @param outlineStrokeSequence the outline stroke sequence. * @param shapeSequence the shape sequence. */ public DefaultDrawingSupplier(Paint[] paintSequence, Paint[] outlinePaintSequence, Stroke[] strokeSequence, Stroke[] outlineStrokeSequence, Shape[] shapeSequence) { this.paintSequence = paintSequence; this.fillPaintSequence = DEFAULT_FILL_PAINT_SEQUENCE; this.outlinePaintSequence = outlinePaintSequence; this.strokeSequence = strokeSequence; this.outlineStrokeSequence = outlineStrokeSequence; this.shapeSequence = shapeSequence; } /** * Creates a new supplier. * * @param paintSequence the paint sequence. * @param fillPaintSequence the fill paint sequence. * @param outlinePaintSequence the outline paint sequence. * @param strokeSequence the stroke sequence. * @param outlineStrokeSequence the outline stroke sequence. * @param shapeSequence the shape sequence. * * @since 1.0.6 */ public DefaultDrawingSupplier(Paint[] paintSequence, Paint[] fillPaintSequence, Paint[] outlinePaintSequence, Stroke[] strokeSequence, Stroke[] outlineStrokeSequence, Shape[] shapeSequence) { this.paintSequence = paintSequence; this.fillPaintSequence = fillPaintSequence; this.outlinePaintSequence = outlinePaintSequence; this.strokeSequence = strokeSequence; this.outlineStrokeSequence = outlineStrokeSequence; this.shapeSequence = shapeSequence; } /** * Returns the next paint in the sequence. * * @return The paint. */ public Paint getNextPaint() { Paint result = this.paintSequence[this.paintIndex % this.paintSequence.length]; this.paintIndex++; return result; } /** * Returns the next outline paint in the sequence. * * @return The paint. */ public Paint getNextOutlinePaint() { Paint result = this.outlinePaintSequence[ this.outlinePaintIndex % this.outlinePaintSequence.length]; this.outlinePaintIndex++; return result; } /** * Returns the next fill paint in the sequence. * * @return The paint. * * @since 1.0.6 */ public Paint getNextFillPaint() { Paint result = this.fillPaintSequence[this.fillPaintIndex % this.fillPaintSequence.length]; this.fillPaintIndex++; return result; } /** * Returns the next stroke in the sequence. * * @return The stroke. */ public Stroke getNextStroke() { Stroke result = this.strokeSequence[ this.strokeIndex % this.strokeSequence.length]; this.strokeIndex++; return result; } /** * Returns the next outline stroke in the sequence. * * @return The stroke. */ public Stroke getNextOutlineStroke() { Stroke result = this.outlineStrokeSequence[ this.outlineStrokeIndex % this.outlineStrokeSequence.length]; this.outlineStrokeIndex++; return result; } /** * Returns the next shape in the sequence. * * @return The shape. */ public Shape getNextShape() { Shape result = this.shapeSequence[ this.shapeIndex % this.shapeSequence.length]; this.shapeIndex++; return result; } /** * Creates an array of standard shapes to display for the items in series * on charts. * * @return The array of shapes. */ public static Shape[] createStandardSeriesShapes() { Shape[] result = new Shape[10]; double size = 6.0; double delta = size / 2.0; int[] xpoints = null; int[] ypoints = null; // square result[0] = new Rectangle2D.Double(-delta, -delta, size, size); // circle result[1] = new Ellipse2D.Double(-delta, -delta, size, size); // up-pointing triangle xpoints = intArray(0.0, delta, -delta); ypoints = intArray(-delta, delta, delta); result[2] = new Polygon(xpoints, ypoints, 3); // diamond xpoints = intArray(0.0, delta, 0.0, -delta); ypoints = intArray(-delta, 0.0, delta, 0.0); result[3] = new Polygon(xpoints, ypoints, 4); // horizontal rectangle result[4] = new Rectangle2D.Double(-delta, -delta / 2, size, size / 2); // down-pointing triangle xpoints = intArray(-delta, +delta, 0.0); ypoints = intArray(-delta, -delta, delta); result[5] = new Polygon(xpoints, ypoints, 3); // horizontal ellipse result[6] = new Ellipse2D.Double(-delta, -delta / 2, size, size / 2); // right-pointing triangle xpoints = intArray(-delta, delta, -delta); ypoints = intArray(-delta, 0.0, delta); result[7] = new Polygon(xpoints, ypoints, 3); // vertical rectangle result[8] = new Rectangle2D.Double(-delta / 2, -delta, size / 2, size); // left-pointing triangle xpoints = intArray(-delta, delta, delta); ypoints = intArray(0.0, -delta, +delta); result[9] = new Polygon(xpoints, ypoints, 3); return result; } /** * Tests this object for equality with another object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultDrawingSupplier)) { return false; } DefaultDrawingSupplier that = (DefaultDrawingSupplier) obj; if (!Arrays.equals(this.paintSequence, that.paintSequence)) { return false; } if (this.paintIndex != that.paintIndex) { return false; } if (!Arrays.equals(this.outlinePaintSequence, that.outlinePaintSequence)) { return false; } if (this.outlinePaintIndex != that.outlinePaintIndex) { return false; } if (!Arrays.equals(this.strokeSequence, that.strokeSequence)) { return false; } if (this.strokeIndex != that.strokeIndex) { return false; } if (!Arrays.equals(this.outlineStrokeSequence, that.outlineStrokeSequence)) { return false; } if (this.outlineStrokeIndex != that.outlineStrokeIndex) { return false; } if (!equalShapes(this.shapeSequence, that.shapeSequence)) { return false; } if (this.shapeIndex != that.shapeIndex) { return false; } return true; } /** * A utility method for testing the equality of two arrays of shapes. * * @param s1 the first array (null permitted). * @param s2 the second array (null permitted). * * @return A boolean. */ private boolean equalShapes(Shape[] s1, Shape[] s2) { if (s1 == null) { return s2 == null; } if (s2 == null) { return false; } if (s1.length != s2.length) { return false; } for (int i = 0; i < s1.length; i++) { if (!ShapeUtilities.equal(s1[i], s2[i])) { return false; } } return true; } /** * Handles serialization. * * @param stream the output stream. * * @throws IOException if there is an I/O problem. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); int paintCount = this.paintSequence.length; stream.writeInt(paintCount); for (int i = 0; i < paintCount; i++) { SerialUtilities.writePaint(this.paintSequence[i], stream); } int outlinePaintCount = this.outlinePaintSequence.length; stream.writeInt(outlinePaintCount); for (int i = 0; i < outlinePaintCount; i++) { SerialUtilities.writePaint(this.outlinePaintSequence[i], stream); } int strokeCount = this.strokeSequence.length; stream.writeInt(strokeCount); for (int i = 0; i < strokeCount; i++) { SerialUtilities.writeStroke(this.strokeSequence[i], stream); } int outlineStrokeCount = this.outlineStrokeSequence.length; stream.writeInt(outlineStrokeCount); for (int i = 0; i < outlineStrokeCount; i++) { SerialUtilities.writeStroke(this.outlineStrokeSequence[i], stream); } int shapeCount = this.shapeSequence.length; stream.writeInt(shapeCount); for (int i = 0; i < shapeCount; i++) { SerialUtilities.writeShape(this.shapeSequence[i], stream); } } /** * Restores a serialized object. * * @param stream the input stream. * * @throws IOException if there is an I/O problem. * @throws ClassNotFoundException if there is a problem loading a class. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int paintCount = stream.readInt(); this.paintSequence = new Paint[paintCount]; for (int i = 0; i < paintCount; i++) { this.paintSequence[i] = SerialUtilities.readPaint(stream); } int outlinePaintCount = stream.readInt(); this.outlinePaintSequence = new Paint[outlinePaintCount]; for (int i = 0; i < outlinePaintCount; i++) { this.outlinePaintSequence[i] = SerialUtilities.readPaint(stream); } int strokeCount = stream.readInt(); this.strokeSequence = new Stroke[strokeCount]; for (int i = 0; i < strokeCount; i++) { this.strokeSequence[i] = SerialUtilities.readStroke(stream); } int outlineStrokeCount = stream.readInt(); this.outlineStrokeSequence = new Stroke[outlineStrokeCount]; for (int i = 0; i < outlineStrokeCount; i++) { this.outlineStrokeSequence[i] = SerialUtilities.readStroke(stream); } int shapeCount = stream.readInt(); this.shapeSequence = new Shape[shapeCount]; for (int i = 0; i < shapeCount; i++) { this.shapeSequence[i] = SerialUtilities.readShape(stream); } } /** * Helper method to avoid lots of explicit casts in getShape(). Returns * an array containing the provided doubles cast to ints. * * @param a x * @param b y * @param c z * * @return int[3] with converted params. */ private static int[] intArray(double a, double b, double c) { return new int[] {(int) a, (int) b, (int) c}; } /** * Helper method to avoid lots of explicit casts in getShape(). Returns * an array containing the provided doubles cast to ints. * * @param a x * @param b y * @param c z * @param d t * * @return int[4] with converted params. */ private static int[] intArray(double a, double b, double c, double d) { return new int[] {(int) a, (int) b, (int) c, (int) d}; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException if a component of the supplier does * not support cloning. */ public Object clone() throws CloneNotSupportedException { DefaultDrawingSupplier clone = (DefaultDrawingSupplier) super.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/DialShape.java0000644000175000017500000000753411173030414026115 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * DialShape.java * -------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 20-Aug-2003 : Version 1 (DG); * 12-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.plot; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the background shape for a * {@link org.jfree.chart.plot.MeterPlot}. */ public final class DialShape implements Serializable { /** For serialization. */ private static final long serialVersionUID = -3471933055190251131L; /** Circle. */ public static final DialShape CIRCLE = new DialShape("DialShape.CIRCLE"); /** Chord. */ public static final DialShape CHORD = new DialShape("DialShape.CHORD"); /** Pie. */ public static final DialShape PIE = new DialShape("DialShape.PIE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private DialShape(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DialShape)) { return false; } DialShape shape = (DialShape) obj; if (!this.name.equals(shape.toString())) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(DialShape.CIRCLE)) { return DialShape.CIRCLE; } else if (this.equals(DialShape.CHORD)) { return DialShape.CHORD; } else if (this.equals(DialShape.PIE)) { return DialShape.PIE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/DrawingSupplier.java0000644000175000017500000000646611173030414027405 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * DrawingSupplier.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Jan-2003 : Version 1 (DG); * 17-Jan-2003 : Renamed PaintSupplier --> DrawingSupplier (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Jun-2007 : Added getNextOutlinePaint() method. * */ package org.jfree.chart.plot; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; /** * A supplier of Paint, Stroke and Shape * objects for use by plots and renderers. By providing a central place for * obtaining these items, we can ensure that duplication is avoided. *

* To support the cloning of charts, classes that implement this interface * should also implement PublicCloneable. */ public interface DrawingSupplier { /** * Returns the next paint in a sequence maintained by the supplier. * * @return The paint. */ public Paint getNextPaint(); /** * Returns the next outline paint in a sequence maintained by the supplier. * * @return The paint. */ public Paint getNextOutlinePaint(); /** * Returns the next fill paint in a sequence maintained by the supplier. * * @return The paint. * * @since 1.0.6 */ public Paint getNextFillPaint(); /** * Returns the next Stroke object in a sequence maintained by * the supplier. * * @return The stroke. */ public Stroke getNextStroke(); /** * Returns the next Stroke object in a sequence maintained by * the supplier. * * @return The stroke. */ public Stroke getNextOutlineStroke(); /** * Returns the next Shape object in a sequence maintained by * the supplier. * * @return The shape. */ public Shape getNextShape(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/FastScatterPlot.java0000644000175000017500000011156111173030414027341 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * FastScatterPlot.java * -------------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Arnaud Lelievre; * * Changes * ------- * 29-Oct-2002 : Added standard header (DG); * 07-Nov-2002 : Fixed errors reported by Checkstyle (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 19-Aug-2003 : Implemented Cloneable (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 12-Nov-2003 : Implemented zooming (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 26-Jan-2004 : Added domain and range grid lines (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 29-Sep-2004 : Removed hard-coded color (DG); * 04-Oct-2004 : Reworked equals() method and renamed ArrayUtils * --> ArrayUtilities (DG); * 12-Nov-2004 : Implemented the new Zoomable interface (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 16-Jun-2005 : Added get/setData() methods (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 10-Nov-2006 : Fixed bug 1593150, by not allowing null axes, and added * setDomainAxis() and setRangeAxis() methods (DG); * 24-Sep-2007 : Implemented new zooming methods (DG); * 25-Mar-2008 : Make use of new fireChangeEvent() method (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 26-Mar-2009 : Implemented Pannable, and fixed bug in zooming (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.axis.ValueTick; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ArrayUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A fast scatter plot. */ public class FastScatterPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7871545897358563521L; /** The default grid line stroke. */ public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] {2.0f, 2.0f}, 0.0f); /** The default grid line paint. */ public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; /** The data. */ private float[][] data; /** The x data range. */ private Range xDataRange; /** The y data range. */ private Range yDataRange; /** The domain axis (used for the x-values). */ private ValueAxis domainAxis; /** The range axis (used for the y-values). */ private ValueAxis rangeAxis; /** The paint used to plot data points. */ private transient Paint paint; /** A flag that controls whether the domain grid-lines are visible. */ private boolean domainGridlinesVisible; /** The stroke used to draw the domain grid-lines. */ private transient Stroke domainGridlineStroke; /** The paint used to draw the domain grid-lines. */ private transient Paint domainGridlinePaint; /** A flag that controls whether the range grid-lines are visible. */ private boolean rangeGridlinesVisible; /** The stroke used to draw the range grid-lines. */ private transient Stroke rangeGridlineStroke; /** The paint used to draw the range grid-lines. */ private transient Paint rangeGridlinePaint; /** * A flag that controls whether or not panning is enabled for the domain * axis. * * @since 1.0.13 */ private boolean domainPannable; /** * A flag that controls whether or not panning is enabled for the range * axis. * * @since 1.0.13 */ private boolean rangePannable; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** * Creates a new instance of FastScatterPlot with default * axes. */ public FastScatterPlot() { this(null, new NumberAxis("X"), new NumberAxis("Y")); } /** * Creates a new fast scatter plot. *

* The data is an array of x, y values: data[0][i] = x, data[1][i] = y. * * @param data the data (null permitted). * @param domainAxis the domain (x) axis (null not permitted). * @param rangeAxis the range (y) axis (null not permitted). */ public FastScatterPlot(float[][] data, ValueAxis domainAxis, ValueAxis rangeAxis) { super(); if (domainAxis == null) { throw new IllegalArgumentException("Null 'domainAxis' argument."); } if (rangeAxis == null) { throw new IllegalArgumentException("Null 'rangeAxis' argument."); } this.data = data; this.xDataRange = calculateXDataRange(data); this.yDataRange = calculateYDataRange(data); this.domainAxis = domainAxis; this.domainAxis.setPlot(this); this.domainAxis.addChangeListener(this); this.rangeAxis = rangeAxis; this.rangeAxis.setPlot(this); this.rangeAxis.addChangeListener(this); this.paint = Color.red; this.domainGridlinesVisible = true; this.domainGridlinePaint = FastScatterPlot.DEFAULT_GRIDLINE_PAINT; this.domainGridlineStroke = FastScatterPlot.DEFAULT_GRIDLINE_STROKE; this.rangeGridlinesVisible = true; this.rangeGridlinePaint = FastScatterPlot.DEFAULT_GRIDLINE_PAINT; this.rangeGridlineStroke = FastScatterPlot.DEFAULT_GRIDLINE_STROKE; } /** * Returns a short string describing the plot type. * * @return A short string describing the plot type. */ public String getPlotType() { return localizationResources.getString("Fast_Scatter_Plot"); } /** * Returns the data array used by the plot. * * @return The data array (possibly null). * * @see #setData(float[][]) */ public float[][] getData() { return this.data; } /** * Sets the data array used by the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param data the data array (null permitted). * * @see #getData() */ public void setData(float[][] data) { this.data = data; fireChangeEvent(); } /** * Returns the orientation of the plot. * * @return The orientation (always {@link PlotOrientation#VERTICAL}). */ public PlotOrientation getOrientation() { return PlotOrientation.VERTICAL; } /** * Returns the domain axis for the plot. * * @return The domain axis (never null). * * @see #setDomainAxis(ValueAxis) */ public ValueAxis getDomainAxis() { return this.domainAxis; } /** * Sets the domain axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param axis the axis (null not permitted). * * @since 1.0.3 * * @see #getDomainAxis() */ public void setDomainAxis(ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } this.domainAxis = axis; fireChangeEvent(); } /** * Returns the range axis for the plot. * * @return The range axis (never null). * * @see #setRangeAxis(ValueAxis) */ public ValueAxis getRangeAxis() { return this.rangeAxis; } /** * Sets the range axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param axis the axis (null not permitted). * * @since 1.0.3 * * @see #getRangeAxis() */ public void setRangeAxis(ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } this.rangeAxis = axis; fireChangeEvent(); } /** * Returns the paint used to plot data points. The default is * Color.red. * * @return The paint. * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the color for the data points and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; fireChangeEvent(); } /** * Returns true if the domain gridlines are visible, and * false otherwise. * * @return true or false. * * @see #setDomainGridlinesVisible(boolean) * @see #setDomainGridlinePaint(Paint) */ public boolean isDomainGridlinesVisible() { return this.domainGridlinesVisible; } /** * Sets the flag that controls whether or not the domain grid-lines are * visible. If the flag value is changed, a {@link PlotChangeEvent} is * sent to all registered listeners. * * @param visible the new value of the flag. * * @see #getDomainGridlinePaint() */ public void setDomainGridlinesVisible(boolean visible) { if (this.domainGridlinesVisible != visible) { this.domainGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the grid-lines (if any) plotted against the * domain axis. * * @return The stroke (never null). * * @see #setDomainGridlineStroke(Stroke) */ public Stroke getDomainGridlineStroke() { return this.domainGridlineStroke; } /** * Sets the stroke for the grid lines plotted against the domain axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getDomainGridlineStroke() */ public void setDomainGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.domainGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the grid lines (if any) plotted against the domain * axis. * * @return The paint (never null). * * @see #setDomainGridlinePaint(Paint) */ public Paint getDomainGridlinePaint() { return this.domainGridlinePaint; } /** * Sets the paint for the grid lines plotted against the domain axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getDomainGridlinePaint() */ public void setDomainGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainGridlinePaint = paint; fireChangeEvent(); } /** * Returns true if the range axis grid is visible, and * false otherwise. * * @return true or false. * * @see #setRangeGridlinesVisible(boolean) */ public boolean isRangeGridlinesVisible() { return this.rangeGridlinesVisible; } /** * Sets the flag that controls whether or not the range axis grid lines are * visible. If the flag value is changed, a {@link PlotChangeEvent} is * sent to all registered listeners. * * @param visible the new value of the flag. * * @see #isRangeGridlinesVisible() */ public void setRangeGridlinesVisible(boolean visible) { if (this.rangeGridlinesVisible != visible) { this.rangeGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the grid lines (if any) plotted against the range * axis. * * @return The stroke (never null). * * @see #setRangeGridlineStroke(Stroke) */ public Stroke getRangeGridlineStroke() { return this.rangeGridlineStroke; } /** * Sets the stroke for the grid lines plotted against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @see #getRangeGridlineStroke() */ public void setRangeGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the grid lines (if any) plotted against the range * axis. * * @return The paint (never null). * * @see #setRangeGridlinePaint(Paint) */ public Paint getRangeGridlinePaint() { return this.rangeGridlinePaint; } /** * Sets the paint for the grid lines plotted against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeGridlinePaint() */ public void setRangeGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeGridlinePaint = paint; fireChangeEvent(); } /** * Draws the fast scatter plot on a Java 2D graphics device (such as the * screen or a printer). * * @param g2 the graphics device. * @param area the area within which the plot (including axis labels) * should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot (ignored). * @param info collects chart drawing information (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // set up info collection... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(area, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); AxisState domainAxisState = this.domainAxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info); drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); render(g2, dataArea, info, null); g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } /** * Draws a representation of the data within the dataArea region. The * info and crosshairState arguments may be * null. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension information. * @param crosshairState collects crosshair information (null * permitted). */ public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState) { //long start = System.currentTimeMillis(); //System.out.println("Start: " + start); g2.setPaint(this.paint); // if the axes use a linear scale, you can uncomment the code below and // switch to the alternative transX/transY calculation inside the loop // that follows - it is a little bit faster then. // // int xx = (int) dataArea.getMinX(); // int ww = (int) dataArea.getWidth(); // int yy = (int) dataArea.getMaxY(); // int hh = (int) dataArea.getHeight(); // double domainMin = this.domainAxis.getLowerBound(); // double domainLength = this.domainAxis.getUpperBound() - domainMin; // double rangeMin = this.rangeAxis.getLowerBound(); // double rangeLength = this.rangeAxis.getUpperBound() - rangeMin; if (this.data != null) { for (int i = 0; i < this.data[0].length; i++) { float x = this.data[0][i]; float y = this.data[1][i]; //int transX = (int) (xx + ww * (x - domainMin) / domainLength); //int transY = (int) (yy - hh * (y - rangeMin) / rangeLength); int transX = (int) this.domainAxis.valueToJava2D(x, dataArea, RectangleEdge.BOTTOM); int transY = (int) this.rangeAxis.valueToJava2D(y, dataArea, RectangleEdge.LEFT); g2.fillRect(transX, transY, 1, 1); } } //long finish = System.currentTimeMillis(); //System.out.println("Finish: " + finish); //System.out.println("Time: " + (finish - start)); } /** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // draw the domain grid lines, if the flag says they're visible... if (isDomainGridlinesVisible()) { Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double v = this.domainAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); g2.setPaint(getDomainGridlinePaint()); g2.setStroke(getDomainGridlineStroke()); g2.draw(line); } } } /** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. */ protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // draw the range grid lines, if the flag says they're visible... if (isRangeGridlinesVisible()) { Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double v = this.rangeAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); g2.setPaint(getRangeGridlinePaint()); g2.setStroke(getRangeGridlineStroke()); g2.draw(line); } } } /** * Returns the range of data values to be plotted along the axis, or * null if the specified axis isn't the domain axis or the * range axis for the plot. * * @param axis the axis (null permitted). * * @return The range (possibly null). */ public Range getDataRange(ValueAxis axis) { Range result = null; if (axis == this.domainAxis) { result = this.xDataRange; } else if (axis == this.rangeAxis) { result = this.yDataRange; } return result; } /** * Calculates the X data range. * * @param data the data (null permitted). * * @return The range. */ private Range calculateXDataRange(float[][] data) { Range result = null; if (data != null) { float lowest = Float.POSITIVE_INFINITY; float highest = Float.NEGATIVE_INFINITY; for (int i = 0; i < data[0].length; i++) { float v = data[0][i]; if (v < lowest) { lowest = v; } if (v > highest) { highest = v; } } if (lowest <= highest) { result = new Range(lowest, highest); } } return result; } /** * Calculates the Y data range. * * @param data the data (null permitted). * * @return The range. */ private Range calculateYDataRange(float[][] data) { Range result = null; if (data != null) { float lowest = Float.POSITIVE_INFINITY; float highest = Float.NEGATIVE_INFINITY; for (int i = 0; i < data[0].length; i++) { float v = data[1][i]; if (v < lowest) { lowest = v; } if (v > highest) { highest = v; } } if (lowest <= highest) { result = new Range(lowest, highest); } } return result; } /** * Multiplies the range on the domain axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point. */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source) { this.domainAxis.resizeRange(factor); } /** * Multiplies the range on the domain axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL // orientation double sourceX = source.getX(); double anchorX = this.domainAxis.java2DToValue(sourceX, info.getDataArea(), RectangleEdge.BOTTOM); this.domainAxis.resizeRange2(factor, anchorX); } else { this.domainAxis.resizeRange(factor); } } /** * Zooms in on the domain axes. * * @param lowerPercent the new lower bound as a percentage of the current * range. * @param upperPercent the new upper bound as a percentage of the current * range. * @param info the plot rendering info. * @param source the source point. */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { this.domainAxis.zoomRange(lowerPercent, upperPercent); } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point. */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source) { this.rangeAxis.resizeRange(factor); } /** * Multiplies the range on the range axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL // orientation double sourceY = source.getY(); double anchorY = this.rangeAxis.java2DToValue(sourceY, info.getDataArea(), RectangleEdge.LEFT); this.rangeAxis.resizeRange2(factor, anchorY); } else { this.rangeAxis.resizeRange(factor); } } /** * Zooms in on the range axes. * * @param lowerPercent the new lower bound as a percentage of the current * range. * @param upperPercent the new upper bound as a percentage of the current * range. * @param info the plot rendering info. * @param source the source point. */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { this.rangeAxis.zoomRange(lowerPercent, upperPercent); } /** * Returns true. * * @return A boolean. */ public boolean isDomainZoomable() { return true; } /** * Returns true. * * @return A boolean. */ public boolean isRangeZoomable() { return true; } /** * Returns true if panning is enabled for the domain axes, * and false otherwise. * * @return A boolean. * * @since 1.0.13 */ public boolean isDomainPannable() { return this.domainPannable; } /** * Sets the flag that enables or disables panning of the plot along the * domain axes. * * @param pannable the new flag value. * * @since 1.0.13 */ public void setDomainPannable(boolean pannable) { this.domainPannable = pannable; } /** * Returns true if panning is enabled for the range axes, * and false otherwise. * * @return A boolean. * * @since 1.0.13 */ public boolean isRangePannable() { return this.rangePannable; } /** * Sets the flag that enables or disables panning of the plot along * the range axes. * * @param pannable the new flag value. * * @since 1.0.13 */ public void setRangePannable(boolean pannable) { this.rangePannable = pannable; } /** * Pans the domain axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panDomainAxes(double percent, PlotRenderingInfo info, Point2D source) { if (!isDomainPannable() || this.domainAxis == null) { return; } double length = this.domainAxis.getRange().getLength(); double adj = -percent * length; if (this.domainAxis.isInverted()) { adj = -adj; } this.domainAxis.setRange(this.domainAxis.getLowerBound() + adj, this.domainAxis.getUpperBound() + adj); } /** * Pans the range axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panRangeAxes(double percent, PlotRenderingInfo info, Point2D source) { if (!isRangePannable() || this.rangeAxis == null) { return; } double length = this.rangeAxis.getRange().getLength(); double adj = percent * length; if (this.rangeAxis.isInverted()) { adj = -adj; } this.rangeAxis.setRange(this.rangeAxis.getLowerBound() + adj, this.rangeAxis.getUpperBound() + adj); } /** * Tests an arbitrary object for equality with this plot. Note that * FastScatterPlot carries its data around with it (rather * than referencing a dataset), and the data is included in the * equality test. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof FastScatterPlot)) { return false; } FastScatterPlot that = (FastScatterPlot) obj; if (this.domainPannable != that.domainPannable) { return false; } if (this.rangePannable != that.rangePannable) { return false; } if (!ArrayUtilities.equal(this.data, that.data)) { return false; } if (!ObjectUtilities.equal(this.domainAxis, that.domainAxis)) { return false; } if (!ObjectUtilities.equal(this.rangeAxis, that.rangeAxis)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (this.domainGridlinesVisible != that.domainGridlinesVisible) { return false; } if (!PaintUtilities.equal(this.domainGridlinePaint, that.domainGridlinePaint)) { return false; } if (!ObjectUtilities.equal(this.domainGridlineStroke, that.domainGridlineStroke)) { return false; } if (!this.rangeGridlinesVisible == that.rangeGridlinesVisible) { return false; } if (!PaintUtilities.equal(this.rangeGridlinePaint, that.rangeGridlinePaint)) { return false; } if (!ObjectUtilities.equal(this.rangeGridlineStroke, that.rangeGridlineStroke)) { return false; } return true; } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if some component of the plot does * not support cloning. */ public Object clone() throws CloneNotSupportedException { FastScatterPlot clone = (FastScatterPlot) super.clone(); if (this.data != null) { clone.data = ArrayUtilities.clone(this.data); } if (this.domainAxis != null) { clone.domainAxis = (ValueAxis) this.domainAxis.clone(); clone.domainAxis.setPlot(clone); clone.domainAxis.addChangeListener(clone); } if (this.rangeAxis != null) { clone.rangeAxis = (ValueAxis) this.rangeAxis.clone(); clone.rangeAxis.setPlot(clone); clone.rangeAxis.addChangeListener(clone); } return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.domainGridlineStroke, stream); SerialUtilities.writePaint(this.domainGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); SerialUtilities.writePaint(this.rangeGridlinePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.domainGridlineStroke = SerialUtilities.readStroke(stream); this.domainGridlinePaint = SerialUtilities.readPaint(stream); this.rangeGridlineStroke = SerialUtilities.readStroke(stream); this.rangeGridlinePaint = SerialUtilities.readPaint(stream); if (this.domainAxis != null) { this.domainAxis.addChangeListener(this); } if (this.rangeAxis != null) { this.rangeAxis.addChangeListener(this); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/GreyPalette.java0000644000175000017500000000556311173030414026510 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * GreyPalette.java * ---------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 26-Mar-2003 : Implemented Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.plot; import java.io.Serializable; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * A grey color palette. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class GreyPalette extends ColorPalette implements Serializable { /** For serialization. */ private static final long serialVersionUID = -2120941170159987395L; /** * Creates a new palette. */ public GreyPalette() { super(); initialize(); } /** * Intializes the palette's indices. */ public void initialize() { setPaletteName("Grey"); this.r = new int[256]; this.g = new int[256]; this.b = new int[256]; this.r[0] = 255; this.g[0] = 255; this.b[0] = 255; this.r[1] = 0; this.g[1] = 0; this.b[1] = 0; for (int i = 2; i < 256; i++) { this.r[i] = i; this.g[i] = i; this.b[i] = i; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/IntervalMarker.java0000644000175000017500000001647311173030414027213 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * IntervalMarker.java * ------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Aug-2002 : Added stroke to constructor in Marker class (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 26-Mar-2003 : Implemented Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Sep-2006 : Added MarkerChangeEvent notification (DG); * 18-Dec-2007 : Added new constructor (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.awt.Stroke; import java.io.Serializable; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.LengthAdjustmentType; import org.jfree.util.ObjectUtilities; /** * Represents an interval to be highlighted in some way. */ public class IntervalMarker extends Marker implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -1762344775267627916L; /** The start value. */ private double startValue; /** The end value. */ private double endValue; /** The gradient paint transformer (optional). */ private GradientPaintTransformer gradientPaintTransformer; /** * Constructs an interval marker. * * @param start the start of the interval. * @param end the end of the interval. */ public IntervalMarker(double start, double end) { this(start, end, Color.gray, new BasicStroke(0.5f), Color.gray, new BasicStroke(0.5f), 0.8f); } /** * Creates a new interval marker with the specified range and fill paint. * The outline paint and stroke default to null. * * @param start the lower bound of the interval. * @param end the upper bound of the interval. * @param paint the fill paint (null not permitted). * * @since 1.0.9 */ public IntervalMarker(double start, double end, Paint paint) { this(start, end, paint, new BasicStroke(0.5f), null, null, 0.8f); } /** * Constructs an interval marker. * * @param start the start of the interval. * @param end the end of the interval. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). * @param outlinePaint the outline paint. * @param outlineStroke the outline stroke. * @param alpha the alpha transparency. */ public IntervalMarker(double start, double end, Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha) { super(paint, stroke, outlinePaint, outlineStroke, alpha); this.startValue = start; this.endValue = end; this.gradientPaintTransformer = null; setLabelOffsetType(LengthAdjustmentType.CONTRACT); } /** * Returns the start value for the interval. * * @return The start value. */ public double getStartValue() { return this.startValue; } /** * Sets the start value for the marker and sends a * {@link MarkerChangeEvent} to all registered listeners. * * @param value the value. * * @since 1.0.3 */ public void setStartValue(double value) { this.startValue = value; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the end value for the interval. * * @return The end value. */ public double getEndValue() { return this.endValue; } /** * Sets the end value for the marker and sends a * {@link MarkerChangeEvent} to all registered listeners. * * @param value the value. * * @since 1.0.3 */ public void setEndValue(double value) { this.endValue = value; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the gradient paint transformer. * * @return The gradient paint transformer (possibly null). */ public GradientPaintTransformer getGradientPaintTransformer() { return this.gradientPaintTransformer; } /** * Sets the gradient paint transformer and sends a * {@link MarkerChangeEvent} to all registered listeners. * * @param transformer the transformer (null permitted). */ public void setGradientPaintTransformer( GradientPaintTransformer transformer) { this.gradientPaintTransformer = transformer; notifyListeners(new MarkerChangeEvent(this)); } /** * Tests the marker for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof IntervalMarker)) { return false; } if (!super.equals(obj)) { return false; } IntervalMarker that = (IntervalMarker) obj; if (this.startValue != that.startValue) { return false; } if (this.endValue != that.endValue) { return false; } if (!ObjectUtilities.equal(this.gradientPaintTransformer, that.gradientPaintTransformer)) { return false; } return true; } /** * Returns a clone of the marker. * * @return A clone. * * @throws CloneNotSupportedException Not thrown by this class, but the * exception is declared for the use of subclasses. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/JThermometer.java0000644000175000017500000002422111173030414026660 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * JThermometer.java * ----------------- * A plot that displays a single value in a thermometer type display. * * (C) Copyright 2000-2008, Australian Antarctic Division and Contributors. * * Original Author: Bryan Scott. * Contributor(s): David Gilbert (for Object Refinery Limited); * Irv Thomae; * * Changes (from 17-Sep-2002) * -------------------------- * 17-Sep-2002 : Reviewed with Checkstyle utility (DG); * 18-Sep-2003 : Integrated new methods contributed by Irv Thomae (DG); * 08-Jan-2004 : Renamed AbstractTitle --> Title and moved to new package (DG); * 31-May-2005 : Fixed typo in method name (DG); * */ package org.jfree.chart.plot; import java.awt.CardLayout; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.io.Serializable; import java.text.DecimalFormat; import javax.swing.JPanel; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.data.general.DefaultValueDataset; import org.jfree.ui.RectangleInsets; /** * An initial quick and dirty. The concept behind this class would be to * generate a gui bean that could be used within JBuilder, Netbeans etc... */ public class JThermometer extends JPanel implements Serializable { /** For serialization. */ private static final long serialVersionUID = 1079905665515589820L; /** The dataset. */ private DefaultValueDataset data; /** The chart. */ private JFreeChart chart; /** The chart panel. */ private ChartPanel panel; /** The thermometer plot. */ private ThermometerPlot plot = new ThermometerPlot(); /** * Default constructor. */ public JThermometer() { super(new CardLayout()); this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); this.data = new DefaultValueDataset(); this.plot.setDataset(this.data); this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, this.plot, false); this.panel = new ChartPanel(this.chart); add(this.panel, "Panel"); setBackground(getBackground()); } /** * Adds a subtitle to the chart. * * @param subtitle the subtitle. */ public void addSubtitle(Title subtitle) { this.chart.addSubtitle(subtitle); } /** * Adds a subtitle to the chart. * * @param subtitle the subtitle. */ public void addSubtitle(String subtitle) { this.chart.addSubtitle(new TextTitle(subtitle)); } /** * Adds a subtitle to the chart. * * @param subtitle the subtitle. * @param font the subtitle font. */ public void addSubtitle(String subtitle, Font font) { this.chart.addSubtitle(new TextTitle(subtitle, font)); } /** * Sets the value format for the thermometer. * * @param df the formatter. */ public void setValueFormat(DecimalFormat df) { this.plot.setValueFormat(df); } /** * Sets the lower and upper bounds for the thermometer. * * @param lower the lower bound. * @param upper the upper bound. */ public void setRange(double lower, double upper) { this.plot.setRange(lower, upper); } /** * Sets the range. * * @param range the range type. * @param displayLow the low value. * @param displayHigh the high value. */ public void setSubrangeInfo(int range, double displayLow, double displayHigh) { this.plot.setSubrangeInfo(range, displayLow, displayHigh); } /** * Sets the range. * * @param range the range type. * @param rangeLow the low value for the range. * @param rangeHigh the high value for the range. * @param displayLow the low value for display. * @param displayHigh the high value for display. */ public void setSubrangeInfo(int range, double rangeLow, double rangeHigh, double displayLow, double displayHigh) { this.plot.setSubrangeInfo(range, rangeLow, rangeHigh, displayLow, displayHigh); } /** * Sets the location at which the temperature value is displayed. * * @param loc the location. */ public void setValueLocation(int loc) { this.plot.setValueLocation(loc); this.panel.repaint(); } /** * Sets the value paint. * * @param paint the paint. */ public void setValuePaint(Paint paint) { this.plot.setValuePaint(paint); } /** * Returns the value of the thermometer. * * @return The value. */ public Number getValue() { if (this.data != null) { return this.data.getValue(); } else { return null; } } /** * Sets the value of the thermometer. * * @param value the value. */ public void setValue(double value) { setValue(new Double(value)); } /** * Sets the value of the thermometer. * * @param value the value. */ public void setValue(Number value) { if (this.data != null) { this.data.setValue(value); } } /** * Sets the unit type. * * @param i the unit type. */ public void setUnits(int i) { if (this.plot != null) { this.plot.setUnits(i); } } /** * Sets the outline paint. * * @param p the paint. */ public void setOutlinePaint(Paint p) { if (this.plot != null) { this.plot.setOutlinePaint(p); } } /** * Sets the foreground color. * * @param fg the foreground color. */ public void setForeground(Color fg) { super.setForeground(fg); if (this.plot != null) { this.plot.setThermometerPaint(fg); } } /** * Sets the background color. * * @param bg the background color. */ public void setBackground(Color bg) { super.setBackground(bg); if (this.plot != null) { this.plot.setBackgroundPaint(bg); } if (this.chart != null) { this.chart.setBackgroundPaint(bg); } if (this.panel != null) { this.panel.setBackground(bg); } } /** * Sets the value font. * * @param f the font. */ public void setValueFont(Font f) { if (this.plot != null) { this.plot.setValueFont(f); } } /** * Returns the tick label font. * * @return The tick label font. */ public Font getTickLabelFont() { ValueAxis axis = this.plot.getRangeAxis(); return axis.getTickLabelFont(); } /** * Sets the tick label font. * * @param font the font. */ public void setTickLabelFont(Font font) { ValueAxis axis = this.plot.getRangeAxis(); axis.setTickLabelFont(font); } /** * Increases or decreases the tick font size. * * @param delta the change in size. */ public void changeTickFontSize(int delta) { Font f = getTickLabelFont(); String fName = f.getFontName(); Font newFont = new Font(fName, f.getStyle(), (f.getSize() + delta)); setTickLabelFont(newFont); } /** * Sets the tick font style. * * @param style the style. */ public void setTickFontStyle(int style) { Font f = getTickLabelFont(); String fName = f.getFontName(); Font newFont = new Font(fName, style, f.getSize()); setTickLabelFont(newFont); } /** * Sets the flag that controls whether or not the display range follows the * data value. * * @param flag the new value of the flag. */ public void setFollowDataInSubranges(boolean flag) { this.plot.setFollowDataInSubranges(flag); } /** * Sets the flag that controls whether or not value lines are displayed. * * @param b the new flag value. */ public void setShowValueLines(boolean b) { this.plot.setShowValueLines(b); } /** * Sets the location for the axis. * * @param location the location. */ public void setShowAxisLocation(int location) { this.plot.setAxisLocation(location); } /** * Returns the location for the axis. * * @return The location. */ public int getShowAxisLocation() { return this.plot.getAxisLocation(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle.properties0000644000175000017500000000115111173030414031305 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # 19-Jan-2004 : Added Polar_Plot (DG); # Category_Plot=Category Plot Combined_Domain_XYPlot=Combined Domain XYPlot Combined_Range_XYPlot=Combined Range XYPlot Compass_Plot=Compass Plot Contour_Plot=Contour Plot Fast_Scatter_Plot=Fast Scatter Plot Meter_Plot=Meter Plot Period_Marker_Plot=Period Marker Plot Pie_Plot=Pie Plot Thermometer_Plot=Thermometer Plot XY_Plot=XY Plot Polar_Plot=Polar Plot #Secteurs 3D Pie_3D_Plot=Pie 3D Plot libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_de.properties0000644000175000017500000000124511173030414031761 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file - german version # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt); # Category_Plot=Kategoriediagramm Combined_Domain_XYPlot=Rubriken-kombiniertes XY-Diagramm Combined_Range_XYPlot=Werte-kombiniertes XY-Diagramm Compass_Plot=Kompass-Diagramm Contour_Plot=Liniendiagramm Fast_Scatter_Plot=Streudiagramm Meter_Plot=Tachometer-Diagramm Period_Marker_Plot=Zeitreihe Pie_Plot=Kreisdiagramm Thermometer_Plot=Thermometer-Diagramm XY_Plot=XY-Diagramm #Secteurs 3D Pie_3D_Plot=3D-Kreisdiagramm libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_es.properties0000644000175000017500000000122311173030414031774 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file - spanish version # # Changes (from 16-Dec-2003) # -------------------------- # 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo # Category_Plot=Barras Combined_Domain_XYPlot=Curvas combinadas por la abcisa Combined_Range_XYPlot=Curvas combinadas por la ordenada Compass_Plot=Diagrama del comp\u00a3s Contour_Plot=Contorno del comp\u00a3s Fast_Scatter_Plot=Dispersi\u00f3n Meter_Plot=Diagrama del metro Period_Marker_Plot=Diagrama del marcador del per�odo Pie_Plot=Sectores Thermometer_Plot=Term\u00f3metro XY_Plot=Curvas Pie_3D_Plot=Sectores 3D libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_fr.properties0000644000175000017500000000107011173030414031774 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file - French version # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # Category_Plot=Barres Combined_Domain_XYPlot=Courbes combin\u00E9es sur l'abcisse Combined_Range_XYPlot=Courbes combin\u00E9es sur l'ordonn\u00E9e Compass_Plot=Compas Contour_Plot=Contours Fast_Scatter_Plot=Nuage de points Meter_Plot=Niveaux Period_Marker_Plot=Period Marker Plot Pie_Plot=Secteurs Thermometer_Plot=Thermom\u00E8tre XY_Plot=Courbes Pie_3D_Plot=Secteurs 3D libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_nl.properties0000644000175000017500000000121511173030414031777 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 24-Mar-2003 : Translated into Dutch # 31-Aug-2003 : Initial version (AL); # Category_Plot=Categorie diagram Combined_Domain_XYPlot=Diagrammen met gecombineerd domein Combined_Range_XYPlot=Diagrammen met gecombineerd bereik Compass_Plot=Kompas diagram Contour_Plot=Contour diagram Fast_Scatter_Plot=Spreidingsdiagram Meter_Plot=Wijzerplaat-diagram Period_Marker_Plot=Periodemarker-diagram Pie_Plot=Taartdiagram Thermometer_Plot=Thermometer-diagram XY_Plot=XY Diagram #Secteurs 3D Pie_3D_Plot=3D Taartdiagram libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_pl.properties0000644000175000017500000000141311173030414032001 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file # # Changes (from 15-Mar-2004) # -------------------------- # 15-Mar-2004 : Initial version (Kuba Duda); # Category_Plot=Wykres kategorii Combined_Domain_XYPlot=Wykres kombinowany z dzielon\u0105 osi\u0105 domeny Combined_Range_XYPlot=Wykres kombinowany z dzielon\u0105 osi\u0105 zasi\u0119gu Compass_Plot=wykres kompasowy Contour_Plot=Wykres konturowy Fast_Scatter_Plot=Szybki wykres rozproszony punktowy Meter_Plot=Wykres miernikowy Period_Marker_Plot=Wykres zaznaczaj\u0105cy okresy czasu Pie_Plot=Wykres ko\u0142owy Thermometer_Plot=Wykres temperatury XY_Plot=Wykres XY Polar_Plot=Wykres dwuwymiarowy o wsp\u00f3\u0142rz\u0119dnych biegunowych #Secteurs 3D Pie_3D_Plot=Wykres ko\u0142owy 3D libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_pt_PT.properties0000644000175000017500000000107311173030414032416 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version # # Changes (from 09-Set-2003) # -------------------------- # 09-Set-2003 : Initial version (Eduardo Ramalho); # Category_Plot=Barras Combined_Domain_XYPlot=Curvas combinadas pela abcissa Combined_Range_XYPlot=Curvas combinadas pela ordenada Compass_Plot=Compasso Contour_Plot=Contours Fast_Scatter_Plot=Dispers\u00E3o Meter_Plot=N\u00EDvel Period_Marker_Plot=Period Marker Plot Pie_Plot=Sectores Thermometer_Plot=Term\u00a2metro XY_Plot=Curvas Pie_3D_Plot=Sectores 3D libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_ru.properties0000644000175000017500000000210411173030414032012 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file # # Changes (from 10-Nov-2003) # -------------------------- # 10-Nov-2003 : Initial version (AL); # Category_Plot=\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f Combined_Domain_XYPlot=\u0421\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0441\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 Combined_Range_XYPlot=\u0421\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0441\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Compass_Plot=\u041a\u043e\u043c\u043f\u0430\u0441 Contour_Plot=\u041a\u043e\u043d\u0442\u0443\u0440 Fast_Scatter_Plot=\u0420\u043e\u0441\u0441\u044b\u043f\u044c Meter_Plot=\u041c\u0435\u0442\u0440\u0438\u043a\u0430 Period_Marker_Plot=\u041f\u0435\u0440\u0438\u043e\u0434 Pie_Plot=\u041a\u0440\u0443\u0433 Thermometer_Plot=\u0422\u0435\u0440\u043c\u043e\u043c\u0435\u0442\u0440 XY_Plot=XY #Secteurs 3D Pie_3D_Plot=\u0422\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0440\u0443\u0433 libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/LocalizationBundle_zh_CN.properties0000644000175000017500000000131611173030414032371 0ustar vincentvincent# org.jfree.chart.plot.plot ResourceBundle properties file # # Changes # ------- # 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495; # Category_Plot=\u7c7b\u6bd4\u56fe Combined_Domain_XYPlot=\u7ec4\u5408\u7684\u9879\u76ee XY \u56fe Combined_Range_XYPlot=\u7ec4\u5408\u7684\u8303\u56f4 XY \u56fe Compass_Plot=\u7f57\u76d8\u56fe Contour_Plot=\u8f6e\u5ed3\u56fe Fast_Scatter_Plot=\u5feb\u901f\u5206\u6563\u56fe Meter_Plot=\u4eea\u8868\u56fe Period_Marker_Plot=\u5468\u671f\u6807\u8bb0\u56fe Pie_Plot=\u997c\u56fe Thermometer_Plot=\u6e29\u5ea6\u8ba1\u56fe XY_Plot=XY \u56fe Polar_Plot=\u6781\u5750\u6807\u56fe #Secteurs 3D Pie_3D_Plot=\u4e09\u7ef4\u997c\u56fe libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/Marker.java0000644000175000017500000005166311173030414025506 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * Marker.java * ----------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; * * Changes * ------- * 02-Jul-2002 : Added extra constructor, standard header and Javadoc * comments (DG); * 20-Aug-2002 : Added the outline stroke attribute (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 16-Oct-2002 : Added new constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 21-May-2003 : Added labels (DG); * 11-Sep-2003 : Implemented Cloneable (NB); * 05-Nov-2003 : Added checks to ensure some attributes are never null (DG); * 11-Feb-2003 : Moved to org.jfree.chart.plot package, plus significant API * changes to support IntervalMarker in plots (DG); * 14-Jun-2004 : Updated equals() method (DG); * 21-Jan-2005 : Added settings to control direction of horizontal and * vertical label offsets (DG); * 01-Jun-2005 : Modified to use only one label offset type - this will be * applied to the domain or range axis as appropriate (DG); * 06-Jun-2005 : Fix equals() method to handle GradientPaint (DG); * 19-Aug-2005 : Changed constructor from public --> protected (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Sep-2006 : Added MarkerChangeListener support (DG); * 26-Sep-2007 : Fix for serialization bug 1802195 (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Stroke; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.EventListener; import javax.swing.event.EventListenerList; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.io.SerialUtilities; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * The base class for markers that can be added to plots to highlight a value * or range of values. *

* An event notification mechanism was added to this class in JFreeChart * version 1.0.3. */ public abstract class Marker implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -734389651405327166L; /** The paint (null is not allowed). */ private transient Paint paint; /** The stroke (null is not allowed). */ private transient Stroke stroke; /** The outline paint. */ private transient Paint outlinePaint; /** The outline stroke. */ private transient Stroke outlineStroke; /** The alpha transparency. */ private float alpha; /** The label. */ private String label = null; /** The label font. */ private Font labelFont; /** The label paint. */ private transient Paint labelPaint; /** The label position. */ private RectangleAnchor labelAnchor; /** The text anchor for the label. */ private TextAnchor labelTextAnchor; /** The label offset from the marker rectangle. */ private RectangleInsets labelOffset; /** * The offset type for the domain or range axis (never null). */ private LengthAdjustmentType labelOffsetType; /** Storage for registered change listeners. */ private transient EventListenerList listenerList; /** * Creates a new marker with default attributes. */ protected Marker() { this(Color.gray); } /** * Constructs a new marker. * * @param paint the paint (null not permitted). */ protected Marker(Paint paint) { this(paint, new BasicStroke(0.5f), Color.gray, new BasicStroke(0.5f), 0.80f); } /** * Constructs a new marker. * * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). * @param outlinePaint the outline paint (null permitted). * @param outlineStroke the outline stroke (null permitted). * @param alpha the alpha transparency (must be in the range 0.0f to * 1.0f). * * @throws IllegalArgumentException if paint or * stroke is null, or alpha is * not in the specified range. */ protected Marker(Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } if (alpha < 0.0f || alpha > 1.0f) throw new IllegalArgumentException( "The 'alpha' value must be in the range 0.0f to 1.0f"); this.paint = paint; this.stroke = stroke; this.outlinePaint = outlinePaint; this.outlineStroke = outlineStroke; this.alpha = alpha; this.labelFont = new Font("SansSerif", Font.PLAIN, 9); this.labelPaint = Color.black; this.labelAnchor = RectangleAnchor.TOP_LEFT; this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0); this.labelOffsetType = LengthAdjustmentType.CONTRACT; this.labelTextAnchor = TextAnchor.CENTER; this.listenerList = new EventListenerList(); } /** * Returns the paint. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint and sends a {@link MarkerChangeEvent} to all registered * listeners. * * @param paint the paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the stroke. * * @return The stroke (never null). * * @see #setStroke(Stroke) */ public Stroke getStroke() { return this.stroke; } /** * Sets the stroke and sends a {@link MarkerChangeEvent} to all registered * listeners. * * @param stroke the stroke (null not permitted). * * @see #getStroke() */ public void setStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.stroke = stroke; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the outline paint. * * @return The outline paint (possibly null). * * @see #setOutlinePaint(Paint) */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint and sends a {@link MarkerChangeEvent} to all * registered listeners. * * @param paint the paint (null permitted). * * @see #getOutlinePaint() */ public void setOutlinePaint(Paint paint) { this.outlinePaint = paint; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the outline stroke. * * @return The outline stroke (possibly null). * * @see #setOutlineStroke(Stroke) */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the outline stroke and sends a {@link MarkerChangeEvent} to all * registered listeners. * * @param stroke the stroke (null permitted). * * @see #getOutlineStroke() */ public void setOutlineStroke(Stroke stroke) { this.outlineStroke = stroke; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the alpha transparency. * * @return The alpha transparency. * * @see #setAlpha(float) */ public float getAlpha() { return this.alpha; } /** * Sets the alpha transparency that should be used when drawing the * marker, and sends a {@link MarkerChangeEvent} to all registered * listeners. The alpha transparency is a value in the range 0.0f * (completely transparent) to 1.0f (completely opaque). * * @param alpha the alpha transparency (must be in the range 0.0f to * 1.0f). * * @throws IllegalArgumentException if alpha is not in the * specified range. * * @see #getAlpha() */ public void setAlpha(float alpha) { if (alpha < 0.0f || alpha > 1.0f) throw new IllegalArgumentException( "The 'alpha' value must be in the range 0.0f to 1.0f"); this.alpha = alpha; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label (if null no label is displayed). * * @return The label (possibly null). * * @see #setLabel(String) */ public String getLabel() { return this.label; } /** * Sets the label (if null no label is displayed) and sends a * {@link MarkerChangeEvent} to all registered listeners. * * @param label the label (null permitted). * * @see #getLabel() */ public void setLabel(String label) { this.label = label; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label font. * * @return The label font (never null). * * @see #setLabelFont(Font) */ public Font getLabelFont() { return this.labelFont; } /** * Sets the label font and sends a {@link MarkerChangeEvent} to all * registered listeners. * * @param font the font (null not permitted). * * @see #getLabelFont() */ public void setLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.labelFont = font; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label paint. * * @return The label paint (never
null
). * * @see #setLabelPaint(Paint) */ public Paint getLabelPaint() { return this.labelPaint; } /** * Sets the label paint and sends a {@link MarkerChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getLabelPaint() */ public void setLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.labelPaint = paint; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label anchor. This defines the position of the label * anchor, relative to the bounds of the marker. * * @return The label anchor (never null). * * @see #setLabelAnchor(RectangleAnchor) */ public RectangleAnchor getLabelAnchor() { return this.labelAnchor; } /** * Sets the label anchor and sends a {@link MarkerChangeEvent} to all * registered listeners. The anchor defines the position of the label * anchor, relative to the bounds of the marker. * * @param anchor the anchor (null not permitted). * * @see #getLabelAnchor() */ public void setLabelAnchor(RectangleAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.labelAnchor = anchor; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label offset. * * @return The label offset (never null). * * @see #setLabelOffset(RectangleInsets) */ public RectangleInsets getLabelOffset() { return this.labelOffset; } /** * Sets the label offset and sends a {@link MarkerChangeEvent} to all * registered listeners. * * @param offset the label offset (null not permitted). * * @see #getLabelOffset() */ public void setLabelOffset(RectangleInsets offset) { if (offset == null) { throw new IllegalArgumentException("Null 'offset' argument."); } this.labelOffset = offset; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label offset type. * * @return The type (never null). * * @see #setLabelOffsetType(LengthAdjustmentType) */ public LengthAdjustmentType getLabelOffsetType() { return this.labelOffsetType; } /** * Sets the label offset type and sends a {@link MarkerChangeEvent} to all * registered listeners. * * @param adj the type (null not permitted). * * @see #getLabelOffsetType() */ public void setLabelOffsetType(LengthAdjustmentType adj) { if (adj == null) { throw new IllegalArgumentException("Null 'adj' argument."); } this.labelOffsetType = adj; notifyListeners(new MarkerChangeEvent(this)); } /** * Returns the label text anchor. * * @return The label text anchor (never null). * * @see #setLabelTextAnchor(TextAnchor) */ public TextAnchor getLabelTextAnchor() { return this.labelTextAnchor; } /** * Sets the label text anchor and sends a {@link MarkerChangeEvent} to * all registered listeners. * * @param anchor the label text anchor (null not permitted). * * @see #getLabelTextAnchor() */ public void setLabelTextAnchor(TextAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.labelTextAnchor = anchor; notifyListeners(new MarkerChangeEvent(this)); } /** * Registers an object for notification of changes to the marker. * * @param listener the object to be registered. * * @see #removeChangeListener(MarkerChangeListener) * * @since 1.0.3 */ public void addChangeListener(MarkerChangeListener listener) { this.listenerList.add(MarkerChangeListener.class, listener); } /** * Unregisters an object for notification of changes to the marker. * * @param listener the object to be unregistered. * * @see #addChangeListener(MarkerChangeListener) * * @since 1.0.3 */ public void removeChangeListener(MarkerChangeListener listener) { this.listenerList.remove(MarkerChangeListener.class, listener); } /** * Notifies all registered listeners that the marker has been modified. * * @param event information about the change event. * * @since 1.0.3 */ public void notifyListeners(MarkerChangeEvent event) { Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == MarkerChangeListener.class) { ((MarkerChangeListener) listeners[i + 1]).markerChanged(event); } } } /** * Returns an array containing all the listeners of the specified type. * * @param listenerType the listener type. * * @return The array of listeners. * * @since 1.0.3 */ public EventListener[] getListeners(Class listenerType) { return this.listenerList.getListeners(listenerType); } /** * Tests the marker for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Marker)) { return false; } Marker that = (Marker) obj; if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { return false; } if (this.alpha != that.alpha) { return false; } if (!ObjectUtilities.equal(this.label, that.label)) { return false; } if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { return false; } if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { return false; } if (this.labelAnchor != that.labelAnchor) { return false; } if (this.labelTextAnchor != that.labelTextAnchor) { return false; } if (!ObjectUtilities.equal(this.labelOffset, that.labelOffset)) { return false; } if (!this.labelOffsetType.equals(that.labelOffsetType)) { return false; } return true; } /** * Creates a clone of the marker. * * @return A clone. * * @throws CloneNotSupportedException never. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writeStroke(this.stroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writePaint(this.labelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); this.labelPaint = SerialUtilities.readPaint(stream); this.listenerList = new EventListenerList(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/MeterInterval.java0000644000175000017500000001610711173030414027040 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * MeterInterval.java * ------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Mar-2005 : Version 1 (DG); * 29-Mar-2005 : Fixed serialization (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.awt.Stroke; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * An interval to be highlighted on a {@link MeterPlot}. Instances of this * class are immutable. */ public class MeterInterval implements Serializable { /** For serialization. */ private static final long serialVersionUID = 1530982090622488257L; /** The interval label. */ private String label; /** The interval range. */ private Range range; /** The outline paint (used for the arc marking the interval). */ private transient Paint outlinePaint; /** The outline stroke (used for the arc marking the interval). */ private transient Stroke outlineStroke; /** The background paint for the interval. */ private transient Paint backgroundPaint; /** * Creates a new interval. * * @param label the label (null not permitted). * @param range the range (null not permitted). */ public MeterInterval(String label, Range range) { this(label, range, Color.yellow, new BasicStroke(2.0f), null); } /** * Creates a new interval. * * @param label the label (null not permitted). * @param range the range (null not permitted). * @param outlinePaint the outline paint (null permitted). * @param outlineStroke the outline stroke (null permitted). * @param backgroundPaint the background paint (null * permitted). */ public MeterInterval(String label, Range range, Paint outlinePaint, Stroke outlineStroke, Paint backgroundPaint) { if (label == null) { throw new IllegalArgumentException("Null 'label' argument."); } if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } this.label = label; this.range = range; this.outlinePaint = outlinePaint; this.outlineStroke = outlineStroke; this.backgroundPaint = backgroundPaint; } /** * Returns the label. * * @return The label (never null). */ public String getLabel() { return this.label; } /** * Returns the range. * * @return The range (never null). */ public Range getRange() { return this.range; } /** * Returns the background paint. If null, the background * should remain unfilled. * * @return The background paint (possibly null). */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Returns the outline paint. * * @return The outline paint (possibly null). */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Returns the outline stroke. * * @return The outline stroke (possibly null). */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Checks this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MeterInterval)) { return false; } MeterInterval that = (MeterInterval) obj; if (!this.label.equals(that.label)) { return false; } if (!this.range.equals(that.range)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writePaint(this.backgroundPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.outlinePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); this.backgroundPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/MeterPlot.java0000644000175000017500000012740411173030414026175 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * MeterPlot.java * -------------- * (C) Copyright 2000-2008, by Hari and Contributors. * * Original Author: Hari (ourhari@hotmail.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * Bob Orchard; * Arnaud Lelievre; * Nicolas Brodu; * David Bastend; * * Changes * ------- * 01-Apr-2002 : Version 1, contributed by Hari (DG); * 23-Apr-2002 : Moved dataset from JFreeChart to Plot (DG); * 22-Aug-2002 : Added changes suggest by Bob Orchard, changed Color to Paint * for consistency, plus added Javadoc comments (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Jan-2003 : Removed one constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 20-Aug-2003 : Changed dataset from MeterDataset --> ValueDataset, added * equals() method, * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * implemented Cloneable, and various other changes (DG); * 08-Sep-2003 : Added serialization methods (NB); * 11-Sep-2003 : Added cloning support (NB); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Sep-2003 : Fix useless cloning. Correct dataset listener registration in * constructor. (NB) * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 17-Jan-2004 : Changed to allow dialBackgroundPaint to be set to null - see * bug 823628 (DG); * 07-Apr-2004 : Changed string bounds calculation (DG); * 12-May-2004 : Added tickLabelFormat attribute - see RFE 949566. Also * updated the equals() method (DG); * 02-Nov-2004 : Added sanity checks for range, and only draw the needle if the * value is contained within the overall range - see bug report * 1056047 (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 02-Feb-2005 : Added optional background paint for each region (DG); * 22-Mar-2005 : Removed 'normal', 'warning' and 'critical' regions and put in * facility to define an arbitrary number of MeterIntervals, * based on a contribution by David Bastend (DG); * 20-Apr-2005 : Small update for change to LegendItem constructors (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * 10-Nov-2005 : Added tickPaint, tickSize and valuePaint attributes, and * put value label drawing code into a separate method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Mar-2007 : Restore clip region correctly (see bug 1667750) (DG); * 18-May-2007 : Set dataset for LegendItem (DG); * 29-Nov-2007 : Fixed serialization bug with dialOutlinePaint (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.text.NumberFormat; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.ValueDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A plot that displays a single value in the form of a needle on a dial. * Defined ranges (for example, 'normal', 'warning' and 'critical') can be * highlighted on the dial. */ public class MeterPlot extends Plot implements Serializable, Cloneable { /** For serialization. */ private static final long serialVersionUID = 2987472457734470962L; /** The default background paint. */ static final Paint DEFAULT_DIAL_BACKGROUND_PAINT = Color.black; /** The default needle paint. */ static final Paint DEFAULT_NEEDLE_PAINT = Color.green; /** The default value font. */ static final Font DEFAULT_VALUE_FONT = new Font("SansSerif", Font.BOLD, 12); /** The default value paint. */ static final Paint DEFAULT_VALUE_PAINT = Color.yellow; /** The default meter angle. */ public static final int DEFAULT_METER_ANGLE = 270; /** The default border size. */ public static final float DEFAULT_BORDER_SIZE = 3f; /** The default circle size. */ public static final float DEFAULT_CIRCLE_SIZE = 10f; /** The default label font. */ public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", Font.BOLD, 10); /** The dataset (contains a single value). */ private ValueDataset dataset; /** The dial shape (background shape). */ private DialShape shape; /** The dial extent (measured in degrees). */ private int meterAngle; /** The overall range of data values on the dial. */ private Range range; /** The tick size. */ private double tickSize; /** The paint used to draw the ticks. */ private transient Paint tickPaint; /** The units displayed on the dial. */ private String units; /** The font for the value displayed in the center of the dial. */ private Font valueFont; /** The paint for the value displayed in the center of the dial. */ private transient Paint valuePaint; /** A flag that controls whether or not the border is drawn. */ private boolean drawBorder; /** The outline paint. */ private transient Paint dialOutlinePaint; /** The paint for the dial background. */ private transient Paint dialBackgroundPaint; /** The paint for the needle. */ private transient Paint needlePaint; /** A flag that controls whether or not the tick labels are visible. */ private boolean tickLabelsVisible; /** The tick label font. */ private Font tickLabelFont; /** The tick label paint. */ private transient Paint tickLabelPaint; /** The tick label format. */ private NumberFormat tickLabelFormat; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** * A (possibly empty) list of the {@link MeterInterval}s to be highlighted * on the dial. */ private List intervals; /** * Creates a new plot with a default range of 0 to * 100 and no value to display. */ public MeterPlot() { this(null); } /** * Creates a new plot that displays the value from the supplied dataset. * * @param dataset the dataset (null permitted). */ public MeterPlot(ValueDataset dataset) { super(); this.shape = DialShape.CIRCLE; this.meterAngle = DEFAULT_METER_ANGLE; this.range = new Range(0.0, 100.0); this.tickSize = 10.0; this.tickPaint = Color.white; this.units = "Units"; this.needlePaint = MeterPlot.DEFAULT_NEEDLE_PAINT; this.tickLabelsVisible = true; this.tickLabelFont = MeterPlot.DEFAULT_LABEL_FONT; this.tickLabelPaint = Color.black; this.tickLabelFormat = NumberFormat.getInstance(); this.valueFont = MeterPlot.DEFAULT_VALUE_FONT; this.valuePaint = MeterPlot.DEFAULT_VALUE_PAINT; this.dialBackgroundPaint = MeterPlot.DEFAULT_DIAL_BACKGROUND_PAINT; this.intervals = new java.util.ArrayList(); setDataset(dataset); } /** * Returns the dial shape. The default is {@link DialShape#CIRCLE}). * * @return The dial shape (never null). * * @see #setDialShape(DialShape) */ public DialShape getDialShape() { return this.shape; } /** * Sets the dial shape and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param shape the shape (null not permitted). * * @see #getDialShape() */ public void setDialShape(DialShape shape) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.shape = shape; fireChangeEvent(); } /** * Returns the meter angle in degrees. This defines, in part, the shape * of the dial. The default is 270 degrees. * * @return The meter angle (in degrees). * * @see #setMeterAngle(int) */ public int getMeterAngle() { return this.meterAngle; } /** * Sets the angle (in degrees) for the whole range of the dial and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param angle the angle (in degrees, in the range 1-360). * * @see #getMeterAngle() */ public void setMeterAngle(int angle) { if (angle < 1 || angle > 360) { throw new IllegalArgumentException("Invalid 'angle' (" + angle + ")"); } this.meterAngle = angle; fireChangeEvent(); } /** * Returns the overall range for the dial. * * @return The overall range (never null). * * @see #setRange(Range) */ public Range getRange() { return this.range; } /** * Sets the range for the dial and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param range the range (null not permitted and zero-length * ranges not permitted). * * @see #getRange() */ public void setRange(Range range) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } if (!(range.getLength() > 0.0)) { throw new IllegalArgumentException( "Range length must be positive."); } this.range = range; fireChangeEvent(); } /** * Returns the tick size (the interval between ticks on the dial). * * @return The tick size. * * @see #setTickSize(double) */ public double getTickSize() { return this.tickSize; } /** * Sets the tick size and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param size the tick size (must be > 0). * * @see #getTickSize() */ public void setTickSize(double size) { if (size <= 0) { throw new IllegalArgumentException("Requires 'size' > 0."); } this.tickSize = size; fireChangeEvent(); } /** * Returns the paint used to draw the ticks around the dial. * * @return The paint used to draw the ticks around the dial (never * null). * * @see #setTickPaint(Paint) */ public Paint getTickPaint() { return this.tickPaint; } /** * Sets the paint used to draw the tick labels around the dial and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getTickPaint() */ public void setTickPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.tickPaint = paint; fireChangeEvent(); } /** * Returns a string describing the units for the dial. * * @return The units (possibly null). * * @see #setUnits(String) */ public String getUnits() { return this.units; } /** * Sets the units for the dial and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param units the units (null permitted). * * @see #getUnits() */ public void setUnits(String units) { this.units = units; fireChangeEvent(); } /** * Returns the paint for the needle. * * @return The paint (never null). * * @see #setNeedlePaint(Paint) */ public Paint getNeedlePaint() { return this.needlePaint; } /** * Sets the paint used to display the needle and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getNeedlePaint() */ public void setNeedlePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.needlePaint = paint; fireChangeEvent(); } /** * Returns the flag that determines whether or not tick labels are visible. * * @return The flag. * * @see #setTickLabelsVisible(boolean) */ public boolean getTickLabelsVisible() { return this.tickLabelsVisible; } /** * Sets the flag that controls whether or not the tick labels are visible * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getTickLabelsVisible() */ public void setTickLabelsVisible(boolean visible) { if (this.tickLabelsVisible != visible) { this.tickLabelsVisible = visible; fireChangeEvent(); } } /** * Returns the tick label font. * * @return The font (never null). * * @see #setTickLabelFont(Font) */ public Font getTickLabelFont() { return this.tickLabelFont; } /** * Sets the tick label font and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param font the font (null not permitted). * * @see #getTickLabelFont() */ public void setTickLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (!this.tickLabelFont.equals(font)) { this.tickLabelFont = font; fireChangeEvent(); } } /** * Returns the tick label paint. * * @return The paint (never null). * * @see #setTickLabelPaint(Paint) */ public Paint getTickLabelPaint() { return this.tickLabelPaint; } /** * Sets the tick label paint and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getTickLabelPaint() */ public void setTickLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (!this.tickLabelPaint.equals(paint)) { this.tickLabelPaint = paint; fireChangeEvent(); } } /** * Returns the tick label format. * * @return The tick label format (never null). * * @see #setTickLabelFormat(NumberFormat) */ public NumberFormat getTickLabelFormat() { return this.tickLabelFormat; } /** * Sets the format for the tick labels and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param format the format (null not permitted). * * @see #getTickLabelFormat() */ public void setTickLabelFormat(NumberFormat format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.tickLabelFormat = format; fireChangeEvent(); } /** * Returns the font for the value label. * * @return The font (never null). * * @see #setValueFont(Font) */ public Font getValueFont() { return this.valueFont; } /** * Sets the font used to display the value label and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * * @see #getValueFont() */ public void setValueFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.valueFont = font; fireChangeEvent(); } /** * Returns the paint for the value label. * * @return The paint (never null). * * @see #setValuePaint(Paint) */ public Paint getValuePaint() { return this.valuePaint; } /** * Sets the paint used to display the value label and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getValuePaint() */ public void setValuePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.valuePaint = paint; fireChangeEvent(); } /** * Returns the paint for the dial background. * * @return The paint (possibly null). * * @see #setDialBackgroundPaint(Paint) */ public Paint getDialBackgroundPaint() { return this.dialBackgroundPaint; } /** * Sets the paint used to fill the dial background. Set this to * null for no background. * * @param paint the paint (null permitted). * * @see #getDialBackgroundPaint() */ public void setDialBackgroundPaint(Paint paint) { this.dialBackgroundPaint = paint; fireChangeEvent(); } /** * Returns a flag that controls whether or not a rectangular border is * drawn around the plot area. * * @return A flag. * * @see #setDrawBorder(boolean) */ public boolean getDrawBorder() { return this.drawBorder; } /** * Sets the flag that controls whether or not a rectangular border is drawn * around the plot area and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param draw the flag. * * @see #getDrawBorder() */ public void setDrawBorder(boolean draw) { // TODO: fix output when this flag is set to true this.drawBorder = draw; fireChangeEvent(); } /** * Returns the dial outline paint. * * @return The paint. * * @see #setDialOutlinePaint(Paint) */ public Paint getDialOutlinePaint() { return this.dialOutlinePaint; } /** * Sets the dial outline paint and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint. * * @see #getDialOutlinePaint() */ public void setDialOutlinePaint(Paint paint) { this.dialOutlinePaint = paint; fireChangeEvent(); } /** * Returns the dataset for the plot. * * @return The dataset (possibly null). * * @see #setDataset(ValueDataset) */ public ValueDataset getDataset() { return this.dataset; } /** * Sets the dataset for the plot, replacing the existing dataset if there * is one, and triggers a {@link PlotChangeEvent}. * * @param dataset the dataset (null permitted). * * @see #getDataset() */ public void setDataset(ValueDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... ValueDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns an unmodifiable list of the intervals for the plot. * * @return A list. * * @see #addInterval(MeterInterval) */ public List getIntervals() { return Collections.unmodifiableList(this.intervals); } /** * Adds an interval and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param interval the interval (null not permitted). * * @see #getIntervals() * @see #clearIntervals() */ public void addInterval(MeterInterval interval) { if (interval == null) { throw new IllegalArgumentException("Null 'interval' argument."); } this.intervals.add(interval); fireChangeEvent(); } /** * Clears the intervals for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @see #addInterval(MeterInterval) */ public void clearIntervals() { this.intervals.clear(); fireChangeEvent(); } /** * Returns an item for each interval. * * @return A collection of legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); Iterator iterator = this.intervals.iterator(); while (iterator.hasNext()) { MeterInterval mi = (MeterInterval) iterator.next(); Paint color = mi.getBackgroundPaint(); if (color == null) { color = mi.getOutlinePaint(); } LegendItem item = new LegendItem(mi.getLabel(), mi.getLabel(), null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0), color); item.setDataset(getDataset()); result.add(item); } return result; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { if (info != null) { info.setPlotArea(area); } // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); area.setRect(area.getX() + 4, area.getY() + 4, area.getWidth() - 8, area.getHeight() - 8); // draw the background if (this.drawBorder) { drawBackground(g2, area); } // adjust the plot area by the interior spacing value double gapHorizontal = (2 * DEFAULT_BORDER_SIZE); double gapVertical = (2 * DEFAULT_BORDER_SIZE); double meterX = area.getX() + gapHorizontal / 2; double meterY = area.getY() + gapVertical / 2; double meterW = area.getWidth() - gapHorizontal; double meterH = area.getHeight() - gapVertical + ((this.meterAngle <= 180) && (this.shape != DialShape.CIRCLE) ? area.getHeight() / 1.25 : 0); double min = Math.min(meterW, meterH) / 2; meterX = (meterX + meterX + meterW) / 2 - min; meterY = (meterY + meterY + meterH) / 2 - min; meterW = 2 * min; meterH = 2 * min; Rectangle2D meterArea = new Rectangle2D.Double(meterX, meterY, meterW, meterH); Rectangle2D.Double originalArea = new Rectangle2D.Double( meterArea.getX() - 4, meterArea.getY() - 4, meterArea.getWidth() + 8, meterArea.getHeight() + 8); double meterMiddleX = meterArea.getCenterX(); double meterMiddleY = meterArea.getCenterY(); // plot the data (unless the dataset is null)... ValueDataset data = getDataset(); if (data != null) { double dataMin = this.range.getLowerBound(); double dataMax = this.range.getUpperBound(); Shape savedClip = g2.getClip(); g2.clip(originalArea); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (this.dialBackgroundPaint != null) { fillArc(g2, originalArea, dataMin, dataMax, this.dialBackgroundPaint, true); } drawTicks(g2, meterArea, dataMin, dataMax); drawArcForInterval(g2, meterArea, new MeterInterval("", this.range, this.dialOutlinePaint, new BasicStroke(1.0f), null)); Iterator iterator = this.intervals.iterator(); while (iterator.hasNext()) { MeterInterval interval = (MeterInterval) iterator.next(); drawArcForInterval(g2, meterArea, interval); } Number n = data.getValue(); if (n != null) { double value = n.doubleValue(); drawValueLabel(g2, meterArea); if (this.range.contains(value)) { g2.setPaint(this.needlePaint); g2.setStroke(new BasicStroke(2.0f)); double radius = (meterArea.getWidth() / 2) + DEFAULT_BORDER_SIZE + 15; double valueAngle = valueToAngle(value); double valueP1 = meterMiddleX + (radius * Math.cos(Math.PI * (valueAngle / 180))); double valueP2 = meterMiddleY - (radius * Math.sin(Math.PI * (valueAngle / 180))); Polygon arrow = new Polygon(); if ((valueAngle > 135 && valueAngle < 225) || (valueAngle < 45 && valueAngle > -45)) { double valueP3 = (meterMiddleY - DEFAULT_CIRCLE_SIZE / 4); double valueP4 = (meterMiddleY + DEFAULT_CIRCLE_SIZE / 4); arrow.addPoint((int) meterMiddleX, (int) valueP3); arrow.addPoint((int) meterMiddleX, (int) valueP4); } else { arrow.addPoint((int) (meterMiddleX - DEFAULT_CIRCLE_SIZE / 4), (int) meterMiddleY); arrow.addPoint((int) (meterMiddleX + DEFAULT_CIRCLE_SIZE / 4), (int) meterMiddleY); } arrow.addPoint((int) valueP1, (int) valueP2); g2.fill(arrow); Ellipse2D circle = new Ellipse2D.Double(meterMiddleX - DEFAULT_CIRCLE_SIZE / 2, meterMiddleY - DEFAULT_CIRCLE_SIZE / 2, DEFAULT_CIRCLE_SIZE, DEFAULT_CIRCLE_SIZE); g2.fill(circle); } } g2.setClip(savedClip); g2.setComposite(originalComposite); } if (this.drawBorder) { drawOutline(g2, area); } } /** * Draws the arc to represent an interval. * * @param g2 the graphics device. * @param meterArea the drawing area. * @param interval the interval. */ protected void drawArcForInterval(Graphics2D g2, Rectangle2D meterArea, MeterInterval interval) { double minValue = interval.getRange().getLowerBound(); double maxValue = interval.getRange().getUpperBound(); Paint outlinePaint = interval.getOutlinePaint(); Stroke outlineStroke = interval.getOutlineStroke(); Paint backgroundPaint = interval.getBackgroundPaint(); if (backgroundPaint != null) { fillArc(g2, meterArea, minValue, maxValue, backgroundPaint, false); } if (outlinePaint != null) { if (outlineStroke != null) { drawArc(g2, meterArea, minValue, maxValue, outlinePaint, outlineStroke); } drawTick(g2, meterArea, minValue, true); drawTick(g2, meterArea, maxValue, true); } } /** * Draws an arc. * * @param g2 the graphics device. * @param area the plot area. * @param minValue the minimum value. * @param maxValue the maximum value. * @param paint the paint. * @param stroke the stroke. */ protected void drawArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, Stroke stroke) { double startAngle = valueToAngle(maxValue); double endAngle = valueToAngle(minValue); double extent = endAngle - startAngle; double x = area.getX(); double y = area.getY(); double w = area.getWidth(); double h = area.getHeight(); g2.setPaint(paint); g2.setStroke(stroke); if (paint != null && stroke != null) { Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent, Arc2D.OPEN); g2.setPaint(paint); g2.setStroke(stroke); g2.draw(arc); } } /** * Fills an arc on the dial between the given values. * * @param g2 the graphics device. * @param area the plot area. * @param minValue the minimum data value. * @param maxValue the maximum data value. * @param paint the background paint (null not permitted). * @param dial a flag that indicates whether the arc represents the whole * dial. */ protected void fillArc(Graphics2D g2, Rectangle2D area, double minValue, double maxValue, Paint paint, boolean dial) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument"); } double startAngle = valueToAngle(maxValue); double endAngle = valueToAngle(minValue); double extent = endAngle - startAngle; double x = area.getX(); double y = area.getY(); double w = area.getWidth(); double h = area.getHeight(); int joinType = Arc2D.OPEN; if (this.shape == DialShape.PIE) { joinType = Arc2D.PIE; } else if (this.shape == DialShape.CHORD) { if (dial && this.meterAngle > 180) { joinType = Arc2D.CHORD; } else { joinType = Arc2D.PIE; } } else if (this.shape == DialShape.CIRCLE) { joinType = Arc2D.PIE; if (dial) { extent = 360; } } else { throw new IllegalStateException("DialShape not recognised."); } g2.setPaint(paint); Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent, joinType); g2.fill(arc); } /** * Translates a data value to an angle on the dial. * * @param value the value. * * @return The angle on the dial. */ public double valueToAngle(double value) { value = value - this.range.getLowerBound(); double baseAngle = 180 + ((this.meterAngle - 180) / 2); return baseAngle - ((value / this.range.getLength()) * this.meterAngle); } /** * Draws the ticks that subdivide the overall range. * * @param g2 the graphics device. * @param meterArea the meter area. * @param minValue the minimum value. * @param maxValue the maximum value. */ protected void drawTicks(Graphics2D g2, Rectangle2D meterArea, double minValue, double maxValue) { for (double v = minValue; v <= maxValue; v += this.tickSize) { drawTick(g2, meterArea, v); } } /** * Draws a tick. * * @param g2 the graphics device. * @param meterArea the meter area. * @param value the value. */ protected void drawTick(Graphics2D g2, Rectangle2D meterArea, double value) { drawTick(g2, meterArea, value, false); } /** * Draws a tick on the dial. * * @param g2 the graphics device. * @param meterArea the meter area. * @param value the tick value. * @param label a flag that controls whether or not a value label is drawn. */ protected void drawTick(Graphics2D g2, Rectangle2D meterArea, double value, boolean label) { double valueAngle = valueToAngle(value); double meterMiddleX = meterArea.getCenterX(); double meterMiddleY = meterArea.getCenterY(); g2.setPaint(this.tickPaint); g2.setStroke(new BasicStroke(2.0f)); double valueP2X = 0; double valueP2Y = 0; double radius = (meterArea.getWidth() / 2) + DEFAULT_BORDER_SIZE; double radius1 = radius - 15; double valueP1X = meterMiddleX + (radius * Math.cos(Math.PI * (valueAngle / 180))); double valueP1Y = meterMiddleY - (radius * Math.sin(Math.PI * (valueAngle / 180))); valueP2X = meterMiddleX + (radius1 * Math.cos(Math.PI * (valueAngle / 180))); valueP2Y = meterMiddleY - (radius1 * Math.sin(Math.PI * (valueAngle / 180))); Line2D.Double line = new Line2D.Double(valueP1X, valueP1Y, valueP2X, valueP2Y); g2.draw(line); if (this.tickLabelsVisible && label) { String tickLabel = this.tickLabelFormat.format(value); g2.setFont(this.tickLabelFont); g2.setPaint(this.tickLabelPaint); FontMetrics fm = g2.getFontMetrics(); Rectangle2D tickLabelBounds = TextUtilities.getTextBounds(tickLabel, g2, fm); double x = valueP2X; double y = valueP2Y; if (valueAngle == 90 || valueAngle == 270) { x = x - tickLabelBounds.getWidth() / 2; } else if (valueAngle < 90 || valueAngle > 270) { x = x - tickLabelBounds.getWidth(); } if ((valueAngle > 135 && valueAngle < 225) || valueAngle > 315 || valueAngle < 45) { y = y - tickLabelBounds.getHeight() / 2; } else { y = y + tickLabelBounds.getHeight() / 2; } g2.drawString(tickLabel, (float) x, (float) y); } } /** * Draws the value label just below the center of the dial. * * @param g2 the graphics device. * @param area the plot area. */ protected void drawValueLabel(Graphics2D g2, Rectangle2D area) { g2.setFont(this.valueFont); g2.setPaint(this.valuePaint); String valueStr = "No value"; if (this.dataset != null) { Number n = this.dataset.getValue(); if (n != null) { valueStr = this.tickLabelFormat.format(n.doubleValue()) + " " + this.units; } } float x = (float) area.getCenterX(); float y = (float) area.getCenterY() + DEFAULT_CIRCLE_SIZE; TextUtilities.drawAlignedString(valueStr, g2, x, y, TextAnchor.TOP_CENTER); } /** * Returns a short string describing the type of plot. * * @return A string describing the type of plot. */ public String getPlotType() { return localizationResources.getString("Meter_Plot"); } /** * A zoom method that does nothing. Plots are required to support the * zoom operation. In the case of a meter plot, it doesn't make sense to * zoom in or out, so the method is empty. * * @param percent The zoom percentage. */ public void zoom(double percent) { // intentionally blank } /** * Tests the plot for equality with an arbitrary object. Note that the * dataset is ignored for the purposes of testing equality. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MeterPlot)) { return false; } if (!super.equals(obj)) { return false; } MeterPlot that = (MeterPlot) obj; if (!ObjectUtilities.equal(this.units, that.units)) { return false; } if (!ObjectUtilities.equal(this.range, that.range)) { return false; } if (!ObjectUtilities.equal(this.intervals, that.intervals)) { return false; } if (!PaintUtilities.equal(this.dialOutlinePaint, that.dialOutlinePaint)) { return false; } if (this.shape != that.shape) { return false; } if (!PaintUtilities.equal(this.dialBackgroundPaint, that.dialBackgroundPaint)) { return false; } if (!PaintUtilities.equal(this.needlePaint, that.needlePaint)) { return false; } if (!ObjectUtilities.equal(this.valueFont, that.valueFont)) { return false; } if (!PaintUtilities.equal(this.valuePaint, that.valuePaint)) { return false; } if (!PaintUtilities.equal(this.tickPaint, that.tickPaint)) { return false; } if (this.tickSize != that.tickSize) { return false; } if (this.tickLabelsVisible != that.tickLabelsVisible) { return false; } if (!ObjectUtilities.equal(this.tickLabelFont, that.tickLabelFont)) { return false; } if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { return false; } if (!ObjectUtilities.equal(this.tickLabelFormat, that.tickLabelFormat)) { return false; } if (this.drawBorder != that.drawBorder) { return false; } if (this.meterAngle != that.meterAngle) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.dialBackgroundPaint, stream); SerialUtilities.writePaint(this.dialOutlinePaint, stream); SerialUtilities.writePaint(this.needlePaint, stream); SerialUtilities.writePaint(this.valuePaint, stream); SerialUtilities.writePaint(this.tickPaint, stream); SerialUtilities.writePaint(this.tickLabelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.dialBackgroundPaint = SerialUtilities.readPaint(stream); this.dialOutlinePaint = SerialUtilities.readPaint(stream); this.needlePaint = SerialUtilities.readPaint(stream); this.valuePaint = SerialUtilities.readPaint(stream); this.tickPaint = SerialUtilities.readPaint(stream); this.tickLabelPaint = SerialUtilities.readPaint(stream); if (this.dataset != null) { this.dataset.addChangeListener(this); } } /** * Returns an independent copy (clone) of the plot. The dataset is NOT * cloned - both the original and the clone will have a reference to the * same dataset. * * @return A clone. * * @throws CloneNotSupportedException if some component of the plot cannot * be cloned. */ public Object clone() throws CloneNotSupportedException { MeterPlot clone = (MeterPlot) super.clone(); clone.tickLabelFormat = (NumberFormat) this.tickLabelFormat.clone(); // the following relies on the fact that the intervals are immutable clone.intervals = new java.util.ArrayList(this.intervals); if (clone.dataset != null) { clone.dataset.addChangeListener(clone); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/MultiplePiePlot.java0000644000175000017500000005572511173030414027360 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * MultiplePiePlot.java * -------------------- * (C) Copyright 2004-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Brian Cabana (patch 1943021); * * Changes * ------- * 29-Jan-2004 : Version 1 (DG); * 31-Mar-2004 : Added setPieIndex() call during drawing (DG); * 20-Apr-2005 : Small change for update to LegendItem constructors (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 16-Jun-2005 : Added get/setDataset() and equals() methods (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Apr-2006 : Fixed bug 1190647 - legend and section colors not consistent * when aggregation limit is specified (DG); * 27-Sep-2006 : Updated draw() method for deprecated code (DG); * 17-Jan-2007 : Updated prefetchSectionPaints() to check settings in * underlying PiePlot (DG); * 17-May-2007 : Added argument check to setPieChart() (DG); * 18-May-2007 : Set dataset for LegendItem (DG); * 18-Apr-2008 : In the constructor, register the plot as a dataset listener - * see patch 1943021 from Brian Cabana (DG); * 30-Dec-2008 : Added legendItemShape field, and fixed cloning bug (DG); * 09-Jan-2009 : See ignoreNullValues to true for sub-chart (DG); * */ package org.jfree.chart.plot; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.title.TextTitle; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.CategoryToPieDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.PieDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.ShapeUtilities; import org.jfree.util.TableOrder; /** * A plot that displays multiple pie plots using data from a * {@link CategoryDataset}. */ public class MultiplePiePlot extends Plot implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -355377800470807389L; /** The chart object that draws the individual pie charts. */ private JFreeChart pieChart; /** The dataset. */ private CategoryDataset dataset; /** The data extract order (by row or by column). */ private TableOrder dataExtractOrder; /** The pie section limit percentage. */ private double limit = 0.0; /** * The key for the aggregated items. * * @since 1.0.2 */ private Comparable aggregatedItemsKey; /** * The paint for the aggregated items. * * @since 1.0.2 */ private transient Paint aggregatedItemsPaint; /** * The colors to use for each section. * * @since 1.0.2 */ private transient Map sectionPaints; /** * The legend item shape (never null). * * @since 1.0.12 */ private transient Shape legendItemShape; /** * Creates a new plot with no data. */ public MultiplePiePlot() { this(null); } /** * Creates a new plot. * * @param dataset the dataset (null permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); setDataset(dataset); PiePlot piePlot = new PiePlot(null); piePlot.setIgnoreNullValues(true); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); } /** * Returns the dataset used by the plot. * * @return The dataset (possibly null). */ public CategoryDataset getDataset() { return this.dataset; } /** * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param dataset the dataset (null permitted). */ public void setDataset(CategoryDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... if (this.dataset != null) { this.dataset.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self to trigger plot change event datasetChanged(new DatasetChangeEvent(this, dataset)); } /** * Returns the pie chart that is used to draw the individual pie plots. * Note that there are some attributes on this chart instance that will * be ignored at rendering time (for example, legend item settings). * * @return The pie chart (never null). * * @see #setPieChart(JFreeChart) */ public JFreeChart getPieChart() { return this.pieChart; } /** * Sets the chart that is used to draw the individual pie plots. The * chart's plot must be an instance of {@link PiePlot}. * * @param pieChart the pie chart (null not permitted). * * @see #getPieChart() */ public void setPieChart(JFreeChart pieChart) { if (pieChart == null) { throw new IllegalArgumentException("Null 'pieChart' argument."); } if (!(pieChart.getPlot() instanceof PiePlot)) { throw new IllegalArgumentException("The 'pieChart' argument must " + "be a chart based on a PiePlot."); } this.pieChart = pieChart; fireChangeEvent(); } /** * Returns the data extract order (by row or by column). * * @return The data extract order (never null). */ public TableOrder getDataExtractOrder() { return this.dataExtractOrder; } /** * Sets the data extract order (by row or by column) and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param order the order (null not permitted). */ public void setDataExtractOrder(TableOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument"); } this.dataExtractOrder = order; fireChangeEvent(); } /** * Returns the limit (as a percentage) below which small pie sections are * aggregated. * * @return The limit percentage. */ public double getLimit() { return this.limit; } /** * Sets the limit below which pie sections are aggregated. * Set this to 0.0 if you don't want any aggregation to occur. * * @param limit the limit percent. */ public void setLimit(double limit) { this.limit = limit; fireChangeEvent(); } /** * Returns the key for aggregated items in the pie plots, if there are any. * The default value is "Other". * * @return The aggregated items key. * * @since 1.0.2 */ public Comparable getAggregatedItemsKey() { return this.aggregatedItemsKey; } /** * Sets the key for aggregated items in the pie plots. You must ensure * that this doesn't clash with any keys in the dataset. * * @param key the key (null not permitted). * * @since 1.0.2 */ public void setAggregatedItemsKey(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.aggregatedItemsKey = key; fireChangeEvent(); } /** * Returns the paint used to draw the pie section representing the * aggregated items. The default value is Color.lightGray. * * @return The paint. * * @since 1.0.2 */ public Paint getAggregatedItemsPaint() { return this.aggregatedItemsPaint; } /** * Sets the paint used to draw the pie section representing the aggregated * items and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @since 1.0.2 */ public void setAggregatedItemsPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.aggregatedItemsPaint = paint; fireChangeEvent(); } /** * Returns a short string describing the type of plot. * * @return The plot type. */ public String getPlotType() { return "Multiple Pie Plot"; // TODO: need to fetch this from localised resources } /** * Returns the shape used for legend items. * * @return The shape (never null). * * @see #setLegendItemShape(Shape) * * @since 1.0.12 */ public Shape getLegendItemShape() { return this.legendItemShape; } /** * Sets the shape used for legend items and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param shape the shape (null not permitted). * * @see #getLegendItemShape() * * @since 1.0.12 */ public void setLegendItemShape(Shape shape) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.legendItemShape = shape; fireChangeEvent(); } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust the drawing area for the plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); drawBackground(g2, area); drawOutline(g2, area); // check that there is some data to display... if (DatasetUtilities.isEmptyOrNull(this.dataset)) { drawNoDataMessage(g2, area); return; } int pieCount = 0; if (this.dataExtractOrder == TableOrder.BY_ROW) { pieCount = this.dataset.getRowCount(); } else { pieCount = this.dataset.getColumnCount(); } // the columns variable is always >= rows int displayCols = (int) Math.ceil(Math.sqrt(pieCount)); int displayRows = (int) Math.ceil((double) pieCount / (double) displayCols); // swap rows and columns to match plotArea shape if (displayCols > displayRows && area.getWidth() < area.getHeight()) { int temp = displayCols; displayCols = displayRows; displayRows = temp; } prefetchSectionPaints(); int x = (int) area.getX(); int y = (int) area.getY(); int width = ((int) area.getWidth()) / displayCols; int height = ((int) area.getHeight()) / displayRows; int row = 0; int column = 0; int diff = (displayRows * displayCols) - pieCount; int xoffset = 0; Rectangle rect = new Rectangle(); for (int pieIndex = 0; pieIndex < pieCount; pieIndex++) { rect.setBounds(x + xoffset + (width * column), y + (height * row), width, height); String title = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { title = this.dataset.getRowKey(pieIndex).toString(); } else { title = this.dataset.getColumnKey(pieIndex).toString(); } this.pieChart.setTitle(title); PieDataset piedataset = null; PieDataset dd = new CategoryToPieDataset(this.dataset, this.dataExtractOrder, pieIndex); if (this.limit > 0.0) { piedataset = DatasetUtilities.createConsolidatedPieDataset( dd, this.aggregatedItemsKey, this.limit); } else { piedataset = dd; } PiePlot piePlot = (PiePlot) this.pieChart.getPlot(); piePlot.setDataset(piedataset); piePlot.setPieIndex(pieIndex); // update the section colors to match the global colors... for (int i = 0; i < piedataset.getItemCount(); i++) { Comparable key = piedataset.getKey(i); Paint p; if (key.equals(this.aggregatedItemsKey)) { p = this.aggregatedItemsPaint; } else { p = (Paint) this.sectionPaints.get(key); } piePlot.setSectionPaint(key, p); } ChartRenderingInfo subinfo = null; if (info != null) { subinfo = new ChartRenderingInfo(); } this.pieChart.draw(g2, rect, subinfo); if (info != null) { info.getOwner().getEntityCollection().addAll( subinfo.getEntityCollection()); info.addSubplotInfo(subinfo.getPlotInfo()); } ++column; if (column == displayCols) { column = 0; ++row; if (row == displayRows - 1 && diff != 0) { xoffset = (diff * width) / 2; } } } } /** * For each key in the dataset, check the sectionPaints * cache to see if a paint is associated with that key and, if not, * fetch one from the drawing supplier. These colors are cached so that * the legend and all the subplots use consistent colors. */ private void prefetchSectionPaints() { // pre-fetch the colors for each key...this is because the subplots // may not display every key, but we need the coloring to be // consistent... PiePlot piePlot = (PiePlot) getPieChart().getPlot(); if (this.dataExtractOrder == TableOrder.BY_ROW) { // column keys provide potential keys for individual pies for (int c = 0; c < this.dataset.getColumnCount(); c++) { Comparable key = this.dataset.getColumnKey(c); Paint p = piePlot.getSectionPaint(key); if (p == null) { p = (Paint) this.sectionPaints.get(key); if (p == null) { p = getDrawingSupplier().getNextPaint(); } } this.sectionPaints.put(key, p); } } else { // row keys provide potential keys for individual pies for (int r = 0; r < this.dataset.getRowCount(); r++) { Comparable key = this.dataset.getRowKey(r); Paint p = piePlot.getSectionPaint(key); if (p == null) { p = (Paint) this.sectionPaints.get(key); if (p == null) { p = getDrawingSupplier().getNextPaint(); } } this.sectionPaints.put(key, p); } } } /** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset == null) { return result; } List keys = null; prefetchSectionPaints(); if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getColumnKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getRowKeys(); } if (keys != null) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); // TODO: use a generator here String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } return result; } /** * Tests this plot for equality with an arbitrary object. Note that the * plot's dataset is not considered in the equality test. * * @param obj the object (null permitted). * * @return true if this plot is equal to obj, and * false otherwise. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MultiplePiePlot)) { return false; } MultiplePiePlot that = (MultiplePiePlot) obj; if (this.dataExtractOrder != that.dataExtractOrder) { return false; } if (this.limit != that.limit) { return false; } if (!this.aggregatedItemsKey.equals(that.aggregatedItemsKey)) { return false; } if (!PaintUtilities.equal(this.aggregatedItemsPaint, that.aggregatedItemsPaint)) { return false; } if (!ObjectUtilities.equal(this.pieChart, that.pieChart)) { return false; } if (!ShapeUtilities.equal(this.legendItemShape, that.legendItemShape)) { return false; } if (!super.equals(obj)) { return false; } return true; } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if some component of the plot does * not support cloning. */ public Object clone() throws CloneNotSupportedException { MultiplePiePlot clone = (MultiplePiePlot) super.clone(); clone.pieChart = (JFreeChart) this.pieChart.clone(); clone.sectionPaints = new HashMap(this.sectionPaints); clone.legendItemShape = ShapeUtilities.clone(this.legendItemShape); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.aggregatedItemsPaint, stream); SerialUtilities.writeShape(this.legendItemShape, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.aggregatedItemsPaint = SerialUtilities.readPaint(stream); this.legendItemShape = SerialUtilities.readShape(stream); this.sectionPaints = new HashMap(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/Pannable.java0000644000175000017500000000612311173030414025774 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * Pannable.java * ------------- * * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: Ulrich Voigt - patch 2686040; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Mar-2009 : Version 1, with modifications from patch by UV (DG); * */ package org.jfree.chart.plot; import java.awt.geom.Point2D; import org.jfree.chart.ChartPanel; /** * An interface that the {@link ChartPanel} class uses to communicate with * plots that support panning. * * @since 1.0.13 */ public interface Pannable { /** * Returns the orientation of the plot. * * @return The orientation (never null). */ public PlotOrientation getOrientation(); /** * Evaluates if the domain axis can be panned. * * @return true if the domain axis is pannable. */ public boolean isDomainPannable(); /** * Evaluates if the range axis can be panned. * * @return true if the range axis is pannable. */ public boolean isRangePannable(); /** * Pans the domain axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. */ public void panDomainAxes(double percent, PlotRenderingInfo info, Point2D source); /** * Pans the range axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. */ public void panRangeAxes(double percent, PlotRenderingInfo info, Point2D source); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PieLabelDistributor.java0000644000175000017500000001713611173030414030172 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * PieLabelDistributor.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Mar-2004 : Version 1 (DG); * 18-Apr-2005 : Use StringBuffer (DG); * 14-Jun-2007 : Now extends AbstractPieLabelDistributor (DG); * 31-Mar-2008 : Fix bugs in label distribution (DG); * */ package org.jfree.chart.plot; import java.util.Collections; /** * This class distributes the section labels for one side of a pie chart so * that they do not overlap. */ public class PieLabelDistributor extends AbstractPieLabelDistributor { /** The minimum gap. */ private double minGap = 4.0; /** * Creates a new distributor. * * @param labelCount the number of labels (ignored). */ public PieLabelDistributor(int labelCount) { super(); } /** * Distributes the labels. * * @param minY the minimum y-coordinate in Java2D-space. * @param height the available height (in Java2D units). */ public void distributeLabels(double minY, double height) { sort(); // sorts the label records into ascending order by baseY // if (isOverlap()) { // adjustInwards(); // } // if still overlapping, do something else... if (isOverlap()) { adjustDownwards(minY, height); } if (isOverlap()) { adjustUpwards(minY, height); } if (isOverlap()) { spreadEvenly(minY, height); } } /** * Returns true if there are overlapping labels in the list, * and false otherwise. * * @return A boolean. */ private boolean isOverlap() { double y = 0.0; for (int i = 0; i < this.labels.size(); i++) { PieLabelRecord plr = getPieLabelRecord(i); if (y > plr.getLowerY()) { return true; } y = plr.getUpperY(); } return false; } /** * Adjusts the y-coordinate for the labels in towards the center in an * attempt to fix overlapping. */ protected void adjustInwards() { int lower = 0; int upper = this.labels.size() - 1; while (upper > lower) { if (lower < upper - 1) { PieLabelRecord r0 = getPieLabelRecord(lower); PieLabelRecord r1 = getPieLabelRecord(lower + 1); if (r1.getLowerY() < r0.getUpperY()) { double adjust = r0.getUpperY() - r1.getLowerY() + this.minGap; r1.setAllocatedY(r1.getAllocatedY() + adjust); } } PieLabelRecord r2 = getPieLabelRecord(upper - 1); PieLabelRecord r3 = getPieLabelRecord(upper); if (r2.getUpperY() > r3.getLowerY()) { double adjust = (r2.getUpperY() - r3.getLowerY()) + this.minGap; r3.setAllocatedY(r3.getAllocatedY() + adjust); } lower++; upper--; } } /** * Any labels that are overlapping are moved down in an attempt to * eliminate the overlaps. * * @param minY the minimum y value (in Java2D coordinate space). * @param height the height available for all labels. */ protected void adjustDownwards(double minY, double height) { for (int i = 0; i < this.labels.size() - 1; i++) { PieLabelRecord record0 = getPieLabelRecord(i); PieLabelRecord record1 = getPieLabelRecord(i + 1); if (record1.getLowerY() < record0.getUpperY()) { record1.setAllocatedY(Math.min(minY + height - record1.getLabelHeight() / 2.0, record0.getUpperY() + this.minGap + record1.getLabelHeight() / 2.0)); } } } /** * Any labels that are overlapping are moved up in an attempt to eliminate * the overlaps. * * @param minY the minimum y value (in Java2D coordinate space). * @param height the height available for all labels. */ protected void adjustUpwards(double minY, double height) { for (int i = this.labels.size() - 1; i > 0; i--) { PieLabelRecord record0 = getPieLabelRecord(i); PieLabelRecord record1 = getPieLabelRecord(i - 1); if (record1.getUpperY() > record0.getLowerY()) { record1.setAllocatedY(Math.max(minY + record1.getLabelHeight() / 2.0, record0.getLowerY() - this.minGap - record1.getLabelHeight() / 2.0)); } } } /** * Labels are spaced evenly in the available space in an attempt to * eliminate the overlaps. * * @param minY the minimum y value (in Java2D coordinate space). * @param height the height available for all labels. */ protected void spreadEvenly(double minY, double height) { double y = minY; double sumOfLabelHeights = 0.0; for (int i = 0; i < this.labels.size(); i++) { sumOfLabelHeights += getPieLabelRecord(i).getLabelHeight(); } double gap = height - sumOfLabelHeights; if (this.labels.size() > 1) { gap = gap / (this.labels.size() - 1); } for (int i = 0; i < this.labels.size(); i++) { PieLabelRecord record = getPieLabelRecord(i); y = y + record.getLabelHeight() / 2.0; record.setAllocatedY(y); y = y + record.getLabelHeight() / 2.0 + gap; } } /** * Sorts the label records into ascending order by y-value. */ public void sort() { Collections.sort(this.labels); } /** * Returns a string containing a description of the object for * debugging purposes. * * @return A string. */ public String toString() { StringBuffer result = new StringBuffer(); for (int i = 0; i < this.labels.size(); i++) { result.append(getPieLabelRecord(i).toString()).append("\n"); } return result.toString(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PieLabelLinkStyle.java0000644000175000017500000001010611173030414027564 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * PieLabelLinkStyle.java * ---------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 31-Mar-2008 : Version 1 (DG); * */ package org.jfree.chart.plot; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the style for the lines linking pie sections to their * corresponding labels. * * @since 1.0.10 */ public final class PieLabelLinkStyle implements Serializable { /** STANDARD. */ public static final PieLabelLinkStyle STANDARD = new PieLabelLinkStyle("PieLabelLinkStyle.STANDARD"); /** QUAD_CURVE. */ public static final PieLabelLinkStyle QUAD_CURVE = new PieLabelLinkStyle("PieLabelLinkStyle.QUAD_CURVE"); /** CUBIC_CURVE. */ public static final PieLabelLinkStyle CUBIC_CURVE = new PieLabelLinkStyle("PieLabelLinkStyle.CUBIC_CURVE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private PieLabelLinkStyle(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof PieLabelLinkStyle)) { return false; } PieLabelLinkStyle style = (PieLabelLinkStyle) obj; if (!this.name.equals(style.toString())) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { Object result = null; if (this.equals(PieLabelLinkStyle.STANDARD)) { result = PieLabelLinkStyle.STANDARD; } else if (this.equals(PieLabelLinkStyle.QUAD_CURVE)) { result = PieLabelLinkStyle.QUAD_CURVE; } else if (this.equals(PieLabelLinkStyle.CUBIC_CURVE)) { result = PieLabelLinkStyle.CUBIC_CURVE; } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PieLabelRecord.java0000644000175000017500000001701611173030414027073 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * PieLabelRecord.java * ------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Mar-2004 : Version 1 (DG); * 14-Jun-2007 : Implemented Serializable, updated API docs (DG); * 21-Nov-2007 : Implemented equals() to shut up FindBugs (DG); * */ package org.jfree.chart.plot; import java.io.Serializable; import org.jfree.text.TextBox; /** * A structure that retains information about the label for a section in a pie * chart. */ public class PieLabelRecord implements Comparable, Serializable { /** The section key. */ private Comparable key; /** The angle of the centre of the section (in radians). */ private double angle; /** The base y-coordinate. */ private double baseY; /** The allocated y-coordinate. */ private double allocatedY; /** The label. */ private TextBox label; /** The label height. */ private double labelHeight; /** The gap. */ private double gap; /** The link percent. */ private double linkPercent; /** * Creates a new record. * * @param key the section key. * @param angle the angle to the middle of the section (in radians). * @param baseY the base y-coordinate. * @param label the section label. * @param labelHeight the label height (in Java2D units). * @param gap the offset to the left. * @param linkPercent the link percent. */ public PieLabelRecord(Comparable key, double angle, double baseY, TextBox label, double labelHeight, double gap, double linkPercent) { this.key = key; this.angle = angle; this.baseY = baseY; this.allocatedY = baseY; this.label = label; this.labelHeight = labelHeight; this.gap = gap; this.linkPercent = linkPercent; } /** * Returns the base y-coordinate. This is where the label will appear if * there is no overlapping of labels. * * @return The base y-coordinate. */ public double getBaseY() { return this.baseY; } /** * Sets the base y-coordinate. * * @param base the base y-coordinate. */ public void setBaseY(double base) { this.baseY = base; } /** * Returns the lower bound of the label. * * @return The lower bound. */ public double getLowerY() { return this.allocatedY - this.labelHeight / 2.0; } /** * Returns the upper bound of the label. * * @return The upper bound. */ public double getUpperY() { return this.allocatedY + this.labelHeight / 2.0; } /** * Returns the angle of the middle of the section, in radians. * * @return The angle, in radians. */ public double getAngle() { return this.angle; } /** * Returns the key for the section that the label applies to. * * @return The key. */ public Comparable getKey() { return this.key; } /** * Returns the label. * * @return The label. */ public TextBox getLabel() { return this.label; } /** * Returns the label height (you could derive this from the label itself, * but we cache the value so it can be retrieved quickly). * * @return The label height (in Java2D units). */ public double getLabelHeight() { return this.labelHeight; } /** * Returns the allocated y-coordinate. * * @return The allocated y-coordinate. */ public double getAllocatedY() { return this.allocatedY; } /** * Sets the allocated y-coordinate. * * @param y the y-coordinate. */ public void setAllocatedY(double y) { this.allocatedY = y; } /** * Returns the gap. * * @return The gap. */ public double getGap() { return this.gap; } /** * Returns the link percent. * * @return The link percent. */ public double getLinkPercent() { return this.linkPercent; } /** * Compares this object to an arbitrary object. * * @param obj the object to compare against. * * @return An integer that specifies the relative order of the two objects. */ public int compareTo(Object obj) { int result = 0; if (obj instanceof PieLabelRecord) { PieLabelRecord plr = (PieLabelRecord) obj; if (this.baseY < plr.baseY) { result = -1; } else if (this.baseY > plr.baseY) { result = 1; } } return result; } /** * Tests this record for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieLabelRecord)) { return false; } PieLabelRecord that = (PieLabelRecord) obj; if (!this.key.equals(that.key)) { return false; } if (this.angle != that.angle) { return false; } if (this.gap != that.gap) { return false; } if (this.allocatedY != that.allocatedY) { return false; } if (this.baseY != that.baseY) { return false; } if (this.labelHeight != that.labelHeight) { return false; } if (this.linkPercent != that.linkPercent) { return false; } if (!this.label.equals(that.label)) { return false; } return true; } /** * Returns a string describing the object. This is used for debugging only. * * @return A string. */ public String toString() { return this.baseY + ", " + this.key.toString(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PiePlot.java0000644000175000017500000037157611173030414025651 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * PiePlot.java * ------------ * (C) Copyright 2000-2008, by Andrzej Porebski and Contributors. * * Original Author: Andrzej Porebski; * Contributor(s): David Gilbert (for Object Refinery Limited); * Martin Cordova (percentages in labels); * Richard Atkinson (URL support for image maps); * Christian W. Zuckschwerdt; * Arnaud Lelievre; * Martin Hilpert (patch 1891849); * Andreas Schroeder (very minor); * Christoph Beck (bug 2121818); * * Changes * ------- * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); * 18-Sep-2001 : Updated header (DG); * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG); * 19-Oct-2001 : Moved series paint and stroke methods from JFreeChart.java to * Plot.java (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 13-Nov-2001 : Modified plot subclasses so that null axes are possible for * pie plot (DG); * 17-Nov-2001 : Added PieDataset interface and amended this class accordingly, * and completed removal of BlankAxis class as it is no longer * required (DG); * 19-Nov-2001 : Changed 'drawCircle' property to 'circular' property (DG); * 21-Nov-2001 : Added options for exploding pie sections and filled out range * of properties (DG); * Added option for percentages in chart labels, based on code * by Martin Cordova (DG); * 30-Nov-2001 : Changed default font from "Arial" --> "SansSerif" (DG); * 12-Dec-2001 : Removed unnecessary 'throws' clause in constructor (DG); * 13-Dec-2001 : Added tooltips (DG); * 16-Jan-2002 : Renamed tooltips class (DG); * 22-Jan-2002 : Fixed bug correlating legend labels with pie data (DG); * 05-Feb-2002 : Added alpha-transparency to plot class, and updated * constructors accordingly (DG); * 06-Feb-2002 : Added optional background image and alpha-transparency to Plot * and subclasses. Clipped drawing within plot area (DG); * 26-Mar-2002 : Added an empty zoom method (DG); * 18-Apr-2002 : PieDataset is no longer sorted (oldman); * 23-Apr-2002 : Moved dataset from JFreeChart to Plot. Added * getLegendItemLabels() method (DG); * 19-Jun-2002 : Added attributes to control starting angle and direction * (default is now clockwise) (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 02-Jul-2002 : Fixed sign of percentage bug introduced in 0.9.2 (DG); * 16-Jul-2002 : Added check for null dataset in getLegendItemLabels() (DG); * 30-Jul-2002 : Moved summation code to DatasetUtilities (DG); * 05-Aug-2002 : Added URL support for image maps - new member variable for * urlGenerator, modified constructor and minor change to the * draw method (RA); * 18-Sep-2002 : Modified the percent label creation and added setters for the * formatters (AS); * 24-Sep-2002 : Added getLegendItems() method (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 09-Oct-2002 : Added check for null entity collection (DG); * 30-Oct-2002 : Changed PieDataset interface (DG); * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG); * 02-Jan-2003 : Fixed "no data" message (DG); * 23-Jan-2003 : Modified to extract data from rows OR columns in * CategoryDataset (DG); * 14-Feb-2003 : Fixed label drawing so that foreground alpha does not apply * (bug id 685536) (DG); * 07-Mar-2003 : Modified to pass pieIndex on to PieSectionEntity and tooltip * and URL generators (DG); * 21-Mar-2003 : Added a minimum angle for drawing arcs * (see bug id 620031) (DG); * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); * 02-Jun-2003 : Fixed bug 721733 (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 19-Aug-2003 : Implemented Cloneable (DG); * 29-Aug-2003 : Fixed bug 796936 (null pointer on setOutlinePaint()) (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 05-Nov-2003 : Fixed missing legend bug (DG); * 10-Nov-2003 : Re-added the DatasetChangeListener to constructors (CZ); * 29-Jan-2004 : Fixed clipping bug in draw() method (DG); * 11-Mar-2004 : Major overhaul to improve labelling (DG); * 31-Mar-2004 : Made an adjustment for the plot area when the label generator * is null. Fixed null pointer exception when the label * generator returns null for a label (DG); * 06-Apr-2004 : Added getter, setter, serialization and draw support for * labelBackgroundPaint (AS); * 08-Apr-2004 : Added flag to control whether null values are ignored or * not (DG); * 15-Apr-2004 : Fixed some minor warnings from Eclipse (DG); * 26-Apr-2004 : Added attributes for label outline and shadow (DG); * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); * 04-Nov-2004 : Fixed null pointer exception with new LegendTitle class (DG); * 09-Nov-2004 : Added user definable legend item shape (DG); * 25-Nov-2004 : Added new legend label generator (DG); * 20-Apr-2005 : Added a tool tip generator for legend labels (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 10-May-2005 : Added flag to control visibility of label linking lines, plus * another flag to control the handling of zero values (DG); * 08-Jun-2005 : Fixed bug in getLegendItems() method (not respecting flags * for ignoring null and zero values), and fixed equals() method * to handle GradientPaint (DG); * 15-Jul-2005 : Added sectionOutlinesVisible attribute (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 09-Jan-2006 : Fixed bug 1400442, inconsistent treatment of null and zero * values in dataset (DG); * 28-Feb-2006 : Fixed bug 1440415, bad distribution of pie section * labels (DG); * 27-Sep-2006 : Initialised baseSectionPaint correctly, added lookup methods * for section paint, outline paint and outline stroke (DG); * 27-Sep-2006 : Refactored paint and stroke methods to use keys rather than * section indices (DG); * 03-Oct-2006 : Replaced call to JRE 1.5 method (DG); * 23-Nov-2006 : Added support for URLs for the legend items (DG); * 24-Nov-2006 : Cloning fixes (DG); * 17-Apr-2007 : Check for null label in legend items (DG); * 19-Apr-2007 : Deprecated override settings (DG); * 18-May-2007 : Set dataset for LegendItem (DG); * 14-Jun-2007 : Added label distributor attribute (DG); * 18-Jul-2007 : Added simple label option (DG); * 21-Nov-2007 : Fixed labelling bugs, added debug code, restored default * white background (DG); * 19-Mar-2008 : Fixed IllegalArgumentException when drawing with null * dataset (DG); * 31-Mar-2008 : Adjust the label area for the interiorGap (DG); * 31-Mar-2008 : Added quad and cubic curve label link lines - see patch * 1891849 by Martin Hilpert (DG); * 02-Jul-2008 : Added autoPopulate flags (DG); * 15-Aug-2008 : Added methods to clear section attributes (DG); * 15-Aug-2008 : Fixed bug 2051168 - problem with LegendItemEntity * generation (DG); * 23-Sep-2008 : Added getLabelLinkDepth() method - see bug 2121818 reported * by Christoph Beck (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.CubicCurve2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.QuadCurve2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; import java.util.TreeMap; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.PaintMap; import org.jfree.chart.StrokeMap; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.PieSectionEntity; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.PieSectionLabelGenerator; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.urls.PieURLGenerator; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.DefaultKeyedValues; import org.jfree.data.KeyedValues; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.PieDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.G2TextMeasurer; import org.jfree.text.TextBlock; import org.jfree.text.TextBox; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.Rotation; import org.jfree.util.ShapeUtilities; import org.jfree.util.UnitType; /** * A plot that displays data in the form of a pie chart, using data from any * class that implements the {@link PieDataset} interface. * The example shown here is generated by the PieChartDemo2.java * program included in the JFreeChart Demo Collection: *

* PiePlotSample.png *

* Special notes: *

    *
  1. the default starting point is 12 o'clock and the pie sections proceed * in a clockwise direction, but these settings can be changed;
  2. *
  3. negative values in the dataset are ignored;
  4. *
  5. there are utility methods for creating a {@link PieDataset} from a * {@link org.jfree.data.category.CategoryDataset};
  6. *
* * @see Plot * @see PieDataset */ public class PiePlot extends Plot implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -795612466005590431L; /** The default interior gap. */ public static final double DEFAULT_INTERIOR_GAP = 0.08; /** The maximum interior gap (currently 40%). */ public static final double MAX_INTERIOR_GAP = 0.40; /** The default starting angle for the pie chart. */ public static final double DEFAULT_START_ANGLE = 90.0; /** The default section label font. */ public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default section label paint. */ public static final Paint DEFAULT_LABEL_PAINT = Color.black; /** The default section label background paint. */ public static final Paint DEFAULT_LABEL_BACKGROUND_PAINT = new Color(255, 255, 192); /** The default section label outline paint. */ public static final Paint DEFAULT_LABEL_OUTLINE_PAINT = Color.black; /** The default section label outline stroke. */ public static final Stroke DEFAULT_LABEL_OUTLINE_STROKE = new BasicStroke( 0.5f); /** The default section label shadow paint. */ public static final Paint DEFAULT_LABEL_SHADOW_PAINT = new Color(151, 151, 151, 128); /** The default minimum arc angle to draw. */ public static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW = 0.00001; /** The dataset for the pie chart. */ private PieDataset dataset; /** The pie index (used by the {@link MultiplePiePlot} class). */ private int pieIndex; /** * The amount of space left around the outside of the pie plot, expressed * as a percentage of the plot area width and height. */ private double interiorGap; /** Flag determining whether to draw an ellipse or a perfect circle. */ private boolean circular; /** The starting angle. */ private double startAngle; /** The direction for the pie segments. */ private Rotation direction; /** The section paint map. */ private PaintMap sectionPaintMap; /** The base section paint (fallback). */ private transient Paint baseSectionPaint; /** * A flag that controls whether or not the section paint is auto-populated * from the drawing supplier. * * @since 1.0.11 */ private boolean autoPopulateSectionPaint; /** * A flag that controls whether or not an outline is drawn for each * section in the plot. */ private boolean sectionOutlinesVisible; /** The section outline paint map. */ private PaintMap sectionOutlinePaintMap; /** The base section outline paint (fallback). */ private transient Paint baseSectionOutlinePaint; /** * A flag that controls whether or not the section outline paint is * auto-populated from the drawing supplier. * * @since 1.0.11 */ private boolean autoPopulateSectionOutlinePaint; /** The section outline stroke map. */ private StrokeMap sectionOutlineStrokeMap; /** The base section outline stroke (fallback). */ private transient Stroke baseSectionOutlineStroke; /** * A flag that controls whether or not the section outline stroke is * auto-populated from the drawing supplier. * * @since 1.0.11 */ private boolean autoPopulateSectionOutlineStroke; /** The shadow paint. */ private transient Paint shadowPaint = Color.gray; /** The x-offset for the shadow effect. */ private double shadowXOffset = 4.0f; /** The y-offset for the shadow effect. */ private double shadowYOffset = 4.0f; /** The percentage amount to explode each pie section. */ private Map explodePercentages; /** The section label generator. */ private PieSectionLabelGenerator labelGenerator; /** The font used to display the section labels. */ private Font labelFont; /** The color used to draw the section labels. */ private transient Paint labelPaint; /** * The color used to draw the background of the section labels. If this * is null, the background is not filled. */ private transient Paint labelBackgroundPaint; /** * The paint used to draw the outline of the section labels * (null permitted). */ private transient Paint labelOutlinePaint; /** * The stroke used to draw the outline of the section labels * (null permitted). */ private transient Stroke labelOutlineStroke; /** * The paint used to draw the shadow for the section labels * (null permitted). */ private transient Paint labelShadowPaint; /** * A flag that controls whether simple or extended labels are used. * * @since 1.0.7 */ private boolean simpleLabels = true; /** * The padding between the labels and the label outlines. This is not * allowed to be null. * * @since 1.0.7 */ private RectangleInsets labelPadding; /** * The simple label offset. * * @since 1.0.7 */ private RectangleInsets simpleLabelOffset; /** The maximum label width as a percentage of the plot width. */ private double maximumLabelWidth = 0.14; /** * The gap between the labels and the link corner, as a percentage of the * plot width. */ private double labelGap = 0.025; /** A flag that controls whether or not the label links are drawn. */ private boolean labelLinksVisible; /** * The label link style. * * @since 1.0.10 */ private PieLabelLinkStyle labelLinkStyle = PieLabelLinkStyle.STANDARD; /** The link margin. */ private double labelLinkMargin = 0.025; /** The paint used for the label linking lines. */ private transient Paint labelLinkPaint = Color.black; /** The stroke used for the label linking lines. */ private transient Stroke labelLinkStroke = new BasicStroke(0.5f); /** * The pie section label distributor. * * @since 1.0.6 */ private AbstractPieLabelDistributor labelDistributor; /** The tooltip generator. */ private PieToolTipGenerator toolTipGenerator; /** The URL generator. */ private PieURLGenerator urlGenerator; /** The legend label generator. */ private PieSectionLabelGenerator legendLabelGenerator; /** A tool tip generator for the legend. */ private PieSectionLabelGenerator legendLabelToolTipGenerator; /** * A URL generator for the legend items (optional). * * @since 1.0.4. */ private PieURLGenerator legendLabelURLGenerator; /** * A flag that controls whether null values are ignored. */ private boolean ignoreNullValues; /** * A flag that controls whether zero values are ignored. */ private boolean ignoreZeroValues; /** The legend item shape. */ private transient Shape legendItemShape; /** * The smallest arc angle that will get drawn (this is to avoid a bug in * various Java implementations that causes the JVM to crash). See this * link for details: * * http://www.jfree.org/phpBB2/viewtopic.php?t=2707 * * ...and this bug report in the Java Bug Parade: * * http://developer.java.sun.com/developer/bugParade/bugs/4836495.html */ private double minimumArcAngleToDraw; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** * This debug flag controls whether or not an outline is drawn showing the * interior of the plot region. This is drawn as a lightGray rectangle * showing the padding provided by the 'interiorGap' setting. */ static final boolean DEBUG_DRAW_INTERIOR = false; /** * This debug flag controls whether or not an outline is drawn showing the * link area (in blue) and link ellipse (in yellow). This controls where * the label links have 'elbow' points. */ static final boolean DEBUG_DRAW_LINK_AREA = false; /** * This debug flag controls whether or not an outline is drawn showing * the pie area (in green). */ static final boolean DEBUG_DRAW_PIE_AREA = false; /** * Creates a new plot. The dataset is initially set to null. */ public PiePlot() { this(null); } /** * Creates a plot that will draw a pie chart for the specified dataset. * * @param dataset the dataset (null permitted). */ public PiePlot(PieDataset dataset) { super(); this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this); } this.pieIndex = 0; this.interiorGap = DEFAULT_INTERIOR_GAP; this.circular = true; this.startAngle = DEFAULT_START_ANGLE; this.direction = Rotation.CLOCKWISE; this.minimumArcAngleToDraw = DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW; this.sectionPaint = null; this.sectionPaintMap = new PaintMap(); this.baseSectionPaint = Color.gray; this.autoPopulateSectionPaint = true; this.sectionOutlinesVisible = true; this.sectionOutlinePaint = null; this.sectionOutlinePaintMap = new PaintMap(); this.baseSectionOutlinePaint = DEFAULT_OUTLINE_PAINT; this.autoPopulateSectionOutlinePaint = false; this.sectionOutlineStroke = null; this.sectionOutlineStrokeMap = new StrokeMap(); this.baseSectionOutlineStroke = DEFAULT_OUTLINE_STROKE; this.autoPopulateSectionOutlineStroke = false; this.explodePercentages = new TreeMap(); this.labelGenerator = new StandardPieSectionLabelGenerator(); this.labelFont = DEFAULT_LABEL_FONT; this.labelPaint = DEFAULT_LABEL_PAINT; this.labelBackgroundPaint = DEFAULT_LABEL_BACKGROUND_PAINT; this.labelOutlinePaint = DEFAULT_LABEL_OUTLINE_PAINT; this.labelOutlineStroke = DEFAULT_LABEL_OUTLINE_STROKE; this.labelShadowPaint = DEFAULT_LABEL_SHADOW_PAINT; this.labelLinksVisible = true; this.labelDistributor = new PieLabelDistributor(0); this.simpleLabels = false; this.simpleLabelOffset = new RectangleInsets(UnitType.RELATIVE, 0.18, 0.18, 0.18, 0.18); this.labelPadding = new RectangleInsets(2, 2, 2, 2); this.toolTipGenerator = null; this.urlGenerator = null; this.legendLabelGenerator = new StandardPieSectionLabelGenerator(); this.legendLabelToolTipGenerator = null; this.legendLabelURLGenerator = null; this.legendItemShape = Plot.DEFAULT_LEGEND_ITEM_CIRCLE; this.ignoreNullValues = false; this.ignoreZeroValues = false; } /** * Returns the dataset. * * @return The dataset (possibly null). * * @see #setDataset(PieDataset) */ public PieDataset getDataset() { return this.dataset; } /** * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'. * * @param dataset the dataset (null permitted). * * @see #getDataset() */ public void setDataset(PieDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... PieDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the pie index (this is used by the {@link MultiplePiePlot} class * to track subplots). * * @return The pie index. * * @see #setPieIndex(int) */ public int getPieIndex() { return this.pieIndex; } /** * Sets the pie index (this is used by the {@link MultiplePiePlot} class to * track subplots). * * @param index the index. * * @see #getPieIndex() */ public void setPieIndex(int index) { this.pieIndex = index; } /** * Returns the start angle for the first pie section. This is measured in * degrees starting from 3 o'clock and measuring anti-clockwise. * * @return The start angle. * * @see #setStartAngle(double) */ public double getStartAngle() { return this.startAngle; } /** * Sets the starting angle and sends a {@link PlotChangeEvent} to all * registered listeners. The initial default value is 90 degrees, which * corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock... * this is the encoding used by Java's Arc2D class. * * @param angle the angle (in degrees). * * @see #getStartAngle() */ public void setStartAngle(double angle) { this.startAngle = angle; fireChangeEvent(); } /** * Returns the direction in which the pie sections are drawn (clockwise or * anti-clockwise). * * @return The direction (never null). * * @see #setDirection(Rotation) */ public Rotation getDirection() { return this.direction; } /** * Sets the direction in which the pie sections are drawn and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param direction the direction (null not permitted). * * @see #getDirection() */ public void setDirection(Rotation direction) { if (direction == null) { throw new IllegalArgumentException("Null 'direction' argument."); } this.direction = direction; fireChangeEvent(); } /** * Returns the interior gap, measured as a percentage of the available * drawing space. * * @return The gap (as a percentage of the available drawing space). * * @see #setInteriorGap(double) */ public double getInteriorGap() { return this.interiorGap; } /** * Sets the interior gap and sends a {@link PlotChangeEvent} to all * registered listeners. This controls the space between the edges of the * pie plot and the plot area itself (the region where the section labels * appear). * * @param percent the gap (as a percentage of the available drawing space). * * @see #getInteriorGap() */ public void setInteriorGap(double percent) { if ((percent < 0.0) || (percent > MAX_INTERIOR_GAP)) { throw new IllegalArgumentException( "Invalid 'percent' (" + percent + ") argument."); } if (this.interiorGap != percent) { this.interiorGap = percent; fireChangeEvent(); } } /** * Returns a flag indicating whether the pie chart is circular, or * stretched into an elliptical shape. * * @return A flag indicating whether the pie chart is circular. * * @see #setCircular(boolean) */ public boolean isCircular() { return this.circular; } /** * A flag indicating whether the pie chart is circular, or stretched into * an elliptical shape. * * @param flag the new value. * * @see #isCircular() */ public void setCircular(boolean flag) { setCircular(flag, true); } /** * Sets the circular attribute and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param circular the new value of the flag. * @param notify notify listeners? * * @see #isCircular() */ public void setCircular(boolean circular, boolean notify) { this.circular = circular; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether null values in the * dataset are ignored. * * @return A boolean. * * @see #setIgnoreNullValues(boolean) */ public boolean getIgnoreNullValues() { return this.ignoreNullValues; } /** * Sets a flag that controls whether null values are ignored, * and sends a {@link PlotChangeEvent} to all registered listeners. At * present, this only affects whether or not the key is presented in the * legend. * * @param flag the flag. * * @see #getIgnoreNullValues() * @see #setIgnoreZeroValues(boolean) */ public void setIgnoreNullValues(boolean flag) { this.ignoreNullValues = flag; fireChangeEvent(); } /** * Returns the flag that controls whether zero values in the * dataset are ignored. * * @return A boolean. * * @see #setIgnoreZeroValues(boolean) */ public boolean getIgnoreZeroValues() { return this.ignoreZeroValues; } /** * Sets a flag that controls whether zero values are ignored, * and sends a {@link PlotChangeEvent} to all registered listeners. This * only affects whether or not a label appears for the non-visible * pie section. * * @param flag the flag. * * @see #getIgnoreZeroValues() * @see #setIgnoreNullValues(boolean) */ public void setIgnoreZeroValues(boolean flag) { this.ignoreZeroValues = flag; fireChangeEvent(); } //// SECTION PAINT //////////////////////////////////////////////////////// /** * Returns the paint for the specified section. This is equivalent to * lookupSectionPaint(section, getAutoPopulateSectionPaint()). * * @param key the section key. * * @return The paint for the specified section. * * @since 1.0.3 * * @see #lookupSectionPaint(Comparable, boolean) */ protected Paint lookupSectionPaint(Comparable key) { return lookupSectionPaint(key, getAutoPopulateSectionPaint()); } /** * Returns the paint for the specified section. The lookup involves these * steps: *
    *
  • if {@link #getSectionPaint()} is non-null, return * it;
  • *
  • if {@link #getSectionPaint(int)} is non-null return * it;
  • *
  • if {@link #getSectionPaint(int)} is null but * autoPopulate is true, attempt to fetch * a new paint from the drawing supplier * ({@link #getDrawingSupplier()}); *
  • if all else fails, return {@link #getBaseSectionPaint()}. *
* * @param key the section key. * @param autoPopulate a flag that controls whether the drawing supplier * is used to auto-populate the section paint settings. * * @return The paint. * * @since 1.0.3 */ protected Paint lookupSectionPaint(Comparable key, boolean autoPopulate) { // is there an override? Paint result = getSectionPaint(); if (result != null) { return result; } // if not, check if there is a paint defined for the specified key result = this.sectionPaintMap.getPaint(key); if (result != null) { return result; } // nothing defined - do we autoPopulate? if (autoPopulate) { DrawingSupplier ds = getDrawingSupplier(); if (ds != null) { result = ds.getNextPaint(); this.sectionPaintMap.put(key, result); } else { result = this.baseSectionPaint; } } else { result = this.baseSectionPaint; } return result; } /** * Returns the paint for ALL sections in the plot. * * @return The paint (possibly null). * * @see #setSectionPaint(Paint) * * @deprecated Use {@link #getSectionPaint(Comparable)} and * {@link #getBaseSectionPaint()}. Deprecated as of version 1.0.6. */ public Paint getSectionPaint() { return this.sectionPaint; } /** * Sets the paint for ALL sections in the plot. If this is set to *
null
, then a list of paints is used instead (to allow * different colors to be used for each section). * * @param paint the paint (null permitted). * * @see #getSectionPaint() * * @deprecated Use {@link #setSectionPaint(Comparable, Paint)} and * {@link #setBaseSectionPaint(Paint)}. Deprecated as of version 1.0.6. */ public void setSectionPaint(Paint paint) { this.sectionPaint = paint; fireChangeEvent(); } /** * Returns a key for the specified section. If there is no such section * in the dataset, we generate a key. This is to provide some backward * compatibility for the (now deprecated) methods that get/set attributes * based on section indices. The preferred way of doing this now is to * link the attributes directly to the section key (there are new methods * for this, starting from version 1.0.3). * * @param section the section index. * * @return The key. * * @since 1.0.3 */ protected Comparable getSectionKey(int section) { Comparable key = null; if (this.dataset != null) { if (section >= 0 && section < this.dataset.getItemCount()) { key = this.dataset.getKey(section); } } if (key == null) { key = new Integer(section); } return key; } /** * Returns the paint associated with the specified key, or * null if there is no paint associated with the key. * * @param key the key (null not permitted). * * @return The paint associated with the specified key, or * null. * * @throws IllegalArgumentException if key is * null. * * @see #setSectionPaint(Comparable, Paint) * * @since 1.0.3 */ public Paint getSectionPaint(Comparable key) { // null argument check delegated... return this.sectionPaintMap.getPaint(key); } /** * Sets the paint associated with the specified key, and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param key the key (null not permitted). * @param paint the paint. * * @throws IllegalArgumentException if key is * null. * * @see #getSectionPaint(Comparable) * * @since 1.0.3 */ public void setSectionPaint(Comparable key, Paint paint) { // null argument check delegated... this.sectionPaintMap.put(key, paint); fireChangeEvent(); } /** * Clears the section paint settings for this plot and, if requested, sends * a {@link PlotChangeEvent} to all registered listeners. Be aware that * if the autoPopulateSectionPaint flag is set, the section * paints may be repopulated using the same colours as before. * * @param notify notify listeners? * * @since 1.0.11 * * @see #autoPopulateSectionPaint */ public void clearSectionPaints(boolean notify) { this.sectionPaintMap.clear(); if (notify) { fireChangeEvent(); } } /** * Returns the base section paint. This is used when no other paint is * defined, which is rare. The default value is Color.gray. * * @return The paint (never null). * * @see #setBaseSectionPaint(Paint) */ public Paint getBaseSectionPaint() { return this.baseSectionPaint; } /** * Sets the base section paint and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseSectionPaint() */ public void setBaseSectionPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseSectionPaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether or not the section paint is * auto-populated by the {@link #lookupSectionPaint(Comparable)} method. * * @return A boolean. * * @since 1.0.11 */ public boolean getAutoPopulateSectionPaint() { return this.autoPopulateSectionPaint; } /** * Sets the flag that controls whether or not the section paint is * auto-populated by the {@link #lookupSectionPaint(Comparable)} method, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param auto auto-populate? * * @since 1.0.11 */ public void setAutoPopulateSectionPaint(boolean auto) { this.autoPopulateSectionPaint = auto; fireChangeEvent(); } //// SECTION OUTLINE PAINT //////////////////////////////////////////////// /** * Returns the flag that controls whether or not the outline is drawn for * each pie section. * * @return The flag that controls whether or not the outline is drawn for * each pie section. * * @see #setSectionOutlinesVisible(boolean) */ public boolean getSectionOutlinesVisible() { return this.sectionOutlinesVisible; } /** * Sets the flag that controls whether or not the outline is drawn for * each pie section, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param visible the flag. * * @see #getSectionOutlinesVisible() */ public void setSectionOutlinesVisible(boolean visible) { this.sectionOutlinesVisible = visible; fireChangeEvent(); } /** * Returns the outline paint for the specified section. This is equivalent * to lookupSectionPaint(section, * getAutoPopulateSectionOutlinePaint()). * * @param key the section key. * * @return The paint for the specified section. * * @since 1.0.3 * * @see #lookupSectionOutlinePaint(Comparable, boolean) */ protected Paint lookupSectionOutlinePaint(Comparable key) { return lookupSectionOutlinePaint(key, getAutoPopulateSectionOutlinePaint()); } /** * Returns the outline paint for the specified section. The lookup * involves these steps: *
    *
  • if {@link #getSectionOutlinePaint()} is non-null, * return it;
  • *
  • otherwise, if {@link #getSectionOutlinePaint(int)} is * non-null return it;
  • *
  • if {@link #getSectionOutlinePaint(int)} is null but * autoPopulate is true, attempt to fetch * a new outline paint from the drawing supplier * ({@link #getDrawingSupplier()}); *
  • if all else fails, return {@link #getBaseSectionOutlinePaint()}. *
* * @param key the section key. * @param autoPopulate a flag that controls whether the drawing supplier * is used to auto-populate the section outline paint settings. * * @return The paint. * * @since 1.0.3 */ protected Paint lookupSectionOutlinePaint(Comparable key, boolean autoPopulate) { // is there an override? Paint result = getSectionOutlinePaint(); if (result != null) { return result; } // if not, check if there is a paint defined for the specified key result = this.sectionOutlinePaintMap.getPaint(key); if (result != null) { return result; } // nothing defined - do we autoPopulate? if (autoPopulate) { DrawingSupplier ds = getDrawingSupplier(); if (ds != null) { result = ds.getNextOutlinePaint(); this.sectionOutlinePaintMap.put(key, result); } else { result = this.baseSectionOutlinePaint; } } else { result = this.baseSectionOutlinePaint; } return result; } /** * Returns the outline paint associated with the specified key, or * null if there is no paint associated with the key. * * @param key the key (null not permitted). * * @return The paint associated with the specified key, or * null. * * @throws IllegalArgumentException if key is * null. * * @see #setSectionOutlinePaint(Comparable, Paint) * * @since 1.0.3 */ public Paint getSectionOutlinePaint(Comparable key) { // null argument check delegated... return this.sectionOutlinePaintMap.getPaint(key); } /** * Sets the outline paint associated with the specified key, and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param key the key (null not permitted). * @param paint the paint. * * @throws IllegalArgumentException if key is * null. * * @see #getSectionOutlinePaint(Comparable) * * @since 1.0.3 */ public void setSectionOutlinePaint(Comparable key, Paint paint) { // null argument check delegated... this.sectionOutlinePaintMap.put(key, paint); fireChangeEvent(); } /** * Clears the section outline paint settings for this plot and, if * requested, sends a {@link PlotChangeEvent} to all registered listeners. * Be aware that if the autoPopulateSectionPaint flag is set, * the section paints may be repopulated using the same colours as before. * * @param notify notify listeners? * * @since 1.0.11 * * @see #autoPopulateSectionOutlinePaint */ public void clearSectionOutlinePaints(boolean notify) { this.sectionOutlinePaintMap.clear(); if (notify) { fireChangeEvent(); } } /** * Returns the base section paint. This is used when no other paint is * available. * * @return The paint (never null). * * @see #setBaseSectionOutlinePaint(Paint) */ public Paint getBaseSectionOutlinePaint() { return this.baseSectionOutlinePaint; } /** * Sets the base section paint. * * @param paint the paint (null not permitted). * * @see #getBaseSectionOutlinePaint() */ public void setBaseSectionOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseSectionOutlinePaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether or not the section outline paint * is auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)} * method. * * @return A boolean. * * @since 1.0.11 */ public boolean getAutoPopulateSectionOutlinePaint() { return this.autoPopulateSectionOutlinePaint; } /** * Sets the flag that controls whether or not the section outline paint is * auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)} * method, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param auto auto-populate? * * @since 1.0.11 */ public void setAutoPopulateSectionOutlinePaint(boolean auto) { this.autoPopulateSectionOutlinePaint = auto; fireChangeEvent(); } //// SECTION OUTLINE STROKE /////////////////////////////////////////////// /** * Returns the outline stroke for the specified section. This is * equivalent to lookupSectionOutlineStroke(section, * getAutoPopulateSectionOutlineStroke()). * * @param key the section key. * * @return The stroke for the specified section. * * @since 1.0.3 * * @see #lookupSectionOutlineStroke(Comparable, boolean) */ protected Stroke lookupSectionOutlineStroke(Comparable key) { return lookupSectionOutlineStroke(key, getAutoPopulateSectionOutlineStroke()); } /** * Returns the outline stroke for the specified section. The lookup * involves these steps: *
    *
  • if {@link #getSectionOutlineStroke()} is non-null, * return it;
  • *
  • otherwise, if {@link #getSectionOutlineStroke(int)} is * non-null return it;
  • *
  • if {@link #getSectionOutlineStroke(int)} is null but * autoPopulate is true, attempt to fetch * a new outline stroke from the drawing supplier * ({@link #getDrawingSupplier()}); *
  • if all else fails, return {@link #getBaseSectionOutlineStroke()}. *
* * @param key the section key. * @param autoPopulate a flag that controls whether the drawing supplier * is used to auto-populate the section outline stroke settings. * * @return The stroke. * * @since 1.0.3 */ protected Stroke lookupSectionOutlineStroke(Comparable key, boolean autoPopulate) { // is there an override? Stroke result = getSectionOutlineStroke(); if (result != null) { return result; } // if not, check if there is a stroke defined for the specified key result = this.sectionOutlineStrokeMap.getStroke(key); if (result != null) { return result; } // nothing defined - do we autoPopulate? if (autoPopulate) { DrawingSupplier ds = getDrawingSupplier(); if (ds != null) { result = ds.getNextOutlineStroke(); this.sectionOutlineStrokeMap.put(key, result); } else { result = this.baseSectionOutlineStroke; } } else { result = this.baseSectionOutlineStroke; } return result; } /** * Returns the outline stroke associated with the specified key, or * null if there is no stroke associated with the key. * * @param key the key (null not permitted). * * @return The stroke associated with the specified key, or * null. * * @throws IllegalArgumentException if key is * null. * * @see #setSectionOutlineStroke(Comparable, Stroke) * * @since 1.0.3 */ public Stroke getSectionOutlineStroke(Comparable key) { // null argument check delegated... return this.sectionOutlineStrokeMap.getStroke(key); } /** * Sets the outline stroke associated with the specified key, and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param key the key (null not permitted). * @param stroke the stroke. * * @throws IllegalArgumentException if key is * null. * * @see #getSectionOutlineStroke(Comparable) * * @since 1.0.3 */ public void setSectionOutlineStroke(Comparable key, Stroke stroke) { // null argument check delegated... this.sectionOutlineStrokeMap.put(key, stroke); fireChangeEvent(); } /** * Clears the section outline stroke settings for this plot and, if * requested, sends a {@link PlotChangeEvent} to all registered listeners. * Be aware that if the autoPopulateSectionPaint flag is set, * the section paints may be repopulated using the same colours as before. * * @param notify notify listeners? * * @since 1.0.11 * * @see #autoPopulateSectionOutlineStroke */ public void clearSectionOutlineStrokes(boolean notify) { this.sectionOutlineStrokeMap.clear(); if (notify) { fireChangeEvent(); } } /** * Returns the base section stroke. This is used when no other stroke is * available. * * @return The stroke (never null). * * @see #setBaseSectionOutlineStroke(Stroke) */ public Stroke getBaseSectionOutlineStroke() { return this.baseSectionOutlineStroke; } /** * Sets the base section stroke. * * @param stroke the stroke (null not permitted). * * @see #getBaseSectionOutlineStroke() */ public void setBaseSectionOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.baseSectionOutlineStroke = stroke; fireChangeEvent(); } /** * Returns the flag that controls whether or not the section outline stroke * is auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)} * method. * * @return A boolean. * * @since 1.0.11 */ public boolean getAutoPopulateSectionOutlineStroke() { return this.autoPopulateSectionOutlineStroke; } /** * Sets the flag that controls whether or not the section outline stroke is * auto-populated by the {@link #lookupSectionOutlineStroke(Comparable)} * method, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param auto auto-populate? * * @since 1.0.11 */ public void setAutoPopulateSectionOutlineStroke(boolean auto) { this.autoPopulateSectionOutlineStroke = auto; fireChangeEvent(); } /** * Returns the shadow paint. * * @return The paint (possibly null). * * @see #setShadowPaint(Paint) */ public Paint getShadowPaint() { return this.shadowPaint; } /** * Sets the shadow paint and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint (null permitted). * * @see #getShadowPaint() */ public void setShadowPaint(Paint paint) { this.shadowPaint = paint; fireChangeEvent(); } /** * Returns the x-offset for the shadow effect. * * @return The offset (in Java2D units). * * @see #setShadowXOffset(double) */ public double getShadowXOffset() { return this.shadowXOffset; } /** * Sets the x-offset for the shadow effect and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param offset the offset (in Java2D units). * * @see #getShadowXOffset() */ public void setShadowXOffset(double offset) { this.shadowXOffset = offset; fireChangeEvent(); } /** * Returns the y-offset for the shadow effect. * * @return The offset (in Java2D units). * * @see #setShadowYOffset(double) */ public double getShadowYOffset() { return this.shadowYOffset; } /** * Sets the y-offset for the shadow effect and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param offset the offset (in Java2D units). * * @see #getShadowYOffset() */ public void setShadowYOffset(double offset) { this.shadowYOffset = offset; fireChangeEvent(); } /** * Returns the amount that the section with the specified key should be * exploded. * * @param key the key (null not permitted). * * @return The amount that the section with the specified key should be * exploded. * * @throws IllegalArgumentException if key is * null. * * @since 1.0.3 * * @see #setExplodePercent(Comparable, double) */ public double getExplodePercent(Comparable key) { double result = 0.0; if (this.explodePercentages != null) { Number percent = (Number) this.explodePercentages.get(key); if (percent != null) { result = percent.doubleValue(); } } return result; } /** * Sets the amount that a pie section should be exploded and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param key the section key (null not permitted). * @param percent the explode percentage (0.30 = 30 percent). * * @since 1.0.3 * * @see #getExplodePercent(Comparable) */ public void setExplodePercent(Comparable key, double percent) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } if (this.explodePercentages == null) { this.explodePercentages = new TreeMap(); } this.explodePercentages.put(key, new Double(percent)); fireChangeEvent(); } /** * Returns the maximum explode percent. * * @return The percent. */ public double getMaximumExplodePercent() { if (this.dataset == null) { return 0.0; } double result = 0.0; Iterator iterator = this.dataset.getKeys().iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number explode = (Number) this.explodePercentages.get(key); if (explode != null) { result = Math.max(result, explode.doubleValue()); } } return result; } /** * Returns the section label generator. * * @return The generator (possibly null). * * @see #setLabelGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLabelGenerator() { return this.labelGenerator; } /** * Sets the section label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (null permitted). * * @see #getLabelGenerator() */ public void setLabelGenerator(PieSectionLabelGenerator generator) { this.labelGenerator = generator; fireChangeEvent(); } /** * Returns the gap between the edge of the pie and the labels, expressed as * a percentage of the plot width. * * @return The gap (a percentage, where 0.05 = five percent). * * @see #setLabelGap(double) */ public double getLabelGap() { return this.labelGap; } /** * Sets the gap between the edge of the pie and the labels (expressed as a * percentage of the plot width) and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param gap the gap (a percentage, where 0.05 = five percent). * * @see #getLabelGap() */ public void setLabelGap(double gap) { this.labelGap = gap; fireChangeEvent(); } /** * Returns the maximum label width as a percentage of the plot width. * * @return The width (a percentage, where 0.20 = 20 percent). * * @see #setMaximumLabelWidth(double) */ public double getMaximumLabelWidth() { return this.maximumLabelWidth; } /** * Sets the maximum label width as a percentage of the plot width and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param width the width (a percentage, where 0.20 = 20 percent). * * @see #getMaximumLabelWidth() */ public void setMaximumLabelWidth(double width) { this.maximumLabelWidth = width; fireChangeEvent(); } /** * Returns the flag that controls whether or not label linking lines are * visible. * * @return A boolean. * * @see #setLabelLinksVisible(boolean) */ public boolean getLabelLinksVisible() { return this.labelLinksVisible; } /** * Sets the flag that controls whether or not label linking lines are * visible and sends a {@link PlotChangeEvent} to all registered listeners. * Please take care when hiding the linking lines - depending on the data * values, the labels can be displayed some distance away from the * corresponding pie section. * * @param visible the flag. * * @see #getLabelLinksVisible() */ public void setLabelLinksVisible(boolean visible) { this.labelLinksVisible = visible; fireChangeEvent(); } /** * Returns the label link style. * * @return The label link style (never null). * * @see #setLabelLinkStyle(PieLabelLinkStyle) * * @since 1.0.10 */ public PieLabelLinkStyle getLabelLinkStyle() { return this.labelLinkStyle; } /** * Sets the label link style and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param style the new style (null not permitted). * * @see #getLabelLinkStyle() * * @since 1.0.10 */ public void setLabelLinkStyle(PieLabelLinkStyle style) { if (style == null) { throw new IllegalArgumentException("Null 'style' argument."); } this.labelLinkStyle = style; fireChangeEvent(); } /** * Returns the margin (expressed as a percentage of the width or height) * between the edge of the pie and the link point. * * @return The link margin (as a percentage, where 0.05 is five percent). * * @see #setLabelLinkMargin(double) */ public double getLabelLinkMargin() { return this.labelLinkMargin; } /** * Sets the link margin and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param margin the margin. * * @see #getLabelLinkMargin() */ public void setLabelLinkMargin(double margin) { this.labelLinkMargin = margin; fireChangeEvent(); } /** * Returns the paint used for the lines that connect pie sections to their * corresponding labels. * * @return The paint (never null). * * @see #setLabelLinkPaint(Paint) */ public Paint getLabelLinkPaint() { return this.labelLinkPaint; } /** * Sets the paint used for the lines that connect pie sections to their * corresponding labels, and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getLabelLinkPaint() */ public void setLabelLinkPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.labelLinkPaint = paint; fireChangeEvent(); } /** * Returns the stroke used for the label linking lines. * * @return The stroke. * * @see #setLabelLinkStroke(Stroke) */ public Stroke getLabelLinkStroke() { return this.labelLinkStroke; } /** * Sets the link stroke and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param stroke the stroke. * * @see #getLabelLinkStroke() */ public void setLabelLinkStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.labelLinkStroke = stroke; fireChangeEvent(); } /** * Returns the distance that the end of the label link is embedded into * the plot, expressed as a percentage of the plot's radius. *

* This method is overridden in the {@link RingPlot} class to resolve * bug 2121818. * * @return 0.10. * * @since 1.0.12 */ protected double getLabelLinkDepth() { return 0.1; } /** * Returns the section label font. * * @return The font (never null). * * @see #setLabelFont(Font) */ public Font getLabelFont() { return this.labelFont; } /** * Sets the section label font and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param font the font (null not permitted). * * @see #getLabelFont() */ public void setLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.labelFont = font; fireChangeEvent(); } /** * Returns the section label paint. * * @return The paint (never null). * * @see #setLabelPaint(Paint) */ public Paint getLabelPaint() { return this.labelPaint; } /** * Sets the section label paint and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getLabelPaint() */ public void setLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.labelPaint = paint; fireChangeEvent(); } /** * Returns the section label background paint. * * @return The paint (possibly null). * * @see #setLabelBackgroundPaint(Paint) */ public Paint getLabelBackgroundPaint() { return this.labelBackgroundPaint; } /** * Sets the section label background paint and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getLabelBackgroundPaint() */ public void setLabelBackgroundPaint(Paint paint) { this.labelBackgroundPaint = paint; fireChangeEvent(); } /** * Returns the section label outline paint. * * @return The paint (possibly null). * * @see #setLabelOutlinePaint(Paint) */ public Paint getLabelOutlinePaint() { return this.labelOutlinePaint; } /** * Sets the section label outline paint and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getLabelOutlinePaint() */ public void setLabelOutlinePaint(Paint paint) { this.labelOutlinePaint = paint; fireChangeEvent(); } /** * Returns the section label outline stroke. * * @return The stroke (possibly null). * * @see #setLabelOutlineStroke(Stroke) */ public Stroke getLabelOutlineStroke() { return this.labelOutlineStroke; } /** * Sets the section label outline stroke and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @see #getLabelOutlineStroke() */ public void setLabelOutlineStroke(Stroke stroke) { this.labelOutlineStroke = stroke; fireChangeEvent(); } /** * Returns the section label shadow paint. * * @return The paint (possibly null). * * @see #setLabelShadowPaint(Paint) */ public Paint getLabelShadowPaint() { return this.labelShadowPaint; } /** * Sets the section label shadow paint and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param paint the paint (null permitted). * * @see #getLabelShadowPaint() */ public void setLabelShadowPaint(Paint paint) { this.labelShadowPaint = paint; fireChangeEvent(); } /** * Returns the label padding. * * @return The label padding (never null). * * @since 1.0.7 * * @see #setLabelPadding(RectangleInsets) */ public RectangleInsets getLabelPadding() { return this.labelPadding; } /** * Sets the padding between each label and its outline and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param padding the padding (null not permitted). * * @since 1.0.7 * * @see #getLabelPadding() */ public void setLabelPadding(RectangleInsets padding) { if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } this.labelPadding = padding; fireChangeEvent(); } /** * Returns the flag that controls whether simple or extended labels are * displayed on the plot. * * @return A boolean. * * @since 1.0.7 */ public boolean getSimpleLabels() { return this.simpleLabels; } /** * Sets the flag that controls whether simple or extended labels are * displayed on the plot, and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param simple the new flag value. * * @since 1.0.7 */ public void setSimpleLabels(boolean simple) { this.simpleLabels = simple; fireChangeEvent(); } /** * Returns the offset used for the simple labels, if they are displayed. * * @return The offset (never null). * * @since 1.0.7 * * @see #setSimpleLabelOffset(RectangleInsets) */ public RectangleInsets getSimpleLabelOffset() { return this.simpleLabelOffset; } /** * Sets the offset for the simple labels and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param offset the offset (null not permitted). * * @since 1.0.7 * * @see #getSimpleLabelOffset() */ public void setSimpleLabelOffset(RectangleInsets offset) { if (offset == null) { throw new IllegalArgumentException("Null 'offset' argument."); } this.simpleLabelOffset = offset; fireChangeEvent(); } /** * Returns the object responsible for the vertical layout of the pie * section labels. * * @return The label distributor (never null). * * @since 1.0.6 */ public AbstractPieLabelDistributor getLabelDistributor() { return this.labelDistributor; } /** * Sets the label distributor and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param distributor the distributor (null not permitted). * * @since 1.0.6 */ public void setLabelDistributor(AbstractPieLabelDistributor distributor) { if (distributor == null) { throw new IllegalArgumentException("Null 'distributor' argument."); } this.labelDistributor = distributor; fireChangeEvent(); } /** * Returns the tool tip generator, an object that is responsible for * generating the text items used for tool tips by the plot. If the * generator is null, no tool tips will be created. * * @return The generator (possibly null). * * @see #setToolTipGenerator(PieToolTipGenerator) */ public PieToolTipGenerator getToolTipGenerator() { return this.toolTipGenerator; } /** * Sets the tool tip generator and sends a {@link PlotChangeEvent} to all * registered listeners. Set the generator to null if you * don't want any tool tips. * * @param generator the generator (null permitted). * * @see #getToolTipGenerator() */ public void setToolTipGenerator(PieToolTipGenerator generator) { this.toolTipGenerator = generator; fireChangeEvent(); } /** * Returns the URL generator. * * @return The generator (possibly null). * * @see #setURLGenerator(PieURLGenerator) */ public PieURLGenerator getURLGenerator() { return this.urlGenerator; } /** * Sets the URL generator and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param generator the generator (null permitted). * * @see #getURLGenerator() */ public void setURLGenerator(PieURLGenerator generator) { this.urlGenerator = generator; fireChangeEvent(); } /** * Returns the minimum arc angle that will be drawn. Pie sections for an * angle smaller than this are not drawn, to avoid a JDK bug. * * @return The minimum angle. * * @see #setMinimumArcAngleToDraw(double) */ public double getMinimumArcAngleToDraw() { return this.minimumArcAngleToDraw; } /** * Sets the minimum arc angle that will be drawn. Pie sections for an * angle smaller than this are not drawn, to avoid a JDK bug. See this * link for details: *

* * http://www.jfree.org/phpBB2/viewtopic.php?t=2707 *

* ...and this bug report in the Java Bug Parade: *

* * http://developer.java.sun.com/developer/bugParade/bugs/4836495.html * * @param angle the minimum angle. * * @see #getMinimumArcAngleToDraw() */ public void setMinimumArcAngleToDraw(double angle) { this.minimumArcAngleToDraw = angle; } /** * Returns the shape used for legend items. * * @return The shape (never null). * * @see #setLegendItemShape(Shape) */ public Shape getLegendItemShape() { return this.legendItemShape; } /** * Sets the shape used for legend items and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param shape the shape (null not permitted). * * @see #getLegendItemShape() */ public void setLegendItemShape(Shape shape) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.legendItemShape = shape; fireChangeEvent(); } /** * Returns the legend label generator. * * @return The legend label generator (never null). * * @see #setLegendLabelGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLegendLabelGenerator() { return this.legendLabelGenerator; } /** * Sets the legend label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (null not permitted). * * @see #getLegendLabelGenerator() */ public void setLegendLabelGenerator(PieSectionLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } this.legendLabelGenerator = generator; fireChangeEvent(); } /** * Returns the legend label tool tip generator. * * @return The legend label tool tip generator (possibly null). * * @see #setLegendLabelToolTipGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLegendLabelToolTipGenerator() { return this.legendLabelToolTipGenerator; } /** * Sets the legend label tool tip generator and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getLegendLabelToolTipGenerator() */ public void setLegendLabelToolTipGenerator( PieSectionLabelGenerator generator) { this.legendLabelToolTipGenerator = generator; fireChangeEvent(); } /** * Returns the legend label URL generator. * * @return The legend label URL generator (possibly null). * * @see #setLegendLabelURLGenerator(PieURLGenerator) * * @since 1.0.4 */ public PieURLGenerator getLegendLabelURLGenerator() { return this.legendLabelURLGenerator; } /** * Sets the legend label URL generator and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getLegendLabelURLGenerator() * * @since 1.0.4 */ public void setLegendLabelURLGenerator(PieURLGenerator generator) { this.legendLabelURLGenerator = generator; fireChangeEvent(); } /** * Initialises the drawing procedure. This method will be called before * the first item is rendered, giving the plot an opportunity to initialise * any state information it wants to maintain. * * @param g2 the graphics device. * @param plotArea the plot area (null not permitted). * @param plot the plot. * @param index the secondary index (null for primary * renderer). * @param info collects chart rendering information for return to caller. * * @return A state object (maintains state information relevant to one * chart drawing). */ public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea, PiePlot plot, Integer index, PlotRenderingInfo info) { PiePlotState state = new PiePlotState(info); state.setPassesRequired(2); if (this.dataset != null) { state.setTotal(DatasetUtilities.calculatePieDatasetTotal( plot.getDataset())); } state.setLatestAngle(plot.getStartAngle()); return state; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing * (null permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); if (info != null) { info.setPlotArea(area); info.setDataArea(area); } drawBackground(g2, area); drawOutline(g2, area); Shape savedClip = g2.getClip(); g2.clip(area); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { drawPie(g2, area, info); } else { drawNoDataMessage(g2, area); } g2.setClip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, area); } /** * Draws the pie. * * @param g2 the graphics device. * @param plotArea the plot area. * @param info chart rendering info. */ protected void drawPie(Graphics2D g2, Rectangle2D plotArea, PlotRenderingInfo info) { PiePlotState state = initialise(g2, plotArea, this, null, info); // adjust the plot area for interior spacing and labels... double labelReserve = 0.0; if (this.labelGenerator != null && !this.simpleLabels) { labelReserve = this.labelGap + this.maximumLabelWidth; } double gapHorizontal = plotArea.getWidth() * (this.interiorGap + labelReserve) * 2.0; double gapVertical = plotArea.getHeight() * this.interiorGap * 2.0; if (DEBUG_DRAW_INTERIOR) { double hGap = plotArea.getWidth() * this.interiorGap; double vGap = plotArea.getHeight() * this.interiorGap; double igx1 = plotArea.getX() + hGap; double igx2 = plotArea.getMaxX() - hGap; double igy1 = plotArea.getY() + vGap; double igy2 = plotArea.getMaxY() - vGap; g2.setPaint(Color.gray); g2.draw(new Rectangle2D.Double(igx1, igy1, igx2 - igx1, igy2 - igy1)); } double linkX = plotArea.getX() + gapHorizontal / 2; double linkY = plotArea.getY() + gapVertical / 2; double linkW = plotArea.getWidth() - gapHorizontal; double linkH = plotArea.getHeight() - gapVertical; // make the link area a square if the pie chart is to be circular... if (this.circular) { double min = Math.min(linkW, linkH) / 2; linkX = (linkX + linkX + linkW) / 2 - min; linkY = (linkY + linkY + linkH) / 2 - min; linkW = 2 * min; linkH = 2 * min; } // the link area defines the dog leg points for the linking lines to // the labels Rectangle2D linkArea = new Rectangle2D.Double(linkX, linkY, linkW, linkH); state.setLinkArea(linkArea); if (DEBUG_DRAW_LINK_AREA) { g2.setPaint(Color.blue); g2.draw(linkArea); g2.setPaint(Color.yellow); g2.draw(new Ellipse2D.Double(linkArea.getX(), linkArea.getY(), linkArea.getWidth(), linkArea.getHeight())); } // the explode area defines the max circle/ellipse for the exploded // pie sections. it is defined by shrinking the linkArea by the // linkMargin factor. double lm = 0.0; if (!this.simpleLabels) { lm = this.labelLinkMargin; } double hh = linkArea.getWidth() * lm * 2.0; double vv = linkArea.getHeight() * lm * 2.0; Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, linkY + vv / 2.0, linkW - hh, linkH - vv); state.setExplodedPieArea(explodeArea); // the pie area defines the circle/ellipse for regular pie sections. // it is defined by shrinking the explodeArea by the explodeMargin // factor. double maximumExplodePercent = getMaximumExplodePercent(); double percent = maximumExplodePercent / (1.0 + maximumExplodePercent); double h1 = explodeArea.getWidth() * percent; double v1 = explodeArea.getHeight() * percent; Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + h1 / 2.0, explodeArea.getY() + v1 / 2.0, explodeArea.getWidth() - h1, explodeArea.getHeight() - v1); if (DEBUG_DRAW_PIE_AREA) { g2.setPaint(Color.green); g2.draw(pieArea); } state.setPieArea(pieArea); state.setPieCenterX(pieArea.getCenterX()); state.setPieCenterY(pieArea.getCenterY()); state.setPieWRadius(pieArea.getWidth() / 2.0); state.setPieHRadius(pieArea.getHeight() / 2.0); // plot the data (unless the dataset is null)... if ((this.dataset != null) && (this.dataset.getKeys().size() > 0)) { List keys = this.dataset.getKeys(); double totalValue = DatasetUtilities.calculatePieDatasetTotal( this.dataset); int passesRequired = state.getPassesRequired(); for (int pass = 0; pass < passesRequired; pass++) { double runningTotal = 0.0; for (int section = 0; section < keys.size(); section++) { Number n = this.dataset.getValue(section); if (n != null) { double value = n.doubleValue(); if (value > 0.0) { runningTotal += value; drawItem(g2, section, explodeArea, state, pass); } } } } if (this.simpleLabels) { drawSimpleLabels(g2, keys, totalValue, plotArea, linkArea, state); } else { drawLabels(g2, keys, totalValue, plotArea, linkArea, state); } } else { drawNoDataMessage(g2, plotArea); } } /** * Draws a single data item. * * @param g2 the graphics device (null not permitted). * @param section the section index. * @param dataArea the data plot area. * @param state state information for one chart. * @param currentPass the current pass index. */ protected void drawItem(Graphics2D g2, int section, Rectangle2D dataArea, PiePlotState state, int currentPass) { Number n = this.dataset.getValue(section); if (n == null) { return; } double value = n.doubleValue(); double angle1 = 0.0; double angle2 = 0.0; if (this.direction == Rotation.CLOCKWISE) { angle1 = state.getLatestAngle(); angle2 = angle1 - value / state.getTotal() * 360.0; } else if (this.direction == Rotation.ANTICLOCKWISE) { angle1 = state.getLatestAngle(); angle2 = angle1 + value / state.getTotal() * 360.0; } else { throw new IllegalStateException("Rotation type not recognised."); } double angle = (angle2 - angle1); if (Math.abs(angle) > getMinimumArcAngleToDraw()) { double ep = 0.0; double mep = getMaximumExplodePercent(); if (mep > 0.0) { ep = getExplodePercent(section) / mep; } Rectangle2D arcBounds = getArcBounds(state.getPieArea(), state.getExplodedPieArea(), angle1, angle, ep); Arc2D.Double arc = new Arc2D.Double(arcBounds, angle1, angle, Arc2D.PIE); if (currentPass == 0) { if (this.shadowPaint != null) { Shape shadowArc = ShapeUtilities.createTranslatedShape( arc, (float) this.shadowXOffset, (float) this.shadowYOffset); g2.setPaint(this.shadowPaint); g2.fill(shadowArc); } } else if (currentPass == 1) { Comparable key = getSectionKey(section); Paint paint = lookupSectionPaint(key); g2.setPaint(paint); g2.fill(arc); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); if (this.sectionOutlinesVisible) { g2.setPaint(outlinePaint); g2.setStroke(outlineStroke); g2.draw(arc); } // update the linking line target for later // add an entity for the pie section if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { String tip = null; if (this.toolTipGenerator != null) { tip = this.toolTipGenerator.generateToolTip( this.dataset, key); } String url = null; if (this.urlGenerator != null) { url = this.urlGenerator.generateURL(this.dataset, key, this.pieIndex); } PieSectionEntity entity = new PieSectionEntity( arc, this.dataset, this.pieIndex, section, key, tip, url); entities.add(entity); } } } } state.setLatestAngle(angle2); } /** * Draws the pie section labels in the simple form. * * @param g2 the graphics device. * @param keys the section keys. * @param totalValue the total value for all sections in the pie. * @param plotArea the plot area. * @param pieArea the area containing the pie. * @param state the plot state. * * @since 1.0.7 */ protected void drawSimpleLabels(Graphics2D g2, List keys, double totalValue, Rectangle2D plotArea, Rectangle2D pieArea, PiePlotState state) { Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); RectangleInsets labelInsets = new RectangleInsets(UnitType.RELATIVE, 0.18, 0.18, 0.18, 0.18); Rectangle2D labelsArea = labelInsets.createInsetRectangle(pieArea); double runningTotal = 0.0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); boolean include = true; double v = 0.0; Number n = getDataset().getValue(key); if (n == null) { include = !getIgnoreNullValues(); } else { v = n.doubleValue(); include = getIgnoreZeroValues() ? v > 0.0 : v >= 0.0; } if (include) { runningTotal = runningTotal + v; // work out the mid angle (0 - 90 and 270 - 360) = right, // otherwise left double mid = getStartAngle() + (getDirection().getFactor() * ((runningTotal - v / 2.0) * 360) / totalValue); Arc2D arc = new Arc2D.Double(labelsArea, getStartAngle(), mid - getStartAngle(), Arc2D.OPEN); int x = (int) arc.getEndPoint().getX(); int y = (int) arc.getEndPoint().getY(); PieSectionLabelGenerator labelGenerator = getLabelGenerator(); if (labelGenerator == null) { continue; } String label = labelGenerator.generateSectionLabel( this.dataset, key); if (label == null) { continue; } g2.setFont(this.labelFont); FontMetrics fm = g2.getFontMetrics(); Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm); Rectangle2D out = this.labelPadding.createOutsetRectangle( bounds); Shape bg = ShapeUtilities.createTranslatedShape(out, x - bounds.getCenterX(), y - bounds.getCenterY()); if (this.labelShadowPaint != null) { Shape shadow = ShapeUtilities.createTranslatedShape(bg, this.shadowXOffset, this.shadowYOffset); g2.setPaint(this.labelShadowPaint); g2.fill(shadow); } if (this.labelBackgroundPaint != null) { g2.setPaint(this.labelBackgroundPaint); g2.fill(bg); } if (this.labelOutlinePaint != null && this.labelOutlineStroke != null) { g2.setPaint(this.labelOutlinePaint); g2.setStroke(this.labelOutlineStroke); g2.draw(bg); } g2.setPaint(this.labelPaint); g2.setFont(this.labelFont); TextUtilities.drawAlignedString(getLabelGenerator() .generateSectionLabel(getDataset(), key), g2, x, y, TextAnchor.CENTER); } } g2.setComposite(originalComposite); } /** * Draws the labels for the pie sections. * * @param g2 the graphics device. * @param keys the keys. * @param totalValue the total value. * @param plotArea the plot area. * @param linkArea the link area. * @param state the state. */ protected void drawLabels(Graphics2D g2, List keys, double totalValue, Rectangle2D plotArea, Rectangle2D linkArea, PiePlotState state) { Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); // classify the keys according to which side the label will appear... DefaultKeyedValues leftKeys = new DefaultKeyedValues(); DefaultKeyedValues rightKeys = new DefaultKeyedValues(); double runningTotal = 0.0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); boolean include = true; double v = 0.0; Number n = this.dataset.getValue(key); if (n == null) { include = !this.ignoreNullValues; } else { v = n.doubleValue(); include = this.ignoreZeroValues ? v > 0.0 : v >= 0.0; } if (include) { runningTotal = runningTotal + v; // work out the mid angle (0 - 90 and 270 - 360) = right, // otherwise left double mid = this.startAngle + (this.direction.getFactor() * ((runningTotal - v / 2.0) * 360) / totalValue); if (Math.cos(Math.toRadians(mid)) < 0.0) { leftKeys.addValue(key, new Double(mid)); } else { rightKeys.addValue(key, new Double(mid)); } } } g2.setFont(getLabelFont()); // calculate the max label width from the plot dimensions, because // a circular pie can leave a lot more room for labels... double marginX = plotArea.getX() + this.interiorGap * plotArea.getWidth(); double gap = plotArea.getWidth() * this.labelGap; double ww = linkArea.getX() - gap - marginX; float labelWidth = (float) this.labelPadding.trimWidth(ww); // draw the labels... if (this.labelGenerator != null) { drawLeftLabels(leftKeys, g2, plotArea, linkArea, labelWidth, state); drawRightLabels(rightKeys, g2, plotArea, linkArea, labelWidth, state); } g2.setComposite(originalComposite); } /** * Draws the left labels. * * @param leftKeys a collection of keys and angles (to the middle of the * section, in degrees) for the sections on the left side of the * plot. * @param g2 the graphics device. * @param plotArea the plot area. * @param linkArea the link area. * @param maxLabelWidth the maximum label width. * @param state the state. */ protected void drawLeftLabels(KeyedValues leftKeys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) { this.labelDistributor.clear(); double lGap = plotArea.getWidth() * this.labelGap; double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; for (int i = 0; i < leftKeys.getItemCount(); i++) { String label = this.labelGenerator.generateSectionLabel( this.dataset, leftKeys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2)); TextBox labelBox = new TextBox(block); labelBox.setBackgroundPaint(this.labelBackgroundPaint); labelBox.setOutlinePaint(this.labelOutlinePaint); labelBox.setOutlineStroke(this.labelOutlineStroke); labelBox.setShadowPaint(this.labelShadowPaint); labelBox.setInteriorGap(this.labelPadding); double theta = Math.toRadians( leftKeys.getValue(i).doubleValue()); double baseY = state.getPieCenterY() - Math.sin(theta) * verticalLinkRadius; double hh = labelBox.getHeight(g2); this.labelDistributor.addPieLabelRecord(new PieLabelRecord( leftKeys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 1.0 - getLabelLinkDepth() + getExplodePercent(leftKeys.getKey(i)))); } } double hh = plotArea.getHeight(); double gap = hh * getInteriorGap(); this.labelDistributor.distributeLabels(plotArea.getMinY() + gap, hh - 2 * gap); for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { drawLeftLabel(g2, state, this.labelDistributor.getPieLabelRecord(i)); } } /** * Draws the right labels. * * @param keys the keys. * @param g2 the graphics device. * @param plotArea the plot area. * @param linkArea the link area. * @param maxLabelWidth the maximum label width. * @param state the state. */ protected void drawRightLabels(KeyedValues keys, Graphics2D g2, Rectangle2D plotArea, Rectangle2D linkArea, float maxLabelWidth, PiePlotState state) { // draw the right labels... this.labelDistributor.clear(); double lGap = plotArea.getWidth() * this.labelGap; double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; for (int i = 0; i < keys.getItemCount(); i++) { String label = this.labelGenerator.generateSectionLabel( this.dataset, keys.getKey(i)); if (label != null) { TextBlock block = TextUtilities.createTextBlock(label, this.labelFont, this.labelPaint, maxLabelWidth, new G2TextMeasurer(g2)); TextBox labelBox = new TextBox(block); labelBox.setBackgroundPaint(this.labelBackgroundPaint); labelBox.setOutlinePaint(this.labelOutlinePaint); labelBox.setOutlineStroke(this.labelOutlineStroke); labelBox.setShadowPaint(this.labelShadowPaint); labelBox.setInteriorGap(this.labelPadding); double theta = Math.toRadians(keys.getValue(i).doubleValue()); double baseY = state.getPieCenterY() - Math.sin(theta) * verticalLinkRadius; double hh = labelBox.getHeight(g2); this.labelDistributor.addPieLabelRecord(new PieLabelRecord( keys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * Math.cos(theta), 1.0 - getLabelLinkDepth() + getExplodePercent(keys.getKey(i)))); } } double hh = plotArea.getHeight(); double gap = hh * getInteriorGap(); this.labelDistributor.distributeLabels(plotArea.getMinY() + gap, hh - 2 * gap); for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { drawRightLabel(g2, state, this.labelDistributor.getPieLabelRecord(i)); } } /** * Returns a collection of legend items for the pie chart. * * @return The legend items (never null). */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset == null) { return result; } List keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number n = this.dataset.getValue(key); boolean include = true; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, // line not visible new Line2D.Float(), new BasicStroke(), Color.black); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; } /** * Returns a short string describing the type of plot. * * @return The plot type. */ public String getPlotType() { return localizationResources.getString("Pie_Plot"); } /** * Returns a rectangle that can be used to create a pie section (taking * into account the amount by which the pie section is 'exploded'). * * @param unexploded the area inside which the unexploded pie sections are * drawn. * @param exploded the area inside which the exploded pie sections are * drawn. * @param angle the start angle. * @param extent the extent of the arc. * @param explodePercent the amount by which the pie section is exploded. * * @return A rectangle that can be used to create a pie section. */ protected Rectangle2D getArcBounds(Rectangle2D unexploded, Rectangle2D exploded, double angle, double extent, double explodePercent) { if (explodePercent == 0.0) { return unexploded; } else { Arc2D arc1 = new Arc2D.Double(unexploded, angle, extent / 2, Arc2D.OPEN); Point2D point1 = arc1.getEndPoint(); Arc2D.Double arc2 = new Arc2D.Double(exploded, angle, extent / 2, Arc2D.OPEN); Point2D point2 = arc2.getEndPoint(); double deltaX = (point1.getX() - point2.getX()) * explodePercent; double deltaY = (point1.getY() - point2.getY()) * explodePercent; return new Rectangle2D.Double(unexploded.getX() - deltaX, unexploded.getY() - deltaY, unexploded.getWidth(), unexploded.getHeight()); } } /** * Draws a section label on the left side of the pie chart. * * @param g2 the graphics device. * @param state the state. * @param record the label record. */ protected void drawLeftLabel(Graphics2D g2, PiePlotState state, PieLabelRecord record) { double anchorX = state.getLinkArea().getMinX(); double targetX = anchorX - record.getGap(); double targetY = record.getAllocatedY(); if (this.labelLinksVisible) { double theta = record.getAngle(); double linkX = state.getPieCenterX() + Math.cos(theta) * state.getPieWRadius() * record.getLinkPercent(); double linkY = state.getPieCenterY() - Math.sin(theta) * state.getPieHRadius() * record.getLinkPercent(); double elbowX = state.getPieCenterX() + Math.cos(theta) * state.getLinkArea().getWidth() / 2.0; double elbowY = state.getPieCenterY() - Math.sin(theta) * state.getLinkArea().getHeight() / 2.0; double anchorY = elbowY; g2.setPaint(this.labelLinkPaint); g2.setStroke(this.labelLinkStroke); PieLabelLinkStyle style = getLabelLinkStyle(); if (style.equals(PieLabelLinkStyle.STANDARD)) { g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY)); } else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) { QuadCurve2D q = new QuadCurve2D.Float(); q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY); g2.draw(q); g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY)); } else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) { CubicCurve2D c = new CubicCurve2D .Float(); c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, linkX, linkY); g2.draw(c); } } TextBox tb = record.getLabel(); tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT); } /** * Draws a section label on the right side of the pie chart. * * @param g2 the graphics device. * @param state the state. * @param record the label record. */ protected void drawRightLabel(Graphics2D g2, PiePlotState state, PieLabelRecord record) { double anchorX = state.getLinkArea().getMaxX(); double targetX = anchorX + record.getGap(); double targetY = record.getAllocatedY(); if (this.labelLinksVisible) { double theta = record.getAngle(); double linkX = state.getPieCenterX() + Math.cos(theta) * state.getPieWRadius() * record.getLinkPercent(); double linkY = state.getPieCenterY() - Math.sin(theta) * state.getPieHRadius() * record.getLinkPercent(); double elbowX = state.getPieCenterX() + Math.cos(theta) * state.getLinkArea().getWidth() / 2.0; double elbowY = state.getPieCenterY() - Math.sin(theta) * state.getLinkArea().getHeight() / 2.0; double anchorY = elbowY; g2.setPaint(this.labelLinkPaint); g2.setStroke(this.labelLinkStroke); PieLabelLinkStyle style = getLabelLinkStyle(); if (style.equals(PieLabelLinkStyle.STANDARD)) { g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY)); g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY)); } else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) { QuadCurve2D q = new QuadCurve2D.Float(); q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY); g2.draw(q); g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY)); } else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) { CubicCurve2D c = new CubicCurve2D .Float(); c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, linkX, linkY); g2.draw(c); } } TextBox tb = record.getLabel(); tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT); } /** * Tests this plot for equality with an arbitrary object. Note that the * plot's dataset is NOT included in the test for equality. * * @param obj the object to test against (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PiePlot)) { return false; } if (!super.equals(obj)) { return false; } PiePlot that = (PiePlot) obj; if (this.pieIndex != that.pieIndex) { return false; } if (this.interiorGap != that.interiorGap) { return false; } if (this.circular != that.circular) { return false; } if (this.startAngle != that.startAngle) { return false; } if (this.direction != that.direction) { return false; } if (this.ignoreZeroValues != that.ignoreZeroValues) { return false; } if (this.ignoreNullValues != that.ignoreNullValues) { return false; } if (!PaintUtilities.equal(this.sectionPaint, that.sectionPaint)) { return false; } if (!ObjectUtilities.equal(this.sectionPaintMap, that.sectionPaintMap)) { return false; } if (!PaintUtilities.equal(this.baseSectionPaint, that.baseSectionPaint)) { return false; } if (this.sectionOutlinesVisible != that.sectionOutlinesVisible) { return false; } if (!PaintUtilities.equal(this.sectionOutlinePaint, that.sectionOutlinePaint)) { return false; } if (!ObjectUtilities.equal(this.sectionOutlinePaintMap, that.sectionOutlinePaintMap)) { return false; } if (!PaintUtilities.equal( this.baseSectionOutlinePaint, that.baseSectionOutlinePaint )) { return false; } if (!ObjectUtilities.equal(this.sectionOutlineStroke, that.sectionOutlineStroke)) { return false; } if (!ObjectUtilities.equal(this.sectionOutlineStrokeMap, that.sectionOutlineStrokeMap)) { return false; } if (!ObjectUtilities.equal( this.baseSectionOutlineStroke, that.baseSectionOutlineStroke )) { return false; } if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { return false; } if (!(this.shadowXOffset == that.shadowXOffset)) { return false; } if (!(this.shadowYOffset == that.shadowYOffset)) { return false; } if (!ObjectUtilities.equal(this.explodePercentages, that.explodePercentages)) { return false; } if (!ObjectUtilities.equal(this.labelGenerator, that.labelGenerator)) { return false; } if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { return false; } if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { return false; } if (!PaintUtilities.equal(this.labelBackgroundPaint, that.labelBackgroundPaint)) { return false; } if (!PaintUtilities.equal(this.labelOutlinePaint, that.labelOutlinePaint)) { return false; } if (!ObjectUtilities.equal(this.labelOutlineStroke, that.labelOutlineStroke)) { return false; } if (!PaintUtilities.equal(this.labelShadowPaint, that.labelShadowPaint)) { return false; } if (this.simpleLabels != that.simpleLabels) { return false; } if (!this.simpleLabelOffset.equals(that.simpleLabelOffset)) { return false; } if (!this.labelPadding.equals(that.labelPadding)) { return false; } if (!(this.maximumLabelWidth == that.maximumLabelWidth)) { return false; } if (!(this.labelGap == that.labelGap)) { return false; } if (!(this.labelLinkMargin == that.labelLinkMargin)) { return false; } if (this.labelLinksVisible != that.labelLinksVisible) { return false; } if (!this.labelLinkStyle.equals(that.labelLinkStyle)) { return false; } if (!PaintUtilities.equal(this.labelLinkPaint, that.labelLinkPaint)) { return false; } if (!ObjectUtilities.equal(this.labelLinkStroke, that.labelLinkStroke)) { return false; } if (!ObjectUtilities.equal(this.toolTipGenerator, that.toolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) { return false; } if (!(this.minimumArcAngleToDraw == that.minimumArcAngleToDraw)) { return false; } if (!ShapeUtilities.equal(this.legendItemShape, that.legendItemShape)) { return false; } if (!ObjectUtilities.equal(this.legendLabelGenerator, that.legendLabelGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendLabelToolTipGenerator, that.legendLabelToolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendLabelURLGenerator, that.legendLabelURLGenerator)) { return false; } if (this.autoPopulateSectionPaint != that.autoPopulateSectionPaint) { return false; } if (this.autoPopulateSectionOutlinePaint != that.autoPopulateSectionOutlinePaint) { return false; } if (this.autoPopulateSectionOutlineStroke != that.autoPopulateSectionOutlineStroke) { return false; } // can't find any difference... return true; } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if some component of the plot does * not support cloning. */ public Object clone() throws CloneNotSupportedException { PiePlot clone = (PiePlot) super.clone(); if (clone.dataset != null) { clone.dataset.addChangeListener(clone); } if (this.urlGenerator instanceof PublicCloneable) { clone.urlGenerator = (PieURLGenerator) ObjectUtilities.clone( this.urlGenerator); } clone.legendItemShape = ShapeUtilities.clone(this.legendItemShape); if (this.legendLabelGenerator != null) { clone.legendLabelGenerator = (PieSectionLabelGenerator) ObjectUtilities.clone(this.legendLabelGenerator); } if (this.legendLabelToolTipGenerator != null) { clone.legendLabelToolTipGenerator = (PieSectionLabelGenerator) ObjectUtilities.clone(this.legendLabelToolTipGenerator); } if (this.legendLabelURLGenerator instanceof PublicCloneable) { clone.legendLabelURLGenerator = (PieURLGenerator) ObjectUtilities.clone(this.legendLabelURLGenerator); } return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.sectionPaint, stream); SerialUtilities.writePaint(this.baseSectionPaint, stream); SerialUtilities.writePaint(this.sectionOutlinePaint, stream); SerialUtilities.writePaint(this.baseSectionOutlinePaint, stream); SerialUtilities.writeStroke(this.sectionOutlineStroke, stream); SerialUtilities.writeStroke(this.baseSectionOutlineStroke, stream); SerialUtilities.writePaint(this.shadowPaint, stream); SerialUtilities.writePaint(this.labelPaint, stream); SerialUtilities.writePaint(this.labelBackgroundPaint, stream); SerialUtilities.writePaint(this.labelOutlinePaint, stream); SerialUtilities.writeStroke(this.labelOutlineStroke, stream); SerialUtilities.writePaint(this.labelShadowPaint, stream); SerialUtilities.writePaint(this.labelLinkPaint, stream); SerialUtilities.writeStroke(this.labelLinkStroke, stream); SerialUtilities.writeShape(this.legendItemShape, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.sectionPaint = SerialUtilities.readPaint(stream); this.baseSectionPaint = SerialUtilities.readPaint(stream); this.sectionOutlinePaint = SerialUtilities.readPaint(stream); this.baseSectionOutlinePaint = SerialUtilities.readPaint(stream); this.sectionOutlineStroke = SerialUtilities.readStroke(stream); this.baseSectionOutlineStroke = SerialUtilities.readStroke(stream); this.shadowPaint = SerialUtilities.readPaint(stream); this.labelPaint = SerialUtilities.readPaint(stream); this.labelBackgroundPaint = SerialUtilities.readPaint(stream); this.labelOutlinePaint = SerialUtilities.readPaint(stream); this.labelOutlineStroke = SerialUtilities.readStroke(stream); this.labelShadowPaint = SerialUtilities.readPaint(stream); this.labelLinkPaint = SerialUtilities.readPaint(stream); this.labelLinkStroke = SerialUtilities.readStroke(stream); this.legendItemShape = SerialUtilities.readShape(stream); } // DEPRECATED FIELDS AND METHODS... /** * The paint for ALL sections (overrides list). * * @deprecated This field is redundant, it is sufficient to use * sectionPaintMap and baseSectionPaint. Deprecated as of version * 1.0.6. */ private transient Paint sectionPaint; /** * The outline paint for ALL sections (overrides list). * * @deprecated This field is redundant, it is sufficient to use * sectionOutlinePaintMap and baseSectionOutlinePaint. Deprecated as * of version 1.0.6. */ private transient Paint sectionOutlinePaint; /** * The outline stroke for ALL sections (overrides list). * * @deprecated This field is redundant, it is sufficient to use * sectionOutlineStrokeMap and baseSectionOutlineStroke. Deprecated as * of version 1.0.6. */ private transient Stroke sectionOutlineStroke; /** * Returns the paint for the specified section. * * @param section the section index (zero-based). * * @return The paint (never null). * * @deprecated Use {@link #getSectionPaint(Comparable)} instead. */ public Paint getSectionPaint(int section) { Comparable key = getSectionKey(section); return getSectionPaint(key); } /** * Sets the paint used to fill a section of the pie and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param section the section index (zero-based). * @param paint the paint (null permitted). * * @deprecated Use {@link #setSectionPaint(Comparable, Paint)} instead. */ public void setSectionPaint(int section, Paint paint) { Comparable key = getSectionKey(section); setSectionPaint(key, paint); } /** * Returns the outline paint for ALL sections in the plot. * * @return The paint (possibly null). * * @see #setSectionOutlinePaint(Paint) * * @deprecated Use {@link #getSectionOutlinePaint(Comparable)} and * {@link #getBaseSectionOutlinePaint()}. Deprecated as of version * 1.0.6. */ public Paint getSectionOutlinePaint() { return this.sectionOutlinePaint; } /** * Sets the outline paint for ALL sections in the plot. If this is set to *
null
, then a list of paints is used instead (to allow * different colors to be used for each section). * * @param paint the paint (null permitted). * * @see #getSectionOutlinePaint() * * @deprecated Use {@link #setSectionOutlinePaint(Comparable, Paint)} and * {@link #setBaseSectionOutlinePaint(Paint)}. Deprecated as of * version 1.0.6. */ public void setSectionOutlinePaint(Paint paint) { this.sectionOutlinePaint = paint; fireChangeEvent(); } /** * Returns the paint for the specified section. * * @param section the section index (zero-based). * * @return The paint (possibly null). * * @deprecated Use {@link #getSectionOutlinePaint(Comparable)} instead. */ public Paint getSectionOutlinePaint(int section) { Comparable key = getSectionKey(section); return getSectionOutlinePaint(key); } /** * Sets the paint used to fill a section of the pie and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param section the section index (zero-based). * @param paint the paint (null permitted). * * @deprecated Use {@link #setSectionOutlinePaint(Comparable, Paint)} * instead. */ public void setSectionOutlinePaint(int section, Paint paint) { Comparable key = getSectionKey(section); setSectionOutlinePaint(key, paint); } /** * Returns the outline stroke for ALL sections in the plot. * * @return The stroke (possibly null). * * @see #setSectionOutlineStroke(Stroke) * * @deprecated Use {@link #getSectionOutlineStroke(Comparable)} and * {@link #getBaseSectionOutlineStroke()}. Deprecated as of version * 1.0.6. */ public Stroke getSectionOutlineStroke() { return this.sectionOutlineStroke; } /** * Sets the outline stroke for ALL sections in the plot. If this is set to * null, then a list of paints is used instead (to allow * different colors to be used for each section). * * @param stroke the stroke (null permitted). * * @see #getSectionOutlineStroke() * * @deprecated Use {@link #setSectionOutlineStroke(Comparable, Stroke)} and * {@link #setBaseSectionOutlineStroke(Stroke)}. Deprecated as of * version 1.0.6. */ public void setSectionOutlineStroke(Stroke stroke) { this.sectionOutlineStroke = stroke; fireChangeEvent(); } /** * Returns the stroke for the specified section. * * @param section the section index (zero-based). * * @return The stroke (possibly null). * * @deprecated Use {@link #getSectionOutlineStroke(Comparable)} instead. */ public Stroke getSectionOutlineStroke(int section) { Comparable key = getSectionKey(section); return getSectionOutlineStroke(key); } /** * Sets the stroke used to fill a section of the pie and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param section the section index (zero-based). * @param stroke the stroke (null permitted). * * @deprecated Use {@link #setSectionOutlineStroke(Comparable, Stroke)} * instead. */ public void setSectionOutlineStroke(int section, Stroke stroke) { Comparable key = getSectionKey(section); setSectionOutlineStroke(key, stroke); } /** * Returns the amount that a section should be 'exploded'. * * @param section the section number. * * @return The amount that a section should be 'exploded'. * * @deprecated Use {@link #getExplodePercent(Comparable)} instead. */ public double getExplodePercent(int section) { Comparable key = getSectionKey(section); return getExplodePercent(key); } /** * Sets the amount that a pie section should be exploded and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param section the section index. * @param percent the explode percentage (0.30 = 30 percent). * * @deprecated Use {@link #setExplodePercent(Comparable, double)} instead. */ public void setExplodePercent(int section, double percent) { Comparable key = getSectionKey(section); setExplodePercent(key, percent); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PiePlot3D.java0000644000175000017500000012063411173030414026023 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * PiePlot3D.java * -------------- * (C) Copyright 2000-2008, by Object Refinery and Contributors. * * Original Author: Tomer Peretz; * Contributor(s): Richard Atkinson; * David Gilbert (for Object Refinery Limited); * Xun Kang; * Christian W. Zuckschwerdt; * Arnaud Lelievre; * Dave Crane; * * Changes * ------- * 21-Jun-2002 : Version 1; * 31-Jul-2002 : Modified to use startAngle and direction, drawing modified so * that charts render with foreground alpha < 1.0 (DG); * 05-Aug-2002 : Small modification to draw method to support URLs for HTML * image maps (RA); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 18-Oct-2002 : Added drawing bug fix sent in by Xun Kang, and made a couple * of other related fixes (DG); * 30-Oct-2002 : Changed the PieDataset interface. Fixed another drawing * bug (DG); * 12-Nov-2002 : Fixed null pointer exception for zero or negative values (DG); * 07-Mar-2003 : Modified to pass pieIndex on to PieSectionEntity (DG); * 21-Mar-2003 : Added workaround for bug id 620031 (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 29-Aug-2003 : Small changes for API updates in PiePlot class (DG); * 02-Sep-2003 : Fixed bug where the 'no data' message is not displayed (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 20-Nov-2003 : Fixed bug 845289 (sides not showing) (DG); * 25-Nov-2003 : Added patch (845095) to fix outline paint issues (DG); * 10-Mar-2004 : Numerous changes to enhance labelling (DG); * 31-Mar-2004 : Adjusted plot area when label generator is null (DG); * 08-Apr-2004 : Added flag to PiePlot class to control the treatment of null * values (DG); * Added pieIndex to PieSectionEntity (DG); * 15-Nov-2004 : Removed creation of default tool tip generator (DG); * 16-Jun-2005 : Added default constructor (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 27-Sep-2006 : Updated draw() method for new lookup methods (DG); * 22-Mar-2007 : Added equals() override (DG); * 18-Jun-2007 : Added handling for simple label option (DG); * 04-Oct-2007 : Added option to darken sides of plot - thanks to Alex Moots * (see patch 1805262) (DG); * 21-Nov-2007 : Changed default depth factor, fixed labelling bugs and added * debug code - see debug flags in PiePlot class (DG); * 20-Mar-2008 : Fixed bug 1920854 - multiple redraws of the section * labels (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.PieSectionEntity; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.PieDataset; import org.jfree.ui.RectangleInsets; /** * A plot that displays data in the form of a 3D pie chart, using data from * any class that implements the {@link PieDataset} interface. *

* Although this class extends {@link PiePlot}, it does not currently support * exploded sections. */ public class PiePlot3D extends PiePlot implements Serializable { /** For serialization. */ private static final long serialVersionUID = 3408984188945161432L; /** The factor of the depth of the pie from the plot height */ private double depthFactor = 0.12; /** * A flag that controls whether or not the sides of the pie chart * are rendered using a darker colour. * * @since 1.0.7. */ private boolean darkerSides = false; // default preserves previous // behaviour /** * Creates a new instance with no dataset. */ public PiePlot3D() { this(null); } /** * Creates a pie chart with a three dimensional effect using the specified * dataset. * * @param dataset the dataset (null permitted). */ public PiePlot3D(PieDataset dataset) { super(dataset); setCircular(false, false); } /** * Returns the depth factor for the chart. * * @return The depth factor. * * @see #setDepthFactor(double) */ public double getDepthFactor() { return this.depthFactor; } /** * Sets the pie depth as a percentage of the height of the plot area, and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param factor the depth factor (for example, 0.20 is twenty percent). * * @see #getDepthFactor() */ public void setDepthFactor(double factor) { this.depthFactor = factor; fireChangeEvent(); } /** * Returns a flag that controls whether or not the sides of the pie chart * are rendered using a darker colour. This is only applied if the * section colour is an instance of {@link java.awt.Color}. * * @return A boolean. * * @see #setDarkerSides(boolean) * * @since 1.0.7 */ public boolean getDarkerSides() { return this.darkerSides; } /** * Sets a flag that controls whether or not the sides of the pie chart * are rendered using a darker colour, and sends a {@link PlotChangeEvent} * to all registered listeners. This is only applied if the * section colour is an instance of {@link java.awt.Color}. * * @param darker true to darken the sides, false to use the default * behaviour. * * @see #getDarkerSides() * * @since 1.0.7. */ public void setDarkerSides(boolean darker) { this.darkerSides = darker; fireChangeEvent(); } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). This method is called by the * {@link org.jfree.chart.JFreeChart} class, you don't normally need * to call it yourself. * * @param g2 the graphics device. * @param plotArea the area within which the plot should be drawn. * @param anchor the anchor point. * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing * (null permitted). */ public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(plotArea); Rectangle2D originalPlotArea = (Rectangle2D) plotArea.clone(); if (info != null) { info.setPlotArea(plotArea); info.setDataArea(plotArea); } drawBackground(g2, plotArea); Shape savedClip = g2.getClip(); g2.clip(plotArea); // adjust the plot area by the interior spacing value double gapPercent = getInteriorGap(); double labelPercent = 0.0; if (getLabelGenerator() != null) { labelPercent = getLabelGap() + getMaximumLabelWidth(); } double gapHorizontal = plotArea.getWidth() * (gapPercent + labelPercent) * 2.0; double gapVertical = plotArea.getHeight() * gapPercent * 2.0; if (DEBUG_DRAW_INTERIOR) { double hGap = plotArea.getWidth() * getInteriorGap(); double vGap = plotArea.getHeight() * getInteriorGap(); double igx1 = plotArea.getX() + hGap; double igx2 = plotArea.getMaxX() - hGap; double igy1 = plotArea.getY() + vGap; double igy2 = plotArea.getMaxY() - vGap; g2.setPaint(Color.lightGray); g2.draw(new Rectangle2D.Double(igx1, igy1, igx2 - igx1, igy2 - igy1)); } double linkX = plotArea.getX() + gapHorizontal / 2; double linkY = plotArea.getY() + gapVertical / 2; double linkW = plotArea.getWidth() - gapHorizontal; double linkH = plotArea.getHeight() - gapVertical; // make the link area a square if the pie chart is to be circular... if (isCircular()) { // is circular? double min = Math.min(linkW, linkH) / 2; linkX = (linkX + linkX + linkW) / 2 - min; linkY = (linkY + linkY + linkH) / 2 - min; linkW = 2 * min; linkH = 2 * min; } PiePlotState state = initialise(g2, plotArea, this, null, info); // the link area defines the dog leg points for the linking lines to // the labels Rectangle2D linkAreaXX = new Rectangle2D.Double(linkX, linkY, linkW, linkH * (1 - this.depthFactor)); state.setLinkArea(linkAreaXX); if (DEBUG_DRAW_LINK_AREA) { g2.setPaint(Color.blue); g2.draw(linkAreaXX); g2.setPaint(Color.yellow); g2.draw(new Ellipse2D.Double(linkAreaXX.getX(), linkAreaXX.getY(), linkAreaXX.getWidth(), linkAreaXX.getHeight())); } // the explode area defines the max circle/ellipse for the exploded pie // sections. // it is defined by shrinking the linkArea by the linkMargin factor. double hh = linkW * getLabelLinkMargin(); double vv = linkH * getLabelLinkMargin(); Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, linkY + vv / 2.0, linkW - hh, linkH - vv); state.setExplodedPieArea(explodeArea); // the pie area defines the circle/ellipse for regular pie sections. // it is defined by shrinking the explodeArea by the explodeMargin // factor. double maximumExplodePercent = getMaximumExplodePercent(); double percent = maximumExplodePercent / (1.0 + maximumExplodePercent); double h1 = explodeArea.getWidth() * percent; double v1 = explodeArea.getHeight() * percent; Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + h1 / 2.0, explodeArea.getY() + v1 / 2.0, explodeArea.getWidth() - h1, explodeArea.getHeight() - v1); // the link area defines the dog-leg point for the linking lines to // the labels int depth = (int) (pieArea.getHeight() * this.depthFactor); Rectangle2D linkArea = new Rectangle2D.Double(linkX, linkY, linkW, linkH - depth); state.setLinkArea(linkArea); state.setPieArea(pieArea); state.setPieCenterX(pieArea.getCenterX()); state.setPieCenterY(pieArea.getCenterY() - depth / 2.0); state.setPieWRadius(pieArea.getWidth() / 2.0); state.setPieHRadius((pieArea.getHeight() - depth) / 2.0); // get the data source - return if null; PieDataset dataset = getDataset(); if (DatasetUtilities.isEmptyOrNull(getDataset())) { drawNoDataMessage(g2, plotArea); g2.setClip(savedClip); drawOutline(g2, plotArea); return; } // if too any elements if (dataset.getKeys().size() > plotArea.getWidth()) { String text = "Too many elements"; Font sfont = new Font("dialog", Font.BOLD, 10); g2.setFont(sfont); FontMetrics fm = g2.getFontMetrics(sfont); int stringWidth = fm.stringWidth(text); g2.drawString(text, (int) (plotArea.getX() + (plotArea.getWidth() - stringWidth) / 2), (int) (plotArea.getY() + (plotArea.getHeight() / 2))); return; } // if we are drawing a perfect circle, we need to readjust the top left // coordinates of the drawing area for the arcs to arrive at this // effect. if (isCircular()) { double min = Math.min(plotArea.getWidth(), plotArea.getHeight()) / 2; plotArea = new Rectangle2D.Double(plotArea.getCenterX() - min, plotArea.getCenterY() - min, 2 * min, 2 * min); } // get a list of keys... List sectionKeys = dataset.getKeys(); if (sectionKeys.size() == 0) { return; } // establish the coordinates of the top left corner of the drawing area double arcX = pieArea.getX(); double arcY = pieArea.getY(); //g2.clip(clipArea); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); double totalValue = DatasetUtilities.calculatePieDatasetTotal(dataset); double runningTotal = 0; if (depth < 0) { return; // if depth is negative don't draw anything } ArrayList arcList = new ArrayList(); Arc2D.Double arc; Paint paint; Paint outlinePaint; Stroke outlineStroke; Iterator iterator = sectionKeys.iterator(); while (iterator.hasNext()) { Comparable currentKey = (Comparable) iterator.next(); Number dataValue = dataset.getValue(currentKey); if (dataValue == null) { arcList.add(null); continue; } double value = dataValue.doubleValue(); if (value <= 0) { arcList.add(null); continue; } double startAngle = getStartAngle(); double direction = getDirection().getFactor(); double angle1 = startAngle + (direction * (runningTotal * 360)) / totalValue; double angle2 = startAngle + (direction * (runningTotal + value) * 360) / totalValue; if (Math.abs(angle2 - angle1) > getMinimumArcAngleToDraw()) { arcList.add(new Arc2D.Double(arcX, arcY + depth, pieArea.getWidth(), pieArea.getHeight() - depth, angle1, angle2 - angle1, Arc2D.PIE)); } else { arcList.add(null); } runningTotal += value; } Shape oldClip = g2.getClip(); Ellipse2D top = new Ellipse2D.Double(pieArea.getX(), pieArea.getY(), pieArea.getWidth(), pieArea.getHeight() - depth); Ellipse2D bottom = new Ellipse2D.Double(pieArea.getX(), pieArea.getY() + depth, pieArea.getWidth(), pieArea.getHeight() - depth); Rectangle2D lower = new Rectangle2D.Double(top.getX(), top.getCenterY(), pieArea.getWidth(), bottom.getMaxY() - top.getCenterY()); Rectangle2D upper = new Rectangle2D.Double(pieArea.getX(), top.getY(), pieArea.getWidth(), bottom.getCenterY() - top.getY()); Area a = new Area(top); a.add(new Area(lower)); Area b = new Area(bottom); b.add(new Area(upper)); Area pie = new Area(a); pie.intersect(b); Area front = new Area(pie); front.subtract(new Area(top)); Area back = new Area(pie); back.subtract(new Area(bottom)); // draw the bottom circle int[] xs; int[] ys; arc = new Arc2D.Double(arcX, arcY + depth, pieArea.getWidth(), pieArea.getHeight() - depth, 0, 360, Arc2D.PIE); int categoryCount = arcList.size(); for (int categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) { arc = (Arc2D.Double) arcList.get(categoryIndex); if (arc == null) { continue; } Comparable key = getSectionKey(categoryIndex); paint = lookupSectionPaint(key); outlinePaint = lookupSectionOutlinePaint(key); outlineStroke = lookupSectionOutlineStroke(key); g2.setPaint(paint); g2.fill(arc); g2.setPaint(outlinePaint); g2.setStroke(outlineStroke); g2.draw(arc); g2.setPaint(paint); Point2D p1 = arc.getStartPoint(); // draw the height xs = new int[] {(int) arc.getCenterX(), (int) arc.getCenterX(), (int) p1.getX(), (int) p1.getX()}; ys = new int[] {(int) arc.getCenterY(), (int) arc.getCenterY() - depth, (int) p1.getY() - depth, (int) p1.getY()}; Polygon polygon = new Polygon(xs, ys, 4); g2.setPaint(java.awt.Color.lightGray); g2.fill(polygon); g2.setPaint(outlinePaint); g2.setStroke(outlineStroke); g2.draw(polygon); g2.setPaint(paint); } g2.setPaint(Color.gray); g2.fill(back); g2.fill(front); // cycle through once drawing only the sides at the back... int cat = 0; iterator = arcList.iterator(); while (iterator.hasNext()) { Arc2D segment = (Arc2D) iterator.next(); if (segment != null) { Comparable key = getSectionKey(cat); paint = lookupSectionPaint(key); outlinePaint = lookupSectionOutlinePaint(key); outlineStroke = lookupSectionOutlineStroke(key); drawSide(g2, pieArea, segment, front, back, paint, outlinePaint, outlineStroke, false, true); } cat++; } // cycle through again drawing only the sides at the front... cat = 0; iterator = arcList.iterator(); while (iterator.hasNext()) { Arc2D segment = (Arc2D) iterator.next(); if (segment != null) { Comparable key = getSectionKey(cat); paint = lookupSectionPaint(key); outlinePaint = lookupSectionOutlinePaint(key); outlineStroke = lookupSectionOutlineStroke(key); drawSide(g2, pieArea, segment, front, back, paint, outlinePaint, outlineStroke, true, false); } cat++; } g2.setClip(oldClip); // draw the sections at the top of the pie (and set up tooltips)... Arc2D upperArc; for (int sectionIndex = 0; sectionIndex < categoryCount; sectionIndex++) { arc = (Arc2D.Double) arcList.get(sectionIndex); if (arc == null) { continue; } upperArc = new Arc2D.Double(arcX, arcY, pieArea.getWidth(), pieArea.getHeight() - depth, arc.getAngleStart(), arc.getAngleExtent(), Arc2D.PIE); Comparable currentKey = (Comparable) sectionKeys.get(sectionIndex); paint = lookupSectionPaint(currentKey, true); outlinePaint = lookupSectionOutlinePaint(currentKey); outlineStroke = lookupSectionOutlineStroke(currentKey); g2.setPaint(paint); g2.fill(upperArc); g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(upperArc); // add a tooltip for the section... if (info != null) { EntityCollection entities = info.getOwner().getEntityCollection(); if (entities != null) { String tip = null; PieToolTipGenerator tipster = getToolTipGenerator(); if (tipster != null) { // @mgs: using the method's return value was missing tip = tipster.generateToolTip(dataset, currentKey); } String url = null; if (getURLGenerator() != null) { url = getURLGenerator().generateURL(dataset, currentKey, getPieIndex()); } PieSectionEntity entity = new PieSectionEntity( upperArc, dataset, getPieIndex(), sectionIndex, currentKey, tip, url); entities.add(entity); } } } List keys = dataset.getKeys(); Rectangle2D adjustedPlotArea = new Rectangle2D.Double( originalPlotArea.getX(), originalPlotArea.getY(), originalPlotArea.getWidth(), originalPlotArea.getHeight() - depth); if (getSimpleLabels()) { drawSimpleLabels(g2, keys, totalValue, adjustedPlotArea, linkArea, state); } else { drawLabels(g2, keys, totalValue, adjustedPlotArea, linkArea, state); } g2.setClip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, originalPlotArea); } /** * Draws the side of a pie section. * * @param g2 the graphics device. * @param plotArea the plot area. * @param arc the arc. * @param front the front of the pie. * @param back the back of the pie. * @param paint the color. * @param outlinePaint the outline paint. * @param outlineStroke the outline stroke. * @param drawFront draw the front? * @param drawBack draw the back? */ protected void drawSide(Graphics2D g2, Rectangle2D plotArea, Arc2D arc, Area front, Area back, Paint paint, Paint outlinePaint, Stroke outlineStroke, boolean drawFront, boolean drawBack) { if (getDarkerSides()) { if (paint instanceof Color) { Color c = (Color) paint; c = c.darker(); paint = c; } } double start = arc.getAngleStart(); double extent = arc.getAngleExtent(); double end = start + extent; g2.setStroke(outlineStroke); // for CLOCKWISE charts, the extent will be negative... if (extent < 0.0) { if (isAngleAtFront(start)) { // start at front if (!isAngleAtBack(end)) { if (extent > -180.0) { // the segment is entirely at the // front of the chart if (drawFront) { Area side = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), arc.getStartPoint().getX() - arc.getEndPoint().getX(), plotArea.getHeight())); side.intersect(front); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // the segment starts at the front, and wraps all // the way around // the back and finishes at the front again Area side1 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight())); side1.intersect(front); Area side2 = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight())); side2.intersect(front); g2.setPaint(paint); if (drawFront) { g2.fill(side1); g2.fill(side2); } if (drawBack) { g2.fill(back); } g2.setPaint(outlinePaint); if (drawFront) { g2.draw(side1); g2.draw(side2); } if (drawBack) { g2.draw(back); } } } else { // starts at the front, finishes at the back (going // around the left side) if (drawBack) { Area side2 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight())); side2.intersect(back); g2.setPaint(paint); g2.fill(side2); g2.setPaint(outlinePaint); g2.draw(side2); } if (drawFront) { Area side1 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight())); side1.intersect(front); g2.setPaint(paint); g2.fill(side1); g2.setPaint(outlinePaint); g2.draw(side1); } } } else { // the segment starts at the back (still extending // CLOCKWISE) if (!isAngleAtFront(end)) { if (extent > -180.0) { // whole segment stays at the back if (drawBack) { Area side = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight())); side.intersect(back); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // starts at the back, wraps around front, and // finishes at back again Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(back); Area side2 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight())); side2.intersect(back); g2.setPaint(paint); if (drawBack) { g2.fill(side1); g2.fill(side2); } if (drawFront) { g2.fill(front); } g2.setPaint(outlinePaint); if (drawBack) { g2.draw(side1); g2.draw(side2); } if (drawFront) { g2.draw(front); } } } else { // starts at back, finishes at front (CLOCKWISE) if (drawBack) { Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(back); g2.setPaint(paint); g2.fill(side1); g2.setPaint(outlinePaint); g2.draw(side1); } if (drawFront) { Area side2 = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight())); side2.intersect(front); g2.setPaint(paint); g2.fill(side2); g2.setPaint(outlinePaint); g2.draw(side2); } } } } else if (extent > 0.0) { // the pie sections are arranged ANTICLOCKWISE if (isAngleAtFront(start)) { // segment starts at the front if (!isAngleAtBack(end)) { // and finishes at the front if (extent < 180.0) { // segment only occupies the front if (drawFront) { Area side = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), arc.getEndPoint().getX() - arc.getStartPoint().getX(), plotArea.getHeight())); side.intersect(front); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // segments wraps right around the back... Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(front); Area side2 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight())); side2.intersect(front); g2.setPaint(paint); if (drawFront) { g2.fill(side1); g2.fill(side2); } if (drawBack) { g2.fill(back); } g2.setPaint(outlinePaint); if (drawFront) { g2.draw(side1); g2.draw(side2); } if (drawBack) { g2.draw(back); } } } else { // segments starts at front and finishes at back... if (drawBack) { Area side2 = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight())); side2.intersect(back); g2.setPaint(paint); g2.fill(side2); g2.setPaint(outlinePaint); g2.draw(side2); } if (drawFront) { Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(front); g2.setPaint(paint); g2.fill(side1); g2.setPaint(outlinePaint); g2.draw(side1); } } } else { // segment starts at back if (!isAngleAtFront(end)) { if (extent < 180.0) { // and finishes at back if (drawBack) { Area side = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), arc.getStartPoint().getX() - arc.getEndPoint().getX(), plotArea.getHeight())); side.intersect(back); g2.setPaint(paint); g2.fill(side); g2.setPaint(outlinePaint); g2.draw(side); } } else { // starts at back and wraps right around to the // back again Area side1 = new Area(new Rectangle2D.Double( arc.getStartPoint().getX(), plotArea.getY(), plotArea.getX() - arc.getStartPoint().getX(), plotArea.getHeight())); side1.intersect(back); Area side2 = new Area(new Rectangle2D.Double( arc.getEndPoint().getX(), plotArea.getY(), plotArea.getMaxX() - arc.getEndPoint().getX(), plotArea.getHeight())); side2.intersect(back); g2.setPaint(paint); if (drawBack) { g2.fill(side1); g2.fill(side2); } if (drawFront) { g2.fill(front); } g2.setPaint(outlinePaint); if (drawBack) { g2.draw(side1); g2.draw(side2); } if (drawFront) { g2.draw(front); } } } else { // starts at the back and finishes at the front // (wrapping the left side) if (drawBack) { Area side1 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getStartPoint().getX() - plotArea.getX(), plotArea.getHeight())); side1.intersect(back); g2.setPaint(paint); g2.fill(side1); g2.setPaint(outlinePaint); g2.draw(side1); } if (drawFront) { Area side2 = new Area(new Rectangle2D.Double( plotArea.getX(), plotArea.getY(), arc.getEndPoint().getX() - plotArea.getX(), plotArea.getHeight())); side2.intersect(front); g2.setPaint(paint); g2.fill(side2); g2.setPaint(outlinePaint); g2.draw(side2); } } } } } /** * Returns a short string describing the type of plot. * * @return Pie 3D Plot. */ public String getPlotType() { return localizationResources.getString("Pie_3D_Plot"); } /** * A utility method that returns true if the angle represents a point at * the front of the 3D pie chart. 0 - 180 degrees is the back, 180 - 360 * is the front. * * @param angle the angle. * * @return A boolean. */ private boolean isAngleAtFront(double angle) { return (Math.sin(Math.toRadians(angle)) < 0.0); } /** * A utility method that returns true if the angle represents a point at * the back of the 3D pie chart. 0 - 180 degrees is the back, 180 - 360 * is the front. * * @param angle the angle. * * @return true if the angle is at the back of the pie. */ private boolean isAngleAtBack(double angle) { return (Math.sin(Math.toRadians(angle)) > 0.0); } /** * Tests this plot for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PiePlot3D)) { return false; } PiePlot3D that = (PiePlot3D) obj; if (this.depthFactor != that.depthFactor) { return false; } if (this.darkerSides != that.darkerSides) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PiePlotState.java0000644000175000017500000001551111173030414026632 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * PiePlotState.java * ----------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Mar-2004 : Version 1 (DG); * */ package org.jfree.chart.plot; import java.awt.geom.Rectangle2D; import org.jfree.chart.renderer.RendererState; /** * A renderer state. */ public class PiePlotState extends RendererState { /** The number of passes required by the renderer. */ private int passesRequired; /** The total of the values in the dataset. */ private double total; /** The latest angle. */ private double latestAngle; /** The exploded pie area. */ private Rectangle2D explodedPieArea; /** The pie area. */ private Rectangle2D pieArea; /** The center of the pie in Java 2D coordinates. */ private double pieCenterX; /** The center of the pie in Java 2D coordinates. */ private double pieCenterY; /** The vertical pie radius. */ private double pieHRadius; /** The horizontal pie radius. */ private double pieWRadius; /** The link area. */ private Rectangle2D linkArea; /** * Creates a new object for recording temporary state information for a * renderer. * * @param info the plot rendering info. */ public PiePlotState(PlotRenderingInfo info) { super(info); this.passesRequired = 1; this.total = 0.0; } /** * Returns the number of passes required by the renderer. * * @return The number of passes. */ public int getPassesRequired() { return this.passesRequired; } /** * Sets the number of passes required by the renderer. * * @param passes the passes. */ public void setPassesRequired(int passes) { this.passesRequired = passes; } /** * Returns the total of the values in the dataset. * * @return The total. */ public double getTotal() { return this.total; } /** * Sets the total. * * @param total the total. */ public void setTotal(double total) { this.total = total; } /** * Returns the latest angle. * * @return The latest angle. */ public double getLatestAngle() { return this.latestAngle; } /** * Sets the latest angle. * * @param angle the angle. */ public void setLatestAngle(double angle) { this.latestAngle = angle; } /** * Returns the pie area. * * @return The pie area. */ public Rectangle2D getPieArea() { return this.pieArea; } /** * Sets the pie area. * * @param area the area. */ public void setPieArea(Rectangle2D area) { this.pieArea = area; } /** * Returns the exploded pie area. * * @return The exploded pie area. */ public Rectangle2D getExplodedPieArea() { return this.explodedPieArea; } /** * Sets the exploded pie area. * * @param area the area. */ public void setExplodedPieArea(Rectangle2D area) { this.explodedPieArea = area; } /** * Returns the x-coordinate of the center of the pie chart. * * @return The x-coordinate (in Java2D space). */ public double getPieCenterX() { return this.pieCenterX; } /** * Sets the x-coordinate of the center of the pie chart. * * @param x the x-coordinate (in Java2D space). */ public void setPieCenterX(double x) { this.pieCenterX = x; } /** * Returns the y-coordinate (in Java2D space) of the center of the pie * chart. For the {@link PiePlot3D} class, we derive this from the top of * the pie. * * @return The y-coordinate (in Java2D space). */ public double getPieCenterY() { return this.pieCenterY; } /** * Sets the y-coordinate of the center of the pie chart. This method is * used by the plot and typically is not called directly by applications. * * @param y the y-coordinate (in Java2D space). */ public void setPieCenterY(double y) { this.pieCenterY = y; } /** * Returns the link area. This defines the "dog-leg" point for the label * linking lines. * * @return The link area. */ public Rectangle2D getLinkArea() { return this.linkArea; } /** * Sets the label link area. This defines the "dog-leg" point for the * label linking lines. * * @param area the area. */ public void setLinkArea(Rectangle2D area) { this.linkArea = area; } /** * Returns the vertical pie radius. * * @return The radius. */ public double getPieHRadius() { return this.pieHRadius; } /** * Sets the vertical pie radius. * * @param radius the radius. */ public void setPieHRadius(double radius) { this.pieHRadius = radius; } /** * Returns the horizontal pie radius. * * @return The radius. */ public double getPieWRadius() { return this.pieWRadius; } /** * Sets the horizontal pie radius. * * @param radius the radius. */ public void setPieWRadius(double radius) { this.pieWRadius = radius; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/Plot.java0000644000175000017500000014721211173030414025177 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Plot.java * --------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Sylvain Vieujot; * Jeremy Bowman; * Andreas Schneider; * Gideon Krause; * Nicolas Brodu; * Michal Krause; * Richard West, Advanced Micro Devices, Inc.; * Peter Kolb - patch 2603321; * * Changes * ------- * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); * 18-Sep-2001 : Updated header info and fixed DOS encoding problem (DG); * 19-Oct-2001 : Moved series paint and stroke methods from JFreeChart * class (DG); * 23-Oct-2001 : Created renderer for LinePlot class (DG); * 07-Nov-2001 : Changed type names for ChartChangeEvent (DG); * Tidied up some Javadoc comments (DG); * 13-Nov-2001 : Changes to allow for null axes on plots such as PiePlot (DG); * Added plot/axis compatibility checks (DG); * 12-Dec-2001 : Changed constructors to protected, and removed unnecessary * 'throws' clauses (DG); * 13-Dec-2001 : Added tooltips (DG); * 22-Jan-2002 : Added handleClick() method, as part of implementation for * crosshairs (DG); * Moved tooltips reference into ChartInfo class (DG); * 23-Jan-2002 : Added test for null axes in chartChanged() method, thanks * to Barry Evans for the bug report (number 506979 on * SourceForge) (DG); * Added a zoom() method (DG); * 05-Feb-2002 : Updated setBackgroundPaint(), setOutlineStroke() and * setOutlinePaint() to better handle null values, as suggested * by Sylvain Vieujot (DG); * 06-Feb-2002 : Added background image, plus alpha transparency for background * and foreground (DG); * 06-Mar-2002 : Added AxisConstants interface (DG); * 26-Mar-2002 : Changed zoom method from empty to abstract (DG); * 23-Apr-2002 : Moved dataset from JFreeChart class (DG); * 11-May-2002 : Added ShapeFactory interface for getShape() methods, * contributed by Jeremy Bowman (DG); * 28-May-2002 : Fixed bug in setSeriesPaint(int, Paint) for subplots (AS); * 25-Jun-2002 : Removed redundant imports (DG); * 30-Jul-2002 : Added 'no data' message for charts with null or empty * datasets (DG); * 21-Aug-2002 : Added code to extend series array if necessary (refer to * SourceForge bug id 594547 for details) (DG); * 17-Sep-2002 : Fixed bug in getSeriesOutlineStroke() method, reported by * Andreas Schroeder (DG); * 23-Sep-2002 : Added getLegendItems() abstract method (DG); * 24-Sep-2002 : Removed firstSeriesIndex, subplots now use their own paint * settings, there is a new mechanism for the legend to collect * the legend items (DG); * 27-Sep-2002 : Added dataset group (DG); * 14-Oct-2002 : Moved listener storage into EventListenerList. Changed some * abstract methods to empty implementations (DG); * 28-Oct-2002 : Added a getBackgroundImage() method (DG); * 21-Nov-2002 : Added a plot index for identifying subplots in combined and * overlaid charts (DG); * 22-Nov-2002 : Changed all attributes from 'protected' to 'private'. Added * dataAreaRatio attribute from David M O'Donnell's code (DG); * 09-Jan-2003 : Integrated fix for plot border contributed by Gideon * Krause (DG); * 17-Jan-2003 : Moved to com.jrefinery.chart.plot (DG); * 23-Jan-2003 : Removed one constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 14-Jul-2003 : Moved the dataset and secondaryDataset attributes to the * CategoryPlot and XYPlot classes (DG); * 21-Jul-2003 : Moved DrawingSupplier from CategoryPlot and XYPlot up to this * class (DG); * 20-Aug-2003 : Implemented Cloneable (DG); * 11-Sep-2003 : Listeners and clone (NB); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 03-Dec-2003 : Modified draw method to accept anchor (DG); * 12-Mar-2004 : Fixed clipping bug in drawNoDataMessage() method (DG); * 07-Apr-2004 : Modified string bounds calculation (DG); * 04-Nov-2004 : Added default shapes for legend items (DG); * 25-Nov-2004 : Some changes to the clone() method implementation (DG); * 23-Feb-2005 : Implemented new LegendItemSource interface (and also * PublicCloneable) (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); * 05-May-2005 : Removed unused draw() method (DG); * 06-Jun-2005 : Fixed bugs in equals() method (DG); * 01-Sep-2005 : Moved dataAreaRatio from here to ContourPlot (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 30-Jun-2006 : Added background image alpha - see bug report 1514904 (DG); * 05-Sep-2006 : Implemented the MarkerChangeListener interface (DG); * 11-Jan-2007 : Added some argument checks, event notifications, and many * API doc updates (DG); * 03-Apr-2007 : Made drawBackgroundImage() public (DG); * 07-Jun-2007 : Added new fillBackground() method to handle GradientPaint * taking into account orientation (DG); * 25-Mar-2008 : Added fireChangeEvent() method - see patch 1914411 (DG); * 15-Aug-2008 : Added setDrawingSupplier() method with notify flag (DG); * 13-Jan-2009 : Added notify flag (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.swing.event.EventListenerList; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.LegendItemSource; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.PlotEntity; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.event.AxisChangeListener; import org.jfree.chart.event.ChartChangeEventType; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.general.DatasetGroup; import org.jfree.io.SerialUtilities; import org.jfree.text.G2TextMeasurer; import org.jfree.text.TextBlock; import org.jfree.text.TextBlockAnchor; import org.jfree.text.TextUtilities; import org.jfree.ui.Align; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * The base class for all plots in JFreeChart. The {@link JFreeChart} class * delegates the drawing of axes and data to the plot. This base class * provides facilities common to most plot types. */ public abstract class Plot implements AxisChangeListener, DatasetChangeListener, MarkerChangeListener, LegendItemSource, PublicCloneable, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8831571430103671324L; /** Useful constant representing zero. */ public static final Number ZERO = new Integer(0); /** The default insets. */ public static final RectangleInsets DEFAULT_INSETS = new RectangleInsets(4.0, 8.0, 4.0, 8.0); /** The default outline stroke. */ public static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(0.5f); /** The default outline color. */ public static final Paint DEFAULT_OUTLINE_PAINT = Color.gray; /** The default foreground alpha transparency. */ public static final float DEFAULT_FOREGROUND_ALPHA = 1.0f; /** The default background alpha transparency. */ public static final float DEFAULT_BACKGROUND_ALPHA = 1.0f; /** The default background color. */ public static final Paint DEFAULT_BACKGROUND_PAINT = Color.white; /** The minimum width at which the plot should be drawn. */ public static final int MINIMUM_WIDTH_TO_DRAW = 10; /** The minimum height at which the plot should be drawn. */ public static final int MINIMUM_HEIGHT_TO_DRAW = 10; /** A default box shape for legend items. */ public static final Shape DEFAULT_LEGEND_ITEM_BOX = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); /** A default circle shape for legend items. */ public static final Shape DEFAULT_LEGEND_ITEM_CIRCLE = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); /** The parent plot (null if this is the root plot). */ private Plot parent; /** The dataset group (to be used for thread synchronisation). */ private DatasetGroup datasetGroup; /** The message to display if no data is available. */ private String noDataMessage; /** The font used to display the 'no data' message. */ private Font noDataMessageFont; /** The paint used to draw the 'no data' message. */ private transient Paint noDataMessagePaint; /** Amount of blank space around the plot area. */ private RectangleInsets insets; /** * A flag that controls whether or not the plot outline is drawn. * * @since 1.0.6 */ private boolean outlineVisible; /** The Stroke used to draw an outline around the plot. */ private transient Stroke outlineStroke; /** The Paint used to draw an outline around the plot. */ private transient Paint outlinePaint; /** An optional color used to fill the plot background. */ private transient Paint backgroundPaint; /** An optional image for the plot background. */ private transient Image backgroundImage; // not currently serialized /** The alignment for the background image. */ private int backgroundImageAlignment = Align.FIT; /** The alpha value used to draw the background image. */ private float backgroundImageAlpha = 0.5f; /** The alpha-transparency for the plot. */ private float foregroundAlpha; /** The alpha transparency for the background paint. */ private float backgroundAlpha; /** The drawing supplier. */ private DrawingSupplier drawingSupplier; /** Storage for registered change listeners. */ private transient EventListenerList listenerList; /** * A flag that controls whether or not the plot will notify listeners * of changes (defaults to true, but sometimes it is useful to disable * this). * * @since 1.0.13 */ private boolean notify; /** * Creates a new plot. */ protected Plot() { this.parent = null; this.insets = DEFAULT_INSETS; this.backgroundPaint = DEFAULT_BACKGROUND_PAINT; this.backgroundAlpha = DEFAULT_BACKGROUND_ALPHA; this.backgroundImage = null; this.outlineVisible = true; this.outlineStroke = DEFAULT_OUTLINE_STROKE; this.outlinePaint = DEFAULT_OUTLINE_PAINT; this.foregroundAlpha = DEFAULT_FOREGROUND_ALPHA; this.noDataMessage = null; this.noDataMessageFont = new Font("SansSerif", Font.PLAIN, 12); this.noDataMessagePaint = Color.black; this.drawingSupplier = new DefaultDrawingSupplier(); this.notify = true; this.listenerList = new EventListenerList(); } /** * Returns the dataset group for the plot (not currently used). * * @return The dataset group. * * @see #setDatasetGroup(DatasetGroup) */ public DatasetGroup getDatasetGroup() { return this.datasetGroup; } /** * Sets the dataset group (not currently used). * * @param group the dataset group (null permitted). * * @see #getDatasetGroup() */ protected void setDatasetGroup(DatasetGroup group) { this.datasetGroup = group; } /** * Returns the string that is displayed when the dataset is empty or * null. * * @return The 'no data' message (null possible). * * @see #setNoDataMessage(String) * @see #getNoDataMessageFont() * @see #getNoDataMessagePaint() */ public String getNoDataMessage() { return this.noDataMessage; } /** * Sets the message that is displayed when the dataset is empty or * null, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param message the message (null permitted). * * @see #getNoDataMessage() */ public void setNoDataMessage(String message) { this.noDataMessage = message; fireChangeEvent(); } /** * Returns the font used to display the 'no data' message. * * @return The font (never null). * * @see #setNoDataMessageFont(Font) * @see #getNoDataMessage() */ public Font getNoDataMessageFont() { return this.noDataMessageFont; } /** * Sets the font used to display the 'no data' message and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * * @see #getNoDataMessageFont() */ public void setNoDataMessageFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.noDataMessageFont = font; fireChangeEvent(); } /** * Returns the paint used to display the 'no data' message. * * @return The paint (never null). * * @see #setNoDataMessagePaint(Paint) * @see #getNoDataMessage() */ public Paint getNoDataMessagePaint() { return this.noDataMessagePaint; } /** * Sets the paint used to display the 'no data' message and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getNoDataMessagePaint() */ public void setNoDataMessagePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.noDataMessagePaint = paint; fireChangeEvent(); } /** * Returns a short string describing the plot type. *

* Note: this gets used in the chart property editing user interface, * but there needs to be a better mechanism for identifying the plot type. * * @return A short string describing the plot type (never * null). */ public abstract String getPlotType(); /** * Returns the parent plot (or null if this plot is not part * of a combined plot). * * @return The parent plot. * * @see #setParent(Plot) * @see #getRootPlot() */ public Plot getParent() { return this.parent; } /** * Sets the parent plot. This method is intended for internal use, you * shouldn't need to call it directly. * * @param parent the parent plot (null permitted). * * @see #getParent() */ public void setParent(Plot parent) { this.parent = parent; } /** * Returns the root plot. * * @return The root plot. * * @see #getParent() */ public Plot getRootPlot() { Plot p = getParent(); if (p == null) { return this; } else { return p.getRootPlot(); } } /** * Returns true if this plot is part of a combined plot * structure (that is, {@link #getParent()} returns a non-null * value), and false otherwise. * * @return true if this plot is part of a combined plot * structure. * * @see #getParent() */ public boolean isSubplot() { return (getParent() != null); } /** * Returns the insets for the plot area. * * @return The insets (never null). * * @see #setInsets(RectangleInsets) */ public RectangleInsets getInsets() { return this.insets; } /** * Sets the insets for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param insets the new insets (null not permitted). * * @see #getInsets() * @see #setInsets(RectangleInsets, boolean) */ public void setInsets(RectangleInsets insets) { setInsets(insets, true); } /** * Sets the insets for the plot and, if requested, and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param insets the new insets (null not permitted). * @param notify a flag that controls whether the registered listeners are * notified. * * @see #getInsets() * @see #setInsets(RectangleInsets) */ public void setInsets(RectangleInsets insets, boolean notify) { if (insets == null) { throw new IllegalArgumentException("Null 'insets' argument."); } if (!this.insets.equals(insets)) { this.insets = insets; if (notify) { fireChangeEvent(); } } } /** * Returns the background color of the plot area. * * @return The paint (possibly null). * * @see #setBackgroundPaint(Paint) */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background color of the plot area and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getBackgroundPaint() */ public void setBackgroundPaint(Paint paint) { if (paint == null) { if (this.backgroundPaint != null) { this.backgroundPaint = null; fireChangeEvent(); } } else { if (this.backgroundPaint != null) { if (this.backgroundPaint.equals(paint)) { return; // nothing to do } } this.backgroundPaint = paint; fireChangeEvent(); } } /** * Returns the alpha transparency of the plot area background. * * @return The alpha transparency. * * @see #setBackgroundAlpha(float) */ public float getBackgroundAlpha() { return this.backgroundAlpha; } /** * Sets the alpha transparency of the plot area background, and notifies * registered listeners that the plot has been modified. * * @param alpha the new alpha value (in the range 0.0f to 1.0f). * * @see #getBackgroundAlpha() */ public void setBackgroundAlpha(float alpha) { if (this.backgroundAlpha != alpha) { this.backgroundAlpha = alpha; fireChangeEvent(); } } /** * Returns the drawing supplier for the plot. * * @return The drawing supplier (possibly null). * * @see #setDrawingSupplier(DrawingSupplier) */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; Plot p = getParent(); if (p != null) { result = p.getDrawingSupplier(); } else { result = this.drawingSupplier; } return result; } /** * Sets the drawing supplier for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. The drawing * supplier is responsible for supplying a limitless (possibly repeating) * sequence of Paint, Stroke and * Shape objects that the plot's renderer(s) can use to * populate its (their) tables. * * @param supplier the new supplier. * * @see #getDrawingSupplier() */ public void setDrawingSupplier(DrawingSupplier supplier) { this.drawingSupplier = supplier; fireChangeEvent(); } /** * Sets the drawing supplier for the plot and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. The drawing * supplier is responsible for supplying a limitless (possibly repeating) * sequence of Paint, Stroke and * Shape objects that the plot's renderer(s) can use to * populate its (their) tables. * * @param supplier the new supplier. * @param notify notify listeners? * * @see #getDrawingSupplier() * * @since 1.0.11 */ public void setDrawingSupplier(DrawingSupplier supplier, boolean notify) { this.drawingSupplier = supplier; if (notify) { fireChangeEvent(); } } /** * Returns the background image that is used to fill the plot's background * area. * * @return The image (possibly null). * * @see #setBackgroundImage(Image) */ public Image getBackgroundImage() { return this.backgroundImage; } /** * Sets the background image for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param image the image (null permitted). * * @see #getBackgroundImage() */ public void setBackgroundImage(Image image) { this.backgroundImage = image; fireChangeEvent(); } /** * Returns the background image alignment. Alignment constants are defined * in the org.jfree.ui.Align class in the JCommon class * library. * * @return The alignment. * * @see #setBackgroundImageAlignment(int) */ public int getBackgroundImageAlignment() { return this.backgroundImageAlignment; } /** * Sets the alignment for the background image and sends a * {@link PlotChangeEvent} to all registered listeners. Alignment options * are defined by the {@link org.jfree.ui.Align} class in the JCommon * class library. * * @param alignment the alignment. * * @see #getBackgroundImageAlignment() */ public void setBackgroundImageAlignment(int alignment) { if (this.backgroundImageAlignment != alignment) { this.backgroundImageAlignment = alignment; fireChangeEvent(); } } /** * Returns the alpha transparency used to draw the background image. This * is a value in the range 0.0f to 1.0f, where 0.0f is fully transparent * and 1.0f is fully opaque. * * @return The alpha transparency. * * @see #setBackgroundImageAlpha(float) */ public float getBackgroundImageAlpha() { return this.backgroundImageAlpha; } /** * Sets the alpha transparency used when drawing the background image. * * @param alpha the alpha transparency (in the range 0.0f to 1.0f, where * 0.0f is fully transparent, and 1.0f is fully opaque). * * @throws IllegalArgumentException if alpha is not within * the specified range. * * @see #getBackgroundImageAlpha() */ public void setBackgroundImageAlpha(float alpha) { if (alpha < 0.0f || alpha > 1.0f) throw new IllegalArgumentException( "The 'alpha' value must be in the range 0.0f to 1.0f."); if (this.backgroundImageAlpha != alpha) { this.backgroundImageAlpha = alpha; fireChangeEvent(); } } /** * Returns the flag that controls whether or not the plot outline is * drawn. The default value is true. Note that for * historical reasons, the plot's outline paint and stroke can take on * null values, in which case the outline will not be drawn * even if this flag is set to true. * * @return The outline visibility flag. * * @since 1.0.6 * * @see #setOutlineVisible(boolean) */ public boolean isOutlineVisible() { return this.outlineVisible; } /** * Sets the flag that controls whether or not the plot's outline is * drawn, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param visible the new flag value. * * @since 1.0.6 * * @see #isOutlineVisible() */ public void setOutlineVisible(boolean visible) { this.outlineVisible = visible; fireChangeEvent(); } /** * Returns the stroke used to outline the plot area. * * @return The stroke (possibly null). * * @see #setOutlineStroke(Stroke) */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the stroke used to outline the plot area and sends a * {@link PlotChangeEvent} to all registered listeners. If you set this * attribute to null, no outline will be drawn. * * @param stroke the stroke (null permitted). * * @see #getOutlineStroke() */ public void setOutlineStroke(Stroke stroke) { if (stroke == null) { if (this.outlineStroke != null) { this.outlineStroke = null; fireChangeEvent(); } } else { if (this.outlineStroke != null) { if (this.outlineStroke.equals(stroke)) { return; // nothing to do } } this.outlineStroke = stroke; fireChangeEvent(); } } /** * Returns the color used to draw the outline of the plot area. * * @return The color (possibly null). * * @see #setOutlinePaint(Paint) */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the paint used to draw the outline of the plot area and sends a * {@link PlotChangeEvent} to all registered listeners. If you set this * attribute to null, no outline will be drawn. * * @param paint the paint (null permitted). * * @see #getOutlinePaint() */ public void setOutlinePaint(Paint paint) { if (paint == null) { if (this.outlinePaint != null) { this.outlinePaint = null; fireChangeEvent(); } } else { if (this.outlinePaint != null) { if (this.outlinePaint.equals(paint)) { return; // nothing to do } } this.outlinePaint = paint; fireChangeEvent(); } } /** * Returns the alpha-transparency for the plot foreground. * * @return The alpha-transparency. * * @see #setForegroundAlpha(float) */ public float getForegroundAlpha() { return this.foregroundAlpha; } /** * Sets the alpha-transparency for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param alpha the new alpha transparency. * * @see #getForegroundAlpha() */ public void setForegroundAlpha(float alpha) { if (this.foregroundAlpha != alpha) { this.foregroundAlpha = alpha; fireChangeEvent(); } } /** * Returns the legend items for the plot. By default, this method returns * null. Subclasses should override to return a * {@link LegendItemCollection}. * * @return The legend items for the plot (possibly null). */ public LegendItemCollection getLegendItems() { return null; } /** * Returns a flag that controls whether or not change events are sent to * registered listeners. * * @return A boolean. * * @see #setNotify(boolean) * * @since 1.0.13 */ public boolean isNotify() { return this.notify; } /** * Sets a flag that controls whether or not listeners receive * {@link PlotChangeEvent} notifications. * * @param notify a boolean. * * @see #isNotify() * * @since 1.0.13 */ public void setNotify(boolean notify) { this.notify = notify; // if the flag is being set to true, there may be queued up changes... if (notify) { notifyListeners(new PlotChangeEvent(this)); } } /** * Registers an object for notification of changes to the plot. * * @param listener the object to be registered. * * @see #removeChangeListener(PlotChangeListener) */ public void addChangeListener(PlotChangeListener listener) { this.listenerList.add(PlotChangeListener.class, listener); } /** * Unregisters an object for notification of changes to the plot. * * @param listener the object to be unregistered. * * @see #addChangeListener(PlotChangeListener) */ public void removeChangeListener(PlotChangeListener listener) { this.listenerList.remove(PlotChangeListener.class, listener); } /** * Notifies all registered listeners that the plot has been modified. * * @param event information about the change event. */ public void notifyListeners(PlotChangeEvent event) { // if the 'notify' flag has been switched to false, we don't notify // the listeners if (!this.notify) { return; } Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == PlotChangeListener.class) { ((PlotChangeListener) listeners[i + 1]).plotChanged(event); } } } /** * Sends a {@link PlotChangeEvent} to all registered listeners. * * @since 1.0.10 */ protected void fireChangeEvent() { notifyListeners(new PlotChangeEvent(this)); } /** * Draws the plot within the specified area. The anchor is a point on the * chart that is specified externally (for instance, it may be the last * point of the last mouse click performed by the user) - plots can use or * ignore this value as they see fit. *

* Subclasses need to provide an implementation of this method, obviously. * * @param g2 the graphics device. * @param area the plot area. * @param anchor the anchor point (null permitted). * @param parentState the parent state (if any). * @param info carries back plot rendering info. */ public abstract void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info); /** * Draws the plot background (the background color and/or image). *

* This method will be called during the chart drawing process and is * declared public so that it can be accessed by the renderers used by * certain subclasses. You shouldn't need to call this method directly. * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. */ public void drawBackground(Graphics2D g2, Rectangle2D area) { // some subclasses override this method completely, so don't put // anything here that *must* be done fillBackground(g2, area); drawBackgroundImage(g2, area); } /** * Fills the specified area with the background paint. * * @param g2 the graphics device. * @param area the area. * * @see #getBackgroundPaint() * @see #getBackgroundAlpha() * @see #fillBackground(Graphics2D, Rectangle2D, PlotOrientation) */ protected void fillBackground(Graphics2D g2, Rectangle2D area) { fillBackground(g2, area, PlotOrientation.VERTICAL); } /** * Fills the specified area with the background paint. If the background * paint is an instance of GradientPaint, the gradient will * run in the direction suggested by the plot's orientation. * * @param g2 the graphics target. * @param area the plot area. * @param orientation the plot orientation (null not * permitted). * * @since 1.0.6 */ protected void fillBackground(Graphics2D g2, Rectangle2D area, PlotOrientation orientation) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } if (this.backgroundPaint == null) { return; } Paint p = this.backgroundPaint; if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) p; if (orientation == PlotOrientation.VERTICAL) { p = new GradientPaint((float) area.getCenterX(), (float) area.getMaxY(), gp.getColor1(), (float) area.getCenterX(), (float) area.getMinY(), gp.getColor2()); } else if (orientation == PlotOrientation.HORIZONTAL) { p = new GradientPaint((float) area.getMinX(), (float) area.getCenterY(), gp.getColor1(), (float) area.getMaxX(), (float) area.getCenterY(), gp.getColor2()); } } Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.backgroundAlpha)); g2.setPaint(p); g2.fill(area); g2.setComposite(originalComposite); } /** * Draws the background image (if there is one) aligned within the * specified area. * * @param g2 the graphics device. * @param area the area. * * @see #getBackgroundImage() * @see #getBackgroundImageAlignment() * @see #getBackgroundImageAlpha() */ public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) { if (this.backgroundImage != null) { Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.backgroundImageAlpha)); Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, this.backgroundImage.getWidth(null), this.backgroundImage.getHeight(null)); Align.align(dest, area, this.backgroundImageAlignment); g2.drawImage(this.backgroundImage, (int) dest.getX(), (int) dest.getY(), (int) dest.getWidth() + 1, (int) dest.getHeight() + 1, null); g2.setComposite(originalComposite); } } /** * Draws the plot outline. This method will be called during the chart * drawing process and is declared public so that it can be accessed by the * renderers used by certain subclasses. You shouldn't need to call this * method directly. * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. */ public void drawOutline(Graphics2D g2, Rectangle2D area) { if (!this.outlineVisible) { return; } if ((this.outlineStroke != null) && (this.outlinePaint != null)) { g2.setStroke(this.outlineStroke); g2.setPaint(this.outlinePaint); g2.draw(area); } } /** * Draws a message to state that there is no data to plot. * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. */ protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) { Shape savedClip = g2.getClip(); g2.clip(area); String message = this.noDataMessage; if (message != null) { g2.setFont(this.noDataMessageFont); g2.setPaint(this.noDataMessagePaint); TextBlock block = TextUtilities.createTextBlock( this.noDataMessage, this.noDataMessageFont, this.noDataMessagePaint, 0.9f * (float) area.getWidth(), new G2TextMeasurer(g2)); block.draw(g2, (float) area.getCenterX(), (float) area.getCenterY(), TextBlockAnchor.CENTER); } g2.setClip(savedClip); } /** * Creates a plot entity that contains a reference to the plot and the * data area as shape. * * @param dataArea the data area used as hot spot for the entity. * @param plotState the plot rendering info containing a reference to the * EntityCollection. * @param toolTip the tool tip (defined in the respective Plot * subclass) (null permitted). * @param urlText the url (defined in the respective Plot subclass) * (null permitted). * * @since 1.0.13 */ protected void createAndAddEntity(Rectangle2D dataArea, PlotRenderingInfo plotState, String toolTip, String urlText){ if (plotState != null && plotState.getOwner() != null) { EntityCollection e = plotState.getOwner().getEntityCollection(); if (e != null) { e.add(new PlotEntity(dataArea, this, toolTip, urlText)); } } } /** * Handles a 'click' on the plot. Since the plot does not maintain any * information about where it has been drawn, the plot rendering info is * supplied as an argument so that the plot dimensions can be determined. * * @param x the x coordinate (in Java2D space). * @param y the y coordinate (in Java2D space). * @param info an object containing information about the dimensions of * the plot. */ public void handleClick(int x, int y, PlotRenderingInfo info) { // provides a 'no action' default } /** * Performs a zoom on the plot. Subclasses should override if zooming is * appropriate for the type of plot. * * @param percent the zoom percentage. */ public void zoom(double percent) { // do nothing by default. } /** * Receives notification of a change to one of the plot's axes. * * @param event information about the event (not used here). */ public void axisChanged(AxisChangeEvent event) { fireChangeEvent(); } /** * Receives notification of a change to the plot's dataset. *

* The plot reacts by passing on a plot change event to all registered * listeners. * * @param event information about the event (not used here). */ public void datasetChanged(DatasetChangeEvent event) { PlotChangeEvent newEvent = new PlotChangeEvent(this); newEvent.setType(ChartChangeEventType.DATASET_UPDATED); notifyListeners(newEvent); } /** * Receives notification of a change to a marker that is assigned to the * plot. * * @param event the event. * * @since 1.0.3 */ public void markerChanged(MarkerChangeEvent event) { fireChangeEvent(); } /** * Adjusts the supplied x-value. * * @param x the x-value. * @param w1 width 1. * @param w2 width 2. * @param edge the edge (left or right). * * @return The adjusted x-value. */ protected double getRectX(double x, double w1, double w2, RectangleEdge edge) { double result = x; if (edge == RectangleEdge.LEFT) { result = result + w1; } else if (edge == RectangleEdge.RIGHT) { result = result + w2; } return result; } /** * Adjusts the supplied y-value. * * @param y the x-value. * @param h1 height 1. * @param h2 height 2. * @param edge the edge (top or bottom). * * @return The adjusted y-value. */ protected double getRectY(double y, double h1, double h2, RectangleEdge edge) { double result = y; if (edge == RectangleEdge.TOP) { result = result + h1; } else if (edge == RectangleEdge.BOTTOM) { result = result + h2; } return result; } /** * Tests this plot for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Plot)) { return false; } Plot that = (Plot) obj; if (!ObjectUtilities.equal(this.noDataMessage, that.noDataMessage)) { return false; } if (!ObjectUtilities.equal( this.noDataMessageFont, that.noDataMessageFont )) { return false; } if (!PaintUtilities.equal(this.noDataMessagePaint, that.noDataMessagePaint)) { return false; } if (!ObjectUtilities.equal(this.insets, that.insets)) { return false; } if (this.outlineVisible != that.outlineVisible) { return false; } if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (!ObjectUtilities.equal(this.backgroundImage, that.backgroundImage)) { return false; } if (this.backgroundImageAlignment != that.backgroundImageAlignment) { return false; } if (this.backgroundImageAlpha != that.backgroundImageAlpha) { return false; } if (this.foregroundAlpha != that.foregroundAlpha) { return false; } if (this.backgroundAlpha != that.backgroundAlpha) { return false; } if (!this.drawingSupplier.equals(that.drawingSupplier)) { return false; } if (this.notify != that.notify) { return false; } return true; } /** * Creates a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if some component of the plot does not * support cloning. */ public Object clone() throws CloneNotSupportedException { Plot clone = (Plot) super.clone(); // private Plot parent <-- don't clone the parent plot, but take care // childs in combined plots instead if (this.datasetGroup != null) { clone.datasetGroup = (DatasetGroup) ObjectUtilities.clone(this.datasetGroup); } clone.drawingSupplier = (DrawingSupplier) ObjectUtilities.clone(this.drawingSupplier); clone.listenerList = new EventListenerList(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.noDataMessagePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); // backgroundImage SerialUtilities.writePaint(this.backgroundPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.noDataMessagePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); // backgroundImage this.backgroundPaint = SerialUtilities.readPaint(stream); this.listenerList = new EventListenerList(); } /** * Resolves a domain axis location for a given plot orientation. * * @param location the location (null not permitted). * @param orientation the orientation (null not permitted). * * @return The edge (never null). */ public static RectangleEdge resolveDomainAxisLocation( AxisLocation location, PlotOrientation orientation) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } RectangleEdge result = null; if (location == AxisLocation.TOP_OR_RIGHT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.RIGHT; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.TOP; } } else if (location == AxisLocation.TOP_OR_LEFT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.LEFT; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.TOP; } } else if (location == AxisLocation.BOTTOM_OR_RIGHT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.RIGHT; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.BOTTOM; } } else if (location == AxisLocation.BOTTOM_OR_LEFT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.LEFT; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.BOTTOM; } } // the above should cover all the options... if (result == null) { throw new IllegalStateException("resolveDomainAxisLocation()"); } return result; } /** * Resolves a range axis location for a given plot orientation. * * @param location the location (null not permitted). * @param orientation the orientation (null not permitted). * * @return The edge (never null). */ public static RectangleEdge resolveRangeAxisLocation( AxisLocation location, PlotOrientation orientation) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } RectangleEdge result = null; if (location == AxisLocation.TOP_OR_RIGHT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.TOP; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.RIGHT; } } else if (location == AxisLocation.TOP_OR_LEFT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.TOP; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.LEFT; } } else if (location == AxisLocation.BOTTOM_OR_RIGHT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.BOTTOM; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.RIGHT; } } else if (location == AxisLocation.BOTTOM_OR_LEFT) { if (orientation == PlotOrientation.HORIZONTAL) { result = RectangleEdge.BOTTOM; } else if (orientation == PlotOrientation.VERTICAL) { result = RectangleEdge.LEFT; } } // the above should cover all the options... if (result == null) { throw new IllegalStateException("resolveRangeAxisLocation()"); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PlotOrientation.java0000644000175000017500000000777511173030414027424 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PlotOrientation.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-May-2003 : Version 1 (DG); * 17-Jul-2003 : Added readResolve() method (DG); * 21-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.plot; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the orientation (horizontal or vertical) of a 2D plot. */ public final class PlotOrientation implements Serializable { /** For serialization. */ private static final long serialVersionUID = -2508771828190337782L; /** For a plot where the range axis is horizontal. */ public static final PlotOrientation HORIZONTAL = new PlotOrientation("PlotOrientation.HORIZONTAL"); /** For a plot where the range axis is vertical. */ public static final PlotOrientation VERTICAL = new PlotOrientation("PlotOrientation.VERTICAL"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private PlotOrientation(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof PlotOrientation)) { return false; } PlotOrientation orientation = (PlotOrientation) obj; if (!this.name.equals(orientation.toString())) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { Object result = null; if (this.equals(PlotOrientation.HORIZONTAL)) { result = PlotOrientation.HORIZONTAL; } else if (this.equals(PlotOrientation.VERTICAL)) { result = PlotOrientation.VERTICAL; } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PlotRenderingInfo.java0000644000175000017500000002154611173030414027652 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * PlotRenderingInfo.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Sep-2003 : Version 1 (DG); * 23-Sep-2003 : Added Javadocs (DG); * 12-Nov-2004 : Added getSubplotCount() and findSubplot() methods (DG); * 01-Nov-2005 : Made 'owner' non-transient to fix bug 1344048 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Dec-2006 : Implemented clone() method properly (DG); * 17-Apr-2007 : Fixed bug 1698965 (NPE in CombinedDomainXYPlot) (DG); * */ package org.jfree.chart.plot; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.List; import org.jfree.chart.ChartRenderingInfo; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; /** * Stores information about the dimensions of a plot and its subplots. */ public class PlotRenderingInfo implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8446720134379617220L; /** The owner of this info. */ private ChartRenderingInfo owner; /** The plot area. */ private transient Rectangle2D plotArea; /** The data area. */ private transient Rectangle2D dataArea; /** * Storage for the plot rendering info objects belonging to the subplots. */ private List subplotInfo; /** * Creates a new instance. * * @param owner the owner (null permitted). */ public PlotRenderingInfo(ChartRenderingInfo owner) { this.owner = owner; this.dataArea = new Rectangle2D.Double(); this.subplotInfo = new java.util.ArrayList(); } /** * Returns the owner (as specified in the constructor). * * @return The owner (possibly null). */ public ChartRenderingInfo getOwner() { return this.owner; } /** * Returns the plot area (in Java2D space). * * @return The plot area (possibly null). * * @see #setPlotArea(Rectangle2D) */ public Rectangle2D getPlotArea() { return this.plotArea; } /** * Sets the plot area. * * @param area the plot area (in Java2D space, null * permitted but discouraged) * * @see #getPlotArea() */ public void setPlotArea(Rectangle2D area) { this.plotArea = area; } /** * Returns the plot's data area (in Java2D space). * * @return The data area (possibly null). * * @see #setDataArea(Rectangle2D) */ public Rectangle2D getDataArea() { return this.dataArea; } /** * Sets the data area. * * @param area the data area (in Java2D space, null permitted * but discouraged). * * @see #getDataArea() */ public void setDataArea(Rectangle2D area) { this.dataArea = area; } /** * Returns the number of subplots (possibly zero). * * @return The subplot count. */ public int getSubplotCount() { return this.subplotInfo.size(); } /** * Adds the info for a subplot. * * @param info the subplot info. * * @see #getSubplotInfo(int) */ public void addSubplotInfo(PlotRenderingInfo info) { this.subplotInfo.add(info); } /** * Returns the info for a subplot. * * @param index the subplot index. * * @return The info. * * @see #addSubplotInfo(PlotRenderingInfo) */ public PlotRenderingInfo getSubplotInfo(int index) { return (PlotRenderingInfo) this.subplotInfo.get(index); } /** * Returns the index of the subplot that contains the specified * (x, y) point (the "source" point). The source point will usually * come from a mouse click on a {@link org.jfree.chart.ChartPanel}, * and this method is then used to determine the subplot that * contains the source point. * * @param source the source point (in Java2D space, null not * permitted). * * @return The subplot index (or -1 if no subplot contains * source). */ public int getSubplotIndex(Point2D source) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } int subplotCount = getSubplotCount(); for (int i = 0; i < subplotCount; i++) { PlotRenderingInfo info = getSubplotInfo(i); Rectangle2D area = info.getDataArea(); if (area.contains(source)) { return i; } } return -1; } /** * Tests this instance for equality against an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof PlotRenderingInfo)) { return false; } PlotRenderingInfo that = (PlotRenderingInfo) obj; if (!ObjectUtilities.equal(this.dataArea, that.dataArea)) { return false; } if (!ObjectUtilities.equal(this.plotArea, that.plotArea)) { return false; } if (!ObjectUtilities.equal(this.subplotInfo, that.subplotInfo)) { return false; } return true; } /** * Returns a clone of this object. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { PlotRenderingInfo clone = (PlotRenderingInfo) super.clone(); if (this.plotArea != null) { clone.plotArea = (Rectangle2D) this.plotArea.clone(); } if (this.dataArea != null) { clone.dataArea = (Rectangle2D) this.dataArea.clone(); } clone.subplotInfo = new java.util.ArrayList(this.subplotInfo.size()); for (int i = 0; i < this.subplotInfo.size(); i++) { PlotRenderingInfo info = (PlotRenderingInfo) this.subplotInfo.get(i); clone.subplotInfo.add(info.clone()); } return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.dataArea, stream); SerialUtilities.writeShape(this.plotArea, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.dataArea = (Rectangle2D) SerialUtilities.readShape(stream); this.plotArea = (Rectangle2D) SerialUtilities.readShape(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PlotState.java0000644000175000017500000000410711173030414026173 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * PlotState.java * -------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Oct-2003 : Version 1 (DG); * */ package org.jfree.chart.plot; import java.util.HashMap; import java.util.Map; /** * Records information about the state of a plot during the drawing process. */ public class PlotState { /** The shared axis states. */ private Map sharedAxisStates; /** * Creates a new state object. */ public PlotState() { this.sharedAxisStates = new HashMap(); } /** * Returns a map containing the shared axis states. * * @return A map. */ public Map getSharedAxisStates() { return this.sharedAxisStates; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PlotUtilities.java0000644000175000017500000000477611173030414027102 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * PlotUtilities.java * ------------------ * (C) Copyright 2007, 2008, by Sergei Ivanov and Contributors. * * Original Author: Sergei Ivanov; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Sep-2007 : Version 1, contributed by Sergei Ivanov (see patch * 1772932) (DG); * */ package org.jfree.chart.plot; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.XYDataset; /** * Some utility methods related to the plot classes. * * @since 1.0.7 */ public class PlotUtilities { /** * Returns true if all the datasets belonging to the specified * plot are empty or null, and false otherwise. * * @param plot the plot (null permitted). * * @return A boolean. * * @since 1.0.7 */ public static boolean isEmptyOrNull(XYPlot plot) { if (plot != null) { for (int i = 0, n = plot.getDatasetCount(); i < n; i++) { final XYDataset dataset = plot.getDataset(i); if (!DatasetUtilities.isEmptyOrNull(dataset)) { return false; } } } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/PolarPlot.java0000644000175000017500000012346011173030414026174 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * PolarPlot.java * -------------- * (C) Copyright 2004-2008, by Solution Engineering, Inc. and Contributors. * * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * Martin Hoeller (patch 1871902); * * Changes * ------- * 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG); * 07-Apr-2004 : Changed text bounds calculation (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 09-Jun-2005 : Fixed getDataRange() and equals() methods (DG); * 25-Oct-2005 : Implemented Zoomable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 07-Feb-2007 : Fixed bug 1599761, data value less than axis minimum (DG); * 21-Mar-2007 : Fixed serialization bug (DG); * 24-Sep-2007 : Implemented new zooming methods (DG); * 17-Feb-2007 : Added angle tick unit attribute (see patch 1871902 by * Martin Hoeller) (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Point; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.NumberTick; import org.jfree.chart.axis.NumberTickUnit; import org.jfree.chart.axis.TickUnit; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.renderer.PolarItemRenderer; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * Plots data that is in (theta, radius) pairs where * theta equal to zero is due north and increases clockwise. */ public class PolarPlot extends Plot implements ValueAxisPlot, Zoomable, RendererChangeListener, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3794383185924179525L; /** The default margin. */ private static final int MARGIN = 20; /** The annotation margin. */ private static final double ANNOTATION_MARGIN = 7.0; /** * The default angle tick unit size. * * @since 1.0.10 */ public static final double DEFAULT_ANGLE_TICK_UNIT_SIZE = 45.0; /** The default grid line stroke. */ public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke( 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[]{2.0f, 2.0f}, 0.0f); /** The default grid line paint. */ public static final Paint DEFAULT_GRIDLINE_PAINT = Color.gray; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** The angles that are marked with gridlines. */ private List angleTicks; /** The axis (used for the y-values). */ private ValueAxis axis; /** The dataset. */ private XYDataset dataset; /** * Object responsible for drawing the visual representation of each point * on the plot. */ private PolarItemRenderer renderer; /** * The tick unit that controls the spacing between the angular grid lines. * * @since 1.0.10 */ private TickUnit angleTickUnit; /** A flag that controls whether or not the angle labels are visible. */ private boolean angleLabelsVisible = true; /** The font used to display the angle labels - never null. */ private Font angleLabelFont = new Font("SansSerif", Font.PLAIN, 12); /** The paint used to display the angle labels. */ private transient Paint angleLabelPaint = Color.black; /** A flag that controls whether the angular grid-lines are visible. */ private boolean angleGridlinesVisible; /** The stroke used to draw the angular grid-lines. */ private transient Stroke angleGridlineStroke; /** The paint used to draw the angular grid-lines. */ private transient Paint angleGridlinePaint; /** A flag that controls whether the radius grid-lines are visible. */ private boolean radiusGridlinesVisible; /** The stroke used to draw the radius grid-lines. */ private transient Stroke radiusGridlineStroke; /** The paint used to draw the radius grid-lines. */ private transient Paint radiusGridlinePaint; /** The annotations for the plot. */ private List cornerTextItems = new ArrayList(); /** * Default constructor. */ public PolarPlot() { this(null, null, null); } /** * Creates a new plot. * * @param dataset the dataset (null permitted). * @param radiusAxis the radius axis (null permitted). * @param renderer the renderer (null permitted). */ public PolarPlot(XYDataset dataset, ValueAxis radiusAxis, PolarItemRenderer renderer) { super(); this.dataset = dataset; if (this.dataset != null) { this.dataset.addChangeListener(this); } this.angleTickUnit = new NumberTickUnit(DEFAULT_ANGLE_TICK_UNIT_SIZE); this.axis = radiusAxis; if (this.axis != null) { this.axis.setPlot(this); this.axis.addChangeListener(this); } this.renderer = renderer; if (this.renderer != null) { this.renderer.setPlot(this); this.renderer.addChangeListener(this); } this.angleGridlinesVisible = true; this.angleGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.angleGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.radiusGridlinesVisible = true; this.radiusGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.radiusGridlinePaint = DEFAULT_GRIDLINE_PAINT; } /** * Add text to be displayed in the lower right hand corner and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param text the text to display (null not permitted). * * @see #removeCornerTextItem(String) */ public void addCornerTextItem(String text) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } this.cornerTextItems.add(text); fireChangeEvent(); } /** * Remove the given text from the list of corner text items and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param text the text to remove (null ignored). * * @see #addCornerTextItem(String) */ public void removeCornerTextItem(String text) { boolean removed = this.cornerTextItems.remove(text); if (removed) { fireChangeEvent(); } } /** * Clear the list of corner text items and sends a {@link PlotChangeEvent} * to all registered listeners. * * @see #addCornerTextItem(String) * @see #removeCornerTextItem(String) */ public void clearCornerTextItems() { if (this.cornerTextItems.size() > 0) { this.cornerTextItems.clear(); fireChangeEvent(); } } /** * Returns the plot type as a string. * * @return A short string describing the type of plot. */ public String getPlotType() { return PolarPlot.localizationResources.getString("Polar_Plot"); } /** * Returns the axis for the plot. * * @return The radius axis (possibly null). * * @see #setAxis(ValueAxis) */ public ValueAxis getAxis() { return this.axis; } /** * Sets the axis for the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param axis the new axis (null permitted). */ public void setAxis(ValueAxis axis) { if (axis != null) { axis.setPlot(this); } // plot is likely registered as a listener with the existing axis... if (this.axis != null) { this.axis.removeChangeListener(this); } this.axis = axis; if (this.axis != null) { this.axis.configure(); this.axis.addChangeListener(this); } fireChangeEvent(); } /** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly null). * * @see #setDataset(XYDataset) */ public XYDataset getDataset() { return this.dataset; } /** * Sets the dataset for the plot, replacing the existing dataset if there * is one. * * @param dataset the dataset (null permitted). * * @see #getDataset() */ public void setDataset(XYDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... XYDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new m_Dataset, and register the chart as a change listener... this.dataset = dataset; if (this.dataset != null) { setDatasetGroup(this.dataset.getGroup()); this.dataset.addChangeListener(this); } // send a m_Dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, this.dataset); datasetChanged(event); } /** * Returns the item renderer. * * @return The renderer (possibly null). * * @see #setRenderer(PolarItemRenderer) */ public PolarItemRenderer getRenderer() { return this.renderer; } /** * Sets the item renderer, and notifies all listeners of a change to the * plot. *

* If the renderer is set to null, no chart will be drawn. * * @param renderer the new renderer (null permitted). * * @see #getRenderer() */ public void setRenderer(PolarItemRenderer renderer) { if (this.renderer != null) { this.renderer.removeChangeListener(this); } this.renderer = renderer; if (this.renderer != null) { this.renderer.setPlot(this); } fireChangeEvent(); } /** * Returns the tick unit that controls the spacing of the angular grid * lines. * * @return The tick unit (never null). * * @since 1.0.10 */ public TickUnit getAngleTickUnit() { return this.angleTickUnit; } /** * Sets the tick unit that controls the spacing of the angular grid * lines, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param unit the tick unit (null not permitted). * * @since 1.0.10 */ public void setAngleTickUnit(TickUnit unit) { if (unit == null) { throw new IllegalArgumentException("Null 'unit' argument."); } this.angleTickUnit = unit; fireChangeEvent(); } /** * Returns a flag that controls whether or not the angle labels are visible. * * @return A boolean. * * @see #setAngleLabelsVisible(boolean) */ public boolean isAngleLabelsVisible() { return this.angleLabelsVisible; } /** * Sets the flag that controls whether or not the angle labels are visible, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #isAngleLabelsVisible() */ public void setAngleLabelsVisible(boolean visible) { if (this.angleLabelsVisible != visible) { this.angleLabelsVisible = visible; fireChangeEvent(); } } /** * Returns the font used to display the angle labels. * * @return A font (never null). * * @see #setAngleLabelFont(Font) */ public Font getAngleLabelFont() { return this.angleLabelFont; } /** * Sets the font used to display the angle labels and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * * @see #getAngleLabelFont() */ public void setAngleLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.angleLabelFont = font; fireChangeEvent(); } /** * Returns the paint used to display the angle labels. * * @return A paint (never null). * * @see #setAngleLabelPaint(Paint) */ public Paint getAngleLabelPaint() { return this.angleLabelPaint; } /** * Sets the paint used to display the angle labels and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). */ public void setAngleLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.angleLabelPaint = paint; fireChangeEvent(); } /** * Returns true if the angular gridlines are visible, and * false otherwise. * * @return true or false. * * @see #setAngleGridlinesVisible(boolean) */ public boolean isAngleGridlinesVisible() { return this.angleGridlinesVisible; } /** * Sets the flag that controls whether or not the angular grid-lines are * visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isAngleGridlinesVisible() */ public void setAngleGridlinesVisible(boolean visible) { if (this.angleGridlinesVisible != visible) { this.angleGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the grid-lines (if any) plotted against the * angular axis. * * @return The stroke (possibly null). * * @see #setAngleGridlineStroke(Stroke) */ public Stroke getAngleGridlineStroke() { return this.angleGridlineStroke; } /** * Sets the stroke for the grid lines plotted against the angular axis and * sends a {@link PlotChangeEvent} to all registered listeners. *

* If you set this to null, no grid lines will be drawn. * * @param stroke the stroke (null permitted). * * @see #getAngleGridlineStroke() */ public void setAngleGridlineStroke(Stroke stroke) { this.angleGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the grid lines (if any) plotted against the * angular axis. * * @return The paint (possibly null). * * @see #setAngleGridlinePaint(Paint) */ public Paint getAngleGridlinePaint() { return this.angleGridlinePaint; } /** * Sets the paint for the grid lines plotted against the angular axis. *

* If you set this to null, no grid lines will be drawn. * * @param paint the paint (null permitted). * * @see #getAngleGridlinePaint() */ public void setAngleGridlinePaint(Paint paint) { this.angleGridlinePaint = paint; fireChangeEvent(); } /** * Returns true if the radius axis grid is visible, and * false otherwise. * * @return true or false. * * @see #setRadiusGridlinesVisible(boolean) */ public boolean isRadiusGridlinesVisible() { return this.radiusGridlinesVisible; } /** * Sets the flag that controls whether or not the radius axis grid lines * are visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isRadiusGridlinesVisible() */ public void setRadiusGridlinesVisible(boolean visible) { if (this.radiusGridlinesVisible != visible) { this.radiusGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the grid lines (if any) plotted against the * radius axis. * * @return The stroke (possibly null). * * @see #setRadiusGridlineStroke(Stroke) */ public Stroke getRadiusGridlineStroke() { return this.radiusGridlineStroke; } /** * Sets the stroke for the grid lines plotted against the radius axis and * sends a {@link PlotChangeEvent} to all registered listeners. *

* If you set this to null, no grid lines will be drawn. * * @param stroke the stroke (null permitted). * * @see #getRadiusGridlineStroke() */ public void setRadiusGridlineStroke(Stroke stroke) { this.radiusGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the grid lines (if any) plotted against the radius * axis. * * @return The paint (possibly null). * * @see #setRadiusGridlinePaint(Paint) */ public Paint getRadiusGridlinePaint() { return this.radiusGridlinePaint; } /** * Sets the paint for the grid lines plotted against the radius axis and * sends a {@link PlotChangeEvent} to all registered listeners. *

* If you set this to null, no grid lines will be drawn. * * @param paint the paint (null permitted). * * @see #getRadiusGridlinePaint() */ public void setRadiusGridlinePaint(Paint paint) { this.radiusGridlinePaint = paint; fireChangeEvent(); } /** * Generates a list of tick values for the angular tick marks. * * @return A list of {@link NumberTick} instances. * * @since 1.0.10 */ protected List refreshAngleTicks() { List ticks = new ArrayList(); for (double currentTickVal = 0.0; currentTickVal < 360.0; currentTickVal += this.angleTickUnit.getSize()) { NumberTick tick = new NumberTick(new Double(currentTickVal), this.angleTickUnit.valueToString(currentTickVal), TextAnchor.CENTER, TextAnchor.CENTER, 0.0); ticks.add(tick); } return ticks; } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). *

* This plot relies on a {@link PolarItemRenderer} to draw each * item in the plot. This allows the visual representation of the data to * be changed easily. *

* The optional info argument collects information about the rendering of * the plot (dimensions, tooltip information etc). Just pass in * null if you do not need this information. * * @param g2 the graphics device. * @param area the area within which the plot (including axes and * labels) should be drawn. * @param anchor the anchor point (null permitted). * @param parentState ignored. * @param info collects chart drawing information (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // if the plot area is too small, just return... boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } // record the plot area... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for the plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); Rectangle2D dataArea = area; if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); double h = Math.min(dataArea.getWidth() / 2.0, dataArea.getHeight() / 2.0) - MARGIN; Rectangle2D quadrant = new Rectangle2D.Double(dataArea.getCenterX(), dataArea.getCenterY(), h, h); AxisState state = drawAxis(g2, area, quadrant); if (this.renderer != null) { Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, getForegroundAlpha())); this.angleTicks = refreshAngleTicks(); drawGridlines(g2, dataArea, this.angleTicks, state.getTicks()); // draw... render(g2, dataArea, info); g2.setClip(originalClip); g2.setComposite(originalComposite); } drawOutline(g2, dataArea); drawCornerTextItems(g2, dataArea); } /** * Draws the corner text items. * * @param g2 the drawing surface. * @param area the area. */ protected void drawCornerTextItems(Graphics2D g2, Rectangle2D area) { if (this.cornerTextItems.isEmpty()) { return; } g2.setColor(Color.black); double width = 0.0; double height = 0.0; for (Iterator it = this.cornerTextItems.iterator(); it.hasNext();) { String msg = (String) it.next(); FontMetrics fm = g2.getFontMetrics(); Rectangle2D bounds = TextUtilities.getTextBounds(msg, g2, fm); width = Math.max(width, bounds.getWidth()); height += bounds.getHeight(); } double xadj = ANNOTATION_MARGIN * 2.0; double yadj = ANNOTATION_MARGIN; width += xadj; height += yadj; double x = area.getMaxX() - width; double y = area.getMaxY() - height; g2.drawRect((int) x, (int) y, (int) width, (int) height); x += ANNOTATION_MARGIN; for (Iterator it = this.cornerTextItems.iterator(); it.hasNext();) { String msg = (String) it.next(); Rectangle2D bounds = TextUtilities.getTextBounds(msg, g2, g2.getFontMetrics()); y += bounds.getHeight(); g2.drawString(msg, (int) x, (int) y); } } /** * A utility method for drawing the axes. * * @param g2 the graphics device. * @param plotArea the plot area. * @param dataArea the data area. * * @return A map containing the axis states. */ protected AxisState drawAxis(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea) { return this.axis.draw(g2, dataArea.getMinY(), plotArea, dataArea, RectangleEdge.TOP, null); } /** * Draws a representation of the data within the dataArea region, using the * current m_Renderer. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param info an optional object for collection dimension * information (null permitted). */ protected void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) { // now get the data and plot it (the visual representation will depend // on the m_Renderer that has been set)... if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { int seriesCount = this.dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { this.renderer.drawSeries(g2, dataArea, info, this, this.dataset, series); } } else { drawNoDataMessage(g2, dataArea); } } /** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param angularTicks the ticks for the angular axis. * @param radialTicks the ticks for the radial axis. */ protected void drawGridlines(Graphics2D g2, Rectangle2D dataArea, List angularTicks, List radialTicks) { // no renderer, no gridlines... if (this.renderer == null) { return; } // draw the domain grid lines, if any... if (isAngleGridlinesVisible()) { Stroke gridStroke = getAngleGridlineStroke(); Paint gridPaint = getAngleGridlinePaint(); if ((gridStroke != null) && (gridPaint != null)) { this.renderer.drawAngularGridLines(g2, this, angularTicks, dataArea); } } // draw the radius grid lines, if any... if (isRadiusGridlinesVisible()) { Stroke gridStroke = getRadiusGridlineStroke(); Paint gridPaint = getRadiusGridlinePaint(); if ((gridStroke != null) && (gridPaint != null)) { this.renderer.drawRadialGridLines(g2, this, this.axis, radialTicks, dataArea); } } } /** * Zooms the axis ranges by the specified percentage about the anchor point. * * @param percent the amount of the zoom. */ public void zoom(double percent) { if (percent > 0.0) { double radius = getMaxRadius(); double scaledRadius = radius * percent; this.axis.setUpperBound(scaledRadius); getAxis().setAutoRange(false); } else { getAxis().setAutoRange(true); } } /** * Returns the range for the specified axis. * * @param axis the axis. * * @return The range. */ public Range getDataRange(ValueAxis axis) { Range result = null; if (this.dataset != null) { result = Range.combine(result, DatasetUtilities.findRangeBounds(this.dataset)); } return result; } /** * Receives notification of a change to the plot's m_Dataset. *

* The axis ranges are updated if necessary. * * @param event information about the event (not used here). */ public void datasetChanged(DatasetChangeEvent event) { if (this.axis != null) { this.axis.configure(); } if (getParent() != null) { getParent().datasetChanged(event); } else { super.datasetChanged(event); } } /** * Notifies all registered listeners of a property change. *

* One source of property change events is the plot's m_Renderer. * * @param event information about the property change. */ public void rendererChanged(RendererChangeEvent event) { fireChangeEvent(); } /** * Returns the number of series in the dataset for this plot. If the * dataset is null, the method returns 0. * * @return The series count. */ public int getSeriesCount() { int result = 0; if (this.dataset != null) { result = this.dataset.getSeriesCount(); } return result; } /** * Returns the legend items for the plot. Each legend item is generated by * the plot's m_Renderer, since the m_Renderer is responsible for the visual * representation of the data. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); // get the legend items for the main m_Dataset... if (this.dataset != null) { if (this.renderer != null) { int seriesCount = this.dataset.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { LegendItem item = this.renderer.getLegendItem(i); result.add(item); } } } return result; } /** * Tests this plot for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PolarPlot)) { return false; } PolarPlot that = (PolarPlot) obj; if (!ObjectUtilities.equal(this.axis, that.axis)) { return false; } if (!ObjectUtilities.equal(this.renderer, that.renderer)) { return false; } if (!this.angleTickUnit.equals(that.angleTickUnit)) { return false; } if (this.angleGridlinesVisible != that.angleGridlinesVisible) { return false; } if (this.angleLabelsVisible != that.angleLabelsVisible) { return false; } if (!this.angleLabelFont.equals(that.angleLabelFont)) { return false; } if (!PaintUtilities.equal(this.angleLabelPaint, that.angleLabelPaint)) { return false; } if (!ObjectUtilities.equal(this.angleGridlineStroke, that.angleGridlineStroke)) { return false; } if (!PaintUtilities.equal( this.angleGridlinePaint, that.angleGridlinePaint )) { return false; } if (this.radiusGridlinesVisible != that.radiusGridlinesVisible) { return false; } if (!ObjectUtilities.equal(this.radiusGridlineStroke, that.radiusGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.radiusGridlinePaint, that.radiusGridlinePaint)) { return false; } if (!this.cornerTextItems.equals(that.cornerTextItems)) { return false; } return super.equals(obj); } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException this can occur if some component of * the plot cannot be cloned. */ public Object clone() throws CloneNotSupportedException { PolarPlot clone = (PolarPlot) super.clone(); if (this.axis != null) { clone.axis = (ValueAxis) ObjectUtilities.clone(this.axis); clone.axis.setPlot(clone); clone.axis.addChangeListener(clone); } if (clone.dataset != null) { clone.dataset.addChangeListener(clone); } if (this.renderer != null) { clone.renderer = (PolarItemRenderer) ObjectUtilities.clone(this.renderer); } clone.cornerTextItems = new ArrayList(this.cornerTextItems); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.angleGridlineStroke, stream); SerialUtilities.writePaint(this.angleGridlinePaint, stream); SerialUtilities.writeStroke(this.radiusGridlineStroke, stream); SerialUtilities.writePaint(this.radiusGridlinePaint, stream); SerialUtilities.writePaint(this.angleLabelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.angleGridlineStroke = SerialUtilities.readStroke(stream); this.angleGridlinePaint = SerialUtilities.readPaint(stream); this.radiusGridlineStroke = SerialUtilities.readStroke(stream); this.radiusGridlinePaint = SerialUtilities.readPaint(stream); this.angleLabelPaint = SerialUtilities.readPaint(stream); if (this.axis != null) { this.axis.setPlot(this); this.axis.addChangeListener(this); } if (this.dataset != null) { this.dataset.addChangeListener(this); } } /** * This method is required by the {@link Zoomable} interface, but since * the plot does not have any domain axes, it does nothing. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source) { // do nothing } /** * This method is required by the {@link Zoomable} interface, but since * the plot does not have any domain axes, it does nothing. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). * @param useAnchor use source point as zoom anchor? * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { // do nothing } /** * This method is required by the {@link Zoomable} interface, but since * the plot does not have any domain axes, it does nothing. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. * @param state the plot state. * @param source the source point (in Java2D coordinates). */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source) { // do nothing } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source) { zoom(factor); } /** * Multiplies the range on the range axis by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { if (useAnchor) { // get the source coordinate - this plot has always a VERTICAL // orientation double sourceX = source.getX(); double anchorX = this.axis.java2DToValue(sourceX, info.getDataArea(), RectangleEdge.BOTTOM); this.axis.resizeRange(factor, anchorX); } else { this.axis.resizeRange(factor); } } /** * Zooms in on the range axes. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. * @param state the plot state. * @param source the source point (in Java2D coordinates). */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source) { zoom((upperPercent + lowerPercent) / 2.0); } /** * Returns false always. * * @return false always. */ public boolean isDomainZoomable() { return false; } /** * Returns true to indicate that the range axis is zoomable. * * @return true. */ public boolean isRangeZoomable() { return true; } /** * Returns the orientation of the plot. * * @return The orientation. */ public PlotOrientation getOrientation() { return PlotOrientation.HORIZONTAL; } /** * Returns the upper bound of the radius axis. * * @return The upper bound. */ public double getMaxRadius() { return this.axis.getUpperBound(); } /** * Translates a (theta, radius) pair into Java2D coordinates. If * radius is less than the lower bound of the axis, then * this method returns the centre point. * * @param angleDegrees the angle in degrees. * @param radius the radius. * @param dataArea the data area. * * @return A point in Java2D space. */ public Point translateValueThetaRadiusToJava2D(double angleDegrees, double radius, Rectangle2D dataArea) { double radians = Math.toRadians(angleDegrees - 90.0); double minx = dataArea.getMinX() + MARGIN; double maxx = dataArea.getMaxX() - MARGIN; double miny = dataArea.getMinY() + MARGIN; double maxy = dataArea.getMaxY() - MARGIN; double lengthX = maxx - minx; double lengthY = maxy - miny; double length = Math.min(lengthX, lengthY); double midX = minx + lengthX / 2.0; double midY = miny + lengthY / 2.0; double axisMin = this.axis.getLowerBound(); double axisMax = getMaxRadius(); double adjustedRadius = Math.max(radius, axisMin); double xv = length / 2.0 * Math.cos(radians); double yv = length / 2.0 * Math.sin(radians); float x = (float) (midX + (xv * (adjustedRadius - axisMin) / (axisMax - axisMin))); float y = (float) (midY + (yv * (adjustedRadius - axisMin) / (axisMax - axisMin))); int ix = Math.round(x); int iy = Math.round(y); Point p = new Point(ix, iy); return p; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/RainbowPalette.java0000644000175000017500000002263111173030414027176 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * RainbowPalette.java * ------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 26-Mar-2003 : Implemented Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart.plot; import java.io.Serializable; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * Contains the data to construct an 8-bit rainbow palette * This come from an old application which ran on 8-bit graphics device. * Thus indexes 0 and 1 were preserved for rendering white and black * respectively. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class RainbowPalette extends ColorPalette implements Serializable { /** For serialization. */ private static final long serialVersionUID = -1906707320728242478L; /** The red values. */ private int[] red = {255, 0, 120, 115, 111, 106, 102, 97, 93, 88, 84, 79, 75, 70, 66, 61, 57, 52, 48, 43, 39, 34, 30, 25, 21, 16, 12, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 10, 14, 19, 23, 28, 32, 37, 41, 46, 50, 55, 59, 64, 68, 73, 77, 82, 86, 91, 95, 100, 104, 109, 113, 118, 123, 127, 132, 136, 141, 145, 150, 154, 159, 163, 168, 172, 177, 181, 186, 190, 195, 199, 204, 208, 213, 217, 222, 226, 231, 235, 240, 244, 249, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}; /** The green values. */ private int[] green = {255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 11, 15, 20, 24, 29, 33, 38, 42, 47, 51, 56, 60, 65, 69, 74, 78, 83, 87, 92, 96, 101, 105, 110, 114, 119, 123, 128, 132, 137, 141, 146, 150, 155, 159, 164, 168, 173, 177, 182, 186, 191, 195, 200, 204, 209, 213, 218, 222, 227, 231, 236, 241, 245, 250, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252, 248, 243, 239, 234, 230, 225, 221, 216, 212, 207, 203, 198, 194, 189, 185, 180, 176, 171, 167, 162, 158, 153, 149, 144, 140, 135, 131, 126, 122, 117, 113, 108, 104, 99, 95, 90, 86, 81, 77, 72, 68, 63, 59, 54, 50, 45, 41, 36, 32, 27, 23, 18, 14, 9, 5, 0}; /** The blue values. */ private int[] blue = {255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 251, 247, 242, 238, 233, 229, 224, 220, 215, 211, 206, 202, 197, 193, 188, 184, 179, 175, 170, 166, 161, 157, 152, 148, 143, 139, 134, 130, 125, 121, 116, 112, 107, 103, 98, 94, 89, 85, 80, 76, 71, 67, 62, 58, 53, 49, 44, 40, 35, 31, 26, 22, 17, 13, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; /** * Default constructor. */ public RainbowPalette() { super(); initialize(); } /** * Intializes the palettes indexes */ public void initialize() { setPaletteName("Rainbow"); this.r = new int[this.red.length]; this.g = new int[this.green.length]; this.b = new int[this.blue.length]; System.arraycopy(this.red, 0, this.r, 0, this.red.length); System.arraycopy(this.green, 0, this.g, 0, this.green.length); System.arraycopy(this.blue, 0, this.b, 0, this.blue.length); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/RingPlot.java0000644000175000017500000004707711173030414026027 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * RingPlot.java * ------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limtied); * Contributor(s): Christoph Beck (bug 2121818); * * Changes * ------- * 08-Nov-2004 : Version 1 (DG); * 22-Feb-2005 : Renamed DonutPlot --> RingPlot (DG); * 06-Jun-2005 : Added default constructor and fixed equals() method to handle * GradientPaint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Dec-2005 : Fixed problem with entity shape (bug 1386328) (DG); * 27-Sep-2006 : Updated drawItem() method for new lookup methods (DG); * 12-Oct-2006 : Added configurable section depth (DG); * 14-Feb-2007 : Added notification in setSectionDepth() method (DG); * 23-Sep-2008 : Fix for bug 2121818 by Christoph Beck (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.PieSectionEntity; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.chart.urls.PieURLGenerator; import org.jfree.data.general.PieDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.Rotation; import org.jfree.util.ShapeUtilities; import org.jfree.util.UnitType; /** * A customised pie plot that leaves a hole in the middle. */ public class RingPlot extends PiePlot implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1556064784129676620L; /** * A flag that controls whether or not separators are drawn between the * sections of the chart. */ private boolean separatorsVisible; /** The stroke used to draw separators. */ private transient Stroke separatorStroke; /** The paint used to draw separators. */ private transient Paint separatorPaint; /** * The length of the inner separator extension (as a percentage of the * depth of the sections). */ private double innerSeparatorExtension; /** * The length of the outer separator extension (as a percentage of the * depth of the sections). */ private double outerSeparatorExtension; /** * The depth of the section as a percentage of the diameter. */ private double sectionDepth; /** * Creates a new plot with a null dataset. */ public RingPlot() { this(null); } /** * Creates a new plot for the specified dataset. * * @param dataset the dataset (null permitted). */ public RingPlot(PieDataset dataset) { super(dataset); this.separatorsVisible = true; this.separatorStroke = new BasicStroke(0.5f); this.separatorPaint = Color.gray; this.innerSeparatorExtension = 0.20; // twenty percent this.outerSeparatorExtension = 0.20; // twenty percent this.sectionDepth = 0.20; // 20% } /** * Returns a flag that indicates whether or not separators are drawn between * the sections in the chart. * * @return A boolean. * * @see #setSeparatorsVisible(boolean) */ public boolean getSeparatorsVisible() { return this.separatorsVisible; } /** * Sets the flag that controls whether or not separators are drawn between * the sections in the chart, and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param visible the flag. * * @see #getSeparatorsVisible() */ public void setSeparatorsVisible(boolean visible) { this.separatorsVisible = visible; fireChangeEvent(); } /** * Returns the separator stroke. * * @return The stroke (never null). * * @see #setSeparatorStroke(Stroke) */ public Stroke getSeparatorStroke() { return this.separatorStroke; } /** * Sets the stroke used to draw the separator between sections and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getSeparatorStroke() */ public void setSeparatorStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.separatorStroke = stroke; fireChangeEvent(); } /** * Returns the separator paint. * * @return The paint (never null). * * @see #setSeparatorPaint(Paint) */ public Paint getSeparatorPaint() { return this.separatorPaint; } /** * Sets the paint used to draw the separator between sections and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getSeparatorPaint() */ public void setSeparatorPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.separatorPaint = paint; fireChangeEvent(); } /** * Returns the length of the inner extension of the separator line that * is drawn between sections, expressed as a percentage of the depth of * the section. * * @return The inner separator extension (as a percentage). * * @see #setInnerSeparatorExtension(double) */ public double getInnerSeparatorExtension() { return this.innerSeparatorExtension; } /** * Sets the length of the inner extension of the separator line that is * drawn between sections, as a percentage of the depth of the * sections, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param percent the percentage. * * @see #getInnerSeparatorExtension() * @see #setOuterSeparatorExtension(double) */ public void setInnerSeparatorExtension(double percent) { this.innerSeparatorExtension = percent; fireChangeEvent(); } /** * Returns the length of the outer extension of the separator line that * is drawn between sections, expressed as a percentage of the depth of * the section. * * @return The outer separator extension (as a percentage). * * @see #setOuterSeparatorExtension(double) */ public double getOuterSeparatorExtension() { return this.outerSeparatorExtension; } /** * Sets the length of the outer extension of the separator line that is * drawn between sections, as a percentage of the depth of the * sections, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param percent the percentage. * * @see #getOuterSeparatorExtension() */ public void setOuterSeparatorExtension(double percent) { this.outerSeparatorExtension = percent; fireChangeEvent(); } /** * Returns the depth of each section, expressed as a percentage of the * plot radius. * * @return The depth of each section. * * @see #setSectionDepth(double) * @since 1.0.3 */ public double getSectionDepth() { return this.sectionDepth; } /** * The section depth is given as percentage of the plot radius. * Specifying 1.0 results in a straightforward pie chart. * * @param sectionDepth the section depth. * * @see #getSectionDepth() * @since 1.0.3 */ public void setSectionDepth(double sectionDepth) { this.sectionDepth = sectionDepth; fireChangeEvent(); } /** * Initialises the plot state (which will store the total of all dataset * values, among other things). This method is called once at the * beginning of each drawing. * * @param g2 the graphics device. * @param plotArea the plot area (null not permitted). * @param plot the plot. * @param index the secondary index (null for primary * renderer). * @param info collects chart rendering information for return to caller. * * @return A state object (maintains state information relevant to one * chart drawing). */ public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea, PiePlot plot, Integer index, PlotRenderingInfo info) { PiePlotState state = super.initialise(g2, plotArea, plot, index, info); state.setPassesRequired(3); return state; } /** * Draws a single data item. * * @param g2 the graphics device (null not permitted). * @param section the section index. * @param dataArea the data plot area. * @param state state information for one chart. * @param currentPass the current pass index. */ protected void drawItem(Graphics2D g2, int section, Rectangle2D dataArea, PiePlotState state, int currentPass) { PieDataset dataset = getDataset(); Number n = dataset.getValue(section); if (n == null) { return; } double value = n.doubleValue(); double angle1 = 0.0; double angle2 = 0.0; Rotation direction = getDirection(); if (direction == Rotation.CLOCKWISE) { angle1 = state.getLatestAngle(); angle2 = angle1 - value / state.getTotal() * 360.0; } else if (direction == Rotation.ANTICLOCKWISE) { angle1 = state.getLatestAngle(); angle2 = angle1 + value / state.getTotal() * 360.0; } else { throw new IllegalStateException("Rotation type not recognised."); } double angle = (angle2 - angle1); if (Math.abs(angle) > getMinimumArcAngleToDraw()) { Comparable key = getSectionKey(section); double ep = 0.0; double mep = getMaximumExplodePercent(); if (mep > 0.0) { ep = getExplodePercent(key) / mep; } Rectangle2D arcBounds = getArcBounds(state.getPieArea(), state.getExplodedPieArea(), angle1, angle, ep); Arc2D.Double arc = new Arc2D.Double(arcBounds, angle1, angle, Arc2D.OPEN); // create the bounds for the inner arc double depth = this.sectionDepth / 2.0; RectangleInsets s = new RectangleInsets(UnitType.RELATIVE, depth, depth, depth, depth); Rectangle2D innerArcBounds = new Rectangle2D.Double(); innerArcBounds.setRect(arcBounds); s.trim(innerArcBounds); // calculate inner arc in reverse direction, for later // GeneralPath construction Arc2D.Double arc2 = new Arc2D.Double(innerArcBounds, angle1 + angle, -angle, Arc2D.OPEN); GeneralPath path = new GeneralPath(); path.moveTo((float) arc.getStartPoint().getX(), (float) arc.getStartPoint().getY()); path.append(arc.getPathIterator(null), false); path.append(arc2.getPathIterator(null), true); path.closePath(); Line2D separator = new Line2D.Double(arc2.getEndPoint(), arc.getStartPoint()); if (currentPass == 0) { Paint shadowPaint = getShadowPaint(); double shadowXOffset = getShadowXOffset(); double shadowYOffset = getShadowYOffset(); if (shadowPaint != null) { Shape shadowArc = ShapeUtilities.createTranslatedShape( path, (float) shadowXOffset, (float) shadowYOffset); g2.setPaint(shadowPaint); g2.fill(shadowArc); } } else if (currentPass == 1) { Paint paint = lookupSectionPaint(key); g2.setPaint(paint); g2.fill(path); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); if (outlinePaint != null && outlineStroke != null) { g2.setPaint(outlinePaint); g2.setStroke(outlineStroke); g2.draw(path); } // add an entity for the pie section if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { String tip = null; PieToolTipGenerator toolTipGenerator = getToolTipGenerator(); if (toolTipGenerator != null) { tip = toolTipGenerator.generateToolTip(dataset, key); } String url = null; PieURLGenerator urlGenerator = getURLGenerator(); if (urlGenerator != null) { url = urlGenerator.generateURL(dataset, key, getPieIndex()); } PieSectionEntity entity = new PieSectionEntity(path, dataset, getPieIndex(), section, key, tip, url); entities.add(entity); } } } else if (currentPass == 2) { if (this.separatorsVisible) { Line2D extendedSeparator = extendLine(separator, this.innerSeparatorExtension, this.outerSeparatorExtension); g2.setStroke(this.separatorStroke); g2.setPaint(this.separatorPaint); g2.draw(extendedSeparator); } } } state.setLatestAngle(angle2); } /** * This method overrides the default value for cases where the ring plot * is very thin. This fixes bug 2121818. * * @return The label link depth, as a percentage of the plot's radius. */ protected double getLabelLinkDepth() { return Math.min(super.getLabelLinkDepth(), getSectionDepth() / 2); } /** * Tests this plot for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof RingPlot)) { return false; } RingPlot that = (RingPlot) obj; if (this.separatorsVisible != that.separatorsVisible) { return false; } if (!ObjectUtilities.equal(this.separatorStroke, that.separatorStroke)) { return false; } if (!PaintUtilities.equal(this.separatorPaint, that.separatorPaint)) { return false; } if (this.innerSeparatorExtension != that.innerSeparatorExtension) { return false; } if (this.outerSeparatorExtension != that.outerSeparatorExtension) { return false; } if (this.sectionDepth != that.sectionDepth) { return false; } return super.equals(obj); } /** * Creates a new line by extending an existing line. * * @param line the line (null not permitted). * @param startPercent the amount to extend the line at the start point * end. * @param endPercent the amount to extend the line at the end point end. * * @return A new line. */ private Line2D extendLine(Line2D line, double startPercent, double endPercent) { if (line == null) { throw new IllegalArgumentException("Null 'line' argument."); } double x1 = line.getX1(); double x2 = line.getX2(); double deltaX = x2 - x1; double y1 = line.getY1(); double y2 = line.getY2(); double deltaY = y2 - y1; x1 = x1 - (startPercent * deltaX); y1 = y1 - (startPercent * deltaY); x2 = x2 + (endPercent * deltaX); y2 = y2 + (endPercent * deltaY); return new Line2D.Double(x1, y1, x2, y2); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.separatorStroke, stream); SerialUtilities.writePaint(this.separatorPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.separatorStroke = SerialUtilities.readStroke(stream); this.separatorPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/SeriesRenderingOrder.java0000644000175000017500000001031211173030414030333 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * SeriesRenderingOrder.java * -------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: Eric Thomas (www.isti.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 21-Apr-2005 : Version 1 contributed by Eric Thomas (ET); * 21-Nov-2007 : Implemented hashCode() (DG); * */ package org.jfree.chart.plot; import java.io.ObjectStreamException; import java.io.Serializable; /** * Defines the tokens that indicate the rendering order for series in a * {@link org.jfree.chart.plot.XYPlot}. */ public final class SeriesRenderingOrder implements Serializable { /** For serialization. */ private static final long serialVersionUID = 209336477448807735L; /** * Render series in the order 0, 1, 2, ..., N-1, where N is the number * of series. */ public static final SeriesRenderingOrder FORWARD = new SeriesRenderingOrder("SeriesRenderingOrder.FORWARD"); /** * Render series in the order N-1, N-2, ..., 2, 1, 0, where N is the * number of series. */ public static final SeriesRenderingOrder REVERSE = new SeriesRenderingOrder("SeriesRenderingOrder.REVERSE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private SeriesRenderingOrder(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string (never null). */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof SeriesRenderingOrder)) { return false; } SeriesRenderingOrder order = (SeriesRenderingOrder) obj; if (!this.name.equals(order.toString())) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(SeriesRenderingOrder.FORWARD)) { return SeriesRenderingOrder.FORWARD; } else if (this.equals(SeriesRenderingOrder.REVERSE)) { return SeriesRenderingOrder.REVERSE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/SpiderWebPlot.java0000644000175000017500000015527111173030414027010 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * SpiderWebPlot.java * ------------------ * (C) Copyright 2005-2008, by Heaps of Flavour Pty Ltd and Contributors. * * Company Info: http://www.i4-talent.com * * Original Author: Don Elliott; * Contributor(s): David Gilbert (for Object Refinery Limited); * Nina Jeliazkova; * * Changes * ------- * 28-Jan-2005 : First cut - missing a few features - still to do: * - needs tooltips/URL/label generator functions * - ticks on axes / background grid? * 31-Jan-2005 : Renamed SpiderWebPlot, added label generator support, and * reformatted for consistency with other source files in * JFreeChart (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 10-Jun-2005 : Added equals() method and fixed serialization (DG); * 16-Jun-2005 : Added default constructor and get/setDataset() * methods (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Apr-2006 : Fixed bug preventing the display of zero values - see patch * 1462727 (DG); * 05-Apr-2006 : Added support for mouse clicks, tool tips and URLs - see patch * 1463455 (DG); * 01-Jun-2006 : Fix bug 1493199, NullPointerException when drawing with null * info (DG); * 05-Feb-2007 : Added attributes for axis stroke and paint, while fixing * bug 1651277, and implemented clone() properly (DG); * 06-Feb-2007 : Changed getPlotValue() to protected, as suggested in bug * 1605202 (DG); * 05-Mar-2007 : Restore clip region correctly (see bug 1667750) (DG); * 18-May-2007 : Set dataset for LegendItem (DG); * 02-Jun-2008 : Fixed bug with chart entities using TableOrder.BY_COLUMN (DG); * 02-Jun-2008 : Fixed bug with null dataset (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; import java.awt.geom.Arc2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.entity.CategoryItemEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintList; import org.jfree.util.PaintUtilities; import org.jfree.util.Rotation; import org.jfree.util.ShapeUtilities; import org.jfree.util.StrokeList; import org.jfree.util.TableOrder; /** * A plot that displays data from a {@link CategoryDataset} in the form of a * "spider web". Multiple series can be plotted on the same axis to allow * easy comparison. This plot doesn't support negative values at present. */ public class SpiderWebPlot extends Plot implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -5376340422031599463L; /** The default head radius percent (currently 1%). */ public static final double DEFAULT_HEAD = 0.01; /** The default axis label gap (currently 10%). */ public static final double DEFAULT_AXIS_LABEL_GAP = 0.10; /** The default interior gap. */ public static final double DEFAULT_INTERIOR_GAP = 0.25; /** The maximum interior gap (currently 40%). */ public static final double MAX_INTERIOR_GAP = 0.40; /** The default starting angle for the radar chart axes. */ public static final double DEFAULT_START_ANGLE = 90.0; /** The default series label font. */ public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default series label paint. */ public static final Paint DEFAULT_LABEL_PAINT = Color.black; /** The default series label background paint. */ public static final Paint DEFAULT_LABEL_BACKGROUND_PAINT = new Color(255, 255, 192); /** The default series label outline paint. */ public static final Paint DEFAULT_LABEL_OUTLINE_PAINT = Color.black; /** The default series label outline stroke. */ public static final Stroke DEFAULT_LABEL_OUTLINE_STROKE = new BasicStroke(0.5f); /** The default series label shadow paint. */ public static final Paint DEFAULT_LABEL_SHADOW_PAINT = Color.lightGray; /** * The default maximum value plotted - forces the plot to evaluate * the maximum from the data passed in */ public static final double DEFAULT_MAX_VALUE = -1.0; /** The head radius as a percentage of the available drawing area. */ protected double headPercent; /** The space left around the outside of the plot as a percentage. */ private double interiorGap; /** The gap between the labels and the axes as a %age of the radius. */ private double axisLabelGap; /** * The paint used to draw the axis lines. * * @since 1.0.4 */ private transient Paint axisLinePaint; /** * The stroke used to draw the axis lines. * * @since 1.0.4 */ private transient Stroke axisLineStroke; /** The dataset. */ private CategoryDataset dataset; /** The maximum value we are plotting against on each category axis */ private double maxValue; /** * The data extract order (BY_ROW or BY_COLUMN). This denotes whether * the data series are stored in rows (in which case the category names are * derived from the column keys) or in columns (in which case the category * names are derived from the row keys). */ private TableOrder dataExtractOrder; /** The starting angle. */ private double startAngle; /** The direction for drawing the radar axis & plots. */ private Rotation direction; /** The legend item shape. */ private transient Shape legendItemShape; /** The paint for ALL series (overrides list). */ private transient Paint seriesPaint; /** The series paint list. */ private PaintList seriesPaintList; /** The base series paint (fallback). */ private transient Paint baseSeriesPaint; /** The outline paint for ALL series (overrides list). */ private transient Paint seriesOutlinePaint; /** The series outline paint list. */ private PaintList seriesOutlinePaintList; /** The base series outline paint (fallback). */ private transient Paint baseSeriesOutlinePaint; /** The outline stroke for ALL series (overrides list). */ private transient Stroke seriesOutlineStroke; /** The series outline stroke list. */ private StrokeList seriesOutlineStrokeList; /** The base series outline stroke (fallback). */ private transient Stroke baseSeriesOutlineStroke; /** The font used to display the category labels. */ private Font labelFont; /** The color used to draw the category labels. */ private transient Paint labelPaint; /** The label generator. */ private CategoryItemLabelGenerator labelGenerator; /** controls if the web polygons are filled or not */ private boolean webFilled = true; /** A tooltip generator for the plot (null permitted). */ private CategoryToolTipGenerator toolTipGenerator; /** A URL generator for the plot (null permitted). */ private CategoryURLGenerator urlGenerator; /** * Creates a default plot with no dataset. */ public SpiderWebPlot() { this(null); } /** * Creates a new spider web plot with the given dataset, with each row * representing a series. * * @param dataset the dataset (null permitted). */ public SpiderWebPlot(CategoryDataset dataset) { this(dataset, TableOrder.BY_ROW); } /** * Creates a new spider web plot with the given dataset. * * @param dataset the dataset. * @param extract controls how data is extracted ({@link TableOrder#BY_ROW} * or {@link TableOrder#BY_COLUMN}). */ public SpiderWebPlot(CategoryDataset dataset, TableOrder extract) { super(); if (extract == null) { throw new IllegalArgumentException("Null 'extract' argument."); } this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this); } this.dataExtractOrder = extract; this.headPercent = DEFAULT_HEAD; this.axisLabelGap = DEFAULT_AXIS_LABEL_GAP; this.axisLinePaint = Color.black; this.axisLineStroke = new BasicStroke(1.0f); this.interiorGap = DEFAULT_INTERIOR_GAP; this.startAngle = DEFAULT_START_ANGLE; this.direction = Rotation.CLOCKWISE; this.maxValue = DEFAULT_MAX_VALUE; this.seriesPaint = null; this.seriesPaintList = new PaintList(); this.baseSeriesPaint = null; this.seriesOutlinePaint = null; this.seriesOutlinePaintList = new PaintList(); this.baseSeriesOutlinePaint = DEFAULT_OUTLINE_PAINT; this.seriesOutlineStroke = null; this.seriesOutlineStrokeList = new StrokeList(); this.baseSeriesOutlineStroke = DEFAULT_OUTLINE_STROKE; this.labelFont = DEFAULT_LABEL_FONT; this.labelPaint = DEFAULT_LABEL_PAINT; this.labelGenerator = new StandardCategoryItemLabelGenerator(); this.legendItemShape = DEFAULT_LEGEND_ITEM_CIRCLE; } /** * Returns a short string describing the type of plot. * * @return The plot type. */ public String getPlotType() { // return localizationResources.getString("Radar_Plot"); return ("Spider Web Plot"); } /** * Returns the dataset. * * @return The dataset (possibly null). * * @see #setDataset(CategoryDataset) */ public CategoryDataset getDataset() { return this.dataset; } /** * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param dataset the dataset (null permitted). * * @see #getDataset() */ public void setDataset(CategoryDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... if (this.dataset != null) { this.dataset.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self to trigger plot change event datasetChanged(new DatasetChangeEvent(this, dataset)); } /** * Method to determine if the web chart is to be filled. * * @return A boolean. * * @see #setWebFilled(boolean) */ public boolean isWebFilled() { return this.webFilled; } /** * Sets the webFilled flag and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param flag the flag. * * @see #isWebFilled() */ public void setWebFilled(boolean flag) { this.webFilled = flag; fireChangeEvent(); } /** * Returns the data extract order (by row or by column). * * @return The data extract order (never null). * * @see #setDataExtractOrder(TableOrder) */ public TableOrder getDataExtractOrder() { return this.dataExtractOrder; } /** * Sets the data extract order (by row or by column) and sends a * {@link PlotChangeEvent}to all registered listeners. * * @param order the order (null not permitted). * * @throws IllegalArgumentException if order is * null. * * @see #getDataExtractOrder() */ public void setDataExtractOrder(TableOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument"); } this.dataExtractOrder = order; fireChangeEvent(); } /** * Returns the head percent. * * @return The head percent. * * @see #setHeadPercent(double) */ public double getHeadPercent() { return this.headPercent; } /** * Sets the head percent and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param percent the percent. * * @see #getHeadPercent() */ public void setHeadPercent(double percent) { this.headPercent = percent; fireChangeEvent(); } /** * Returns the start angle for the first radar axis. *
* This is measured in degrees starting from 3 o'clock (Java Arc2D default) * and measuring anti-clockwise. * * @return The start angle. * * @see #setStartAngle(double) */ public double getStartAngle() { return this.startAngle; } /** * Sets the starting angle and sends a {@link PlotChangeEvent} to all * registered listeners. *

* The initial default value is 90 degrees, which corresponds to 12 o'clock. * A value of zero corresponds to 3 o'clock... this is the encoding used by * Java's Arc2D class. * * @param angle the angle (in degrees). * * @see #getStartAngle() */ public void setStartAngle(double angle) { this.startAngle = angle; fireChangeEvent(); } /** * Returns the maximum value any category axis can take. * * @return The maximum value. * * @see #setMaxValue(double) */ public double getMaxValue() { return this.maxValue; } /** * Sets the maximum value any category axis can take and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param value the maximum value. * * @see #getMaxValue() */ public void setMaxValue(double value) { this.maxValue = value; fireChangeEvent(); } /** * Returns the direction in which the radar axes are drawn * (clockwise or anti-clockwise). * * @return The direction (never null). * * @see #setDirection(Rotation) */ public Rotation getDirection() { return this.direction; } /** * Sets the direction in which the radar axes are drawn and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param direction the direction (null not permitted). * * @see #getDirection() */ public void setDirection(Rotation direction) { if (direction == null) { throw new IllegalArgumentException("Null 'direction' argument."); } this.direction = direction; fireChangeEvent(); } /** * Returns the interior gap, measured as a percentage of the available * drawing space. * * @return The gap (as a percentage of the available drawing space). * * @see #setInteriorGap(double) */ public double getInteriorGap() { return this.interiorGap; } /** * Sets the interior gap and sends a {@link PlotChangeEvent} to all * registered listeners. This controls the space between the edges of the * plot and the plot area itself (the region where the axis labels appear). * * @param percent the gap (as a percentage of the available drawing space). * * @see #getInteriorGap() */ public void setInteriorGap(double percent) { if ((percent < 0.0) || (percent > MAX_INTERIOR_GAP)) { throw new IllegalArgumentException( "Percentage outside valid range."); } if (this.interiorGap != percent) { this.interiorGap = percent; fireChangeEvent(); } } /** * Returns the axis label gap. * * @return The axis label gap. * * @see #setAxisLabelGap(double) */ public double getAxisLabelGap() { return this.axisLabelGap; } /** * Sets the axis label gap and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param gap the gap. * * @see #getAxisLabelGap() */ public void setAxisLabelGap(double gap) { this.axisLabelGap = gap; fireChangeEvent(); } /** * Returns the paint used to draw the axis lines. * * @return The paint used to draw the axis lines (never null). * * @see #setAxisLinePaint(Paint) * @see #getAxisLineStroke() * @since 1.0.4 */ public Paint getAxisLinePaint() { return this.axisLinePaint; } /** * Sets the paint used to draw the axis lines and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getAxisLinePaint() * @since 1.0.4 */ public void setAxisLinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.axisLinePaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the axis lines. * * @return The stroke used to draw the axis lines (never null). * * @see #setAxisLineStroke(Stroke) * @see #getAxisLinePaint() * @since 1.0.4 */ public Stroke getAxisLineStroke() { return this.axisLineStroke; } /** * Sets the stroke used to draw the axis lines and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getAxisLineStroke() * @since 1.0.4 */ public void setAxisLineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.axisLineStroke = stroke; fireChangeEvent(); } //// SERIES PAINT ///////////////////////// /** * Returns the paint for ALL series in the plot. * * @return The paint (possibly null). * * @see #setSeriesPaint(Paint) */ public Paint getSeriesPaint() { return this.seriesPaint; } /** * Sets the paint for ALL series in the plot. If this is set to null * , then a list of paints is used instead (to allow different colors * to be used for each series of the radar group). * * @param paint the paint (null permitted). * * @see #getSeriesPaint() */ public void setSeriesPaint(Paint paint) { this.seriesPaint = paint; fireChangeEvent(); } /** * Returns the paint for the specified series. * * @param series the series index (zero-based). * * @return The paint (never null). * * @see #setSeriesPaint(int, Paint) */ public Paint getSeriesPaint(int series) { // return the override, if there is one... if (this.seriesPaint != null) { return this.seriesPaint; } // otherwise look up the paint list Paint result = this.seriesPaintList.getPaint(series); if (result == null) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { Paint p = supplier.getNextPaint(); this.seriesPaintList.setPaint(series, p); result = p; } else { result = this.baseSeriesPaint; } } return result; } /** * Sets the paint used to fill a series of the radar and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesPaint(int) */ public void setSeriesPaint(int series, Paint paint) { this.seriesPaintList.setPaint(series, paint); fireChangeEvent(); } /** * Returns the base series paint. This is used when no other paint is * available. * * @return The paint (never null). * * @see #setBaseSeriesPaint(Paint) */ public Paint getBaseSeriesPaint() { return this.baseSeriesPaint; } /** * Sets the base series paint. * * @param paint the paint (null not permitted). * * @see #getBaseSeriesPaint() */ public void setBaseSeriesPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseSeriesPaint = paint; fireChangeEvent(); } //// SERIES OUTLINE PAINT //////////////////////////// /** * Returns the outline paint for ALL series in the plot. * * @return The paint (possibly null). */ public Paint getSeriesOutlinePaint() { return this.seriesOutlinePaint; } /** * Sets the outline paint for ALL series in the plot. If this is set to * null, then a list of paints is used instead (to allow * different colors to be used for each series). * * @param paint the paint (null permitted). */ public void setSeriesOutlinePaint(Paint paint) { this.seriesOutlinePaint = paint; fireChangeEvent(); } /** * Returns the paint for the specified series. * * @param series the series index (zero-based). * * @return The paint (never null). */ public Paint getSeriesOutlinePaint(int series) { // return the override, if there is one... if (this.seriesOutlinePaint != null) { return this.seriesOutlinePaint; } // otherwise look up the paint list Paint result = this.seriesOutlinePaintList.getPaint(series); if (result == null) { result = this.baseSeriesOutlinePaint; } return result; } /** * Sets the paint used to fill a series of the radar and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). */ public void setSeriesOutlinePaint(int series, Paint paint) { this.seriesOutlinePaintList.setPaint(series, paint); fireChangeEvent(); } /** * Returns the base series paint. This is used when no other paint is * available. * * @return The paint (never null). */ public Paint getBaseSeriesOutlinePaint() { return this.baseSeriesOutlinePaint; } /** * Sets the base series paint. * * @param paint the paint (null not permitted). */ public void setBaseSeriesOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseSeriesOutlinePaint = paint; fireChangeEvent(); } //// SERIES OUTLINE STROKE ///////////////////// /** * Returns the outline stroke for ALL series in the plot. * * @return The stroke (possibly null). */ public Stroke getSeriesOutlineStroke() { return this.seriesOutlineStroke; } /** * Sets the outline stroke for ALL series in the plot. If this is set to * null, then a list of paints is used instead (to allow * different colors to be used for each series). * * @param stroke the stroke (null permitted). */ public void setSeriesOutlineStroke(Stroke stroke) { this.seriesOutlineStroke = stroke; fireChangeEvent(); } /** * Returns the stroke for the specified series. * * @param series the series index (zero-based). * * @return The stroke (never null). */ public Stroke getSeriesOutlineStroke(int series) { // return the override, if there is one... if (this.seriesOutlineStroke != null) { return this.seriesOutlineStroke; } // otherwise look up the paint list Stroke result = this.seriesOutlineStrokeList.getStroke(series); if (result == null) { result = this.baseSeriesOutlineStroke; } return result; } /** * Sets the stroke used to fill a series of the radar and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). */ public void setSeriesOutlineStroke(int series, Stroke stroke) { this.seriesOutlineStrokeList.setStroke(series, stroke); fireChangeEvent(); } /** * Returns the base series stroke. This is used when no other stroke is * available. * * @return The stroke (never null). */ public Stroke getBaseSeriesOutlineStroke() { return this.baseSeriesOutlineStroke; } /** * Sets the base series stroke. * * @param stroke the stroke (null not permitted). */ public void setBaseSeriesOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.baseSeriesOutlineStroke = stroke; fireChangeEvent(); } /** * Returns the shape used for legend items. * * @return The shape (never null). * * @see #setLegendItemShape(Shape) */ public Shape getLegendItemShape() { return this.legendItemShape; } /** * Sets the shape used for legend items and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param shape the shape (null not permitted). * * @see #getLegendItemShape() */ public void setLegendItemShape(Shape shape) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.legendItemShape = shape; fireChangeEvent(); } /** * Returns the series label font. * * @return The font (never null). * * @see #setLabelFont(Font) */ public Font getLabelFont() { return this.labelFont; } /** * Sets the series label font and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param font the font (null not permitted). * * @see #getLabelFont() */ public void setLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.labelFont = font; fireChangeEvent(); } /** * Returns the series label paint. * * @return The paint (never null). * * @see #setLabelPaint(Paint) */ public Paint getLabelPaint() { return this.labelPaint; } /** * Sets the series label paint and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getLabelPaint() */ public void setLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.labelPaint = paint; fireChangeEvent(); } /** * Returns the label generator. * * @return The label generator (never null). * * @see #setLabelGenerator(CategoryItemLabelGenerator) */ public CategoryItemLabelGenerator getLabelGenerator() { return this.labelGenerator; } /** * Sets the label generator and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param generator the generator (null not permitted). * * @see #getLabelGenerator() */ public void setLabelGenerator(CategoryItemLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } this.labelGenerator = generator; } /** * Returns the tool tip generator for the plot. * * @return The tool tip generator (possibly null). * * @see #setToolTipGenerator(CategoryToolTipGenerator) * * @since 1.0.2 */ public CategoryToolTipGenerator getToolTipGenerator() { return this.toolTipGenerator; } /** * Sets the tool tip generator for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getToolTipGenerator() * * @since 1.0.2 */ public void setToolTipGenerator(CategoryToolTipGenerator generator) { this.toolTipGenerator = generator; fireChangeEvent(); } /** * Returns the URL generator for the plot. * * @return The URL generator (possibly null). * * @see #setURLGenerator(CategoryURLGenerator) * * @since 1.0.2 */ public CategoryURLGenerator getURLGenerator() { return this.urlGenerator; } /** * Sets the URL generator for the plot and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getURLGenerator() * * @since 1.0.2 */ public void setURLGenerator(CategoryURLGenerator generator) { this.urlGenerator = generator; fireChangeEvent(); } /** * Returns a collection of legend items for the radar chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (getDataset() == null) { return result; } List keys = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getRowKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getColumnKeys(); } if (keys != null) { int series = 0; Iterator iterator = keys.iterator(); Shape shape = getLegendItemShape(); while (iterator.hasNext()) { String label = iterator.next().toString(); String description = label; Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); Stroke stroke = getSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, null, null, shape, paint, stroke, outlinePaint); item.setDataset(getDataset()); result.add(item); series++; } } return result; } /** * Returns a cartesian point from a polar angle, length and bounding box * * @param bounds the area inside which the point needs to be. * @param angle the polar angle, in degrees. * @param length the relative length. Given in percent of maximum extend. * * @return The cartesian point. */ protected Point2D getWebPoint(Rectangle2D bounds, double angle, double length) { double angrad = Math.toRadians(angle); double x = Math.cos(angrad) * length * bounds.getWidth() / 2; double y = -Math.sin(angrad) * length * bounds.getHeight() / 2; return new Point2D.Double(bounds.getX() + x + bounds.getWidth() / 2, bounds.getY() + y + bounds.getHeight() / 2); } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); if (info != null) { info.setPlotArea(area); info.setDataArea(area); } drawBackground(g2, area); drawOutline(g2, area); Shape savedClip = g2.getClip(); g2.clip(area); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { int seriesCount = 0, catCount = 0; if (this.dataExtractOrder == TableOrder.BY_ROW) { seriesCount = this.dataset.getRowCount(); catCount = this.dataset.getColumnCount(); } else { seriesCount = this.dataset.getColumnCount(); catCount = this.dataset.getRowCount(); } // ensure we have a maximum value to use on the axes if (this.maxValue == DEFAULT_MAX_VALUE) calculateMaxValue(seriesCount, catCount); // Next, setup the plot area // adjust the plot area by the interior spacing value double gapHorizontal = area.getWidth() * getInteriorGap(); double gapVertical = area.getHeight() * getInteriorGap(); double X = area.getX() + gapHorizontal / 2; double Y = area.getY() + gapVertical / 2; double W = area.getWidth() - gapHorizontal; double H = area.getHeight() - gapVertical; double headW = area.getWidth() * this.headPercent; double headH = area.getHeight() * this.headPercent; // make the chart area a square double min = Math.min(W, H) / 2; X = (X + X + W) / 2 - min; Y = (Y + Y + H) / 2 - min; W = 2 * min; H = 2 * min; Point2D centre = new Point2D.Double(X + W / 2, Y + H / 2); Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H); // draw the axis and category label for (int cat = 0; cat < catCount; cat++) { double angle = getStartAngle() + (getDirection().getFactor() * cat * 360 / catCount); Point2D endPoint = getWebPoint(radarArea, angle, 1); // 1 = end of axis Line2D line = new Line2D.Double(centre, endPoint); g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(line); drawLabel(g2, radarArea, 0.0, cat, angle, 360.0 / catCount); } // Now actually plot each of the series polygons.. for (int series = 0; series < seriesCount; series++) { drawRadarPoly(g2, radarArea, centre, info, series, catCount, headH, headW); } } else { drawNoDataMessage(g2, area); } g2.setClip(savedClip); g2.setComposite(originalComposite); drawOutline(g2, area); } /** * loop through each of the series to get the maximum value * on each category axis * * @param seriesCount the number of series * @param catCount the number of categories */ private void calculateMaxValue(int seriesCount, int catCount) { double v = 0; Number nV = null; for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) { for (int catIndex = 0; catIndex < catCount; catIndex++) { nV = getPlotValue(seriesIndex, catIndex); if (nV != null) { v = nV.doubleValue(); if (v > this.maxValue) { this.maxValue = v; } } } } } /** * Draws a radar plot polygon. * * @param g2 the graphics device. * @param plotArea the area we are plotting in (already adjusted). * @param centre the centre point of the radar axes * @param info chart rendering info. * @param series the series within the dataset we are plotting * @param catCount the number of categories per radar plot * @param headH the data point height * @param headW the data point width */ protected void drawRadarPoly(Graphics2D g2, Rectangle2D plotArea, Point2D centre, PlotRenderingInfo info, int series, int catCount, double headH, double headW) { Polygon polygon = new Polygon(); EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } // plot the data... for (int cat = 0; cat < catCount; cat++) { Number dataValue = getPlotValue(series, cat); if (dataValue != null) { double value = dataValue.doubleValue(); if (value >= 0) { // draw the polygon series... // Finds our starting angle from the centre for this axis double angle = getStartAngle() + (getDirection().getFactor() * cat * 360 / catCount); // The following angle calc will ensure there isn't a top // vertical axis - this may be useful if you don't want any // given criteria to 'appear' move important than the // others.. // + (getDirection().getFactor() // * (cat + 0.5) * 360 / catCount); // find the point at the appropriate distance end point // along the axis/angle identified above and add it to the // polygon Point2D point = getWebPoint(plotArea, angle, value / this.maxValue); polygon.addPoint((int) point.getX(), (int) point.getY()); // put an elipse at the point being plotted.. Paint paint = getSeriesPaint(series); Paint outlinePaint = getSeriesOutlinePaint(series); Stroke outlineStroke = getSeriesOutlineStroke(series); Ellipse2D head = new Ellipse2D.Double(point.getX() - headW / 2, point.getY() - headH / 2, headW, headH); g2.setPaint(paint); g2.fill(head); g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(head); if (entities != null) { int row = 0; int col = 0; if (this.dataExtractOrder == TableOrder.BY_ROW) { row = series; col = cat; } else { row = cat; col = series; } String tip = null; if (this.toolTipGenerator != null) { tip = this.toolTipGenerator.generateToolTip( this.dataset, row, col); } String url = null; if (this.urlGenerator != null) { url = this.urlGenerator.generateURL(this.dataset, row, col); } Shape area = new Rectangle( (int) (point.getX() - headW), (int) (point.getY() - headH), (int) (headW * 2), (int) (headH * 2)); CategoryItemEntity entity = new CategoryItemEntity( area, tip, url, this.dataset, this.dataset.getRowKey(row), this.dataset.getColumnKey(col)); entities.add(entity); } } } } // Plot the polygon Paint paint = getSeriesPaint(series); g2.setPaint(paint); g2.setStroke(getSeriesOutlineStroke(series)); g2.draw(polygon); // Lastly, fill the web polygon if this is required if (this.webFilled) { g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f)); g2.fill(polygon); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); } } /** * Returns the value to be plotted at the interseries of the * series and the category. This allows us to plot * BY_ROW or BY_COLUMN which basically is just * reversing the definition of the categories and data series being * plotted. * * @param series the series to be plotted. * @param cat the category within the series to be plotted. * * @return The value to be plotted (possibly null). * * @see #getDataExtractOrder() */ protected Number getPlotValue(int series, int cat) { Number value = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { value = this.dataset.getValue(series, cat); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { value = this.dataset.getValue(cat, series); } return value; } /** * Draws the label for one axis. * * @param g2 the graphics device. * @param plotArea the plot area * @param value the value of the label (ignored). * @param cat the category (zero-based index). * @param startAngle the starting angle. * @param extent the extent of the arc. */ protected void drawLabel(Graphics2D g2, Rectangle2D plotArea, double value, int cat, double startAngle, double extent) { FontRenderContext frc = g2.getFontRenderContext(); String label = null; if (this.dataExtractOrder == TableOrder.BY_ROW) { // if series are in rows, then the categories are the column keys label = this.labelGenerator.generateColumnLabel(this.dataset, cat); } else { // if series are in columns, then the categories are the row keys label = this.labelGenerator.generateRowLabel(this.dataset, cat); } Rectangle2D labelBounds = getLabelFont().getStringBounds(label, frc); LineMetrics lm = getLabelFont().getLineMetrics(label, frc); double ascent = lm.getAscent(); Point2D labelLocation = calculateLabelLocation(labelBounds, ascent, plotArea, startAngle); Composite saveComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); g2.setPaint(getLabelPaint()); g2.setFont(getLabelFont()); g2.drawString(label, (float) labelLocation.getX(), (float) labelLocation.getY()); g2.setComposite(saveComposite); } /** * Returns the location for a label * * @param labelBounds the label bounds. * @param ascent the ascent (height of font). * @param plotArea the plot area * @param startAngle the start angle for the pie series. * * @return The location for a label. */ protected Point2D calculateLabelLocation(Rectangle2D labelBounds, double ascent, Rectangle2D plotArea, double startAngle) { Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN); Point2D point1 = arc1.getEndPoint(); double deltaX = -(point1.getX() - plotArea.getCenterX()) * this.axisLabelGap; double deltaY = -(point1.getY() - plotArea.getCenterY()) * this.axisLabelGap; double labelX = point1.getX() - deltaX; double labelY = point1.getY() - deltaY; if (labelX < plotArea.getCenterX()) { labelX -= labelBounds.getWidth(); } if (labelX == plotArea.getCenterX()) { labelX -= labelBounds.getWidth() / 2; } if (labelY > plotArea.getCenterY()) { labelY += ascent; } return new Point2D.Double(labelX, labelY); } /** * Tests this plot for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SpiderWebPlot)) { return false; } if (!super.equals(obj)) { return false; } SpiderWebPlot that = (SpiderWebPlot) obj; if (!this.dataExtractOrder.equals(that.dataExtractOrder)) { return false; } if (this.headPercent != that.headPercent) { return false; } if (this.interiorGap != that.interiorGap) { return false; } if (this.startAngle != that.startAngle) { return false; } if (!this.direction.equals(that.direction)) { return false; } if (this.maxValue != that.maxValue) { return false; } if (this.webFilled != that.webFilled) { return false; } if (this.axisLabelGap != that.axisLabelGap) { return false; } if (!PaintUtilities.equal(this.axisLinePaint, that.axisLinePaint)) { return false; } if (!this.axisLineStroke.equals(that.axisLineStroke)) { return false; } if (!ShapeUtilities.equal(this.legendItemShape, that.legendItemShape)) { return false; } if (!PaintUtilities.equal(this.seriesPaint, that.seriesPaint)) { return false; } if (!this.seriesPaintList.equals(that.seriesPaintList)) { return false; } if (!PaintUtilities.equal(this.baseSeriesPaint, that.baseSeriesPaint)) { return false; } if (!PaintUtilities.equal(this.seriesOutlinePaint, that.seriesOutlinePaint)) { return false; } if (!this.seriesOutlinePaintList.equals(that.seriesOutlinePaintList)) { return false; } if (!PaintUtilities.equal(this.baseSeriesOutlinePaint, that.baseSeriesOutlinePaint)) { return false; } if (!ObjectUtilities.equal(this.seriesOutlineStroke, that.seriesOutlineStroke)) { return false; } if (!this.seriesOutlineStrokeList.equals( that.seriesOutlineStrokeList)) { return false; } if (!this.baseSeriesOutlineStroke.equals( that.baseSeriesOutlineStroke)) { return false; } if (!this.labelFont.equals(that.labelFont)) { return false; } if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { return false; } if (!this.labelGenerator.equals(that.labelGenerator)) { return false; } if (!ObjectUtilities.equal(this.toolTipGenerator, that.toolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) { return false; } return true; } /** * Returns a clone of this plot. * * @return A clone of this plot. * * @throws CloneNotSupportedException if the plot cannot be cloned for * any reason. */ public Object clone() throws CloneNotSupportedException { SpiderWebPlot clone = (SpiderWebPlot) super.clone(); clone.legendItemShape = ShapeUtilities.clone(this.legendItemShape); clone.seriesPaintList = (PaintList) this.seriesPaintList.clone(); clone.seriesOutlinePaintList = (PaintList) this.seriesOutlinePaintList.clone(); clone.seriesOutlineStrokeList = (StrokeList) this.seriesOutlineStrokeList.clone(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendItemShape, stream); SerialUtilities.writePaint(this.seriesPaint, stream); SerialUtilities.writePaint(this.baseSeriesPaint, stream); SerialUtilities.writePaint(this.seriesOutlinePaint, stream); SerialUtilities.writePaint(this.baseSeriesOutlinePaint, stream); SerialUtilities.writeStroke(this.seriesOutlineStroke, stream); SerialUtilities.writeStroke(this.baseSeriesOutlineStroke, stream); SerialUtilities.writePaint(this.labelPaint, stream); SerialUtilities.writePaint(this.axisLinePaint, stream); SerialUtilities.writeStroke(this.axisLineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendItemShape = SerialUtilities.readShape(stream); this.seriesPaint = SerialUtilities.readPaint(stream); this.baseSeriesPaint = SerialUtilities.readPaint(stream); this.seriesOutlinePaint = SerialUtilities.readPaint(stream); this.baseSeriesOutlinePaint = SerialUtilities.readPaint(stream); this.seriesOutlineStroke = SerialUtilities.readStroke(stream); this.baseSeriesOutlineStroke = SerialUtilities.readStroke(stream); this.labelPaint = SerialUtilities.readPaint(stream); this.axisLinePaint = SerialUtilities.readPaint(stream); this.axisLineStroke = SerialUtilities.readStroke(stream); if (this.dataset != null) { this.dataset.addChangeListener(this); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ThermometerPlot.java0000644000175000017500000016275011173030414027417 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ThermometerPlot.java * -------------------- * * (C) Copyright 2000-2008, by Bryan Scott and Contributors. * * Original Author: Bryan Scott (based on MeterPlot by Hari). * Contributor(s): David Gilbert (for Object Refinery Limited). * Arnaud Lelievre; * Julien Henry (see patch 1769088) (DG); * * Changes * ------- * 11-Apr-2002 : Version 1, contributed by Bryan Scott; * 15-Apr-2002 : Changed to implement VerticalValuePlot; * 29-Apr-2002 : Added getVerticalValueAxis() method (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 17-Sep-2002 : Reviewed with Checkstyle utility (DG); * 18-Sep-2002 : Extensive changes made to API, to iron out bugs and * inconsistencies (DG); * 13-Oct-2002 : Corrected error datasetChanged which would generate exceptions * when value set to null (BRS). * 23-Jan-2003 : Removed one constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 02-Jun-2003 : Removed test for compatible range axis (DG); * 01-Jul-2003 : Added additional check in draw method to ensure value not * null (BRS); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 29-Sep-2003 : Updated draw to set value of cursor to non-zero and allow * painting of axis. An incomplete fix and needs to be set for * left or right drawing (BRS); * 19-Nov-2003 : Added support for value labels to be displayed left of the * thermometer * 19-Nov-2003 : Improved axis drawing (now default axis does not draw axis line * and is closer to the bulb). Added support for the positioning * of the axis to the left or right of the bulb. (BRS); * 03-Dec-2003 : Directly mapped deprecated setData()/getData() method to * get/setDataset() (TM); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 07-Apr-2004 : Changed string width calculation (DG); * 12-Nov-2004 : Implemented the new Zoomable interface (DG); * 06-Jan-2004 : Added getOrientation() method (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 29-Mar-2005 : Fixed equals() method (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 09-Jun-2005 : Fixed more bugs in equals() method (DG); * 10-Jun-2005 : Fixed minor bug in setDisplayRange() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 14-Nov-2006 : Fixed margin when drawing (DG); * 03-May-2007 : Fixed datasetChanged() to handle null dataset, added null * argument check and event notification to setRangeAxis(), * added null argument check to setPadding(), setValueFont(), * setValuePaint(), setValueFormat() and setMercuryPaint(), * deprecated get/setShowValueLines(), deprecated * getMinimum/MaximumVerticalDataValue(), and fixed serialization * bug (DG); * 24-Sep-2007 : Implemented new methods in Zoomable interface (DG); * 08-Oct-2007 : Added attributes for thermometer dimensions - see patch 1769088 * by Julien Henry (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Arrays; import java.util.ResourceBundle; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DefaultValueDataset; import org.jfree.data.general.ValueDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.UnitType; /** * A plot that displays a single value (from a {@link ValueDataset}) in a * thermometer type display. *

* This plot supports a number of options: *

    *
  1. three sub-ranges which could be viewed as 'Normal', 'Warning' * and 'Critical' ranges.
  2. *
  3. the thermometer can be run in two modes: *
      *
    • fixed range, or
    • *
    • range adjusts to current sub-range.
    • *
    *
  4. *
  5. settable units to be displayed.
  6. *
  7. settable display location for the value text.
  8. *
*/ public class ThermometerPlot extends Plot implements ValueAxisPlot, Zoomable, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 4087093313147984390L; /** A constant for unit type 'None'. */ public static final int UNITS_NONE = 0; /** A constant for unit type 'Fahrenheit'. */ public static final int UNITS_FAHRENHEIT = 1; /** A constant for unit type 'Celcius'. */ public static final int UNITS_CELCIUS = 2; /** A constant for unit type 'Kelvin'. */ public static final int UNITS_KELVIN = 3; /** A constant for the value label position (no label). */ public static final int NONE = 0; /** A constant for the value label position (right of the thermometer). */ public static final int RIGHT = 1; /** A constant for the value label position (left of the thermometer). */ public static final int LEFT = 2; /** A constant for the value label position (in the thermometer bulb). */ public static final int BULB = 3; /** A constant for the 'normal' range. */ public static final int NORMAL = 0; /** A constant for the 'warning' range. */ public static final int WARNING = 1; /** A constant for the 'critical' range. */ public static final int CRITICAL = 2; /** * The bulb radius. * * @deprecated As of 1.0.7, use {@link #getBulbRadius()}. */ protected static final int BULB_RADIUS = 40; /** * The bulb diameter. * * @deprecated As of 1.0.7, use {@link #getBulbDiameter()}. */ protected static final int BULB_DIAMETER = BULB_RADIUS * 2; /** * The column radius. * * @deprecated As of 1.0.7, use {@link #getColumnRadius()}. */ protected static final int COLUMN_RADIUS = 20; /** * The column diameter. * * @deprecated As of 1.0.7, use {@link #getColumnDiameter()}. */ protected static final int COLUMN_DIAMETER = COLUMN_RADIUS * 2; /** * The gap radius. * * @deprecated As of 1.0.7, use {@link #getGap()}. */ protected static final int GAP_RADIUS = 5; /** * The gap diameter. * * @deprecated As of 1.0.7, use {@link #getGap()} times two. */ protected static final int GAP_DIAMETER = GAP_RADIUS * 2; /** The axis gap. */ protected static final int AXIS_GAP = 10; /** The unit strings. */ protected static final String[] UNITS = {"", "\u00B0F", "\u00B0C", "\u00B0K"}; /** Index for low value in subrangeInfo matrix. */ protected static final int RANGE_LOW = 0; /** Index for high value in subrangeInfo matrix. */ protected static final int RANGE_HIGH = 1; /** Index for display low value in subrangeInfo matrix. */ protected static final int DISPLAY_LOW = 2; /** Index for display high value in subrangeInfo matrix. */ protected static final int DISPLAY_HIGH = 3; /** The default lower bound. */ protected static final double DEFAULT_LOWER_BOUND = 0.0; /** The default upper bound. */ protected static final double DEFAULT_UPPER_BOUND = 100.0; /** * The default bulb radius. * * @since 1.0.7 */ protected static final int DEFAULT_BULB_RADIUS = 40; /** * The default column radius. * * @since 1.0.7 */ protected static final int DEFAULT_COLUMN_RADIUS = 20; /** * The default gap between the outlines representing the thermometer. * * @since 1.0.7 */ protected static final int DEFAULT_GAP = 5; /** The dataset for the plot. */ private ValueDataset dataset; /** The range axis. */ private ValueAxis rangeAxis; /** The lower bound for the thermometer. */ private double lowerBound = DEFAULT_LOWER_BOUND; /** The upper bound for the thermometer. */ private double upperBound = DEFAULT_UPPER_BOUND; /** * The value label position. * * @since 1.0.7 */ private int bulbRadius = DEFAULT_BULB_RADIUS; /** * The column radius. * * @since 1.0.7 */ private int columnRadius = DEFAULT_COLUMN_RADIUS; /** * The gap between the two outlines the represent the thermometer. * * @since 1.0.7 */ private int gap = DEFAULT_GAP; /** * Blank space inside the plot area around the outside of the thermometer. */ private RectangleInsets padding; /** Stroke for drawing the thermometer */ private transient Stroke thermometerStroke = new BasicStroke(1.0f); /** Paint for drawing the thermometer */ private transient Paint thermometerPaint = Color.black; /** The display units */ private int units = UNITS_CELCIUS; /** The value label position. */ private int valueLocation = BULB; /** The position of the axis **/ private int axisLocation = LEFT; /** The font to write the value in */ private Font valueFont = new Font("SansSerif", Font.BOLD, 16); /** Colour that the value is written in */ private transient Paint valuePaint = Color.white; /** Number format for the value */ private NumberFormat valueFormat = new DecimalFormat(); /** The default paint for the mercury in the thermometer. */ private transient Paint mercuryPaint = Color.lightGray; /** A flag that controls whether value lines are drawn. */ private boolean showValueLines = false; /** The display sub-range. */ private int subrange = -1; /** The start and end values for the subranges. */ private double[][] subrangeInfo = { {0.0, 50.0, 0.0, 50.0}, {50.0, 75.0, 50.0, 75.0}, {75.0, 100.0, 75.0, 100.0} }; /** * A flag that controls whether or not the axis range adjusts to the * sub-ranges. */ private boolean followDataInSubranges = false; /** * A flag that controls whether or not the mercury paint changes with * the subranges. */ private boolean useSubrangePaint = true; /** Paint for each range */ private transient Paint[] subrangePaint = {Color.green, Color.orange, Color.red}; /** A flag that controls whether the sub-range indicators are visible. */ private boolean subrangeIndicatorsVisible = true; /** The stroke for the sub-range indicators. */ private transient Stroke subrangeIndicatorStroke = new BasicStroke(2.0f); /** The range indicator stroke. */ private transient Stroke rangeIndicatorStroke = new BasicStroke(3.0f); /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** * Creates a new thermometer plot. */ public ThermometerPlot() { this(new DefaultValueDataset()); } /** * Creates a new thermometer plot, using default attributes where necessary. * * @param dataset the data set. */ public ThermometerPlot(ValueDataset dataset) { super(); this.padding = new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, 0.05); this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this); } NumberAxis axis = new NumberAxis(null); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); axis.setAxisLineVisible(false); axis.setPlot(this); axis.addChangeListener(this); this.rangeAxis = axis; setAxisRange(); } /** * Returns the dataset for the plot. * * @return The dataset (possibly null). * * @see #setDataset(ValueDataset) */ public ValueDataset getDataset() { return this.dataset; } /** * Sets the dataset for the plot, replacing the existing dataset if there * is one, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param dataset the dataset (null permitted). * * @see #getDataset() */ public void setDataset(ValueDataset dataset) { // if there is an existing dataset, remove the plot from the list // of change listeners... ValueDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the range axis. * * @return The range axis (never null). * * @see #setRangeAxis(ValueAxis) */ public ValueAxis getRangeAxis() { return this.rangeAxis; } /** * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the new axis (null not permitted). * * @see #getRangeAxis() */ public void setRangeAxis(ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } // plot is registered as a listener with the existing axis... this.rangeAxis.removeChangeListener(this); axis.setPlot(this); axis.addChangeListener(this); this.rangeAxis = axis; fireChangeEvent(); } /** * Returns the lower bound for the thermometer. The data value can be set * lower than this, but it will not be shown in the thermometer. * * @return The lower bound. * * @see #setLowerBound(double) */ public double getLowerBound() { return this.lowerBound; } /** * Sets the lower bound for the thermometer. * * @param lower the lower bound. * * @see #getLowerBound() */ public void setLowerBound(double lower) { this.lowerBound = lower; setAxisRange(); } /** * Returns the upper bound for the thermometer. The data value can be set * higher than this, but it will not be shown in the thermometer. * * @return The upper bound. * * @see #setUpperBound(double) */ public double getUpperBound() { return this.upperBound; } /** * Sets the upper bound for the thermometer. * * @param upper the upper bound. * * @see #getUpperBound() */ public void setUpperBound(double upper) { this.upperBound = upper; setAxisRange(); } /** * Sets the lower and upper bounds for the thermometer. * * @param lower the lower bound. * @param upper the upper bound. */ public void setRange(double lower, double upper) { this.lowerBound = lower; this.upperBound = upper; setAxisRange(); } /** * Returns the padding for the thermometer. This is the space inside the * plot area. * * @return The padding (never null). * * @see #setPadding(RectangleInsets) */ public RectangleInsets getPadding() { return this.padding; } /** * Sets the padding for the thermometer and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param padding the padding (null not permitted). * * @see #getPadding() */ public void setPadding(RectangleInsets padding) { if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } this.padding = padding; fireChangeEvent(); } /** * Returns the stroke used to draw the thermometer outline. * * @return The stroke (never null). * * @see #setThermometerStroke(Stroke) * @see #getThermometerPaint() */ public Stroke getThermometerStroke() { return this.thermometerStroke; } /** * Sets the stroke used to draw the thermometer outline and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param s the new stroke (null ignored). * * @see #getThermometerStroke() */ public void setThermometerStroke(Stroke s) { if (s != null) { this.thermometerStroke = s; fireChangeEvent(); } } /** * Returns the paint used to draw the thermometer outline. * * @return The paint (never null). * * @see #setThermometerPaint(Paint) * @see #getThermometerStroke() */ public Paint getThermometerPaint() { return this.thermometerPaint; } /** * Sets the paint used to draw the thermometer outline and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the new paint (null ignored). * * @see #getThermometerPaint() */ public void setThermometerPaint(Paint paint) { if (paint != null) { this.thermometerPaint = paint; fireChangeEvent(); } } /** * Returns a code indicating the unit display type. This is one of * {@link #UNITS_NONE}, {@link #UNITS_FAHRENHEIT}, {@link #UNITS_CELCIUS} * and {@link #UNITS_KELVIN}. * * @return The units type. * * @see #setUnits(int) */ public int getUnits() { return this.units; } /** * Sets the units to be displayed in the thermometer. Use one of the * following constants: * *
    *
  • UNITS_NONE : no units displayed.
  • *
  • UNITS_FAHRENHEIT : units displayed in Fahrenheit.
  • *
  • UNITS_CELCIUS : units displayed in Celcius.
  • *
  • UNITS_KELVIN : units displayed in Kelvin.
  • *
* * @param u the new unit type. * * @see #getUnits() */ public void setUnits(int u) { if ((u >= 0) && (u < UNITS.length)) { if (this.units != u) { this.units = u; fireChangeEvent(); } } } /** * Sets the unit type. * * @param u the unit type (null ignored). * * @deprecated Use setUnits(int) instead. Deprecated as of version 1.0.6, * because this method is a little obscure and redundant anyway. */ public void setUnits(String u) { if (u == null) { return; } u = u.toUpperCase().trim(); for (int i = 0; i < UNITS.length; ++i) { if (u.equals(UNITS[i].toUpperCase().trim())) { setUnits(i); i = UNITS.length; } } } /** * Returns a code indicating the location at which the value label is * displayed. * * @return The location (one of {@link #NONE}, {@link #RIGHT}, * {@link #LEFT} and {@link #BULB}.). */ public int getValueLocation() { return this.valueLocation; } /** * Sets the location at which the current value is displayed and sends a * {@link PlotChangeEvent} to all registered listeners. *

* The location can be one of the constants: * NONE, * RIGHT * LEFT and * BULB. * * @param location the location. */ public void setValueLocation(int location) { if ((location >= 0) && (location < 4)) { this.valueLocation = location; fireChangeEvent(); } else { throw new IllegalArgumentException("Location not recognised."); } } /** * Returns the axis location. * * @return The location (one of {@link #NONE}, {@link #LEFT} and * {@link #RIGHT}). * * @see #setAxisLocation(int) */ public int getAxisLocation() { return this.axisLocation; } /** * Sets the location at which the axis is displayed relative to the * thermometer, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param location the location (one of {@link #NONE}, {@link #LEFT} and * {@link #RIGHT}). * * @see #getAxisLocation() */ public void setAxisLocation(int location) { if ((location >= 0) && (location < 3)) { this.axisLocation = location; fireChangeEvent(); } else { throw new IllegalArgumentException("Location not recognised."); } } /** * Gets the font used to display the current value. * * @return The font. * * @see #setValueFont(Font) */ public Font getValueFont() { return this.valueFont; } /** * Sets the font used to display the current value. * * @param f the new font (null not permitted). * * @see #getValueFont() */ public void setValueFont(Font f) { if (f == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (!this.valueFont.equals(f)) { this.valueFont = f; fireChangeEvent(); } } /** * Gets the paint used to display the current value. * * @return The paint. * * @see #setValuePaint(Paint) */ public Paint getValuePaint() { return this.valuePaint; } /** * Sets the paint used to display the current value and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the new paint (null not permitted). * * @see #getValuePaint() */ public void setValuePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (!this.valuePaint.equals(paint)) { this.valuePaint = paint; fireChangeEvent(); } } // FIXME: No getValueFormat() method? /** * Sets the formatter for the value label and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param formatter the new formatter (null not permitted). */ public void setValueFormat(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.valueFormat = formatter; fireChangeEvent(); } /** * Returns the default mercury paint. * * @return The paint (never null). * * @see #setMercuryPaint(Paint) */ public Paint getMercuryPaint() { return this.mercuryPaint; } /** * Sets the default mercury paint and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param paint the new paint (null not permitted). * * @see #getMercuryPaint() */ public void setMercuryPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.mercuryPaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether not value lines are displayed. * * @return The flag. * * @see #setShowValueLines(boolean) * * @deprecated This flag doesn't do anything useful/visible. Deprecated * as of version 1.0.6. */ public boolean getShowValueLines() { return this.showValueLines; } /** * Sets the display as to whether to show value lines in the output. * * @param b Whether to show value lines in the thermometer * * @see #getShowValueLines() * * @deprecated This flag doesn't do anything useful/visible. Deprecated * as of version 1.0.6. */ public void setShowValueLines(boolean b) { this.showValueLines = b; fireChangeEvent(); } /** * Sets information for a particular range. * * @param range the range to specify information about. * @param low the low value for the range * @param hi the high value for the range */ public void setSubrangeInfo(int range, double low, double hi) { setSubrangeInfo(range, low, hi, low, hi); } /** * Sets the subrangeInfo attribute of the ThermometerPlot object * * @param range the new rangeInfo value. * @param rangeLow the new rangeInfo value * @param rangeHigh the new rangeInfo value * @param displayLow the new rangeInfo value * @param displayHigh the new rangeInfo value */ public void setSubrangeInfo(int range, double rangeLow, double rangeHigh, double displayLow, double displayHigh) { if ((range >= 0) && (range < 3)) { setSubrange(range, rangeLow, rangeHigh); setDisplayRange(range, displayLow, displayHigh); setAxisRange(); fireChangeEvent(); } } /** * Sets the bounds for a subrange. * * @param range the range type. * @param low the low value. * @param high the high value. */ public void setSubrange(int range, double low, double high) { if ((range >= 0) && (range < 3)) { this.subrangeInfo[range][RANGE_HIGH] = high; this.subrangeInfo[range][RANGE_LOW] = low; } } /** * Sets the displayed bounds for a sub range. * * @param range the range type. * @param low the low value. * @param high the high value. */ public void setDisplayRange(int range, double low, double high) { if ((range >= 0) && (range < this.subrangeInfo.length) && isValidNumber(high) && isValidNumber(low)) { if (high > low) { this.subrangeInfo[range][DISPLAY_HIGH] = high; this.subrangeInfo[range][DISPLAY_LOW] = low; } else { this.subrangeInfo[range][DISPLAY_HIGH] = low; this.subrangeInfo[range][DISPLAY_LOW] = high; } } } /** * Gets the paint used for a particular subrange. * * @param range the range (. * * @return The paint. * * @see #setSubrangePaint(int, Paint) */ public Paint getSubrangePaint(int range) { if ((range >= 0) && (range < this.subrangePaint.length)) { return this.subrangePaint[range]; } else { return this.mercuryPaint; } } /** * Sets the paint to be used for a subrange and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param range the range (0, 1 or 2). * @param paint the paint to be applied (null not permitted). * * @see #getSubrangePaint(int) */ public void setSubrangePaint(int range, Paint paint) { if ((range >= 0) && (range < this.subrangePaint.length) && (paint != null)) { this.subrangePaint[range] = paint; fireChangeEvent(); } } /** * Returns a flag that controls whether or not the thermometer axis zooms * to display the subrange within which the data value falls. * * @return The flag. */ public boolean getFollowDataInSubranges() { return this.followDataInSubranges; } /** * Sets the flag that controls whether or not the thermometer axis zooms * to display the subrange within which the data value falls. * * @param flag the flag. */ public void setFollowDataInSubranges(boolean flag) { this.followDataInSubranges = flag; fireChangeEvent(); } /** * Returns a flag that controls whether or not the mercury color changes * for each subrange. * * @return The flag. * * @see #setUseSubrangePaint(boolean) */ public boolean getUseSubrangePaint() { return this.useSubrangePaint; } /** * Sets the range colour change option. * * @param flag the new range colour change option * * @see #getUseSubrangePaint() */ public void setUseSubrangePaint(boolean flag) { this.useSubrangePaint = flag; fireChangeEvent(); } /** * Returns the bulb radius, in Java2D units. * @return The bulb radius. * * @since 1.0.7 */ public int getBulbRadius() { return this.bulbRadius; } /** * Sets the bulb radius (in Java2D units) and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param r the new radius (in Java2D units). * * @see #getBulbRadius() * * @since 1.0.7 */ public void setBulbRadius(int r) { this.bulbRadius = r; fireChangeEvent(); } /** * Returns the bulb diameter, which is always twice the value returned * by {@link #getBulbRadius()}. * * @return The bulb diameter. * * @since 1.0.7 */ public int getBulbDiameter() { return getBulbRadius() * 2; } /** * Returns the column radius, in Java2D units. * * @return The column radius. * * @see #setColumnRadius(int) * * @since 1.0.7 */ public int getColumnRadius() { return this.columnRadius; } /** * Sets the column radius (in Java2D units) and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param r the new radius. * * @see #getColumnRadius() * * @since 1.0.7 */ public void setColumnRadius(int r) { this.columnRadius = r; fireChangeEvent(); } /** * Returns the column diameter, which is always twice the value returned * by {@link #getColumnRadius()}. * * @return The column diameter. * * @since 1.0.7 */ public int getColumnDiameter() { return getColumnRadius() * 2; } /** * Returns the gap, in Java2D units, between the two outlines that * represent the thermometer. * * @return The gap. * * @see #setGap(int) * * @since 1.0.7 */ public int getGap() { return this.gap; } /** * Sets the gap (in Java2D units) between the two outlines that represent * the thermometer, and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param gap the new gap. * * @see #getGap() * * @since 1.0.7 */ public void setGap(int gap) { this.gap = gap; fireChangeEvent(); } /** * Draws the plot on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area within which the plot should be drawn. * @param anchor the anchor point (null permitted). * @param parentState the state from the parent plot, if there is one. * @param info collects info about the drawing. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { RoundRectangle2D outerStem = new RoundRectangle2D.Double(); RoundRectangle2D innerStem = new RoundRectangle2D.Double(); RoundRectangle2D mercuryStem = new RoundRectangle2D.Double(); Ellipse2D outerBulb = new Ellipse2D.Double(); Ellipse2D innerBulb = new Ellipse2D.Double(); String temp = null; FontMetrics metrics = null; if (info != null) { info.setPlotArea(area); } // adjust for insets... RectangleInsets insets = getInsets(); insets.trim(area); drawBackground(g2, area); // adjust for padding... Rectangle2D interior = (Rectangle2D) area.clone(); this.padding.trim(interior); int midX = (int) (interior.getX() + (interior.getWidth() / 2)); int midY = (int) (interior.getY() + (interior.getHeight() / 2)); int stemTop = (int) (interior.getMinY() + getBulbRadius()); int stemBottom = (int) (interior.getMaxY() - getBulbDiameter()); Rectangle2D dataArea = new Rectangle2D.Double(midX - getColumnRadius(), stemTop, getColumnRadius(), stemBottom - stemTop); outerBulb.setFrame(midX - getBulbRadius(), stemBottom, getBulbDiameter(), getBulbDiameter()); outerStem.setRoundRect(midX - getColumnRadius(), interior.getMinY(), getColumnDiameter(), stemBottom + getBulbDiameter() - stemTop, getColumnDiameter(), getColumnDiameter()); Area outerThermometer = new Area(outerBulb); Area tempArea = new Area(outerStem); outerThermometer.add(tempArea); innerBulb.setFrame(midX - getBulbRadius() + getGap(), stemBottom + getGap(), getBulbDiameter() - getGap() * 2, getBulbDiameter() - getGap() * 2); innerStem.setRoundRect(midX - getColumnRadius() + getGap(), interior.getMinY() + getGap(), getColumnDiameter() - getGap() * 2, stemBottom + getBulbDiameter() - getGap() * 2 - stemTop, getColumnDiameter() - getGap() * 2, getColumnDiameter() - getGap() * 2); Area innerThermometer = new Area(innerBulb); tempArea = new Area(innerStem); innerThermometer.add(tempArea); if ((this.dataset != null) && (this.dataset.getValue() != null)) { double current = this.dataset.getValue().doubleValue(); double ds = this.rangeAxis.valueToJava2D(current, dataArea, RectangleEdge.LEFT); int i = getColumnDiameter() - getGap() * 2; // already calculated int j = getColumnRadius() - getGap(); // already calculated int l = (i / 2); int k = (int) Math.round(ds); if (k < (getGap() + interior.getMinY())) { k = (int) (getGap() + interior.getMinY()); l = getBulbRadius(); } Area mercury = new Area(innerBulb); if (k < (stemBottom + getBulbRadius())) { mercuryStem.setRoundRect(midX - j, k, i, (stemBottom + getBulbRadius()) - k, l, l); tempArea = new Area(mercuryStem); mercury.add(tempArea); } g2.setPaint(getCurrentPaint()); g2.fill(mercury); // draw range indicators... if (this.subrangeIndicatorsVisible) { g2.setStroke(this.subrangeIndicatorStroke); Range range = this.rangeAxis.getRange(); // draw start of normal range double value = this.subrangeInfo[NORMAL][RANGE_LOW]; if (range.contains(value)) { double x = midX + getColumnRadius() + 2; double y = this.rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(x, y, x + 10, y); g2.setPaint(this.subrangePaint[NORMAL]); g2.draw(line); } // draw start of warning range value = this.subrangeInfo[WARNING][RANGE_LOW]; if (range.contains(value)) { double x = midX + getColumnRadius() + 2; double y = this.rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(x, y, x + 10, y); g2.setPaint(this.subrangePaint[WARNING]); g2.draw(line); } // draw start of critical range value = this.subrangeInfo[CRITICAL][RANGE_LOW]; if (range.contains(value)) { double x = midX + getColumnRadius() + 2; double y = this.rangeAxis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(x, y, x + 10, y); g2.setPaint(this.subrangePaint[CRITICAL]); g2.draw(line); } } // draw the axis... if ((this.rangeAxis != null) && (this.axisLocation != NONE)) { int drawWidth = AXIS_GAP; if (this.showValueLines) { drawWidth += getColumnDiameter(); } Rectangle2D drawArea; double cursor = 0; switch (this.axisLocation) { case RIGHT: cursor = midX + getColumnRadius(); drawArea = new Rectangle2D.Double(cursor, stemTop, drawWidth, (stemBottom - stemTop + 1)); this.rangeAxis.draw(g2, cursor, area, drawArea, RectangleEdge.RIGHT, null); break; case LEFT: default: //cursor = midX - COLUMN_RADIUS - AXIS_GAP; cursor = midX - getColumnRadius(); drawArea = new Rectangle2D.Double(cursor, stemTop, drawWidth, (stemBottom - stemTop + 1)); this.rangeAxis.draw(g2, cursor, area, drawArea, RectangleEdge.LEFT, null); break; } } // draw text value on screen g2.setFont(this.valueFont); g2.setPaint(this.valuePaint); metrics = g2.getFontMetrics(); switch (this.valueLocation) { case RIGHT: g2.drawString(this.valueFormat.format(current), midX + getColumnRadius() + getGap(), midY); break; case LEFT: String valueString = this.valueFormat.format(current); int stringWidth = metrics.stringWidth(valueString); g2.drawString(valueString, midX - getColumnRadius() - getGap() - stringWidth, midY); break; case BULB: temp = this.valueFormat.format(current); i = metrics.stringWidth(temp) / 2; g2.drawString(temp, midX - i, stemBottom + getBulbRadius() + getGap()); break; default: } /***/ } g2.setPaint(this.thermometerPaint); g2.setFont(this.valueFont); // draw units indicator metrics = g2.getFontMetrics(); int tickX1 = midX - getColumnRadius() - getGap() * 2 - metrics.stringWidth(UNITS[this.units]); if (tickX1 > area.getMinX()) { g2.drawString(UNITS[this.units], tickX1, (int) (area.getMinY() + 20)); } // draw thermometer outline g2.setStroke(this.thermometerStroke); g2.draw(outerThermometer); g2.draw(innerThermometer); drawOutline(g2, area); } /** * A zoom method that does nothing. Plots are required to support the * zoom operation. In the case of a thermometer chart, it doesn't make * sense to zoom in or out, so the method is empty. * * @param percent the zoom percentage. */ public void zoom(double percent) { // intentionally blank } /** * Returns a short string describing the type of plot. * * @return A short string describing the type of plot. */ public String getPlotType() { return localizationResources.getString("Thermometer_Plot"); } /** * Checks to see if a new value means the axis range needs adjusting. * * @param event the dataset change event. */ public void datasetChanged(DatasetChangeEvent event) { if (this.dataset != null) { Number vn = this.dataset.getValue(); if (vn != null) { double value = vn.doubleValue(); if (inSubrange(NORMAL, value)) { this.subrange = NORMAL; } else if (inSubrange(WARNING, value)) { this.subrange = WARNING; } else if (inSubrange(CRITICAL, value)) { this.subrange = CRITICAL; } else { this.subrange = -1; } setAxisRange(); } } super.datasetChanged(event); } /** * Returns the minimum value in either the domain or the range, whichever * is displayed against the vertical axis for the particular type of plot * implementing this interface. * * @return The minimum value in either the domain or the range. * * @deprecated This method is not used. Officially deprecated in version * 1.0.6. */ public Number getMinimumVerticalDataValue() { return new Double(this.lowerBound); } /** * Returns the maximum value in either the domain or the range, whichever * is displayed against the vertical axis for the particular type of plot * implementing this interface. * * @return The maximum value in either the domain or the range * * @deprecated This method is not used. Officially deprecated in version * 1.0.6. */ public Number getMaximumVerticalDataValue() { return new Double(this.upperBound); } /** * Returns the data range. * * @param axis the axis. * * @return The range of data displayed. */ public Range getDataRange(ValueAxis axis) { return new Range(this.lowerBound, this.upperBound); } /** * Sets the axis range to the current values in the rangeInfo array. */ protected void setAxisRange() { if ((this.subrange >= 0) && (this.followDataInSubranges)) { this.rangeAxis.setRange( new Range(this.subrangeInfo[this.subrange][DISPLAY_LOW], this.subrangeInfo[this.subrange][DISPLAY_HIGH])); } else { this.rangeAxis.setRange(this.lowerBound, this.upperBound); } } /** * Returns the legend items for the plot. * * @return null. */ public LegendItemCollection getLegendItems() { return null; } /** * Returns the orientation of the plot. * * @return The orientation (always {@link PlotOrientation#VERTICAL}). */ public PlotOrientation getOrientation() { return PlotOrientation.VERTICAL; } /** * Determine whether a number is valid and finite. * * @param d the number to be tested. * * @return true if the number is valid and finite, and * false otherwise. */ protected static boolean isValidNumber(double d) { return (!(Double.isNaN(d) || Double.isInfinite(d))); } /** * Returns true if the value is in the specified range, and false otherwise. * * @param subrange the subrange. * @param value the value to check. * * @return A boolean. */ private boolean inSubrange(int subrange, double value) { return (value > this.subrangeInfo[subrange][RANGE_LOW] && value <= this.subrangeInfo[subrange][RANGE_HIGH]); } /** * Returns the mercury paint corresponding to the current data value. * Called from the {@link #draw(Graphics2D, Rectangle2D, Point2D, * PlotState, PlotRenderingInfo)} method. * * @return The paint (never null). */ private Paint getCurrentPaint() { Paint result = this.mercuryPaint; if (this.useSubrangePaint) { double value = this.dataset.getValue().doubleValue(); if (inSubrange(NORMAL, value)) { result = this.subrangePaint[NORMAL]; } else if (inSubrange(WARNING, value)) { result = this.subrangePaint[WARNING]; } else if (inSubrange(CRITICAL, value)) { result = this.subrangePaint[CRITICAL]; } } return result; } /** * Tests this plot for equality with another object. The plot's dataset * is not considered in the test. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ThermometerPlot)) { return false; } ThermometerPlot that = (ThermometerPlot) obj; if (!super.equals(obj)) { return false; } if (!ObjectUtilities.equal(this.rangeAxis, that.rangeAxis)) { return false; } if (this.axisLocation != that.axisLocation) { return false; } if (this.lowerBound != that.lowerBound) { return false; } if (this.upperBound != that.upperBound) { return false; } if (!ObjectUtilities.equal(this.padding, that.padding)) { return false; } if (!ObjectUtilities.equal(this.thermometerStroke, that.thermometerStroke)) { return false; } if (!PaintUtilities.equal(this.thermometerPaint, that.thermometerPaint)) { return false; } if (this.units != that.units) { return false; } if (this.valueLocation != that.valueLocation) { return false; } if (!ObjectUtilities.equal(this.valueFont, that.valueFont)) { return false; } if (!PaintUtilities.equal(this.valuePaint, that.valuePaint)) { return false; } if (!ObjectUtilities.equal(this.valueFormat, that.valueFormat)) { return false; } if (!PaintUtilities.equal(this.mercuryPaint, that.mercuryPaint)) { return false; } if (this.showValueLines != that.showValueLines) { return false; } if (this.subrange != that.subrange) { return false; } if (this.followDataInSubranges != that.followDataInSubranges) { return false; } if (!equal(this.subrangeInfo, that.subrangeInfo)) { return false; } if (this.useSubrangePaint != that.useSubrangePaint) { return false; } if (this.bulbRadius != that.bulbRadius) { return false; } if (this.columnRadius != that.columnRadius) { return false; } if (this.gap != that.gap) { return false; } for (int i = 0; i < this.subrangePaint.length; i++) { if (!PaintUtilities.equal(this.subrangePaint[i], that.subrangePaint[i])) { return false; } } return true; } /** * Tests two double[][] arrays for equality. * * @param array1 the first array (null permitted). * @param array2 the second arrray (null permitted). * * @return A boolean. */ private static boolean equal(double[][] array1, double[][] array2) { if (array1 == null) { return (array2 == null); } if (array2 == null) { return false; } if (array1.length != array2.length) { return false; } for (int i = 0; i < array1.length; i++) { if (!Arrays.equals(array1[i], array2[i])) { return false; } } return true; } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if the plot cannot be cloned. */ public Object clone() throws CloneNotSupportedException { ThermometerPlot clone = (ThermometerPlot) super.clone(); if (clone.dataset != null) { clone.dataset.addChangeListener(clone); } clone.rangeAxis = (ValueAxis) ObjectUtilities.clone(this.rangeAxis); if (clone.rangeAxis != null) { clone.rangeAxis.setPlot(clone); clone.rangeAxis.addChangeListener(clone); } clone.valueFormat = (NumberFormat) this.valueFormat.clone(); clone.subrangePaint = (Paint[]) this.subrangePaint.clone(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.thermometerStroke, stream); SerialUtilities.writePaint(this.thermometerPaint, stream); SerialUtilities.writePaint(this.valuePaint, stream); SerialUtilities.writePaint(this.mercuryPaint, stream); SerialUtilities.writeStroke(this.subrangeIndicatorStroke, stream); SerialUtilities.writeStroke(this.rangeIndicatorStroke, stream); for (int i = 0; i < 3; i++) { SerialUtilities.writePaint(this.subrangePaint[i], stream); } } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.thermometerStroke = SerialUtilities.readStroke(stream); this.thermometerPaint = SerialUtilities.readPaint(stream); this.valuePaint = SerialUtilities.readPaint(stream); this.mercuryPaint = SerialUtilities.readPaint(stream); this.subrangeIndicatorStroke = SerialUtilities.readStroke(stream); this.rangeIndicatorStroke = SerialUtilities.readStroke(stream); this.subrangePaint = new Paint[3]; for (int i = 0; i < 3; i++) { this.subrangePaint[i] = SerialUtilities.readPaint(stream); } if (this.rangeAxis != null) { this.rangeAxis.addChangeListener(this); } } /** * Multiplies the range on the domain axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point. */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source) { // no domain axis to zoom } /** * Multiplies the range on the domain axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point. * @param useAnchor a flag that controls whether or not the source point * is used for the zoom anchor. * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { // no domain axis to zoom } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point. */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source) { this.rangeAxis.resizeRange(factor); } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param state the plot state. * @param source the source point. * @param useAnchor a flag that controls whether or not the source point * is used for the zoom anchor. * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor) { double anchorY = this.getRangeAxis().java2DToValue(source.getY(), state.getDataArea(), RectangleEdge.LEFT); this.rangeAxis.resizeRange(factor, anchorY); } /** * This method does nothing. * * @param lowerPercent the lower percent. * @param upperPercent the upper percent. * @param state the plot state. * @param source the source point. */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source) { // no domain axis to zoom } /** * Zooms the range axes. * * @param lowerPercent the lower percent. * @param upperPercent the upper percent. * @param state the plot state. * @param source the source point. */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source) { this.rangeAxis.zoomRange(lowerPercent, upperPercent); } /** * Returns false. * * @return A boolean. */ public boolean isDomainZoomable() { return false; } /** * Returns true. * * @return A boolean. */ public boolean isRangeZoomable() { return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ValueAxisPlot.java0000644000175000017500000000423711173030414027020 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * ValueAxisPlot.java * ------------------ * * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-May-2003 : Version 1 (DG); * 11-Nov-2004 : Changed Horizontal --> Domain and Vertical --> Range (DG); * 12-Nov-2004 : Moved zooming methods to new Zoomable interface (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.axis.ValueAxis; import org.jfree.data.Range; /** * An interface that is implemented by plots that use a {@link ValueAxis}, * providing a standard method to find the current data range. */ public interface ValueAxisPlot { /** * Returns the data range that should apply for the specified axis. * * @param axis the axis. * * @return The data range. */ public Range getDataRange(ValueAxis axis); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/ValueMarker.java0000644000175000017500000001152311173030414026472 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ValueMarker.java * ---------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Feb-2004 : Version 1 (DG); * 16-Feb-2005 : Added new constructor (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Sep-2006 : Added setValue() method (DG); * 08-Oct-2007 : Fixed bug 1808376, constructor calling super with incorrect * values (DG); * */ package org.jfree.chart.plot; import java.awt.Paint; import java.awt.Stroke; import org.jfree.chart.event.MarkerChangeEvent; /** * A marker that represents a single value. Markers can be added to plots to * highlight specific values. */ public class ValueMarker extends Marker { /** The value. */ private double value; /** * Creates a new marker. * * @param value the value. */ public ValueMarker(double value) { super(); this.value = value; } /** * Creates a new marker. * * @param value the value. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). */ public ValueMarker(double value, Paint paint, Stroke stroke) { this(value, paint, stroke, paint, stroke, 1.0f); } /** * Creates a new value marker. * * @param value the value. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). * @param outlinePaint the outline paint (null permitted). * @param outlineStroke the outline stroke (null permitted). * @param alpha the alpha transparency (in the range 0.0f to 1.0f). */ public ValueMarker(double value, Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha) { super(paint, stroke, outlinePaint, outlineStroke, alpha); this.value = value; } /** * Returns the value. * * @return The value. * * @see #setValue(double) */ public double getValue() { return this.value; } /** * Sets the value for the marker and sends a {@link MarkerChangeEvent} to * all registered listeners. * * @param value the value. * * @see #getValue() * * @since 1.0.3 */ public void setValue(double value) { this.value = value; notifyListeners(new MarkerChangeEvent(this)); } /** * Tests this marker for equality with an arbitrary object. This method * returns true if: * *

    *
  • obj is not null;
  • *
  • obj is an instance of ValueMarker;
  • *
  • obj has the same value as this marker;
  • *
  • super.equals(obj) returns true.
  • *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof ValueMarker)) { return false; } ValueMarker that = (ValueMarker) obj; if (this.value != that.value) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/WaferMapPlot.java0000644000175000017500000003452111173030414026620 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * WaferMapPlot.java * ----------------- * * (C) Copyright 2003-2008, by Robert Redburn and Contributors. * * Original Author: Robert Redburn; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 25-Nov-2003 : Version 1 contributed by Robert Redburn (DG); * 05-May-2005 : Updated draw() method parameters (DG); * 10-Jun-2005 : Changed private --> protected for drawChipGrid(), * drawWaferEdge() and getWafterEdge() (DG); * 16-Jun-2005 : Added default constructor and setDataset() method (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.plot; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Arc2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ResourceBundle; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.renderer.WaferMapRenderer; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.WaferMapDataset; import org.jfree.ui.RectangleInsets; /** * A wafer map plot. */ public class WaferMapPlot extends Plot implements RendererChangeListener, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 4668320403707308155L; /** The default grid line stroke. */ public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] {2.0f, 2.0f}, 0.0f); /** The default grid line paint. */ public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; /** The default crosshair visibility. */ public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false; /** The default crosshair stroke. */ public static final Stroke DEFAULT_CROSSHAIR_STROKE = DEFAULT_GRIDLINE_STROKE; /** The default crosshair paint. */ public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** The plot orientation. * vertical = notch down * horizontal = notch right */ private PlotOrientation orientation; /** The dataset. */ private WaferMapDataset dataset; /** * Object responsible for drawing the visual representation of each point * on the plot. */ private WaferMapRenderer renderer; /** * Creates a new plot with no dataset. */ public WaferMapPlot() { this(null); } /** * Creates a new plot. * * @param dataset the dataset (null permitted). */ public WaferMapPlot(WaferMapDataset dataset) { this(dataset, null); } /** * Creates a new plot. * * @param dataset the dataset (null permitted). * @param renderer the renderer (null permitted). */ public WaferMapPlot(WaferMapDataset dataset, WaferMapRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this); } this.renderer = renderer; if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } } /** * Returns the plot type as a string. * * @return A short string describing the type of plot. */ public String getPlotType() { return ("WMAP_Plot"); } /** * Returns the dataset * * @return The dataset (possibly null). */ public WaferMapDataset getDataset() { return this.dataset; } /** * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param dataset the dataset (null permitted). */ public void setDataset(WaferMapDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... if (this.dataset != null) { this.dataset.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self to trigger plot change event datasetChanged(new DatasetChangeEvent(this, dataset)); } /** * Sets the item renderer, and notifies all listeners of a change to the * plot. If the renderer is set to null, no chart will be * drawn. * * @param renderer the new renderer (null permitted). */ public void setRenderer(WaferMapRenderer renderer) { if (this.renderer != null) { this.renderer.removeChangeListener(this); } this.renderer = renderer; if (renderer != null) { renderer.setPlot(this); } fireChangeEvent(); } /** * Draws the wafermap view. * * @param g2 the graphics device. * @param area the plot area. * @param anchor the anchor point (null permitted). * @param state the plot state. * @param info the plot rendering info. */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState state, PlotRenderingInfo info) { // if the plot area is too small, just return... boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } // record the plot area... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for the plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); drawChipGrid(g2, area); drawWaferEdge(g2, area); } /** * Calculates and draws the chip locations on the wafer. * * @param g2 the graphics device. * @param plotArea the plot area. */ protected void drawChipGrid(Graphics2D g2, Rectangle2D plotArea) { Shape savedClip = g2.getClip(); g2.setClip(getWaferEdge(plotArea)); Rectangle2D chip = new Rectangle2D.Double(); int xchips = 35; int ychips = 20; double space = 1d; if (this.dataset != null) { xchips = this.dataset.getMaxChipX() + 2; ychips = this.dataset.getMaxChipY() + 2; space = this.dataset.getChipSpace(); } double startX = plotArea.getX(); double startY = plotArea.getY(); double chipWidth = 1d; double chipHeight = 1d; if (plotArea.getWidth() != plotArea.getHeight()) { double major = 0d; double minor = 0d; if (plotArea.getWidth() > plotArea.getHeight()) { major = plotArea.getWidth(); minor = plotArea.getHeight(); } else { major = plotArea.getHeight(); minor = plotArea.getWidth(); } //set upperLeft point if (plotArea.getWidth() == minor) { // x is minor startY += (major - minor) / 2; chipWidth = (plotArea.getWidth() - (space * xchips - 1)) / xchips; chipHeight = (plotArea.getWidth() - (space * ychips - 1)) / ychips; } else { // y is minor startX += (major - minor) / 2; chipWidth = (plotArea.getHeight() - (space * xchips - 1)) / xchips; chipHeight = (plotArea.getHeight() - (space * ychips - 1)) / ychips; } } for (int x = 1; x <= xchips; x++) { double upperLeftX = (startX - chipWidth) + (chipWidth * x) + (space * (x - 1)); for (int y = 1; y <= ychips; y++) { double upperLeftY = (startY - chipHeight) + (chipHeight * y) + (space * (y - 1)); chip.setFrame(upperLeftX, upperLeftY, chipWidth, chipHeight); g2.setColor(Color.white); if (this.dataset.getChipValue(x - 1, ychips - y - 1) != null) { g2.setPaint( this.renderer.getChipColor( this.dataset.getChipValue(x - 1, ychips - y - 1) ) ); } g2.fill(chip); g2.setColor(Color.lightGray); g2.draw(chip); } } g2.setClip(savedClip); } /** * Calculates the location of the waferedge. * * @param plotArea the plot area. * * @return The wafer edge. */ protected Ellipse2D getWaferEdge(Rectangle2D plotArea) { Ellipse2D edge = new Ellipse2D.Double(); double diameter = plotArea.getWidth(); double upperLeftX = plotArea.getX(); double upperLeftY = plotArea.getY(); //get major dimension if (plotArea.getWidth() != plotArea.getHeight()) { double major = 0d; double minor = 0d; if (plotArea.getWidth() > plotArea.getHeight()) { major = plotArea.getWidth(); minor = plotArea.getHeight(); } else { major = plotArea.getHeight(); minor = plotArea.getWidth(); } //ellipse diameter is the minor dimension diameter = minor; //set upperLeft point if (plotArea.getWidth() == minor) { // x is minor upperLeftY = plotArea.getY() + (major - minor) / 2; } else { // y is minor upperLeftX = plotArea.getX() + (major - minor) / 2; } } edge.setFrame(upperLeftX, upperLeftY, diameter, diameter); return edge; } /** * Draws the waferedge, including the notch. * * @param g2 the graphics device. * @param plotArea the plot area. */ protected void drawWaferEdge(Graphics2D g2, Rectangle2D plotArea) { // draw the wafer Ellipse2D waferEdge = getWaferEdge(plotArea); g2.setColor(Color.black); g2.draw(waferEdge); // calculate and draw the notch // horizontal orientation is considered notch right // vertical orientation is considered notch down Arc2D notch = null; Rectangle2D waferFrame = waferEdge.getFrame(); double notchDiameter = waferFrame.getWidth() * 0.04; if (this.orientation == PlotOrientation.HORIZONTAL) { Rectangle2D notchFrame = new Rectangle2D.Double( waferFrame.getX() + waferFrame.getWidth() - (notchDiameter / 2), waferFrame.getY() + (waferFrame.getHeight() / 2) - (notchDiameter / 2), notchDiameter, notchDiameter ); notch = new Arc2D.Double(notchFrame, 90d, 180d, Arc2D.OPEN); } else { Rectangle2D notchFrame = new Rectangle2D.Double( waferFrame.getX() + (waferFrame.getWidth() / 2) - (notchDiameter / 2), waferFrame.getY() + waferFrame.getHeight() - (notchDiameter / 2), notchDiameter, notchDiameter ); notch = new Arc2D.Double(notchFrame, 0d, 180d, Arc2D.OPEN); } g2.setColor(Color.white); g2.fill(notch); g2.setColor(Color.black); g2.draw(notch); } /** * Return the legend items from the renderer. * * @return The legend items. */ public LegendItemCollection getLegendItems() { return this.renderer.getLegendCollection(); } /** * Notifies all registered listeners of a renderer change. * * @param event the event. */ public void rendererChanged(RendererChangeEvent event) { fireChangeEvent(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/XYCrosshairState.java0000644000175000017500000000352211173030414027473 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYCrosshairState.java * --------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.renderer.xy.XYItemRenderer; /** * Crosshair state information for the {@link XYPlot} and {@link XYItemRenderer} * classes. */ public class XYCrosshairState extends CrosshairState { /** * Creates a new instance. */ public XYCrosshairState() { } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/XYPlot.java0000644000175000017500000061346711173030414025472 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * XYPlot.java * ----------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Craig MacFarlane; * Mark Watson (www.markwatson.com); * Jonathan Nash; * Gideon Krause; * Klaus Rheinwald; * Xavier Poinsard; * Richard Atkinson; * Arnaud Lelievre; * Nicolas Brodu; * Eduardo Ramalho; * Sergei Ivanov; * Richard West, Advanced Micro Devices, Inc.; * Ulrich Voigt - patches 1997549 and 2686040; * Peter Kolb - patches 1934255 and 2603321; * Andrew Mickish - patch 1868749; * * Changes (from 21-Jun-2001) * -------------------------- * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); * 18-Sep-2001 : Updated header and fixed DOS encoding problem (DG); * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG); * 19-Oct-2001 : Removed the code for drawing the visual representation of each * data point into a separate class StandardXYItemRenderer. * This will make it easier to add variations to the way the * charts are drawn. Based on code contributed by Mark * Watson (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 20-Nov-2001 : Fixed clipping bug that shows up when chart is displayed * inside JScrollPane (DG); * 12-Dec-2001 : Removed unnecessary 'throws' clauses from constructor (DG); * 13-Dec-2001 : Added skeleton code for tooltips. Added new constructor. (DG); * 16-Jan-2002 : Renamed the tooltips class (DG); * 22-Jan-2002 : Added DrawInfo class, incorporating tooltips and crosshairs. * Crosshairs based on code by Jonathan Nash (DG); * 05-Feb-2002 : Added alpha-transparency setting based on code by Sylvain * Vieujot (DG); * 26-Feb-2002 : Updated getMinimumXXX() and getMaximumXXX() methods to handle * special case when chart is null (DG); * 28-Feb-2002 : Renamed Datasets.java --> DatasetUtilities.java (DG); * 28-Mar-2002 : The plot now registers with the renderer as a property change * listener. Also added a new constructor (DG); * 09-Apr-2002 : Removed the transRangeZero from the renderer.drawItem() * method. Moved the tooltip generator into the renderer (DG); * 23-Apr-2002 : Fixed bug in methods for drawing horizontal and vertical * lines (DG); * 13-May-2002 : Small change to the draw() method so that it works for * OverlaidXYPlot also (DG); * 25-Jun-2002 : Removed redundant import (DG); * 20-Aug-2002 : Renamed getItemRenderer() --> getRenderer(), and * setXYItemRenderer() --> setRenderer() (DG); * 28-Aug-2002 : Added mechanism for (optional) plot annotations (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 18-Nov-2002 : Added grid settings for both domain and range axis (previously * these were set in the axes) (DG); * 09-Jan-2003 : Further additions to the grid settings, plus integrated plot * border bug fix contributed by Gideon Krause (DG); * 22-Jan-2003 : Removed monolithic constructor (DG); * 04-Mar-2003 : Added 'no data' message, see bug report 691634. Added * secondary range markers using code contributed by Klaus * Rheinwald (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 03-Apr-2003 : Added setDomainAxisLocation() method (DG); * 30-Apr-2003 : Moved annotation drawing into a separate method (DG); * 01-May-2003 : Added multi-pass mechanism for renderers (DG); * 02-May-2003 : Changed axis locations from int to AxisLocation (DG); * 15-May-2003 : Added an orientation attribute (DG); * 02-Jun-2003 : Removed range axis compatibility test (DG); * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer * Services Ltd) (DG); * 26-Jun-2003 : Fixed bug (757303) in getDataRange() method (DG); * 02-Jul-2003 : Added patch from bug report 698646 (secondary axes for * overlaid plots) (DG); * 23-Jul-2003 : Added support for multiple secondary datasets, axes and * renderers (DG); * 27-Jul-2003 : Added support for stacked XY area charts (RA); * 19-Aug-2003 : Implemented Cloneable (DG); * 01-Sep-2003 : Fixed bug where change to secondary datasets didn't generate * change event (797466) (DG) * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 08-Sep-2003 : Changed ValueAxis API (DG); * 08-Sep-2003 : Fixes for serialization (NB); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 17-Sep-2003 : Fixed zooming to include secondary domain axes (DG); * 18-Sep-2003 : Added getSecondaryDomainAxisCount() and * getSecondaryRangeAxisCount() methods suggested by Eduardo * Ramalho (RFE 808548) (DG); * 23-Sep-2003 : Split domain and range markers into foreground and * background (DG); * 06-Oct-2003 : Fixed bug in clearDomainMarkers() and clearRangeMarkers() * methods. Fixed bug (815876) in addSecondaryRangeMarker() * method. Added new addSecondaryDomainMarker methods (see bug * id 815869) (DG); * 10-Nov-2003 : Added getSecondaryDomain/RangeAxisMappedToDataset() methods * requested by Eduardo Ramalho (DG); * 24-Nov-2003 : Removed unnecessary notification when updating axis anchor * values (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 12-Mar-2004 : Fixed bug where primary renderer is always used to determine * range type (DG); * 22-Mar-2004 : Fixed cloning bug (DG); * 23-Mar-2004 : Fixed more cloning bugs (DG); * 07-Apr-2004 : Fixed problem with axis range when the secondary renderer is * stacked, see this post in the forum: * http://www.jfree.org/phpBB2/viewtopic.php?t=8204 (DG); * 07-Apr-2004 : Added get/setDatasetRenderingOrder() methods (DG); * 26-Apr-2004 : Added option to fill quadrant areas in the background of the * plot (DG); * 27-Apr-2004 : Removed major distinction between primary and secondary * datasets, renderers and axes (DG); * 30-Apr-2004 : Modified to make use of the new getRangeExtent() method in the * renderer interface (DG); * 13-May-2004 : Added optional fixedLegendItems attribute (DG); * 19-May-2004 : Added indexOf() method (DG); * 03-Jun-2004 : Fixed zooming bug (DG); * 18-Aug-2004 : Added removedAnnotation() method (by tkram01) (DG); * 05-Oct-2004 : Modified storage type for dataset-to-axis maps (DG); * 06-Oct-2004 : Modified getDataRange() method to use renderer to determine * the x-value range (now matches behaviour for y-values). Added * getDomainAxisIndex() method (DG); * 12-Nov-2004 : Implemented new Zoomable interface (DG); * 25-Nov-2004 : Small update to clone() implementation (DG); * 22-Feb-2005 : Changed axis offsets from Spacer --> RectangleInsets (DG); * 24-Feb-2005 : Added indexOf(XYItemRenderer) method (DG); * 21-Mar-2005 : Register plot as change listener in setRenderer() method (DG); * 21-Apr-2005 : Added get/setSeriesRenderingOrder() methods (ET); * 26-Apr-2005 : Removed LOGGER (DG); * 04-May-2005 : Fixed serialization of domain and range markers (DG); * 05-May-2005 : Removed unused draw() method (DG); * 20-May-2005 : Added setDomainAxes() and setRangeAxes() methods, as per * RFE 1183100 (DG); * 01-Jun-2005 : Upon deserialization, register plot as a listener with its * axes, dataset(s) and renderer(s) - see patch 1209475 (DG); * 01-Jun-2005 : Added clearDomainMarkers(int) method to match * clearRangeMarkers(int) (DG); * 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * 09-Jun-2005 : Added setRenderers(), as per RFE 1183100 (DG); * 06-Jul-2005 : Fixed crosshair bug (id = 1233336) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 26-Jan-2006 : Added getAnnotations() method (DG); * 05-Sep-2006 : Added MarkerChangeEvent support (DG); * 13-Oct-2006 : Fixed initialisation of CrosshairState - see bug report * 1565168 (DG); * 22-Nov-2006 : Fixed equals() and cloning() for quadrant attributes, plus * API doc updates (DG); * 29-Nov-2006 : Added argument checks (DG); * 15-Jan-2007 : Fixed bug in drawRangeMarkers() (DG); * 07-Feb-2007 : Fixed bug 1654215, renderer with no dataset (DG); * 26-Feb-2007 : Added missing setDomainAxisLocation() and * setRangeAxisLocation() methods (DG); * 02-Mar-2007 : Fix for crosshair positioning with horizontal orientation * (see patch 1671648 by Sergei Ivanov) (DG); * 13-Mar-2007 : Added null argument checks for crosshair attributes (DG); * 23-Mar-2007 : Added domain zero base line facility (DG); * 04-May-2007 : Render only visible data items if possible (DG); * 24-May-2007 : Fixed bug in render method for an empty series (DG); * 07-Jun-2007 : Modified drawBackground() to pass orientation to * fillBackground() for handling GradientPaint (DG); * 24-Sep-2007 : Added new zoom methods (DG); * 26-Sep-2007 : Include index value in IllegalArgumentExceptions (DG); * 05-Nov-2007 : Applied patch 1823697, by Richard West, for removal of domain * and range markers (DG); * 12-Nov-2007 : Fixed bug in equals() method for domain and range tick * band paint attributes (DG); * 27-Nov-2007 : Added new setFixedDomain/RangeAxisSpace() methods (DG); * 04-Jan-2008 : Fix for quadrant painting error - see patch 1849564 (DG); * 25-Mar-2008 : Added new methods with optional notification - see patch * 1913751 (DG); * 07-Apr-2008 : Fixed NPE in removeDomainMarker() and * removeRangeMarker() (DG); * 22-May-2008 : Modified calculateAxisSpace() to process range axes first, * then adjust the plot area before calculating the space * for the domain axes (DG); * 09-Jul-2008 : Added renderer state notification when series pass begins * and ends - see patch 1997549 by Ulrich Voigt (DG); * 25-Jul-2008 : Fixed NullPointerException for plots with no axes (DG); * 15-Aug-2008 : Added getRendererCount() method (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * 25-Nov-2008 : Allow datasets to be mapped to multiple axes - based on patch * 1868749 by Andrew Mickish (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 10-Mar-2009 : Allow some annotations to contribute to axis autoRange (DG); * 18-Mar-2009 : Modified anchored zoom behaviour and fixed bug in * "process visible range" rendering (DG); * 19-Mar-2009 : Added panning support based on patch 2686040 by Ulrich * Voigt (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * 30-Mar-2009 : Delegate panning to axes (DG); * */ package org.jfree.chart.plot; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; import java.util.TreeMap; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.annotations.XYAnnotation; import org.jfree.chart.annotations.XYAnnotationBoundsInfo; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.AxisCollection; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.TickType; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.axis.ValueTick; import org.jfree.chart.event.ChartChangeEventType; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.renderer.RendererUtilities; import org.jfree.chart.renderer.xy.AbstractXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRendererState; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.data.general.Dataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.Layer; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectList; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A general class for plotting data in the form of (x, y) pairs. This plot can * use data from any class that implements the {@link XYDataset} interface. *

* XYPlot makes use of an {@link XYItemRenderer} to draw each point * on the plot. By using different renderers, various chart types can be * produced. *

* The {@link org.jfree.chart.ChartFactory} class contains static methods for * creating pre-configured charts. */ public class XYPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable, RendererChangeListener, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7044148245716569264L; /** The default grid line stroke. */ public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] {2.0f, 2.0f}, 0.0f); /** The default grid line paint. */ public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; /** The default crosshair visibility. */ public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false; /** The default crosshair stroke. */ public static final Stroke DEFAULT_CROSSHAIR_STROKE = DEFAULT_GRIDLINE_STROKE; /** The default crosshair paint. */ public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.plot.LocalizationBundle"); /** The plot orientation. */ private PlotOrientation orientation; /** The offset between the data area and the axes. */ private RectangleInsets axisOffset; /** The domain axis / axes (used for the x-values). */ private ObjectList domainAxes; /** The domain axis locations. */ private ObjectList domainAxisLocations; /** The range axis (used for the y-values). */ private ObjectList rangeAxes; /** The range axis location. */ private ObjectList rangeAxisLocations; /** Storage for the datasets. */ private ObjectList datasets; /** Storage for the renderers. */ private ObjectList renderers; /** * Storage for the mapping between datasets/renderers and domain axes. The * keys in the map are Integer objects, corresponding to the dataset * index. The values in the map are List objects containing Integer * objects (corresponding to the axis indices). If the map contains no * entry for a dataset, it is assumed to map to the primary domain axis * (index = 0). */ private Map datasetToDomainAxesMap; /** * Storage for the mapping between datasets/renderers and range axes. The * keys in the map are Integer objects, corresponding to the dataset * index. The values in the map are List objects containing Integer * objects (corresponding to the axis indices). If the map contains no * entry for a dataset, it is assumed to map to the primary domain axis * (index = 0). */ private Map datasetToRangeAxesMap; /** The origin point for the quadrants (if drawn). */ private transient Point2D quadrantOrigin = new Point2D.Double(0.0, 0.0); /** The paint used for each quadrant. */ private transient Paint[] quadrantPaint = new Paint[] {null, null, null, null}; /** A flag that controls whether the domain grid-lines are visible. */ private boolean domainGridlinesVisible; /** The stroke used to draw the domain grid-lines. */ private transient Stroke domainGridlineStroke; /** The paint used to draw the domain grid-lines. */ private transient Paint domainGridlinePaint; /** A flag that controls whether the range grid-lines are visible. */ private boolean rangeGridlinesVisible; /** The stroke used to draw the range grid-lines. */ private transient Stroke rangeGridlineStroke; /** The paint used to draw the range grid-lines. */ private transient Paint rangeGridlinePaint; /** * A flag that controls whether the domain minor grid-lines are visible. * * @since 1.0.12 */ private boolean domainMinorGridlinesVisible; /** * The stroke used to draw the domain minor grid-lines. * * @since 1.0.12 */ private transient Stroke domainMinorGridlineStroke; /** * The paint used to draw the domain minor grid-lines. * * @since 1.0.12 */ private transient Paint domainMinorGridlinePaint; /** * A flag that controls whether the range minor grid-lines are visible. * * @since 1.0.12 */ private boolean rangeMinorGridlinesVisible; /** * The stroke used to draw the range minor grid-lines. * * @since 1.0.12 */ private transient Stroke rangeMinorGridlineStroke; /** * The paint used to draw the range minor grid-lines. * * @since 1.0.12 */ private transient Paint rangeMinorGridlinePaint; /** * A flag that controls whether or not the zero baseline against the domain * axis is visible. * * @since 1.0.5 */ private boolean domainZeroBaselineVisible; /** * The stroke used for the zero baseline against the domain axis. * * @since 1.0.5 */ private transient Stroke domainZeroBaselineStroke; /** * The paint used for the zero baseline against the domain axis. * * @since 1.0.5 */ private transient Paint domainZeroBaselinePaint; /** * A flag that controls whether or not the zero baseline against the range * axis is visible. */ private boolean rangeZeroBaselineVisible; /** The stroke used for the zero baseline against the range axis. */ private transient Stroke rangeZeroBaselineStroke; /** The paint used for the zero baseline against the range axis. */ private transient Paint rangeZeroBaselinePaint; /** A flag that controls whether or not a domain crosshair is drawn..*/ private boolean domainCrosshairVisible; /** The domain crosshair value. */ private double domainCrosshairValue; /** The pen/brush used to draw the crosshair (if any). */ private transient Stroke domainCrosshairStroke; /** The color used to draw the crosshair (if any). */ private transient Paint domainCrosshairPaint; /** * A flag that controls whether or not the crosshair locks onto actual * data points. */ private boolean domainCrosshairLockedOnData = true; /** A flag that controls whether or not a range crosshair is drawn..*/ private boolean rangeCrosshairVisible; /** The range crosshair value. */ private double rangeCrosshairValue; /** The pen/brush used to draw the crosshair (if any). */ private transient Stroke rangeCrosshairStroke; /** The color used to draw the crosshair (if any). */ private transient Paint rangeCrosshairPaint; /** * A flag that controls whether or not the crosshair locks onto actual * data points. */ private boolean rangeCrosshairLockedOnData = true; /** A map of lists of foreground markers (optional) for the domain axes. */ private Map foregroundDomainMarkers; /** A map of lists of background markers (optional) for the domain axes. */ private Map backgroundDomainMarkers; /** A map of lists of foreground markers (optional) for the range axes. */ private Map foregroundRangeMarkers; /** A map of lists of background markers (optional) for the range axes. */ private Map backgroundRangeMarkers; /** * A (possibly empty) list of annotations for the plot. The list should * be initialised in the constructor and never allowed to be * null. */ private List annotations; /** The paint used for the domain tick bands (if any). */ private transient Paint domainTickBandPaint; /** The paint used for the range tick bands (if any). */ private transient Paint rangeTickBandPaint; /** The fixed domain axis space. */ private AxisSpace fixedDomainAxisSpace; /** The fixed range axis space. */ private AxisSpace fixedRangeAxisSpace; /** * The order of the dataset rendering (REVERSE draws the primary dataset * last so that it appears to be on top). */ private DatasetRenderingOrder datasetRenderingOrder = DatasetRenderingOrder.REVERSE; /** * The order of the series rendering (REVERSE draws the primary series * last so that it appears to be on top). */ private SeriesRenderingOrder seriesRenderingOrder = SeriesRenderingOrder.REVERSE; /** * The weight for this plot (only relevant if this is a subplot in a * combined plot). */ private int weight; /** * An optional collection of legend items that can be returned by the * getLegendItems() method. */ private LegendItemCollection fixedLegendItems; /** * A flag that controls whether or not panning is enabled for the domain * axis/axes. * * @since 1.0.13 */ private boolean domainPannable; /** * A flag that controls whether or not panning is enabled for the range * axis/axes. * * @since 1.0.13 */ private boolean rangePannable; /** * Creates a new XYPlot instance with no dataset, no axes and * no renderer. You should specify these items before using the plot. */ public XYPlot() { this(null, null, null, null); } /** * Creates a new plot with the specified dataset, axes and renderer. Any * of the arguments can be null, but in that case you should * take care to specify the value before using the plot (otherwise a * NullPointerException may be thrown). * * @param dataset the dataset (null permitted). * @param domainAxis the domain axis (null permitted). * @param rangeAxis the range axis (null permitted). * @param renderer the renderer (null permitted). */ public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) { super(); this.orientation = PlotOrientation.VERTICAL; this.weight = 1; // only relevant when this is a subplot this.axisOffset = RectangleInsets.ZERO_INSETS; // allocate storage for datasets, axes and renderers (all optional) this.domainAxes = new ObjectList(); this.domainAxisLocations = new ObjectList(); this.foregroundDomainMarkers = new HashMap(); this.backgroundDomainMarkers = new HashMap(); this.rangeAxes = new ObjectList(); this.rangeAxisLocations = new ObjectList(); this.foregroundRangeMarkers = new HashMap(); this.backgroundRangeMarkers = new HashMap(); this.datasets = new ObjectList(); this.renderers = new ObjectList(); this.datasetToDomainAxesMap = new TreeMap(); this.datasetToRangeAxesMap = new TreeMap(); this.annotations = new java.util.ArrayList(); this.datasets.set(0, dataset); if (dataset != null) { dataset.addChangeListener(this); } this.renderers.set(0, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } this.domainAxes.set(0, domainAxis); this.mapDatasetToDomainAxis(0, 0); if (domainAxis != null) { domainAxis.setPlot(this); domainAxis.addChangeListener(this); } this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); this.rangeAxes.set(0, rangeAxis); this.mapDatasetToRangeAxis(0, 0); if (rangeAxis != null) { rangeAxis.setPlot(this); rangeAxis.addChangeListener(this); } this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); configureDomainAxes(); configureRangeAxes(); this.domainGridlinesVisible = true; this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.domainMinorGridlinesVisible = false; this.domainMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainMinorGridlinePaint = Color.white; this.domainZeroBaselineVisible = false; this.domainZeroBaselinePaint = Color.black; this.domainZeroBaselineStroke = new BasicStroke(0.5f); this.rangeGridlinesVisible = true; this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; this.rangeMinorGridlinesVisible = false; this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeMinorGridlinePaint = Color.white; this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = Color.black; this.rangeZeroBaselineStroke = new BasicStroke(0.5f); this.domainCrosshairVisible = false; this.domainCrosshairValue = 0.0; this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; this.rangeCrosshairVisible = false; this.rangeCrosshairValue = 0.0; this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; } /** * Returns the plot type as a string. * * @return A short string describing the type of plot. */ public String getPlotType() { return localizationResources.getString("XY_Plot"); } /** * Returns the orientation of the plot. * * @return The orientation (never null). * * @see #setOrientation(PlotOrientation) */ public PlotOrientation getOrientation() { return this.orientation; } /** * Sets the orientation for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param orientation the orientation (null not allowed). * * @see #getOrientation() */ public void setOrientation(PlotOrientation orientation) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } if (orientation != this.orientation) { this.orientation = orientation; fireChangeEvent(); } } /** * Returns the axis offset. * * @return The axis offset (never null). * * @see #setAxisOffset(RectangleInsets) */ public RectangleInsets getAxisOffset() { return this.axisOffset; } /** * Sets the axis offsets (gap between the data area and the axes) and sends * a {@link PlotChangeEvent} to all registered listeners. * * @param offset the offset (null not permitted). * * @see #getAxisOffset() */ public void setAxisOffset(RectangleInsets offset) { if (offset == null) { throw new IllegalArgumentException("Null 'offset' argument."); } this.axisOffset = offset; fireChangeEvent(); } /** * Returns the domain axis with index 0. If the domain axis for this plot * is null, then the method will return the parent plot's * domain axis (if there is a parent plot). * * @return The domain axis (possibly null). * * @see #getDomainAxis(int) * @see #setDomainAxis(ValueAxis) */ public ValueAxis getDomainAxis() { return getDomainAxis(0); } /** * Returns the domain axis with the specified index, or null. * * @param index the axis index. * * @return The axis (null possible). * * @see #setDomainAxis(int, ValueAxis) */ public ValueAxis getDomainAxis(int index) { ValueAxis result = null; if (index < this.domainAxes.size()) { result = (ValueAxis) this.domainAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof XYPlot) { XYPlot xy = (XYPlot) parent; result = xy.getDomainAxis(index); } } return result; } /** * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axis the new axis (null permitted). * * @see #getDomainAxis() * @see #setDomainAxis(int, ValueAxis) */ public void setDomainAxis(ValueAxis axis) { setDomainAxis(0, axis); } /** * Sets a domain axis and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the axis index. * @param axis the axis (null permitted). * * @see #getDomainAxis(int) * @see #setRangeAxis(int, ValueAxis) */ public void setDomainAxis(int index, ValueAxis axis) { setDomainAxis(index, axis, true); } /** * Sets a domain axis and, if requested, sends a {@link PlotChangeEvent} to * all registered listeners. * * @param index the axis index. * @param axis the axis. * @param notify notify listeners? * * @see #getDomainAxis(int) */ public void setDomainAxis(int index, ValueAxis axis, boolean notify) { ValueAxis existing = getDomainAxis(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.domainAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } if (notify) { fireChangeEvent(); } } /** * Sets the domain axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (null not permitted). * * @see #setRangeAxes(ValueAxis[]) */ public void setDomainAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setDomainAxis(i, axes[i], false); } fireChangeEvent(); } /** * Returns the location of the primary domain axis. * * @return The location (never null). * * @see #setDomainAxisLocation(AxisLocation) */ public AxisLocation getDomainAxisLocation() { return (AxisLocation) this.domainAxisLocations.get(0); } /** * Sets the location of the primary domain axis and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the location (null not permitted). * * @see #getDomainAxisLocation() */ public void setDomainAxisLocation(AxisLocation location) { // delegate... setDomainAxisLocation(0, location, true); } /** * Sets the location of the domain axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the location (null not permitted). * @param notify notify listeners? * * @see #getDomainAxisLocation() */ public void setDomainAxisLocation(AxisLocation location, boolean notify) { // delegate... setDomainAxisLocation(0, location, notify); } /** * Returns the edge for the primary domain axis (taking into account the * plot's orientation). * * @return The edge. * * @see #getDomainAxisLocation() * @see #getOrientation() */ public RectangleEdge getDomainAxisEdge() { return Plot.resolveDomainAxisLocation(getDomainAxisLocation(), this.orientation); } /** * Returns the number of domain axes. * * @return The axis count. * * @see #getRangeAxisCount() */ public int getDomainAxisCount() { return this.domainAxes.size(); } /** * Clears the domain axes from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @see #clearRangeAxes() */ public void clearDomainAxes() { for (int i = 0; i < this.domainAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.domainAxes.get(i); if (axis != null) { axis.removeChangeListener(this); } } this.domainAxes.clear(); fireChangeEvent(); } /** * Configures the domain axes. */ public void configureDomainAxes() { for (int i = 0; i < this.domainAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.domainAxes.get(i); if (axis != null) { axis.configure(); } } } /** * Returns the location for a domain axis. If this hasn't been set * explicitly, the method returns the location that is opposite to the * primary domain axis location. * * @param index the axis index. * * @return The location (never null). * * @see #setDomainAxisLocation(int, AxisLocation) */ public AxisLocation getDomainAxisLocation(int index) { AxisLocation result = null; if (index < this.domainAxisLocations.size()) { result = (AxisLocation) this.domainAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getDomainAxisLocation()); } return result; } /** * Sets the location for a domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param index the axis index. * @param location the location (null not permitted for index * 0). * * @see #getDomainAxisLocation(int) */ public void setDomainAxisLocation(int index, AxisLocation location) { // delegate... setDomainAxisLocation(index, location, true); } /** * Sets the axis location for a domain axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the axis index. * @param location the location (null not permitted for * index 0). * @param notify notify listeners? * * @since 1.0.5 * * @see #getDomainAxisLocation(int) * @see #setRangeAxisLocation(int, AxisLocation, boolean) */ public void setDomainAxisLocation(int index, AxisLocation location, boolean notify) { if (index == 0 && location == null) { throw new IllegalArgumentException( "Null 'location' for index 0 not permitted."); } this.domainAxisLocations.set(index, location); if (notify) { fireChangeEvent(); } } /** * Returns the edge for a domain axis. * * @param index the axis index. * * @return The edge. * * @see #getRangeAxisEdge(int) */ public RectangleEdge getDomainAxisEdge(int index) { AxisLocation location = getDomainAxisLocation(index); RectangleEdge result = Plot.resolveDomainAxisLocation(location, this.orientation); if (result == null) { result = RectangleEdge.opposite(getDomainAxisEdge()); } return result; } /** * Returns the range axis for the plot. If the range axis for this plot is * null, then the method will return the parent plot's range * axis (if there is a parent plot). * * @return The range axis. * * @see #getRangeAxis(int) * @see #setRangeAxis(ValueAxis) */ public ValueAxis getRangeAxis() { return getRangeAxis(0); } /** * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis (null permitted). * * @see #getRangeAxis() * @see #setRangeAxis(int, ValueAxis) */ public void setRangeAxis(ValueAxis axis) { if (axis != null) { axis.setPlot(this); } // plot is likely registered as a listener with the existing axis... ValueAxis existing = getRangeAxis(); if (existing != null) { existing.removeChangeListener(this); } this.rangeAxes.set(0, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } fireChangeEvent(); } /** * Returns the location of the primary range axis. * * @return The location (never null). * * @see #setRangeAxisLocation(AxisLocation) */ public AxisLocation getRangeAxisLocation() { return (AxisLocation) this.rangeAxisLocations.get(0); } /** * Sets the location of the primary range axis and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the location (null not permitted). * * @see #getRangeAxisLocation() */ public void setRangeAxisLocation(AxisLocation location) { // delegate... setRangeAxisLocation(0, location, true); } /** * Sets the location of the primary range axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param location the location (null not permitted). * @param notify notify listeners? * * @see #getRangeAxisLocation() */ public void setRangeAxisLocation(AxisLocation location, boolean notify) { // delegate... setRangeAxisLocation(0, location, notify); } /** * Returns the edge for the primary range axis. * * @return The range axis edge. * * @see #getRangeAxisLocation() * @see #getOrientation() */ public RectangleEdge getRangeAxisEdge() { return Plot.resolveRangeAxisLocation(getRangeAxisLocation(), this.orientation); } /** * Returns a range axis. * * @param index the axis index. * * @return The axis (null possible). * * @see #setRangeAxis(int, ValueAxis) */ public ValueAxis getRangeAxis(int index) { ValueAxis result = null; if (index < this.rangeAxes.size()) { result = (ValueAxis) this.rangeAxes.get(index); } if (result == null) { Plot parent = getParent(); if (parent instanceof XYPlot) { XYPlot xy = (XYPlot) parent; result = xy.getRangeAxis(index); } } return result; } /** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param index the axis index. * @param axis the axis (null permitted). * * @see #getRangeAxis(int) */ public void setRangeAxis(int index, ValueAxis axis) { setRangeAxis(index, axis, true); } /** * Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to * all registered listeners. * * @param index the axis index. * @param axis the axis (null permitted). * @param notify notify listeners? * * @see #getRangeAxis(int) */ public void setRangeAxis(int index, ValueAxis axis, boolean notify) { ValueAxis existing = getRangeAxis(index); if (existing != null) { existing.removeChangeListener(this); } if (axis != null) { axis.setPlot(this); } this.rangeAxes.set(index, axis); if (axis != null) { axis.configure(); axis.addChangeListener(this); } if (notify) { fireChangeEvent(); } } /** * Sets the range axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (null not permitted). * * @see #setDomainAxes(ValueAxis[]) */ public void setRangeAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setRangeAxis(i, axes[i], false); } fireChangeEvent(); } /** * Returns the number of range axes. * * @return The axis count. * * @see #getDomainAxisCount() */ public int getRangeAxisCount() { return this.rangeAxes.size(); } /** * Clears the range axes from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @see #clearDomainAxes() */ public void clearRangeAxes() { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { axis.removeChangeListener(this); } } this.rangeAxes.clear(); fireChangeEvent(); } /** * Configures the range axes. * * @see #configureDomainAxes() */ public void configureRangeAxes() { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { axis.configure(); } } } /** * Returns the location for a range axis. If this hasn't been set * explicitly, the method returns the location that is opposite to the * primary range axis location. * * @param index the axis index. * * @return The location (never null). * * @see #setRangeAxisLocation(int, AxisLocation) */ public AxisLocation getRangeAxisLocation(int index) { AxisLocation result = null; if (index < this.rangeAxisLocations.size()) { result = (AxisLocation) this.rangeAxisLocations.get(index); } if (result == null) { result = AxisLocation.getOpposite(getRangeAxisLocation()); } return result; } /** * Sets the location for a range axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param index the axis index. * @param location the location (null permitted). * * @see #getRangeAxisLocation(int) */ public void setRangeAxisLocation(int index, AxisLocation location) { // delegate... setRangeAxisLocation(index, location, true); } /** * Sets the axis location for a domain axis and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the axis index. * @param location the location (null not permitted for * index 0). * @param notify notify listeners? * * @since 1.0.5 * * @see #getRangeAxisLocation(int) * @see #setDomainAxisLocation(int, AxisLocation, boolean) */ public void setRangeAxisLocation(int index, AxisLocation location, boolean notify) { if (index == 0 && location == null) { throw new IllegalArgumentException( "Null 'location' for index 0 not permitted."); } this.rangeAxisLocations.set(index, location); if (notify) { fireChangeEvent(); } } /** * Returns the edge for a range axis. * * @param index the axis index. * * @return The edge. * * @see #getRangeAxisLocation(int) * @see #getOrientation() */ public RectangleEdge getRangeAxisEdge(int index) { AxisLocation location = getRangeAxisLocation(index); RectangleEdge result = Plot.resolveRangeAxisLocation(location, this.orientation); if (result == null) { result = RectangleEdge.opposite(getRangeAxisEdge()); } return result; } /** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly null). * * @see #getDataset(int) * @see #setDataset(XYDataset) */ public XYDataset getDataset() { return getDataset(0); } /** * Returns a dataset. * * @param index the dataset index. * * @return The dataset (possibly null). * * @see #setDataset(int, XYDataset) */ public XYDataset getDataset(int index) { XYDataset result = null; if (this.datasets.size() > index) { result = (XYDataset) this.datasets.get(index); } return result; } /** * Sets the primary dataset for the plot, replacing the existing dataset if * there is one. * * @param dataset the dataset (null permitted). * * @see #getDataset() * @see #setDataset(int, XYDataset) */ public void setDataset(XYDataset dataset) { setDataset(0, dataset); } /** * Sets a dataset for the plot. * * @param index the dataset index. * @param dataset the dataset (null permitted). * * @see #getDataset(int) */ public void setDataset(int index, XYDataset dataset) { XYDataset existing = getDataset(index); if (existing != null) { existing.removeChangeListener(this); } this.datasets.set(index, dataset); if (dataset != null) { dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); } /** * Returns the number of datasets. * * @return The number of datasets. */ public int getDatasetCount() { return this.datasets.size(); } /** * Returns the index of the specified dataset, or -1 if the * dataset does not belong to the plot. * * @param dataset the dataset (null not permitted). * * @return The index. */ public int indexOf(XYDataset dataset) { int result = -1; for (int i = 0; i < this.datasets.size(); i++) { if (dataset == this.datasets.get(i)) { result = i; break; } } return result; } /** * Maps a dataset to a particular domain axis. All data will be plotted * against axis zero by default, no mapping is required for this case. * * @param index the dataset index (zero-based). * @param axisIndex the axis index. * * @see #mapDatasetToRangeAxis(int, int) */ public void mapDatasetToDomainAxis(int index, int axisIndex) { List axisIndices = new java.util.ArrayList(1); axisIndices.add(new Integer(axisIndex)); mapDatasetToDomainAxes(index, axisIndices); } /** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices (null permitted). * * @since 1.0.12 */ public void mapDatasetToDomainAxes(int index, List axisIndices) { if (index < 0) { throw new IllegalArgumentException("Requires 'index' >= 0."); } checkAxisIndices(axisIndices); Integer key = new Integer(index); this.datasetToDomainAxesMap.put(key, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); } /** * Maps a dataset to a particular range axis. All data will be plotted * against axis zero by default, no mapping is required for this case. * * @param index the dataset index (zero-based). * @param axisIndex the axis index. * * @see #mapDatasetToDomainAxis(int, int) */ public void mapDatasetToRangeAxis(int index, int axisIndex) { List axisIndices = new java.util.ArrayList(1); axisIndices.add(new Integer(axisIndex)); mapDatasetToRangeAxes(index, axisIndices); } /** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices (null permitted). * * @since 1.0.12 */ public void mapDatasetToRangeAxes(int index, List axisIndices) { if (index < 0) { throw new IllegalArgumentException("Requires 'index' >= 0."); } checkAxisIndices(axisIndices); Integer key = new Integer(index); this.datasetToRangeAxesMap.put(key, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); } /** * This method is used to perform argument checking on the list of * axis indices passed to mapDatasetToDomainAxes() and * mapDatasetToRangeAxes(). * * @param indices the list of indices (null permitted). */ private void checkAxisIndices(List indices) { // axisIndices can be: // 1. null; // 2. non-empty, containing only Integer objects that are unique. if (indices == null) { return; // OK } int count = indices.size(); if (count == 0) { throw new IllegalArgumentException("Empty list not permitted."); } HashSet set = new HashSet(); for (int i = 0; i < count; i++) { Object item = indices.get(i); if (!(item instanceof Integer)) { throw new IllegalArgumentException( "Indices must be Integer instances."); } if (set.contains(item)) { throw new IllegalArgumentException("Indices must be unique."); } set.add(item); } } /** * Returns the number of renderer slots for this plot. * * @return The number of renderer slots. * * @since 1.0.11 */ public int getRendererCount() { return this.renderers.size(); } /** * Returns the renderer for the primary dataset. * * @return The item renderer (possibly null). * * @see #setRenderer(XYItemRenderer) */ public XYItemRenderer getRenderer() { return getRenderer(0); } /** * Returns the renderer for a dataset, or null. * * @param index the renderer index. * * @return The renderer (possibly null). * * @see #setRenderer(int, XYItemRenderer) */ public XYItemRenderer getRenderer(int index) { XYItemRenderer result = null; if (this.renderers.size() > index) { result = (XYItemRenderer) this.renderers.get(index); } return result; } /** * Sets the renderer for the primary dataset and sends a * {@link PlotChangeEvent} to all registered listeners. If the renderer * is set to null, no data will be displayed. * * @param renderer the renderer (null permitted). * * @see #getRenderer() */ public void setRenderer(XYItemRenderer renderer) { setRenderer(0, renderer); } /** * Sets a renderer and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the index. * @param renderer the renderer. * * @see #getRenderer(int) */ public void setRenderer(int index, XYItemRenderer renderer) { setRenderer(index, renderer, true); } /** * Sets a renderer and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param index the index. * @param renderer the renderer. * @param notify notify listeners? * * @see #getRenderer(int) */ public void setRenderer(int index, XYItemRenderer renderer, boolean notify) { XYItemRenderer existing = getRenderer(index); if (existing != null) { existing.removeChangeListener(this); } this.renderers.set(index, renderer); if (renderer != null) { renderer.setPlot(this); renderer.addChangeListener(this); } configureDomainAxes(); configureRangeAxes(); if (notify) { fireChangeEvent(); } } /** * Sets the renderers for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param renderers the renderers (null not permitted). */ public void setRenderers(XYItemRenderer[] renderers) { for (int i = 0; i < renderers.length; i++) { setRenderer(i, renderers[i], false); } fireChangeEvent(); } /** * Returns the dataset rendering order. * * @return The order (never null). * * @see #setDatasetRenderingOrder(DatasetRenderingOrder) */ public DatasetRenderingOrder getDatasetRenderingOrder() { return this.datasetRenderingOrder; } /** * Sets the rendering order and sends a {@link PlotChangeEvent} to all * registered listeners. By default, the plot renders the primary dataset * last (so that the primary dataset overlays the secondary datasets). * You can reverse this if you want to. * * @param order the rendering order (null not permitted). * * @see #getDatasetRenderingOrder() */ public void setDatasetRenderingOrder(DatasetRenderingOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.datasetRenderingOrder = order; fireChangeEvent(); } /** * Returns the series rendering order. * * @return the order (never null). * * @see #setSeriesRenderingOrder(SeriesRenderingOrder) */ public SeriesRenderingOrder getSeriesRenderingOrder() { return this.seriesRenderingOrder; } /** * Sets the series order and sends a {@link PlotChangeEvent} to all * registered listeners. By default, the plot renders the primary series * last (so that the primary series appears to be on top). * You can reverse this if you want to. * * @param order the rendering order (null not permitted). * * @see #getSeriesRenderingOrder() */ public void setSeriesRenderingOrder(SeriesRenderingOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.seriesRenderingOrder = order; fireChangeEvent(); } /** * Returns the index of the specified renderer, or -1 if the * renderer is not assigned to this plot. * * @param renderer the renderer (null permitted). * * @return The renderer index. */ public int getIndexOf(XYItemRenderer renderer) { return this.renderers.indexOf(renderer); } /** * Returns the renderer for the specified dataset. The code first * determines the index of the dataset, then checks if there is a * renderer with the same index (if not, the method returns renderer(0). * * @param dataset the dataset (null permitted). * * @return The renderer (possibly null). */ public XYItemRenderer getRendererForDataset(XYDataset dataset) { XYItemRenderer result = null; for (int i = 0; i < this.datasets.size(); i++) { if (this.datasets.get(i) == dataset) { result = (XYItemRenderer) this.renderers.get(i); if (result == null) { result = getRenderer(); } break; } } return result; } /** * Returns the weight for this plot when it is used as a subplot within a * combined plot. * * @return The weight. * * @see #setWeight(int) */ public int getWeight() { return this.weight; } /** * Sets the weight for the plot and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param weight the weight. * * @see #getWeight() */ public void setWeight(int weight) { this.weight = weight; fireChangeEvent(); } /** * Returns true if the domain gridlines are visible, and * false otherwise. * * @return true or false. * * @see #setDomainGridlinesVisible(boolean) */ public boolean isDomainGridlinesVisible() { return this.domainGridlinesVisible; } /** * Sets the flag that controls whether or not the domain grid-lines are * visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isDomainGridlinesVisible() */ public void setDomainGridlinesVisible(boolean visible) { if (this.domainGridlinesVisible != visible) { this.domainGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns true if the domain minor gridlines are visible, and * false otherwise. * * @return true or false. * * @see #setDomainMinorGridlinesVisible(boolean) * * @since 1.0.12 */ public boolean isDomainMinorGridlinesVisible() { return this.domainMinorGridlinesVisible; } /** * Sets the flag that controls whether or not the domain minor grid-lines * are visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isDomainMinorGridlinesVisible() * * @since 1.0.12 */ public void setDomainMinorGridlinesVisible(boolean visible) { if (this.domainMinorGridlinesVisible != visible) { this.domainMinorGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the grid-lines (if any) plotted against the * domain axis. * * @return The stroke (never null). * * @see #setDomainGridlineStroke(Stroke) */ public Stroke getDomainGridlineStroke() { return this.domainGridlineStroke; } /** * Sets the stroke for the grid lines plotted against the domain axis, and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @throws IllegalArgumentException if stroke is * null. * * @see #getDomainGridlineStroke() */ public void setDomainGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.domainGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the stroke for the minor grid-lines (if any) plotted against the * domain axis. * * @return The stroke (never null). * * @see #setDomainMinorGridlineStroke(Stroke) * * @since 1.0.12 */ public Stroke getDomainMinorGridlineStroke() { return this.domainMinorGridlineStroke; } /** * Sets the stroke for the minor grid lines plotted against the domain * axis, and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @throws IllegalArgumentException if stroke is * null. * * @see #getDomainMinorGridlineStroke() * * @since 1.0.12 */ public void setDomainMinorGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.domainMinorGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the grid lines (if any) plotted against the domain * axis. * * @return The paint (never null). * * @see #setDomainGridlinePaint(Paint) */ public Paint getDomainGridlinePaint() { return this.domainGridlinePaint; } /** * Sets the paint for the grid lines plotted against the domain axis, and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @throws IllegalArgumentException if paint is * null. * * @see #getDomainGridlinePaint() */ public void setDomainGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainGridlinePaint = paint; fireChangeEvent(); } /** * Returns the paint for the minor grid lines (if any) plotted against the * domain axis. * * @return The paint (never null). * * @see #setDomainMinorGridlinePaint(Paint) * * @since 1.0.12 */ public Paint getDomainMinorGridlinePaint() { return this.domainMinorGridlinePaint; } /** * Sets the paint for the minor grid lines plotted against the domain axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @throws IllegalArgumentException if paint is * null. * * @see #getDomainMinorGridlinePaint() * * @since 1.0.12 */ public void setDomainMinorGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainMinorGridlinePaint = paint; fireChangeEvent(); } /** * Returns true if the range axis grid is visible, and * false otherwise. * * @return A boolean. * * @see #setRangeGridlinesVisible(boolean) */ public boolean isRangeGridlinesVisible() { return this.rangeGridlinesVisible; } /** * Sets the flag that controls whether or not the range axis grid lines * are visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isRangeGridlinesVisible() */ public void setRangeGridlinesVisible(boolean visible) { if (this.rangeGridlinesVisible != visible) { this.rangeGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the grid lines (if any) plotted against the * range axis. * * @return The stroke (never null). * * @see #setRangeGridlineStroke(Stroke) */ public Stroke getRangeGridlineStroke() { return this.rangeGridlineStroke; } /** * Sets the stroke for the grid lines plotted against the range axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getRangeGridlineStroke() */ public void setRangeGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the grid lines (if any) plotted against the range * axis. * * @return The paint (never null). * * @see #setRangeGridlinePaint(Paint) */ public Paint getRangeGridlinePaint() { return this.rangeGridlinePaint; } /** * Sets the paint for the grid lines plotted against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeGridlinePaint() */ public void setRangeGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeGridlinePaint = paint; fireChangeEvent(); } /** * Returns true if the range axis minor grid is visible, and * false otherwise. * * @return A boolean. * * @see #setRangeMinorGridlinesVisible(boolean) * * @since 1.0.12 */ public boolean isRangeMinorGridlinesVisible() { return this.rangeMinorGridlinesVisible; } /** * Sets the flag that controls whether or not the range axis minor grid * lines are visible. *

* If the flag value is changed, a {@link PlotChangeEvent} is sent to all * registered listeners. * * @param visible the new value of the flag. * * @see #isRangeMinorGridlinesVisible() * * @since 1.0.12 */ public void setRangeMinorGridlinesVisible(boolean visible) { if (this.rangeMinorGridlinesVisible != visible) { this.rangeMinorGridlinesVisible = visible; fireChangeEvent(); } } /** * Returns the stroke for the minor grid lines (if any) plotted against the * range axis. * * @return The stroke (never null). * * @see #setRangeMinorGridlineStroke(Stroke) * * @since 1.0.12 */ public Stroke getRangeMinorGridlineStroke() { return this.rangeMinorGridlineStroke; } /** * Sets the stroke for the minor grid lines plotted against the range axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getRangeMinorGridlineStroke() * * @since 1.0.12 */ public void setRangeMinorGridlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeMinorGridlineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the minor grid lines (if any) plotted against the range * axis. * * @return The paint (never null). * * @see #setRangeMinorGridlinePaint(Paint) * * @since 1.0.12 */ public Paint getRangeMinorGridlinePaint() { return this.rangeMinorGridlinePaint; } /** * Sets the paint for the minor grid lines plotted against the range axis * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeMinorGridlinePaint() * * @since 1.0.12 */ public void setRangeMinorGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeMinorGridlinePaint = paint; fireChangeEvent(); } /** * Returns a flag that controls whether or not a zero baseline is * displayed for the domain axis. * * @return A boolean. * * @since 1.0.5 * * @see #setDomainZeroBaselineVisible(boolean) */ public boolean isDomainZeroBaselineVisible() { return this.domainZeroBaselineVisible; } /** * Sets the flag that controls whether or not the zero baseline is * displayed for the domain axis, and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param visible the flag. * * @since 1.0.5 * * @see #isDomainZeroBaselineVisible() */ public void setDomainZeroBaselineVisible(boolean visible) { this.domainZeroBaselineVisible = visible; fireChangeEvent(); } /** * Returns the stroke used for the zero baseline against the domain axis. * * @return The stroke (never null). * * @since 1.0.5 * * @see #setDomainZeroBaselineStroke(Stroke) */ public Stroke getDomainZeroBaselineStroke() { return this.domainZeroBaselineStroke; } /** * Sets the stroke for the zero baseline for the domain axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @since 1.0.5 * * @see #getRangeZeroBaselineStroke() */ public void setDomainZeroBaselineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.domainZeroBaselineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the zero baseline (if any) plotted against the * domain axis. * * @since 1.0.5 * * @return The paint (never null). * * @see #setDomainZeroBaselinePaint(Paint) */ public Paint getDomainZeroBaselinePaint() { return this.domainZeroBaselinePaint; } /** * Sets the paint for the zero baseline plotted against the domain axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @since 1.0.5 * * @see #getDomainZeroBaselinePaint() */ public void setDomainZeroBaselinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainZeroBaselinePaint = paint; fireChangeEvent(); } /** * Returns a flag that controls whether or not a zero baseline is * displayed for the range axis. * * @return A boolean. * * @see #setRangeZeroBaselineVisible(boolean) */ public boolean isRangeZeroBaselineVisible() { return this.rangeZeroBaselineVisible; } /** * Sets the flag that controls whether or not the zero baseline is * displayed for the range axis, and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param visible the flag. * * @see #isRangeZeroBaselineVisible() */ public void setRangeZeroBaselineVisible(boolean visible) { this.rangeZeroBaselineVisible = visible; fireChangeEvent(); } /** * Returns the stroke used for the zero baseline against the range axis. * * @return The stroke (never null). * * @see #setRangeZeroBaselineStroke(Stroke) */ public Stroke getRangeZeroBaselineStroke() { return this.rangeZeroBaselineStroke; } /** * Sets the stroke for the zero baseline for the range axis, * and sends a {@link PlotChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getRangeZeroBaselineStroke() */ public void setRangeZeroBaselineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeZeroBaselineStroke = stroke; fireChangeEvent(); } /** * Returns the paint for the zero baseline (if any) plotted against the * range axis. * * @return The paint (never null). * * @see #setRangeZeroBaselinePaint(Paint) */ public Paint getRangeZeroBaselinePaint() { return this.rangeZeroBaselinePaint; } /** * Sets the paint for the zero baseline plotted against the range axis and * sends a {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getRangeZeroBaselinePaint() */ public void setRangeZeroBaselinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeZeroBaselinePaint = paint; fireChangeEvent(); } /** * Returns the paint used for the domain tick bands. If this is * null, no tick bands will be drawn. * * @return The paint (possibly null). * * @see #setDomainTickBandPaint(Paint) */ public Paint getDomainTickBandPaint() { return this.domainTickBandPaint; } /** * Sets the paint for the domain tick bands. * * @param paint the paint (null permitted). * * @see #getDomainTickBandPaint() */ public void setDomainTickBandPaint(Paint paint) { this.domainTickBandPaint = paint; fireChangeEvent(); } /** * Returns the paint used for the range tick bands. If this is * null, no tick bands will be drawn. * * @return The paint (possibly null). * * @see #setRangeTickBandPaint(Paint) */ public Paint getRangeTickBandPaint() { return this.rangeTickBandPaint; } /** * Sets the paint for the range tick bands. * * @param paint the paint (null permitted). * * @see #getRangeTickBandPaint() */ public void setRangeTickBandPaint(Paint paint) { this.rangeTickBandPaint = paint; fireChangeEvent(); } /** * Returns the origin for the quadrants that can be displayed on the plot. * This defaults to (0, 0). * * @return The origin point (never null). * * @see #setQuadrantOrigin(Point2D) */ public Point2D getQuadrantOrigin() { return this.quadrantOrigin; } /** * Sets the quadrant origin and sends a {@link PlotChangeEvent} to all * registered listeners. * * @param origin the origin (null not permitted). * * @see #getQuadrantOrigin() */ public void setQuadrantOrigin(Point2D origin) { if (origin == null) { throw new IllegalArgumentException("Null 'origin' argument."); } this.quadrantOrigin = origin; fireChangeEvent(); } /** * Returns the paint used for the specified quadrant. * * @param index the quadrant index (0-3). * * @return The paint (possibly null). * * @see #setQuadrantPaint(int, Paint) */ public Paint getQuadrantPaint(int index) { if (index < 0 || index > 3) { throw new IllegalArgumentException("The index value (" + index + ") should be in the range 0 to 3."); } return this.quadrantPaint[index]; } /** * Sets the paint used for the specified quadrant and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the quadrant index (0-3). * @param paint the paint (null permitted). * * @see #getQuadrantPaint(int) */ public void setQuadrantPaint(int index, Paint paint) { if (index < 0 || index > 3) { throw new IllegalArgumentException("The index value (" + index + ") should be in the range 0 to 3."); } this.quadrantPaint[index] = paint; fireChangeEvent(); } /** * Adds a marker for the domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * * @see #addDomainMarker(Marker, Layer) * @see #clearDomainMarkers() */ public void addDomainMarker(Marker marker) { // defer argument checking... addDomainMarker(marker, Layer.FOREGROUND); } /** * Adds a marker for the domain axis in the specified layer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background). * * @see #addDomainMarker(int, Marker, Layer) */ public void addDomainMarker(Marker marker, Layer layer) { addDomainMarker(0, marker, layer); } /** * Clears all the (foreground and background) domain markers and sends a * {@link PlotChangeEvent} to all registered listeners. * * @see #addDomainMarker(int, Marker, Layer) */ public void clearDomainMarkers() { if (this.backgroundDomainMarkers != null) { Set keys = this.backgroundDomainMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearDomainMarkers(key.intValue()); } this.backgroundDomainMarkers.clear(); } if (this.foregroundDomainMarkers != null) { Set keys = this.foregroundDomainMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearDomainMarkers(key.intValue()); } this.foregroundDomainMarkers.clear(); } fireChangeEvent(); } /** * Clears the (foreground and background) domain markers for a particular * renderer. * * @param index the renderer index. * * @see #clearRangeMarkers(int) */ public void clearDomainMarkers(int index) { Integer key = new Integer(index); if (this.backgroundDomainMarkers != null) { Collection markers = (Collection) this.backgroundDomainMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } if (this.foregroundRangeMarkers != null) { Collection markers = (Collection) this.foregroundDomainMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } fireChangeEvent(); } /** * Adds a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the domain axis (that the renderer is mapped to), however this is * entirely up to the renderer. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * * @see #clearDomainMarkers(int) * @see #addRangeMarker(int, Marker, Layer) */ public void addDomainMarker(int index, Marker marker, Layer layer) { addDomainMarker(index, marker, layer, true); } /** * Adds a marker for a specific dataset/renderer and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the domain axis (that the renderer is mapped to), however this is * entirely up to the renderer. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * @param notify notify listeners? * * @since 1.0.10 */ public void addDomainMarker(int index, Marker marker, Layer layer, boolean notify) { if (marker == null) { throw new IllegalArgumentException("Null 'marker' not permitted."); } if (layer == null) { throw new IllegalArgumentException("Null 'layer' not permitted."); } Collection markers; if (layer == Layer.FOREGROUND) { markers = (Collection) this.foregroundDomainMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.foregroundDomainMarkers.put(new Integer(index), markers); } markers.add(marker); } else if (layer == Layer.BACKGROUND) { markers = (Collection) this.backgroundDomainMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.backgroundDomainMarkers.put(new Integer(index), markers); } markers.add(marker); } marker.addChangeListener(this); if (notify) { fireChangeEvent(); } } /** * Removes a marker for the domain axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param marker the marker. * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeDomainMarker(Marker marker) { return removeDomainMarker(marker, Layer.FOREGROUND); } /** * Removes a marker for the domain axis in the specified layer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeDomainMarker(Marker marker, Layer layer) { return removeDomainMarker(0, marker, layer); } /** * Removes a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeDomainMarker(int index, Marker marker, Layer layer) { return removeDomainMarker(index, marker, layer, true); } /** * Removes a marker for a specific dataset/renderer and, if requested, * sends a {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * @param notify notify listeners? * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.10 */ public boolean removeDomainMarker(int index, Marker marker, Layer layer, boolean notify) { ArrayList markers; if (layer == Layer.FOREGROUND) { markers = (ArrayList) this.foregroundDomainMarkers.get( new Integer(index)); } else { markers = (ArrayList) this.backgroundDomainMarkers.get( new Integer(index)); } if (markers == null) { return false; } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); } return removed; } /** * Adds a marker for the range axis and sends a {@link PlotChangeEvent} to * all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * * @see #addRangeMarker(Marker, Layer) */ public void addRangeMarker(Marker marker) { addRangeMarker(marker, Layer.FOREGROUND); } /** * Adds a marker for the range axis in the specified layer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background). * * @see #addRangeMarker(int, Marker, Layer) */ public void addRangeMarker(Marker marker, Layer layer) { addRangeMarker(0, marker, layer); } /** * Clears all the range markers and sends a {@link PlotChangeEvent} to all * registered listeners. * * @see #clearRangeMarkers() */ public void clearRangeMarkers() { if (this.backgroundRangeMarkers != null) { Set keys = this.backgroundRangeMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearRangeMarkers(key.intValue()); } this.backgroundRangeMarkers.clear(); } if (this.foregroundRangeMarkers != null) { Set keys = this.foregroundRangeMarkers.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Integer key = (Integer) iterator.next(); clearRangeMarkers(key.intValue()); } this.foregroundRangeMarkers.clear(); } fireChangeEvent(); } /** * Adds a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * * @see #clearRangeMarkers(int) * @see #addDomainMarker(int, Marker, Layer) */ public void addRangeMarker(int index, Marker marker, Layer layer) { addRangeMarker(index, marker, layer, true); } /** * Adds a marker for a specific dataset/renderer and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. *

* Typically a marker will be drawn by the renderer as a line perpendicular * to the range axis, however this is entirely up to the renderer. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * @param notify notify listeners? * * @since 1.0.10 */ public void addRangeMarker(int index, Marker marker, Layer layer, boolean notify) { Collection markers; if (layer == Layer.FOREGROUND) { markers = (Collection) this.foregroundRangeMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.foregroundRangeMarkers.put(new Integer(index), markers); } markers.add(marker); } else if (layer == Layer.BACKGROUND) { markers = (Collection) this.backgroundRangeMarkers.get( new Integer(index)); if (markers == null) { markers = new java.util.ArrayList(); this.backgroundRangeMarkers.put(new Integer(index), markers); } markers.add(marker); } marker.addChangeListener(this); if (notify) { fireChangeEvent(); } } /** * Clears the (foreground and background) range markers for a particular * renderer. * * @param index the renderer index. */ public void clearRangeMarkers(int index) { Integer key = new Integer(index); if (this.backgroundRangeMarkers != null) { Collection markers = (Collection) this.backgroundRangeMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } if (this.foregroundRangeMarkers != null) { Collection markers = (Collection) this.foregroundRangeMarkers.get(key); if (markers != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker m = (Marker) iterator.next(); m.removeChangeListener(this); } markers.clear(); } } fireChangeEvent(); } /** * Removes a marker for the range axis and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param marker the marker. * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeRangeMarker(Marker marker) { return removeRangeMarker(marker, Layer.FOREGROUND); } /** * Removes a marker for the range axis in the specified layer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param marker the marker (null not permitted). * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeRangeMarker(Marker marker, Layer layer) { return removeRangeMarker(0, marker, layer); } /** * Removes a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.7 */ public boolean removeRangeMarker(int index, Marker marker, Layer layer) { return removeRangeMarker(index, marker, layer, true); } /** * Removes a marker for a specific dataset/renderer and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param index the dataset/renderer index. * @param marker the marker. * @param layer the layer (foreground or background). * @param notify notify listeners? * * @return A boolean indicating whether or not the marker was actually * removed. * * @since 1.0.10 */ public boolean removeRangeMarker(int index, Marker marker, Layer layer, boolean notify) { if (marker == null) { throw new IllegalArgumentException("Null 'marker' argument."); } ArrayList markers; if (layer == Layer.FOREGROUND) { markers = (ArrayList) this.foregroundRangeMarkers.get( new Integer(index)); } else { markers = (ArrayList) this.backgroundRangeMarkers.get( new Integer(index)); } if (markers == null) { return false; } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); } return removed; } /** * Adds an annotation to the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param annotation the annotation (null not permitted). * * @see #getAnnotations() * @see #removeAnnotation(XYAnnotation) */ public void addAnnotation(XYAnnotation annotation) { addAnnotation(annotation, true); } /** * Adds an annotation to the plot and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param annotation the annotation (null not permitted). * @param notify notify listeners? * * @since 1.0.10 */ public void addAnnotation(XYAnnotation annotation, boolean notify) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } this.annotations.add(annotation); if (notify) { fireChangeEvent(); } } /** * Removes an annotation from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param annotation the annotation (null not permitted). * * @return A boolean (indicates whether or not the annotation was removed). * * @see #addAnnotation(XYAnnotation) * @see #getAnnotations() */ public boolean removeAnnotation(XYAnnotation annotation) { return removeAnnotation(annotation, true); } /** * Removes an annotation from the plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param annotation the annotation (null not permitted). * @param notify notify listeners? * * @return A boolean (indicates whether or not the annotation was removed). * * @since 1.0.10 */ public boolean removeAnnotation(XYAnnotation annotation, boolean notify) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } boolean removed = this.annotations.remove(annotation); if (removed && notify) { fireChangeEvent(); } return removed; } /** * Returns the list of annotations. * * @return The list of annotations. * * @since 1.0.1 * * @see #addAnnotation(XYAnnotation) */ public List getAnnotations() { return new ArrayList(this.annotations); } /** * Clears all the annotations and sends a {@link PlotChangeEvent} to all * registered listeners. * * @see #addAnnotation(XYAnnotation) */ public void clearAnnotations() { this.annotations.clear(); fireChangeEvent(); } /** * Calculates the space required for all the axes in the plot. * * @param g2 the graphics device. * @param plotArea the plot area. * * @return The required space. */ protected AxisSpace calculateAxisSpace(Graphics2D g2, Rectangle2D plotArea) { AxisSpace space = new AxisSpace(); space = calculateRangeAxisSpace(g2, plotArea, space); Rectangle2D revPlotArea = space.shrink(plotArea, null); space = calculateDomainAxisSpace(g2, revPlotArea, space); return space; } /** * Calculates the space required for the domain axis/axes. * * @param g2 the graphics device. * @param plotArea the plot area. * @param space a carrier for the result (null permitted). * * @return The required space. */ protected AxisSpace calculateDomainAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) { if (space == null) { space = new AxisSpace(); } // reserve some space for the domain axis... if (this.fixedDomainAxisSpace != null) { if (this.orientation == PlotOrientation.HORIZONTAL) { space.ensureAtLeast(this.fixedDomainAxisSpace.getLeft(), RectangleEdge.LEFT); space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), RectangleEdge.RIGHT); } else if (this.orientation == PlotOrientation.VERTICAL) { space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), RectangleEdge.TOP); space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), RectangleEdge.BOTTOM); } } else { // reserve space for the domain axes... for (int i = 0; i < this.domainAxes.size(); i++) { Axis axis = (Axis) this.domainAxes.get(i); if (axis != null) { RectangleEdge edge = getDomainAxisEdge(i); space = axis.reserveSpace(g2, this, plotArea, edge, space); } } } return space; } /** * Calculates the space required for the range axis/axes. * * @param g2 the graphics device. * @param plotArea the plot area. * @param space a carrier for the result (null permitted). * * @return The required space. */ protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, Rectangle2D plotArea, AxisSpace space) { if (space == null) { space = new AxisSpace(); } // reserve some space for the range axis... if (this.fixedRangeAxisSpace != null) { if (this.orientation == PlotOrientation.HORIZONTAL) { space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), RectangleEdge.TOP); space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), RectangleEdge.BOTTOM); } else if (this.orientation == PlotOrientation.VERTICAL) { space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), RectangleEdge.LEFT); space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), RectangleEdge.RIGHT); } } else { // reserve space for the range axes... for (int i = 0; i < this.rangeAxes.size(); i++) { Axis axis = (Axis) this.rangeAxes.get(i); if (axis != null) { RectangleEdge edge = getRangeAxisEdge(i); space = axis.reserveSpace(g2, this, plotArea, edge, space); } } } return space; } /** * Draws the plot within the specified area on a graphics device. * * @param g2 the graphics device. * @param area the plot area (in Java2D space). * @param anchor an anchor point in Java2D space (null * permitted). * @param parentState the state from the parent plot, if there is one * (null permitted). * @param info collects chart drawing information (null * permitted). */ public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) { // if the plot area is too small, just return... boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); if (b1 || b2) { return; } // record the plot area... if (info != null) { info.setPlotArea(area); } // adjust the drawing area for the plot insets (if any)... RectangleInsets insets = getInsets(); insets.trim(area); AxisSpace space = calculateAxisSpace(g2, area); Rectangle2D dataArea = space.shrink(area, null); this.axisOffset.trim(dataArea); createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); Map axisStateMap = drawAxes(g2, area, dataArea, info); PlotOrientation orient = getOrientation(); // the anchor point is typically the point where the mouse last // clicked - the crosshairs will be driven off this point... if (anchor != null && !dataArea.contains(anchor)) { anchor = null; } CrosshairState crosshairState = new CrosshairState(); crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); crosshairState.setAnchor(anchor); crosshairState.setAnchorX(Double.NaN); crosshairState.setAnchorY(Double.NaN); if (anchor != null) { ValueAxis domainAxis = getDomainAxis(); if (domainAxis != null) { double x; if (orient == PlotOrientation.VERTICAL) { x = domainAxis.java2DToValue(anchor.getX(), dataArea, getDomainAxisEdge()); } else { x = domainAxis.java2DToValue(anchor.getY(), dataArea, getDomainAxisEdge()); } crosshairState.setAnchorX(x); } ValueAxis rangeAxis = getRangeAxis(); if (rangeAxis != null) { double y; if (orient == PlotOrientation.VERTICAL) { y = rangeAxis.java2DToValue(anchor.getY(), dataArea, getRangeAxisEdge()); } else { y = rangeAxis.java2DToValue(anchor.getX(), dataArea, getRangeAxisEdge()); } crosshairState.setAnchorY(y); } } crosshairState.setCrosshairX(getDomainCrosshairValue()); crosshairState.setCrosshairY(getRangeCrosshairValue()); Shape originalClip = g2.getClip(); Composite originalComposite = g2.getComposite(); g2.clip(dataArea); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())); AxisState domainAxisState = (AxisState) axisStateMap.get( getDomainAxis()); if (domainAxisState == null) { if (parentState != null) { domainAxisState = (AxisState) parentState.getSharedAxisStates() .get(getDomainAxis()); } } AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis()); if (rangeAxisState == null) { if (parentState != null) { rangeAxisState = (AxisState) parentState.getSharedAxisStates() .get(getRangeAxis()); } } if (domainAxisState != null) { drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); } if (rangeAxisState != null) { drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); } if (domainAxisState != null) { drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); drawZeroDomainBaseline(g2, dataArea); } if (rangeAxisState != null) { drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); drawZeroRangeBaseline(g2, dataArea); } // draw the markers that are associated with a specific renderer... for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); } // now draw annotations and render data items... boolean foundData = false; DatasetRenderingOrder order = getDatasetRenderingOrder(); if (order == DatasetRenderingOrder.FORWARD) { // draw background annotations int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } // render data items... for (int i = 0; i < getDatasetCount(); i++) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } // draw foreground annotations for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = getRenderer(i); if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } else if (order == DatasetRenderingOrder.REVERSE) { // draw background annotations int rendererCount = this.renderers.size(); for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { // we need the dataset to make continue; // a link to the axes } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.BACKGROUND, info); } } for (int i = getDatasetCount() - 1; i >= 0; i--) { foundData = render(g2, dataArea, i, info, crosshairState) || foundData; } // draw foreground annotations for (int i = rendererCount - 1; i >= 0; i--) { XYItemRenderer r = getRenderer(i); if (i >= getDatasetCount()) { // we need the dataset to make continue; // a link to the axes } if (r != null) { ValueAxis domainAxis = getDomainAxisForDataset(i); ValueAxis rangeAxis = getRangeAxisForDataset(i); r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, Layer.FOREGROUND, info); } } } // draw domain crosshair if required... int xAxisIndex = crosshairState.getDomainAxisIndex(); ValueAxis xAxis = getDomainAxis(xAxisIndex); RectangleEdge xAxisEdge = getDomainAxisEdge(xAxisIndex); if (!this.domainCrosshairLockedOnData && anchor != null) { double xx; if (orient == PlotOrientation.VERTICAL) { xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); } else { xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); } crosshairState.setCrosshairX(xx); } setDomainCrosshairValue(crosshairState.getCrosshairX(), false); if (isDomainCrosshairVisible()) { double x = getDomainCrosshairValue(); Paint paint = getDomainCrosshairPaint(); Stroke stroke = getDomainCrosshairStroke(); drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); } // draw range crosshair if required... int yAxisIndex = crosshairState.getRangeAxisIndex(); ValueAxis yAxis = getRangeAxis(yAxisIndex); RectangleEdge yAxisEdge = getRangeAxisEdge(yAxisIndex); if (!this.rangeCrosshairLockedOnData && anchor != null) { double yy; if (orient == PlotOrientation.VERTICAL) { yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); } else { yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); } crosshairState.setCrosshairY(yy); } setRangeCrosshairValue(crosshairState.getCrosshairY(), false); if (isRangeCrosshairVisible()) { double y = getRangeCrosshairValue(); Paint paint = getRangeCrosshairPaint(); Stroke stroke = getRangeCrosshairStroke(); drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); } if (!foundData) { drawNoDataMessage(g2, dataArea); } for (int i = 0; i < this.renderers.size(); i++) { drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); } for (int i = 0; i < this.renderers.size(); i++) { drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); } drawAnnotations(g2, dataArea, info); g2.setClip(originalClip); g2.setComposite(originalComposite); drawOutline(g2, dataArea); } /** * Draws the background for the plot. * * @param g2 the graphics device. * @param area the area. */ public void drawBackground(Graphics2D g2, Rectangle2D area) { fillBackground(g2, area, this.orientation); drawQuadrants(g2, area); drawBackgroundImage(g2, area); } /** * Draws the quadrants. * * @param g2 the graphics device. * @param area the area. * * @see #setQuadrantOrigin(Point2D) * @see #setQuadrantPaint(int, Paint) */ protected void drawQuadrants(Graphics2D g2, Rectangle2D area) { // 0 | 1 // --+-- // 2 | 3 boolean somethingToDraw = false; ValueAxis xAxis = getDomainAxis(); if (xAxis == null) { // we can't draw quadrants without a valid x-axis return; } double x = xAxis.getRange().constrain(this.quadrantOrigin.getX()); double xx = xAxis.valueToJava2D(x, area, getDomainAxisEdge()); ValueAxis yAxis = getRangeAxis(); if (yAxis == null) { // we can't draw quadrants without a valid y-axis return; } double y = yAxis.getRange().constrain(this.quadrantOrigin.getY()); double yy = yAxis.valueToJava2D(y, area, getRangeAxisEdge()); double xmin = xAxis.getLowerBound(); double xxmin = xAxis.valueToJava2D(xmin, area, getDomainAxisEdge()); double xmax = xAxis.getUpperBound(); double xxmax = xAxis.valueToJava2D(xmax, area, getDomainAxisEdge()); double ymin = yAxis.getLowerBound(); double yymin = yAxis.valueToJava2D(ymin, area, getRangeAxisEdge()); double ymax = yAxis.getUpperBound(); double yymax = yAxis.valueToJava2D(ymax, area, getRangeAxisEdge()); Rectangle2D[] r = new Rectangle2D[] {null, null, null, null}; if (this.quadrantPaint[0] != null) { if (x > xmin && y < ymax) { if (this.orientation == PlotOrientation.HORIZONTAL) { r[0] = new Rectangle2D.Double(Math.min(yymax, yy), Math.min(xxmin, xx), Math.abs(yy - yymax), Math.abs(xx - xxmin)); } else { // PlotOrientation.VERTICAL r[0] = new Rectangle2D.Double(Math.min(xxmin, xx), Math.min(yymax, yy), Math.abs(xx - xxmin), Math.abs(yy - yymax)); } somethingToDraw = true; } } if (this.quadrantPaint[1] != null) { if (x < xmax && y < ymax) { if (this.orientation == PlotOrientation.HORIZONTAL) { r[1] = new Rectangle2D.Double(Math.min(yymax, yy), Math.min(xxmax, xx), Math.abs(yy - yymax), Math.abs(xx - xxmax)); } else { // PlotOrientation.VERTICAL r[1] = new Rectangle2D.Double(Math.min(xx, xxmax), Math.min(yymax, yy), Math.abs(xx - xxmax), Math.abs(yy - yymax)); } somethingToDraw = true; } } if (this.quadrantPaint[2] != null) { if (x > xmin && y > ymin) { if (this.orientation == PlotOrientation.HORIZONTAL) { r[2] = new Rectangle2D.Double(Math.min(yymin, yy), Math.min(xxmin, xx), Math.abs(yy - yymin), Math.abs(xx - xxmin)); } else { // PlotOrientation.VERTICAL r[2] = new Rectangle2D.Double(Math.min(xxmin, xx), Math.min(yymin, yy), Math.abs(xx - xxmin), Math.abs(yy - yymin)); } somethingToDraw = true; } } if (this.quadrantPaint[3] != null) { if (x < xmax && y > ymin) { if (this.orientation == PlotOrientation.HORIZONTAL) { r[3] = new Rectangle2D.Double(Math.min(yymin, yy), Math.min(xxmax, xx), Math.abs(yy - yymin), Math.abs(xx - xxmax)); } else { // PlotOrientation.VERTICAL r[3] = new Rectangle2D.Double(Math.min(xx, xxmax), Math.min(yymin, yy), Math.abs(xx - xxmax), Math.abs(yy - yymin)); } somethingToDraw = true; } } if (somethingToDraw) { Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getBackgroundAlpha())); for (int i = 0; i < 4; i++) { if (this.quadrantPaint[i] != null && r[i] != null) { g2.setPaint(this.quadrantPaint[i]); g2.fill(r[i]); } } g2.setComposite(originalComposite); } } /** * Draws the domain tick bands, if any. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #setDomainTickBandPaint(Paint) */ public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea, List ticks) { Paint bandPaint = getDomainTickBandPaint(); if (bandPaint != null) { boolean fillBand = false; ValueAxis xAxis = getDomainAxis(); double previous = xAxis.getLowerBound(); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double current = tick.getValue(); if (fillBand) { getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea, previous, current); } previous = current; fillBand = !fillBand; } double end = xAxis.getUpperBound(); if (fillBand) { getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea, previous, end); } } } /** * Draws the range tick bands, if any. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #setRangeTickBandPaint(Paint) */ public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea, List ticks) { Paint bandPaint = getRangeTickBandPaint(); if (bandPaint != null) { boolean fillBand = false; ValueAxis axis = getRangeAxis(); double previous = axis.getLowerBound(); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { ValueTick tick = (ValueTick) iterator.next(); double current = tick.getValue(); if (fillBand) { getRenderer().fillRangeGridBand(g2, this, axis, dataArea, previous, current); } previous = current; fillBand = !fillBand; } double end = axis.getUpperBound(); if (fillBand) { getRenderer().fillRangeGridBand(g2, this, axis, dataArea, previous, end); } } } /** * A utility method for drawing the axes. * * @param g2 the graphics device (null not permitted). * @param plotArea the plot area (null not permitted). * @param dataArea the data area (null not permitted). * @param plotState collects information about the plot (null * permitted). * * @return A map containing the state for each axis drawn. */ protected Map drawAxes(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, PlotRenderingInfo plotState) { AxisCollection axisCollection = new AxisCollection(); // add domain axes to lists... for (int index = 0; index < this.domainAxes.size(); index++) { ValueAxis axis = (ValueAxis) this.domainAxes.get(index); if (axis != null) { axisCollection.add(axis, getDomainAxisEdge(index)); } } // add range axes to lists... for (int index = 0; index < this.rangeAxes.size(); index++) { ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(index); if (yAxis != null) { axisCollection.add(yAxis, getRangeAxisEdge(index)); } } Map axisStateMap = new HashMap(); // draw the top axes double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset( dataArea.getHeight()); Iterator iterator = axisCollection.getAxesAtTop().iterator(); while (iterator.hasNext()) { ValueAxis axis = (ValueAxis) iterator.next(); AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.TOP, plotState); cursor = info.getCursor(); axisStateMap.put(axis, info); } // draw the bottom axes cursor = dataArea.getMaxY() + this.axisOffset.calculateBottomOutset(dataArea.getHeight()); iterator = axisCollection.getAxesAtBottom().iterator(); while (iterator.hasNext()) { ValueAxis axis = (ValueAxis) iterator.next(); AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, plotState); cursor = info.getCursor(); axisStateMap.put(axis, info); } // draw the left axes cursor = dataArea.getMinX() - this.axisOffset.calculateLeftOutset(dataArea.getWidth()); iterator = axisCollection.getAxesAtLeft().iterator(); while (iterator.hasNext()) { ValueAxis axis = (ValueAxis) iterator.next(); AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, plotState); cursor = info.getCursor(); axisStateMap.put(axis, info); } // draw the right axes cursor = dataArea.getMaxX() + this.axisOffset.calculateRightOutset(dataArea.getWidth()); iterator = axisCollection.getAxesAtRight().iterator(); while (iterator.hasNext()) { ValueAxis axis = (ValueAxis) iterator.next(); AxisState info = axis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.RIGHT, plotState); cursor = info.getCursor(); axisStateMap.put(axis, info); } return axisStateMap; } /** * Draws a representation of the data within the dataArea region, using the * current renderer. *

* The info and crosshairState arguments may be * null. * * @param g2 the graphics device. * @param dataArea the region in which the data is to be drawn. * @param index the dataset index. * @param info an optional object for collection dimension information. * @param crosshairState collects crosshair information * (null permitted). * * @return A flag that indicates whether any data was actually rendered. */ public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, PlotRenderingInfo info, CrosshairState crosshairState) { boolean foundData = false; XYDataset dataset = getDataset(index); if (!DatasetUtilities.isEmptyOrNull(dataset)) { foundData = true; ValueAxis xAxis = getDomainAxisForDataset(index); ValueAxis yAxis = getRangeAxisForDataset(index); if (xAxis == null || yAxis == null) { return foundData; // can't render anything without axes } XYItemRenderer renderer = getRenderer(index); if (renderer == null) { renderer = getRenderer(); if (renderer == null) { // no default renderer available return foundData; } } XYItemRendererState state = renderer.initialise(g2, dataArea, this, dataset, info); int passCount = renderer.getPassCount(); SeriesRenderingOrder seriesOrder = getSeriesRenderingOrder(); if (seriesOrder == SeriesRenderingOrder.REVERSE) { //render series in reverse order for (int pass = 0; pass < passCount; pass++) { int seriesCount = dataset.getSeriesCount(); for (int series = seriesCount - 1; series >= 0; series--) { int firstItem = 0; int lastItem = dataset.getItemCount(series) - 1; if (lastItem == -1) { continue; } if (state.getProcessVisibleItemsOnly()) { int[] itemBounds = RendererUtilities.findLiveItems( dataset, series, xAxis.getLowerBound(), xAxis.getUpperBound()); firstItem = Math.max(itemBounds[0] - 1, 0); lastItem = Math.min(itemBounds[1] + 1, lastItem); } state.startSeriesPass(dataset, series, firstItem, lastItem, pass, passCount); for (int item = firstItem; item <= lastItem; item++) { renderer.drawItem(g2, state, dataArea, info, this, xAxis, yAxis, dataset, series, item, crosshairState, pass); } state.endSeriesPass(dataset, series, firstItem, lastItem, pass, passCount); } } } else { //render series in forward order for (int pass = 0; pass < passCount; pass++) { int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int firstItem = 0; int lastItem = dataset.getItemCount(series) - 1; if (state.getProcessVisibleItemsOnly()) { int[] itemBounds = RendererUtilities.findLiveItems( dataset, series, xAxis.getLowerBound(), xAxis.getUpperBound()); firstItem = Math.max(itemBounds[0] - 1, 0); lastItem = Math.min(itemBounds[1] + 1, lastItem); } state.startSeriesPass(dataset, series, firstItem, lastItem, pass, passCount); for (int item = firstItem; item <= lastItem; item++) { renderer.drawItem(g2, state, dataArea, info, this, xAxis, yAxis, dataset, series, item, crosshairState, pass); } state.endSeriesPass(dataset, series, firstItem, lastItem, pass, passCount); } } } } return foundData; } /** * Returns the domain axis for a dataset. * * @param index the dataset index. * * @return The axis. */ public ValueAxis getDomainAxisForDataset(int index) { int upper = Math.max(getDatasetCount(), getRendererCount()); if (index < 0 || index >= upper) { throw new IllegalArgumentException("Index " + index + " out of bounds."); } ValueAxis valueAxis = null; List axisIndices = (List) this.datasetToDomainAxesMap.get( new Integer(index)); if (axisIndices != null) { // the first axis in the list is used for data <--> Java2D Integer axisIndex = (Integer) axisIndices.get(0); valueAxis = getDomainAxis(axisIndex.intValue()); } else { valueAxis = getDomainAxis(0); } return valueAxis; } /** * Returns the range axis for a dataset. * * @param index the dataset index. * * @return The axis. */ public ValueAxis getRangeAxisForDataset(int index) { int upper = Math.max(getDatasetCount(), getRendererCount()); if (index < 0 || index >= upper) { throw new IllegalArgumentException("Index " + index + " out of bounds."); } ValueAxis valueAxis = null; List axisIndices = (List) this.datasetToRangeAxesMap.get( new Integer(index)); if (axisIndices != null) { // the first axis in the list is used for data <--> Java2D Integer axisIndex = (Integer) axisIndices.get(0); valueAxis = getRangeAxis(axisIndex.intValue()); } else { valueAxis = getRangeAxis(0); } return valueAxis; } /** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // no renderer, no gridlines... if (getRenderer() == null) { return; } // draw the domain grid lines, if any... if (isDomainGridlinesVisible() || isDomainMinorGridlinesVisible()) { Stroke gridStroke = null; Paint gridPaint = null; Iterator iterator = ticks.iterator(); boolean paintLine = false; while (iterator.hasNext()) { paintLine = false; ValueTick tick = (ValueTick) iterator.next(); if ((tick.getTickType() == TickType.MINOR) && isDomainMinorGridlinesVisible()){ gridStroke = getDomainMinorGridlineStroke(); gridPaint = getDomainMinorGridlinePaint(); paintLine = true; } else if ((tick.getTickType() == TickType.MAJOR) && isDomainGridlinesVisible()){ gridStroke = getDomainGridlineStroke(); gridPaint = getDomainGridlinePaint(); paintLine = true; } XYItemRenderer r = getRenderer(); if ((r instanceof AbstractXYItemRenderer) && paintLine) { ((AbstractXYItemRenderer) r).drawDomainLine(g2, this, getDomainAxis(), dataArea, tick.getValue(), gridPaint, gridStroke); } } } } /** * Draws the gridlines for the plot's primary range axis, if they are * visible. * * @param g2 the graphics device. * @param area the data area. * @param ticks the ticks. * * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List) */ protected void drawRangeGridlines(Graphics2D g2, Rectangle2D area, List ticks) { // no renderer, no gridlines... if (getRenderer() == null) { return; } // draw the range grid lines, if any... if (isRangeGridlinesVisible() || isRangeMinorGridlinesVisible()) { Stroke gridStroke = null; Paint gridPaint = null; ValueAxis axis = getRangeAxis(); if (axis != null) { Iterator iterator = ticks.iterator(); boolean paintLine = false; while (iterator.hasNext()) { paintLine = false; ValueTick tick = (ValueTick) iterator.next(); if ((tick.getTickType() == TickType.MINOR) && isRangeMinorGridlinesVisible()) { gridStroke = getRangeMinorGridlineStroke(); gridPaint = getRangeMinorGridlinePaint(); paintLine = true; } else if ((tick.getTickType() == TickType.MAJOR) && isRangeGridlinesVisible()) { gridStroke = getRangeGridlineStroke(); gridPaint = getRangeGridlinePaint(); paintLine = true; } if ((tick.getValue() != 0.0 || !isRangeZeroBaselineVisible()) && paintLine) { getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, tick.getValue(), gridPaint, gridStroke); } } } } } /** * Draws a base line across the chart at value zero on the domain axis. * * @param g2 the graphics device. * @param area the data area. * * @see #setDomainZeroBaselineVisible(boolean) * * @since 1.0.5 */ protected void drawZeroDomainBaseline(Graphics2D g2, Rectangle2D area) { if (isDomainZeroBaselineVisible()) { XYItemRenderer r = getRenderer(); // FIXME: the renderer interface doesn't have the drawDomainLine() // method, so we have to rely on the renderer being a subclass of // AbstractXYItemRenderer (which is lame) if (r instanceof AbstractXYItemRenderer) { AbstractXYItemRenderer renderer = (AbstractXYItemRenderer) r; renderer.drawDomainLine(g2, this, getDomainAxis(), area, 0.0, this.domainZeroBaselinePaint, this.domainZeroBaselineStroke); } } } /** * Draws a base line across the chart at value zero on the range axis. * * @param g2 the graphics device. * @param area the data area. * * @see #setRangeZeroBaselineVisible(boolean) */ protected void drawZeroRangeBaseline(Graphics2D g2, Rectangle2D area) { if (isRangeZeroBaselineVisible()) { getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, 0.0, this.rangeZeroBaselinePaint, this.rangeZeroBaselineStroke); } } /** * Draws the annotations for the plot. * * @param g2 the graphics device. * @param dataArea the data area. * @param info the chart rendering info. */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info) { Iterator iterator = this.annotations.iterator(); while (iterator.hasNext()) { XYAnnotation annotation = (XYAnnotation) iterator.next(); ValueAxis xAxis = getDomainAxis(); ValueAxis yAxis = getRangeAxis(); annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info); } } /** * Draws the domain markers (if any) for an axis and layer. This method is * typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). */ protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { XYItemRenderer r = getRenderer(index); if (r == null) { return; } // check that the renderer has a corresponding dataset (it doesn't // matter if the dataset is null) if (index >= getDatasetCount()) { return; } Collection markers = getDomainMarkers(index, layer); ValueAxis axis = getDomainAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawDomainMarker(g2, this, axis, marker, dataArea); } } } /** * Draws the range markers (if any) for a renderer and layer. This method * is typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). */ protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { XYItemRenderer r = getRenderer(index); if (r == null) { return; } // check that the renderer has a corresponding dataset (it doesn't // matter if the dataset is null) if (index >= getDatasetCount()) { return; } Collection markers = getRangeMarkers(index, layer); ValueAxis axis = getRangeAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawRangeMarker(g2, this, axis, marker, dataArea); } } } /** * Returns the list of domain markers (read only) for the specified layer. * * @param layer the layer (foreground or background). * * @return The list of domain markers. * * @see #getRangeMarkers(Layer) */ public Collection getDomainMarkers(Layer layer) { return getDomainMarkers(0, layer); } /** * Returns the list of range markers (read only) for the specified layer. * * @param layer the layer (foreground or background). * * @return The list of range markers. * * @see #getDomainMarkers(Layer) */ public Collection getRangeMarkers(Layer layer) { return getRangeMarkers(0, layer); } /** * Returns a collection of domain markers for a particular renderer and * layer. * * @param index the renderer index. * @param layer the layer. * * @return A collection of markers (possibly null). * * @see #getRangeMarkers(int, Layer) */ public Collection getDomainMarkers(int index, Layer layer) { Collection result = null; Integer key = new Integer(index); if (layer == Layer.FOREGROUND) { result = (Collection) this.foregroundDomainMarkers.get(key); } else if (layer == Layer.BACKGROUND) { result = (Collection) this.backgroundDomainMarkers.get(key); } if (result != null) { result = Collections.unmodifiableCollection(result); } return result; } /** * Returns a collection of range markers for a particular renderer and * layer. * * @param index the renderer index. * @param layer the layer. * * @return A collection of markers (possibly null). * * @see #getDomainMarkers(int, Layer) */ public Collection getRangeMarkers(int index, Layer layer) { Collection result = null; Integer key = new Integer(index); if (layer == Layer.FOREGROUND) { result = (Collection) this.foregroundRangeMarkers.get(key); } else if (layer == Layer.BACKGROUND) { result = (Collection) this.backgroundRangeMarkers.get(key); } if (result != null) { result = Collections.unmodifiableCollection(result); } return result; } /** * Utility method for drawing a horizontal line across the data area of the * plot. * * @param g2 the graphics device. * @param dataArea the data area. * @param value the coordinate, where to draw the line. * @param stroke the stroke to use. * @param paint the paint to use. */ protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { ValueAxis axis = getRangeAxis(); if (getOrientation() == PlotOrientation.HORIZONTAL) { axis = getDomainAxis(); } if (axis.getRange().contains(value)) { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } } /** * Draws a domain crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.4 */ protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (axis.getRange().contains(value)) { Line2D line = null; if (orientation == PlotOrientation.VERTICAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } } /** * Utility method for drawing a vertical line on the data area of the plot. * * @param g2 the graphics device. * @param dataArea the data area. * @param value the coordinate, where to draw the line. * @param stroke the stroke to use. * @param paint the paint to use. */ protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { ValueAxis axis = getDomainAxis(); if (getOrientation() == PlotOrientation.HORIZONTAL) { axis = getRangeAxis(); } if (axis.getRange().contains(value)) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } } /** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.4 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (axis.getRange().contains(value)) { Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } } /** * Handles a 'click' on the plot by updating the anchor values. * * @param x the x-coordinate, where the click occurred, in Java2D space. * @param y the y-coordinate, where the click occurred, in Java2D space. * @param info object containing information about the plot dimensions. */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { // set the anchor value for the horizontal axis... ValueAxis xaxis = getDomainAxis(); if (xaxis != null) { double hvalue = xaxis.java2DToValue(x, info.getDataArea(), getDomainAxisEdge()); setDomainCrosshairValue(hvalue); } // set the anchor value for the vertical axis... ValueAxis yaxis = getRangeAxis(); if (yaxis != null) { double vvalue = yaxis.java2DToValue(y, info.getDataArea(), getRangeAxisEdge()); setRangeCrosshairValue(vvalue); } } } /** * A utility method that returns a list of datasets that are mapped to a * particular axis. * * @param axisIndex the axis index (null not permitted). * * @return A list of datasets. */ private List getDatasetsMappedToDomainAxis(Integer axisIndex) { if (axisIndex == null) { throw new IllegalArgumentException("Null 'axisIndex' argument."); } List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { List mappedAxes = (List) this.datasetToDomainAxesMap.get( new Integer(i)); if (mappedAxes == null) { if (axisIndex.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxes.contains(axisIndex)) { result.add(this.datasets.get(i)); } } } return result; } /** * A utility method that returns a list of datasets that are mapped to a * particular axis. * * @param axisIndex the axis index (null not permitted). * * @return A list of datasets. */ private List getDatasetsMappedToRangeAxis(Integer axisIndex) { if (axisIndex == null) { throw new IllegalArgumentException("Null 'axisIndex' argument."); } List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { List mappedAxes = (List) this.datasetToRangeAxesMap.get( new Integer(i)); if (mappedAxes == null) { if (axisIndex.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxes.contains(axisIndex)) { result.add(this.datasets.get(i)); } } } return result; } /** * Returns the index of the given domain axis. * * @param axis the axis. * * @return The axis index. * * @see #getRangeAxisIndex(ValueAxis) */ public int getDomainAxisIndex(ValueAxis axis) { int result = this.domainAxes.indexOf(axis); if (result < 0) { // try the parent plot Plot parent = getParent(); if (parent instanceof XYPlot) { XYPlot p = (XYPlot) parent; result = p.getDomainAxisIndex(axis); } } return result; } /** * Returns the index of the given range axis. * * @param axis the axis. * * @return The axis index. * * @see #getDomainAxisIndex(ValueAxis) */ public int getRangeAxisIndex(ValueAxis axis) { int result = this.rangeAxes.indexOf(axis); if (result < 0) { // try the parent plot Plot parent = getParent(); if (parent instanceof XYPlot) { XYPlot p = (XYPlot) parent; result = p.getRangeAxisIndex(axis); } } return result; } /** * Returns the range for the specified axis. * * @param axis the axis. * * @return The range. */ public Range getDataRange(ValueAxis axis) { Range result = null; List mappedDatasets = new ArrayList(); List includedAnnotations = new ArrayList(); boolean isDomainAxis = true; // is it a domain axis? int domainIndex = getDomainAxisIndex(axis); if (domainIndex >= 0) { isDomainAxis = true; mappedDatasets.addAll(getDatasetsMappedToDomainAxis( new Integer(domainIndex))); if (domainIndex == 0) { // grab the plot's annotations Iterator iterator = this.annotations.iterator(); while (iterator.hasNext()) { XYAnnotation annotation = (XYAnnotation) iterator.next(); if (annotation instanceof XYAnnotationBoundsInfo) { includedAnnotations.add(annotation); } } } } // or is it a range axis? int rangeIndex = getRangeAxisIndex(axis); if (rangeIndex >= 0) { isDomainAxis = false; mappedDatasets.addAll(getDatasetsMappedToRangeAxis( new Integer(rangeIndex))); if (rangeIndex == 0) { Iterator iterator = this.annotations.iterator(); while (iterator.hasNext()) { XYAnnotation annotation = (XYAnnotation) iterator.next(); if (annotation instanceof XYAnnotationBoundsInfo) { includedAnnotations.add(annotation); } } } } // iterate through the datasets that map to the axis and get the union // of the ranges. Iterator iterator = mappedDatasets.iterator(); while (iterator.hasNext()) { XYDataset d = (XYDataset) iterator.next(); if (d != null) { XYItemRenderer r = getRendererForDataset(d); if (isDomainAxis) { if (r != null) { result = Range.combine(result, r.findDomainBounds(d)); } else { result = Range.combine(result, DatasetUtilities.findDomainBounds(d)); } } else { if (r != null) { result = Range.combine(result, r.findRangeBounds(d)); } else { result = Range.combine(result, DatasetUtilities.findRangeBounds(d)); } } // FIXME: the XYItemRenderer interface doesn't specify the // getAnnotations() method but it should if (r instanceof AbstractXYItemRenderer) { AbstractXYItemRenderer rr = (AbstractXYItemRenderer) r; Collection c = rr.getAnnotations(); Iterator i = c.iterator(); while (i.hasNext()) { XYAnnotation a = (XYAnnotation) i.next(); if (a instanceof XYAnnotationBoundsInfo) { includedAnnotations.add(a); } } } } } Iterator it = includedAnnotations.iterator(); while (it.hasNext()) { XYAnnotationBoundsInfo xyabi = (XYAnnotationBoundsInfo) it.next(); if (xyabi.getIncludeInDataBounds()) { if (isDomainAxis) { result = Range.combine(result, xyabi.getXRange()); } else { result = Range.combine(result, xyabi.getYRange()); } } } return result; } /** * Receives notification of a change to the plot's dataset. *

* The axis ranges are updated if necessary. * * @param event information about the event (not used here). */ public void datasetChanged(DatasetChangeEvent event) { configureDomainAxes(); configureRangeAxes(); if (getParent() != null) { getParent().datasetChanged(event); } else { PlotChangeEvent e = new PlotChangeEvent(this); e.setType(ChartChangeEventType.DATASET_UPDATED); notifyListeners(e); } } /** * Receives notification of a renderer change event. * * @param event the event. */ public void rendererChanged(RendererChangeEvent event) { // if the event was caused by a change to series visibility, then // the axis ranges might need updating... if (event.getSeriesVisibilityChanged()) { configureDomainAxes(); configureRangeAxes(); } fireChangeEvent(); } /** * Returns a flag indicating whether or not the domain crosshair is visible. * * @return The flag. * * @see #setDomainCrosshairVisible(boolean) */ public boolean isDomainCrosshairVisible() { return this.domainCrosshairVisible; } /** * Sets the flag indicating whether or not the domain crosshair is visible * and, if the flag changes, sends a {@link PlotChangeEvent} to all * registered listeners. * * @param flag the new value of the flag. * * @see #isDomainCrosshairVisible() */ public void setDomainCrosshairVisible(boolean flag) { if (this.domainCrosshairVisible != flag) { this.domainCrosshairVisible = flag; fireChangeEvent(); } } /** * Returns a flag indicating whether or not the crosshair should "lock-on" * to actual data values. * * @return The flag. * * @see #setDomainCrosshairLockedOnData(boolean) */ public boolean isDomainCrosshairLockedOnData() { return this.domainCrosshairLockedOnData; } /** * Sets the flag indicating whether or not the domain crosshair should * "lock-on" to actual data values. If the flag value changes, this * method sends a {@link PlotChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #isDomainCrosshairLockedOnData() */ public void setDomainCrosshairLockedOnData(boolean flag) { if (this.domainCrosshairLockedOnData != flag) { this.domainCrosshairLockedOnData = flag; fireChangeEvent(); } } /** * Returns the domain crosshair value. * * @return The value. * * @see #setDomainCrosshairValue(double) */ public double getDomainCrosshairValue() { return this.domainCrosshairValue; } /** * Sets the domain crosshair value and sends a {@link PlotChangeEvent} to * all registered listeners (provided that the domain crosshair is visible). * * @param value the value. * * @see #getDomainCrosshairValue() */ public void setDomainCrosshairValue(double value) { setDomainCrosshairValue(value, true); } /** * Sets the domain crosshair value and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners (provided that the * domain crosshair is visible). * * @param value the new value. * @param notify notify listeners? * * @see #getDomainCrosshairValue() */ public void setDomainCrosshairValue(double value, boolean notify) { this.domainCrosshairValue = value; if (isDomainCrosshairVisible() && notify) { fireChangeEvent(); } } /** * Returns the {@link Stroke} used to draw the crosshair (if visible). * * @return The crosshair stroke (never null). * * @see #setDomainCrosshairStroke(Stroke) * @see #isDomainCrosshairVisible() * @see #getDomainCrosshairPaint() */ public Stroke getDomainCrosshairStroke() { return this.domainCrosshairStroke; } /** * Sets the Stroke used to draw the crosshairs (if visible) and notifies * registered listeners that the axis has been modified. * * @param stroke the new crosshair stroke (null not * permitted). * * @see #getDomainCrosshairStroke() */ public void setDomainCrosshairStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.domainCrosshairStroke = stroke; fireChangeEvent(); } /** * Returns the domain crosshair paint. * * @return The crosshair paint (never null). * * @see #setDomainCrosshairPaint(Paint) * @see #isDomainCrosshairVisible() * @see #getDomainCrosshairStroke() */ public Paint getDomainCrosshairPaint() { return this.domainCrosshairPaint; } /** * Sets the paint used to draw the crosshairs (if visible) and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the new crosshair paint (null not permitted). * * @see #getDomainCrosshairPaint() */ public void setDomainCrosshairPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainCrosshairPaint = paint; fireChangeEvent(); } /** * Returns a flag indicating whether or not the range crosshair is visible. * * @return The flag. * * @see #setRangeCrosshairVisible(boolean) * @see #isDomainCrosshairVisible() */ public boolean isRangeCrosshairVisible() { return this.rangeCrosshairVisible; } /** * Sets the flag indicating whether or not the range crosshair is visible. * If the flag value changes, this method sends a {@link PlotChangeEvent} * to all registered listeners. * * @param flag the new value of the flag. * * @see #isRangeCrosshairVisible() */ public void setRangeCrosshairVisible(boolean flag) { if (this.rangeCrosshairVisible != flag) { this.rangeCrosshairVisible = flag; fireChangeEvent(); } } /** * Returns a flag indicating whether or not the crosshair should "lock-on" * to actual data values. * * @return The flag. * * @see #setRangeCrosshairLockedOnData(boolean) */ public boolean isRangeCrosshairLockedOnData() { return this.rangeCrosshairLockedOnData; } /** * Sets the flag indicating whether or not the range crosshair should * "lock-on" to actual data values. If the flag value changes, this method * sends a {@link PlotChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #isRangeCrosshairLockedOnData() */ public void setRangeCrosshairLockedOnData(boolean flag) { if (this.rangeCrosshairLockedOnData != flag) { this.rangeCrosshairLockedOnData = flag; fireChangeEvent(); } } /** * Returns the range crosshair value. * * @return The value. * * @see #setRangeCrosshairValue(double) */ public double getRangeCrosshairValue() { return this.rangeCrosshairValue; } /** * Sets the range crosshair value. *

* Registered listeners are notified that the plot has been modified, but * only if the crosshair is visible. * * @param value the new value. * * @see #getRangeCrosshairValue() */ public void setRangeCrosshairValue(double value) { setRangeCrosshairValue(value, true); } /** * Sets the range crosshair value and sends a {@link PlotChangeEvent} to * all registered listeners, but only if the crosshair is visible. * * @param value the new value. * @param notify a flag that controls whether or not listeners are * notified. * * @see #getRangeCrosshairValue() */ public void setRangeCrosshairValue(double value, boolean notify) { this.rangeCrosshairValue = value; if (isRangeCrosshairVisible() && notify) { fireChangeEvent(); } } /** * Returns the stroke used to draw the crosshair (if visible). * * @return The crosshair stroke (never null). * * @see #setRangeCrosshairStroke(Stroke) * @see #isRangeCrosshairVisible() * @see #getRangeCrosshairPaint() */ public Stroke getRangeCrosshairStroke() { return this.rangeCrosshairStroke; } /** * Sets the stroke used to draw the crosshairs (if visible) and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param stroke the new crosshair stroke (null not * permitted). * * @see #getRangeCrosshairStroke() */ public void setRangeCrosshairStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.rangeCrosshairStroke = stroke; fireChangeEvent(); } /** * Returns the range crosshair paint. * * @return The crosshair paint (never null). * * @see #setRangeCrosshairPaint(Paint) * @see #isRangeCrosshairVisible() * @see #getRangeCrosshairStroke() */ public Paint getRangeCrosshairPaint() { return this.rangeCrosshairPaint; } /** * Sets the paint used to color the crosshairs (if visible) and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the new crosshair paint (null not permitted). * * @see #getRangeCrosshairPaint() */ public void setRangeCrosshairPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeCrosshairPaint = paint; fireChangeEvent(); } /** * Returns the fixed domain axis space. * * @return The fixed domain axis space (possibly null). * * @see #setFixedDomainAxisSpace(AxisSpace) */ public AxisSpace getFixedDomainAxisSpace() { return this.fixedDomainAxisSpace; } /** * Sets the fixed domain axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). * * @see #getFixedDomainAxisSpace() */ public void setFixedDomainAxisSpace(AxisSpace space) { setFixedDomainAxisSpace(space, true); } /** * Sets the fixed domain axis space and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param space the space (null permitted). * @param notify notify listeners? * * @see #getFixedDomainAxisSpace() * * @since 1.0.9 */ public void setFixedDomainAxisSpace(AxisSpace space, boolean notify) { this.fixedDomainAxisSpace = space; if (notify) { fireChangeEvent(); } } /** * Returns the fixed range axis space. * * @return The fixed range axis space (possibly null). * * @see #setFixedRangeAxisSpace(AxisSpace) */ public AxisSpace getFixedRangeAxisSpace() { return this.fixedRangeAxisSpace; } /** * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param space the space (null permitted). * * @see #getFixedRangeAxisSpace() */ public void setFixedRangeAxisSpace(AxisSpace space) { setFixedRangeAxisSpace(space, true); } /** * Sets the fixed range axis space and, if requested, sends a * {@link PlotChangeEvent} to all registered listeners. * * @param space the space (null permitted). * @param notify notify listeners? * * @see #getFixedRangeAxisSpace() * * @since 1.0.9 */ public void setFixedRangeAxisSpace(AxisSpace space, boolean notify) { this.fixedRangeAxisSpace = space; if (notify) { fireChangeEvent(); } } /** * Returns true if panning is enabled for the domain axes, * and false otherwise. * * @return A boolean. * * @since 1.0.13 */ public boolean isDomainPannable() { return this.domainPannable; } /** * Sets the flag that enables or disables panning of the plot along the * domain axes. * * @param pannable the new flag value. * * @since 1.0.13 */ public void setDomainPannable(boolean pannable) { this.domainPannable = pannable; } /** * Returns true if panning is enabled for the range axes, * and false otherwise. * * @return A boolean. * * @since 1.0.13 */ public boolean isRangePannable() { return this.rangePannable; } /** * Sets the flag that enables or disables panning of the plot along * the range axes. * * @param pannable the new flag value. * * @since 1.0.13 */ public void setRangePannable(boolean pannable) { this.rangePannable = pannable; } /** * Pans the domain axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panDomainAxes(double percent, PlotRenderingInfo info, Point2D source) { if (!isDomainPannable()) { return; } int domainAxisCount = getDomainAxisCount(); for (int i = 0; i < domainAxisCount; i++) { ValueAxis axis = getDomainAxis(i); if (axis == null) { continue; } if (axis.isInverted()) { percent = -percent; } axis.pan(percent); } } /** * Pans the range axes by the specified percentage. * * @param percent the distance to pan (as a percentage of the axis length). * @param info the plot info * @param source the source point where the pan action started. * * @since 1.0.13 */ public void panRangeAxes(double percent, PlotRenderingInfo info, Point2D source) { if (!isRangePannable()) { return; } int rangeAxisCount = getRangeAxisCount(); for (int i = 0; i < rangeAxisCount; i++) { ValueAxis axis = getRangeAxis(i); if (axis == null) { continue; } if (axis.isInverted()) { percent = -percent; } axis.pan(percent); } } /** * Multiplies the range on the domain axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D) */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source) { // delegate to other method zoomDomainAxes(factor, info, source, false); } /** * Multiplies the range on the domain axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point (in Java2D space). * @param useAnchor use source point as zoom anchor? * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { // perform the zoom on each domain axis for (int i = 0; i < this.domainAxes.size(); i++) { ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i); if (domainAxis != null) { if (useAnchor) { // get the relevant source coordinate given the plot // orientation double sourceX = source.getX(); if (this.orientation == PlotOrientation.HORIZONTAL) { sourceX = source.getY(); } double anchorX = domainAxis.java2DToValue(sourceX, info.getDataArea(), getDomainAxisEdge()); domainAxis.resizeRange2(factor, anchorX); } else { domainAxis.resizeRange(factor); } } } } /** * Zooms in on the domain axis/axes. The new lower and upper bounds are * specified as percentages of the current axis range, where 0 percent is * the current lower bound and 100 percent is the current upper bound. * * @param lowerPercent a percentage that determines the new lower bound * for the axis (e.g. 0.20 is twenty percent). * @param upperPercent a percentage that determines the new upper bound * for the axis (e.g. 0.80 is eighty percent). * @param info the plot rendering info. * @param source the source point (ignored). * * @see #zoomRangeAxes(double, double, PlotRenderingInfo, Point2D) */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { for (int i = 0; i < this.domainAxes.size(); i++) { ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i); if (domainAxis != null) { domainAxis.zoomRange(lowerPercent, upperPercent); } } } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point. * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source) { // delegate to other method zoomRangeAxes(factor, info, source, false); } /** * Multiplies the range on the range axis/axes by the specified factor. * * @param factor the zoom factor. * @param info the plot rendering info. * @param source the source point. * @param useAnchor a flag that controls whether or not the source point * is used for the zoom anchor. * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor) { // perform the zoom on each range axis for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); if (rangeAxis != null) { if (useAnchor) { // get the relevant source coordinate given the plot // orientation double sourceY = source.getY(); if (this.orientation == PlotOrientation.HORIZONTAL) { sourceY = source.getX(); } double anchorY = rangeAxis.java2DToValue(sourceY, info.getDataArea(), getRangeAxisEdge()); rangeAxis.resizeRange2(factor, anchorY); } else { rangeAxis.resizeRange(factor); } } } } /** * Zooms in on the range axes. * * @param lowerPercent the lower bound. * @param upperPercent the upper bound. * @param info the plot rendering info. * @param source the source point. * * @see #zoomDomainAxes(double, double, PlotRenderingInfo, Point2D) */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source) { for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); if (rangeAxis != null) { rangeAxis.zoomRange(lowerPercent, upperPercent); } } } /** * Returns true, indicating that the domain axis/axes for this * plot are zoomable. * * @return A boolean. * * @see #isRangeZoomable() */ public boolean isDomainZoomable() { return true; } /** * Returns true, indicating that the range axis/axes for this * plot are zoomable. * * @return A boolean. * * @see #isDomainZoomable() */ public boolean isRangeZoomable() { return true; } /** * Returns the number of series in the primary dataset for this plot. If * the dataset is null, the method returns 0. * * @return The series count. */ public int getSeriesCount() { int result = 0; XYDataset dataset = getDataset(); if (dataset != null) { result = dataset.getSeriesCount(); } return result; } /** * Returns the fixed legend items, if any. * * @return The legend items (possibly null). * * @see #setFixedLegendItems(LegendItemCollection) */ public LegendItemCollection getFixedLegendItems() { return this.fixedLegendItems; } /** * Sets the fixed legend items for the plot. Leave this set to * null if you prefer the legend items to be created * automatically. * * @param items the legend items (null permitted). * * @see #getFixedLegendItems() */ public void setFixedLegendItems(LegendItemCollection items) { this.fixedLegendItems = items; fireChangeEvent(); } /** * Returns the legend items for the plot. Each legend item is generated by * the plot's renderer, since the renderer is responsible for the visual * representation of the data. * * @return The legend items. */ public LegendItemCollection getLegendItems() { if (this.fixedLegendItems != null) { return this.fixedLegendItems; } LegendItemCollection result = new LegendItemCollection(); int count = this.datasets.size(); for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { XYDataset dataset = getDataset(datasetIndex); if (dataset != null) { XYItemRenderer renderer = getRenderer(datasetIndex); if (renderer == null) { renderer = getRenderer(0); } if (renderer != null) { int seriesCount = dataset.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { if (renderer.isSeriesVisible(i) && renderer.isSeriesVisibleInLegend(i)) { LegendItem item = renderer.getLegendItem( datasetIndex, i); if (item != null) { result.add(item); } } } } } } return result; } /** * Tests this plot for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYPlot)) { return false; } XYPlot that = (XYPlot) obj; if (this.weight != that.weight) { return false; } if (this.orientation != that.orientation) { return false; } if (!this.domainAxes.equals(that.domainAxes)) { return false; } if (!this.domainAxisLocations.equals(that.domainAxisLocations)) { return false; } if (this.rangeCrosshairLockedOnData != that.rangeCrosshairLockedOnData) { return false; } if (this.domainGridlinesVisible != that.domainGridlinesVisible) { return false; } if (this.rangeGridlinesVisible != that.rangeGridlinesVisible) { return false; } if (this.domainMinorGridlinesVisible != that.domainMinorGridlinesVisible) { return false; } if (this.rangeMinorGridlinesVisible != that.rangeMinorGridlinesVisible) { return false; } if (this.domainZeroBaselineVisible != that.domainZeroBaselineVisible) { return false; } if (this.rangeZeroBaselineVisible != that.rangeZeroBaselineVisible) { return false; } if (this.domainCrosshairVisible != that.domainCrosshairVisible) { return false; } if (this.domainCrosshairValue != that.domainCrosshairValue) { return false; } if (this.domainCrosshairLockedOnData != that.domainCrosshairLockedOnData) { return false; } if (this.rangeCrosshairVisible != that.rangeCrosshairVisible) { return false; } if (this.rangeCrosshairValue != that.rangeCrosshairValue) { return false; } if (!ObjectUtilities.equal(this.axisOffset, that.axisOffset)) { return false; } if (!ObjectUtilities.equal(this.renderers, that.renderers)) { return false; } if (!ObjectUtilities.equal(this.rangeAxes, that.rangeAxes)) { return false; } if (!this.rangeAxisLocations.equals(that.rangeAxisLocations)) { return false; } if (!ObjectUtilities.equal(this.datasetToDomainAxesMap, that.datasetToDomainAxesMap)) { return false; } if (!ObjectUtilities.equal(this.datasetToRangeAxesMap, that.datasetToRangeAxesMap)) { return false; } if (!ObjectUtilities.equal(this.domainGridlineStroke, that.domainGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.domainGridlinePaint, that.domainGridlinePaint)) { return false; } if (!ObjectUtilities.equal(this.rangeGridlineStroke, that.rangeGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.rangeGridlinePaint, that.rangeGridlinePaint)) { return false; } if (!ObjectUtilities.equal(this.domainMinorGridlineStroke, that.domainMinorGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.domainMinorGridlinePaint, that.domainMinorGridlinePaint)) { return false; } if (!ObjectUtilities.equal(this.rangeMinorGridlineStroke, that.rangeMinorGridlineStroke)) { return false; } if (!PaintUtilities.equal(this.rangeMinorGridlinePaint, that.rangeMinorGridlinePaint)) { return false; } if (!PaintUtilities.equal(this.domainZeroBaselinePaint, that.domainZeroBaselinePaint)) { return false; } if (!ObjectUtilities.equal(this.domainZeroBaselineStroke, that.domainZeroBaselineStroke)) { return false; } if (!PaintUtilities.equal(this.rangeZeroBaselinePaint, that.rangeZeroBaselinePaint)) { return false; } if (!ObjectUtilities.equal(this.rangeZeroBaselineStroke, that.rangeZeroBaselineStroke)) { return false; } if (!ObjectUtilities.equal(this.domainCrosshairStroke, that.domainCrosshairStroke)) { return false; } if (!PaintUtilities.equal(this.domainCrosshairPaint, that.domainCrosshairPaint)) { return false; } if (!ObjectUtilities.equal(this.rangeCrosshairStroke, that.rangeCrosshairStroke)) { return false; } if (!PaintUtilities.equal(this.rangeCrosshairPaint, that.rangeCrosshairPaint)) { return false; } if (!ObjectUtilities.equal(this.foregroundDomainMarkers, that.foregroundDomainMarkers)) { return false; } if (!ObjectUtilities.equal(this.backgroundDomainMarkers, that.backgroundDomainMarkers)) { return false; } if (!ObjectUtilities.equal(this.foregroundRangeMarkers, that.foregroundRangeMarkers)) { return false; } if (!ObjectUtilities.equal(this.backgroundRangeMarkers, that.backgroundRangeMarkers)) { return false; } if (!ObjectUtilities.equal(this.foregroundDomainMarkers, that.foregroundDomainMarkers)) { return false; } if (!ObjectUtilities.equal(this.backgroundDomainMarkers, that.backgroundDomainMarkers)) { return false; } if (!ObjectUtilities.equal(this.foregroundRangeMarkers, that.foregroundRangeMarkers)) { return false; } if (!ObjectUtilities.equal(this.backgroundRangeMarkers, that.backgroundRangeMarkers)) { return false; } if (!ObjectUtilities.equal(this.annotations, that.annotations)) { return false; } if (!PaintUtilities.equal(this.domainTickBandPaint, that.domainTickBandPaint)) { return false; } if (!PaintUtilities.equal(this.rangeTickBandPaint, that.rangeTickBandPaint)) { return false; } if (!this.quadrantOrigin.equals(that.quadrantOrigin)) { return false; } for (int i = 0; i < 4; i++) { if (!PaintUtilities.equal(this.quadrantPaint[i], that.quadrantPaint[i])) { return false; } } return super.equals(obj); } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException this can occur if some component of * the plot cannot be cloned. */ public Object clone() throws CloneNotSupportedException { XYPlot clone = (XYPlot) super.clone(); clone.domainAxes = (ObjectList) ObjectUtilities.clone(this.domainAxes); for (int i = 0; i < this.domainAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.domainAxes.get(i); if (axis != null) { ValueAxis clonedAxis = (ValueAxis) axis.clone(); clone.domainAxes.set(i, clonedAxis); clonedAxis.setPlot(clone); clonedAxis.addChangeListener(clone); } } clone.domainAxisLocations = (ObjectList) this.domainAxisLocations.clone(); clone.rangeAxes = (ObjectList) ObjectUtilities.clone(this.rangeAxes); for (int i = 0; i < this.rangeAxes.size(); i++) { ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); if (axis != null) { ValueAxis clonedAxis = (ValueAxis) axis.clone(); clone.rangeAxes.set(i, clonedAxis); clonedAxis.setPlot(clone); clonedAxis.addChangeListener(clone); } } clone.rangeAxisLocations = (ObjectList) ObjectUtilities.clone( this.rangeAxisLocations); // the datasets are not cloned, but listeners need to be added... clone.datasets = (ObjectList) ObjectUtilities.clone(this.datasets); for (int i = 0; i < clone.datasets.size(); ++i) { XYDataset d = getDataset(i); if (d != null) { d.addChangeListener(clone); } } clone.datasetToDomainAxesMap = new TreeMap(); clone.datasetToDomainAxesMap.putAll(this.datasetToDomainAxesMap); clone.datasetToRangeAxesMap = new TreeMap(); clone.datasetToRangeAxesMap.putAll(this.datasetToRangeAxesMap); clone.renderers = (ObjectList) ObjectUtilities.clone(this.renderers); for (int i = 0; i < this.renderers.size(); i++) { XYItemRenderer renderer2 = (XYItemRenderer) this.renderers.get(i); if (renderer2 instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) renderer2; clone.renderers.set(i, pc.clone()); } } clone.foregroundDomainMarkers = (Map) ObjectUtilities.clone( this.foregroundDomainMarkers); clone.backgroundDomainMarkers = (Map) ObjectUtilities.clone( this.backgroundDomainMarkers); clone.foregroundRangeMarkers = (Map) ObjectUtilities.clone( this.foregroundRangeMarkers); clone.backgroundRangeMarkers = (Map) ObjectUtilities.clone( this.backgroundRangeMarkers); clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); if (this.fixedDomainAxisSpace != null) { clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone( this.fixedDomainAxisSpace); } if (this.fixedRangeAxisSpace != null) { clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone( this.fixedRangeAxisSpace); } clone.quadrantOrigin = (Point2D) ObjectUtilities.clone( this.quadrantOrigin); clone.quadrantPaint = (Paint[]) this.quadrantPaint.clone(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.domainGridlineStroke, stream); SerialUtilities.writePaint(this.domainGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); SerialUtilities.writePaint(this.rangeGridlinePaint, stream); SerialUtilities.writeStroke(this.domainMinorGridlineStroke, stream); SerialUtilities.writePaint(this.domainMinorGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeMinorGridlineStroke, stream); SerialUtilities.writePaint(this.rangeMinorGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeZeroBaselineStroke, stream); SerialUtilities.writePaint(this.rangeZeroBaselinePaint, stream); SerialUtilities.writeStroke(this.domainCrosshairStroke, stream); SerialUtilities.writePaint(this.domainCrosshairPaint, stream); SerialUtilities.writeStroke(this.rangeCrosshairStroke, stream); SerialUtilities.writePaint(this.rangeCrosshairPaint, stream); SerialUtilities.writePaint(this.domainTickBandPaint, stream); SerialUtilities.writePaint(this.rangeTickBandPaint, stream); SerialUtilities.writePoint2D(this.quadrantOrigin, stream); for (int i = 0; i < 4; i++) { SerialUtilities.writePaint(this.quadrantPaint[i], stream); } SerialUtilities.writeStroke(this.domainZeroBaselineStroke, stream); SerialUtilities.writePaint(this.domainZeroBaselinePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.domainGridlineStroke = SerialUtilities.readStroke(stream); this.domainGridlinePaint = SerialUtilities.readPaint(stream); this.rangeGridlineStroke = SerialUtilities.readStroke(stream); this.rangeGridlinePaint = SerialUtilities.readPaint(stream); this.domainMinorGridlineStroke = SerialUtilities.readStroke(stream); this.domainMinorGridlinePaint = SerialUtilities.readPaint(stream); this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream); this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream); this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream); this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream); this.domainCrosshairStroke = SerialUtilities.readStroke(stream); this.domainCrosshairPaint = SerialUtilities.readPaint(stream); this.rangeCrosshairStroke = SerialUtilities.readStroke(stream); this.rangeCrosshairPaint = SerialUtilities.readPaint(stream); this.domainTickBandPaint = SerialUtilities.readPaint(stream); this.rangeTickBandPaint = SerialUtilities.readPaint(stream); this.quadrantOrigin = SerialUtilities.readPoint2D(stream); this.quadrantPaint = new Paint[4]; for (int i = 0; i < 4; i++) { this.quadrantPaint[i] = SerialUtilities.readPaint(stream); } this.domainZeroBaselineStroke = SerialUtilities.readStroke(stream); this.domainZeroBaselinePaint = SerialUtilities.readPaint(stream); // register the plot as a listener with its axes, datasets, and // renderers... int domainAxisCount = this.domainAxes.size(); for (int i = 0; i < domainAxisCount; i++) { Axis axis = (Axis) this.domainAxes.get(i); if (axis != null) { axis.setPlot(this); axis.addChangeListener(this); } } int rangeAxisCount = this.rangeAxes.size(); for (int i = 0; i < rangeAxisCount; i++) { Axis axis = (Axis) this.rangeAxes.get(i); if (axis != null) { axis.setPlot(this); axis.addChangeListener(this); } } int datasetCount = this.datasets.size(); for (int i = 0; i < datasetCount; i++) { Dataset dataset = (Dataset) this.datasets.get(i); if (dataset != null) { dataset.addChangeListener(this); } } int rendererCount = this.renderers.size(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer renderer = (XYItemRenderer) this.renderers.get(i); if (renderer != null) { renderer.addChangeListener(this); } } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/Zoomable.java0000644000175000017500000001522011173030414026022 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * Zoomable.java * ------------- * * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Rune Fauske; * * Changes * ------- * 12-Nov-2004 : Version 1 (DG); * 26-Jan-2004 : Added getOrientation() method (DG); * 04-Sep-2006 : Added credit for Rune Fauske, see patch 1050659 (DG); * 21-Sep-2007 : Added new zooming methods with 'useAnchor' flag. This breaks * the API, but is the cleanest way I can think of to fix a * long-standing bug (DG); * */ package org.jfree.chart.plot; import java.awt.geom.Point2D; import org.jfree.chart.ChartPanel; /** * A plot that is zoomable must implement this interface to provide a * mechanism for the {@link ChartPanel} to control the zooming. */ public interface Zoomable { /** * Returns true if the plot's domain is zoomable, and * false otherwise. * * @return A boolean. * * @see #isRangeZoomable() */ public boolean isDomainZoomable(); /** * Returns true if the plot's range is zoomable, and * false otherwise. * * @return A boolean. * * @see #isDomainZoomable() */ public boolean isRangeZoomable(); /** * Returns the orientation of the plot. * * @return The orientation. */ public PlotOrientation getOrientation(); /** * Multiplies the range on the domain axis/axes by the specified factor. * The source point can be used in some cases to identify a * subplot, or to determine the center of zooming (refer to the * documentation of the implementing class for details). * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D) */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source); /** * Multiplies the range on the domain axis/axes by the specified factor. * The source point can be used in some cases to identify a * subplot, or to determine the center of zooming (refer to the * documentation of the implementing class for details). * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). * @param useAnchor use source point as zoom anchor? * * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) * * @since 1.0.7 */ public void zoomDomainAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor); /** * Zooms in on the domain axes. The source point can be used * in some cases to identify a subplot for zooming. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. * @param state the plot state. * @param source the source point (in Java2D coordinates). * * @see #zoomRangeAxes(double, double, PlotRenderingInfo, Point2D) */ public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source); /** * Multiplies the range on the range axis/axes by the specified factor. * The source point can be used in some cases to identify a * subplot, or to determine the center of zooming (refer to the * documentation of the implementing class for details). * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D) */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source); /** * Multiplies the range on the range axis/axes by the specified factor. * The source point can be used in some cases to identify a * subplot, or to determine the center of zooming (refer to the * documentation of the implementing class for details). * * @param factor the zoom factor. * @param state the plot state. * @param source the source point (in Java2D coordinates). * @param useAnchor use source point as zoom anchor? * * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D) * * @since 1.0.7 */ public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor); /** * Zooms in on the range axes. The source point can be used * in some cases to identify a subplot for zooming. * * @param lowerPercent the new lower bound. * @param upperPercent the new upper bound. * @param state the plot state. * @param source the source point (in Java2D coordinates). * * @see #zoomDomainAxes(double, double, PlotRenderingInfo, Point2D) */ public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo state, Point2D source); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/plot/package.html0000644000175000017500000000022111173030414025663 0ustar vincentvincent Plot classes and related interfaces. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/0000755000175000017500000000000011216245562024251 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/0000755000175000017500000000000011216245562026066 5ustar vincentvincent././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer0000644000175000017500000021122311173030414033547 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * AbstractCategoryItemRenderer.java * --------------------------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Peter Kolb (patch 2497611); * * Changes: * -------- * 29-May-2002 : Version 1 (DG); * 06-Jun-2002 : Added accessor methods for the tool tip generator (DG); * 11-Jun-2002 : Made constructors protected (DG); * 26-Jun-2002 : Added axis to initialise method (DG); * 05-Aug-2002 : Added urlGenerator member variable plus accessors (RA); * 22-Aug-2002 : Added categoriesPaint attribute, based on code submitted by * Janet Banks. This can be used when there is only one series, * and you want each category item to have a different color (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 29-Oct-2002 : Fixed bug where background image for plot was not being * drawn (DG); * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); * 26-Nov 2002 : Replaced the isStacked() method with getRangeType() (DG); * 09-Jan-2003 : Renamed grid-line methods (DG); * 17-Jan-2003 : Moved plot classes into separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 12-May-2003 : Modified to take into account the plot orientation (DG); * 12-Aug-2003 : Very minor javadoc corrections (DB) * 13-Aug-2003 : Implemented Cloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 05-Nov-2003 : Fixed marker rendering bug (833623) (DG); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * 11-Feb-2004 : Modified labelling for markers (DG); * 12-Feb-2004 : Updated clone() method (DG); * 15-Apr-2004 : Created a new CategoryToolTipGenerator interface (DG); * 05-May-2004 : Fixed bug (948310) where interval markers extend outside axis * range (DG); * 14-Jun-2004 : Fixed bug in drawRangeMarker() method - now uses 'paint' and * 'stroke' rather than 'outlinePaint' and 'outlineStroke' (DG); * 15-Jun-2004 : Interval markers can now use GradientPaint (DG); * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities * --> TextUtilities (DG); * 01-Oct-2004 : Fixed bug 1029697, problem with label alignment in * drawRangeMarker() method (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() (DG); * 21-Jan-2005 : Modified return type of calculateRangeMarkerTextAnchorPoint() * method (DG); * 08-Mar-2005 : Fixed positioning of marker labels (DG); * 20-Apr-2005 : Added legend label, tooltip and URL generators (DG); * 01-Jun-2005 : Handle one dimension of the marker label adjustment * automatically (DG); * 09-Jun-2005 : Added utility method for adding an item entity (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Mar-2006 : Updated getLegendItems() to check seriesVisibleInLegend * flags (DG); * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG); * 23-Oct-2006 : Draw outlines for interval markers (DG); * 24-Oct-2006 : Respect alpha setting in markers, as suggested by Sergei * Ivanov in patch 1567843 (DG); * 30-Nov-2006 : Added a check for series visibility in the getLegendItem() * method (DG); * 07-Dec-2006 : Fix for equals() method (DG); * 22-Feb-2007 : Added createState() method (DG); * 01-Mar-2007 : Fixed interval marker drawing (patch 1670686 thanks to * Sergei Ivanov) (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change, and deprecated * itemLabelGenerator, toolTipGenerator and itemURLGenerator * override fields (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 26-Jun-2008 : Added crosshair support (DG); * 25-Nov-2008 : Fixed bug in findRangeBounds() method (DG); * 14-Jan-2009 : Update initialise() to store visible series indices (PK); * 21-Jan-2009 : Added drawRangeLine() method (DG); * 27-Mar-2009 : Added new findRangeBounds() method to account for hidden * series (DG); * 01-Apr-2009 : Added new addEntity() method (DG); * */ package org.jfree.chart.renderer.category; import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.CategoryItemEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.labels.CategorySeriesLabelGenerator; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator; import org.jfree.chart.plot.CategoryCrosshairState; import org.jfree.chart.plot.CategoryMarker; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.DrawingSupplier; import org.jfree.chart.plot.IntervalMarker; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.renderer.AbstractRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectList; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An abstract base class that you can use to implement a new * {@link CategoryItemRenderer}. When you create a new * {@link CategoryItemRenderer} you are not required to extend this class, * but it makes the job easier. */ public abstract class AbstractCategoryItemRenderer extends AbstractRenderer implements CategoryItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1247553218442497391L; /** The plot that the renderer is assigned to. */ private CategoryPlot plot; /** A list of item label generators (one per series). */ private ObjectList itemLabelGeneratorList; /** The base item label generator. */ private CategoryItemLabelGenerator baseItemLabelGenerator; /** A list of tool tip generators (one per series). */ private ObjectList toolTipGeneratorList; /** The base tool tip generator. */ private CategoryToolTipGenerator baseToolTipGenerator; /** A list of item label generators (one per series). */ private ObjectList itemURLGeneratorList; /** The base item label generator. */ private CategoryURLGenerator baseItemURLGenerator; /** The legend item label generator. */ private CategorySeriesLabelGenerator legendItemLabelGenerator; /** The legend item tool tip generator. */ private CategorySeriesLabelGenerator legendItemToolTipGenerator; /** The legend item URL generator. */ private CategorySeriesLabelGenerator legendItemURLGenerator; /** The number of rows in the dataset (temporary record). */ private transient int rowCount; /** The number of columns in the dataset (temporary record). */ private transient int columnCount; /** * Creates a new renderer with no tool tip generator and no URL generator. * The defaults (no tool tip or URL generators) have been chosen to * minimise the processing required to generate a default chart. If you * require tool tips or URLs, then you can easily add the required * generators. */ protected AbstractCategoryItemRenderer() { this.itemLabelGenerator = null; this.itemLabelGeneratorList = new ObjectList(); this.toolTipGenerator = null; this.toolTipGeneratorList = new ObjectList(); this.itemURLGenerator = null; this.itemURLGeneratorList = new ObjectList(); this.legendItemLabelGenerator = new StandardCategorySeriesLabelGenerator(); } /** * Returns the number of passes through the dataset required by the * renderer. This method returns 1, subclasses should * override if they need more passes. * * @return The pass count. */ public int getPassCount() { return 1; } /** * Returns the plot that the renderer has been assigned to (where * null indicates that the renderer is not currently assigned * to a plot). * * @return The plot (possibly null). * * @see #setPlot(CategoryPlot) */ public CategoryPlot getPlot() { return this.plot; } /** * Sets the plot that the renderer has been assigned to. This method is * usually called by the {@link CategoryPlot}, in normal usage you * shouldn't need to call this method directly. * * @param plot the plot (null not permitted). * * @see #getPlot() */ public void setPlot(CategoryPlot plot) { if (plot == null) { throw new IllegalArgumentException("Null 'plot' argument."); } this.plot = plot; } // ITEM LABEL GENERATOR /** * Returns the item label generator for a data item. This implementation * simply passes control to the {@link #getSeriesItemLabelGenerator(int)} * method. If, for some reason, you want a different generator for * individual items, you can override this method. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The generator (possibly null). */ public CategoryItemLabelGenerator getItemLabelGenerator(int row, int column) { return getSeriesItemLabelGenerator(row); } /** * Returns the item label generator for a series. * * @param series the series index (zero based). * * @return The generator (possibly null). * * @see #setSeriesItemLabelGenerator(int, CategoryItemLabelGenerator) */ public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series) { // return the generator for ALL series, if there is one... if (this.itemLabelGenerator != null) { return this.itemLabelGenerator; } // otherwise look up the generator table CategoryItemLabelGenerator generator = (CategoryItemLabelGenerator) this.itemLabelGeneratorList.get(series); if (generator == null) { generator = this.baseItemLabelGenerator; } return generator; } /** * Sets the item label generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param generator the generator (null permitted). * * @see #getSeriesItemLabelGenerator(int) */ public void setSeriesItemLabelGenerator(int series, CategoryItemLabelGenerator generator) { this.itemLabelGeneratorList.set(series, generator); fireChangeEvent(); } /** * Returns the base item label generator. * * @return The generator (possibly null). * * @see #setBaseItemLabelGenerator(CategoryItemLabelGenerator) */ public CategoryItemLabelGenerator getBaseItemLabelGenerator() { return this.baseItemLabelGenerator; } /** * Sets the base item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getBaseItemLabelGenerator() */ public void setBaseItemLabelGenerator( CategoryItemLabelGenerator generator) { this.baseItemLabelGenerator = generator; fireChangeEvent(); } // TOOL TIP GENERATOR /** * Returns the tool tip generator that should be used for the specified * item. This method looks up the generator using the "three-layer" * approach outlined in the general description of this interface. You * can override this method if you want to return a different generator per * item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The generator (possibly null). */ public CategoryToolTipGenerator getToolTipGenerator(int row, int column) { CategoryToolTipGenerator result = null; if (this.toolTipGenerator != null) { result = this.toolTipGenerator; } else { result = getSeriesToolTipGenerator(row); if (result == null) { result = this.baseToolTipGenerator; } } return result; } /** * Returns the tool tip generator for the specified series (a "layer 1" * generator). * * @param series the series index (zero-based). * * @return The tool tip generator (possibly null). * * @see #setSeriesToolTipGenerator(int, CategoryToolTipGenerator) */ public CategoryToolTipGenerator getSeriesToolTipGenerator(int series) { return (CategoryToolTipGenerator) this.toolTipGeneratorList.get(series); } /** * Sets the tool tip generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param generator the generator (null permitted). * * @see #getSeriesToolTipGenerator(int) */ public void setSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator) { this.toolTipGeneratorList.set(series, generator); fireChangeEvent(); } /** * Returns the base tool tip generator (the "layer 2" generator). * * @return The tool tip generator (possibly null). * * @see #setBaseToolTipGenerator(CategoryToolTipGenerator) */ public CategoryToolTipGenerator getBaseToolTipGenerator() { return this.baseToolTipGenerator; } /** * Sets the base tool tip generator and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param generator the generator (null permitted). * * @see #getBaseToolTipGenerator() */ public void setBaseToolTipGenerator(CategoryToolTipGenerator generator) { this.baseToolTipGenerator = generator; fireChangeEvent(); } // URL GENERATOR /** * Returns the URL generator for a data item. This method just calls the * getSeriesItemURLGenerator method, but you can override this behaviour if * you want to. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The URL generator. */ public CategoryURLGenerator getItemURLGenerator(int row, int column) { return getSeriesItemURLGenerator(row); } /** * Returns the URL generator for a series. * * @param series the series index (zero based). * * @return The URL generator for the series. * * @see #setSeriesItemURLGenerator(int, CategoryURLGenerator) */ public CategoryURLGenerator getSeriesItemURLGenerator(int series) { // return the generator for ALL series, if there is one... if (this.itemURLGenerator != null) { return this.itemURLGenerator; } // otherwise look up the generator table CategoryURLGenerator generator = (CategoryURLGenerator) this.itemURLGeneratorList.get(series); if (generator == null) { generator = this.baseItemURLGenerator; } return generator; } /** * Sets the URL generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param generator the generator. * * @see #getSeriesItemURLGenerator(int) */ public void setSeriesItemURLGenerator(int series, CategoryURLGenerator generator) { this.itemURLGeneratorList.set(series, generator); fireChangeEvent(); } /** * Returns the base item URL generator. * * @return The item URL generator. * * @see #setBaseItemURLGenerator(CategoryURLGenerator) */ public CategoryURLGenerator getBaseItemURLGenerator() { return this.baseItemURLGenerator; } /** * Sets the base item URL generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the item URL generator (null permitted). * * @see #getBaseItemURLGenerator() */ public void setBaseItemURLGenerator(CategoryURLGenerator generator) { this.baseItemURLGenerator = generator; fireChangeEvent(); } /** * Returns the number of rows in the dataset. This value is updated in the * {@link AbstractCategoryItemRenderer#initialise} method. * * @return The row count. */ public int getRowCount() { return this.rowCount; } /** * Returns the number of columns in the dataset. This value is updated in * the {@link AbstractCategoryItemRenderer#initialise} method. * * @return The column count. */ public int getColumnCount() { return this.columnCount; } /** * Creates a new state instance---this method is called from the * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, * PlotRenderingInfo)} method. Subclasses can override this method if * they need to use a subclass of {@link CategoryItemRendererState}. * * @param info collects plot rendering info (null permitted). * * @return The new state instance (never null). * * @since 1.0.5 */ protected CategoryItemRendererState createState(PlotRenderingInfo info) { return new CategoryItemRendererState(info); } /** * Initialises the renderer and returns a state object that will be used * for the remainder of the drawing process for a single chart. The state * object allows for the fact that the renderer may be used simultaneously * by multiple threads (each thread will work with a separate state object). * * @param g2 the graphics device. * @param dataArea the data area. * @param plot the plot. * @param rendererIndex the renderer index. * @param info an object for returning information about the structure of * the plot (null permitted). * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { setPlot(plot); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { this.rowCount = data.getRowCount(); this.columnCount = data.getColumnCount(); } else { this.rowCount = 0; this.columnCount = 0; } CategoryItemRendererState state = createState(info); int[] visibleSeriesTemp = new int[this.rowCount]; int visibleSeriesCount = 0; for (int row = 0; row < this.rowCount; row++){ if (isSeriesVisible(row)) { visibleSeriesTemp[visibleSeriesCount] = row; visibleSeriesCount++; } } int[] visibleSeries = new int[visibleSeriesCount]; System.arraycopy(visibleSeriesTemp, 0, visibleSeries, 0, visibleSeriesCount); state.setVisibleSeriesArray(visibleSeries); return state; } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(CategoryDataset dataset) { return findRangeBounds(dataset, false); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * @param includeInterval include the y-interval if the dataset has one. * * @return The range (null if the dataset is null * or empty). * * @since 1.0.13 */ protected Range findRangeBounds(CategoryDataset dataset, boolean includeInterval) { if (dataset == null) { return null; } if (getDataBoundsIncludesVisibleSeriesOnly()) { List visibleSeriesKeys = new ArrayList(); int seriesCount = dataset.getRowCount(); for (int s = 0; s < seriesCount; s++) { if (isSeriesVisible(s)) { visibleSeriesKeys.add(dataset.getRowKey(s)); } } return DatasetUtilities.findRangeBounds(dataset, visibleSeriesKeys, includeInterval); } else { return DatasetUtilities.findRangeBounds(dataset, includeInterval); } } /** * Returns the Java2D coordinate for the middle of the specified data item. * * @param rowKey the row key. * @param columnKey the column key. * @param dataset the dataset. * @param axis the axis. * @param area the data area. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate for the middle of the item. * * @since 1.0.11 */ public double getItemMiddle(Comparable rowKey, Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, RectangleEdge edge) { return axis.getCategoryMiddle(columnKey, dataset.getColumnKeys(), area, edge); } /** * Draws a background for the data area. The default implementation just * gets the plot to draw the background, but some renderers will override * this behaviour. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. */ public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { plot.drawBackground(g2, dataArea); } /** * Draws an outline for the data area. The default implementation just * gets the plot to draw the outline, but some renderers will override this * behaviour. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. */ public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { plot.drawOutline(g2, dataArea); } /** * Draws a grid line against the domain axis. *

* Note that this default implementation assumes that the horizontal axis * is the domain axis. If this is not the case, you will need to override * this method. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. * * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, * Rectangle2D, double) */ public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) { Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } Paint paint = plot.getDomainGridlinePaint(); if (paint == null) { paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; } g2.setPaint(paint); Stroke stroke = plot.getDomainGridlineStroke(); if (stroke == null) { stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; } g2.setStroke(stroke); g2.draw(line); } /** * Draws a grid line against the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value at which the grid line should be drawn. * * @see #drawDomainGridline(Graphics2D, CategoryPlot, Rectangle2D, double) */ public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } Paint paint = plot.getRangeGridlinePaint(); if (paint == null) { paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; } g2.setPaint(paint); Stroke stroke = plot.getRangeGridlineStroke(); if (stroke == null) { stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; } g2.setStroke(stroke); g2.draw(line); } /** * Draws a line perpendicular to the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D * effect). * @param value the value at which the grid line should be drawn. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). * * @see #drawRangeGridline * * @since 1.0.13 */ public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { // TODO: In JFreeChart 1.2.0, put this method in the // CategoryItemRenderer interface Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); Line2D line = null; double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); } /** * Draws a marker for the domain axis. * * @param g2 the graphics device (not null). * @param plot the plot (not null). * @param axis the range axis (not null). * @param marker the marker to be drawn (not null). * @param dataArea the area inside the axes (not null). * * @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker, * Rectangle2D) */ public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea) { Comparable category = marker.getKey(); CategoryDataset dataset = plot.getDataset(plot.getIndexOf(this)); int columnIndex = dataset.getColumnIndex(category); if (columnIndex < 0) { return; } final Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); PlotOrientation orientation = plot.getOrientation(); Rectangle2D bounds = null; if (marker.getDrawAsLine()) { double v = axis.getCategoryMiddle(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } g2.setPaint(marker.getPaint()); g2.setStroke(marker.getStroke()); g2.draw(line); bounds = line.getBounds2D(); } else { double v0 = axis.getCategoryStart(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()); double v1 = axis.getCategoryEnd(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()); Rectangle2D area = null; if (orientation == PlotOrientation.HORIZONTAL) { area = new Rectangle2D.Double(dataArea.getMinX(), v0, dataArea.getWidth(), (v1 - v0)); } else if (orientation == PlotOrientation.VERTICAL) { area = new Rectangle2D.Double(v0, dataArea.getMinY(), (v1 - v0), dataArea.getHeight()); } g2.setPaint(marker.getPaint()); g2.fill(area); bounds = area; } String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateDomainMarkerTextAnchorPoint( g2, orientation, dataArea, bounds, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(savedComposite); } /** * Draws a marker for the range axis. * * @param g2 the graphics device (not null). * @param plot the plot (not null). * @param axis the range axis (not null). * @param marker the marker to be drawn (not null). * @param dataArea the area inside the axes (not null). * * @see #drawDomainMarker(Graphics2D, CategoryPlot, CategoryAxis, * CategoryMarker, Rectangle2D) */ public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = axis.getRange(); if (!range.contains(value)) { return; } final Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); PlotOrientation orientation = plot.getOrientation(); double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } g2.setPaint(marker.getPaint()); g2.setStroke(marker.getStroke()); g2.draw(line); String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateRangeMarkerTextAnchorPoint( g2, orientation, dataArea, line.getBounds2D(), marker.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(savedComposite); } else if (marker instanceof IntervalMarker) { IntervalMarker im = (IntervalMarker) marker; double start = im.getStartValue(); double end = im.getEndValue(); Range range = axis.getRange(); if (!(range.intersects(start, end))) { return; } final Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); double start2d = axis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); double end2d = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); double low = Math.min(start2d, end2d); double high = Math.max(start2d, end2d); PlotOrientation orientation = plot.getOrientation(); Rectangle2D rect = null; if (orientation == PlotOrientation.HORIZONTAL) { // clip left and right bounds to data area low = Math.max(low, dataArea.getMinX()); high = Math.min(high, dataArea.getMaxX()); rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); } else if (orientation == PlotOrientation.VERTICAL) { // clip top and bottom bounds to data area low = Math.max(low, dataArea.getMinY()); high = Math.min(high, dataArea.getMaxY()); rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); } Paint p = marker.getPaint(); if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) p; GradientPaintTransformer t = im.getGradientPaintTransformer(); if (t != null) { gp = t.transform(gp, rect); } g2.setPaint(gp); } else { g2.setPaint(p); } g2.fill(rect); // now draw the outlines, if visible... if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) { if (orientation == PlotOrientation.VERTICAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } else { // PlotOrientation.HORIZONTAL Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } } String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateRangeMarkerTextAnchorPoint( g2, orientation, dataArea, rect, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(savedComposite); } } /** * Calculates the (x, y) coordinates for drawing the label for a marker on * the range axis. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the rectangle surrounding the marker. * @param markerOffset the marker offset. * @param labelOffsetType the label offset type. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetType); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetType, LengthAdjustmentType.CONTRACT); } return RectangleAnchor.coordinates(anchorRect, anchor); } /** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the rectangle surrounding the marker. * @param markerOffset the marker offset. * @param labelOffsetType the label offset type. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetType, LengthAdjustmentType.CONTRACT); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetType); } return RectangleAnchor.coordinates(anchorRect, anchor); } /** * Returns a legend item for a series. This default implementation will * return null if {@link #isSeriesVisible(int)} or * {@link #isSeriesVisibleInLegend(int)} returns false. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly null). * * @see #getLegendItems() */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); String label = this.legendItemLabelGenerator.generateLabel(dataset, series); String description = label; String toolTipText = null; if (this.legendItemToolTipGenerator != null) { toolTipText = this.legendItemToolTipGenerator.generateLabel( dataset, series); } String urlText = null; if (this.legendItemURLGenerator != null) { urlText = this.legendItemURLGenerator.generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; } /** * Tests this renderer for equality with another object. * * @param obj the object. * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractCategoryItemRenderer)) { return false; } AbstractCategoryItemRenderer that = (AbstractCategoryItemRenderer) obj; if (!ObjectUtilities.equal(this.itemLabelGenerator, that.itemLabelGenerator)) { return false; } if (!ObjectUtilities.equal(this.itemLabelGeneratorList, that.itemLabelGeneratorList)) { return false; } if (!ObjectUtilities.equal(this.baseItemLabelGenerator, that.baseItemLabelGenerator)) { return false; } if (!ObjectUtilities.equal(this.toolTipGenerator, that.toolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.toolTipGeneratorList, that.toolTipGeneratorList)) { return false; } if (!ObjectUtilities.equal(this.baseToolTipGenerator, that.baseToolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.itemURLGenerator, that.itemURLGenerator)) { return false; } if (!ObjectUtilities.equal(this.itemURLGeneratorList, that.itemURLGeneratorList)) { return false; } if (!ObjectUtilities.equal(this.baseItemURLGenerator, that.baseItemURLGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendItemLabelGenerator, that.legendItemLabelGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendItemToolTipGenerator, that.legendItemToolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendItemURLGenerator, that.legendItemURLGenerator)) { return false; } return super.equals(obj); } /** * Returns a hash code for the renderer. * * @return The hash code. */ public int hashCode() { int result = super.hashCode(); return result; } /** * Returns the drawing supplier from the plot. * * @return The drawing supplier (possibly null). */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; CategoryPlot cp = getPlot(); if (cp != null) { result = cp.getDrawingSupplier(); } return result; } /** * Considers the current (x, y) coordinate and updates the crosshair point * if it meets the criteria (usually means the (x, y) coordinate is the * closest to the anchor point so far). * * @param crosshairState the crosshair state (null permitted, * but the method does nothing in that case). * @param rowKey the row key. * @param columnKey the column key. * @param value the data value. * @param datasetIndex the dataset index. * @param transX the x-value translated to Java2D space. * @param transY the y-value translated to Java2D space. * @param orientation the plot orientation (null not * permitted). * * @since 1.0.11 */ protected void updateCrosshairValues(CategoryCrosshairState crosshairState, Comparable rowKey, Comparable columnKey, double value, int datasetIndex, double transX, double transY, PlotOrientation orientation) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } if (crosshairState != null) { if (this.plot.isRangeCrosshairLockedOnData()) { // both axes crosshairState.updateCrosshairPoint(rowKey, columnKey, value, datasetIndex, transX, transY, orientation); } else { crosshairState.updateCrosshairX(rowKey, columnKey, datasetIndex, transX, orientation); } } } /** * Draws an item label. * * @param g2 the graphics device. * @param orientation the orientation. * @param dataset the dataset. * @param row the row. * @param column the column. * @param x the x coordinate (in Java2D space). * @param y the y coordinate (in Java2D space). * @param negative indicates a negative value (which affects the item * label position). */ protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, CategoryDataset dataset, int row, int column, double x, double y, boolean negative) { CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null) { Font labelFont = getItemLabelFont(row, column); Paint paint = getItemLabelPaint(row, column); g2.setFont(labelFont); g2.setPaint(paint); String label = generator.generateLabel(dataset, row, column); ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(row, column); } else { position = getNegativeItemLabelPosition(row, column); } Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), x, y, orientation); TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } } /** * Returns an independent copy of the renderer. The plot * reference is shallow copied. * * @return A clone. * * @throws CloneNotSupportedException can be thrown if one of the objects * belonging to the renderer does not support cloning (for example, * an item label generator). */ public Object clone() throws CloneNotSupportedException { AbstractCategoryItemRenderer clone = (AbstractCategoryItemRenderer) super.clone(); if (this.itemLabelGenerator != null) { if (this.itemLabelGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.itemLabelGenerator; clone.itemLabelGenerator = (CategoryItemLabelGenerator) pc.clone(); } else { throw new CloneNotSupportedException( "ItemLabelGenerator not cloneable."); } } if (this.itemLabelGeneratorList != null) { clone.itemLabelGeneratorList = (ObjectList) this.itemLabelGeneratorList.clone(); } if (this.baseItemLabelGenerator != null) { if (this.baseItemLabelGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.baseItemLabelGenerator; clone.baseItemLabelGenerator = (CategoryItemLabelGenerator) pc.clone(); } else { throw new CloneNotSupportedException( "ItemLabelGenerator not cloneable."); } } if (this.toolTipGenerator != null) { if (this.toolTipGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.toolTipGenerator; clone.toolTipGenerator = (CategoryToolTipGenerator) pc.clone(); } else { throw new CloneNotSupportedException( "Tool tip generator not cloneable."); } } if (this.toolTipGeneratorList != null) { clone.toolTipGeneratorList = (ObjectList) this.toolTipGeneratorList.clone(); } if (this.baseToolTipGenerator != null) { if (this.baseToolTipGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.baseToolTipGenerator; clone.baseToolTipGenerator = (CategoryToolTipGenerator) pc.clone(); } else { throw new CloneNotSupportedException( "Base tool tip generator not cloneable."); } } if (this.itemURLGenerator != null) { if (this.itemURLGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.itemURLGenerator; clone.itemURLGenerator = (CategoryURLGenerator) pc.clone(); } else { throw new CloneNotSupportedException( "Item URL generator not cloneable."); } } if (this.itemURLGeneratorList != null) { clone.itemURLGeneratorList = (ObjectList) this.itemURLGeneratorList.clone(); } if (this.baseItemURLGenerator != null) { if (this.baseItemURLGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.baseItemURLGenerator; clone.baseItemURLGenerator = (CategoryURLGenerator) pc.clone(); } else { throw new CloneNotSupportedException( "Base item URL generator not cloneable."); } } if (this.legendItemLabelGenerator instanceof PublicCloneable) { clone.legendItemLabelGenerator = (CategorySeriesLabelGenerator) ObjectUtilities.clone(this.legendItemLabelGenerator); } if (this.legendItemToolTipGenerator instanceof PublicCloneable) { clone.legendItemToolTipGenerator = (CategorySeriesLabelGenerator) ObjectUtilities.clone(this.legendItemToolTipGenerator); } if (this.legendItemURLGenerator instanceof PublicCloneable) { clone.legendItemURLGenerator = (CategorySeriesLabelGenerator) ObjectUtilities.clone(this.legendItemURLGenerator); } return clone; } /** * Returns a domain axis for a plot. * * @param plot the plot. * @param index the axis index. * * @return A domain axis. */ protected CategoryAxis getDomainAxis(CategoryPlot plot, int index) { CategoryAxis result = plot.getDomainAxis(index); if (result == null) { result = plot.getDomainAxis(); } return result; } /** * Returns a range axis for a plot. * * @param plot the plot. * @param index the axis index. * * @return A range axis. */ protected ValueAxis getRangeAxis(CategoryPlot plot, int index) { ValueAxis result = plot.getRangeAxis(index); if (result == null) { result = plot.getRangeAxis(); } return result; } /** * Returns a (possibly empty) collection of legend items for the series * that this renderer is responsible for drawing. * * @return The legend item collection (never null). * * @see #getLegendItem(int, int) */ public LegendItemCollection getLegendItems() { if (this.plot == null) { return new LegendItemCollection(); } LegendItemCollection result = new LegendItemCollection(); int index = this.plot.getIndexOf(this); CategoryDataset dataset = this.plot.getDataset(index); if (dataset != null) { int seriesCount = dataset.getRowCount(); for (int i = 0; i < seriesCount; i++) { if (isSeriesVisibleInLegend(i)) { LegendItem item = getLegendItem(index, i); if (item != null) { result.add(item); } } } } return result; } /** * Returns the legend item label generator. * * @return The label generator (never null). * * @see #setLegendItemLabelGenerator(CategorySeriesLabelGenerator) */ public CategorySeriesLabelGenerator getLegendItemLabelGenerator() { return this.legendItemLabelGenerator; } /** * Sets the legend item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null not permitted). * * @see #getLegendItemLabelGenerator() */ public void setLegendItemLabelGenerator( CategorySeriesLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } this.legendItemLabelGenerator = generator; fireChangeEvent(); } /** * Returns the legend item tool tip generator. * * @return The tool tip generator (possibly null). * * @see #setLegendItemToolTipGenerator(CategorySeriesLabelGenerator) */ public CategorySeriesLabelGenerator getLegendItemToolTipGenerator() { return this.legendItemToolTipGenerator; } /** * Sets the legend item tool tip generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #setLegendItemToolTipGenerator(CategorySeriesLabelGenerator) */ public void setLegendItemToolTipGenerator( CategorySeriesLabelGenerator generator) { this.legendItemToolTipGenerator = generator; fireChangeEvent(); } /** * Returns the legend item URL generator. * * @return The URL generator (possibly null). * * @see #setLegendItemURLGenerator(CategorySeriesLabelGenerator) */ public CategorySeriesLabelGenerator getLegendItemURLGenerator() { return this.legendItemURLGenerator; } /** * Sets the legend item URL generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getLegendItemURLGenerator() */ public void setLegendItemURLGenerator( CategorySeriesLabelGenerator generator) { this.legendItemURLGenerator = generator; fireChangeEvent(); } /** * Adds an entity with the specified hotspot. * * @param entities the entity collection. * @param dataset the dataset. * @param row the row index. * @param column the column index. * @param hotspot the hotspot (null not permitted). */ protected void addItemEntity(EntityCollection entities, CategoryDataset dataset, int row, int column, Shape hotspot) { if (hotspot == null) { throw new IllegalArgumentException("Null 'hotspot' argument."); } if (!getItemCreateEntity(row, column)) { return; } String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); } /** * Adds an entity to the collection. * * @param entities the entity collection being populated. * @param hotspot the entity area (if null a default will be * used). * @param dataset the dataset. * @param row the series. * @param column the item. * @param entityX the entity's center x-coordinate in user space (only * used if area is null). * @param entityY the entity's center y-coordinate in user space (only * used if area is null). * * @since 1.0.13 */ protected void addEntity(EntityCollection entities, Shape hotspot, CategoryDataset dataset, int row, int column, double entityX, double entityY) { if (!getItemCreateEntity(row, column)) { return; } Shape s = hotspot; if (hotspot == null) { double r = getDefaultEntityRadius(); double w = r * 2; if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { s = new Ellipse2D.Double(entityX - r, entityY - r, w, w); } else { s = new Ellipse2D.Double(entityY - r, entityX - r, w, w); } } String tip = null; CategoryToolTipGenerator generator = getToolTipGenerator(row, column); if (generator != null) { tip = generator.generateToolTip(dataset, row, column); } String url = null; CategoryURLGenerator urlster = getItemURLGenerator(row, column); if (urlster != null) { url = urlster.generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(s, tip, url, dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); entities.add(entity); } // === DEPRECATED CODE === /** * The item label generator for ALL series. * * @deprecated This field is redundant and deprecated as of version 1.0.6. */ private CategoryItemLabelGenerator itemLabelGenerator; /** * The tool tip generator for ALL series. * * @deprecated This field is redundant and deprecated as of version 1.0.6. */ private CategoryToolTipGenerator toolTipGenerator; /** * The URL generator. * * @deprecated This field is redundant and deprecated as of version 1.0.6. */ private CategoryURLGenerator itemURLGenerator; /** * Sets the item label generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelGenerator(int, * CategoryItemLabelGenerator)} and * {@link #setBaseItemLabelGenerator(CategoryItemLabelGenerator)}. */ public void setItemLabelGenerator(CategoryItemLabelGenerator generator) { this.itemLabelGenerator = generator; fireChangeEvent(); } /** * Returns the tool tip generator that will be used for ALL items in the * dataset (the "layer 0" generator). * * @return A tool tip generator (possibly null). * * @see #setToolTipGenerator(CategoryToolTipGenerator) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesToolTipGenerator(int)} * and {@link #getBaseToolTipGenerator()}. */ public CategoryToolTipGenerator getToolTipGenerator() { return this.toolTipGenerator; } /** * Sets the tool tip generator for ALL series and sends a * {@link org.jfree.chart.event.RendererChangeEvent} to all registered * listeners. * * @param generator the generator (null permitted). * * @see #getToolTipGenerator() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesToolTipGenerator(int, * CategoryToolTipGenerator)} and * {@link #setBaseToolTipGenerator(CategoryToolTipGenerator)}. */ public void setToolTipGenerator(CategoryToolTipGenerator generator) { this.toolTipGenerator = generator; fireChangeEvent(); } /** * Sets the item URL generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemURLGenerator(int, * CategoryURLGenerator)} and * {@link #setBaseItemURLGenerator(CategoryURLGenerator)}. */ public void setItemURLGenerator(CategoryURLGenerator generator) { this.itemURLGenerator = generator; fireChangeEvent(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/AreaRenderer.java0000644000175000017500000003257111173030414031266 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * AreaRenderer.java * ----------------- * (C) Copyright 2002-2008, by Jon Iles and Contributors. * * Original Author: Jon Iles; * Contributor(s): David Gilbert (for Object Refinery Limited); * Christian W. Zuckschwerdt; * * Changes: * -------- * 21-May-2002 : Version 1, contributed by John Iles (DG); * 29-May-2002 : Now extends AbstractCategoryItemRenderer (DG); * 11-Jun-2002 : Updated Javadoc comments (DG); * 25-Jun-2002 : Removed unnecessary imports (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Oct-2002 : Added constructors and basic entity support (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); * 06-Nov-2002 : Renamed drawCategoryItem() --> drawItem() and now using axis * for category spacing. Renamed AreaCategoryItemRenderer * --> AreaRenderer (DG); * 17-Jan-2003 : Moved plot classes into a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in * drawItem() method (DG); * 12-May-2003 : Modified to take into account the plot orientation (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 13-Aug-2003 : Implemented Cloneable (DG); * 07-Oct-2003 : Added renderer state (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 20-Apr-2005 : Apply tooltips and URLs to legend items (DG); * 09-Jun-2005 : Use addItemEntity() method from superclass (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Oct-2006 : Fixed bug in equals() method (DG); * 30-Nov-2006 : Added checks for series visibility (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 26-Jun-2008 : Added crosshair support (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.AreaRendererEndType; import org.jfree.data.category.CategoryDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A category item renderer that draws area charts. You can use this renderer * with the {@link CategoryPlot} class. The example shown here is generated * by the AreaChartDemo1.java program included in the JFreeChart * Demo Collection: *

* AreaRendererSample.png */ public class AreaRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4231878281385812757L; /** A flag that controls how the ends of the areas are drawn. */ private AreaRendererEndType endType; /** * Creates a new renderer. */ public AreaRenderer() { super(); this.endType = AreaRendererEndType.TAPER; setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); } /** * Returns a token that controls how the renderer draws the end points. * The default value is {@link AreaRendererEndType#TAPER}. * * @return The end type (never null). * * @see #setEndType */ public AreaRendererEndType getEndType() { return this.endType; } /** * Sets a token that controls how the renderer draws the end points, and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param type the end type (null not permitted). * * @see #getEndType() */ public void setEndType(AreaRendererEndType type) { if (type == null) { throw new IllegalArgumentException("Null 'type' argument."); } this.endType = type; fireChangeEvent(); } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { // if there is no plot, there is no dataset to access... CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data plot area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // do nothing if item is not visible if (!getItemVisible(row, column)) { return; } // plot non-null values only... Number value = dataset.getValue(row, column); if (value != null) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge axisEdge = plot.getDomainAxisEdge(); int count = dataset.getColumnCount(); float x0 = (float) domainAxis.getCategoryStart(column, count, dataArea, axisEdge); float x1 = (float) domainAxis.getCategoryMiddle(column, count, dataArea, axisEdge); float x2 = (float) domainAxis.getCategoryEnd(column, count, dataArea, axisEdge); x0 = Math.round(x0); x1 = Math.round(x1); x2 = Math.round(x2); if (this.endType == AreaRendererEndType.TRUNCATE) { if (column == 0) { x0 = x1; } else if (column == getColumnCount() - 1) { x2 = x1; } } double yy1 = value.doubleValue(); double yy0 = 0.0; if (column > 0) { Number n0 = dataset.getValue(row, column - 1); if (n0 != null) { yy0 = (n0.doubleValue() + yy1) / 2.0; } } double yy2 = 0.0; if (column < dataset.getColumnCount() - 1) { Number n2 = dataset.getValue(row, column + 1); if (n2 != null) { yy2 = (n2.doubleValue() + yy1) / 2.0; } } RectangleEdge edge = plot.getRangeAxisEdge(); float y0 = (float) rangeAxis.valueToJava2D(yy0, dataArea, edge); float y1 = (float) rangeAxis.valueToJava2D(yy1, dataArea, edge); float y2 = (float) rangeAxis.valueToJava2D(yy2, dataArea, edge); float yz = (float) rangeAxis.valueToJava2D(0.0, dataArea, edge); g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); GeneralPath area = new GeneralPath(); if (orientation == PlotOrientation.VERTICAL) { area.moveTo(x0, yz); area.lineTo(x0, y0); area.lineTo(x1, y1); area.lineTo(x2, y2); area.lineTo(x2, yz); } else if (orientation == PlotOrientation.HORIZONTAL) { area.moveTo(yz, x0); area.lineTo(y0, x0); area.lineTo(y1, x1); area.lineTo(y2, x2); area.lineTo(yz, x2); } area.closePath(); g2.setPaint(getItemPaint(row, column)); g2.fill(area); // draw the item labels if there are any... if (isItemLabelVisible(row, column)) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value.doubleValue() < 0.0)); } // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), yy1, datasetIndex, x1, y1, orientation); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, area); } } } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AreaRenderer)) { return false; } AreaRenderer that = (AreaRenderer) obj; if (!this.endType.equals(that.endType)) { return false; } return super.equals(obj); } /** * Returns an independent copy of the renderer. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/BarPainter.java0000644000175000017500000000650011173030414030747 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * BarPainter.java * --------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.geom.RectangularShape; import org.jfree.ui.RectangleEdge; /** * The interface for plugin painter for the {@link BarRenderer} class. When * developing a class that implements this interface, bear in mind the * following: *

    *
  • the equals(Object) method should be overridden;
  • *
  • instances of the class should be immutable OR implement the * PublicCloneable interface, so that a renderer using the * painter can be cloned reliably; *
  • the class should be Serializable, otherwise chart * serialization will not be supported.
  • *
* * @since 1.0.11 */ public interface BarPainter { /** * Paints a single bar on behalf of a renderer. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index for the item. * @param column the column index for the item. * @param bar the bounds for the bar. * @param base the base of the bar. */ public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base); /** * Paints the shadow for a single bar on behalf of a renderer. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index for the item. * @param column the column index for the item. * @param bar the bounds for the bar. * @param base the base of the bar. * @param pegShadow peg the shadow to the base of the bar? */ public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/BarRenderer.java0000644000175000017500000014212111173030414031113 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * BarRenderer.java * ---------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Christian W. Zuckschwerdt; * Peter Kolb (patch 2497611); * * Changes * ------- * 14-Mar-2002 : Version 1 (DG); * 23-May-2002 : Added tooltip generator to renderer (DG); * 29-May-2002 : Moved tooltip generator to abstract super-class (DG); * 25-Jun-2002 : Changed constructor to protected and removed redundant * code (DG); * 26-Jun-2002 : Added axis to initialise method, and record upper and lower * clip values (DG); * 24-Sep-2002 : Added getLegendItem() method (DG); * 09-Oct-2002 : Modified constructor to include URL generator (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 10-Jan-2003 : Moved get/setItemMargin() method up from subclasses (DG); * 17-Jan-2003 : Moved plot classes into a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified clipping to allow for dual axes and datasets (DG); * 12-May-2003 : Merged horizontal and vertical bar renderers (DG); * 12-Jun-2003 : Updates for item labels (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 02-Sep-2003 : Changed initialise method to fix bug 790407 (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 27-Oct-2003 : Merged drawHorizontalItem() and drawVerticalItem() * methods (DG); * 28-Oct-2003 : Added support for gradient paint on bars (DG); * 14-Nov-2003 : Added 'maxBarWidth' attribute (DG); * 10-Feb-2004 : Small changes inside drawItem() method to ease cut-and-paste * overriding (DG); * 19-Mar-2004 : Fixed bug introduced with separation of tool tip and item * label generators. Fixed equals() method (DG); * 11-May-2004 : Fix for null pointer exception (bug id 951127) (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 26-Jan-2005 : Provided override for getLegendItem() method (DG); * 20-Apr-2005 : Generate legend labels, tooltips and URLs (DG); * 18-May-2005 : Added configurable base value (DG); * 09-Jun-2005 : Use addItemEntity() method from superclass (DG); * 01-Dec-2005 : Update legend item to use/not use outline (DG); * ------------: JFreeChart 1.0.x --------------------------------------------- * 06-Dec-2005 : Fixed bug 1374222 (JDK 1.4 specific code) (DG); * 11-Jan-2006 : Fixed bug 1401856 (bad rendering for non-zero base) (DG); * 04-Aug-2006 : Fixed bug 1467706 (missing item labels for zero value * bars) (DG); * 04-Dec-2006 : Fixed bug in rendering to non-primary axis (DG); * 13-Dec-2006 : Add support for GradientPaint display in legend items (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 11-May-2007 : Check for visibility in getLegendItem() (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 07-May-2008 : If minimumBarLength is > 0.0, extend the non-base end of the * bar (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 24-Jun-2008 : Added barPainter mechanism (DG); * 26-Jun-2008 : Added crosshair support (DG); * 13-Aug-2008 : Added shadowPaint attribute (DG); * 14-Jan-2009 : Added support for seriesVisible flags (PK); * 03-Feb-2009 : Added defaultShadowsVisible flag - see patch 2511330 (PK); * */ package org.jfree.chart.renderer.category; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A {@link CategoryItemRenderer} that draws individual data items as bars. * The example shown here is generated by the BarChartDemo1.java * program included in the JFreeChart Demo Collection: *

* BarRendererSample.png */ public class BarRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 6000649414965887481L; /** The default item margin percentage. */ public static final double DEFAULT_ITEM_MARGIN = 0.20; /** * Constant that controls the minimum width before a bar has an outline * drawn. */ public static final double BAR_OUTLINE_WIDTH_THRESHOLD = 3.0; /** * The default bar painter assigned to each new instance of this renderer. * * @since 1.0.11 */ private static BarPainter defaultBarPainter = new GradientBarPainter(); /** * Returns the default bar painter. * * @return The default bar painter. * * @since 1.0.11 */ public static BarPainter getDefaultBarPainter() { return BarRenderer.defaultBarPainter; } /** * Sets the default bar painter. * * @param painter the painter (null not permitted). * * @since 1.0.11 */ public static void setDefaultBarPainter(BarPainter painter) { if (painter == null) { throw new IllegalArgumentException("Null 'painter' argument."); } BarRenderer.defaultBarPainter = painter; } /** * The default value for the initialisation of the shadowsVisible flag. */ private static boolean defaultShadowsVisible = true; /** * Returns the default value for the shadowsVisible flag. * * @return A boolean. * * @see #setDefaultShadowsVisible(boolean) * * @since 1.0.13 */ public static boolean getDefaultShadowsVisible() { return BarRenderer.defaultShadowsVisible; } /** * Sets the default value for the shadows visible flag. * * @param visible the new value for the default. * * @see #getDefaultShadowsVisible() * * @since 1.0.13 */ public static void setDefaultShadowsVisible(boolean visible) { BarRenderer.defaultShadowsVisible = visible; } /** The margin between items (bars) within a category. */ private double itemMargin; /** A flag that controls whether or not bar outlines are drawn. */ private boolean drawBarOutline; /** The maximum bar width as a percentage of the available space. */ private double maximumBarWidth; /** The minimum bar length (in Java2D units). */ private double minimumBarLength; /** * An optional class used to transform gradient paint objects to fit each * bar. */ private GradientPaintTransformer gradientPaintTransformer; /** * The fallback position if a positive item label doesn't fit inside the * bar. */ private ItemLabelPosition positiveItemLabelPositionFallback; /** * The fallback position if a negative item label doesn't fit inside the * bar. */ private ItemLabelPosition negativeItemLabelPositionFallback; /** The upper clip (axis) value for the axis. */ private double upperClip; // TODO: this needs to move into the renderer state /** The lower clip (axis) value for the axis. */ private double lowerClip; // TODO: this needs to move into the renderer state /** The base value for the bars (defaults to 0.0). */ private double base; /** * A flag that controls whether the base value is included in the range * returned by the findRangeBounds() method. */ private boolean includeBaseInRange; /** * The bar painter (never null). * * @since 1.0.11 */ private BarPainter barPainter; /** * The flag that controls whether or not shadows are drawn for the bars. * * @since 1.0.11 */ private boolean shadowsVisible; /** * The shadow paint. * * @since 1.0.11 */ private transient Paint shadowPaint; /** * The x-offset for the shadow effect. * * @since 1.0.11 */ private double shadowXOffset; /** * The y-offset for the shadow effect. * * @since 1.0.11 */ private double shadowYOffset; /** * Creates a new bar renderer with default settings. */ public BarRenderer() { super(); this.base = 0.0; this.includeBaseInRange = true; this.itemMargin = DEFAULT_ITEM_MARGIN; this.drawBarOutline = false; this.maximumBarWidth = 1.0; // 100 percent, so it will not apply unless changed this.positiveItemLabelPositionFallback = null; this.negativeItemLabelPositionFallback = null; this.gradientPaintTransformer = new StandardGradientPaintTransformer(); this.minimumBarLength = 0.0; setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); this.barPainter = getDefaultBarPainter(); this.shadowsVisible = getDefaultShadowsVisible(); this.shadowPaint = Color.gray; this.shadowXOffset = 4.0; this.shadowYOffset = 4.0; } /** * Returns the base value for the bars. The default value is * 0.0. * * @return The base value for the bars. * * @see #setBase(double) */ public double getBase() { return this.base; } /** * Sets the base value for the bars and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param base the new base value. * * @see #getBase() */ public void setBase(double base) { this.base = base; fireChangeEvent(); } /** * Returns the item margin as a percentage of the available space for all * bars. * * @return The margin percentage (where 0.10 is ten percent). * * @see #setItemMargin(double) */ public double getItemMargin() { return this.itemMargin; } /** * Sets the item margin and sends a {@link RendererChangeEvent} to all * registered listeners. The value is expressed as a percentage of the * available width for plotting all the bars, with the resulting amount to * be distributed between all the bars evenly. * * @param percent the margin (where 0.10 is ten percent). * * @see #getItemMargin() */ public void setItemMargin(double percent) { this.itemMargin = percent; fireChangeEvent(); } /** * Returns a flag that controls whether or not bar outlines are drawn. * * @return A boolean. * * @see #setDrawBarOutline(boolean) */ public boolean isDrawBarOutline() { return this.drawBarOutline; } /** * Sets the flag that controls whether or not bar outlines are drawn and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param draw the flag. * * @see #isDrawBarOutline() */ public void setDrawBarOutline(boolean draw) { this.drawBarOutline = draw; fireChangeEvent(); } /** * Returns the maximum bar width, as a percentage of the available drawing * space. * * @return The maximum bar width. * * @see #setMaximumBarWidth(double) */ public double getMaximumBarWidth() { return this.maximumBarWidth; } /** * Sets the maximum bar width, which is specified as a percentage of the * available space for all bars, and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param percent the percent (where 0.05 is five percent). * * @see #getMaximumBarWidth() */ public void setMaximumBarWidth(double percent) { this.maximumBarWidth = percent; fireChangeEvent(); } /** * Returns the minimum bar length (in Java2D units). The default value is * 0.0. * * @return The minimum bar length. * * @see #setMinimumBarLength(double) */ public double getMinimumBarLength() { return this.minimumBarLength; } /** * Sets the minimum bar length and sends a {@link RendererChangeEvent} to * all registered listeners. The minimum bar length is specified in Java2D * units, and can be used to prevent bars that represent very small data * values from disappearing when drawn on the screen. Typically you would * set this to (say) 0.5 or 1.0 Java 2D units. Use this attribute with * caution, however, because setting it to a non-zero value will * artificially increase the length of bars representing small values, * which may misrepresent your data. * * @param min the minimum bar length (in Java2D units, must be >= 0.0). * * @see #getMinimumBarLength() */ public void setMinimumBarLength(double min) { if (min < 0.0) { throw new IllegalArgumentException("Requires 'min' >= 0.0"); } this.minimumBarLength = min; fireChangeEvent(); } /** * Returns the gradient paint transformer (an object used to transform * gradient paint objects to fit each bar). * * @return A transformer (null possible). * * @see #setGradientPaintTransformer(GradientPaintTransformer) */ public GradientPaintTransformer getGradientPaintTransformer() { return this.gradientPaintTransformer; } /** * Sets the gradient paint transformer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param transformer the transformer (null permitted). * * @see #getGradientPaintTransformer() */ public void setGradientPaintTransformer( GradientPaintTransformer transformer) { this.gradientPaintTransformer = transformer; fireChangeEvent(); } /** * Returns the fallback position for positive item labels that don't fit * within a bar. * * @return The fallback position (null possible). * * @see #setPositiveItemLabelPositionFallback(ItemLabelPosition) */ public ItemLabelPosition getPositiveItemLabelPositionFallback() { return this.positiveItemLabelPositionFallback; } /** * Sets the fallback position for positive item labels that don't fit * within a bar, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * * @see #getPositiveItemLabelPositionFallback() */ public void setPositiveItemLabelPositionFallback( ItemLabelPosition position) { this.positiveItemLabelPositionFallback = position; fireChangeEvent(); } /** * Returns the fallback position for negative item labels that don't fit * within a bar. * * @return The fallback position (null possible). * * @see #setPositiveItemLabelPositionFallback(ItemLabelPosition) */ public ItemLabelPosition getNegativeItemLabelPositionFallback() { return this.negativeItemLabelPositionFallback; } /** * Sets the fallback position for negative item labels that don't fit * within a bar, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * * @see #getNegativeItemLabelPositionFallback() */ public void setNegativeItemLabelPositionFallback( ItemLabelPosition position) { this.negativeItemLabelPositionFallback = position; fireChangeEvent(); } /** * Returns the flag that controls whether or not the base value for the * bars is included in the range calculated by * {@link #findRangeBounds(CategoryDataset)}. * * @return true if the base is included in the range, and * false otherwise. * * @since 1.0.1 * * @see #setIncludeBaseInRange(boolean) */ public boolean getIncludeBaseInRange() { return this.includeBaseInRange; } /** * Sets the flag that controls whether or not the base value for the bars * is included in the range calculated by * {@link #findRangeBounds(CategoryDataset)}. If the flag is changed, * a {@link RendererChangeEvent} is sent to all registered listeners. * * @param include the new value for the flag. * * @since 1.0.1 * * @see #getIncludeBaseInRange() */ public void setIncludeBaseInRange(boolean include) { if (this.includeBaseInRange != include) { this.includeBaseInRange = include; fireChangeEvent(); } } /** * Returns the bar painter. * * @return The bar painter (never null). * * @see #setBarPainter(BarPainter) * * @since 1.0.11 */ public BarPainter getBarPainter() { return this.barPainter; } /** * Sets the bar painter for this renderer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param painter the painter (null not permitted). * * @see #getBarPainter() * * @since 1.0.11 */ public void setBarPainter(BarPainter painter) { if (painter == null) { throw new IllegalArgumentException("Null 'painter' argument."); } this.barPainter = painter; fireChangeEvent(); } /** * Returns the flag that controls whether or not shadows are drawn for * the bars. * * @return A boolean. * * @since 1.0.11 */ public boolean getShadowsVisible() { return this.shadowsVisible; } /** * Sets the flag that controls whether or not shadows are * drawn by the renderer. * * @param visible the new flag value. * * @since 1.0.11 */ public void setShadowVisible(boolean visible) { this.shadowsVisible = visible; fireChangeEvent(); } /** * Returns the shadow paint. * * @return The shadow paint. * * @see #setShadowPaint(Paint) * * @since 1.0.11 */ public Paint getShadowPaint() { return this.shadowPaint; } /** * Sets the shadow paint and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getShadowPaint() * * @since 1.0.11 */ public void setShadowPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.shadowPaint = paint; fireChangeEvent(); } /** * Returns the shadow x-offset. * * @return The shadow x-offset. * * @since 1.0.11 */ public double getShadowXOffset() { return this.shadowXOffset; } /** * Sets the x-offset for the bar shadow and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param offset the offset. * * @since 1.0.11 */ public void setShadowXOffset(double offset) { this.shadowXOffset = offset; fireChangeEvent(); } /** * Returns the shadow y-offset. * * @return The shadow y-offset. * * @since 1.0.11 */ public double getShadowYOffset() { return this.shadowYOffset; } /** * Sets the y-offset for the bar shadow and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param offset the offset. * * @since 1.0.11 */ public void setShadowYOffset(double offset) { this.shadowYOffset = offset; fireChangeEvent(); } /** * Returns the lower clip value. This value is recalculated in the * initialise() method. * * @return The value. */ public double getLowerClip() { // TODO: this attribute should be transferred to the renderer state. return this.lowerClip; } /** * Returns the upper clip value. This value is recalculated in the * initialise() method. * * @return The value. */ public double getUpperClip() { // TODO: this attribute should be transferred to the renderer state. return this.upperClip; } /** * Initialises the renderer and returns a state object that will be passed * to subsequent calls to the drawItem method. This method gets called * once at the start of the process of drawing a chart. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info); // get the clipping values... ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex); this.lowerClip = rangeAxis.getRange().getLowerBound(); this.upperClip = rangeAxis.getRange().getUpperBound(); // calculate the bar width calculateBarWidth(plot, dataArea, rendererIndex, state); return state; } /** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } } /** * Calculates the coordinate of the first "side" of a bar. This will be * the minimum x-coordinate for a vertical bar, and the minimum * y-coordinate for a horizontal bar. * * @param plot the plot. * @param orientation the plot orientation. * @param dataArea the data area. * @param domainAxis the domain axis. * @param state the renderer state (has the bar width precalculated). * @param row the row index. * @param column the column index. * * @return The coordinate. */ protected double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column) { // calculate bar width... double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else { space = dataArea.getWidth(); } double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); int seriesCount = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : getRowCount(); int categoryCount = getColumnCount(); if (seriesCount > 1) { double seriesGap = space * getItemMargin() / (categoryCount * (seriesCount - 1)); double seriesW = calculateSeriesWidth(space, domainAxis, categoryCount, seriesCount); barW0 = barW0 + row * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0); } else { barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; } return barW0; } /** * Calculates the coordinates for the length of a single bar. * * @param value the value represented by the bar. * * @return The coordinates for each end of the bar (or null if * the bar is not visible for the current axis range). */ protected double[] calculateBarL0L1(double value) { double lclip = getLowerClip(); double uclip = getUpperClip(); double barLow = Math.min(this.base, value); double barHigh = Math.max(this.base, value); if (barHigh < lclip) { // bar is not visible return null; } if (barLow > uclip) { // bar is not visible return null; } barLow = Math.max(barLow, lclip); barHigh = Math.min(barHigh, uclip); return new double[] {barLow, barHigh}; } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. This takes into account the range * of values in the dataset, plus the flag that determines whether or not * the base value for the bars should be included in the range. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } Range result = DatasetUtilities.findRangeBounds(dataset); if (result != null) { if (this.includeBaseInRange) { result = Range.expandToInclude(result, this.base); } } return result; } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly null). */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.black); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // nothing is drawn if the row index is not included in the list with // the indices of the visible rows... int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } final double value = dataValue.doubleValue(); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, state, visibleRow, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], dataArea, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], dataArea, edge); // in the following code, barL0 is (in Java2D coordinates) the LEFT // end of the bar for a horizontal bar chart, and the TOP end of the // bar for a vertical bar chart. Whether this is the BASE of the bar // or not depends also on (a) whether the data value is 'negative' // relative to the base value and (b) whether or not the range axis is // inverted. This only matters if/when we apply the minimumBarLength // attribute, because we should extend the non-base end of the bar boolean positive = (value >= this.base); boolean inverted = rangeAxis.isInverted(); double barL0 = Math.min(transL0, transL1); double barLength = Math.abs(transL1 - transL0); double barLengthAdj = 0.0; if (barLength > 0.0 && barLength < getMinimumBarLength()) { barLengthAdj = getMinimumBarLength() - barLength; } double barL0Adj = 0.0; RectangleEdge barBase; if (orientation == PlotOrientation.HORIZONTAL) { if (positive && inverted || !positive && !inverted) { barL0Adj = barLengthAdj; barBase = RectangleEdge.RIGHT; } else { barBase = RectangleEdge.LEFT; } } else { if (positive && !inverted || !positive && inverted) { barL0Adj = barLengthAdj; barBase = RectangleEdge.BOTTOM; } else { barBase = RectangleEdge.TOP; } } // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0 - barL0Adj, barW0, barLength + barLengthAdj, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0 - barL0Adj, state.getBarWidth(), barLength + barLengthAdj); } if (getShadowsVisible()) { this.barPainter.paintBarShadow(g2, this, row, column, bar, barBase, true); } this.barPainter.paintBar(g2, this, row, column, bar, barBase); CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value, datasetIndex, barW0, barL0, orientation); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Calculates the available space for each series. * * @param space the space along the entire axis (in Java2D units). * @param axis the category axis. * @param categories the number of categories. * @param series the number of series. * * @return The width of one series. */ protected double calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series) { double factor = 1.0 - getItemMargin() - axis.getLowerMargin() - axis.getUpperMargin(); if (categories > 1) { factor = factor - axis.getCategoryMargin(); } return (space * factor) / (categories * series); } /** * Draws an item label. This method is overridden so that the bar can be * used to calculate the label anchor point. * * @param g2 the graphics device. * @param data the dataset. * @param row the row. * @param column the column. * @param plot the plot. * @param generator the label generator. * @param bar the bar. * @param negative a flag indicating a negative value. */ protected void drawItemLabel(Graphics2D g2, CategoryDataset data, int row, int column, CategoryPlot plot, CategoryItemLabelGenerator generator, Rectangle2D bar, boolean negative) { String label = generator.generateLabel(data, row, column); if (label == null) { return; // nothing to do } Font labelFont = getItemLabelFont(row, column); g2.setFont(labelFont); Paint paint = getItemLabelPaint(row, column); g2.setPaint(paint); // find out where to place the label... ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(row, column); } else { position = getNegativeItemLabelPosition(row, column); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); if (isInternalAnchor(position.getItemLabelAnchor())) { Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); if (bounds != null) { if (!bar.contains(bounds.getBounds2D())) { if (!negative) { position = getPositiveItemLabelPositionFallback(); } else { position = getNegativeItemLabelPositionFallback(); } if (position != null) { anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); } } } } if (position != null) { TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } } /** * Calculates the item label anchor point. * * @param anchor the anchor. * @param bar the bar. * @param orientation the plot orientation. * * @return The anchor point. */ private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, Rectangle2D bar, PlotOrientation orientation) { Point2D result = null; double offset = getItemLabelAnchorOffset(); double x0 = bar.getX() - offset; double x1 = bar.getX(); double x2 = bar.getX() + offset; double x3 = bar.getCenterX(); double x4 = bar.getMaxX() - offset; double x5 = bar.getMaxX(); double x6 = bar.getMaxX() + offset; double y0 = bar.getMaxY() + offset; double y1 = bar.getMaxY(); double y2 = bar.getMaxY() - offset; double y3 = bar.getCenterY(); double y4 = bar.getMinY() + offset; double y5 = bar.getMinY(); double y6 = bar.getMinY() - offset; if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x3, y3); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x4, y3); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x3, y2); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x2, y3); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x3, y4); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double(x5, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double(x6, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x6, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double(x6, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double(x5, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x3, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double(x1, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double(x0, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x0, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double(x0, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double(x1, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x3, y6); } return result; } /** * Returns true if the specified anchor point is inside a bar. * * @param anchor the anchor point. * * @return A boolean. */ private boolean isInternalAnchor(ItemLabelAnchor anchor) { return anchor == ItemLabelAnchor.CENTER || anchor == ItemLabelAnchor.INSIDE1 || anchor == ItemLabelAnchor.INSIDE2 || anchor == ItemLabelAnchor.INSIDE3 || anchor == ItemLabelAnchor.INSIDE4 || anchor == ItemLabelAnchor.INSIDE5 || anchor == ItemLabelAnchor.INSIDE6 || anchor == ItemLabelAnchor.INSIDE7 || anchor == ItemLabelAnchor.INSIDE8 || anchor == ItemLabelAnchor.INSIDE9 || anchor == ItemLabelAnchor.INSIDE10 || anchor == ItemLabelAnchor.INSIDE11 || anchor == ItemLabelAnchor.INSIDE12; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BarRenderer)) { return false; } BarRenderer that = (BarRenderer) obj; if (this.base != that.base) { return false; } if (this.itemMargin != that.itemMargin) { return false; } if (this.drawBarOutline != that.drawBarOutline) { return false; } if (this.maximumBarWidth != that.maximumBarWidth) { return false; } if (this.minimumBarLength != that.minimumBarLength) { return false; } if (!ObjectUtilities.equal(this.gradientPaintTransformer, that.gradientPaintTransformer)) { return false; } if (!ObjectUtilities.equal(this.positiveItemLabelPositionFallback, that.positiveItemLabelPositionFallback)) { return false; } if (!ObjectUtilities.equal(this.negativeItemLabelPositionFallback, that.negativeItemLabelPositionFallback)) { return false; } if (!this.barPainter.equals(that.barPainter)) { return false; } if (this.shadowsVisible != that.shadowsVisible) { return false; } if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { return false; } if (this.shadowXOffset != that.shadowXOffset) { return false; } if (this.shadowYOffset != that.shadowYOffset) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.shadowPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.shadowPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/BarRenderer3D.java0000644000175000017500000007615611173030414031320 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * BarRenderer3D.java * ------------------ * (C) Copyright 2001-2009, by Serge V. Grachov and Contributors. * * Original Author: Serge V. Grachov; * Contributor(s): David Gilbert (for Object Refinery Limited); * Tin Luu; * Milo Simpson; * Richard Atkinson; * Rich Unger; * Christian W. Zuckschwerdt; * * Changes * ------- * 31-Oct-2001 : First version, contributed by Serge V. Grachov (DG); * 15-Nov-2001 : Modified to allow for null data values (DG); * 13-Dec-2001 : Added tooltips (DG); * 16-Jan-2002 : Added fix for single category or single series datasets, * pointed out by Taoufik Romdhane (DG); * 24-May-2002 : Incorporated tooltips into chart entities (DG); * 11-Jun-2002 : Added check for (permitted) null info object, bug and fix * reported by David Basten. Also updated Javadocs. (DG); * 19-Jun-2002 : Added code to draw labels on bars (TL); * 26-Jun-2002 : Added bar clipping to avoid PRExceptions (DG); * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs * for HTML image maps (RA); * 06-Aug-2002 : Value labels now use number formatter, thanks to Milo * Simpson (DG); * 08-Aug-2002 : Applied fixed in bug id 592218 (DG); * 20-Sep-2002 : Added fix for categoryPaint by Rich Unger, and fixed errors * reported by Checkstyle (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); * 06-Nov-2002 : Moved to the com.jrefinery.chart.renderer package (DG); * 28-Jan-2003 : Added an attribute to control the shading of the left and * bottom walls in the plot background (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 10-Apr-2003 : Removed category paint usage (DG); * 13-May-2003 : Renamed VerticalBarRenderer3D --> BarRenderer3D and merged with * HorizontalBarRenderer3D (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 19-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 07-Oct-2003 : Added renderer state (DG); * 08-Oct-2003 : Removed clipping (replaced with flag in CategoryPlot to * control order in which the data items are processed) (DG); * 20-Oct-2003 : Fixed bug (outline stroke not being used for bar * outlines) (DG); * 21-Oct-2003 : Bar width moved into CategoryItemRendererState (DG); * 24-Nov-2003 : Fixed bug 846324 (item labels not showing) (DG); * 27-Nov-2003 : Added code to respect maxBarWidth setting (DG); * 02-Feb-2004 : Fixed bug where 'drawBarOutline' flag is not respected (DG); * 10-Feb-2004 : Small change to drawItem() method to make cut-and-paste * overriding easier (DG); * 04-Oct-2004 : Fixed bug with item label positioning when plot alignment is * horizontal (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 25-Apr-2005 : Override initialise() method to fix bug 1189642 (DG); * 09-Jun-2005 : Use addEntityItem from super class (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 07-Dec-2006 : Implemented equals() override (DG); * 17-Jan-2007 : Fixed bug in drawDomainGridline() method (DG); * 03-Apr-2007 : Fixed bugs in drawBackground() method (DG); * 16-Oct-2007 : Fixed bug in range marker drawing (DG); * 19-Mar-2009 : Override for drawRangeLine() method (DG); * */ package org.jfree.chart.renderer.category; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.Effect3D; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueMarker; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A renderer for bars with a 3D effect, for use with the * {@link CategoryPlot} class. The example shown here is generated * by the BarChart3DDemo1.java program included in the JFreeChart * Demo Collection: *

* BarRenderer3DSample.png */ public class BarRenderer3D extends BarRenderer implements Effect3D, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7686976503536003636L; /** The default x-offset for the 3D effect. */ public static final double DEFAULT_X_OFFSET = 12.0; /** The default y-offset for the 3D effect. */ public static final double DEFAULT_Y_OFFSET = 8.0; /** The default wall paint. */ public static final Paint DEFAULT_WALL_PAINT = new Color(0xDD, 0xDD, 0xDD); /** The size of x-offset for the 3D effect. */ private double xOffset; /** The size of y-offset for the 3D effect. */ private double yOffset; /** The paint used to shade the left and lower 3D wall. */ private transient Paint wallPaint; /** * Default constructor, creates a renderer with a default '3D effect'. */ public BarRenderer3D() { this(DEFAULT_X_OFFSET, DEFAULT_Y_OFFSET); } /** * Constructs a new renderer with the specified '3D effect'. * * @param xOffset the x-offset for the 3D effect. * @param yOffset the y-offset for the 3D effect. */ public BarRenderer3D(double xOffset, double yOffset) { super(); this.xOffset = xOffset; this.yOffset = yOffset; this.wallPaint = DEFAULT_WALL_PAINT; // set the default item label positions ItemLabelPosition p1 = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.TOP_CENTER); setBasePositiveItemLabelPosition(p1); ItemLabelPosition p2 = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.TOP_CENTER); setBaseNegativeItemLabelPosition(p2); } /** * Returns the x-offset for the 3D effect. * * @return The 3D effect. * * @see #getYOffset() */ public double getXOffset() { return this.xOffset; } /** * Returns the y-offset for the 3D effect. * * @return The 3D effect. */ public double getYOffset() { return this.yOffset; } /** * Returns the paint used to highlight the left and bottom wall in the plot * background. * * @return The paint. * * @see #setWallPaint(Paint) */ public Paint getWallPaint() { return this.wallPaint; } /** * Sets the paint used to hightlight the left and bottom walls in the plot * background, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param paint the paint (null not permitted). * * @see #getWallPaint() */ public void setWallPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.wallPaint = paint; fireChangeEvent(); } /** * Initialises the renderer and returns a state object that will be passed * to subsequent calls to the drawItem method. This method gets called * once at the start of the process of drawing a chart. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); CategoryItemRendererState state = super.initialise(g2, adjusted, plot, rendererIndex, info); return state; } /** * Draws the background for the plot. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area inside the axes. */ public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(this.xOffset); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(this.xOffset); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(this.yOffset); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(this.yOffset); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0); clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getBackgroundAlpha())); // fill background... Paint backgroundPaint = plot.getBackgroundPaint(); if (backgroundPaint != null) { g2.setPaint(backgroundPaint); g2.fill(clip); } GeneralPath leftWall = new GeneralPath(); leftWall.moveTo(x0, y0); leftWall.lineTo(x0, y2); leftWall.lineTo(x1, y3); leftWall.lineTo(x1, y1); leftWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(leftWall); GeneralPath bottomWall = new GeneralPath(); bottomWall.moveTo(x0, y0); bottomWall.lineTo(x1, y1); bottomWall.lineTo(x3, y1); bottomWall.lineTo(x2, y0); bottomWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(bottomWall); // highlight the background corners... g2.setPaint(Color.lightGray); Line2D corner = new Line2D.Double(x0, y0, x1, y1); g2.draw(corner); corner.setLine(x1, y1, x1, y3); g2.draw(corner); corner.setLine(x1, y1, x3, y1); g2.draw(corner); // draw background image, if there is one... Image backgroundImage = plot.getBackgroundImage(); if (backgroundImage != null) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + getXOffset(), dataArea.getY(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); plot.drawBackgroundImage(g2, adjusted); } g2.setComposite(originalComposite); } /** * Draws the outline for the plot. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area inside the axes. */ public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(this.xOffset); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(this.xOffset); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(this.yOffset); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(this.yOffset); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0); clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); // put an outline around the data area... Stroke outlineStroke = plot.getOutlineStroke(); Paint outlinePaint = plot.getOutlinePaint(); if ((outlineStroke != null) && (outlinePaint != null)) { g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(clip); } } /** * Draws a grid line against the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. * */ public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) { Line2D line1 = null; Line2D line2 = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { double y0 = value; double y1 = value - getYOffset(); double x0 = dataArea.getMinX(); double x1 = x0 + getXOffset(); double x2 = dataArea.getMaxX(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x2, y1); } else if (orientation == PlotOrientation.VERTICAL) { double x0 = value; double x1 = value + getXOffset(); double y0 = dataArea.getMaxY(); double y1 = y0 - getYOffset(); double y2 = dataArea.getMinY(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x1, y2); } Paint paint = plot.getDomainGridlinePaint(); Stroke stroke = plot.getDomainGridlineStroke(); g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); g2.draw(line1); g2.draw(line2); } /** * Draws a grid line against the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value at which the grid line should be drawn. * */ public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value) { Range range = axis.getRange(); if (!range.contains(value)) { return; } Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); Line2D line1 = null; Line2D line2 = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { double x0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double x1 = x0 + getXOffset(); double y0 = dataArea.getMaxY(); double y1 = y0 - getYOffset(); double y2 = dataArea.getMinY(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x1, y2); } else if (orientation == PlotOrientation.VERTICAL) { double y0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double y1 = y0 - getYOffset(); double x0 = dataArea.getMinX(); double x1 = x0 + getXOffset(); double x2 = dataArea.getMaxX(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x2, y1); } Paint paint = plot.getRangeGridlinePaint(); Stroke stroke = plot.getRangeGridlineStroke(); g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); g2.draw(line1); g2.draw(line2); } /** * Draws a line perpendicular to the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D * effect). * @param value the value at which the grid line should be drawn. * @param paint the paint. * @param stroke the stroke. * * @see #drawRangeGridline * * @since 1.0.13 */ public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { Range range = axis.getRange(); if (!range.contains(value)) { return; } Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); Line2D line1 = null; Line2D line2 = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { double x0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double x1 = x0 + getXOffset(); double y0 = dataArea.getMaxY(); double y1 = y0 - getYOffset(); double y2 = dataArea.getMinY(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x1, y2); } else if (orientation == PlotOrientation.VERTICAL) { double y0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double y1 = y0 - getYOffset(); double x0 = dataArea.getMinX(); double x1 = x0 + getXOffset(); double x2 = dataArea.getMaxX(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x2, y1); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line1); g2.draw(line2); } /** * Draws a range marker. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param marker the marker. * @param dataArea the area for plotting data (not including 3D effect). */ public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = axis.getRange(); if (!range.contains(value)) { return; } GeneralPath path = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { float x = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); float y = (float) adjusted.getMaxY(); path = new GeneralPath(); path.moveTo(x, y); path.lineTo((float) (x + getXOffset()), y - (float) getYOffset()); path.lineTo((float) (x + getXOffset()), (float) (adjusted.getMinY() - getYOffset())); path.lineTo(x, (float) adjusted.getMinY()); path.closePath(); } else if (orientation == PlotOrientation.VERTICAL) { float y = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); float x = (float) dataArea.getX(); path = new GeneralPath(); path.moveTo(x, y); path.lineTo(x + (float) this.xOffset, y - (float) this.yOffset); path.lineTo((float) (adjusted.getMaxX() + this.xOffset), y - (float) this.yOffset); path.lineTo((float) (adjusted.getMaxX()), y); path.closePath(); } g2.setPaint(marker.getPaint()); g2.fill(path); g2.setPaint(marker.getOutlinePaint()); g2.draw(path); String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateRangeMarkerTextAnchorPoint( g2, orientation, dataArea, path.getBounds2D(), marker.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } } else { super.drawRangeMarker(g2, plot, axis, marker, adjusted); // TODO: draw the interval marker with a 3D effect } } /** * Draws a 3D bar to represent one data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area for plotting the data. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); double barL0 = Math.min(transL0, transL1); double barLength = Math.abs(transL1 - transL0); // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } Paint itemPaint = getItemPaint(row, column); g2.setPaint(itemPaint); g2.fill(bar); double x0 = bar.getMinX(); double x1 = x0 + getXOffset(); double x2 = bar.getMaxX(); double x3 = x2 + getXOffset(); double y0 = bar.getMinY() - getYOffset(); double y1 = bar.getMinY(); double y2 = bar.getMaxY() - getYOffset(); double y3 = bar.getMaxY(); GeneralPath bar3dRight = null; GeneralPath bar3dTop = null; if (barLength > 0.0) { bar3dRight = new GeneralPath(); bar3dRight.moveTo((float) x2, (float) y3); bar3dRight.lineTo((float) x2, (float) y1); bar3dRight.lineTo((float) x3, (float) y0); bar3dRight.lineTo((float) x3, (float) y2); bar3dRight.closePath(); if (itemPaint instanceof Color) { g2.setPaint(((Color) itemPaint).darker()); } g2.fill(bar3dRight); } bar3dTop = new GeneralPath(); bar3dTop.moveTo((float) x0, (float) y1); bar3dTop.lineTo((float) x1, (float) y0); bar3dTop.lineTo((float) x3, (float) y0); bar3dTop.lineTo((float) x2, (float) y1); bar3dTop.closePath(); g2.fill(bar3dTop); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (bar3dRight != null) { g2.draw(bar3dRight); } if (bar3dTop != null) { g2.draw(bar3dTop); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { GeneralPath barOutline = new GeneralPath(); barOutline.moveTo((float) x0, (float) y3); barOutline.lineTo((float) x0, (float) y1); barOutline.lineTo((float) x1, (float) y0); barOutline.lineTo((float) x3, (float) y0); barOutline.lineTo((float) x3, (float) y2); barOutline.lineTo((float) x2, (float) y3); barOutline.closePath(); addItemEntity(entities, dataset, row, column, barOutline); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BarRenderer3D)) { return false; } BarRenderer3D that = (BarRenderer3D) obj; if (this.xOffset != that.xOffset) { return false; } if (this.yOffset != that.yOffset) { return false; } if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.wallPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.wallPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java0000644000175000017500000011437711173030414033133 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * BoxAndWhiskerRenderer.java * -------------------------- * (C) Copyright 2003-2009, by David Browning and Contributors. * * Original Author: David Browning (for the Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * Tim Bardzil; * Rob Van der Sanden (patches 1866446 and 1888422); * * Changes * ------- * 21-Aug-2003 : Version 1, contributed by David Browning (for the Australian * Institute of Marine Science); * 01-Sep-2003 : Incorporated outlier and farout symbols for low values * also (DG); * 08-Sep-2003 : Changed ValueAxis API (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 12-Nov-2003 : Fixed casting bug reported by Tim Bardzil (DG); * 13-Nov-2003 : Added drawHorizontalItem() method contributed by Tim * Bardzil (DG); * 25-Apr-2004 : Added fillBox attribute, equals() method and added * serialization code (DG); * 29-Apr-2004 : Changed drawing of upper and lower shadows - see bug report * 944011 (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 09-Mar-2005 : Override getLegendItem() method so that legend item shapes * are shown as blocks (DG); * 20-Apr-2005 : Generate legend labels, tooltips and URLs (DG); * 09-Jun-2005 : Updated equals() to handle GradientPaint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 12-Oct-2006 : Source reformatting and API doc updates (DG); * 12-Oct-2006 : Fixed bug 1572478, potential NullPointerException (DG); * 05-Feb-2006 : Added event notifications to a couple of methods (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 11-May-2007 : Added check for visibility in getLegendItem() (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 03-Jan-2008 : Check visibility of average marker before drawing it (DG); * 15-Jan-2008 : Add getMaximumBarWidth() and setMaximumBarWidth() * methods (RVdS); * 14-Feb-2008 : Fix bar position for horizontal chart, see patch * 1888422 (RVdS); * 27-Mar-2008 : Boxes should use outlinePaint/Stroke settings (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 02-Oct-2008 : Check item visibility in drawItem() method (DG); * 21-Jan-2009 : Added flags to control visibility of mean and median * indicators (DG); */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.renderer.Outlier; import org.jfree.chart.renderer.OutlierList; import org.jfree.chart.renderer.OutlierListCollection; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A box-and-whisker renderer. This renderer requires a * {@link BoxAndWhiskerCategoryDataset} and is for use with the * {@link CategoryPlot} class. The example shown here is generated * by the BoxAndWhiskerChartDemo1.java program included in the * JFreeChart Demo Collection: *

* BoxAndWhiskerRendererSample.png */ public class BoxAndWhiskerRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 632027470694481177L; /** The color used to paint the median line and average marker. */ private transient Paint artifactPaint; /** A flag that controls whether or not the box is filled. */ private boolean fillBox; /** The margin between items (boxes) within a category. */ private double itemMargin; /** * The maximum bar width as percentage of the available space in the plot, * where 0.05 is five percent. */ private double maximumBarWidth; /** * A flag that controls whether or not the median indicator is drawn. * * @since 1.0.13 */ private boolean medianVisible; /** * A flag that controls whether or not the mean indicator is drawn. * * @since 1.0.13 */ private boolean meanVisible; /** * Default constructor. */ public BoxAndWhiskerRenderer() { this.artifactPaint = Color.black; this.fillBox = true; this.itemMargin = 0.20; this.maximumBarWidth = 1.0; this.medianVisible = true; this.meanVisible = true; setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); } /** * Returns the paint used to color the median and average markers. * * @return The paint used to draw the median and average markers (never * null). * * @see #setArtifactPaint(Paint) */ public Paint getArtifactPaint() { return this.artifactPaint; } /** * Sets the paint used to color the median and average markers and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getArtifactPaint() */ public void setArtifactPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.artifactPaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether or not the box is filled. * * @return A boolean. * * @see #setFillBox(boolean) */ public boolean getFillBox() { return this.fillBox; } /** * Sets the flag that controls whether or not the box is filled and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getFillBox() */ public void setFillBox(boolean flag) { this.fillBox = flag; fireChangeEvent(); } /** * Returns the item margin. This is a percentage of the available space * that is allocated to the space between items in the chart. * * @return The margin. * * @see #setItemMargin(double) */ public double getItemMargin() { return this.itemMargin; } /** * Sets the item margin and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param margin the margin (a percentage). * * @see #getItemMargin() */ public void setItemMargin(double margin) { this.itemMargin = margin; fireChangeEvent(); } /** * Returns the maximum bar width as a percentage of the available drawing * space. * * @return The maximum bar width. * * @see #setMaximumBarWidth(double) * * @since 1.0.10 */ public double getMaximumBarWidth() { return this.maximumBarWidth; } /** * Sets the maximum bar width, which is specified as a percentage of the * available space for all bars, and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param percent the maximum Bar Width (a percentage). * * @see #getMaximumBarWidth() * * @since 1.0.10 */ public void setMaximumBarWidth(double percent) { this.maximumBarWidth = percent; fireChangeEvent(); } /** * Returns the flag that controls whether or not the mean indicator is * draw for each item. * * @return A boolean. * * @see #setMeanVisible(boolean) * * @since 1.0.13 */ public boolean isMeanVisible() { return this.meanVisible; } /** * Sets the flag that controls whether or not the mean indicator is drawn * for each item, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param visible the new flag value. * * @see #isMeanVisible() * * @since 1.0.13 */ public void setMeanVisible(boolean visible) { if (this.meanVisible == visible) { return; } this.meanVisible = visible; fireChangeEvent(); } /** * Returns the flag that controls whether or not the median indicator is * draw for each item. * * @return A boolean. * * @see #setMedianVisible(boolean) * * @since 1.0.13 */ public boolean isMedianVisible() { return this.medianVisible; } /** * Sets the flag that controls whether or not the median indicator is drawn * for each item, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param visible the new flag value. * * @see #isMedianVisible() * * @since 1.0.13 */ public void setMedianVisible(boolean visible) { this.medianVisible = visible; } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly null). */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } /** * Returns the range of values from the specified dataset that the * renderer will require to display all the data. * * @param dataset the dataset. * * @return The range. */ public Range findRangeBounds(CategoryDataset dataset) { return super.findRangeBounds(dataset, true); } /** * Initialises the renderer. This method gets called once at the start of * the process of drawing a chart. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info); // calculate the box width CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (dataset.getColumnCount() * dataset.getRowCount()), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } return state; } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data (must be an instance of * {@link BoxAndWhiskerCategoryDataset}). * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // do nothing if item is not visible if (!getItemVisible(row, column)) { return; } if (!(dataset instanceof BoxAndWhiskerCategoryDataset)) { throw new IllegalArgumentException( "BoxAndWhiskerRenderer.drawItem() : the data should be " + "of type BoxAndWhiskerCategoryDataset only."); } PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { drawHorizontalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column); } else if (orientation == PlotOrientation.VERTICAL) { drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column); } } /** * Draws the visual representation of a single data item when the plot has * a horizontal orientation. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (must be an instance of * {@link BoxAndWhiskerCategoryDataset}). * @param row the row index (zero-based). * @param column the column index (zero-based). */ public void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset; double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double categoryWidth = Math.abs(categoryEnd - categoryStart); double yy = categoryStart; int seriesCount = getRowCount(); int categoryCount = getColumnCount(); if (seriesCount > 1) { double seriesGap = dataArea.getHeight() * getItemMargin() / (categoryCount * (seriesCount - 1)); double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1)); // offset the start of the boxes if the total width used is smaller // than the category width double offset = (categoryWidth - usedWidth) / 2; yy = yy + offset + (row * (state.getBarWidth() + seriesGap)); } else { // offset the start of the box if the box width is smaller than // the category width double offset = (categoryWidth - state.getBarWidth()) / 2; yy = yy + offset; } g2.setPaint(getItemPaint(row, column)); Stroke s = getItemStroke(row, column); g2.setStroke(s); RectangleEdge location = plot.getRangeAxisEdge(); Number xQ1 = bawDataset.getQ1Value(row, column); Number xQ3 = bawDataset.getQ3Value(row, column); Number xMax = bawDataset.getMaxRegularValue(row, column); Number xMin = bawDataset.getMinRegularValue(row, column); Shape box = null; if (xQ1 != null && xQ3 != null && xMax != null && xMin != null) { double xxQ1 = rangeAxis.valueToJava2D(xQ1.doubleValue(), dataArea, location); double xxQ3 = rangeAxis.valueToJava2D(xQ3.doubleValue(), dataArea, location); double xxMax = rangeAxis.valueToJava2D(xMax.doubleValue(), dataArea, location); double xxMin = rangeAxis.valueToJava2D(xMin.doubleValue(), dataArea, location); double yymid = yy + state.getBarWidth() / 2.0; // draw the upper shadow... g2.draw(new Line2D.Double(xxMax, yymid, xxQ3, yymid)); g2.draw(new Line2D.Double(xxMax, yy, xxMax, yy + state.getBarWidth())); // draw the lower shadow... g2.draw(new Line2D.Double(xxMin, yymid, xxQ1, yymid)); g2.draw(new Line2D.Double(xxMin, yy, xxMin, yy + state.getBarWidth())); // draw the box... box = new Rectangle2D.Double(Math.min(xxQ1, xxQ3), yy, Math.abs(xxQ1 - xxQ3), state.getBarWidth()); if (this.fillBox) { g2.fill(box); } g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(box); } // draw mean - SPECIAL AIMS REQUIREMENT... g2.setPaint(this.artifactPaint); double aRadius = 0; // average radius if (this.meanVisible) { Number xMean = bawDataset.getMeanValue(row, column); if (xMean != null) { double xxMean = rangeAxis.valueToJava2D(xMean.doubleValue(), dataArea, location); aRadius = state.getBarWidth() / 4; // here we check that the average marker will in fact be // visible before drawing it... if ((xxMean > (dataArea.getMinX() - aRadius)) && (xxMean < (dataArea.getMaxX() + aRadius))) { Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxMean - aRadius, yy + aRadius, aRadius * 2, aRadius * 2); g2.fill(avgEllipse); g2.draw(avgEllipse); } } } // draw median... if (this.medianVisible) { Number xMedian = bawDataset.getMedianValue(row, column); if (xMedian != null) { double xxMedian = rangeAxis.valueToJava2D(xMedian.doubleValue(), dataArea, location); g2.draw(new Line2D.Double(xxMedian, yy, xxMedian, yy + state.getBarWidth())); } } // collect entity and tool tip information... if (state.getInfo() != null && box != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, box); } } } /** * Draws the visual representation of a single data item when the plot has * a vertical orientation. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (must be an instance of * {@link BoxAndWhiskerCategoryDataset}). * @param row the row index (zero-based). * @param column the column index (zero-based). */ public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset; double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double categoryWidth = categoryEnd - categoryStart; double xx = categoryStart; int seriesCount = getRowCount(); int categoryCount = getColumnCount(); if (seriesCount > 1) { double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1)); double usedWidth = (state.getBarWidth() * seriesCount) + (seriesGap * (seriesCount - 1)); // offset the start of the boxes if the total width used is smaller // than the category width double offset = (categoryWidth - usedWidth) / 2; xx = xx + offset + (row * (state.getBarWidth() + seriesGap)); } else { // offset the start of the box if the box width is smaller than the // category width double offset = (categoryWidth - state.getBarWidth()) / 2; xx = xx + offset; } double yyAverage = 0.0; double yyOutlier; Paint itemPaint = getItemPaint(row, column); g2.setPaint(itemPaint); Stroke s = getItemStroke(row, column); g2.setStroke(s); double aRadius = 0; // average radius RectangleEdge location = plot.getRangeAxisEdge(); Number yQ1 = bawDataset.getQ1Value(row, column); Number yQ3 = bawDataset.getQ3Value(row, column); Number yMax = bawDataset.getMaxRegularValue(row, column); Number yMin = bawDataset.getMinRegularValue(row, column); Shape box = null; if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) { double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, location); double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, location); double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location); double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location); double xxmid = xx + state.getBarWidth() / 2.0; // draw the upper shadow... g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3)); g2.draw(new Line2D.Double(xx, yyMax, xx + state.getBarWidth(), yyMax)); // draw the lower shadow... g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1)); g2.draw(new Line2D.Double(xx, yyMin, xx + state.getBarWidth(), yyMin)); // draw the body... box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), state.getBarWidth(), Math.abs(yyQ1 - yyQ3)); if (this.fillBox) { g2.fill(box); } g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(box); } g2.setPaint(this.artifactPaint); // draw mean - SPECIAL AIMS REQUIREMENT... if (this.meanVisible) { Number yMean = bawDataset.getMeanValue(row, column); if (yMean != null) { yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location); aRadius = state.getBarWidth() / 4; // here we check that the average marker will in fact be // visible before drawing it... if ((yyAverage > (dataArea.getMinY() - aRadius)) && (yyAverage < (dataArea.getMaxY() + aRadius))) { Ellipse2D.Double avgEllipse = new Ellipse2D.Double( xx + aRadius, yyAverage - aRadius, aRadius * 2, aRadius * 2); g2.fill(avgEllipse); g2.draw(avgEllipse); } } } // draw median... if (this.medianVisible) { Number yMedian = bawDataset.getMedianValue(row, column); if (yMedian != null) { double yyMedian = rangeAxis.valueToJava2D( yMedian.doubleValue(), dataArea, location); g2.draw(new Line2D.Double(xx, yyMedian, xx + state.getBarWidth(), yyMedian)); } } // draw yOutliers... double maxAxisValue = rangeAxis.valueToJava2D( rangeAxis.getUpperBound(), dataArea, location) + aRadius; double minAxisValue = rangeAxis.valueToJava2D( rangeAxis.getLowerBound(), dataArea, location) - aRadius; g2.setPaint(itemPaint); // draw outliers double oRadius = state.getBarWidth() / 3; // outlier radius List outliers = new ArrayList(); OutlierListCollection outlierListCollection = new OutlierListCollection(); // From outlier array sort out which are outliers and put these into a // list If there are any farouts, set the flag on the // OutlierListCollection List yOutliers = bawDataset.getOutliers(row, column); if (yOutliers != null) { for (int i = 0; i < yOutliers.size(); i++) { double outlier = ((Number) yOutliers.get(i)).doubleValue(); Number minOutlier = bawDataset.getMinOutlier(row, column); Number maxOutlier = bawDataset.getMaxOutlier(row, column); Number minRegular = bawDataset.getMinRegularValue(row, column); Number maxRegular = bawDataset.getMaxRegularValue(row, column); if (outlier > maxOutlier.doubleValue()) { outlierListCollection.setHighFarOut(true); } else if (outlier < minOutlier.doubleValue()) { outlierListCollection.setLowFarOut(true); } else if (outlier > maxRegular.doubleValue()) { yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location); outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius)); } else if (outlier < minRegular.doubleValue()) { yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location); outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, yyOutlier, oRadius)); } Collections.sort(outliers); } // Process outliers. Each outlier is either added to the // appropriate outlier list or a new outlier list is made for (Iterator iterator = outliers.iterator(); iterator.hasNext();) { Outlier outlier = (Outlier) iterator.next(); outlierListCollection.add(outlier); } for (Iterator iterator = outlierListCollection.iterator(); iterator.hasNext();) { OutlierList list = (OutlierList) iterator.next(); Outlier outlier = list.getAveragedOutlier(); Point2D point = outlier.getPoint(); if (list.isMultiple()) { drawMultipleEllipse(point, state.getBarWidth(), oRadius, g2); } else { drawEllipse(point, oRadius, g2); } } // draw farout indicators if (outlierListCollection.isHighFarOut()) { drawHighFarOut(aRadius / 2.0, g2, xx + state.getBarWidth() / 2.0, maxAxisValue); } if (outlierListCollection.isLowFarOut()) { drawLowFarOut(aRadius / 2.0, g2, xx + state.getBarWidth() / 2.0, minAxisValue); } } // collect entity and tool tip information... if (state.getInfo() != null && box != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, box); } } } /** * Draws a dot to represent an outlier. * * @param point the location. * @param oRadius the radius. * @param g2 the graphics device. */ private void drawEllipse(Point2D point, double oRadius, Graphics2D g2) { Ellipse2D dot = new Ellipse2D.Double(point.getX() + oRadius / 2, point.getY(), oRadius, oRadius); g2.draw(dot); } /** * Draws two dots to represent the average value of more than one outlier. * * @param point the location * @param boxWidth the box width. * @param oRadius the radius. * @param g2 the graphics device. */ private void drawMultipleEllipse(Point2D point, double boxWidth, double oRadius, Graphics2D g2) { Ellipse2D dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius); Ellipse2D dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), point.getY(), oRadius, oRadius); g2.draw(dot1); g2.draw(dot2); } /** * Draws a triangle to indicate the presence of far-out values. * * @param aRadius the radius. * @param g2 the graphics device. * @param xx the x coordinate. * @param m the y coordinate. */ private void drawHighFarOut(double aRadius, Graphics2D g2, double xx, double m) { double side = aRadius * 2; g2.draw(new Line2D.Double(xx - side, m + side, xx + side, m + side)); g2.draw(new Line2D.Double(xx - side, m + side, xx, m)); g2.draw(new Line2D.Double(xx + side, m + side, xx, m)); } /** * Draws a triangle to indicate the presence of far-out values. * * @param aRadius the radius. * @param g2 the graphics device. * @param xx the x coordinate. * @param m the y coordinate. */ private void drawLowFarOut(double aRadius, Graphics2D g2, double xx, double m) { double side = aRadius * 2; g2.draw(new Line2D.Double(xx - side, m - side, xx + side, m - side)); g2.draw(new Line2D.Double(xx - side, m - side, xx, m)); g2.draw(new Line2D.Double(xx + side, m - side, xx, m)); } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BoxAndWhiskerRenderer)) { return false; } BoxAndWhiskerRenderer that = (BoxAndWhiskerRenderer) obj; if (this.fillBox != that.fillBox) { return false; } if (this.itemMargin != that.itemMargin) { return false; } if (this.maximumBarWidth != that.maximumBarWidth) { return false; } if (this.meanVisible != that.meanVisible) { return false; } if (this.medianVisible != that.medianVisible) { return false; } if (!PaintUtilities.equal(this.artifactPaint, that.artifactPaint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.artifactPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.artifactPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/CategoryItemRenderer.java0000644000175000017500000020444711173030414033015 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CategoryItemRenderer.java * ------------------------- * * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Mark Watson (www.markwatson.com); * * Changes * ------- * 23-Oct-2001 : Version 1 (DG); * 16-Jan-2002 : Renamed HorizontalCategoryItemRenderer.java * --> CategoryItemRenderer.java (DG); * 05-Feb-2002 : Changed return type of the drawCategoryItem method from void * to Shape, as part of the tooltips implementation (DG) * * NOTE (30-May-2002) : this has subsequently been changed back * to void, tooltips are now collected along with entities in * ChartRenderingInfo (DG); * * 14-Mar-2002 : Added the initialise method, and changed all bar plots to use * this renderer (DG); * 23-May-2002 : Added ChartRenderingInfo to the initialise method (DG); * 29-May-2002 : Added the getAxisArea(Rectangle2D) method (DG); * 06-Jun-2002 : Updated Javadoc comments (DG); * 26-Jun-2002 : Added range axis to the initialise method (DG); * 24-Sep-2002 : Added getLegendItem() method (DG); * 23-Oct-2002 : Added methods to get/setToolTipGenerator (DG); * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); * 06-Nov-2002 : Added the domain axis to the drawCategoryItem method. Renamed * drawCategoryItem() --> drawItem() (DG); * 20-Nov-2002 : Changed signature of drawItem() method to reflect use of * TableDataset (DG); * 26-Nov-2002 : Replaced the isStacked() method with the getRangeType() * method (DG); * 08-Jan-2003 : Changed getSeriesCount() --> getRowCount() and * getCategoryCount() --> getColumnCount() (DG); * 09-Jan-2003 : Changed name of grid-line methods (DG); * 21-Jan-2003 : Merged TableDataset with CategoryDataset (DG); * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in * drawItem() method (DG); * 29-Apr-2003 : Eliminated Renderer interface (DG); * 02-Sep-2003 : Fix for bug 790407 (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 20-Oct-2003 : Added setOutlinePaint() method (DG); * 06-Feb-2004 : Added missing methods, and moved deprecated methods (DG); * 19-Feb-2004 : Added extra setXXXLabelsVisible() methods (DG); * 29-Apr-2004 : Changed Integer --> int in initialise() method (DG); * 18-May-2004 : Added methods for item label paint (DG); * 05-Nov-2004 : Added getPassCount() method and 'pass' parameter to drawItem() * method (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 23-Feb-2005 : Now extends LegendItemSource (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 20-May-2005 : Added drawDomainMarker() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Feb-2007 : Updated API docs (DG); * 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG); * 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke, * outlineStroke, shape, itemLabelsVisible, itemLabelFont, * itemLabelPaint, positiveItemLabelPosition, * negativeItemLabelPosition and createEntities override * fields (DG); * 26-Jun-2008 : Added new method required for crosshair support - THIS CHANGES * THE API as of version 1.0.11 (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemSource; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.CategoryMarker; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.ui.RectangleEdge; /** * A plug-in object that is used by the {@link CategoryPlot} class to display * individual data items from a {@link CategoryDataset}. *

* This interface defines the methods that must be provided by all renderers. * If you are implementing a custom renderer, you should consider extending the * {@link AbstractCategoryItemRenderer} class. *

* Most renderer attributes are defined using a "three layer" approach. When * looking up an attribute (for example, the outline paint) the renderer first * checks to see if there is a setting (in layer 0) that applies to ALL items * that the renderer draws. If there is, that setting is used, but if it is * null the renderer looks up the next layer, which contains * "per series" settings for the attribute (many attributes are defined on a * per series basis, so this is the layer that is most commonly used). If the * layer 1 setting is null, the renderer will look up the final * layer, which provides a default or "base" setting. Some attributes allow * the base setting to be null, while other attributes enforce * non-null values. */ public interface CategoryItemRenderer extends LegendItemSource { /** * Returns the number of passes through the dataset required by the * renderer. Usually this will be one, but some renderers may use * a second or third pass to overlay items on top of things that were * drawn in an earlier pass. * * @return The pass count. */ public int getPassCount(); /** * Returns the plot that the renderer has been assigned to (where * null indicates that the renderer is not currently assigned * to a plot). * * @return The plot (possibly null). * * @see #setPlot(CategoryPlot) */ public CategoryPlot getPlot(); /** * Sets the plot that the renderer has been assigned to. This method is * usually called by the {@link CategoryPlot}, in normal usage you * shouldn't need to call this method directly. * * @param plot the plot (null not permitted). * * @see #getPlot() */ public void setPlot(CategoryPlot plot); /** * Adds a change listener. * * @param listener the listener. * * @see #removeChangeListener(RendererChangeListener) */ public void addChangeListener(RendererChangeListener listener); /** * Removes a change listener. * * @param listener the listener. * * @see #addChangeListener(RendererChangeListener) */ public void removeChangeListener(RendererChangeListener listener); /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(CategoryDataset dataset); /** * Initialises the renderer. This method will be called before the first * item is rendered, giving the renderer an opportunity to initialise any * state information it wants to maintain. The renderer can do nothing if * it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return A state object (maintains state information relevant to one * chart drawing). */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info); /** * Returns a boolean that indicates whether or not the specified item * should be drawn (this is typically used to hide an entire series). * * @param series the series index. * @param item the item index. * * @return A boolean. */ public boolean getItemVisible(int series, int item); /** * Returns a boolean that indicates whether or not the specified series * should be drawn (this is typically used to hide an entire series). * * @param series the series index. * * @return A boolean. */ public boolean isSeriesVisible(int series); /** * Returns the flag that controls the visibility of ALL series. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @return The flag (possibly null). * * @see #setSeriesVisible(Boolean) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesVisible(int)} and * {@link #getBaseSeriesVisible()}. */ public Boolean getSeriesVisible(); /** * Sets the flag that controls the visibility of ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @param visible the flag (null permitted). * * @see #getSeriesVisible() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} * and {@link #setBaseSeriesVisible(boolean)}. */ public void setSeriesVisible(Boolean visible); /** * Sets the flag that controls the visibility of ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisible() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean, * boolean)} and {@link #setBaseSeriesVisible(boolean, boolean)}. */ public void setSeriesVisible(Boolean visible, boolean notify); /** * Returns the flag that controls whether a series is visible. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesVisible(int, Boolean) */ public Boolean getSeriesVisible(int series); /** * Sets the flag that controls whether a series is visible and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #getSeriesVisible(int) */ public void setSeriesVisible(int series, Boolean visible); /** * Sets the flag that controls whether a series is visible and, if * requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisible(int) */ public void setSeriesVisible(int series, Boolean visible, boolean notify); /** * Returns the base visibility for all series. * * @return The base visibility. * * @see #setBaseSeriesVisible(boolean) */ public boolean getBaseSeriesVisible(); /** * Sets the base visibility and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param visible the flag. * * @see #getBaseSeriesVisible() */ public void setBaseSeriesVisible(boolean visible); /** * Sets the base visibility and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility. * @param notify notify listeners? * * @see #getBaseSeriesVisible() */ public void setBaseSeriesVisible(boolean visible, boolean notify); // SERIES VISIBLE IN LEGEND (not yet respected by all renderers) /** * Returns true if the series should be shown in the legend, * and false otherwise. * * @param series the series index. * * @return A boolean. */ public boolean isSeriesVisibleInLegend(int series); /** * Returns the flag that controls the visibility of ALL series in the * legend. This flag overrides the per series and default settings - you * must set it to null if you want the other settings to * apply. * * @return The flag (possibly null). * * @see #setSeriesVisibleInLegend(Boolean) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesVisibleInLegend(int)} * and {@link #getBaseSeriesVisibleInLegend()}. */ public Boolean getSeriesVisibleInLegend(); /** * Sets the flag that controls the visibility of ALL series in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * This flag overrides the per series and default settings - you must set * it to null if you want the other settings to apply. * * @param visible the flag (null permitted). * * @see #getSeriesVisibleInLegend() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, * Boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean)}. */ public void setSeriesVisibleInLegend(Boolean visible); /** * Sets the flag that controls the visibility of ALL series in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * This flag overrides the per series and default settings - you must set * it to null if you want the other settings to apply. * * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisibleInLegend() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, * Boolean, boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean, * boolean)}. */ public void setSeriesVisibleInLegend(Boolean visible, boolean notify); /** * Returns the flag that controls whether a series is visible in the * legend. This method returns only the "per series" settings - to * incorporate the override and base settings as well, you need to use the * {@link #isSeriesVisibleInLegend(int)} method. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesVisibleInLegend(int, Boolean) */ public Boolean getSeriesVisibleInLegend(int series); /** * Sets the flag that controls whether a series is visible in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #getSeriesVisibleInLegend(int) */ public void setSeriesVisibleInLegend(int series, Boolean visible); /** * Sets the flag that controls whether a series is visible in the legend * and, if requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisibleInLegend(int) */ public void setSeriesVisibleInLegend(int series, Boolean visible, boolean notify); /** * Returns the base visibility in the legend for all series. * * @return The base visibility. * * @see #setBaseSeriesVisibleInLegend(boolean) */ public boolean getBaseSeriesVisibleInLegend(); /** * Sets the base visibility in the legend and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getBaseSeriesVisibleInLegend() */ public void setBaseSeriesVisibleInLegend(boolean visible); /** * Sets the base visibility in the legend and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility. * @param notify notify listeners? * * @see #getBaseSeriesVisibleInLegend() */ public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify); //// PAINT ///////////////////////////////////////////////////////////////// /** * Returns the paint used to fill data items as they are drawn. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemPaint(int row, int column); /** * Sets the paint to be used for ALL series, and sends a * {@link RendererChangeEvent} to all registered listeners. If this is * null, the renderer will use the paint for the series. * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesPaint(int, Paint)} and * {@link #setBasePaint(Paint)}. */ public void setPaint(Paint paint); /** * Returns the paint used to fill an item drawn by the renderer. * * @param series the series index (zero-based). * * @return The paint (possibly null). * * @see #setSeriesPaint(int, Paint) */ public Paint getSeriesPaint(int series); /** * Sets the paint used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesPaint(int) */ public void setSeriesPaint(int series, Paint paint); // FIXME: add setSeriesPaint(int, Paint, boolean)? /** * Returns the base paint. * * @return The base paint (never null). * * @see #setBasePaint(Paint) */ public Paint getBasePaint(); /** * Sets the base paint and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getBasePaint() */ public void setBasePaint(Paint paint); // FIXME: add setBasePaint(int, Paint, boolean)? //// FILL PAINT ///////////////////////////////////////////////////////// // /** // * Returns the paint used to fill data items as they are drawn. // * // * @param row the row (or series) index (zero-based). // * @param column the column (or category) index (zero-based). // * // * @return The paint (never null). // */ // public Paint getItemFillPaint(int row, int column); // // /** // * Returns the paint used to fill an item drawn by the renderer. // * // * @param series the series (zero-based index). // * // * @return The paint (possibly null). // * // * @see #setSeriesFillPaint(int, Paint) // */ // public Paint getSeriesFillPaint(int series); // // /** // * Sets the paint used for a series outline and sends a // * {@link RendererChangeEvent} to all registered listeners. // * // * @param series the series index (zero-based). // * @param paint the paint (null permitted). // * // * @see #getSeriesFillPaint(int) // */ // public void setSeriesFillPaint(int series, Paint paint); // // /** // * Returns the base outline paint. // * // * @return The paint (never null). // * // * @see #setBaseFillPaint(Paint) // */ // public Paint getBaseFillPaint(); // // /** // * Sets the base outline paint and sends a {@link RendererChangeEvent} to // * all registered listeners. // * // * @param paint the paint (null not permitted). // * // * @see #getBaseFillPaint() // */ // public void setBaseFillPaint(Paint paint); //// OUTLINE PAINT ///////////////////////////////////////////////////////// /** * Returns the paint used to outline data items as they are drawn. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemOutlinePaint(int row, int column); /** * Sets the outline paint for ALL series (optional). * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, * Paint)} and {@link #setBaseOutlinePaint(Paint)}. */ public void setOutlinePaint(Paint paint); /** * Returns the paint used to outline an item drawn by the renderer. * * @param series the series (zero-based index). * * @return The paint (possibly null). * * @see #setSeriesOutlinePaint(int, Paint) */ public Paint getSeriesOutlinePaint(int series); /** * Sets the paint used for a series outline and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesOutlinePaint(int) */ public void setSeriesOutlinePaint(int series, Paint paint); // FIXME: add setSeriesOutlinePaint(int, Paint, boolean)? /** * Returns the base outline paint. * * @return The paint (never null). * * @see #setBaseOutlinePaint(Paint) */ public Paint getBaseOutlinePaint(); /** * Sets the base outline paint and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseOutlinePaint() */ public void setBaseOutlinePaint(Paint paint); // FIXME: add setBaseOutlinePaint(Paint, boolean)? //// STROKE //////////////////////////////////////////////////////////////// /** * Returns the stroke used to draw data items. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The stroke (never null). */ public Stroke getItemStroke(int row, int column); /** * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param stroke the stroke (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke)} * and {@link #setBaseStroke(Stroke)}. */ public void setStroke(Stroke stroke); /** * Returns the stroke used to draw the items in a series. * * @param series the series (zero-based index). * * @return The stroke (never null). * * @see #setSeriesStroke(int, Stroke) */ public Stroke getSeriesStroke(int series); /** * Sets the stroke used for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * * @see #getSeriesStroke(int) */ public void setSeriesStroke(int series, Stroke stroke); // FIXME: add setSeriesStroke(int, Stroke, boolean) ? /** * Returns the base stroke. * * @return The base stroke (never null). * * @see #setBaseStroke(Stroke) */ public Stroke getBaseStroke(); /** * Sets the base stroke and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getBaseStroke() */ public void setBaseStroke(Stroke stroke); // FIXME: add setBaseStroke(Stroke, boolean) ? //// OUTLINE STROKE //////////////////////////////////////////////////////// /** * Returns the stroke used to outline data items. *

* The default implementation passes control to the * lookupSeriesOutlineStroke method. You can override this method if you * require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The stroke (never null). */ public Stroke getItemOutlineStroke(int row, int column); /** * Sets the outline stroke for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, * Stroke)} and {@link #setBaseOutlineStroke(Stroke)}. */ public void setOutlineStroke(Stroke stroke); /** * Returns the stroke used to outline the items in a series. * * @param series the series (zero-based index). * * @return The stroke (possibly null). * * @see #setSeriesOutlineStroke(int, Stroke) */ public Stroke getSeriesOutlineStroke(int series); /** * Sets the outline stroke used for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * * @see #getSeriesOutlineStroke(int) */ public void setSeriesOutlineStroke(int series, Stroke stroke); // FIXME: add setSeriesOutlineStroke(int, Stroke, boolean) ? /** * Returns the base outline stroke. * * @return The stroke (never null). * * @see #setBaseOutlineStroke(Stroke) */ public Stroke getBaseOutlineStroke(); /** * Sets the base outline stroke and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getBaseOutlineStroke() */ public void setBaseOutlineStroke(Stroke stroke); // FIXME: add setBaseOutlineStroke(Stroke, boolean) ? //// SHAPE ///////////////////////////////////////////////////////////////// /** * Returns a shape used to represent a data item. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The shape (never null). */ public Shape getItemShape(int row, int column); /** * Sets the shape for ALL series (optional) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesShape(int, Shape)} and * {@link #setBaseShape(Shape)}. */ public void setShape(Shape shape); /** * Returns a shape used to represent the items in a series. * * @param series the series (zero-based index). * * @return The shape (possibly null). * * @see #setSeriesShape(int, Shape) */ public Shape getSeriesShape(int series); /** * Sets the shape used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param shape the shape (null permitted). * * @see #getSeriesShape(int) */ public void setSeriesShape(int series, Shape shape); // FIXME: add setSeriesShape(int, Shape, boolean) ? /** * Returns the base shape. * * @return The shape (never null). * * @see #setBaseShape(Shape) */ public Shape getBaseShape(); /** * Sets the base shape and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param shape the shape (null not permitted). * * @see #getBaseShape() */ public void setBaseShape(Shape shape); // FIXME: add setBaseShape(Shape, boolean) ? // ITEM LABELS VISIBLE /** * Returns true if an item label is visible, and * false otherwise. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return A boolean. */ public boolean isItemLabelVisible(int row, int column); /** * Sets a flag that controls whether or not the item labels for ALL series * are visible. * * @param visible the flag. * * @see #setItemLabelsVisible(Boolean) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. */ public void setItemLabelsVisible(boolean visible); /** * Sets a flag that controls whether or not the item labels for ALL series * are visible. * * @param visible the flag (null permitted). * * @see #setItemLabelsVisible(boolean) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. */ public void setItemLabelsVisible(Boolean visible); /** * Sets the visibility of item labels for ALL series and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param visible a flag that controls whether or not the item labels are * visible (null permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean, boolean)} and {@link #setBaseItemLabelsVisible(Boolean, * boolean)}. */ public void setItemLabelsVisible(Boolean visible, boolean notify); /** * Returns true if the item labels for a series are visible, * and false otherwise. * * @param series the series index (zero-based). * * @return A boolean. * * @see #setSeriesItemLabelsVisible(int, Boolean) */ public boolean isSeriesItemLabelsVisible(int series); /** * Sets a flag that controls the visibility of the item labels for a series. * * @param series the series index (zero-based). * @param visible the flag. * * @see #isSeriesItemLabelsVisible(int) */ public void setSeriesItemLabelsVisible(int series, boolean visible); /** * Sets a flag that controls the visibility of the item labels for a series. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #isSeriesItemLabelsVisible(int) */ public void setSeriesItemLabelsVisible(int series, Boolean visible); /** * Sets the visibility of item labels for a series and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the visible flag. * @param notify a flag that controls whether or not listeners are * notified. * * @see #isSeriesItemLabelsVisible(int) */ public void setSeriesItemLabelsVisible(int series, Boolean visible, boolean notify); /** * Returns the base setting for item label visibility. A null * result should be interpreted as equivalent to Boolean.FALSE * (this is an error in the API design, the return value should have been * a boolean primitive). * * @return A flag (possibly null). * * @see #setBaseItemLabelsVisible(Boolean) */ public Boolean getBaseItemLabelsVisible(); /** * Sets the base flag that controls whether or not item labels are visible * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(boolean visible); /** * Sets the base setting for item label visibility and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag (null permitted). * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(Boolean visible); /** * Sets the base visibility for item labels and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility flag. * @param notify a flag that controls whether or not listeners are * notified. * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(Boolean visible, boolean notify); // ITEM LABEL GENERATOR /** * Returns the item label generator for the specified data item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The generator (possibly null). */ public CategoryItemLabelGenerator getItemLabelGenerator(int series, int item); /** * Sets the item label generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This overrides * the per-series settings. * * @param generator the generator (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelGenerator(int, * CategoryItemLabelGenerator)} and * {@link #setBaseItemLabelGenerator(CategoryItemLabelGenerator)}. */ public void setItemLabelGenerator(CategoryItemLabelGenerator generator); /** * Returns the item label generator for a series. * * @param series the series index (zero-based). * * @return The label generator (possibly null). * * @see #setSeriesItemLabelGenerator(int, CategoryItemLabelGenerator) */ public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series); /** * Sets the item label generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param generator the generator. * * @see #getSeriesItemLabelGenerator(int) */ public void setSeriesItemLabelGenerator(int series, CategoryItemLabelGenerator generator); // FIXME: add setSeriesItemLabelGenerator(int, CategoryItemLabelGenerator, // boolean) /** * Returns the base item label generator. * * @return The generator (possibly null). * * @see #setBaseItemLabelGenerator(CategoryItemLabelGenerator) */ public CategoryItemLabelGenerator getBaseItemLabelGenerator(); /** * Sets the base item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getBaseItemLabelGenerator() */ public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator); // FIXME: add setBaseItemLabelGenerator(CategoryItemLabelGenerator, // boolean) ? // TOOL TIP GENERATOR /** * Returns the tool tip generator that should be used for the specified * item. This method looks up the generator using the "three-layer" * approach outlined in the general description of this interface. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The generator (possibly null). */ public CategoryToolTipGenerator getToolTipGenerator(int row, int column); /** * Returns the tool tip generator that will be used for ALL items in the * dataset (the "layer 0" generator). * * @return A tool tip generator (possibly null). * * @see #setToolTipGenerator(CategoryToolTipGenerator) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesToolTipGenerator(int)} * and {@link #getBaseToolTipGenerator()}. */ public CategoryToolTipGenerator getToolTipGenerator(); /** * Sets the tool tip generator for ALL series and sends a * {@link org.jfree.chart.event.RendererChangeEvent} to all registered * listeners. * * @param generator the generator (null permitted). * * @see #getToolTipGenerator() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesToolTipGenerator(int, * CategoryToolTipGenerator)} and * {@link #setBaseToolTipGenerator(CategoryToolTipGenerator)}. */ public void setToolTipGenerator(CategoryToolTipGenerator generator); /** * Returns the tool tip generator for the specified series (a "layer 1" * generator). * * @param series the series index (zero-based). * * @return The tool tip generator (possibly null). * * @see #setSeriesToolTipGenerator(int, CategoryToolTipGenerator) */ public CategoryToolTipGenerator getSeriesToolTipGenerator(int series); /** * Sets the tool tip generator for a series and sends a * {@link org.jfree.chart.event.RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param generator the generator (null permitted). * * @see #getSeriesToolTipGenerator(int) */ public void setSeriesToolTipGenerator(int series, CategoryToolTipGenerator generator); // FIXME: add setSeriesToolTipGenerator(int, CategoryToolTipGenerator, // boolean) ? /** * Returns the base tool tip generator (the "layer 2" generator). * * @return The tool tip generator (possibly null). * * @see #setBaseToolTipGenerator(CategoryToolTipGenerator) */ public CategoryToolTipGenerator getBaseToolTipGenerator(); /** * Sets the base tool tip generator and sends a * {@link org.jfree.chart.event.RendererChangeEvent} to all registered * listeners. * * @param generator the generator (null permitted). * * @see #getBaseToolTipGenerator() */ public void setBaseToolTipGenerator(CategoryToolTipGenerator generator); // FIXME: add setBaseToolTipGenerator(CategoryToolTipGenerator, boolean) ? //// ITEM LABEL FONT ////////////////////////////////////////////////////// /** * Returns the font for an item label. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The font (never null). */ public Font getItemLabelFont(int row, int column); /** * Returns the font used for all item labels. This may be * null, in which case the per series font settings will apply. * * @return The font (possibly null). * * @see #setItemLabelFont(Font) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesItemLabelFont(int)} and * {@link #getBaseItemLabelFont()}. */ public Font getItemLabelFont(); /** * Sets the item label font for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. You can set * this to null if you prefer to set the font on a per series * basis. * * @param font the font (null permitted). * * @see #getItemLabelFont() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, * Font)} and {@link #setBaseItemLabelFont(Font)}. */ public void setItemLabelFont(Font font); /** * Returns the font for all the item labels in a series. * * @param series the series index (zero-based). * * @return The font (possibly null). * * @see #setSeriesItemLabelFont(int, Font) */ public Font getSeriesItemLabelFont(int series); /** * Sets the item label font for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param font the font (null permitted). * * @see #getSeriesItemLabelFont(int) */ public void setSeriesItemLabelFont(int series, Font font); // FIXME: add setSeriesItemLabelFont(int, Font, boolean) ? /** * Returns the base item label font (this is used when no other font * setting is available). * * @return The font (never null). * * @see #setBaseItemLabelFont(Font) */ public Font getBaseItemLabelFont(); /** * Sets the base item label font and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param font the font (null not permitted). * * @see #getBaseItemLabelFont() */ public void setBaseItemLabelFont(Font font); // FIXME: add setBaseItemLabelFont(Font, boolean) ? //// ITEM LABEL PAINT ///////////////////////////////////////////////////// /** * Returns the paint used to draw an item label. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The paint (never null). */ public Paint getItemLabelPaint(int row, int column); /** * Returns the paint used for all item labels. This may be * null, in which case the per series paint settings will * apply. * * @return The paint (possibly null). * * @see #setItemLabelPaint(Paint) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesItemLabelPaint(int)} * and {@link #getBaseItemLabelPaint()}. */ public Paint getItemLabelPaint(); /** * Sets the item label paint for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getItemLabelPaint() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, * Paint)} and {@link #setBaseItemLabelPaint(Paint)}. */ public void setItemLabelPaint(Paint paint); /** * Returns the paint used to draw the item labels for a series. * * @param series the series index (zero based). * * @return The paint (possibly null). * * @see #setSeriesItemLabelPaint(int, Paint) */ public Paint getSeriesItemLabelPaint(int series); /** * Sets the item label paint for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series (zero based index). * @param paint the paint (null permitted). * * @see #getSeriesItemLabelPaint(int) */ public void setSeriesItemLabelPaint(int series, Paint paint); // FIXME: add setSeriesItemLabelPaint(int, Paint, boolean) ? /** * Returns the base item label paint. * * @return The paint (never null). * * @see #setBaseItemLabelPaint(Paint) */ public Paint getBaseItemLabelPaint(); /** * Sets the base item label paint and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseItemLabelPaint() */ public void setBaseItemLabelPaint(Paint paint); // FIXME: add setBaseItemLabelPaint(Paint, boolean) ? // POSITIVE ITEM LABEL POSITION... /** * Returns the item label position for positive values. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The item label position (never null). */ public ItemLabelPosition getPositiveItemLabelPosition(int row, int column); /** * Returns the item label position for positive values in ALL series. * * @return The item label position (possibly null). * * @see #setPositiveItemLabelPosition(ItemLabelPosition) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #getSeriesPositiveItemLabelPosition(int)} * and {@link #getBasePositiveItemLabelPosition()}. */ public ItemLabelPosition getPositiveItemLabelPosition(); /** * Sets the item label position for positive values in ALL series, and * sends a {@link RendererChangeEvent} to all registered listeners. You * need to set this to null to expose the settings for * individual series. * * @param position the position (null permitted). * * @see #getPositiveItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition)} * and {@link #setBasePositiveItemLabelPosition(ItemLabelPosition)}. */ public void setPositiveItemLabelPosition(ItemLabelPosition position); /** * Sets the positive item label position for ALL series and (if requested) * sends a {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getPositiveItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, * boolean)} and {@link #setBasePositiveItemLabelPosition( * ItemLabelPosition, boolean)}. */ public void setPositiveItemLabelPosition(ItemLabelPosition position, boolean notify); /** * Returns the item label position for all positive values in a series. * * @param series the series index (zero-based). * * @return The item label position. * * @see #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition) */ public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series); /** * Sets the item label position for all positive values in a series and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * * @see #getSeriesPositiveItemLabelPosition(int) */ public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position); /** * Sets the item label position for all positive values in a series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getSeriesPositiveItemLabelPosition(int) */ public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position, boolean notify); /** * Returns the base positive item label position. * * @return The position. * * @see #setBasePositiveItemLabelPosition(ItemLabelPosition) */ public ItemLabelPosition getBasePositiveItemLabelPosition(); /** * Sets the base positive item label position. * * @param position the position. * * @see #getBasePositiveItemLabelPosition() */ public void setBasePositiveItemLabelPosition(ItemLabelPosition position); /** * Sets the base positive item label position and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position. * @param notify notify registered listeners? * * @see #getBasePositiveItemLabelPosition() */ public void setBasePositiveItemLabelPosition(ItemLabelPosition position, boolean notify); // NEGATIVE ITEM LABEL POSITION... /** * Returns the item label position for negative values. This method can be * overridden to provide customisation of the item label position for * individual data items. * * @param row the row index (zero-based). * @param column the column (zero-based). * * @return The item label position. */ public ItemLabelPosition getNegativeItemLabelPosition(int row, int column); /** * Returns the item label position for negative values in ALL series. * * @return The item label position (possibly null). * * @see #setNegativeItemLabelPosition(ItemLabelPosition) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #getSeriesNegativeItemLabelPosition(int)} * and {@link #getBaseNegativeItemLabelPosition()}. */ public ItemLabelPosition getNegativeItemLabelPosition(); /** * Sets the item label position for negative values in ALL series, and * sends a {@link RendererChangeEvent} to all registered listeners. You * need to set this to null to expose the settings for * individual series. * * @param position the position (null permitted). * * @see #getNegativeItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition)} * and {@link #setBaseNegativeItemLabelPosition(ItemLabelPosition)}. */ public void setNegativeItemLabelPosition(ItemLabelPosition position); /** * Sets the item label position for negative values in ALL series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getNegativeItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, * boolean)} and {@link #setBaseNegativeItemLabelPosition( * ItemLabelPosition, boolean)}. */ public void setNegativeItemLabelPosition(ItemLabelPosition position, boolean notify); /** * Returns the item label position for all negative values in a series. * * @param series the series index (zero-based). * * @return The item label position. * * @see #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition) */ public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series); /** * Sets the item label position for negative values in a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * * @see #getSeriesNegativeItemLabelPosition(int) */ public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position); /** * Sets the item label position for negative values in a series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getSeriesNegativeItemLabelPosition(int) */ public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position, boolean notify); /** * Returns the base item label position for negative values. * * @return The position. * * @see #setBaseNegativeItemLabelPosition(ItemLabelPosition) */ public ItemLabelPosition getBaseNegativeItemLabelPosition(); /** * Sets the base item label position for negative values and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position. * * @see #getBaseNegativeItemLabelPosition() */ public void setBaseNegativeItemLabelPosition(ItemLabelPosition position); /** * Sets the base negative item label position and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position. * @param notify notify registered listeners? * * @see #getBaseNegativeItemLabelPosition() */ public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, boolean notify); // CREATE ENTITIES // FIXME: these methods should be defined // public boolean getItemCreateEntity(int series, int item); // // public Boolean getSeriesCreateEntities(int series); // // public void setSeriesCreateEntities(int series, Boolean create); // // public void setSeriesCreateEntities(int series, Boolean create, // boolean notify); // // public boolean getBaseCreateEntities(); // // public void setBaseCreateEntities(boolean create); // // public void setBaseCreateEntities(boolean create, boolean notify); // ITEM URL GENERATOR /** * Returns the URL generator for an item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The item URL generator. */ public CategoryURLGenerator getItemURLGenerator(int series, int item); /** * Sets the item URL generator for ALL series. * * @param generator the generator. * * @see #getSeriesItemURLGenerator(int) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemURLGenerator(int, * CategoryURLGenerator)} and * {@link #setBaseItemURLGenerator(CategoryURLGenerator)}. */ public void setItemURLGenerator(CategoryURLGenerator generator); /** * Returns the item URL generator for a series. * * @param series the series index (zero-based). * * @return The URL generator. * * @see #setSeriesItemURLGenerator(int, CategoryURLGenerator) */ public CategoryURLGenerator getSeriesItemURLGenerator(int series); /** * Sets the item URL generator for a series. * * @param series the series index (zero-based). * @param generator the generator. * * @see #getSeriesItemURLGenerator(int) */ public void setSeriesItemURLGenerator(int series, CategoryURLGenerator generator); // FIXME: add setSeriesItemURLGenerator(int, CategoryURLGenerator, boolean)? /** * Returns the base item URL generator. * * @return The item URL generator (possibly null). * * @see #setBaseItemURLGenerator(CategoryURLGenerator) */ public CategoryURLGenerator getBaseItemURLGenerator(); /** * Sets the base item URL generator and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param generator the item URL generator (null permitted). * * @see #getBaseItemURLGenerator() */ public void setBaseItemURLGenerator(CategoryURLGenerator generator); // FIXME: add setBaseItemURLGenerator(CategoryURLGenerator, boolean) ? /** * Returns a legend item for a series. This method can return * null, in which case the series will have no entry in the * legend. * * @param datasetIndex the dataset index (zero-based). * @param series the series (zero-based index). * * @return The legend item (possibly null). */ public LegendItem getLegendItem(int datasetIndex, int series); /** * Draws a background for the data area. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. */ public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea); /** * Draws an outline for the data area. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the data area. */ public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea); /** * Draws a single data item. * * @param g2 the graphics device. * @param state state information for one chart. * @param dataArea the data plot area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass); /** * Draws a grid line against the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value. * * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, * Rectangle2D, double) */ public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value); /** * Draws a grid line against the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value. * * @see #drawDomainGridline(Graphics2D, CategoryPlot, Rectangle2D, double) */ public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value); /** * Draws a line (or some other marker) to indicate a particular category on * the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the category axis. * @param marker the marker. * @param dataArea the area for plotting data (not including 3D effect). * * @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker, * Rectangle2D) */ public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea); /** * Draws a line (or some other marker) to indicate a particular value on * the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param marker the marker. * @param dataArea the area for plotting data (not including 3D effect). * * @see #drawDomainMarker(Graphics2D, CategoryPlot, CategoryAxis, * CategoryMarker, Rectangle2D) */ public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea); /** * Returns the Java2D coordinate for the middle of the specified data item. * * @param rowKey the row key. * @param columnKey the column key. * @param dataset the dataset. * @param axis the axis. * @param area the data area. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate for the middle of the item. * * @since 1.0.11 */ public double getItemMiddle(Comparable rowKey, Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, RectangleEdge edge); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/CategoryItemRendererState.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/CategoryItemRendererState.ja0000644000175000017500000001516511173030414033464 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CategoryItemRendererState.java * ------------------------------ * (C) Copyright 2003-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Peter Kolb (patch 2497611); * * Changes (since 20-Oct-2003): * ---------------------------- * 20-Oct-2003 : Added series running total (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Dec-2006 : Updated API docs (DG); * 26-Jun-2008 : Added CrosshairState (DG); * 14-Jan-2009 : Added visibleSeries[] array (PK); * 04-Feb-2009 : Added getVisibleSeriesArray() method (DG); * */ package org.jfree.chart.renderer.category; import org.jfree.chart.plot.CategoryCrosshairState; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.renderer.RendererState; /** * An object that retains temporary state information for a * {@link CategoryItemRenderer}. */ public class CategoryItemRendererState extends RendererState { /** The bar width. */ private double barWidth; /** The series running total. */ private double seriesRunningTotal; /** The array with the indices of the visible series.*/ private int[] visibleSeries; /** * State information for crosshairs in the plot (this is updated by the * renderer, but may be passed to several renderers in one chart). * * @since 1.0.11 */ private CategoryCrosshairState crosshairState; /** * Creates a new object for recording temporary state information for a * renderer. * * @param info the plot rendering info (null permitted). */ public CategoryItemRendererState(PlotRenderingInfo info) { super(info); this.barWidth = 0.0; this.seriesRunningTotal = 0.0; } /** * Returns the bar width. * * @return The bar width. * * @see #setBarWidth(double) */ public double getBarWidth() { return this.barWidth; } /** * Sets the bar width. The renderer calculates this value and stores it * here - it is not intended that users can manually set the bar width. * * @param width the width. * * @see #getBarWidth() */ public void setBarWidth(double width) { this.barWidth = width; } /** * Returns the series running total. * * @return The running total. * * @see #setSeriesRunningTotal(double) */ public double getSeriesRunningTotal() { return this.seriesRunningTotal; } /** * Sets the series running total (this method is intended for the use of * the renderer only). * * @param total the new total. * * @see #getSeriesRunningTotal() */ void setSeriesRunningTotal(double total) { this.seriesRunningTotal = total; } /** * Returns the crosshair state, if any. * * @return The crosshair state (possibly null). * * @since 1.0.11 * * @see #setCrosshairState(CategoryCrosshairState) */ public CategoryCrosshairState getCrosshairState() { return this.crosshairState; } /** * Sets the crosshair state. * * @param state the new state (null permitted). * * @since 1.0.11 * * @see #getCrosshairState() */ public void setCrosshairState(CategoryCrosshairState state) { this.crosshairState = state; } /** * Returns the index of the row relative to the visible rows. If no * visible rows have been specified, the original row index is returned. * If the row index is not included in the array of visible rows, * -1 is returned. * * @param rowIndex the row index. * * @return The new row index or -1. * * @since 1.0.13 */ public int getVisibleSeriesIndex(int rowIndex) { if (this.visibleSeries == null) { return rowIndex; } int index = -1; for (int vRow = 0; vRow < this.visibleSeries.length ; vRow++){ if (this.visibleSeries[vRow] == rowIndex) { index = vRow; break; } } return index; } /** * Returns the number of visible series or -1 if no visible series have * been specified. * * @return The number or -1. * * @since 1.0.13 */ public int getVisibleSeriesCount() { if (this.visibleSeries == null) { return -1; } return this.visibleSeries.length; } /** * Returns a copy of the visible series array. * * @return The visible series array (possibly null). * * @since 1.0.13 */ public int[] getVisibleSeriesArray() { if (this.visibleSeries == null) { return null; } int[] result = new int[this.visibleSeries.length]; System.arraycopy(this.visibleSeries, 0, result, 0, this.visibleSeries.length); return result; } /** * Sets an array with the indices of the visible rows. * * @param visibleSeries the array (null permitted). * * @since 1.0.13 */ public void setVisibleSeriesArray(int[] visibleSeries) { this.visibleSeries = visibleSeries; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/CategoryStepRenderer.java0000644000175000017500000003274611173030414033033 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CategoryStepRenderer.java * ------------------------- * * (C) Copyright 2004-2008, by Brian Cole and Contributors. * * Original Author: Brian Cole; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 21-Apr-2004 : Version 1, contributed by Brian Cole (DG); * 22-Apr-2004 : Fixed Checkstyle complaints (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 08-Mar-2005 : Added equals() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 30-Nov-2006 : Added checks for series visibility (DG); * 22-Feb-2007 : Use new state object for reusable line, enable chart entities * (for tooltips, URLs), added new getLegendItem() override (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.renderer.xy.XYStepRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.util.PublicCloneable; /** * A "step" renderer similar to {@link XYStepRenderer} but * that can be used with the {@link CategoryPlot} class. The example shown * here is generated by the CategoryStepChartDemo1.java program * included in the JFreeChart Demo Collection: *

* CategoryStepRendererSample.png */ public class CategoryStepRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** * State information for the renderer. */ protected static class State extends CategoryItemRendererState { /** * A working line for re-use to avoid creating large numbers of * objects. */ public Line2D line; /** * Creates a new state instance. * * @param info collects plot rendering information (null * permitted). */ public State(PlotRenderingInfo info) { super(info); this.line = new Line2D.Double(); } } /** For serialization. */ private static final long serialVersionUID = -5121079703118261470L; /** The stagger width. */ public static final int STAGGER_WIDTH = 5; // could make this configurable /** * A flag that controls whether or not the steps for multiple series are * staggered. */ private boolean stagger = false; /** * Creates a new renderer (stagger defaults to false). */ public CategoryStepRenderer() { this(false); } /** * Creates a new renderer. * * @param stagger should the horizontal part of the step be staggered by * series? */ public CategoryStepRenderer(boolean stagger) { this.stagger = stagger; setBaseLegendShape(new Rectangle2D.Double(-4.0, -3.0, 8.0, 6.0)); } /** * Returns the flag that controls whether the series steps are staggered. * * @return A boolean. */ public boolean getStagger() { return this.stagger; } /** * Sets the flag that controls whether or not the series steps are * staggered and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param shouldStagger a boolean. */ public void setStagger(boolean shouldStagger) { this.stagger = shouldStagger; fireChangeEvent(); } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; } /** * Creates a new state instance. This method is called from * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, * PlotRenderingInfo)}, and we override it to ensure that the state * contains a working Line2D instance. * * @param info the plot rendering info (null is permitted). * * @return A new state instance. */ protected CategoryItemRendererState createState(PlotRenderingInfo info) { return new State(info); } /** * Draws a line taking into account the specified orientation. *

* In version 1.0.5, the signature of this method was changed by the * addition of the 'state' parameter. This is an incompatible change, but * is considered a low risk because it is unlikely that anyone has * subclassed this renderer. If this *does* cause trouble for you, please * report it as a bug. * * @param g2 the graphics device. * @param state the renderer state. * @param orientation the plot orientation. * @param x0 the x-coordinate for the start of the line. * @param y0 the y-coordinate for the start of the line. * @param x1 the x-coordinate for the end of the line. * @param y1 the y-coordinate for the end of the line. */ protected void drawLine(Graphics2D g2, State state, PlotOrientation orientation, double x0, double y0, double x1, double y1) { if (orientation == PlotOrientation.VERTICAL) { state.line.setLine(x0, y0, x1, y1); g2.draw(state.line); } else if (orientation == PlotOrientation.HORIZONTAL) { state.line.setLine(y0, x0, y1, x1); // switch x and y g2.draw(state.line); } } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // do nothing if item is not visible if (!getItemVisible(row, column)) { return; } Number value = dataset.getValue(row, column); if (value == null) { return; } PlotOrientation orientation = plot.getOrientation(); // current data point... double x1s = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double x1e = 2 * x1 - x1s; // or: x1s + 2*(x1-x1s) double y1 = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, plot.getRangeAxisEdge()); g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); if (column != 0) { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0s = domainAxis.getCategoryStart(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double x0e = 2 * x0 - x0s; // or: x0s + 2*(x0-x0s) double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); if (getStagger()) { int xStagger = row * STAGGER_WIDTH; if (xStagger > (x1s - x0e)) { xStagger = (int) (x1s - x0e); } x1s = x0e + xStagger; } drawLine(g2, (State) state, orientation, x0e, y0, x1s, y0); // extend x0's flat bar drawLine(g2, (State) state, orientation, x1s, y0, x1s, y1); // upright bar } } drawLine(g2, (State) state, orientation, x1s, y1, x1e, y1); // x1's flat bar // draw the item labels if there are any... if (isItemLabelVisible(row, column)) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value.doubleValue() < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { Rectangle2D hotspot = new Rectangle2D.Double(); if (orientation == PlotOrientation.VERTICAL) { hotspot.setRect(x1s, y1, x1e - x1s, 4.0); } else { hotspot.setRect(y1 - 2.0, x1s, 4.0, x1e - x1s); } addItemEntity(entities, dataset, row, column, hotspot); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryStepRenderer)) { return false; } CategoryStepRenderer that = (CategoryStepRenderer) obj; if (this.stagger != that.stagger) { return false; } return super.equals(obj); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/DefaultCategoryItemRenderer.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/DefaultCategoryItemRenderer.0000644000175000017500000000411211173030414033443 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * DefaultCategoryItemRenderer.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2003 : Version 1 (DG); * */ package org.jfree.chart.renderer.category; import java.io.Serializable; import org.jfree.chart.plot.CategoryPlot; /** * A default renderer for the {@link CategoryPlot} class. This is simply an * alias for the {@link LineAndShapeRenderer} class. */ public class DefaultCategoryItemRenderer extends LineAndShapeRenderer implements Serializable { /** For serialization. */ private static final long serialVersionUID = -7793786349384231896L; // no new methods } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/GanttRenderer.java0000644000175000017500000005714611173030414031500 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * GanttRenderer.java * ------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Sep-2003 : Version 1 (DG); * 23-Sep-2003 : Fixed Checkstyle issues (DG); * 21-Oct-2003 : Bar width moved into CategoryItemRendererState (DG); * 03-Feb-2004 : Added get/set methods for attributes (DG); * 12-Aug-2004 : Fixed rendering problem with maxBarWidth attribute (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 01-Dec-2005 : Fix for bug 1369954, drawBarOutline flag ignored (DG); * ------------- JFREECHART 1.0.x -------------------------------------------- * 17-Jan-2006 : Set includeBaseInRange flag to false (DG); * 20-Mar-2007 : Implemented equals() and fixed serialization (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * 26-Jun-2008 : Added crosshair support (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.data.gantt.GanttCategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; /** * A renderer for simple Gantt charts. The example shown * here is generated by the GanttDemo1.java program * included in the JFreeChart Demo Collection: *

* GanttRendererSample.png */ public class GanttRenderer extends IntervalBarRenderer implements Serializable { /** For serialization. */ private static final long serialVersionUID = -4010349116350119512L; /** The paint for displaying the percentage complete. */ private transient Paint completePaint; /** The paint for displaying the incomplete part of a task. */ private transient Paint incompletePaint; /** * Controls the starting edge of the progress indicator (expressed as a * percentage of the overall bar width). */ private double startPercent; /** * Controls the ending edge of the progress indicator (expressed as a * percentage of the overall bar width). */ private double endPercent; /** * Creates a new renderer. */ public GanttRenderer() { super(); setIncludeBaseInRange(false); this.completePaint = Color.green; this.incompletePaint = Color.red; this.startPercent = 0.35; this.endPercent = 0.65; } /** * Returns the paint used to show the percentage complete. * * @return The paint (never null. * * @see #setCompletePaint(Paint) */ public Paint getCompletePaint() { return this.completePaint; } /** * Sets the paint used to show the percentage complete and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getCompletePaint() */ public void setCompletePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.completePaint = paint; fireChangeEvent(); } /** * Returns the paint used to show the percentage incomplete. * * @return The paint (never null). * * @see #setCompletePaint(Paint) */ public Paint getIncompletePaint() { return this.incompletePaint; } /** * Sets the paint used to show the percentage incomplete and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getIncompletePaint() */ public void setIncompletePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.incompletePaint = paint; fireChangeEvent(); } /** * Returns the position of the start of the progress indicator, as a * percentage of the bar width. * * @return The start percent. * * @see #setStartPercent(double) */ public double getStartPercent() { return this.startPercent; } /** * Sets the position of the start of the progress indicator, as a * percentage of the bar width, and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param percent the percent. * * @see #getStartPercent() */ public void setStartPercent(double percent) { this.startPercent = percent; fireChangeEvent(); } /** * Returns the position of the end of the progress indicator, as a * percentage of the bar width. * * @return The end percent. * * @see #setEndPercent(double) */ public double getEndPercent() { return this.endPercent; } /** * Sets the position of the end of the progress indicator, as a percentage * of the bar width, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param percent the percent. * * @see #getEndPercent() */ public void setEndPercent(double percent) { this.endPercent = percent; fireChangeEvent(); } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { if (dataset instanceof GanttCategoryDataset) { GanttCategoryDataset gcd = (GanttCategoryDataset) dataset; drawTasks(g2, state, dataArea, plot, domainAxis, rangeAxis, gcd, row, column); } else { // let the superclass handle it... super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); } } /** * Draws the tasks/subtasks for one item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data plot area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawTasks(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, GanttCategoryDataset dataset, int row, int column) { int count = dataset.getSubIntervalCount(row, column); if (count == 0) { drawTask(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column); } PlotOrientation orientation = plot.getOrientation(); for (int subinterval = 0; subinterval < count; subinterval++) { RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // value 0 Number value0 = dataset.getStartValue(row, column, subinterval); if (value0 == null) { return; } double translatedValue0 = rangeAxis.valueToJava2D( value0.doubleValue(), dataArea, rangeAxisLocation); // value 1 Number value1 = dataset.getEndValue(row, column, subinterval); if (value1 == null) { return; } double translatedValue1 = rangeAxis.valueToJava2D( value1.doubleValue(), dataArea, rangeAxisLocation); if (translatedValue1 < translatedValue0) { double temp = translatedValue1; translatedValue1 = translatedValue0; translatedValue0 = temp; } double rectStart = calculateBarW0(plot, plot.getOrientation(), dataArea, domainAxis, state, row, column); double rectLength = Math.abs(translatedValue1 - translatedValue0); double rectBreadth = state.getBarWidth(); // DRAW THE BARS... Rectangle2D bar = null; RectangleEdge barBase = null; if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(translatedValue0, rectStart, rectLength, rectBreadth); barBase = RectangleEdge.LEFT; } else if (plot.getOrientation() == PlotOrientation.VERTICAL) { bar = new Rectangle2D.Double(rectStart, translatedValue0, rectBreadth, rectLength); barBase = RectangleEdge.BOTTOM; } Rectangle2D completeBar = null; Rectangle2D incompleteBar = null; Number percent = dataset.getPercentComplete(row, column, subinterval); double start = getStartPercent(); double end = getEndPercent(); if (percent != null) { double p = percent.doubleValue(); if (orientation == PlotOrientation.HORIZONTAL) { completeBar = new Rectangle2D.Double(translatedValue0, rectStart + start * rectBreadth, rectLength * p, rectBreadth * (end - start)); incompleteBar = new Rectangle2D.Double(translatedValue0 + rectLength * p, rectStart + start * rectBreadth, rectLength * (1 - p), rectBreadth * (end - start)); } else if (orientation == PlotOrientation.VERTICAL) { completeBar = new Rectangle2D.Double(rectStart + start * rectBreadth, translatedValue0 + rectLength * (1 - p), rectBreadth * (end - start), rectLength * p); incompleteBar = new Rectangle2D.Double(rectStart + start * rectBreadth, translatedValue0, rectBreadth * (end - start), rectLength * (1 - p)); } } if (getShadowsVisible()) { getBarPainter().paintBarShadow(g2, this, row, column, bar, barBase, true); } getBarPainter().paintBar(g2, this, row, column, bar, barBase); if (completeBar != null) { g2.setPaint(getCompletePaint()); g2.fill(completeBar); } if (incompleteBar != null) { g2.setPaint(getIncompletePaint()); g2.fill(incompleteBar); } if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); } if (subinterval == count - 1) { // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); Comparable columnKey = dataset.getColumnKey(column); Comparable rowKey = dataset.getRowKey(row); double xx = domainAxis.getCategorySeriesMiddle(columnKey, rowKey, dataset, getItemMargin(), dataArea, plot.getDomainAxisEdge()); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value1.doubleValue(), datasetIndex, xx, translatedValue1, orientation); } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } } } /** * Draws a single task. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data plot area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawTask(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, GanttCategoryDataset dataset, int row, int column) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // Y0 Number value0 = dataset.getEndValue(row, column); if (value0 == null) { return; } double java2dValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation); // Y1 Number value1 = dataset.getStartValue(row, column); if (value1 == null) { return; } double java2dValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), dataArea, rangeAxisLocation); if (java2dValue1 < java2dValue0) { double temp = java2dValue1; java2dValue1 = java2dValue0; java2dValue0 = temp; Number tempNum = value1; value1 = value0; value0 = tempNum; } double rectStart = calculateBarW0(plot, orientation, dataArea, domainAxis, state, row, column); double rectBreadth = state.getBarWidth(); double rectLength = Math.abs(java2dValue1 - java2dValue0); Rectangle2D bar = null; RectangleEdge barBase = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(java2dValue0, rectStart, rectLength, rectBreadth); barBase = RectangleEdge.LEFT; } else if (orientation == PlotOrientation.VERTICAL) { bar = new Rectangle2D.Double(rectStart, java2dValue1, rectBreadth, rectLength); barBase = RectangleEdge.BOTTOM; } Rectangle2D completeBar = null; Rectangle2D incompleteBar = null; Number percent = dataset.getPercentComplete(row, column); double start = getStartPercent(); double end = getEndPercent(); if (percent != null) { double p = percent.doubleValue(); if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { completeBar = new Rectangle2D.Double(java2dValue0, rectStart + start * rectBreadth, rectLength * p, rectBreadth * (end - start)); incompleteBar = new Rectangle2D.Double(java2dValue0 + rectLength * p, rectStart + start * rectBreadth, rectLength * (1 - p), rectBreadth * (end - start)); } else if (plot.getOrientation() == PlotOrientation.VERTICAL) { completeBar = new Rectangle2D.Double(rectStart + start * rectBreadth, java2dValue1 + rectLength * (1 - p), rectBreadth * (end - start), rectLength * p); incompleteBar = new Rectangle2D.Double(rectStart + start * rectBreadth, java2dValue1, rectBreadth * (end - start), rectLength * (1 - p)); } } if (getShadowsVisible()) { getBarPainter().paintBarShadow(g2, this, row, column, bar, barBase, true); } getBarPainter().paintBar(g2, this, row, column, bar, barBase); if (completeBar != null) { g2.setPaint(getCompletePaint()); g2.fill(completeBar); } if (incompleteBar != null) { g2.setPaint(getIncompletePaint()); g2.fill(incompleteBar); } // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, false); } // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); Comparable columnKey = dataset.getColumnKey(column); Comparable rowKey = dataset.getRowKey(row); double xx = domainAxis.getCategorySeriesMiddle(columnKey, rowKey, dataset, getItemMargin(), dataArea, plot.getDomainAxisEdge()); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value1.doubleValue(), datasetIndex, xx, java2dValue1, orientation); // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Returns the Java2D coordinate for the middle of the specified data item. * * @param rowKey the row key. * @param columnKey the column key. * @param dataset the dataset. * @param axis the axis. * @param area the drawing area. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate. * * @since 1.0.11 */ public double getItemMiddle(Comparable rowKey, Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, RectangleEdge edge) { return axis.getCategorySeriesMiddle(columnKey, rowKey, dataset, getItemMargin(), area, edge); } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GanttRenderer)) { return false; } GanttRenderer that = (GanttRenderer) obj; if (!PaintUtilities.equal(this.completePaint, that.completePaint)) { return false; } if (!PaintUtilities.equal(this.incompletePaint, that.incompletePaint)) { return false; } if (this.startPercent != that.startPercent) { return false; } if (this.endPercent != that.endPercent) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.completePaint, stream); SerialUtilities.writePaint(this.incompletePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.completePaint = SerialUtilities.readPaint(stream); this.incompletePaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/GradientBarPainter.java0000644000175000017500000003124411173030414032430 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * GradientBarPainter.java * ----------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); * 15-Aug-2008 : Use outline paint and shadow paint (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.ui.RectangleEdge; /** * An implementation of the {@link BarPainter} interface that uses several * gradient fills to enrich the appearance of the bars. * * @since 1.0.11 */ public class GradientBarPainter implements BarPainter, Serializable { /** The division point between the first and second gradient regions. */ private double g1; /** The division point between the second and third gradient regions. */ private double g2; /** The division point between the third and fourth gradient regions. */ private double g3; /** * Creates a new instance. */ public GradientBarPainter() { this(0.10, 0.20, 0.80); } /** * Creates a new instance. * * @param g1 * @param g2 * @param g3 */ public GradientBarPainter(double g1, double g2, double g3) { this.g1 = g1; this.g2 = g2; this.g3 = g3; } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. */ public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column); Color c0, c1; if (itemPaint instanceof Color) { c0 = (Color) itemPaint; c1 = c0.brighter(); } else if (itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; c0 = gp.getColor1(); c1 = gp.getColor2(); } else { c0 = Color.blue; c1 = Color.blue.brighter(); } // as a special case, if the bar colour has alpha == 0, we draw // nothing. if (c0.getAlpha() == 0) { return; } if (base == RectangleEdge.TOP || base == RectangleEdge.BOTTOM) { Rectangle2D[] regions = splitVerticalBar(bar, this.g1, this.g2, this.g3); GradientPaint gp = new GradientPaint((float) regions[0].getMinX(), 0.0f, c0, (float) regions[0].getMaxX(), 0.0f, Color.white); g2.setPaint(gp); g2.fill(regions[0]); gp = new GradientPaint((float) regions[1].getMinX(), 0.0f, Color.white, (float) regions[1].getMaxX(), 0.0f, c0); g2.setPaint(gp); g2.fill(regions[1]); gp = new GradientPaint((float) regions[2].getMinX(), 0.0f, c0, (float) regions[2].getMaxX(), 0.0f, c1); g2.setPaint(gp); g2.fill(regions[2]); gp = new GradientPaint((float) regions[3].getMinX(), 0.0f, c1, (float) regions[3].getMaxX(), 0.0f, c0); g2.setPaint(gp); g2.fill(regions[3]); } else if (base == RectangleEdge.LEFT || base == RectangleEdge.RIGHT) { Rectangle2D[] regions = splitHorizontalBar(bar, this.g1, this.g2, this.g3); GradientPaint gp = new GradientPaint(0.0f, (float) regions[0].getMinY(), c0, 0.0f, (float) regions[0].getMaxX(), Color.white); g2.setPaint(gp); g2.fill(regions[0]); gp = new GradientPaint(0.0f, (float) regions[1].getMinY(), Color.white, 0.0f, (float) regions[1].getMaxY(), c0); g2.setPaint(gp); g2.fill(regions[1]); gp = new GradientPaint(0.0f, (float) regions[2].getMinY(), c0, 0.0f, (float) regions[2].getMaxY(), c1); g2.setPaint(gp); g2.fill(regions[2]); gp = new GradientPaint(0.0f, (float) regions[3].getMinY(), c1, 0.0f, (float) regions[3].getMaxY(), c0); g2.setPaint(gp); g2.fill(regions[3]); } // draw the outline... if (renderer.isDrawBarOutline() /*&& state.getBarWidth() > renderer.BAR_OUTLINE_WIDTH_THRESHOLD*/) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. * @param pegShadow peg the shadow to the base of the bar? */ public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow) { // handle a special case - if the bar colour has alpha == 0, it is // invisible so we shouldn't draw any shadow Paint itemPaint = renderer.getItemPaint(row, column); if (itemPaint instanceof Color) { Color c = (Color) itemPaint; if (c.getAlpha() == 0) { return; } } RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); g2.setPaint(renderer.getShadowPaint()); g2.fill(shadow); } /** * Creates a shadow for the bar. * * @param bar the bar shape. * @param xOffset the x-offset for the shadow. * @param yOffset the y-offset for the shadow. * @param base the edge that is the base of the bar. * @param pegShadow peg the shadow to the base? * * @return A rectangle for the shadow. */ private Rectangle2D createShadow(RectangularShape bar, double xOffset, double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY(); if (base == RectangleEdge.TOP) { x0 += xOffset; x1 += xOffset; if (!pegShadow) { y0 += yOffset; } y1 += yOffset; } else if (base == RectangleEdge.BOTTOM) { x0 += xOffset; x1 += xOffset; y0 += yOffset; if (!pegShadow) { y1 += yOffset; } } else if (base == RectangleEdge.LEFT) { if (!pegShadow) { x0 += xOffset; } x1 += xOffset; y0 += yOffset; y1 += yOffset; } else if (base == RectangleEdge.RIGHT) { x0 += xOffset; if (!pegShadow) { x1 += xOffset; } y0 += yOffset; y1 += yOffset; } return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); } /** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double x0 = bar.getMinX(); double x1 = Math.rint(x0 + (bar.getWidth() * a)); double x2 = Math.rint(x0 + (bar.getWidth() * b)); double x3 = Math.rint(x0 + (bar.getWidth() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight()); result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight()); result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight()); result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight()); return result; } /** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double y0 = bar.getMinY(); double y1 = Math.rint(y0 + (bar.getHeight() * a)); double y2 = Math.rint(y0 + (bar.getHeight() * b)); double y3 = Math.rint(y0 + (bar.getHeight() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), y1 - y0); result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(), y2 - y1); result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(), y3 - y2); result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(), bar.getMaxY() - y3); return result; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the obj (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GradientBarPainter)) { return false; } GradientBarPainter that = (GradientBarPainter) obj; if (this.g1 != that.g1) { return false; } if (this.g2 != that.g2) { return false; } if (this.g3 != that.g3) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 37; hash = HashUtilities.hashCode(hash, this.g1); hash = HashUtilities.hashCode(hash, this.g2); hash = HashUtilities.hashCode(hash, this.g3); return hash; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.ja0000644000175000017500000003415211173030414033415 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * GroupedStackedBarRenderer.java * ------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2004 : Version 1 (DG); * 08-Jul-2004 : Added equals() method (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); * 20-Dec-2007 : Fix for bug 1848961 (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.KeyToGroupMap; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A renderer that draws stacked bars within groups. This will probably be * merged with the {@link StackedBarRenderer} class at some point. The example * shown here is generated by the StackedBarChartDemo4.java * program included in the JFreeChart Demo Collection: *

* GroupedStackedBarRendererSample.png */ public class GroupedStackedBarRenderer extends StackedBarRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2725921399005922939L; /** A map used to assign each series to a group. */ private KeyToGroupMap seriesToGroupMap; /** * Creates a new renderer. */ public GroupedStackedBarRenderer() { super(); this.seriesToGroupMap = new KeyToGroupMap(); } /** * Updates the map used to assign each series to a group, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param map the map (null not permitted). */ public void setSeriesToGroupMap(KeyToGroupMap map) { if (map == null) { throw new IllegalArgumentException("Null 'map' argument."); } this.seriesToGroupMap = map; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } Range r = DatasetUtilities.findStackedRangeBounds( dataset, this.seriesToGroupMap); return r; } /** * Calculates the bar width and stores it in the renderer state. We * override the method in the base class to take account of the * series-to-group mapping. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { // calculate the bar width CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { PlotOrientation orientation = plot.getOrientation(); double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); int groups = this.seriesToGroupMap.getGroupCount(); int categories = data.getColumnCount(); int columns = groups * categories; double categoryMargin = 0.0; double itemMargin = 0.0; if (categories > 1) { categoryMargin = xAxis.getCategoryMargin(); } if (groups > 1) { itemMargin = getItemMargin(); } double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin - itemMargin); if (columns > 0) { state.setBarWidth(Math.min(used / columns, maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } } /** * Calculates the coordinate of the first "side" of a bar. This will be * the minimum x-coordinate for a vertical bar, and the minimum * y-coordinate for a horizontal bar. * * @param plot the plot. * @param orientation the plot orientation. * @param dataArea the data area. * @param domainAxis the domain axis. * @param state the renderer state (has the bar width precalculated). * @param row the row index. * @param column the column index. * * @return The coordinate. */ protected double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column) { // calculate bar width... double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else { space = dataArea.getWidth(); } double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); int groupCount = this.seriesToGroupMap.getGroupCount(); int groupIndex = this.seriesToGroupMap.getGroupIndex( this.seriesToGroupMap.getGroup(plot.getDataset( plot.getIndexOf(this)).getRowKey(row))); int categoryCount = getColumnCount(); if (groupCount > 1) { double groupGap = space * getItemMargin() / (categoryCount * (groupCount - 1)); double groupW = calculateSeriesWidth(space, domainAxis, categoryCount, groupCount); barW0 = barW0 + groupIndex * (groupW + groupGap) + (groupW / 2.0) - (state.getBarWidth() / 2.0); } else { barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; } return barW0; } /** * Draws a stacked bar for a specific item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the plot area. * @param plot the plot. * @param domainAxis the domain (category) axis. * @param rangeAxis the range (value) axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); Comparable group = this.seriesToGroupMap.getGroup( dataset.getRowKey(row)); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, state, row, column); double positiveBase = 0.0; double negativeBase = 0.0; for (int i = 0; i < row; i++) { if (group.equals(this.seriesToGroupMap.getGroup( dataset.getRowKey(i)))) { Number v = dataset.getValue(i, column); if (v != null) { double d = v.doubleValue(); if (d > 0) { positiveBase = positiveBase + d; } else { negativeBase = negativeBase + d; } } } } double translatedBase; double translatedValue; boolean positive = (value > 0.0); boolean inverted = rangeAxis.isInverted(); RectangleEdge barBase; if (orientation == PlotOrientation.HORIZONTAL) { if (positive && inverted || !positive && !inverted) { barBase = RectangleEdge.RIGHT; } else { barBase = RectangleEdge.LEFT; } } else { if (positive && !inverted || !positive && inverted) { barBase = RectangleEdge.BOTTOM; } else { barBase = RectangleEdge.TOP; } } RectangleEdge location = plot.getRangeAxisEdge(); if (value > 0.0) { translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, location); translatedValue = rangeAxis.valueToJava2D(positiveBase + value, dataArea, location); } else { translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, location); translatedValue = rangeAxis.valueToJava2D(negativeBase + value, dataArea, location); } double barL0 = Math.min(translatedBase, translatedValue); double barLength = Math.max(Math.abs(translatedValue - translatedBase), getMinimumBarLength()); Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } getBarPainter().paintBar(g2, this, row, column, bar, barBase); CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GroupedStackedBarRenderer)) { return false; } GroupedStackedBarRenderer that = (GroupedStackedBarRenderer) obj; if (!this.seriesToGroupMap.equals(that.seriesToGroupMap)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java0000644000175000017500000002537611173030414032634 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * IntervalBarRenderer.java * ------------------------ * (C) Copyright 2002-2009, by Jeremy Bowman. * * Original Author: Jeremy Bowman; * Contributor(s): David Gilbert (for Object Refinery Limited); * Christian W. Zuckschwerdt; * Peter Kolb (patch 2497611); * * Changes * ------- * 29-Apr-2002 : Version 1, contributed by Jeremy Bowman (DG); * 11-May-2002 : Use CategoryPlot.getLabelsVisible() (JB); * 29-May-2002 : Added constructors (DG); * 26-Jun-2002 : Added axis to initialise method (DG); * 20-Sep-2002 : Added basic support for chart entities (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 19-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 08-Sep-2003 : Added checks for null values (DG); * 07-Oct-2003 : Added renderer state (DG); * 21-Oct-2003 : Bar width moved into renderer state (DG); * 23-Dec-2003 : Removed the deprecated MultiIntervalCategoryDataset * interface (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * 07-Oct-2008 : Override equals() method to fix minor bug (DG); * 14-Jan-2009 : Added support for seriesVisible flags (PK); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.ui.RectangleEdge; /** * A renderer that handles the drawing of bars for a bar plot where * each bar has a high and low value. This renderer is for use with the * {@link CategoryPlot} class. The example shown here is generated by the * IntervalBarChartDemo1.java program included in the JFreeChart * Demo Collection: *

* IntervalBarRendererSample.png */ public class IntervalBarRenderer extends BarRenderer { /** For serialization. */ private static final long serialVersionUID = -5068857361615528725L; /** * Constructs a new renderer. */ public IntervalBarRenderer() { super(); } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset d = (IntervalCategoryDataset) dataset; drawInterval(g2, state, dataArea, plot, domainAxis, rangeAxis, d, row, column); } else { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); } } /** * Draws a single interval. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data plot area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawInterval(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, IntervalCategoryDataset dataset, int row, int column) { int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } int seriesCount = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : getRowCount(); int categoryCount = getColumnCount(); PlotOrientation orientation = plot.getOrientation(); double rectX = 0.0; double rectY = 0.0; RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // Y0 Number value0 = dataset.getEndValue(row, column); if (value0 == null) { return; } double java2dValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), dataArea, rangeAxisLocation); // Y1 Number value1 = dataset.getStartValue(row, column); if (value1 == null) { return; } double java2dValue1 = rangeAxis.valueToJava2D( value1.doubleValue(), dataArea, rangeAxisLocation); if (java2dValue1 < java2dValue0) { double temp = java2dValue1; java2dValue1 = java2dValue0; java2dValue0 = temp; Number tempNum = value1; value1 = value0; value0 = tempNum; } // BAR WIDTH double rectWidth = state.getBarWidth(); // BAR HEIGHT double rectHeight = Math.abs(java2dValue1 - java2dValue0); RectangleEdge barBase = RectangleEdge.LEFT; if (orientation == PlotOrientation.HORIZONTAL) { // BAR Y rectY = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, domainAxisLocation); if (seriesCount > 1) { double seriesGap = dataArea.getHeight() * getItemMargin() / (categoryCount * (seriesCount - 1)); rectY = rectY + visibleRow * (state.getBarWidth() + seriesGap); } else { rectY = rectY + visibleRow * state.getBarWidth(); } rectX = java2dValue0; rectHeight = state.getBarWidth(); rectWidth = Math.abs(java2dValue1 - java2dValue0); barBase = RectangleEdge.LEFT; } else if (orientation == PlotOrientation.VERTICAL) { // BAR X rectX = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, domainAxisLocation); if (seriesCount > 1) { double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1)); rectX = rectX + visibleRow * (state.getBarWidth() + seriesGap); } else { rectX = rectX + visibleRow * state.getBarWidth(); } rectY = java2dValue0; barBase = RectangleEdge.BOTTOM; } Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight); BarPainter painter = getBarPainter(); if (getShadowsVisible()) { painter.paintBarShadow(g2, this, row, column, bar, barBase, false); } getBarPainter().paintBar(g2, this, row, column, bar, barBase); CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, false); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof IntervalBarRenderer)) { return false; } // there are no fields to check return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/LayeredBarRenderer.java0000644000175000017500000004273511173030414032433 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * LayeredBarRenderer.java * ----------------------- * (C) Copyright 2003-2008, by Arnaud Lelievre and Contributors. * * Original Author: Arnaud Lelievre (for Garden); * Contributor(s): David Gilbert (for Object Refinery Limited); * Zoheb Borbora; * * Changes * ------- * 28-Aug-2003 : Version 1 (AL); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 21-Oct-2003 : Bar width moved to renderer state (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 17-Nov-2005 : Added support for gradient paint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-Aug-2006 : Fixed the bar width calculation to respect the maximum bar * width setting (thanks to Zoheb Borbora) (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.renderer.category; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectList; /** * A {@link CategoryItemRenderer} that represents data using bars which are * superimposed. The example shown here is generated by the * LayeredBarChartDemo1.java program included in the JFreeChart * Demo Collection: *

* LayeredBarRendererSample.png */ public class LayeredBarRenderer extends BarRenderer implements Serializable { /** For serialization. */ private static final long serialVersionUID = -8716572894780469487L; /** A list of the width of each series bar. */ protected ObjectList seriesBarWidthList; /** * Default constructor. */ public LayeredBarRenderer() { super(); this.seriesBarWidthList = new ObjectList(); } /** * Returns the bar width for a series, or Double.NaN if no * width has been set. * * @param series the series index (zero based). * * @return The width for the series (1.0=100%, it is the maximum). */ public double getSeriesBarWidth(int series) { double result = Double.NaN; Number n = (Number) this.seriesBarWidthList.get(series); if (n != null) { result = n.doubleValue(); } return result; } /** * Sets the width of the bars of a series. * * @param series the series index (zero based). * @param width the width of the series bar in percentage (1.0=100%, it is * the maximum). */ public void setSeriesBarWidth(int series, double width) { this.seriesBarWidthList.set(series, new Double(width)); } /** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { // calculate the bar width - this calculation differs from the // BarRenderer calculation because the bars are layered on top of one // another, so there is effectively only one bar per category for // the purpose of the bar width calculation CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (dataset.getColumnCount()), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } } /** * Draws the bar for one item in the dataset. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the plot area. * @param plot the plot. * @param domainAxis the domain (category) axis. * @param rangeAxis the range (value) axis. * @param data the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset data, int row, int column, int pass) { PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { drawHorizontalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, data, row, column); } else if (orientation == PlotOrientation.VERTICAL) { drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, data, row, column); } } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } // X double value = dataValue.doubleValue(); double base = 0.0; double lclip = getLowerClip(); double uclip = getUpperClip(); if (uclip <= 0.0) { // cases 1, 2, 3 and 4 if (value >= uclip) { return; // bar is not visible } base = uclip; if (value <= lclip) { value = lclip; } } else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 if (value >= uclip) { value = uclip; } else { if (value <= lclip) { value = lclip; } } } else { // cases 9, 10, 11 and 12 if (value <= lclip) { return; // bar is not visible } base = lclip; if (value >= uclip) { value = uclip; } } RectangleEdge edge = plot.getRangeAxisEdge(); double transX1 = rangeAxis.valueToJava2D(base, dataArea, edge); double transX2 = rangeAxis.valueToJava2D(value, dataArea, edge); double rectX = Math.min(transX1, transX2); double rectWidth = Math.abs(transX2 - transX1); // Y double rectY = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; int seriesCount = getRowCount(); // draw the bar... double shift = 0.0; double rectHeight = 0.0; double widthFactor = 1.0; double seriesBarWidth = getSeriesBarWidth(row); if (!Double.isNaN(seriesBarWidth)) { widthFactor = seriesBarWidth; } rectHeight = widthFactor * state.getBarWidth(); rectY = rectY + (1 - widthFactor) * state.getBarWidth() / 2.0; if (seriesCount > 1) { shift = rectHeight * 0.20 / (seriesCount - 1); } Rectangle2D bar = new Rectangle2D.Double(rectX, (rectY + ((seriesCount - 1 - row) * shift)), rectWidth, (rectHeight - (seriesCount - 1 - row) * shift * 2)); Paint itemPaint = getItemPaint(row, column); GradientPaintTransformer t = getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (transX1 > transX2)); } // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } // BAR X double rectX = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; int seriesCount = getRowCount(); // BAR Y double value = dataValue.doubleValue(); double base = 0.0; double lclip = getLowerClip(); double uclip = getUpperClip(); if (uclip <= 0.0) { // cases 1, 2, 3 and 4 if (value >= uclip) { return; // bar is not visible } base = uclip; if (value <= lclip) { value = lclip; } } else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 if (value >= uclip) { value = uclip; } else { if (value <= lclip) { value = lclip; } } } else { // cases 9, 10, 11 and 12 if (value <= lclip) { return; // bar is not visible } base = getLowerClip(); if (value >= uclip) { value = uclip; } } RectangleEdge edge = plot.getRangeAxisEdge(); double transY1 = rangeAxis.valueToJava2D(base, dataArea, edge); double transY2 = rangeAxis.valueToJava2D(value, dataArea, edge); double rectY = Math.min(transY2, transY1); double rectWidth = state.getBarWidth(); double rectHeight = Math.abs(transY2 - transY1); // draw the bar... double shift = 0.0; rectWidth = 0.0; double widthFactor = 1.0; double seriesBarWidth = getSeriesBarWidth(row); if (!Double.isNaN(seriesBarWidth)) { widthFactor = seriesBarWidth; } rectWidth = widthFactor * state.getBarWidth(); rectX = rectX + (1 - widthFactor) * state.getBarWidth() / 2.0; if (seriesCount > 1) { // needs to be improved !!! shift = rectWidth * 0.20 / (seriesCount - 1); } Rectangle2D bar = new Rectangle2D.Double( (rectX + ((seriesCount - 1 - row) * shift)), rectY, (rectWidth - (seriesCount - 1 - row) * shift * 2), rectHeight); Paint itemPaint = getItemPaint(row, column); GradientPaintTransformer t = getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } // draw the item labels if there are any... double transX1 = rangeAxis.valueToJava2D(base, dataArea, edge); double transX2 = rangeAxis.valueToJava2D(value, dataArea, edge); CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (transX1 > transX2)); } // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/LevelRenderer.java0000644000175000017500000004206311173030414031462 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * LevelRenderer.java * ------------------ * (C) Copyright 2004-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Peter Kolb (patch 2511330); * * Changes * ------- * 09-Jan-2004 : Version 1 (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 23-Jan-2006 : Renamed getMaxItemWidth() --> getMaximumItemWidth() (DG); * 13-May-2008 : Code clean-up (DG); * 26-Jun-2008 : Added crosshair support (DG); * 23-Jan-2009 : Set more appropriate default shape in legend (DG); * 23-Jan-2009 : Added support for seriesVisible flags - see patch * 2511330 (PK) * */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.data.category.CategoryDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A {@link CategoryItemRenderer} that draws individual data items as * horizontal lines, spaced in the same way as bars in a bar chart. The * example shown here is generated by the * OverlaidBarChartDemo2.java program included in the JFreeChart * Demo Collection: *

* LevelRendererSample.png */ public class LevelRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8204856624355025117L; /** The default item margin percentage. */ public static final double DEFAULT_ITEM_MARGIN = 0.20; /** The margin between items within a category. */ private double itemMargin; /** The maximum item width as a percentage of the available space. */ private double maxItemWidth; /** * Creates a new renderer with default settings. */ public LevelRenderer() { super(); this.itemMargin = DEFAULT_ITEM_MARGIN; this.maxItemWidth = 1.0; // 100 percent, so it will not apply unless // changed setBaseLegendShape(new Rectangle2D.Float(-5.0f, -1.0f, 10.0f, 2.0f)); // set the outline paint to fully transparent, then the legend shape // will just have the same colour as the lines drawn by the renderer setBaseOutlinePaint(new Color(0, 0, 0, 0)); } /** * Returns the item margin. * * @return The margin. * * @see #setItemMargin(double) */ public double getItemMargin() { return this.itemMargin; } /** * Sets the item margin and sends a {@link RendererChangeEvent} to all * registered listeners. The value is expressed as a percentage of the * available width for plotting all the bars, with the resulting amount to * be distributed between all the bars evenly. * * @param percent the new margin. * * @see #getItemMargin() */ public void setItemMargin(double percent) { this.itemMargin = percent; fireChangeEvent(); } /** * Returns the maximum width, as a percentage of the available drawing * space. * * @return The maximum width. * * @see #setMaximumItemWidth(double) */ public double getMaximumItemWidth() { return getMaxItemWidth(); } /** * Sets the maximum item width, which is specified as a percentage of the * available space for all items, and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param percent the percent. * * @see #getMaximumItemWidth() */ public void setMaximumItemWidth(double percent) { setMaxItemWidth(percent); } /** * Initialises the renderer and returns a state object that will be passed * to subsequent calls to the drawItem method. *

* This method gets called once at the start of the process of drawing a * chart. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be plotted. * @param plot the plot. * @param rendererIndex the renderer index. * @param info collects chart rendering information for return to caller. * * @return The renderer state. */ public CategoryItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, PlotRenderingInfo info) { CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info); calculateItemWidth(plot, dataArea, rendererIndex, state); return state; } /** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateItemWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset dataset = plot.getDataset(rendererIndex); if (dataset != null) { int columns = dataset.getColumnCount(); int rows = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : dataset.getRowCount(); double space = 0.0; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumItemWidth(); double categoryMargin = 0.0; double currentItemMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } if (rows > 1) { currentItemMargin = getItemMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin - currentItemMargin); if ((rows * columns) > 0) { state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } } /** * Calculates the coordinate of the first "side" of a bar. This will be * the minimum x-coordinate for a vertical bar, and the minimum * y-coordinate for a horizontal bar. * * @param plot the plot. * @param orientation the plot orientation. * @param dataArea the data area. * @param domainAxis the domain axis. * @param state the renderer state (has the bar width precalculated). * @param row the row index. * @param column the column index. * * @return The coordinate. */ protected double calculateBarW0(CategoryPlot plot, PlotOrientation orientation, Rectangle2D dataArea, CategoryAxis domainAxis, CategoryItemRendererState state, int row, int column) { // calculate bar width... double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else { space = dataArea.getWidth(); } double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); int seriesCount = state.getVisibleSeriesCount(); if (seriesCount < 0) { seriesCount = getRowCount(); } int categoryCount = getColumnCount(); if (seriesCount > 1) { double seriesGap = space * getItemMargin() / (categoryCount * (seriesCount - 1)); double seriesW = calculateSeriesWidth(space, domainAxis, categoryCount, seriesCount); barW0 = barW0 + row * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0); } else { barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; } return barW0; } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // nothing is drawn if the row index is not included in the list with // the indices of the visible rows... int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, state, visibleRow, column); RectangleEdge edge = plot.getRangeAxisEdge(); double barL = rangeAxis.valueToJava2D(value, dataArea, edge); // draw the bar... Line2D line = null; double x = 0.0; double y = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { x = barL; y = barW0 + state.getBarWidth() / 2.0; line = new Line2D.Double(barL, barW0, barL, barW0 + state.getBarWidth()); } else { x = barW0 + state.getBarWidth() / 2.0; y = barL; line = new Line2D.Double(barW0, barL, barW0 + state.getBarWidth(), barL); } Stroke itemStroke = getItemStroke(row, column); Paint itemPaint = getItemPaint(row, column); g2.setStroke(itemStroke); g2.setPaint(itemPaint); g2.draw(line); CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, orientation, dataset, row, column, x, y, (value < 0.0)); } // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value, datasetIndex, barW0, barL, orientation); // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, line.getBounds()); } } /** * Calculates the available space for each series. * * @param space the space along the entire axis (in Java2D units). * @param axis the category axis. * @param categories the number of categories. * @param series the number of series. * * @return The width of one series. */ protected double calculateSeriesWidth(double space, CategoryAxis axis, int categories, int series) { double factor = 1.0 - getItemMargin() - axis.getLowerMargin() - axis.getUpperMargin(); if (categories > 1) { factor = factor - axis.getCategoryMargin(); } return (space * factor) / (categories * series); } /** * Returns the Java2D coordinate for the middle of the specified data item. * * @param rowKey the row key. * @param columnKey the column key. * @param dataset the dataset. * @param axis the axis. * @param area the drawing area. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate. * * @since 1.0.11 */ public double getItemMiddle(Comparable rowKey, Comparable columnKey, CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, RectangleEdge edge) { return axis.getCategorySeriesMiddle(columnKey, rowKey, dataset, this.itemMargin, area, edge); } /** * Tests an object for equality with this instance. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LevelRenderer)) { return false; } LevelRenderer that = (LevelRenderer) obj; if (this.itemMargin != that.itemMargin) { return false; } if (this.maxItemWidth != that.maxItemWidth) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = super.hashCode(); hash = HashUtilities.hashCode(hash, this.itemMargin); hash = HashUtilities.hashCode(hash, this.maxItemWidth); return hash; } /** * Returns the maximum width, as a percentage of the available drawing * space. * * @return The maximum width. * * @deprecated Use {@link #getMaximumItemWidth()} instead. */ public double getMaxItemWidth() { return this.maxItemWidth; } /** * Sets the maximum item width, which is specified as a percentage of the * available space for all items, and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param percent the percent. * * @deprecated Use {@link #setMaximumItemWidth(double)} instead. */ public void setMaxItemWidth(double percent) { this.maxItemWidth = percent; fireChangeEvent(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java0000644000175000017500000011306411173030414032706 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * LineAndShapeRenderer.java * ------------------------- * (C) Copyright 2001-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Mark Watson (www.markwatson.com); * Jeremy Bowman; * Richard Atkinson; * Christian W. Zuckschwerdt; * Peter Kolb (patch 2497611); * * Changes * ------- * 23-Oct-2001 : Version 1 (DG); * 15-Nov-2001 : Modified to allow for null data values (DG); * 16-Jan-2002 : Renamed HorizontalCategoryItemRenderer.java * --> CategoryItemRenderer.java (DG); * 05-Feb-2002 : Changed return type of the drawCategoryItem method from void * to Shape, as part of the tooltips implementation (DG); * 11-May-2002 : Support for value label drawing (JB); * 29-May-2002 : Now extends AbstractCategoryItemRenderer (DG); * 25-Jun-2002 : Removed redundant import (DG); * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs * for HTML image maps (RA); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 11-Oct-2002 : Added new constructor to incorporate tool tip and URL * generators (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 06-Nov-2002 : Renamed drawCategoryItem() --> drawItem() and now using axis * for category spacing (DG); * 17-Jan-2003 : Moved plot classes to a separate package (DG); * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in drawItem() * method (DG); * 12-May-2003 : Modified to take into account the plot orientation (DG); * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 22-Sep-2003 : Fixed cloning (DG); * 10-Feb-2004 : Small change to drawItem() method to make cut-and-paste * override easier (DG); * 16-Jun-2004 : Fixed bug (id=972454) with label positioning on horizontal * charts (DG); * 15-Oct-2004 : Updated equals() method (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 11-Nov-2004 : Now uses ShapeUtilities class to translate shapes (DG); * 27-Jan-2005 : Changed attribute names, modified constructor and removed * constants (DG); * 01-Feb-2005 : Removed unnecessary constants (DG); * 15-Mar-2005 : Fixed bug 1163897, concerning outlines for shapes (DG); * 13-Apr-2005 : Check flags that control series visibility (DG); * 20-Apr-2005 : Use generators for legend labels, tooltips and URLs (DG); * 09-Jun-2005 : Use addItemEntity() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 25-May-2006 : Added check to drawItem() to detect when both the line and * the shape are not visible (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 24-Sep-2007 : Deprecated redundant fields/methods (DG); * 27-Sep-2007 : Added option to offset series x-position within category (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 26-Jun-2008 : Added crosshair support (DG); * 14-Jan-2009 : Added support for seriesVisible flags (PK); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.util.BooleanList; import org.jfree.util.BooleanUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that draws shapes for each data item, and lines between data * items (for use with the {@link CategoryPlot} class). * The example shown here is generated by the LineChartDemo1.java * program included in the JFreeChart Demo Collection: *

* LineAndShapeRendererSample.png */ public class LineAndShapeRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -197749519869226398L; /** * A flag that controls whether or not lines are visible for ALL series. * * @deprecated As of 1.0.7 (this override flag is unnecessary). */ private Boolean linesVisible; /** * A table of flags that control (per series) whether or not lines are * visible. */ private BooleanList seriesLinesVisible; /** * A flag indicating whether or not lines are drawn between non-null * points. */ private boolean baseLinesVisible; /** * A flag that controls whether or not shapes are visible for ALL series. * * @deprecated As of 1.0.7 (this override flag is unnecessary). */ private Boolean shapesVisible; /** * A table of flags that control (per series) whether or not shapes are * visible. */ private BooleanList seriesShapesVisible; /** The default value returned by the getShapeVisible() method. */ private boolean baseShapesVisible; /** * A flag that controls whether or not shapes are filled for ALL series. * * @deprecated As of 1.0.7 (this override flag is unnecessary). */ private Boolean shapesFilled; /** * A table of flags that control (per series) whether or not shapes are * filled. */ private BooleanList seriesShapesFilled; /** The default value returned by the getShapeFilled() method. */ private boolean baseShapesFilled; /** * A flag that controls whether the fill paint is used for filling * shapes. */ private boolean useFillPaint; /** A flag that controls whether outlines are drawn for shapes. */ private boolean drawOutlines; /** * A flag that controls whether the outline paint is used for drawing shape * outlines - if not, the regular series paint is used. */ private boolean useOutlinePaint; /** * A flag that controls whether or not the x-position for each item is * offset within the category according to the series. * * @since 1.0.7 */ private boolean useSeriesOffset; /** * The item margin used for series offsetting - this allows the positioning * to match the bar positions of the {@link BarRenderer} class. * * @since 1.0.7 */ private double itemMargin; /** * Creates a renderer with both lines and shapes visible by default. */ public LineAndShapeRenderer() { this(true, true); } /** * Creates a new renderer with lines and/or shapes visible. * * @param lines draw lines? * @param shapes draw shapes? */ public LineAndShapeRenderer(boolean lines, boolean shapes) { super(); this.linesVisible = null; this.seriesLinesVisible = new BooleanList(); this.baseLinesVisible = lines; this.shapesVisible = null; this.seriesShapesVisible = new BooleanList(); this.baseShapesVisible = shapes; this.shapesFilled = null; this.seriesShapesFilled = new BooleanList(); this.baseShapesFilled = true; this.useFillPaint = false; this.drawOutlines = true; this.useOutlinePaint = false; this.useSeriesOffset = false; // preserves old behaviour this.itemMargin = 0.0; } // LINES VISIBLE /** * Returns the flag used to control whether or not the line for an item is * visible. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. */ public boolean getItemLineVisible(int series, int item) { Boolean flag = this.linesVisible; if (flag == null) { flag = getSeriesLinesVisible(series); } if (flag != null) { return flag.booleanValue(); } else { return this.baseLinesVisible; } } /** * Returns a flag that controls whether or not lines are drawn for ALL * series. If this flag is null, then the "per series" * settings will apply. * * @return A flag (possibly null). * * @see #setLinesVisible(Boolean) * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public Boolean getLinesVisible() { return this.linesVisible; } /** * Sets a flag that controls whether or not lines are drawn between the * items in ALL series, and sends a {@link RendererChangeEvent} to all * registered listeners. You need to set this to null if you * want the "per series" settings to apply. * * @param visible the flag (null permitted). * * @see #getLinesVisible() * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public void setLinesVisible(Boolean visible) { this.linesVisible = visible; fireChangeEvent(); } /** * Sets a flag that controls whether or not lines are drawn between the * items in ALL series, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param visible the flag. * * @see #getLinesVisible() * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public void setLinesVisible(boolean visible) { setLinesVisible(BooleanUtilities.valueOf(visible)); } /** * Returns the flag used to control whether or not the lines for a series * are visible. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesLinesVisible(int, Boolean) */ public Boolean getSeriesLinesVisible(int series) { return this.seriesLinesVisible.getBoolean(series); } /** * Sets the 'lines visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag (null permitted). * * @see #getSeriesLinesVisible(int) */ public void setSeriesLinesVisible(int series, Boolean flag) { this.seriesLinesVisible.setBoolean(series, flag); fireChangeEvent(); } /** * Sets the 'lines visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag. * * @see #getSeriesLinesVisible(int) */ public void setSeriesLinesVisible(int series, boolean visible) { setSeriesLinesVisible(series, BooleanUtilities.valueOf(visible)); } /** * Returns the base 'lines visible' attribute. * * @return The base flag. * * @see #getBaseLinesVisible() */ public boolean getBaseLinesVisible() { return this.baseLinesVisible; } /** * Sets the base 'lines visible' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseLinesVisible() */ public void setBaseLinesVisible(boolean flag) { this.baseLinesVisible = flag; fireChangeEvent(); } // SHAPES VISIBLE /** * Returns the flag used to control whether or not the shape for an item is * visible. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. */ public boolean getItemShapeVisible(int series, int item) { Boolean flag = this.shapesVisible; if (flag == null) { flag = getSeriesShapesVisible(series); } if (flag != null) { return flag.booleanValue(); } else { return this.baseShapesVisible; } } /** * Returns the flag that controls whether the shapes are visible for the * items in ALL series. * * @return The flag (possibly null). * * @see #setShapesVisible(Boolean) * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public Boolean getShapesVisible() { return this.shapesVisible; } /** * Sets the 'shapes visible' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag (null permitted). * * @see #getShapesVisible() * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public void setShapesVisible(Boolean visible) { this.shapesVisible = visible; fireChangeEvent(); } /** * Sets the 'shapes visible' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getShapesVisible() * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public void setShapesVisible(boolean visible) { setShapesVisible(BooleanUtilities.valueOf(visible)); } /** * Returns the flag used to control whether or not the shapes for a series * are visible. * * @param series the series index (zero-based). * * @return A boolean. * * @see #setSeriesShapesVisible(int, Boolean) */ public Boolean getSeriesShapesVisible(int series) { return this.seriesShapesVisible.getBoolean(series); } /** * Sets the 'shapes visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag. * * @see #getSeriesShapesVisible(int) */ public void setSeriesShapesVisible(int series, boolean visible) { setSeriesShapesVisible(series, BooleanUtilities.valueOf(visible)); } /** * Sets the 'shapes visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag. * * @see #getSeriesShapesVisible(int) */ public void setSeriesShapesVisible(int series, Boolean flag) { this.seriesShapesVisible.setBoolean(series, flag); fireChangeEvent(); } /** * Returns the base 'shape visible' attribute. * * @return The base flag. * * @see #setBaseShapesVisible(boolean) */ public boolean getBaseShapesVisible() { return this.baseShapesVisible; } /** * Sets the base 'shapes visible' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseShapesVisible() */ public void setBaseShapesVisible(boolean flag) { this.baseShapesVisible = flag; fireChangeEvent(); } /** * Returns true if outlines should be drawn for shapes, and * false otherwise. * * @return A boolean. * * @see #setDrawOutlines(boolean) */ public boolean getDrawOutlines() { return this.drawOutlines; } /** * Sets the flag that controls whether outlines are drawn for * shapes, and sends a {@link RendererChangeEvent} to all registered * listeners. *

* In some cases, shapes look better if they do NOT have an outline, but * this flag allows you to set your own preference. * * @param flag the flag. * * @see #getDrawOutlines() */ public void setDrawOutlines(boolean flag) { this.drawOutlines = flag; fireChangeEvent(); } /** * Returns the flag that controls whether the outline paint is used for * shape outlines. If not, the regular series paint is used. * * @return A boolean. * * @see #setUseOutlinePaint(boolean) */ public boolean getUseOutlinePaint() { return this.useOutlinePaint; } /** * Sets the flag that controls whether the outline paint is used for shape * outlines, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param use the flag. * * @see #getUseOutlinePaint() */ public void setUseOutlinePaint(boolean use) { this.useOutlinePaint = use; fireChangeEvent(); } // SHAPES FILLED /** * Returns the flag used to control whether or not the shape for an item * is filled. The default implementation passes control to the * getSeriesShapesFilled method. You can override this method * if you require different behaviour. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. */ public boolean getItemShapeFilled(int series, int item) { return getSeriesShapesFilled(series); } /** * Returns the flag used to control whether or not the shapes for a series * are filled. * * @param series the series index (zero-based). * * @return A boolean. */ public boolean getSeriesShapesFilled(int series) { // return the overall setting, if there is one... if (this.shapesFilled != null) { return this.shapesFilled.booleanValue(); } // otherwise look up the paint table Boolean flag = this.seriesShapesFilled.getBoolean(series); if (flag != null) { return flag.booleanValue(); } else { return this.baseShapesFilled; } } /** * Returns the flag that controls whether or not shapes are filled for * ALL series. * * @return A Boolean. * * @see #setShapesFilled(Boolean) * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public Boolean getShapesFilled() { return this.shapesFilled; } /** * Sets the 'shapes filled' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param filled the flag. * * @see #getShapesFilled() * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public void setShapesFilled(boolean filled) { if (filled) { setShapesFilled(Boolean.TRUE); } else { setShapesFilled(Boolean.FALSE); } } /** * Sets the 'shapes filled' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param filled the flag (null permitted). * * @see #getShapesFilled() * * @deprecated As of 1.0.7 (the override facility is unnecessary, just * use the per-series and base (default) settings). */ public void setShapesFilled(Boolean filled) { this.shapesFilled = filled; fireChangeEvent(); } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param filled the flag. * * @see #getSeriesShapesFilled(int) */ public void setSeriesShapesFilled(int series, Boolean filled) { this.seriesShapesFilled.setBoolean(series, filled); fireChangeEvent(); } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param filled the flag. * * @see #getSeriesShapesFilled(int) */ public void setSeriesShapesFilled(int series, boolean filled) { // delegate setSeriesShapesFilled(series, BooleanUtilities.valueOf(filled)); } /** * Returns the base 'shape filled' attribute. * * @return The base flag. * * @see #setBaseShapesFilled(boolean) */ public boolean getBaseShapesFilled() { return this.baseShapesFilled; } /** * Sets the base 'shapes filled' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseShapesFilled() */ public void setBaseShapesFilled(boolean flag) { this.baseShapesFilled = flag; fireChangeEvent(); } /** * Returns true if the renderer should use the fill paint * setting to fill shapes, and false if it should just * use the regular paint. * * @return A boolean. * * @see #setUseFillPaint(boolean) */ public boolean getUseFillPaint() { return this.useFillPaint; } /** * Sets the flag that controls whether the fill paint is used to fill * shapes, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param flag the flag. * * @see #getUseFillPaint() */ public void setUseFillPaint(boolean flag) { this.useFillPaint = flag; fireChangeEvent(); } /** * Returns the flag that controls whether or not the x-position for each * data item is offset within the category according to the series. * * @return A boolean. * * @see #setUseSeriesOffset(boolean) * * @since 1.0.7 */ public boolean getUseSeriesOffset() { return this.useSeriesOffset; } /** * Sets the flag that controls whether or not the x-position for each * data item is offset within its category according to the series, and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param offset the offset. * * @see #getUseSeriesOffset() * * @since 1.0.7 */ public void setUseSeriesOffset(boolean offset) { this.useSeriesOffset = offset; fireChangeEvent(); } /** * Returns the item margin, which is the gap between items within a * category (expressed as a percentage of the overall category width). * This can be used to match the offset alignment with the bars drawn by * a {@link BarRenderer}). * * @return The item margin. * * @see #setItemMargin(double) * @see #getUseSeriesOffset() * * @since 1.0.7 */ public double getItemMargin() { return this.itemMargin; } /** * Sets the item margin, which is the gap between items within a category * (expressed as a percentage of the overall category width), and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param margin the margin (0.0 <= margin < 1.0). * * @see #getItemMargin() * @see #getUseSeriesOffset() * * @since 1.0.7 */ public void setItemMargin(double margin) { if (margin < 0.0 || margin >= 1.0) { throw new IllegalArgumentException("Requires 0.0 <= margin < 1.0."); } this.itemMargin = margin; fireChangeEvent(); } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint fillPaint = (this.useFillPaint ? getItemFillPaint(series, 0) : paint); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? getItemOutlinePaint(series, 0) : paint); Stroke outlineStroke = lookupSeriesOutlineStroke(series); boolean lineVisible = getItemLineVisible(series, 0); boolean shapeVisible = getItemShapeVisible(series, 0); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeVisible, shape, getItemShapeFilled(series, 0), fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), getItemStroke(series, 0), getItemPaint(series, 0)); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } return null; } /** * This renderer uses two passes to draw the data. * * @return The pass count (2 for this renderer). */ public int getPassCount() { return 2; } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // do nothing if item is not visible if (!getItemVisible(row, column)) { return; } // do nothing if both the line and shape are not visible if (!getItemLineVisible(row, column) && !getItemShapeVisible(row, column)) { return; } // nothing is drawn for null... Number v = dataset.getValue(row, column); if (v == null) { return; } int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } int visibleRowCount = state.getVisibleSeriesCount(); PlotOrientation orientation = plot.getOrientation(); // current data point... double x1; if (this.useSeriesOffset) { x1 = domainAxis.getCategorySeriesMiddle(column, dataset.getColumnCount(), visibleRow, visibleRowCount, this.itemMargin, dataArea, plot.getDomainAxisEdge()); } else { x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double value = v.doubleValue(); double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); if (pass == 0 && getItemLineVisible(row, column)) { if (column != 0) { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0; if (this.useSeriesOffset) { x0 = domainAxis.getCategorySeriesMiddle( column - 1, dataset.getColumnCount(), visibleRow, visibleRowCount, this.itemMargin, dataArea, plot.getDomainAxisEdge()); } else { x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(y0, x0, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(x0, y0, x1, y1); } g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); g2.draw(line); } } } if (pass == 1) { Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); } if (getItemShapeVisible(row, column)) { if (getItemShapeFilled(row, column)) { if (this.useFillPaint) { g2.setPaint(getItemFillPaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.fill(shape); } if (this.drawOutlines) { if (this.useOutlinePaint) { g2.setPaint(getItemOutlinePaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.setStroke(getItemOutlineStroke(row, column)); g2.draw(shape); } } // draw the item label if there is one... if (isItemLabelVisible(row, column)) { if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (value < 0.0)); } else if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value < 0.0)); } } // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value, datasetIndex, x1, y1, orientation); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, shape); } } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LineAndShapeRenderer)) { return false; } LineAndShapeRenderer that = (LineAndShapeRenderer) obj; if (this.baseLinesVisible != that.baseLinesVisible) { return false; } if (!ObjectUtilities.equal(this.seriesLinesVisible, that.seriesLinesVisible)) { return false; } if (!ObjectUtilities.equal(this.linesVisible, that.linesVisible)) { return false; } if (this.baseShapesVisible != that.baseShapesVisible) { return false; } if (!ObjectUtilities.equal(this.seriesShapesVisible, that.seriesShapesVisible)) { return false; } if (!ObjectUtilities.equal(this.shapesVisible, that.shapesVisible)) { return false; } if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) { return false; } if (!ObjectUtilities.equal(this.seriesShapesFilled, that.seriesShapesFilled)) { return false; } if (this.baseShapesFilled != that.baseShapesFilled) { return false; } if (this.useOutlinePaint != that.useOutlinePaint) { return false; } if (this.useSeriesOffset != that.useSeriesOffset) { return false; } if (this.itemMargin != that.itemMargin) { return false; } return super.equals(obj); } /** * Returns an independent copy of the renderer. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { LineAndShapeRenderer clone = (LineAndShapeRenderer) super.clone(); clone.seriesLinesVisible = (BooleanList) this.seriesLinesVisible.clone(); clone.seriesShapesVisible = (BooleanList) this.seriesShapesVisible.clone(); clone.seriesShapesFilled = (BooleanList) this.seriesShapesFilled.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/LineRenderer3D.java0000644000175000017500000005651411173030414031477 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * LineRenderer3D.java * ------------------- * (C) Copyright 2004-2008, by Tobias Selb and Contributors. * * Original Author: Tobias Selb (http://www.uepselon.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 15-Oct-2004 : Version 1 (TS); * 05-Nov-2004 : Modified drawItem() signature (DG); * 11-Nov-2004 : Now uses ShapeUtilities class to translate shapes (DG); * 26-Jan-2005 : Update for changes in super class (DG); * 13-Apr-2005 : Check item visibility in drawItem() method (DG); * 09-Jun-2005 : Use addItemEntity() in drawItem() method (DG); * 10-Jun-2005 : Fixed capitalisation of setXOffset() and setYOffset() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Dec-2006 : Fixed equals() and serialization (DG); * 17-Jan-2007 : Fixed bug in drawDomainGridline() method and added * argument check to setWallPaint() (DG); * 03-Apr-2007 : Fixed bugs in drawBackground() method (DG); * 16-Oct-2007 : Fixed bug in range marker drawing (DG); * */ package org.jfree.chart.renderer.category; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.Effect3D; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.ValueMarker; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.ShapeUtilities; /** * A line renderer with a 3D effect. The example shown here is generated by * the LineChart3DDemo1.java program included in the JFreeChart * Demo Collection: *

* LineRenderer3DSample.png */ public class LineRenderer3D extends LineAndShapeRenderer implements Effect3D, Serializable { /** For serialization. */ private static final long serialVersionUID = 5467931468380928736L; /** The default x-offset for the 3D effect. */ public static final double DEFAULT_X_OFFSET = 12.0; /** The default y-offset for the 3D effect. */ public static final double DEFAULT_Y_OFFSET = 8.0; /** The default wall paint. */ public static final Paint DEFAULT_WALL_PAINT = new Color(0xDD, 0xDD, 0xDD); /** The size of x-offset for the 3D effect. */ private double xOffset; /** The size of y-offset for the 3D effect. */ private double yOffset; /** The paint used to shade the left and lower 3D wall. */ private transient Paint wallPaint; /** * Creates a new renderer. */ public LineRenderer3D() { super(true, false); //Create a line renderer only this.xOffset = DEFAULT_X_OFFSET; this.yOffset = DEFAULT_Y_OFFSET; this.wallPaint = DEFAULT_WALL_PAINT; } /** * Returns the x-offset for the 3D effect. * * @return The x-offset. * * @see #setXOffset(double) * @see #getYOffset() */ public double getXOffset() { return this.xOffset; } /** * Returns the y-offset for the 3D effect. * * @return The y-offset. * * @see #setYOffset(double) * @see #getXOffset() */ public double getYOffset() { return this.yOffset; } /** * Sets the x-offset and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param xOffset the x-offset. * * @see #getXOffset() */ public void setXOffset(double xOffset) { this.xOffset = xOffset; fireChangeEvent(); } /** * Sets the y-offset and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param yOffset the y-offset. * * @see #getYOffset() */ public void setYOffset(double yOffset) { this.yOffset = yOffset; fireChangeEvent(); } /** * Returns the paint used to highlight the left and bottom wall in the plot * background. * * @return The paint. * * @see #setWallPaint(Paint) */ public Paint getWallPaint() { return this.wallPaint; } /** * Sets the paint used to hightlight the left and bottom walls in the plot * background, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getWallPaint() */ public void setWallPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.wallPaint = paint; fireChangeEvent(); } /** * Draws the background for the plot. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area inside the axes. */ public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(this.xOffset); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(this.xOffset); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(this.yOffset); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(this.yOffset); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0); clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getBackgroundAlpha())); // fill background... Paint backgroundPaint = plot.getBackgroundPaint(); if (backgroundPaint != null) { g2.setPaint(backgroundPaint); g2.fill(clip); } GeneralPath leftWall = new GeneralPath(); leftWall.moveTo(x0, y0); leftWall.lineTo(x0, y2); leftWall.lineTo(x1, y3); leftWall.lineTo(x1, y1); leftWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(leftWall); GeneralPath bottomWall = new GeneralPath(); bottomWall.moveTo(x0, y0); bottomWall.lineTo(x1, y1); bottomWall.lineTo(x3, y1); bottomWall.lineTo(x2, y0); bottomWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(bottomWall); // higlight the background corners... g2.setPaint(Color.lightGray); Line2D corner = new Line2D.Double(x0, y0, x1, y1); g2.draw(corner); corner.setLine(x1, y1, x1, y3); g2.draw(corner); corner.setLine(x1, y1, x3, y1); g2.draw(corner); // draw background image, if there is one... Image backgroundImage = plot.getBackgroundImage(); if (backgroundImage != null) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + getXOffset(), dataArea.getY(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); plot.drawBackgroundImage(g2, adjusted); } g2.setComposite(originalComposite); } /** * Draws the outline for the plot. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area inside the axes. */ public void drawOutline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(this.xOffset); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(this.xOffset); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(this.yOffset); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(this.yOffset); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0); clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); // put an outline around the data area... Stroke outlineStroke = plot.getOutlineStroke(); Paint outlinePaint = plot.getOutlinePaint(); if ((outlineStroke != null) && (outlinePaint != null)) { g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(clip); } } /** * Draws a grid line against the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. * */ public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) { Line2D line1 = null; Line2D line2 = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { double y0 = value; double y1 = value - getYOffset(); double x0 = dataArea.getMinX(); double x1 = x0 + getXOffset(); double x2 = dataArea.getMaxX(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x2, y1); } else if (orientation == PlotOrientation.VERTICAL) { double x0 = value; double x1 = value + getXOffset(); double y0 = dataArea.getMaxY(); double y1 = y0 - getYOffset(); double y2 = dataArea.getMinY(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x1, y2); } g2.setPaint(plot.getDomainGridlinePaint()); g2.setStroke(plot.getDomainGridlineStroke()); g2.draw(line1); g2.draw(line2); } /** * Draws a grid line against the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value at which the grid line should be drawn. * */ public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Rectangle2D dataArea, double value) { Range range = axis.getRange(); if (!range.contains(value)) { return; } Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); Line2D line1 = null; Line2D line2 = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { double x0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double x1 = x0 + getXOffset(); double y0 = dataArea.getMaxY(); double y1 = y0 - getYOffset(); double y2 = dataArea.getMinY(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x1, y2); } else if (orientation == PlotOrientation.VERTICAL) { double y0 = axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); double y1 = y0 - getYOffset(); double x0 = dataArea.getMinX(); double x1 = x0 + getXOffset(); double x2 = dataArea.getMaxX(); line1 = new Line2D.Double(x0, y0, x1, y1); line2 = new Line2D.Double(x1, y1, x2, y1); } g2.setPaint(plot.getRangeGridlinePaint()); g2.setStroke(plot.getRangeGridlineStroke()); g2.draw(line1); g2.draw(line2); } /** * Draws a range marker. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param marker the marker. * @param dataArea the area for plotting data (not including 3D effect). */ public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = axis.getRange(); if (!range.contains(value)) { return; } GeneralPath path = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { float x = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); float y = (float) adjusted.getMaxY(); path = new GeneralPath(); path.moveTo(x, y); path.lineTo((float) (x + getXOffset()), y - (float) getYOffset()); path.lineTo((float) (x + getXOffset()), (float) (adjusted.getMinY() - getYOffset())); path.lineTo(x, (float) adjusted.getMinY()); path.closePath(); } else if (orientation == PlotOrientation.VERTICAL) { float y = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); float x = (float) dataArea.getX(); path = new GeneralPath(); path.moveTo(x, y); path.lineTo(x + (float) this.xOffset, y - (float) this.yOffset); path.lineTo((float) (adjusted.getMaxX() + this.xOffset), y - (float) this.yOffset); path.lineTo((float) (adjusted.getMaxX()), y); path.closePath(); } g2.setPaint(marker.getPaint()); g2.fill(path); g2.setPaint(marker.getOutlinePaint()); g2.draw(path); } else { super.drawRangeMarker(g2, plot, axis, marker, adjusted); // TODO: draw the interval marker with a 3D effect } } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { if (!getItemVisible(row, column)) { return; } // nothing is drawn for null... Number v = dataset.getValue(row, column); if (v == null) { return; } Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); // current data point... double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), adjusted, plot.getDomainAxisEdge()); double value = v.doubleValue(); double y1 = rangeAxis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge()); Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); } if (getItemLineVisible(row, column)) { if (column != 0) { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), adjusted, plot.getDomainAxisEdge()); double y0 = rangeAxis.valueToJava2D(previous, adjusted, plot.getRangeAxisEdge()); double x2 = x0 + getXOffset(); double y2 = y0 - getYOffset(); double x3 = x1 + getXOffset(); double y3 = y1 - getYOffset(); GeneralPath clip = new GeneralPath(); if (orientation == PlotOrientation.HORIZONTAL) { clip.moveTo((float) y0, (float) x0); clip.lineTo((float) y1, (float) x1); clip.lineTo((float) y3, (float) x3); clip.lineTo((float) y2, (float) x2); clip.lineTo((float) y0, (float) x0); clip.closePath(); } else if (orientation == PlotOrientation.VERTICAL) { clip.moveTo((float) x0, (float) y0); clip.lineTo((float) x1, (float) y1); clip.lineTo((float) x3, (float) y3); clip.lineTo((float) x2, (float) y2); clip.lineTo((float) x0, (float) y0); clip.closePath(); } g2.setPaint(getItemPaint(row, column)); g2.fill(clip); g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(clip); } } } // draw the item label if there is one... if (isItemLabelVisible(row, column)) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, shape); } } /** * Checks this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LineRenderer3D)) { return false; } LineRenderer3D that = (LineRenderer3D) obj; if (this.xOffset != that.xOffset) { return false; } if (this.yOffset != that.yOffset) { return false; } if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.wallPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.wallPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java0000644000175000017500000004714611173030414033311 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * MinMaxCategoryRenderer.java * --------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: Tomer Peretz; * Contributor(s): David Gilbert (for Object Refinery Limited); * Christian W. Zuckschwerdt; * Nicolas Brodu (for Astrium and EADS Corporate Research * Center); * * Changes: * -------- * 29-May-2002 : Version 1 (TP); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 17-Jan-2003 : Moved plot classes to a separate package (DG); * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in drawItem() * method (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 08-Sep-2003 : Implemented Serializable (NB); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 17-Nov-2005 : Added change events and argument checks (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 09-Mar-2007 : Fixed problem with horizontal rendering (DG); * 28-Sep-2007 : Added equals() method override (DG); * */ package org.jfree.chart.renderer.category; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import javax.swing.Icon; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; /** * Renderer for drawing min max plot. This renderer draws all the series under * the same category in the same x position using objectIcon and * a line from the maximum value to the minimum value. For use with the * {@link CategoryPlot} class. The example shown here is generated by * the MinMaxCategoryPlotDemo1.java program included in the * JFreeChart Demo Collection: *

* MinMaxCategoryRendererSample.png */ public class MinMaxCategoryRenderer extends AbstractCategoryItemRenderer { /** For serialization. */ private static final long serialVersionUID = 2935615937671064911L; /** A flag indicating whether or not lines are drawn between XY points. */ private boolean plotLines = false; /** * The paint of the line between the minimum value and the maximum value. */ private transient Paint groupPaint = Color.black; /** * The stroke of the line between the minimum value and the maximum value. */ private transient Stroke groupStroke = new BasicStroke(1.0f); /** The icon used to indicate the minimum value.*/ private transient Icon minIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360, Arc2D.OPEN), null, Color.black); /** The icon used to indicate the maximum value.*/ private transient Icon maxIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360, Arc2D.OPEN), null, Color.black); /** The icon used to indicate the values.*/ private transient Icon objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), false, true); /** The last category. */ private int lastCategory = -1; /** The minimum. */ private double min; /** The maximum. */ private double max; /** * Default constructor. */ public MinMaxCategoryRenderer() { super(); } /** * Gets whether or not lines are drawn between category points. * * @return boolean true if line will be drawn between sequenced categories, * otherwise false. * * @see #setDrawLines(boolean) */ public boolean isDrawLines() { return this.plotLines; } /** * Sets the flag that controls whether or not lines are drawn to connect * the items within a series and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param draw the new value of the flag. * * @see #isDrawLines() */ public void setDrawLines(boolean draw) { if (this.plotLines != draw) { this.plotLines = draw; fireChangeEvent(); } } /** * Returns the paint used to draw the line between the minimum and maximum * value items in each category. * * @return The paint (never null). * * @see #setGroupPaint(Paint) */ public Paint getGroupPaint() { return this.groupPaint; } /** * Sets the paint used to draw the line between the minimum and maximum * value items in each category and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getGroupPaint() */ public void setGroupPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.groupPaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the line between the minimum and maximum * value items in each category. * * @return The stroke (never null). * * @see #setGroupStroke(Stroke) */ public Stroke getGroupStroke() { return this.groupStroke; } /** * Sets the stroke of the line between the minimum value and the maximum * value and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param stroke the new stroke (null not permitted). */ public void setGroupStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.groupStroke = stroke; fireChangeEvent(); } /** * Returns the icon drawn for each data item. * * @return The icon (never null). * * @see #setObjectIcon(Icon) */ public Icon getObjectIcon() { return this.objectIcon; } /** * Sets the icon drawn for each data item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param icon the icon. * * @see #getObjectIcon() */ public void setObjectIcon(Icon icon) { if (icon == null) { throw new IllegalArgumentException("Null 'icon' argument."); } this.objectIcon = icon; fireChangeEvent(); } /** * Returns the icon displayed for the maximum value data item within each * category. * * @return The icon (never null). * * @see #setMaxIcon(Icon) */ public Icon getMaxIcon() { return this.maxIcon; } /** * Sets the icon displayed for the maximum value data item within each * category and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param icon the icon (null not permitted). * * @see #getMaxIcon() */ public void setMaxIcon(Icon icon) { if (icon == null) { throw new IllegalArgumentException("Null 'icon' argument."); } this.maxIcon = icon; fireChangeEvent(); } /** * Returns the icon displayed for the minimum value data item within each * category. * * @return The icon (never null). * * @see #setMinIcon(Icon) */ public Icon getMinIcon() { return this.minIcon; } /** * Sets the icon displayed for the minimum value data item within each * category and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param icon the icon (null not permitted). * * @see #getMinIcon() */ public void setMinIcon(Icon icon) { if (icon == null) { throw new IllegalArgumentException("Null 'icon' argument."); } this.minIcon = icon; fireChangeEvent(); } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // first check the number we are plotting... Number value = dataset.getValue(row, column); if (value != null) { // current data point... double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double y1 = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, plot.getRangeAxisEdge()); g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); Shape shape = null; shape = new Rectangle2D.Double(x1 - 4, y1 - 4, 8.0, 8.0); PlotOrientation orient = plot.getOrientation(); if (orient == PlotOrientation.VERTICAL) { this.objectIcon.paintIcon(null, g2, (int) x1, (int) y1); } else { this.objectIcon.paintIcon(null, g2, (int) y1, (int) x1); } if (this.lastCategory == column) { if (this.min > value.doubleValue()) { this.min = value.doubleValue(); } if (this.max < value.doubleValue()) { this.max = value.doubleValue(); } // last series, so we are ready to draw the min and max if (dataset.getRowCount() - 1 == row) { g2.setPaint(this.groupPaint); g2.setStroke(this.groupStroke); double minY = rangeAxis.valueToJava2D(this.min, dataArea, plot.getRangeAxisEdge()); double maxY = rangeAxis.valueToJava2D(this.max, dataArea, plot.getRangeAxisEdge()); if (orient == PlotOrientation.VERTICAL) { g2.draw(new Line2D.Double(x1, minY, x1, maxY)); this.minIcon.paintIcon(null, g2, (int) x1, (int) minY); this.maxIcon.paintIcon(null, g2, (int) x1, (int) maxY); } else { g2.draw(new Line2D.Double(minY, x1, maxY, x1)); this.minIcon.paintIcon(null, g2, (int) minY, (int) x1); this.maxIcon.paintIcon(null, g2, (int) maxY, (int) x1); } } } else { // reset the min and max this.lastCategory = column; this.min = value.doubleValue(); this.max = value.doubleValue(); } // connect to the previous point if (this.plotLines) { if (column != 0) { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); Line2D line; if (orient == PlotOrientation.VERTICAL) { line = new Line2D.Double(x0, y0, x1, y1); } else { line = new Line2D.Double(y0, x0, y1, x1); } g2.draw(line); } } } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null && shape != null) { addItemEntity(entities, dataset, row, column, shape); } } } /** * Tests this instance for equality with an arbitrary object. The icon * fields are NOT included in the test, so this implementation is a little * weak. * * @param obj the object (null permitted). * * @return A boolean. * * @since 1.0.7 */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MinMaxCategoryRenderer)) { return false; } MinMaxCategoryRenderer that = (MinMaxCategoryRenderer) obj; if (this.plotLines != that.plotLines) { return false; } if (!PaintUtilities.equal(this.groupPaint, that.groupPaint)) { return false; } if (!this.groupStroke.equals(that.groupStroke)) { return false; } return super.equals(obj); } /** * Returns an icon. * * @param shape the shape. * @param fillPaint the fill paint. * @param outlinePaint the outline paint. * * @return The icon. */ private Icon getIcon(Shape shape, final Paint fillPaint, final Paint outlinePaint) { final int width = shape.getBounds().width; final int height = shape.getBounds().height; final GeneralPath path = new GeneralPath(shape); return new Icon() { public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g; path.transform(AffineTransform.getTranslateInstance(x, y)); if (fillPaint != null) { g2.setPaint(fillPaint); g2.fill(path); } if (outlinePaint != null) { g2.setPaint(outlinePaint); g2.draw(path); } path.transform(AffineTransform.getTranslateInstance(-x, -y)); } public int getIconWidth() { return width; } public int getIconHeight() { return height; } }; } /** * Returns an icon from a shape. * * @param shape the shape. * @param fill the fill flag. * @param outline the outline flag. * * @return The icon. */ private Icon getIcon(Shape shape, final boolean fill, final boolean outline) { final int width = shape.getBounds().width; final int height = shape.getBounds().height; final GeneralPath path = new GeneralPath(shape); return new Icon() { public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g; path.transform(AffineTransform.getTranslateInstance(x, y)); if (fill) { g2.fill(path); } if (outline) { g2.draw(path); } path.transform(AffineTransform.getTranslateInstance(-x, -y)); } public int getIconWidth() { return width; } public int getIconHeight() { return height; } }; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.groupStroke, stream); SerialUtilities.writePaint(this.groupPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.groupStroke = SerialUtilities.readStroke(stream); this.groupPaint = SerialUtilities.readPaint(stream); this.minIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360, Arc2D.OPEN), null, Color.black); this.maxIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360, Arc2D.OPEN), null, Color.black); this.objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), false, true); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/ScatterRenderer.java0000644000175000017500000004603611173030414032024 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ScatterRenderer.java * -------------------- * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): David Forslund; * Peter Kolb (patch 2497611); * * Changes * ------- * 08-Oct-2007 : Version 1, based on patch 1780779 by David Forslund (DG); * 11-Oct-2007 : Renamed ScatterRenderer (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 14-Jan-2009 : Added support for seriesVisible flags (PK); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.data.statistics.MultiValueCategoryDataset; import org.jfree.util.BooleanList; import org.jfree.util.BooleanUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that handles the multiple values from a * {@link MultiValueCategoryDataset} by plotting a shape for each value for * each given item in the dataset. The example shown here is generated by * the ScatterRendererDemo1.java program included in the * JFreeChart Demo Collection: *

* ScatterRendererSample.png * * @since 1.0.7 */ public class ScatterRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { /** * A table of flags that control (per series) whether or not shapes are * filled. */ private BooleanList seriesShapesFilled; /** * The default value returned by the getShapeFilled() method. */ private boolean baseShapesFilled; /** * A flag that controls whether the fill paint is used for filling * shapes. */ private boolean useFillPaint; /** * A flag that controls whether outlines are drawn for shapes. */ private boolean drawOutlines; /** * A flag that controls whether the outline paint is used for drawing shape * outlines - if not, the regular series paint is used. */ private boolean useOutlinePaint; /** * A flag that controls whether or not the x-position for each item is * offset within the category according to the series. */ private boolean useSeriesOffset; /** * The item margin used for series offsetting - this allows the positioning * to match the bar positions of the {@link BarRenderer} class. */ private double itemMargin; /** * Constructs a new renderer. */ public ScatterRenderer() { this.seriesShapesFilled = new BooleanList(); this.baseShapesFilled = true; this.useFillPaint = false; this.drawOutlines = false; this.useOutlinePaint = false; this.useSeriesOffset = true; this.itemMargin = 0.20; } /** * Returns the flag that controls whether or not the x-position for each * data item is offset within the category according to the series. * * @return A boolean. * * @see #setUseSeriesOffset(boolean) */ public boolean getUseSeriesOffset() { return this.useSeriesOffset; } /** * Sets the flag that controls whether or not the x-position for each * data item is offset within its category according to the series, and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param offset the offset. * * @see #getUseSeriesOffset() */ public void setUseSeriesOffset(boolean offset) { this.useSeriesOffset = offset; fireChangeEvent(); } /** * Returns the item margin, which is the gap between items within a * category (expressed as a percentage of the overall category width). * This can be used to match the offset alignment with the bars drawn by * a {@link BarRenderer}). * * @return The item margin. * * @see #setItemMargin(double) * @see #getUseSeriesOffset() */ public double getItemMargin() { return this.itemMargin; } /** * Sets the item margin, which is the gap between items within a category * (expressed as a percentage of the overall category width), and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param margin the margin (0.0 <= margin < 1.0). * * @see #getItemMargin() * @see #getUseSeriesOffset() */ public void setItemMargin(double margin) { if (margin < 0.0 || margin >= 1.0) { throw new IllegalArgumentException("Requires 0.0 <= margin < 1.0."); } this.itemMargin = margin; fireChangeEvent(); } /** * Returns true if outlines should be drawn for shapes, and * false otherwise. * * @return A boolean. * * @see #setDrawOutlines(boolean) */ public boolean getDrawOutlines() { return this.drawOutlines; } /** * Sets the flag that controls whether outlines are drawn for * shapes, and sends a {@link RendererChangeEvent} to all registered * listeners. *

* In some cases, shapes look better if they do NOT have an outline, but * this flag allows you to set your own preference. * * @param flag the flag. * * @see #getDrawOutlines() */ public void setDrawOutlines(boolean flag) { this.drawOutlines = flag; fireChangeEvent(); } /** * Returns the flag that controls whether the outline paint is used for * shape outlines. If not, the regular series paint is used. * * @return A boolean. * * @see #setUseOutlinePaint(boolean) */ public boolean getUseOutlinePaint() { return this.useOutlinePaint; } /** * Sets the flag that controls whether the outline paint is used for shape * outlines, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param use the flag. * * @see #getUseOutlinePaint() */ public void setUseOutlinePaint(boolean use) { this.useOutlinePaint = use; fireChangeEvent(); } // SHAPES FILLED /** * Returns the flag used to control whether or not the shape for an item * is filled. The default implementation passes control to the * getSeriesShapesFilled method. You can override this method * if you require different behaviour. * * @param series the series index (zero-based). * @param item the item index (zero-based). * @return A boolean. */ public boolean getItemShapeFilled(int series, int item) { return getSeriesShapesFilled(series); } /** * Returns the flag used to control whether or not the shapes for a series * are filled. * * @param series the series index (zero-based). * @return A boolean. */ public boolean getSeriesShapesFilled(int series) { Boolean flag = this.seriesShapesFilled.getBoolean(series); if (flag != null) { return flag.booleanValue(); } else { return this.baseShapesFilled; } } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param filled the flag. */ public void setSeriesShapesFilled(int series, Boolean filled) { this.seriesShapesFilled.setBoolean(series, filled); fireChangeEvent(); } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param filled the flag. */ public void setSeriesShapesFilled(int series, boolean filled) { this.seriesShapesFilled.setBoolean(series, BooleanUtilities.valueOf(filled)); fireChangeEvent(); } /** * Returns the base 'shape filled' attribute. * * @return The base flag. */ public boolean getBaseShapesFilled() { return this.baseShapesFilled; } /** * Sets the base 'shapes filled' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. */ public void setBaseShapesFilled(boolean flag) { this.baseShapesFilled = flag; fireChangeEvent(); } /** * Returns true if the renderer should use the fill paint * setting to fill shapes, and false if it should just * use the regular paint. * * @return A boolean. */ public boolean getUseFillPaint() { return this.useFillPaint; } /** * Sets the flag that controls whether the fill paint is used to fill * shapes, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param flag the flag. */ public void setUseFillPaint(boolean flag) { this.useFillPaint = flag; fireChangeEvent(); } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // do nothing if item is not visible if (!getItemVisible(row, column)) { return; } int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } int visibleRowCount = state.getVisibleSeriesCount(); PlotOrientation orientation = plot.getOrientation(); MultiValueCategoryDataset d = (MultiValueCategoryDataset) dataset; List values = d.getValues(row, column); if (values == null) { return; } int valueCount = values.size(); for (int i = 0; i < valueCount; i++) { // current data point... double x1; if (this.useSeriesOffset) { x1 = domainAxis.getCategorySeriesMiddle(column,dataset.getColumnCount(), visibleRow, visibleRowCount, this.itemMargin, dataArea, plot.getDomainAxisEdge()); } else { x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } Number n = (Number) values.get(i); double value = n.doubleValue(); double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); } if (getItemShapeFilled(row, column)) { if (this.useFillPaint) { g2.setPaint(getItemFillPaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.fill(shape); } if (this.drawOutlines) { if (this.useOutlinePaint) { g2.setPaint(getItemOutlinePaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.setStroke(getItemOutlineStroke(row, column)); g2.draw(shape); } } } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint fillPaint = (this.useFillPaint ? getItemFillPaint(series, 0) : paint); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? getItemOutlinePaint(series, 0) : paint); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, getItemShapeFilled(series, 0), fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, false, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), getItemStroke(series, 0), getItemPaint(series, 0)); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } return null; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ScatterRenderer)) { return false; } ScatterRenderer that = (ScatterRenderer) obj; if (!ObjectUtilities.equal(this.seriesShapesFilled, that.seriesShapesFilled)) { return false; } if (this.baseShapesFilled != that.baseShapesFilled) { return false; } if (this.useFillPaint != that.useFillPaint) { return false; } if (this.drawOutlines != that.drawOutlines) { return false; } if (this.useOutlinePaint != that.useOutlinePaint) { return false; } if (this.useSeriesOffset != that.useSeriesOffset) { return false; } if (this.itemMargin != that.itemMargin) { return false; } return super.equals(obj); } /** * Returns an independent copy of the renderer. * * @return A clone. * * @throws CloneNotSupportedException should not happen. */ public Object clone() throws CloneNotSupportedException { ScatterRenderer clone = (ScatterRenderer) super.clone(); clone.seriesShapesFilled = (BooleanList) this.seriesShapesFilled.clone(); return clone; } /** * Provides serialization support. * * @param stream the output stream. * @throws java.io.IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); } /** * Provides serialization support. * * @param stream the input stream. * @throws java.io.IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StackedAreaRenderer.java0000644000175000017500000005110111173030414032553 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * StackedAreaRenderer.java * ------------------------ * (C) Copyright 2002-2009, by Dan Rivett (d.rivett@ukonline.co.uk) and * Contributors. * * Original Author: Dan Rivett (adapted from AreaRenderer); * Contributor(s): Jon Iles; * David Gilbert (for Object Refinery Limited); * Christian W. Zuckschwerdt; * Peter Kolb (patch 2511330); * * Changes: * -------- * 20-Sep-2002 : Version 1, contributed by Dan Rivett; * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 01-Nov-2002 : Added tooltips (DG); * 06-Nov-2002 : Renamed drawCategoryItem() --> drawItem() and now using axis * for category spacing. Renamed StackedAreaCategoryItemRenderer * --> StackedAreaRenderer (DG); * 26-Nov-2002 : Switched CategoryDataset --> TableDataset (DG); * 26-Nov-2002 : Replaced isStacked() method with getRangeType() method (DG); * 17-Jan-2003 : Moved plot classes to a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 13-May-2003 : Modified to take into account the plot orientation (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 07-Oct-2003 : Added renderer state (DG); * 29-Apr-2004 : Added getRangeExtent() override (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Oct-2006 : Added support for rendering data values as percentages, * and added a second pass for drawing item labels (DG); * 04-Feb-2009 : Fixed support for hidden series, and bug in findRangeBounds() * method for null dataset (PK/DG); * 04-Feb-2009 : Added item label support, and generate entities only in first * pass (DG); * 04-Feb-2009 : Fixed bug for renderAsPercentages == true (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.data.DataUtilities; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A renderer that draws stacked area charts for a {@link CategoryPlot}. * The example shown here is generated by the * StackedAreaChartDemo1.java program included in the * JFreeChart Demo Collection: *

* StackedAreaRendererSample.png */ public class StackedAreaRenderer extends AreaRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3595635038460823663L; /** A flag that controls whether the areas display values or percentages. */ private boolean renderAsPercentages; /** * Creates a new renderer. */ public StackedAreaRenderer() { this(false); } /** * Creates a new renderer. * * @param renderAsPercentages a flag that controls whether the data values * are rendered as percentages. */ public StackedAreaRenderer(boolean renderAsPercentages) { super(); this.renderAsPercentages = renderAsPercentages; } /** * Returns true if the renderer displays each item value as * a percentage (so that the stacked areas add to 100%), and * false otherwise. * * @return A boolean. * * @since 1.0.3 */ public boolean getRenderAsPercentages() { return this.renderAsPercentages; } /** * Sets the flag that controls whether the renderer displays each item * value as a percentage (so that the stacked areas add to 100%), and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param asPercentages the flag. * * @since 1.0.3 */ public void setRenderAsPercentages(boolean asPercentages) { this.renderAsPercentages = asPercentages; fireChangeEvent(); } /** * Returns the number of passes (2) required by this renderer. * The first pass is used to draw the areas, the second pass is used to * draw the item labels (if visible). * * @return The number of passes required by the renderer. */ public int getPassCount() { return 2; } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null not permitted). * * @return The range (or null if the dataset is empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } if (this.renderAsPercentages) { return new Range(0.0, 1.0); } else { return DatasetUtilities.findStackedRangeBounds(dataset); } } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data plot area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { if (!isSeriesVisible(row)) { return; } // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = state.getEntityCollection(); double y1 = 0.0; Number n = dataset.getValue(row, column); if (n != null) { y1 = n.doubleValue(); if (this.renderAsPercentages) { double total = DataUtilities.calculateColumnTotal(dataset, column, state.getVisibleSeriesArray()); y1 = y1 / total; } } double[] stack1 = getStackValues(dataset, row, column, state.getVisibleSeriesArray()); // leave the y values (y1, y0) untranslated as it is going to be be // stacked up later by previous series values, after this it will be // translated. double xx1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); // get the previous point and the next point so we can calculate a // "hot spot" for the area (used by the chart entity)... double y0 = 0.0; n = dataset.getValue(row, Math.max(column - 1, 0)); if (n != null) { y0 = n.doubleValue(); if (this.renderAsPercentages) { double total = DataUtilities.calculateColumnTotal(dataset, Math.max(column - 1, 0), state.getVisibleSeriesArray()); y0 = y0 / total; } } double[] stack0 = getStackValues(dataset, row, Math.max(column - 1, 0), state.getVisibleSeriesArray()); // FIXME: calculate xx0 double xx0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); int itemCount = dataset.getColumnCount(); double y2 = 0.0; n = dataset.getValue(row, Math.min(column + 1, itemCount - 1)); if (n != null) { y2 = n.doubleValue(); if (this.renderAsPercentages) { double total = DataUtilities.calculateColumnTotal(dataset, Math.min(column + 1, itemCount - 1), state.getVisibleSeriesArray()); y2 = y2 / total; } } double[] stack2 = getStackValues(dataset, row, Math.min(column + 1, itemCount - 1), state.getVisibleSeriesArray()); double xx2 = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); // FIXME: calculate xxLeft and xxRight double xxLeft = xx0; double xxRight = xx2; double[] stackLeft = averageStackValues(stack0, stack1); double[] stackRight = averageStackValues(stack1, stack2); double[] adjStackLeft = adjustedStackValues(stack0, stack1); double[] adjStackRight = adjustedStackValues(stack1, stack2); float transY1; RectangleEdge edge1 = plot.getRangeAxisEdge(); GeneralPath left = new GeneralPath(); GeneralPath right = new GeneralPath(); if (y1 >= 0.0) { // handle positive value transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea, edge1); float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1], dataArea, edge1); float transStackLeft = (float) rangeAxis.valueToJava2D( adjStackLeft[1], dataArea, edge1); // LEFT POLYGON if (y0 >= 0.0) { double yleft = (y0 + y1) / 2.0 + stackLeft[1]; float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1); left.moveTo((float) xx1, transY1); left.lineTo((float) xx1, transStack1); left.lineTo((float) xxLeft, transStackLeft); left.lineTo((float) xxLeft, transYLeft); left.closePath(); } else { left.moveTo((float) xx1, transStack1); left.lineTo((float) xx1, transY1); left.lineTo((float) xxLeft, transStackLeft); left.closePath(); } float transStackRight = (float) rangeAxis.valueToJava2D( adjStackRight[1], dataArea, edge1); // RIGHT POLYGON if (y2 >= 0.0) { double yright = (y1 + y2) / 2.0 + stackRight[1]; float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1); right.moveTo((float) xx1, transStack1); right.lineTo((float) xx1, transY1); right.lineTo((float) xxRight, transYRight); right.lineTo((float) xxRight, transStackRight); right.closePath(); } else { right.moveTo((float) xx1, transStack1); right.lineTo((float) xx1, transY1); right.lineTo((float) xxRight, transStackRight); right.closePath(); } } else { // handle negative value transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea, edge1); float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0], dataArea, edge1); float transStackLeft = (float) rangeAxis.valueToJava2D( adjStackLeft[0], dataArea, edge1); // LEFT POLYGON if (y0 >= 0.0) { left.moveTo((float) xx1, transStack1); left.lineTo((float) xx1, transY1); left.lineTo((float) xxLeft, transStackLeft); left.clone(); } else { double yleft = (y0 + y1) / 2.0 + stackLeft[0]; float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1); left.moveTo((float) xx1, transY1); left.lineTo((float) xx1, transStack1); left.lineTo((float) xxLeft, transStackLeft); left.lineTo((float) xxLeft, transYLeft); left.closePath(); } float transStackRight = (float) rangeAxis.valueToJava2D( adjStackRight[0], dataArea, edge1); // RIGHT POLYGON if (y2 >= 0.0) { right.moveTo((float) xx1, transStack1); right.lineTo((float) xx1, transY1); right.lineTo((float) xxRight, transStackRight); right.closePath(); } else { double yright = (y1 + y2) / 2.0 + stackRight[0]; float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1); right.moveTo((float) xx1, transStack1); right.lineTo((float) xx1, transY1); right.lineTo((float) xxRight, transYRight); right.lineTo((float) xxRight, transStackRight); right.closePath(); } } if (pass == 0) { Paint itemPaint = getItemPaint(row, column); g2.setPaint(itemPaint); g2.fill(left); g2.fill(right); // add an entity for the item... if (entities != null) { GeneralPath gp = new GeneralPath(left); gp.append(right, false); entityArea = gp; addItemEntity(entities, dataset, row, column, entityArea); } } else if (pass == 1) { drawItemLabel(g2, plot.getOrientation(), dataset, row, column, xx1, transY1, y1 < 0.0); } } /** * Calculates the stacked values (one positive and one negative) of all * series up to, but not including, series for the specified * item. It returns [0.0, 0.0] if series is the first series. * * @param dataset the dataset (null not permitted). * @param series the series index. * @param index the item index. * * @return An array containing the cumulative negative and positive values * for all series values up to but excluding series * for index. */ protected double[] getStackValues(CategoryDataset dataset, int series, int index, int[] validRows) { double[] result = new double[2]; double total = 0.0; if (this.renderAsPercentages) { total = DataUtilities.calculateColumnTotal(dataset, index, validRows); } for (int i = 0; i < series; i++) { if (isSeriesVisible(i)) { double v = 0.0; Number n = dataset.getValue(i, index); if (n != null) { v = n.doubleValue(); if (this.renderAsPercentages) { v = v / total; } } if (!Double.isNaN(v)) { if (v >= 0.0) { result[1] += v; } else { result[0] += v; } } } } return result; } /** * Returns a pair of "stack" values calculated as the mean of the two * specified stack value pairs. * * @param stack1 the first stack pair. * @param stack2 the second stack pair. * * @return A pair of average stack values. */ private double[] averageStackValues(double[] stack1, double[] stack2) { double[] result = new double[2]; result[0] = (stack1[0] + stack2[0]) / 2.0; result[1] = (stack1[1] + stack2[1]) / 2.0; return result; } /** * Calculates adjusted stack values from the supplied values. The value is * the mean of the supplied values, unless either of the supplied values * is zero, in which case the adjusted value is zero also. * * @param stack1 the first stack pair. * @param stack2 the second stack pair. * * @return A pair of average stack values. */ private double[] adjustedStackValues(double[] stack1, double[] stack2) { double[] result = new double[2]; if (stack1[0] == 0.0 || stack2[0] == 0.0) { result[0] = 0.0; } else { result[0] = (stack1[0] + stack2[0]) / 2.0; } if (stack1[1] == 0.0 || stack2[1] == 0.0) { result[1] = 0.0; } else { result[1] = (stack1[1] + stack2[1]) / 2.0; } return result; } /** * Checks this instance for equality with an arbitrary object. * * @param obj the object (null not permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StackedAreaRenderer)) { return false; } StackedAreaRenderer that = (StackedAreaRenderer) obj; if (this.renderAsPercentages != that.renderAsPercentages) { return false; } return super.equals(obj); } /** * Calculates the stacked value of the all series up to, but not including * series for the specified category, category. * It returns 0.0 if series is the first series, i.e. 0. * * @param dataset the dataset (null not permitted). * @param series the series. * @param category the category. * * @return double returns a cumulative value for all series' values up to * but excluding series for Object * category. * * @deprecated As of 1.0.13, as the method is never used internally. */ protected double getPreviousHeight(CategoryDataset dataset, int series, int category) { double result = 0.0; Number n; double total = 0.0; if (this.renderAsPercentages) { total = DataUtilities.calculateColumnTotal(dataset, category); } for (int i = 0; i < series; i++) { n = dataset.getValue(i, category); if (n != null) { double v = n.doubleValue(); if (this.renderAsPercentages) { v = v / total; } result += v; } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StackedBarRenderer.java0000644000175000017500000004166711173030414032427 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * StackedBarRenderer.java * ----------------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Thierry Saura; * Christian W. Zuckschwerdt; * Peter Kolb (patch 2511330); * * Changes * ------- * 19-Oct-2001 : Version 1 (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 23-Oct-2001 : Changed intro and trail gaps on bar plots to use percentage of * available space rather than a fixed number of units (DG); * 15-Nov-2001 : Modified to allow for null data values (DG); * 22-Nov-2001 : Modified to allow for negative data values (DG); * 13-Dec-2001 : Added tooltips (DG); * 16-Jan-2002 : Fixed bug for single category datasets (DG); * 15-Feb-2002 : Added isStacked() method (DG); * 14-Mar-2002 : Modified to implement the CategoryItemRenderer interface (DG); * 24-May-2002 : Incorporated tooltips into chart entities (DG); * 11-Jun-2002 : Added check for (permitted) null info object, bug and fix * reported by David Basten. Also updated Javadocs. (DG); * 25-Jun-2002 : Removed redundant import (DG); * 26-Jun-2002 : Small change to entity (DG); * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs * for HTML image maps (RA); * 08-Aug-2002 : Added optional linking lines, contributed by Thierry * Saura (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); * 26-Nov-2002 : Replaced isStacked() method with getRangeType() method (DG); * 17-Jan-2003 : Moved plot classes to a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 12-May-2003 : Merged horizontal and vertical stacked bar renderers (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 08-Sep-2003 : Fixed bug 799668 (isBarOutlineDrawn() ignored) (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 21-Oct-2003 : Moved bar width into renderer state (DG); * 26-Nov-2003 : Added code to respect maxBarWidth attribute (DG); * 05-Nov-2004 : Changed to a two-pass renderer so that item labels are not * overwritten by other bars (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() (DG); * 29-Mar-2005 : Modified drawItem() method so that a zero value is handled * within the code for positive rather than negative values (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 17-May-2005 : Added flag to allow rendering values as percentages - inspired * by patch 1200886 submitted by John Xiao (DG); * 09-Jun-2005 : Added accessor methods for the renderAsPercentages flag, * provided equals() method, and use addItemEntity from * superclass (DG); * 09-Jun-2005 : Added support for GradientPaint - see bug report 1215670 (DG); * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); * 29-Sep-2005 : Use outline stroke in drawItem method - see bug report * 1304139 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Oct-2006 : Source reformatting (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * 04-Feb-2009 : Added support for hidden series (PK); * */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.DataUtilities; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.util.PublicCloneable; /** * A stacked bar renderer for use with the {@link CategoryPlot} class. * The example shown here is generated by the * StackedBarChartDemo1.java program included in the * JFreeChart Demo Collection: *

* StackedBarRendererSample.png */ public class StackedBarRenderer extends BarRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ static final long serialVersionUID = 6402943811500067531L; /** A flag that controls whether the bars display values or percentages. */ private boolean renderAsPercentages; /** * Creates a new renderer. By default, the renderer has no tool tip * generator and no URL generator. These defaults have been chosen to * minimise the processing required to generate a default chart. If you * require tool tips or URLs, then you can easily add the required * generators. */ public StackedBarRenderer() { this(false); } /** * Creates a new renderer. * * @param renderAsPercentages a flag that controls whether the data values * are rendered as percentages. */ public StackedBarRenderer(boolean renderAsPercentages) { super(); this.renderAsPercentages = renderAsPercentages; // set the default item label positions, which will only be used if // the user requests visible item labels... ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER); setBasePositiveItemLabelPosition(p); setBaseNegativeItemLabelPosition(p); setPositiveItemLabelPositionFallback(null); setNegativeItemLabelPositionFallback(null); } /** * Returns true if the renderer displays each item value as * a percentage (so that the stacked bars add to 100%), and * false otherwise. * * @return A boolean. * * @see #setRenderAsPercentages(boolean) */ public boolean getRenderAsPercentages() { return this.renderAsPercentages; } /** * Sets the flag that controls whether the renderer displays each item * value as a percentage (so that the stacked bars add to 100%), and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param asPercentages the flag. * * @see #getRenderAsPercentages() */ public void setRenderAsPercentages(boolean asPercentages) { this.renderAsPercentages = asPercentages; fireChangeEvent(); } /** * Returns the number of passes (3) required by this renderer. * The first pass is used to draw the bar shadows, the second pass is used * to draw the bars, and the third pass is used to draw the item labels * (if visible). * * @return The number of passes required by the renderer. */ public int getPassCount() { return 3; } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } if (this.renderAsPercentages) { return new Range(0.0, 1.0); } else { return DatasetUtilities.findStackedRangeBounds(dataset, getBase()); } } /** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { // calculate the bar width CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { PlotOrientation orientation = plot.getOrientation(); double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); int columns = data.getColumnCount(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = xAxis.getCategoryMargin(); } double used = space * (1 - xAxis.getLowerMargin() - xAxis.getUpperMargin() - categoryMargin); if (columns > 0) { state.setBarWidth(Math.min(used / columns, maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } } /** * Draws a stacked bar for a specific item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the plot area. * @param plot the plot. * @param domainAxis the domain (category) axis. * @param rangeAxis the range (value) axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { if (!isSeriesVisible(row)) { return; } // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); double total = 0.0; // only needed if calculating percentages if (this.renderAsPercentages) { total = DataUtilities.calculateColumnTotal(dataset, column, state.getVisibleSeriesArray()); value = value / total; } PlotOrientation orientation = plot.getOrientation(); double barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; double positiveBase = getBase(); double negativeBase = positiveBase; for (int i = 0; i < row; i++) { Number v = dataset.getValue(i, column); if (v != null && isSeriesVisible(i)) { double d = v.doubleValue(); if (this.renderAsPercentages) { d = d / total; } if (d > 0) { positiveBase = positiveBase + d; } else { negativeBase = negativeBase + d; } } } double translatedBase; double translatedValue; boolean positive = (value > 0.0); boolean inverted = rangeAxis.isInverted(); RectangleEdge barBase; if (orientation == PlotOrientation.HORIZONTAL) { if (positive && inverted || !positive && !inverted) { barBase = RectangleEdge.RIGHT; } else { barBase = RectangleEdge.LEFT; } } else { if (positive && !inverted || !positive && inverted) { barBase = RectangleEdge.BOTTOM; } else { barBase = RectangleEdge.TOP; } } RectangleEdge location = plot.getRangeAxisEdge(); if (positive) { translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, location); translatedValue = rangeAxis.valueToJava2D(positiveBase + value, dataArea, location); } else { translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, location); translatedValue = rangeAxis.valueToJava2D(negativeBase + value, dataArea, location); } double barL0 = Math.min(translatedBase, translatedValue); double barLength = Math.max(Math.abs(translatedValue - translatedBase), getMinimumBarLength()); Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } if (pass == 0) { if (getShadowsVisible()) { boolean pegToBase = (positive && (positiveBase == getBase())) || (!positive && (negativeBase == getBase())); getBarPainter().paintBarShadow(g2, this, row, column, bar, barBase, pegToBase); } } else if (pass == 1) { getBarPainter().paintBar(g2, this, row, column, bar, barBase); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } else if (pass == 2) { CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StackedBarRenderer)) { return false; } StackedBarRenderer that = (StackedBarRenderer) obj; if (this.renderAsPercentages != that.renderAsPercentages) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java0000644000175000017500000010164111173030414032603 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * StackedBarRenderer3D.java * ------------------------- * (C) Copyright 2000-2009, by Serge V. Grachov and Contributors. * * Original Author: Serge V. Grachov; * Contributor(s): David Gilbert (for Object Refinery Limited); * Richard Atkinson; * Christian W. Zuckschwerdt; * Max Herfort (patch 1459313); * * Changes * ------- * 31-Oct-2001 : Version 1, contributed by Serge V. Grachov (DG); * 15-Nov-2001 : Modified to allow for null data values (DG); * 13-Dec-2001 : Added tooltips (DG); * 15-Feb-2002 : Added isStacked() method (DG); * 24-May-2002 : Incorporated tooltips into chart entities (DG); * 19-Jun-2002 : Added check for null info in drawCategoryItem method (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 26-Jun-2002 : Small change to entity (DG); * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs * for HTML image maps (RA); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); * 26-Nov-2002 : Replaced isStacked() method with getRangeType() method (DG); * 17-Jan-2003 : Moved plot classes to a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Added default constructor (bug 726235) and fixed bug * 726260) (DG); * 13-May-2003 : Renamed StackedVerticalBarRenderer3D * --> StackedBarRenderer3D (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 07-Oct-2003 : Added renderer state (DG); * 21-Nov-2003 : Added a new constructor (DG); * 27-Nov-2003 : Modified code to respect maxBarWidth setting (DG); * 11-Aug-2004 : Fixed bug where isDrawBarOutline() was ignored (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); * 18-Mar-2005 : Override for getPassCount() method (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 09-Jun-2005 : Use addItemEntity() method from superclass (DG); * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Mar-2006 : Added renderAsPercentages option - see patch 1459313 submitted * by Max Herfort (DG); * 16-Jan-2007 : Replaced rendering code to draw whole stack at once (DG); * 18-Jan-2007 : Fixed bug handling null values in createStackedValueList() * method (DG); * 18-Jan-2007 : Updated block drawing code to take account of inverted axes, * see bug report 1599652 (DG); * 08-May-2007 : Fixed bugs 1713401 (drawBarOutlines flag) and 1713474 * (shading) (DG); * 15-Aug-2008 : Fixed bug 2031407 - no negative zero for stack encoding (DG); * 03-Feb-2009 : Fixed regression in findRangeBounds() method for null * dataset (DG); * 04-Feb-2009 : Handle seriesVisible flag (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.DataUtilities; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; import org.jfree.util.BooleanUtilities; import org.jfree.util.PublicCloneable; /** * Renders stacked bars with 3D-effect, for use with the {@link CategoryPlot} * class. The example shown here is generated by the * StackedBarChart3DDemo1.java program included in the * JFreeChart Demo Collection: *

* StackedBarRenderer3DSample.png */ public class StackedBarRenderer3D extends BarRenderer3D implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -5832945916493247123L; /** A flag that controls whether the bars display values or percentages. */ private boolean renderAsPercentages; /** * Creates a new renderer with no tool tip generator and no URL generator. *

* The defaults (no tool tip or URL generators) have been chosen to * minimise the processing required to generate a default chart. If you * require tool tips or URLs, then you can easily add the required * generators. */ public StackedBarRenderer3D() { this(false); } /** * Constructs a new renderer with the specified '3D effect'. * * @param xOffset the x-offset for the 3D effect. * @param yOffset the y-offset for the 3D effect. */ public StackedBarRenderer3D(double xOffset, double yOffset) { super(xOffset, yOffset); } /** * Creates a new renderer. * * @param renderAsPercentages a flag that controls whether the data values * are rendered as percentages. * * @since 1.0.2 */ public StackedBarRenderer3D(boolean renderAsPercentages) { super(); this.renderAsPercentages = renderAsPercentages; } /** * Constructs a new renderer with the specified '3D effect'. * * @param xOffset the x-offset for the 3D effect. * @param yOffset the y-offset for the 3D effect. * @param renderAsPercentages a flag that controls whether the data values * are rendered as percentages. * * @since 1.0.2 */ public StackedBarRenderer3D(double xOffset, double yOffset, boolean renderAsPercentages) { super(xOffset, yOffset); this.renderAsPercentages = renderAsPercentages; } /** * Returns true if the renderer displays each item value as * a percentage (so that the stacked bars add to 100%), and * false otherwise. * * @return A boolean. * * @since 1.0.2 */ public boolean getRenderAsPercentages() { return this.renderAsPercentages; } /** * Sets the flag that controls whether the renderer displays each item * value as a percentage (so that the stacked bars add to 100%), and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param asPercentages the flag. * * @since 1.0.2 */ public void setRenderAsPercentages(boolean asPercentages) { this.renderAsPercentages = asPercentages; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null not permitted). * * @return The range (or null if the dataset is empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } if (this.renderAsPercentages) { return new Range(0.0, 1.0); } else { return DatasetUtilities.findStackedRangeBounds(dataset); } } /** * Calculates the bar width and stores it in the renderer state. * * @param plot the plot. * @param dataArea the data area. * @param rendererIndex the renderer index. * @param state the renderer state. */ protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, int rendererIndex, CategoryItemRendererState state) { // calculate the bar width CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); CategoryDataset data = plot.getDataset(rendererIndex); if (data != null) { PlotOrientation orientation = plot.getOrientation(); double space = 0.0; if (orientation == PlotOrientation.HORIZONTAL) { space = dataArea.getHeight(); } else if (orientation == PlotOrientation.VERTICAL) { space = dataArea.getWidth(); } double maxWidth = space * getMaximumBarWidth(); int columns = data.getColumnCount(); double categoryMargin = 0.0; if (columns > 1) { categoryMargin = domainAxis.getCategoryMargin(); } double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin() - categoryMargin); if (columns > 0) { state.setBarWidth(Math.min(used / columns, maxWidth)); } else { state.setBarWidth(Math.min(used, maxWidth)); } } } /** * Returns a list containing the stacked values for the specified series * in the given dataset, plus the supplied base value. * * @param dataset the dataset (null not permitted). * @param category the category key (null not permitted). * @param base the base value. * @param asPercentages a flag that controls whether the values in the * list are converted to percentages of the total. * * @return The value list. * * @since 1.0.4 * * @deprecated As of 1.0.13, use {@link #createStackedValueList( * CategoryDataset, Comparable, int[], double, boolean)}. */ protected static List createStackedValueList(CategoryDataset dataset, Comparable category, double base, boolean asPercentages) { int[] rows = new int[dataset.getRowCount()]; for (int i = 0; i < rows.length; i++) { rows[i] = i; } return createStackedValueList(dataset, category, rows, base, asPercentages); } /** * Returns a list containing the stacked values for the specified series * in the given dataset, plus the supplied base value. * * @param dataset the dataset (null not permitted). * @param category the category key (null not permitted). * @param includedRows the included rows. * @param base the base value. * @param asPercentages a flag that controls whether the values in the * list are converted to percentages of the total. * * @return The value list. * * @since 1.0.13 */ protected static List createStackedValueList(CategoryDataset dataset, Comparable category, int[] includedRows, double base, boolean asPercentages) { List result = new ArrayList(); double posBase = base; double negBase = base; double total = 0.0; if (asPercentages) { total = DataUtilities.calculateColumnTotal(dataset, dataset.getColumnIndex(category), includedRows); } int baseIndex = -1; int rowCount = includedRows.length; for (int i = 0; i < rowCount; i++) { int r = includedRows[i]; Number n = dataset.getValue(dataset.getRowKey(r), category); if (n == null) { continue; } double v = n.doubleValue(); if (asPercentages) { v = v / total; } if (v >= 0.0) { if (baseIndex < 0) { result.add(new Object[] {null, new Double(base)}); baseIndex = 0; } posBase = posBase + v; result.add(new Object[] {new Integer(r), new Double(posBase)}); } else if (v < 0.0) { if (baseIndex < 0) { result.add(new Object[] {null, new Double(base)}); baseIndex = 0; } negBase = negBase + v; // '+' because v is negative result.add(0, new Object[] {new Integer(-r - 1), new Double(negBase)}); baseIndex++; } } return result; } /** * Draws the visual representation of one data item from the chart (in * fact, this method does nothing until it reaches the last item for each * category, at which point it draws all the items for that category). * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the plot area. * @param plot the plot. * @param domainAxis the domain (category) axis. * @param rangeAxis the range (value) axis. * @param dataset the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // wait till we are at the last item for the row then draw the // whole stack at once if (row < dataset.getRowCount() - 1) { return; } Comparable category = dataset.getColumnKey(column); List values = createStackedValueList(dataset, dataset.getColumnKey(column), state.getVisibleSeriesArray(), getBase(), this.renderAsPercentages); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); // handle rendering separately for the two plot orientations... if (orientation == PlotOrientation.HORIZONTAL) { drawStackHorizontal(values, category, g2, state, adjusted, plot, domainAxis, rangeAxis, dataset); } else { drawStackVertical(values, category, g2, state, adjusted, plot, domainAxis, rangeAxis, dataset); } } /** * Draws a stack of bars for one category, with a horizontal orientation. * * @param values the value list. * @param category the category. * @param g2 the graphics device. * @param state the state. * @param dataArea the data area (adjusted for the 3D effect). * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * * @since 1.0.4 */ protected void drawStackHorizontal(List values, Comparable category, Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset) { int column = dataset.getColumnIndex(category); double barX0 = domainAxis.getCategoryMiddle(column, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; double barW = state.getBarWidth(); // a list to store the series index and bar region, so we can draw // all the labels at the end... List itemLabelList = new ArrayList(); // draw the blocks boolean inverted = rangeAxis.isInverted(); int blockCount = values.size() - 1; for (int k = 0; k < blockCount; k++) { int index = (inverted ? blockCount - k - 1 : k); Object[] prev = (Object[]) values.get(index); Object[] curr = (Object[]) values.get(index + 1); int series = 0; if (curr[0] == null) { series = -((Integer) prev[0]).intValue() - 1; } else { series = ((Integer) curr[0]).intValue(); if (series < 0) { series = -((Integer) prev[0]).intValue() - 1; } } double v0 = ((Double) prev[1]).doubleValue(); double vv0 = rangeAxis.valueToJava2D(v0, dataArea, plot.getRangeAxisEdge()); double v1 = ((Double) curr[1]).doubleValue(); double vv1 = rangeAxis.valueToJava2D(v1, dataArea, plot.getRangeAxisEdge()); Shape[] faces = createHorizontalBlock(barX0, barW, vv0, vv1, inverted); Paint fillPaint = getItemPaint(series, column); Paint fillPaintDark = fillPaint; if (fillPaintDark instanceof Color) { fillPaintDark = ((Color) fillPaint).darker(); } boolean drawOutlines = isDrawBarOutline(); Paint outlinePaint = fillPaint; if (drawOutlines) { outlinePaint = getItemOutlinePaint(series, column); g2.setStroke(getItemOutlineStroke(series, column)); } for (int f = 0; f < 6; f++) { if (f == 5) { g2.setPaint(fillPaint); } else { g2.setPaint(fillPaintDark); } g2.fill(faces[f]); if (drawOutlines) { g2.setPaint(outlinePaint); g2.draw(faces[f]); } } itemLabelList.add(new Object[] {new Integer(series), faces[5].getBounds2D(), BooleanUtilities.valueOf(v0 < getBase())}); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, series, column, faces[5]); } } for (int i = 0; i < itemLabelList.size(); i++) { Object[] record = (Object[]) itemLabelList.get(i); int series = ((Integer) record[0]).intValue(); Rectangle2D bar = (Rectangle2D) record[1]; boolean neg = ((Boolean) record[2]).booleanValue(); CategoryItemLabelGenerator generator = getItemLabelGenerator(series, column); if (generator != null && isItemLabelVisible(series, column)) { drawItemLabel(g2, dataset, series, column, plot, generator, bar, neg); } } } /** * Creates an array of shapes representing the six sides of a block in a * horizontal stack. * * @param x0 left edge of bar (in Java2D space). * @param width the width of the bar (in Java2D units). * @param y0 the base of the block (in Java2D space). * @param y1 the top of the block (in Java2D space). * @param inverted a flag indicating whether or not the block is inverted * (this changes the order of the faces of the block). * * @return The sides of the block. */ private Shape[] createHorizontalBlock(double x0, double width, double y0, double y1, boolean inverted) { Shape[] result = new Shape[6]; Point2D p00 = new Point2D.Double(y0, x0); Point2D p01 = new Point2D.Double(y0, x0 + width); Point2D p02 = new Point2D.Double(p01.getX() + getXOffset(), p01.getY() - getYOffset()); Point2D p03 = new Point2D.Double(p00.getX() + getXOffset(), p00.getY() - getYOffset()); Point2D p0 = new Point2D.Double(y1, x0); Point2D p1 = new Point2D.Double(y1, x0 + width); Point2D p2 = new Point2D.Double(p1.getX() + getXOffset(), p1.getY() - getYOffset()); Point2D p3 = new Point2D.Double(p0.getX() + getXOffset(), p0.getY() - getYOffset()); GeneralPath bottom = new GeneralPath(); bottom.moveTo((float) p1.getX(), (float) p1.getY()); bottom.lineTo((float) p01.getX(), (float) p01.getY()); bottom.lineTo((float) p02.getX(), (float) p02.getY()); bottom.lineTo((float) p2.getX(), (float) p2.getY()); bottom.closePath(); GeneralPath top = new GeneralPath(); top.moveTo((float) p0.getX(), (float) p0.getY()); top.lineTo((float) p00.getX(), (float) p00.getY()); top.lineTo((float) p03.getX(), (float) p03.getY()); top.lineTo((float) p3.getX(), (float) p3.getY()); top.closePath(); GeneralPath back = new GeneralPath(); back.moveTo((float) p2.getX(), (float) p2.getY()); back.lineTo((float) p02.getX(), (float) p02.getY()); back.lineTo((float) p03.getX(), (float) p03.getY()); back.lineTo((float) p3.getX(), (float) p3.getY()); back.closePath(); GeneralPath front = new GeneralPath(); front.moveTo((float) p0.getX(), (float) p0.getY()); front.lineTo((float) p1.getX(), (float) p1.getY()); front.lineTo((float) p01.getX(), (float) p01.getY()); front.lineTo((float) p00.getX(), (float) p00.getY()); front.closePath(); GeneralPath left = new GeneralPath(); left.moveTo((float) p0.getX(), (float) p0.getY()); left.lineTo((float) p1.getX(), (float) p1.getY()); left.lineTo((float) p2.getX(), (float) p2.getY()); left.lineTo((float) p3.getX(), (float) p3.getY()); left.closePath(); GeneralPath right = new GeneralPath(); right.moveTo((float) p00.getX(), (float) p00.getY()); right.lineTo((float) p01.getX(), (float) p01.getY()); right.lineTo((float) p02.getX(), (float) p02.getY()); right.lineTo((float) p03.getX(), (float) p03.getY()); right.closePath(); result[0] = bottom; result[1] = back; if (inverted) { result[2] = right; result[3] = left; } else { result[2] = left; result[3] = right; } result[4] = top; result[5] = front; return result; } /** * Draws a stack of bars for one category, with a vertical orientation. * * @param values the value list. * @param category the category. * @param g2 the graphics device. * @param state the state. * @param dataArea the data area (adjusted for the 3D effect). * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * * @since 1.0.4 */ protected void drawStackVertical(List values, Comparable category, Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset) { int column = dataset.getColumnIndex(category); double barX0 = domainAxis.getCategoryMiddle(column, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; double barW = state.getBarWidth(); // a list to store the series index and bar region, so we can draw // all the labels at the end... List itemLabelList = new ArrayList(); // draw the blocks boolean inverted = rangeAxis.isInverted(); int blockCount = values.size() - 1; for (int k = 0; k < blockCount; k++) { int index = (inverted ? blockCount - k - 1 : k); Object[] prev = (Object[]) values.get(index); Object[] curr = (Object[]) values.get(index + 1); int series = 0; if (curr[0] == null) { series = -((Integer) prev[0]).intValue() - 1; } else { series = ((Integer) curr[0]).intValue(); if (series < 0) { series = -((Integer) prev[0]).intValue() - 1; } } double v0 = ((Double) prev[1]).doubleValue(); double vv0 = rangeAxis.valueToJava2D(v0, dataArea, plot.getRangeAxisEdge()); double v1 = ((Double) curr[1]).doubleValue(); double vv1 = rangeAxis.valueToJava2D(v1, dataArea, plot.getRangeAxisEdge()); Shape[] faces = createVerticalBlock(barX0, barW, vv0, vv1, inverted); Paint fillPaint = getItemPaint(series, column); Paint fillPaintDark = fillPaint; if (fillPaintDark instanceof Color) { fillPaintDark = ((Color) fillPaint).darker(); } boolean drawOutlines = isDrawBarOutline(); Paint outlinePaint = fillPaint; if (drawOutlines) { outlinePaint = getItemOutlinePaint(series, column); g2.setStroke(getItemOutlineStroke(series, column)); } for (int f = 0; f < 6; f++) { if (f == 5) { g2.setPaint(fillPaint); } else { g2.setPaint(fillPaintDark); } g2.fill(faces[f]); if (drawOutlines) { g2.setPaint(outlinePaint); g2.draw(faces[f]); } } itemLabelList.add(new Object[] {new Integer(series), faces[5].getBounds2D(), BooleanUtilities.valueOf(v0 < getBase())}); // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, series, column, faces[5]); } } for (int i = 0; i < itemLabelList.size(); i++) { Object[] record = (Object[]) itemLabelList.get(i); int series = ((Integer) record[0]).intValue(); Rectangle2D bar = (Rectangle2D) record[1]; boolean neg = ((Boolean) record[2]).booleanValue(); CategoryItemLabelGenerator generator = getItemLabelGenerator(series, column); if (generator != null && isItemLabelVisible(series, column)) { drawItemLabel(g2, dataset, series, column, plot, generator, bar, neg); } } } /** * Creates an array of shapes representing the six sides of a block in a * vertical stack. * * @param x0 left edge of bar (in Java2D space). * @param width the width of the bar (in Java2D units). * @param y0 the base of the block (in Java2D space). * @param y1 the top of the block (in Java2D space). * @param inverted a flag indicating whether or not the block is inverted * (this changes the order of the faces of the block). * * @return The sides of the block. */ private Shape[] createVerticalBlock(double x0, double width, double y0, double y1, boolean inverted) { Shape[] result = new Shape[6]; Point2D p00 = new Point2D.Double(x0, y0); Point2D p01 = new Point2D.Double(x0 + width, y0); Point2D p02 = new Point2D.Double(p01.getX() + getXOffset(), p01.getY() - getYOffset()); Point2D p03 = new Point2D.Double(p00.getX() + getXOffset(), p00.getY() - getYOffset()); Point2D p0 = new Point2D.Double(x0, y1); Point2D p1 = new Point2D.Double(x0 + width, y1); Point2D p2 = new Point2D.Double(p1.getX() + getXOffset(), p1.getY() - getYOffset()); Point2D p3 = new Point2D.Double(p0.getX() + getXOffset(), p0.getY() - getYOffset()); GeneralPath right = new GeneralPath(); right.moveTo((float) p1.getX(), (float) p1.getY()); right.lineTo((float) p01.getX(), (float) p01.getY()); right.lineTo((float) p02.getX(), (float) p02.getY()); right.lineTo((float) p2.getX(), (float) p2.getY()); right.closePath(); GeneralPath left = new GeneralPath(); left.moveTo((float) p0.getX(), (float) p0.getY()); left.lineTo((float) p00.getX(), (float) p00.getY()); left.lineTo((float) p03.getX(), (float) p03.getY()); left.lineTo((float) p3.getX(), (float) p3.getY()); left.closePath(); GeneralPath back = new GeneralPath(); back.moveTo((float) p2.getX(), (float) p2.getY()); back.lineTo((float) p02.getX(), (float) p02.getY()); back.lineTo((float) p03.getX(), (float) p03.getY()); back.lineTo((float) p3.getX(), (float) p3.getY()); back.closePath(); GeneralPath front = new GeneralPath(); front.moveTo((float) p0.getX(), (float) p0.getY()); front.lineTo((float) p1.getX(), (float) p1.getY()); front.lineTo((float) p01.getX(), (float) p01.getY()); front.lineTo((float) p00.getX(), (float) p00.getY()); front.closePath(); GeneralPath top = new GeneralPath(); top.moveTo((float) p0.getX(), (float) p0.getY()); top.lineTo((float) p1.getX(), (float) p1.getY()); top.lineTo((float) p2.getX(), (float) p2.getY()); top.lineTo((float) p3.getX(), (float) p3.getY()); top.closePath(); GeneralPath bottom = new GeneralPath(); bottom.moveTo((float) p00.getX(), (float) p00.getY()); bottom.lineTo((float) p01.getX(), (float) p01.getY()); bottom.lineTo((float) p02.getX(), (float) p02.getY()); bottom.lineTo((float) p03.getX(), (float) p03.getY()); bottom.closePath(); result[0] = bottom; result[1] = back; result[2] = left; result[3] = right; result[4] = top; result[5] = front; if (inverted) { result[0] = top; result[4] = bottom; } return result; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StackedBarRenderer3D)) { return false; } if (!super.equals(obj)) { return false; } StackedBarRenderer3D that = (StackedBarRenderer3D) obj; if (this.renderAsPercentages != that.getRenderAsPercentages()) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StandardBarPainter.java0000644000175000017500000001577311173030414032444 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * StandardBarPainter.java * ----------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); * 15-Aug-2008 : Use renderer's shadow paint (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.io.Serializable; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; /** * An implementation of the {@link BarPainter} interface that preserves the * behaviour of bar painting that existed prior to the introduction of the * {@link BarPainter} interface. * * @see GradientBarPainter * * @since 1.0.11 */ public class StandardBarPainter implements BarPainter, Serializable { /** * Creates a new instance. */ public StandardBarPainter() { } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. */ public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column); GradientPaintTransformer t = renderer.getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (renderer.isDrawBarOutline()) { // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. * @param pegShadow peg the shadow to the base of the bar? */ public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow) { // handle a special case - if the bar colour has alpha == 0, it is // invisible so we shouldn't draw any shadow Paint itemPaint = renderer.getItemPaint(row, column); if (itemPaint instanceof Color) { Color c = (Color) itemPaint; if (c.getAlpha() == 0) { return; } } RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); g2.setPaint(renderer.getShadowPaint()); g2.fill(shadow); } /** * Creates a shadow for the bar. * * @param bar the bar shape. * @param xOffset the x-offset for the shadow. * @param yOffset the y-offset for the shadow. * @param base the edge that is the base of the bar. * @param pegShadow peg the shadow to the base? * * @return A rectangle for the shadow. */ private Rectangle2D createShadow(RectangularShape bar, double xOffset, double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY(); if (base == RectangleEdge.TOP) { x0 += xOffset; x1 += xOffset; if (!pegShadow) { y0 += yOffset; } y1 += yOffset; } else if (base == RectangleEdge.BOTTOM) { x0 += xOffset; x1 += xOffset; y0 += yOffset; if (!pegShadow) { y1 += yOffset; } } else if (base == RectangleEdge.LEFT) { if (!pegShadow) { x0 += xOffset; } x1 += xOffset; y0 += yOffset; y1 += yOffset; } else if (base == RectangleEdge.RIGHT) { x0 += xOffset; if (!pegShadow) { x1 += xOffset; } y0 += yOffset; y1 += yOffset; } return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the obj (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardBarPainter)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 37; // no fields to compute... return hash; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java0000644000175000017500000005504511173030414033330 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StatisticalBarRenderer.java * --------------------------- * (C) Copyright 2002-2009, by Pascal Collet and Contributors. * * Original Author: Pascal Collet; * Contributor(s): David Gilbert (for Object Refinery Limited); * Christian W. Zuckschwerdt; * Peter Kolb (patch 2497611); * * Changes * ------- * 21-Aug-2002 : Version 1, contributed by Pascal Collet (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Changes to dataset interface (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 05-Feb-2003 : Updates for new DefaultStatisticalCategoryDataset (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 06-Oct-2003 : Corrected typo in exception message (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 15-Jun-2005 : Added errorIndicatorPaint attribute (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 19-May-2006 : Added support for tooltips and URLs (DG); * 12-Jul-2006 : Added support for item labels (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 28-Aug-2007 : Fixed NullPointerException - see bug 1779941 (DG); * 14-Nov-2007 : Added errorIndicatorStroke, and fixed bugs with drawBarOutline * and gradientPaintTransformer attributes being ignored (DG); * 14-Jan-2009 : Added support for seriesVisible flags (PK); * */ package org.jfree.chart.renderer.category; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.data.statistics.StatisticalCategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A renderer that handles the drawing a bar plot where * each bar has a mean value and a standard deviation line. The example shown * here is generated by the StatisticalBarChartDemo1.java program * included in the JFreeChart Demo Collection: *

* StatisticalBarRendererSample.png */ public class StatisticalBarRenderer extends BarRenderer implements CategoryItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -4986038395414039117L; /** The paint used to show the error indicator. */ private transient Paint errorIndicatorPaint; /** * The stroke used to draw the error indicators. * * @since 1.0.8 */ private transient Stroke errorIndicatorStroke; /** * Default constructor. */ public StatisticalBarRenderer() { super(); this.errorIndicatorPaint = Color.gray; this.errorIndicatorStroke = new BasicStroke(1.0f); } /** * Returns the paint used for the error indicators. * * @return The paint used for the error indicators (possibly * null). * * @see #setErrorIndicatorPaint(Paint) */ public Paint getErrorIndicatorPaint() { return this.errorIndicatorPaint; } /** * Sets the paint used for the error indicators (if null, * the item outline paint is used instead) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getErrorIndicatorPaint() */ public void setErrorIndicatorPaint(Paint paint) { this.errorIndicatorPaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the error indicators. If this is * null, the renderer will use the item outline stroke). * * @return The stroke (possibly null). * * @see #setErrorIndicatorStroke(Stroke) * * @since 1.0.8 */ public Stroke getErrorIndicatorStroke() { return this.errorIndicatorStroke; } /** * Sets the stroke used to draw the error indicators, and sends a * {@link RendererChangeEvent} to all registered listeners. If you set * this to null, the renderer will use the item outline * stroke. * * @param stroke the stroke (null permitted). * * @see #getErrorIndicatorStroke() * * @since 1.0.8 */ public void setErrorIndicatorStroke(Stroke stroke) { this.errorIndicatorStroke = stroke; fireChangeEvent(); } /** * Draws the bar with its standard deviation line range for a single * (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param data the data. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset data, int row, int column, int pass) { int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } // defensive check if (!(data instanceof StatisticalCategoryDataset)) { throw new IllegalArgumentException( "Requires StatisticalCategoryDataset."); } StatisticalCategoryDataset statData = (StatisticalCategoryDataset) data; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { drawHorizontalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, statData, visibleRow, row, column); } else if (orientation == PlotOrientation.VERTICAL) { drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, statData, visibleRow, row, column); } } /** * Draws an item for a plot with a horizontal orientation. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param visibleRow the visible row index. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawHorizontalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, StatisticalCategoryDataset dataset, int visibleRow, int row, int column) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); // BAR Y double rectY = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, xAxisLocation); int seriesCount = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : getRowCount(); int categoryCount = getColumnCount(); if (seriesCount > 1) { double seriesGap = dataArea.getHeight() * getItemMargin() / (categoryCount * (seriesCount - 1)); rectY = rectY + visibleRow * (state.getBarWidth() + seriesGap); } else { rectY = rectY + visibleRow * state.getBarWidth(); } // BAR X Number meanValue = dataset.getMeanValue(row, column); if (meanValue == null) { return; } double value = meanValue.doubleValue(); double base = 0.0; double lclip = getLowerClip(); double uclip = getUpperClip(); if (uclip <= 0.0) { // cases 1, 2, 3 and 4 if (value >= uclip) { return; // bar is not visible } base = uclip; if (value <= lclip) { value = lclip; } } else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 if (value >= uclip) { value = uclip; } else { if (value <= lclip) { value = lclip; } } } else { // cases 9, 10, 11 and 12 if (value <= lclip) { return; // bar is not visible } base = getLowerClip(); if (value >= uclip) { value = uclip; } } RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transY1 = rangeAxis.valueToJava2D(base, dataArea, yAxisLocation); double transY2 = rangeAxis.valueToJava2D(value, dataArea, yAxisLocation); double rectX = Math.min(transY2, transY1); double rectHeight = state.getBarWidth(); double rectWidth = Math.abs(transY2 - transY1); Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight); Paint itemPaint = getItemPaint(row, column); GradientPaintTransformer t = getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } // standard deviation lines Number n = dataset.getStdDevValue(row, column); if (n != null) { double valueDelta = n.doubleValue(); double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + valueDelta, dataArea, yAxisLocation); double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() - valueDelta, dataArea, yAxisLocation); if (this.errorIndicatorPaint != null) { g2.setPaint(this.errorIndicatorPaint); } else { g2.setPaint(getItemOutlinePaint(row, column)); } if (this.errorIndicatorStroke != null) { g2.setStroke(this.errorIndicatorStroke); } else { g2.setStroke(getItemOutlineStroke(row, column)); } Line2D line = null; line = new Line2D.Double(lowVal, rectY + rectHeight / 2.0d, highVal, rectY + rectHeight / 2.0d); g2.draw(line); line = new Line2D.Double(highVal, rectY + rectHeight * 0.25, highVal, rectY + rectHeight * 0.75); g2.draw(line); line = new Line2D.Double(lowVal, rectY + rectHeight * 0.25, lowVal, rectY + rectHeight * 0.75); g2.draw(line); } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Draws an item for a plot with a vertical orientation. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the data. * @param visibleRow the visible row index. * @param row the row index (zero-based). * @param column the column index (zero-based). */ protected void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, StatisticalCategoryDataset dataset, int visibleRow, int row, int column) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); // BAR X double rectX = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, xAxisLocation); int seriesCount = state.getVisibleSeriesCount() >= 0 ? state.getVisibleSeriesCount() : getRowCount(); int categoryCount = getColumnCount(); if (seriesCount > 1) { double seriesGap = dataArea.getWidth() * getItemMargin() / (categoryCount * (seriesCount - 1)); rectX = rectX + visibleRow * (state.getBarWidth() + seriesGap); } else { rectX = rectX + visibleRow * state.getBarWidth(); } // BAR Y Number meanValue = dataset.getMeanValue(row, column); if (meanValue == null) { return; } double value = meanValue.doubleValue(); double base = 0.0; double lclip = getLowerClip(); double uclip = getUpperClip(); if (uclip <= 0.0) { // cases 1, 2, 3 and 4 if (value >= uclip) { return; // bar is not visible } base = uclip; if (value <= lclip) { value = lclip; } } else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 if (value >= uclip) { value = uclip; } else { if (value <= lclip) { value = lclip; } } } else { // cases 9, 10, 11 and 12 if (value <= lclip) { return; // bar is not visible } base = getLowerClip(); if (value >= uclip) { value = uclip; } } RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transY1 = rangeAxis.valueToJava2D(base, dataArea, yAxisLocation); double transY2 = rangeAxis.valueToJava2D(value, dataArea, yAxisLocation); double rectY = Math.min(transY2, transY1); double rectWidth = state.getBarWidth(); double rectHeight = Math.abs(transY2 - transY1); Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight); Paint itemPaint = getItemPaint(row, column); GradientPaintTransformer t = getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } // standard deviation lines Number n = dataset.getStdDevValue(row, column); if (n != null) { double valueDelta = n.doubleValue(); double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + valueDelta, dataArea, yAxisLocation); double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() - valueDelta, dataArea, yAxisLocation); if (this.errorIndicatorPaint != null) { g2.setPaint(this.errorIndicatorPaint); } else { g2.setPaint(getItemOutlinePaint(row, column)); } if (this.errorIndicatorStroke != null) { g2.setStroke(this.errorIndicatorStroke); } else { g2.setStroke(getItemOutlineStroke(row, column)); } Line2D line = null; line = new Line2D.Double(rectX + rectWidth / 2.0d, lowVal, rectX + rectWidth / 2.0d, highVal); g2.draw(line); line = new Line2D.Double(rectX + rectWidth / 2.0d - 5.0d, highVal, rectX + rectWidth / 2.0d + 5.0d, highVal); g2.draw(line); line = new Line2D.Double(rectX + rectWidth / 2.0d - 5.0d, lowVal, rectX + rectWidth / 2.0d + 5.0d, lowVal); g2.draw(line); } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StatisticalBarRenderer)) { return false; } StatisticalBarRenderer that = (StatisticalBarRenderer) obj; if (!PaintUtilities.equal(this.errorIndicatorPaint, that.errorIndicatorPaint)) { return false; } if (!ObjectUtilities.equal(this.errorIndicatorStroke, that.errorIndicatorStroke)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.errorIndicatorPaint, stream); SerialUtilities.writeStroke(this.errorIndicatorStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.errorIndicatorPaint = SerialUtilities.readPaint(stream); this.errorIndicatorStroke = SerialUtilities.readStroke(stream); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.javalibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRende0000644000175000017500000004463511173030414033471 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * StatisticalLineAndShapeRenderer.java * ------------------------------------ * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: Mofeed Shahin; * Contributor(s): David Gilbert (for Object Refinery Limited); * Peter Kolb (patch 2497611); * * Changes * ------- * 01-Feb-2005 : Version 1, contributed by Mofeed Shahin (DG); * 16-Jun-2005 : Added errorIndicatorPaint to be consistent with * StatisticalBarRenderer (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Apr-2006 : Fixed bug 1468794, error bars drawn incorrectly when rendering * plots with horizontal orientation (DG); * 25-Sep-2006 : Fixed bug 1562759, constructor ignoring arguments (DG); * 01-Jun-2007 : Return early from drawItem() method if item is not * visible (DG); * 14-Jun-2007 : If the dataset is not a StatisticalCategoryDataset, revert * to the drawing behaviour of LineAndShapeRenderer (DG); * 27-Sep-2007 : Added offset option to match new option in * LineAndShapeRenderer (DG); * 14-Jan-2009 : Added support for seriesVisible flags (PK); * 23-Jan-2009 : Observe useFillPaint and drawOutlines flags (PK); * 23-Jan-2009 : In drawItem, divide code into passes (DG); * 05-Feb-2009 : Added errorIndicatorStroke field (DG); * 01-Apr-2009 : Added override for findRangeBounds(), and fixed NPE in * creating item entities (DG); */ package org.jfree.chart.renderer.category; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.statistics.StatisticalCategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that draws shapes for each data item, and lines between data * items. Each point has a mean value and a standard deviation line. For use * with the {@link CategoryPlot} class. The example shown * here is generated by the StatisticalLineChartDemo1.java program * included in the JFreeChart Demo Collection: *

* StatisticalLineRendererSample.png */ public class StatisticalLineAndShapeRenderer extends LineAndShapeRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3557517173697777579L; /** The paint used to show the error indicator. */ private transient Paint errorIndicatorPaint; /** * The stroke used to draw the error indicators. If null, the renderer * will use the itemOutlineStroke. * * @since 1.0.13 */ private transient Stroke errorIndicatorStroke; /** * Constructs a default renderer (draws shapes and lines). */ public StatisticalLineAndShapeRenderer() { this(true, true); } /** * Constructs a new renderer. * * @param linesVisible draw lines? * @param shapesVisible draw shapes? */ public StatisticalLineAndShapeRenderer(boolean linesVisible, boolean shapesVisible) { super(linesVisible, shapesVisible); this.errorIndicatorPaint = null; this.errorIndicatorStroke = null; } /** * Returns the paint used for the error indicators. * * @return The paint used for the error indicators (possibly * null). * * @see #setErrorIndicatorPaint(Paint) */ public Paint getErrorIndicatorPaint() { return this.errorIndicatorPaint; } /** * Sets the paint used for the error indicators (if null, * the item paint is used instead) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getErrorIndicatorPaint() */ public void setErrorIndicatorPaint(Paint paint) { this.errorIndicatorPaint = paint; fireChangeEvent(); } /** * Returns the stroke used for the error indicators. * * @return The stroke used for the error indicators (possibly * null). * * @see #setErrorIndicatorStroke(Stroke) * * @since 1.0.13 */ public Stroke getErrorIndicatorStroke() { return this.errorIndicatorStroke; } /** * Sets the stroke used for the error indicators (if null, * the item outline stroke is used instead) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @see #getErrorIndicatorStroke() * * @since 1.0.13 */ public void setErrorIndicatorStroke(Stroke stroke) { this.errorIndicatorStroke = stroke; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(CategoryDataset dataset) { return findRangeBounds(dataset, true); } /** * Draw a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area in which the data is drawn. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (a {@link StatisticalCategoryDataset} is * required). * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // do nothing if item is not visible if (!getItemVisible(row, column)) { return; } // if the dataset is not a StatisticalCategoryDataset then just revert // to the superclass (LineAndShapeRenderer) behaviour... if (!(dataset instanceof StatisticalCategoryDataset)) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); return; } int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } int visibleRowCount = state.getVisibleSeriesCount(); StatisticalCategoryDataset statDataset = (StatisticalCategoryDataset) dataset; Number meanValue = statDataset.getMeanValue(row, column); if (meanValue == null) { return; } PlotOrientation orientation = plot.getOrientation(); // current data point... double x1; if (getUseSeriesOffset()) { x1 = domainAxis.getCategorySeriesMiddle(column, dataset.getColumnCount(), visibleRow, visibleRowCount, getItemMargin(), dataArea, plot.getDomainAxisEdge()); } else { x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double y1 = rangeAxis.valueToJava2D(meanValue.doubleValue(), dataArea, plot.getRangeAxisEdge()); // draw the standard deviation lines *before* the shapes (if they're // visible) - it looks better if the shape fill colour is different to // the line colour Number sdv = statDataset.getStdDevValue(row, column); if (pass == 1 && sdv != null) { //standard deviation lines RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double valueDelta = sdv.doubleValue(); double highVal, lowVal; if ((meanValue.doubleValue() + valueDelta) > rangeAxis.getRange().getUpperBound()) { highVal = rangeAxis.valueToJava2D( rangeAxis.getRange().getUpperBound(), dataArea, yAxisLocation); } else { highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + valueDelta, dataArea, yAxisLocation); } if ((meanValue.doubleValue() + valueDelta) < rangeAxis.getRange().getLowerBound()) { lowVal = rangeAxis.valueToJava2D( rangeAxis.getRange().getLowerBound(), dataArea, yAxisLocation); } else { lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() - valueDelta, dataArea, yAxisLocation); } if (this.errorIndicatorPaint != null) { g2.setPaint(this.errorIndicatorPaint); } else { g2.setPaint(getItemPaint(row, column)); } if (this.errorIndicatorStroke != null) { g2.setStroke(this.errorIndicatorStroke); } else { g2.setStroke(getItemOutlineStroke(row, column)); } Line2D line = new Line2D.Double(); if (orientation == PlotOrientation.HORIZONTAL) { line.setLine(lowVal, x1, highVal, x1); g2.draw(line); line.setLine(lowVal, x1 - 5.0d, lowVal, x1 + 5.0d); g2.draw(line); line.setLine(highVal, x1 - 5.0d, highVal, x1 + 5.0d); g2.draw(line); } else { // PlotOrientation.VERTICAL line.setLine(x1, lowVal, x1, highVal); g2.draw(line); line.setLine(x1 - 5.0d, highVal, x1 + 5.0d, highVal); g2.draw(line); line.setLine(x1 - 5.0d, lowVal, x1 + 5.0d, lowVal); g2.draw(line); } } Shape hotspot = null; if (pass == 1 && getItemShapeVisible(row, column)) { Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); } hotspot = shape; if (getItemShapeFilled(row, column)) { if (getUseFillPaint()) { g2.setPaint(getItemFillPaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.fill(shape); } if (getDrawOutlines()) { if (getUseOutlinePaint()) { g2.setPaint(getItemOutlinePaint(row, column)); } else { g2.setPaint(getItemPaint(row, column)); } g2.setStroke(getItemOutlineStroke(row, column)); g2.draw(shape); } // draw the item label if there is one... if (isItemLabelVisible(row, column)) { if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (meanValue.doubleValue() < 0.0)); } else if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (meanValue.doubleValue() < 0.0)); } } } if (pass == 0 && getItemLineVisible(row, column)) { if (column != 0) { Number previousValue = statDataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0; if (getUseSeriesOffset()) { x0 = domainAxis.getCategorySeriesMiddle( column - 1, dataset.getColumnCount(), visibleRow, visibleRowCount, getItemMargin(), dataArea, plot.getDomainAxisEdge()); } else { x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(y0, x0, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(x0, y0, x1, y1); } g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); g2.draw(line); } } } if (pass == 1) { // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addEntity(entities, hotspot, dataset, row, column, x1, y1); } } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StatisticalLineAndShapeRenderer)) { return false; } StatisticalLineAndShapeRenderer that = (StatisticalLineAndShapeRenderer) obj; if (!PaintUtilities.equal(this.errorIndicatorPaint, that.errorIndicatorPaint)) { return false; } if (!ObjectUtilities.equal(this.errorIndicatorStroke, that.errorIndicatorStroke)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = super.hashCode(); hash = HashUtilities.hashCode(hash, this.errorIndicatorPaint); return hash; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.errorIndicatorPaint, stream); SerialUtilities.writeStroke(this.errorIndicatorStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.errorIndicatorPaint = SerialUtilities.readPaint(stream); this.errorIndicatorStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java0000644000175000017500000004561711173030414032771 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * WaterfallBarRenderer.java * ------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: Darshan Shah; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 20-Oct-2003 : Version 1, contributed by Darshan Shah (DG); * 06-Nov-2003 : Changed order of parameters in constructor, and added support * for GradientPaint (DG); * 10-Feb-2004 : Updated drawItem() method to make cut-and-paste overriding * easier. Also fixed a bug that meant the minimum bar length * was being ignored (DG); * 04-Oct-2004 : Reworked equals() method and renamed PaintUtils * --> PaintUtilities (DG); * 05-Nov-2004 : Modified drawItem() signature (DG); * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); * 23-Feb-2005 : Added argument checking (DG); * 20-Apr-2005 : Renamed CategoryLabelGenerator * --> CategoryItemLabelGenerator (DG); * 09-Jun-2005 : Use addItemEntity() from superclass (DG); * 27-Mar-2008 : Fixed error in findRangeBounds() method (DG); * 26-Sep-2008 : Fixed bug with bar alignment when maximumBarWidth is * applied (DG); * 04-Feb-2009 : Updated findRangeBounds to handle null dataset consistently * with other renderers (DG); * */ package org.jfree.chart.renderer.category; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.CategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.AbstractRenderer; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.RectangleEdge; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.PaintUtilities; /** * A renderer that handles the drawing of waterfall bar charts, for use with * the {@link CategoryPlot} class. Some quirks to note: *

    *
  • the value in the last category of the dataset should be (redundantly) * specified as the sum of the items in the preceding categories - otherwise * the final bar in the plot will be incorrectly plotted;
  • *
  • the bar colors are defined using special methods in this class - the * inherited methods (for example, * {@link AbstractRenderer#setSeriesPaint(int, Paint)}) are ignored;
  • *
* The example shown here is generated by the * WaterfallChartDemo1.java program included in the JFreeChart * Demo Collection: *

* WaterfallBarRendererSample.png */ public class WaterfallBarRenderer extends BarRenderer { /** For serialization. */ private static final long serialVersionUID = -2482910643727230911L; /** The paint used to draw the first bar. */ private transient Paint firstBarPaint; /** The paint used to draw the last bar. */ private transient Paint lastBarPaint; /** The paint used to draw bars having positive values. */ private transient Paint positiveBarPaint; /** The paint used to draw bars having negative values. */ private transient Paint negativeBarPaint; /** * Constructs a new renderer with default values for the bar colors. */ public WaterfallBarRenderer() { this(new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)), new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)), new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66))); } /** * Constructs a new waterfall renderer. * * @param firstBarPaint the color of the first bar (null not * permitted). * @param positiveBarPaint the color for bars with positive values * (null not permitted). * @param negativeBarPaint the color for bars with negative values * (null not permitted). * @param lastBarPaint the color of the last bar (null not * permitted). */ public WaterfallBarRenderer(Paint firstBarPaint, Paint positiveBarPaint, Paint negativeBarPaint, Paint lastBarPaint) { super(); if (firstBarPaint == null) { throw new IllegalArgumentException("Null 'firstBarPaint' argument"); } if (positiveBarPaint == null) { throw new IllegalArgumentException( "Null 'positiveBarPaint' argument"); } if (negativeBarPaint == null) { throw new IllegalArgumentException( "Null 'negativeBarPaint' argument"); } if (lastBarPaint == null) { throw new IllegalArgumentException("Null 'lastBarPaint' argument"); } this.firstBarPaint = firstBarPaint; this.lastBarPaint = lastBarPaint; this.positiveBarPaint = positiveBarPaint; this.negativeBarPaint = negativeBarPaint; setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); setMinimumBarLength(1.0); } /** * Returns the paint used to draw the first bar. * * @return The paint (never null). */ public Paint getFirstBarPaint() { return this.firstBarPaint; } /** * Sets the paint that will be used to draw the first bar and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). */ public void setFirstBarPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument"); } this.firstBarPaint = paint; fireChangeEvent(); } /** * Returns the paint used to draw the last bar. * * @return The paint (never null). */ public Paint getLastBarPaint() { return this.lastBarPaint; } /** * Sets the paint that will be used to draw the last bar and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). */ public void setLastBarPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument"); } this.lastBarPaint = paint; fireChangeEvent(); } /** * Returns the paint used to draw bars with positive values. * * @return The paint (never null). */ public Paint getPositiveBarPaint() { return this.positiveBarPaint; } /** * Sets the paint that will be used to draw bars having positive values. * * @param paint the paint (null not permitted). */ public void setPositiveBarPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument"); } this.positiveBarPaint = paint; fireChangeEvent(); } /** * Returns the paint used to draw bars with negative values. * * @return The paint (never null). */ public Paint getNegativeBarPaint() { return this.negativeBarPaint; } /** * Sets the paint that will be used to draw bars having negative values, * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). */ public void setNegativeBarPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument"); } this.negativeBarPaint = paint; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null not permitted). * * @return The range (or null if the dataset is empty). */ public Range findRangeBounds(CategoryDataset dataset) { if (dataset == null) { return null; } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... double minimum = 0.0; double maximum = 0.0; int columnCount = dataset.getColumnCount(); for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= columnCount - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (column == columnCount - 1) { // treat the last column value as an absolute runningTotal = value; } else { runningTotal = runningTotal + value; } minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } } /** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { double previous = state.getSeriesRunningTotal(); if (column == dataset.getColumnCount() - 1) { previous = 0.0; } double current = 0.0; Number n = dataset.getValue(row, column); if (n != null) { current = previous + n.doubleValue(); } state.setSeriesRunningTotal(current); int categoryCount = getColumnCount(); PlotOrientation orientation = plot.getOrientation(); double rectX = 0.0; double rectY = 0.0; RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // Y0 double j2dy0 = rangeAxis.valueToJava2D(previous, dataArea, rangeAxisLocation); // Y1 double j2dy1 = rangeAxis.valueToJava2D(current, dataArea, rangeAxisLocation); double valDiff = current - previous; if (j2dy1 < j2dy0) { double temp = j2dy1; j2dy1 = j2dy0; j2dy0 = temp; } // BAR WIDTH double rectWidth = state.getBarWidth(); // BAR HEIGHT double rectHeight = Math.max(getMinimumBarLength(), Math.abs(j2dy1 - j2dy0)); Comparable seriesKey = dataset.getRowKey(row); Comparable categoryKey = dataset.getColumnKey(column); if (orientation == PlotOrientation.HORIZONTAL) { rectY = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, dataset, getItemMargin(), dataArea, RectangleEdge.LEFT); rectX = j2dy0; rectHeight = state.getBarWidth(); rectY = rectY - rectHeight / 2.0; rectWidth = Math.max(getMinimumBarLength(), Math.abs(j2dy1 - j2dy0)); } else if (orientation == PlotOrientation.VERTICAL) { rectX = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, dataset, getItemMargin(), dataArea, RectangleEdge.TOP); rectX = rectX - rectWidth / 2.0; rectY = j2dy0; } Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, rectHeight); Paint seriesPaint = getFirstBarPaint(); if (column == 0) { seriesPaint = getFirstBarPaint(); } else if (column == categoryCount - 1) { seriesPaint = getLastBarPaint(); } else { if (valDiff < 0.0) { seriesPaint = getNegativeBarPaint(); } else if (valDiff > 0.0) { seriesPaint = getPositiveBarPaint(); } else { seriesPaint = getLastBarPaint(); } } if (getGradientPaintTransformer() != null && seriesPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) seriesPaint; seriesPaint = getGradientPaintTransformer().transform(gp, bar); } g2.setPaint(seriesPaint); g2.fill(bar); // draw the outline... if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = getItemOutlineStroke(row, column); Paint paint = getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (valDiff < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, bar); } } /** * Tests an object for equality with this instance. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof WaterfallBarRenderer)) { return false; } WaterfallBarRenderer that = (WaterfallBarRenderer) obj; if (!PaintUtilities.equal(this.firstBarPaint, that.firstBarPaint)) { return false; } if (!PaintUtilities.equal(this.lastBarPaint, that.lastBarPaint)) { return false; } if (!PaintUtilities.equal(this.positiveBarPaint, that.positiveBarPaint)) { return false; } if (!PaintUtilities.equal(this.negativeBarPaint, that.negativeBarPaint)) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.firstBarPaint, stream); SerialUtilities.writePaint(this.lastBarPaint, stream); SerialUtilities.writePaint(this.positiveBarPaint, stream); SerialUtilities.writePaint(this.negativeBarPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.firstBarPaint = SerialUtilities.readPaint(stream); this.lastBarPaint = SerialUtilities.readPaint(stream); this.positiveBarPaint = SerialUtilities.readPaint(stream); this.negativeBarPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/category/package.html0000644000175000017500000000026711173030414030342 0ustar vincentvincent Plug-in renderers for the {@link org.jfree.chart.plot.CategoryPlot} class. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/0000755000175000017500000000000011216245562024711 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java0000644000175000017500000021627511173030414032111 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * AbstractXYItemRenderer.java * --------------------------- * (C) Copyright 2002-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Focus Computer Services Limited; * Tim Bardzil; * Sergei Ivanov; * * Changes: * -------- * 15-Mar-2002 : Version 1 (DG); * 09-Apr-2002 : Added a getToolTipGenerator() method reflecting the change in * the XYItemRenderer interface (DG); * 05-Aug-2002 : Added a urlGenerator member variable to support HTML image * maps (RA); * 20-Aug-2002 : Added property change events for the tooltip and URL * generators (DG); * 22-Aug-2002 : Moved property change support into AbstractRenderer class (DG); * 23-Sep-2002 : Fixed errors reported by Checkstyle tool (DG); * 18-Nov-2002 : Added methods for drawing grid lines (DG); * 17-Jan-2003 : Moved plot classes into a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified initialise() return type and drawItem() method * signature (DG); * 15-May-2003 : Modified to take into account the plot orientation (DG); * 21-May-2003 : Added labels to markers (DG); * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer * Services Ltd) (DG); * 27-Jul-2003 : Added getRangeType() to support stacked XY area charts (RA); * 31-Jul-2003 : Deprecated all but the default constructor (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 05-Nov-2003 : Fixed marker rendering bug (833623) (DG); * 11-Feb-2004 : Updated labelling for markers (DG); * 25-Feb-2004 : Added updateCrosshairValues() method. Moved deprecated code * to bottom of source file (DG); * 16-Apr-2004 : Added support for IntervalMarker in drawRangeMarker() method * - thanks to Tim Bardzil (DG); * 05-May-2004 : Fixed bug (948310) where interval markers extend beyond axis * range (DG); * 03-Jun-2004 : Fixed more bugs in drawing interval markers (DG); * 26-Aug-2004 : Added the addEntity() method (DG); * 29-Sep-2004 : Added annotation support (with layers) (DG); * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities --> * TextUtilities (DG); * 06-Oct-2004 : Added findDomainBounds() method and renamed * getRangeExtent() --> findRangeBounds() (DG); * 07-Jan-2005 : Removed deprecated code (DG); * 27-Jan-2005 : Modified getLegendItem() to omit hidden series (DG); * 24-Feb-2005 : Added getLegendItems() method (DG); * 08-Mar-2005 : Fixed positioning of marker labels (DG); * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator and * added generators for legend labels, tooltips and URLs (DG); * 01-Jun-2005 : Handle one dimension of the marker label adjustment * automatically (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG); * 24-Oct-2006 : Respect alpha setting in markers (see patch 1567843 by Sergei * Ivanov) (DG); * 24-Oct-2006 : Added code to draw outlines for interval markers (DG); * 24-Nov-2006 : Fixed cloning for legend item generators (DG); * 06-Feb-2007 : Added new updateCrosshairValues() method that takes into * account multiple axis plots (see bug 1086307) (DG); * 20-Feb-2007 : Fixed equals() method implementation (DG); * 01-Mar-2007 : Fixed interval marker drawing (patch 1670686 thanks to * Sergei Ivanov) (DG); * 22-Mar-2007 : Modified the tool tip generator look up (DG); * 23-Mar-2007 : Added drawDomainLine() method (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change, and deprecated * itemLabelGenerator and toolTipGenerator override fields (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 12-Nov-2007 : Fixed domain and range band drawing methods (DG); * 07-Apr-2008 : Minor API doc update (DG); * 14-May-2008 : Updated addEntity() method to take plot orientation into * account when the incoming area is null (DG); * 02-Jun-2008 : Added isPointInRect() method (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 09-Mar-2009 : Added getAnnotations() method (DG); * 27-Mar-2009 : Added new findDomainBounds() and findRangeBounds() methods to * take account of hidden series (DG); * 01-Apr-2009 : Moved defaultEntityRadius up to superclass (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.annotations.XYAnnotation; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.XYItemEntity; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.labels.XYSeriesLabelGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.DrawingSupplier; import org.jfree.chart.plot.IntervalMarker; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.AbstractRenderer; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.text.TextUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.Layer; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.util.ObjectList; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A base class that can be used to create new {@link XYItemRenderer} * implementations. */ public abstract class AbstractXYItemRenderer extends AbstractRenderer implements XYItemRenderer, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8019124836026607990L; /** The plot. */ private XYPlot plot; /** A list of item label generators (one per series). */ private ObjectList itemLabelGeneratorList; /** The base item label generator. */ private XYItemLabelGenerator baseItemLabelGenerator; /** A list of tool tip generators (one per series). */ private ObjectList toolTipGeneratorList; /** The base tool tip generator. */ private XYToolTipGenerator baseToolTipGenerator; /** The URL text generator. */ private XYURLGenerator urlGenerator; /** * Annotations to be drawn in the background layer ('underneath' the data * items). */ private List backgroundAnnotations; /** * Annotations to be drawn in the foreground layer ('on top' of the data * items). */ private List foregroundAnnotations; /** The legend item label generator. */ private XYSeriesLabelGenerator legendItemLabelGenerator; /** The legend item tool tip generator. */ private XYSeriesLabelGenerator legendItemToolTipGenerator; /** The legend item URL generator. */ private XYSeriesLabelGenerator legendItemURLGenerator; /** * Creates a renderer where the tooltip generator and the URL generator are * both null. */ protected AbstractXYItemRenderer() { super(); this.itemLabelGenerator = null; this.itemLabelGeneratorList = new ObjectList(); this.toolTipGenerator = null; this.toolTipGeneratorList = new ObjectList(); this.urlGenerator = null; this.backgroundAnnotations = new java.util.ArrayList(); this.foregroundAnnotations = new java.util.ArrayList(); this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator( "{0}"); } /** * Returns the number of passes through the data that the renderer requires * in order to draw the chart. Most charts will require a single pass, but * some require two passes. * * @return The pass count. */ public int getPassCount() { return 1; } /** * Returns the plot that the renderer is assigned to. * * @return The plot (possibly null). */ public XYPlot getPlot() { return this.plot; } /** * Sets the plot that the renderer is assigned to. * * @param plot the plot (null permitted). */ public void setPlot(XYPlot plot) { this.plot = plot; } /** * Initialises the renderer and returns a state object that should be * passed to all subsequent calls to the drawItem() method. *

* This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state (never null). */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { XYItemRendererState state = new XYItemRendererState(info); return state; } // ITEM LABEL GENERATOR /** * Returns the label generator for a data item. This implementation simply * passes control to the {@link #getSeriesItemLabelGenerator(int)} method. * If, for some reason, you want a different generator for individual * items, you can override this method. * * @param series the series index (zero based). * @param item the item index (zero based). * * @return The generator (possibly null). */ public XYItemLabelGenerator getItemLabelGenerator(int series, int item) { // return the generator for ALL series, if there is one... if (this.itemLabelGenerator != null) { return this.itemLabelGenerator; } // otherwise look up the generator table XYItemLabelGenerator generator = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series); if (generator == null) { generator = this.baseItemLabelGenerator; } return generator; } /** * Returns the item label generator for a series. * * @param series the series index (zero based). * * @return The generator (possibly null). */ public XYItemLabelGenerator getSeriesItemLabelGenerator(int series) { return (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series); } /** * Sets the item label generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param generator the generator (null permitted). */ public void setSeriesItemLabelGenerator(int series, XYItemLabelGenerator generator) { this.itemLabelGeneratorList.set(series, generator); fireChangeEvent(); } /** * Returns the base item label generator. * * @return The generator (possibly null). */ public XYItemLabelGenerator getBaseItemLabelGenerator() { return this.baseItemLabelGenerator; } /** * Sets the base item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). */ public void setBaseItemLabelGenerator(XYItemLabelGenerator generator) { this.baseItemLabelGenerator = generator; fireChangeEvent(); } // TOOL TIP GENERATOR /** * Returns the tool tip generator for a data item. If, for some reason, * you want a different generator for individual items, you can override * this method. * * @param series the series index (zero based). * @param item the item index (zero based). * * @return The generator (possibly null). */ public XYToolTipGenerator getToolTipGenerator(int series, int item) { // return the generator for ALL series, if there is one... if (this.toolTipGenerator != null) { return this.toolTipGenerator; } // otherwise look up the generator table XYToolTipGenerator generator = (XYToolTipGenerator) this.toolTipGeneratorList.get(series); if (generator == null) { generator = this.baseToolTipGenerator; } return generator; } /** * Returns the tool tip generator for a series. * * @param series the series index (zero based). * * @return The generator (possibly null). */ public XYToolTipGenerator getSeriesToolTipGenerator(int series) { return (XYToolTipGenerator) this.toolTipGeneratorList.get(series); } /** * Sets the tool tip generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param generator the generator (null permitted). */ public void setSeriesToolTipGenerator(int series, XYToolTipGenerator generator) { this.toolTipGeneratorList.set(series, generator); fireChangeEvent(); } /** * Returns the base tool tip generator. * * @return The generator (possibly null). * * @see #setBaseToolTipGenerator(XYToolTipGenerator) */ public XYToolTipGenerator getBaseToolTipGenerator() { return this.baseToolTipGenerator; } /** * Sets the base tool tip generator and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param generator the generator (null permitted). * * @see #getBaseToolTipGenerator() */ public void setBaseToolTipGenerator(XYToolTipGenerator generator) { this.baseToolTipGenerator = generator; fireChangeEvent(); } // URL GENERATOR /** * Returns the URL generator for HTML image maps. * * @return The URL generator (possibly null). */ public XYURLGenerator getURLGenerator() { return this.urlGenerator; } /** * Sets the URL generator for HTML image maps and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param urlGenerator the URL generator (null permitted). */ public void setURLGenerator(XYURLGenerator urlGenerator) { this.urlGenerator = urlGenerator; fireChangeEvent(); } /** * Adds an annotation and sends a {@link RendererChangeEvent} to all * registered listeners. The annotation is added to the foreground * layer. * * @param annotation the annotation (null not permitted). */ public void addAnnotation(XYAnnotation annotation) { // defer argument checking addAnnotation(annotation, Layer.FOREGROUND); } /** * Adds an annotation to the specified layer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param annotation the annotation (null not permitted). * @param layer the layer (null not permitted). */ public void addAnnotation(XYAnnotation annotation, Layer layer) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } if (layer.equals(Layer.FOREGROUND)) { this.foregroundAnnotations.add(annotation); fireChangeEvent(); } else if (layer.equals(Layer.BACKGROUND)) { this.backgroundAnnotations.add(annotation); fireChangeEvent(); } else { // should never get here throw new RuntimeException("Unknown layer."); } } /** * Removes the specified annotation and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param annotation the annotation to remove (null not * permitted). * * @return A boolean to indicate whether or not the annotation was * successfully removed. */ public boolean removeAnnotation(XYAnnotation annotation) { boolean removed = this.foregroundAnnotations.remove(annotation); removed = removed & this.backgroundAnnotations.remove(annotation); fireChangeEvent(); return removed; } /** * Removes all annotations and sends a {@link RendererChangeEvent} * to all registered listeners. */ public void removeAnnotations() { this.foregroundAnnotations.clear(); this.backgroundAnnotations.clear(); fireChangeEvent(); } /** * Returns a collection of the annotations that are assigned to the * renderer. * * @return A collection of annotations (possibly empty but never * null). * * @since 1.0.13 */ public Collection getAnnotations() { List result = new java.util.ArrayList(this.foregroundAnnotations); result.addAll(this.backgroundAnnotations); return result; } /** * Returns the legend item label generator. * * @return The label generator (never null). * * @see #setLegendItemLabelGenerator(XYSeriesLabelGenerator) */ public XYSeriesLabelGenerator getLegendItemLabelGenerator() { return this.legendItemLabelGenerator; } /** * Sets the legend item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null not permitted). * * @see #getLegendItemLabelGenerator() */ public void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } this.legendItemLabelGenerator = generator; fireChangeEvent(); } /** * Returns the legend item tool tip generator. * * @return The tool tip generator (possibly null). * * @see #setLegendItemToolTipGenerator(XYSeriesLabelGenerator) */ public XYSeriesLabelGenerator getLegendItemToolTipGenerator() { return this.legendItemToolTipGenerator; } /** * Sets the legend item tool tip generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getLegendItemToolTipGenerator() */ public void setLegendItemToolTipGenerator( XYSeriesLabelGenerator generator) { this.legendItemToolTipGenerator = generator; fireChangeEvent(); } /** * Returns the legend item URL generator. * * @return The URL generator (possibly null). * * @see #setLegendItemURLGenerator(XYSeriesLabelGenerator) */ public XYSeriesLabelGenerator getLegendItemURLGenerator() { return this.legendItemURLGenerator; } /** * Sets the legend item URL generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getLegendItemURLGenerator() */ public void setLegendItemURLGenerator(XYSeriesLabelGenerator generator) { this.legendItemURLGenerator = generator; fireChangeEvent(); } /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @see #findRangeBounds(XYDataset) */ public Range findDomainBounds(XYDataset dataset) { return findDomainBounds(dataset, false); } /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @since 1.0.13 */ protected Range findDomainBounds(XYDataset dataset, boolean includeInterval) { if (dataset == null) { return null; } if (getDataBoundsIncludesVisibleSeriesOnly()) { List visibleSeriesKeys = new ArrayList(); int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { if (isSeriesVisible(s)) { visibleSeriesKeys.add(dataset.getSeriesKey(s)); } } return DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, includeInterval); } else { return DatasetUtilities.findDomainBounds(dataset, includeInterval); } } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @see #findDomainBounds(XYDataset) */ public Range findRangeBounds(XYDataset dataset) { return findRangeBounds(dataset, false); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @since 1.0.13 */ protected Range findRangeBounds(XYDataset dataset, boolean includeInterval) { if (dataset == null) { return null; } if (getDataBoundsIncludesVisibleSeriesOnly()) { List visibleSeriesKeys = new ArrayList(); int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { if (isSeriesVisible(s)) { visibleSeriesKeys.add(dataset.getSeriesKey(s)); } } // the bounds should be calculated using just the items within // the current range of the x-axis...if there is one Range xRange = null; XYPlot p = getPlot(); if (p != null) { ValueAxis xAxis = null; int index = p.getIndexOf(this); if (index >= 0) { xAxis = plot.getDomainAxisForDataset(index); } if (xAxis != null) { xRange = xAxis.getRange(); } } if (xRange == null) { xRange = new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); } return DatasetUtilities.findRangeBounds(dataset, visibleSeriesKeys, xRange, includeInterval); } else { return DatasetUtilities.findRangeBounds(dataset, includeInterval); } } /** * Returns a (possibly empty) collection of legend items for the series * that this renderer is responsible for drawing. * * @return The legend item collection (never null). */ public LegendItemCollection getLegendItems() { if (this.plot == null) { return new LegendItemCollection(); } LegendItemCollection result = new LegendItemCollection(); int index = this.plot.getIndexOf(this); XYDataset dataset = this.plot.getDataset(index); if (dataset != null) { int seriesCount = dataset.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { if (isSeriesVisibleInLegend(i)) { LegendItem item = getLegendItem(index, i); if (item != null) { result.add(item); } } } } return result; } /** * Returns a default legend item for the specified series. Subclasses * should override this method to generate customised items. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot xyplot = getPlot(); if (xyplot != null) { XYDataset dataset = xyplot.getDataset(datasetIndex); if (dataset != null) { String label = this.legendItemLabelGenerator.generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); Paint labelPaint = lookupLegendTextPaint(series); result.setLabelFont(lookupLegendTextFont(series)); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); } } return result; } /** * Fills a band between two values on the axis. This can be used to color * bands between the grid lines. * * @param g2 the graphics device. * @param plot the plot. * @param axis the domain axis. * @param dataArea the data area. * @param start the start value. * @param end the end value. */ public void fillDomainGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end) { double x1 = axis.valueToJava2D(start, dataArea, plot.getDomainAxisEdge()); double x2 = axis.valueToJava2D(end, dataArea, plot.getDomainAxisEdge()); Rectangle2D band; if (plot.getOrientation() == PlotOrientation.VERTICAL) { band = new Rectangle2D.Double(Math.min(x1, x2), dataArea.getMinY(), Math.abs(x2 - x1), dataArea.getWidth()); } else { band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(x1, x2), dataArea.getWidth(), Math.abs(x2 - x1)); } Paint paint = plot.getDomainTickBandPaint(); if (paint != null) { g2.setPaint(paint); g2.fill(band); } } /** * Fills a band between two values on the range axis. This can be used to * color bands between the grid lines. * * @param g2 the graphics device. * @param plot the plot. * @param axis the range axis. * @param dataArea the data area. * @param start the start value. * @param end the end value. */ public void fillRangeGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end) { double y1 = axis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); double y2 = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); Rectangle2D band; if (plot.getOrientation() == PlotOrientation.VERTICAL) { band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(y1, y2), dataArea.getWidth(), Math.abs(y2 - y1)); } else { band = new Rectangle2D.Double(Math.min(y1, y2), dataArea.getMinY(), Math.abs(y2 - y1), dataArea.getHeight()); } Paint paint = plot.getRangeTickBandPaint(); if (paint != null) { g2.setPaint(paint); g2.fill(band); } } /** * Draws a grid line against the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value at which the grid line should be drawn. */ public void drawDomainGridLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); double v = axis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } Paint paint = plot.getDomainGridlinePaint(); Stroke stroke = plot.getDomainGridlineStroke(); g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); g2.draw(line); } /** * Draws a line perpendicular to the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D * effect). * @param value the value at which the grid line should be drawn. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). * * @since 1.0.5 */ public void drawDomainLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); Line2D line = null; double v = axis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge()); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); } /** * Draws a line perpendicular to the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any 3D * effect). * @param value the value at which the grid line should be drawn. * @param paint the paint. * @param stroke the stroke. */ public void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { Range range = axis.getRange(); if (!range.contains(value)) { return; } PlotOrientation orientation = plot.getOrientation(); Line2D line = null; double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); } /** * Draws a vertical line on the chart to represent a 'range marker'. * * @param g2 the graphics device. * @param plot the plot. * @param domainAxis the domain axis. * @param marker the marker line. * @param dataArea the axis data area. */ public void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis domainAxis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = domainAxis.getRange(); if (!range.contains(value)) { return; } double v = domainAxis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge()); PlotOrientation orientation = plot.getOrientation(); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } final Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); g2.setPaint(marker.getPaint()); g2.setStroke(marker.getStroke()); g2.draw(line); String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateDomainMarkerTextAnchorPoint( g2, orientation, dataArea, line.getBounds2D(), marker.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(originalComposite); } else if (marker instanceof IntervalMarker) { IntervalMarker im = (IntervalMarker) marker; double start = im.getStartValue(); double end = im.getEndValue(); Range range = domainAxis.getRange(); if (!(range.intersects(start, end))) { return; } double start2d = domainAxis.valueToJava2D(start, dataArea, plot.getDomainAxisEdge()); double end2d = domainAxis.valueToJava2D(end, dataArea, plot.getDomainAxisEdge()); double low = Math.min(start2d, end2d); double high = Math.max(start2d, end2d); PlotOrientation orientation = plot.getOrientation(); Rectangle2D rect = null; if (orientation == PlotOrientation.HORIZONTAL) { // clip top and bottom bounds to data area low = Math.max(low, dataArea.getMinY()); high = Math.min(high, dataArea.getMaxY()); rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); } else if (orientation == PlotOrientation.VERTICAL) { // clip left and right bounds to data area low = Math.max(low, dataArea.getMinX()); high = Math.min(high, dataArea.getMaxX()); rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); } final Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); Paint p = marker.getPaint(); if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) p; GradientPaintTransformer t = im.getGradientPaintTransformer(); if (t != null) { gp = t.transform(gp, rect); } g2.setPaint(gp); } else { g2.setPaint(p); } g2.fill(rect); // now draw the outlines, if visible... if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) { if (orientation == PlotOrientation.VERTICAL) { Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } else { // PlotOrientation.HORIZONTAL Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } } String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateDomainMarkerTextAnchorPoint( g2, orientation, dataArea, rect, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(originalComposite); } } /** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the rectangle surrounding the marker area. * @param markerOffset the marker label offset. * @param labelOffsetType the label offset type. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetType); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetType, LengthAdjustmentType.CONTRACT); } return RectangleAnchor.coordinates(anchorRect, anchor); } /** * Draws a horizontal line across the chart to represent a 'range marker'. * * @param g2 the graphics device. * @param plot the plot. * @param rangeAxis the range axis. * @param marker the marker line. * @param dataArea the axis data area. */ public void drawRangeMarker(Graphics2D g2, XYPlot plot, ValueAxis rangeAxis, Marker marker, Rectangle2D dataArea) { if (marker instanceof ValueMarker) { ValueMarker vm = (ValueMarker) marker; double value = vm.getValue(); Range range = rangeAxis.getRange(); if (!range.contains(value)) { return; } double v = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); PlotOrientation orientation = plot.getOrientation(); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY()); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v); } final Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); g2.setPaint(marker.getPaint()); g2.setStroke(marker.getStroke()); g2.draw(line); String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateRangeMarkerTextAnchorPoint( g2, orientation, dataArea, line.getBounds2D(), marker.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(originalComposite); } else if (marker instanceof IntervalMarker) { IntervalMarker im = (IntervalMarker) marker; double start = im.getStartValue(); double end = im.getEndValue(); Range range = rangeAxis.getRange(); if (!(range.intersects(start, end))) { return; } double start2d = rangeAxis.valueToJava2D(start, dataArea, plot.getRangeAxisEdge()); double end2d = rangeAxis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); double low = Math.min(start2d, end2d); double high = Math.max(start2d, end2d); PlotOrientation orientation = plot.getOrientation(); Rectangle2D rect = null; if (orientation == PlotOrientation.HORIZONTAL) { // clip left and right bounds to data area low = Math.max(low, dataArea.getMinX()); high = Math.min(high, dataArea.getMaxX()); rect = new Rectangle2D.Double(low, dataArea.getMinY(), high - low, dataArea.getHeight()); } else if (orientation == PlotOrientation.VERTICAL) { // clip top and bottom bounds to data area low = Math.max(low, dataArea.getMinY()); high = Math.min(high, dataArea.getMaxY()); rect = new Rectangle2D.Double(dataArea.getMinX(), low, dataArea.getWidth(), high - low); } final Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, marker.getAlpha())); Paint p = marker.getPaint(); if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) p; GradientPaintTransformer t = im.getGradientPaintTransformer(); if (t != null) { gp = t.transform(gp, rect); } g2.setPaint(gp); } else { g2.setPaint(p); } g2.fill(rect); // now draw the outlines, if visible... if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) { if (orientation == PlotOrientation.VERTICAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } else { // PlotOrientation.HORIZONTAL Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } } String label = marker.getLabel(); RectangleAnchor anchor = marker.getLabelAnchor(); if (label != null) { Font labelFont = marker.getLabelFont(); g2.setFont(labelFont); g2.setPaint(marker.getLabelPaint()); Point2D coordinates = calculateRangeMarkerTextAnchorPoint( g2, orientation, dataArea, rect, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor); TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor()); } g2.setComposite(originalComposite); } } /** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the marker area. * @param markerOffset the marker offset. * @param labelOffsetForRange ?? * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ private Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetForRange, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetForRange, LengthAdjustmentType.CONTRACT); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetForRange); } return RectangleAnchor.coordinates(anchorRect, anchor); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer does not support * cloning. */ protected Object clone() throws CloneNotSupportedException { AbstractXYItemRenderer clone = (AbstractXYItemRenderer) super.clone(); // 'plot' : just retain reference, not a deep copy if (this.itemLabelGenerator != null && this.itemLabelGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.itemLabelGenerator; clone.itemLabelGenerator = (XYItemLabelGenerator) pc.clone(); } clone.itemLabelGeneratorList = (ObjectList) this.itemLabelGeneratorList.clone(); if (this.baseItemLabelGenerator != null && this.baseItemLabelGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.baseItemLabelGenerator; clone.baseItemLabelGenerator = (XYItemLabelGenerator) pc.clone(); } if (this.toolTipGenerator != null && this.toolTipGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.toolTipGenerator; clone.toolTipGenerator = (XYToolTipGenerator) pc.clone(); } clone.toolTipGeneratorList = (ObjectList) this.toolTipGeneratorList.clone(); if (this.baseToolTipGenerator != null && this.baseToolTipGenerator instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.baseToolTipGenerator; clone.baseToolTipGenerator = (XYToolTipGenerator) pc.clone(); } if (clone.legendItemLabelGenerator instanceof PublicCloneable) { clone.legendItemLabelGenerator = (XYSeriesLabelGenerator) ObjectUtilities.clone(this.legendItemLabelGenerator); } if (clone.legendItemToolTipGenerator instanceof PublicCloneable) { clone.legendItemToolTipGenerator = (XYSeriesLabelGenerator) ObjectUtilities.clone(this.legendItemToolTipGenerator); } if (clone.legendItemURLGenerator instanceof PublicCloneable) { clone.legendItemURLGenerator = (XYSeriesLabelGenerator) ObjectUtilities.clone(this.legendItemURLGenerator); } clone.foregroundAnnotations = (List) ObjectUtilities.deepClone( this.foregroundAnnotations); clone.backgroundAnnotations = (List) ObjectUtilities.deepClone( this.backgroundAnnotations); if (clone.legendItemLabelGenerator instanceof PublicCloneable) { clone.legendItemLabelGenerator = (XYSeriesLabelGenerator) ObjectUtilities.clone(this.legendItemLabelGenerator); } if (clone.legendItemToolTipGenerator instanceof PublicCloneable) { clone.legendItemToolTipGenerator = (XYSeriesLabelGenerator) ObjectUtilities.clone(this.legendItemToolTipGenerator); } if (clone.legendItemURLGenerator instanceof PublicCloneable) { clone.legendItemURLGenerator = (XYSeriesLabelGenerator) ObjectUtilities.clone(this.legendItemURLGenerator); } return clone; } /** * Tests this renderer for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractXYItemRenderer)) { return false; } AbstractXYItemRenderer that = (AbstractXYItemRenderer) obj; if (!ObjectUtilities.equal(this.itemLabelGenerator, that.itemLabelGenerator)) { return false; } if (!this.itemLabelGeneratorList.equals(that.itemLabelGeneratorList)) { return false; } if (!ObjectUtilities.equal(this.baseItemLabelGenerator, that.baseItemLabelGenerator)) { return false; } if (!ObjectUtilities.equal(this.toolTipGenerator, that.toolTipGenerator)) { return false; } if (!this.toolTipGeneratorList.equals(that.toolTipGeneratorList)) { return false; } if (!ObjectUtilities.equal(this.baseToolTipGenerator, that.baseToolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) { return false; } if (!this.foregroundAnnotations.equals(that.foregroundAnnotations)) { return false; } if (!this.backgroundAnnotations.equals(that.backgroundAnnotations)) { return false; } if (!ObjectUtilities.equal(this.legendItemLabelGenerator, that.legendItemLabelGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendItemToolTipGenerator, that.legendItemToolTipGenerator)) { return false; } if (!ObjectUtilities.equal(this.legendItemURLGenerator, that.legendItemURLGenerator)) { return false; } return super.equals(obj); } /** * Returns the drawing supplier from the plot. * * @return The drawing supplier (possibly null). */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; XYPlot p = getPlot(); if (p != null) { result = p.getDrawingSupplier(); } return result; } /** * Considers the current (x, y) coordinate and updates the crosshair point * if it meets the criteria (usually means the (x, y) coordinate is the * closest to the anchor point so far). * * @param crosshairState the crosshair state (null permitted, * but the method does nothing in that case). * @param x the x-value (in data space). * @param y the y-value (in data space). * @param domainAxisIndex the index of the domain axis for the point. * @param rangeAxisIndex the index of the range axis for the point. * @param transX the x-value translated to Java2D space. * @param transY the y-value translated to Java2D space. * @param orientation the plot orientation (null not * permitted). * * @since 1.0.4 */ protected void updateCrosshairValues(CrosshairState crosshairState, double x, double y, int domainAxisIndex, int rangeAxisIndex, double transX, double transY, PlotOrientation orientation) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } if (crosshairState != null) { // do we need to update the crosshair values? if (this.plot.isDomainCrosshairLockedOnData()) { if (this.plot.isRangeCrosshairLockedOnData()) { // both axes crosshairState.updateCrosshairPoint(x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } else { // just the domain axis... crosshairState.updateCrosshairX(x, domainAxisIndex); } } else { if (this.plot.isRangeCrosshairLockedOnData()) { // just the range axis... crosshairState.updateCrosshairY(y, rangeAxisIndex); } } } } /** * Draws an item label. * * @param g2 the graphics device. * @param orientation the orientation. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param x the x coordinate (in Java2D space). * @param y the y coordinate (in Java2D space). * @param negative indicates a negative value (which affects the item * label position). */ protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, double x, double y, boolean negative) { XYItemLabelGenerator generator = getItemLabelGenerator(series, item); if (generator != null) { Font labelFont = getItemLabelFont(series, item); Paint paint = getItemLabelPaint(series, item); g2.setFont(labelFont); g2.setPaint(paint); String label = generator.generateLabel(dataset, series, item); // get the label position.. ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(series, item); } else { position = getNegativeItemLabelPosition(series, item); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), x, y, orientation); TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } } /** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info) { Iterator iterator = null; if (layer.equals(Layer.FOREGROUND)) { iterator = this.foregroundAnnotations.iterator(); } else if (layer.equals(Layer.BACKGROUND)) { iterator = this.backgroundAnnotations.iterator(); } else { // should not get here throw new RuntimeException("Unknown layer."); } while (iterator.hasNext()) { XYAnnotation annotation = (XYAnnotation) iterator.next(); annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, 0, info); } } /** * Adds an entity to the collection. * * @param entities the entity collection being populated. * @param area the entity area (if null a default will be * used). * @param dataset the dataset. * @param series the series. * @param item the item. * @param entityX the entity's center x-coordinate in user space (only * used if area is null). * @param entityY the entity's center y-coordinate in user space (only * used if area is null). */ protected void addEntity(EntityCollection entities, Shape area, XYDataset dataset, int series, int item, double entityX, double entityY) { if (!getItemCreateEntity(series, item)) { return; } Shape hotspot = area; if (hotspot == null) { double r = getDefaultEntityRadius(); double w = r * 2; if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w); } else { hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w); } } String tip = null; XYToolTipGenerator generator = getToolTipGenerator(series, item); if (generator != null) { tip = generator.generateToolTip(dataset, series, item); } String url = null; if (getURLGenerator() != null) { url = getURLGenerator().generateURL(dataset, series, item); } XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item, tip, url); entities.add(entity); } /** * Returns true if the specified point (x, y) falls within or * on the boundary of the specified rectangle. * * @param rect the rectangle (null not permitted). * @param x the x-coordinate. * @param y the y-coordinate. * * @return A boolean. * * @since 1.0.10 */ public static boolean isPointInRect(Rectangle2D rect, double x, double y) { // TODO: For JFreeChart 1.2.0, this method should go in the // ShapeUtilities class return (x >= rect.getMinX() && x <= rect.getMaxX() && y >= rect.getMinY() && y <= rect.getMaxY()); } // === DEPRECATED CODE === /** * The item label generator for ALL series. * * @deprecated This field is redundant, use itemLabelGeneratorList and * baseItemLabelGenerator instead. Deprecated as of version 1.0.6. */ private XYItemLabelGenerator itemLabelGenerator; /** * The tool tip generator for ALL series. * * @deprecated This field is redundant, use tooltipGeneratorList and * baseToolTipGenerator instead. Deprecated as of version 1.0.6. */ private XYToolTipGenerator toolTipGenerator; /** * Returns the item label generator override. * * @return The generator (possibly null). * * @since 1.0.5 * * @see #setItemLabelGenerator(XYItemLabelGenerator) * * @deprecated As of version 1.0.6, this override setting should not be * used. You can use the base setting instead * ({@link #getBaseItemLabelGenerator()}). */ public XYItemLabelGenerator getItemLabelGenerator() { return this.itemLabelGenerator; } /** * Sets the item label generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getItemLabelGenerator() * * @deprecated As of version 1.0.6, this override setting should not be * used. You can use the base setting instead * ({@link #setBaseItemLabelGenerator(XYItemLabelGenerator)}). */ public void setItemLabelGenerator(XYItemLabelGenerator generator) { this.itemLabelGenerator = generator; fireChangeEvent(); } /** * Returns the override tool tip generator. * * @return The tool tip generator (possible null). * * @since 1.0.5 * * @see #setToolTipGenerator(XYToolTipGenerator) * * @deprecated As of version 1.0.6, this override setting should not be * used. You can use the base setting instead * ({@link #getBaseToolTipGenerator()}). */ public XYToolTipGenerator getToolTipGenerator() { return this.toolTipGenerator; } /** * Sets the tool tip generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getToolTipGenerator() * * @deprecated As of version 1.0.6, this override setting should not be * used. You can use the base setting instead * ({@link #setBaseToolTipGenerator(XYToolTipGenerator)}). */ public void setToolTipGenerator(XYToolTipGenerator generator) { this.toolTipGenerator = generator; fireChangeEvent(); } /** * Considers the current (x, y) coordinate and updates the crosshair point * if it meets the criteria (usually means the (x, y) coordinate is the * closest to the anchor point so far). * * @param crosshairState the crosshair state (null permitted, * but the method does nothing in that case). * @param x the x-value (in data space). * @param y the y-value (in data space). * @param transX the x-value translated to Java2D space. * @param transY the y-value translated to Java2D space. * @param orientation the plot orientation (null not * permitted). * * @deprecated Use {@link #updateCrosshairValues(CrosshairState, double, * double, int, int, double, double, PlotOrientation)} -- see bug * report 1086307. */ protected void updateCrosshairValues(CrosshairState crosshairState, double x, double y, double transX, double transY, PlotOrientation orientation) { updateCrosshairValues(crosshairState, x, y, 0, 0, transX, transY, orientation); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/CandlestickRenderer.java0000644000175000017500000010436311173030414031464 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CandlestickRenderer.java * ------------------------ * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Authors: David Gilbert (for Object Refinery Limited); * Sylvain Vieujot; * Contributor(s): Richard Atkinson; * Christian W. Zuckschwerdt; * Jerome Fisher; * * Changes * ------- * 13-Dec-2001 : Version 1. Based on code in the (now redundant) * CandlestickPlot class, written by Sylvain Vieujot (DG); * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); * 28-Mar-2002 : Added a property change listener mechanism so that renderers * no longer need to be immutable. Added properties for up and * down colors (DG); * 04-Apr-2002 : Updated with new automatic width calculation and optional * volume display, contributed by Sylvain Vieujot (DG); * 09-Apr-2002 : Removed translatedRangeZero from the drawItem() method, and * changed the return type of the drawItem method to void, * reflecting a change in the XYItemRenderer interface. Added * tooltip code to drawItem() method (DG); * 25-Jun-2002 : Removed redundant code (DG); * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML * image maps (RA); * 19-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 30-Jun-2003 : Added support for PlotOrientation (for completeness, this * renderer is unlikely to be used with a HORIZONTAL * orientation) (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 29-Aug-2003 : Moved maxVolume calculation to initialise method (see bug * report 796619) (DG); * 02-Sep-2003 : Added maxCandleWidthInMilliseconds as workaround for bug * 796621 (DG); * 08-Sep-2003 : Changed ValueAxis API (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 13-Oct-2003 : Applied patch from Jerome Fisher to improve auto width * calculations (DG); * 23-Dec-2003 : Fixed bug where up and down paint are used incorrectly (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Jul-2006 : Swapped calls to getX() --> getXValue(), and the same for the * other data values (DG); * 17-Aug-2006 : Corrections to the equals() method (DG); * 05-Mar-2007 : Added flag to allow optional use of outline paint (DG); * 08-Oct-2007 : Added new volumePaint field (DG); * 08-Apr-2008 : Added findRangeBounds() method override (DG); * 13-May-2008 : Fixed chart entity bugs (1962467 and 1962472) (DG); * 27-Mar-2009 : Updated findRangeBounds() to call new method in * superclass (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.HighLowItemLabelGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A renderer that draws candlesticks on an {@link XYPlot} (requires a * {@link OHLCDataset}). The example shown here is generated * by the CandlestickChartDemo1.java program included in the * JFreeChart demo collection: *

* CandlestickRendererSample.png *

* This renderer does not include code to calculate the crosshair point for the * plot. */ public class CandlestickRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 50390395841817121L; /** The average width method. */ public static final int WIDTHMETHOD_AVERAGE = 0; /** The smallest width method. */ public static final int WIDTHMETHOD_SMALLEST = 1; /** The interval data method. */ public static final int WIDTHMETHOD_INTERVALDATA = 2; /** The method of automatically calculating the candle width. */ private int autoWidthMethod = WIDTHMETHOD_AVERAGE; /** * The number (generally between 0.0 and 1.0) by which the available space * automatically calculated for the candles will be multiplied to determine * the actual width to use. */ private double autoWidthFactor = 4.5 / 7; /** The minimum gap between one candle and the next */ private double autoWidthGap = 0.0; /** The candle width. */ private double candleWidth; /** The maximum candlewidth in milliseconds. */ private double maxCandleWidthInMilliseconds = 1000.0 * 60.0 * 60.0 * 20.0; /** Temporary storage for the maximum candle width. */ private double maxCandleWidth; /** * The paint used to fill the candle when the price moved up from open to * close. */ private transient Paint upPaint; /** * The paint used to fill the candle when the price moved down from open * to close. */ private transient Paint downPaint; /** A flag controlling whether or not volume bars are drawn on the chart. */ private boolean drawVolume; /** * The paint used to fill the volume bars (if they are visible). Once * initialised, this field should never be set to null. * * @since 1.0.7 */ private transient Paint volumePaint; /** Temporary storage for the maximum volume. */ private transient double maxVolume; /** * A flag that controls whether or not the renderer's outline paint is * used to draw the outline of the candlestick. The default value is * false to avoid a change of behaviour for existing code. * * @since 1.0.5 */ private boolean useOutlinePaint; /** * Creates a new renderer for candlestick charts. */ public CandlestickRenderer() { this(-1.0); } /** * Creates a new renderer for candlestick charts. *

* Use -1 for the candle width if you prefer the width to be calculated * automatically. * * @param candleWidth The candle width. */ public CandlestickRenderer(double candleWidth) { this(candleWidth, true, new HighLowItemLabelGenerator()); } /** * Creates a new renderer for candlestick charts. *

* Use -1 for the candle width if you prefer the width to be calculated * automatically. * * @param candleWidth the candle width. * @param drawVolume a flag indicating whether or not volume bars should * be drawn. * @param toolTipGenerator the tool tip generator. null is * none. */ public CandlestickRenderer(double candleWidth, boolean drawVolume, XYToolTipGenerator toolTipGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); this.candleWidth = candleWidth; this.drawVolume = drawVolume; this.volumePaint = Color.gray; this.upPaint = Color.green; this.downPaint = Color.red; this.useOutlinePaint = false; // false preserves the old behaviour // prior to introducing this flag } /** * Returns the width of each candle. * * @return The candle width. * * @see #setCandleWidth(double) */ public double getCandleWidth() { return this.candleWidth; } /** * Sets the candle width and sends a {@link RendererChangeEvent} to all * registered listeners. *

* If you set the width to a negative value, the renderer will calculate * the candle width automatically based on the space available on the chart. * * @param width The width. * @see #setAutoWidthMethod(int) * @see #setAutoWidthGap(double) * @see #setAutoWidthFactor(double) * @see #setMaxCandleWidthInMilliseconds(double) */ public void setCandleWidth(double width) { if (width != this.candleWidth) { this.candleWidth = width; fireChangeEvent(); } } /** * Returns the maximum width (in milliseconds) of each candle. * * @return The maximum candle width in milliseconds. * * @see #setMaxCandleWidthInMilliseconds(double) */ public double getMaxCandleWidthInMilliseconds() { return this.maxCandleWidthInMilliseconds; } /** * Sets the maximum candle width (in milliseconds) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param millis The maximum width. * * @see #getMaxCandleWidthInMilliseconds() * @see #setCandleWidth(double) * @see #setAutoWidthMethod(int) * @see #setAutoWidthGap(double) * @see #setAutoWidthFactor(double) */ public void setMaxCandleWidthInMilliseconds(double millis) { this.maxCandleWidthInMilliseconds = millis; fireChangeEvent(); } /** * Returns the method of automatically calculating the candle width. * * @return The method of automatically calculating the candle width. * * @see #setAutoWidthMethod(int) */ public int getAutoWidthMethod() { return this.autoWidthMethod; } /** * Sets the method of automatically calculating the candle width and * sends a {@link RendererChangeEvent} to all registered listeners. *

* WIDTHMETHOD_AVERAGE: Divides the entire display (ignoring * scale factor) by the number of items, and uses this as the available * width.
* WIDTHMETHOD_SMALLEST: Checks the interval between each * item, and uses the smallest as the available width.
* WIDTHMETHOD_INTERVALDATA: Assumes that the dataset supports * the IntervalXYDataset interface, and uses the startXValue - endXValue as * the available width. *
* * @param autoWidthMethod The method of automatically calculating the * candle width. * * @see #WIDTHMETHOD_AVERAGE * @see #WIDTHMETHOD_SMALLEST * @see #WIDTHMETHOD_INTERVALDATA * @see #getAutoWidthMethod() * @see #setCandleWidth(double) * @see #setAutoWidthGap(double) * @see #setAutoWidthFactor(double) * @see #setMaxCandleWidthInMilliseconds(double) */ public void setAutoWidthMethod(int autoWidthMethod) { if (this.autoWidthMethod != autoWidthMethod) { this.autoWidthMethod = autoWidthMethod; fireChangeEvent(); } } /** * Returns the factor by which the available space automatically * calculated for the candles will be multiplied to determine the actual * width to use. * * @return The width factor (generally between 0.0 and 1.0). * * @see #setAutoWidthFactor(double) */ public double getAutoWidthFactor() { return this.autoWidthFactor; } /** * Sets the factor by which the available space automatically calculated * for the candles will be multiplied to determine the actual width to use. * * @param autoWidthFactor The width factor (generally between 0.0 and 1.0). * * @see #getAutoWidthFactor() * @see #setCandleWidth(double) * @see #setAutoWidthMethod(int) * @see #setAutoWidthGap(double) * @see #setMaxCandleWidthInMilliseconds(double) */ public void setAutoWidthFactor(double autoWidthFactor) { if (this.autoWidthFactor != autoWidthFactor) { this.autoWidthFactor = autoWidthFactor; fireChangeEvent(); } } /** * Returns the amount of space to leave on the left and right of each * candle when automatically calculating widths. * * @return The gap. * * @see #setAutoWidthGap(double) */ public double getAutoWidthGap() { return this.autoWidthGap; } /** * Sets the amount of space to leave on the left and right of each candle * when automatically calculating widths and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param autoWidthGap The gap. * * @see #getAutoWidthGap() * @see #setCandleWidth(double) * @see #setAutoWidthMethod(int) * @see #setAutoWidthFactor(double) * @see #setMaxCandleWidthInMilliseconds(double) */ public void setAutoWidthGap(double autoWidthGap) { if (this.autoWidthGap != autoWidthGap) { this.autoWidthGap = autoWidthGap; fireChangeEvent(); } } /** * Returns the paint used to fill candles when the price moves up from open * to close. * * @return The paint (possibly null). * * @see #setUpPaint(Paint) */ public Paint getUpPaint() { return this.upPaint; } /** * Sets the paint used to fill candles when the price moves up from open * to close and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param paint the paint (null permitted). * * @see #getUpPaint() */ public void setUpPaint(Paint paint) { this.upPaint = paint; fireChangeEvent(); } /** * Returns the paint used to fill candles when the price moves down from * open to close. * * @return The paint (possibly null). * * @see #setDownPaint(Paint) */ public Paint getDownPaint() { return this.downPaint; } /** * Sets the paint used to fill candles when the price moves down from open * to close and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param paint The paint (null permitted). */ public void setDownPaint(Paint paint) { this.downPaint = paint; fireChangeEvent(); } /** * Returns a flag indicating whether or not volume bars are drawn on the * chart. * * @return A boolean. * * @since 1.0.5 * * @see #setDrawVolume(boolean) */ public boolean getDrawVolume() { return this.drawVolume; } /** * Sets a flag that controls whether or not volume bars are drawn in the * background and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #getDrawVolume() */ public void setDrawVolume(boolean flag) { if (this.drawVolume != flag) { this.drawVolume = flag; fireChangeEvent(); } } /** * Returns the paint that is used to fill the volume bars if they are * visible. * * @return The paint (never null). * * @see #setVolumePaint(Paint) * * @since 1.0.7 */ public Paint getVolumePaint() { return this.volumePaint; } /** * Sets the paint used to fill the volume bars, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getVolumePaint() * @see #getDrawVolume() * * @since 1.0.7 */ public void setVolumePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.volumePaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether or not the renderer's outline * paint is used to draw the candlestick outline. The default value is * false. * * @return A boolean. * * @since 1.0.5 * * @see #setUseOutlinePaint(boolean) */ public boolean getUseOutlinePaint() { return this.useOutlinePaint; } /** * Sets the flag that controls whether or not the renderer's outline * paint is used to draw the candlestick outline, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param use the new flag value. * * @since 1.0.5 * * @see #getUseOutlinePaint() */ public void setUseOutlinePaint(boolean use) { if (this.useOutlinePaint != use) { this.useOutlinePaint = use; fireChangeEvent(); } } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { return findRangeBounds(dataset, true); } /** * Initialises the renderer then returns the number of 'passes' through the * data that the renderer will require (usually just one). This method * will be called before the first item is rendered, giving the renderer * an opportunity to initialise any state information it wants to maintain. * The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param dataset the data. * @param info an optional info collection object to return data back to * the caller. * * @return The number of passes the renderer requires. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { // calculate the maximum allowed candle width from the axis... ValueAxis axis = plot.getDomainAxis(); double x1 = axis.getLowerBound(); double x2 = x1 + this.maxCandleWidthInMilliseconds; RectangleEdge edge = plot.getDomainAxisEdge(); double xx1 = axis.valueToJava2D(x1, dataArea, edge); double xx2 = axis.valueToJava2D(x2, dataArea, edge); this.maxCandleWidth = Math.abs(xx2 - xx1); // Absolute value, since the relative x // positions are reversed for horizontal orientation // calculate the highest volume in the dataset... if (this.drawVolume) { OHLCDataset highLowDataset = (OHLCDataset) dataset; this.maxVolume = 0.0; for (int series = 0; series < highLowDataset.getSeriesCount(); series++) { for (int item = 0; item < highLowDataset.getItemCount(series); item++) { double volume = highLowDataset.getVolumeValue(series, item); if (volume > this.maxVolume) { this.maxVolume = volume; } } } } return new XYItemRendererState(info); } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects info about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { boolean horiz; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { horiz = true; } else if (orientation == PlotOrientation.VERTICAL) { horiz = false; } else { return; } // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } OHLCDataset highLowData = (OHLCDataset) dataset; double x = highLowData.getXValue(series, item); double yHigh = highLowData.getHighValue(series, item); double yLow = highLowData.getLowValue(series, item); double yOpen = highLowData.getOpenValue(series, item); double yClose = highLowData.getCloseValue(series, item); RectangleEdge domainEdge = plot.getDomainAxisEdge(); double xx = domainAxis.valueToJava2D(x, dataArea, domainEdge); RectangleEdge edge = plot.getRangeAxisEdge(); double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, edge); double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, edge); double yyOpen = rangeAxis.valueToJava2D(yOpen, dataArea, edge); double yyClose = rangeAxis.valueToJava2D(yClose, dataArea, edge); double volumeWidth; double stickWidth; if (this.candleWidth > 0) { // These are deliberately not bounded to minimums/maxCandleWidth to // retain old behaviour. volumeWidth = this.candleWidth; stickWidth = this.candleWidth; } else { double xxWidth = 0; int itemCount; switch (this.autoWidthMethod) { case WIDTHMETHOD_AVERAGE: itemCount = highLowData.getItemCount(series); if (horiz) { xxWidth = dataArea.getHeight() / itemCount; } else { xxWidth = dataArea.getWidth() / itemCount; } break; case WIDTHMETHOD_SMALLEST: // Note: It would be nice to pre-calculate this per series itemCount = highLowData.getItemCount(series); double lastPos = -1; xxWidth = dataArea.getWidth(); for (int i = 0; i < itemCount; i++) { double pos = domainAxis.valueToJava2D( highLowData.getXValue(series, i), dataArea, domainEdge); if (lastPos != -1) { xxWidth = Math.min(xxWidth, Math.abs(pos - lastPos)); } lastPos = pos; } break; case WIDTHMETHOD_INTERVALDATA: IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; double startPos = domainAxis.valueToJava2D( intervalXYData.getStartXValue(series, item), dataArea, plot.getDomainAxisEdge()); double endPos = domainAxis.valueToJava2D( intervalXYData.getEndXValue(series, item), dataArea, plot.getDomainAxisEdge()); xxWidth = Math.abs(endPos - startPos); break; } xxWidth -= 2 * this.autoWidthGap; xxWidth *= this.autoWidthFactor; xxWidth = Math.min(xxWidth, this.maxCandleWidth); volumeWidth = Math.max(Math.min(1, this.maxCandleWidth), xxWidth); stickWidth = Math.max(Math.min(3, this.maxCandleWidth), xxWidth); } Paint p = getItemPaint(series, item); Paint outlinePaint = null; if (this.useOutlinePaint) { outlinePaint = getItemOutlinePaint(series, item); } Stroke s = getItemStroke(series, item); g2.setStroke(s); if (this.drawVolume) { int volume = (int) highLowData.getVolumeValue(series, item); double volumeHeight = volume / this.maxVolume; double min, max; if (horiz) { min = dataArea.getMinX(); max = dataArea.getMaxX(); } else { min = dataArea.getMinY(); max = dataArea.getMaxY(); } double zzVolume = volumeHeight * (max - min); g2.setPaint(getVolumePaint()); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.3f)); if (horiz) { g2.fill(new Rectangle2D.Double(min, xx - volumeWidth / 2, zzVolume, volumeWidth)); } else { g2.fill(new Rectangle2D.Double(xx - volumeWidth / 2, max - zzVolume, volumeWidth, zzVolume)); } g2.setComposite(originalComposite); } if (this.useOutlinePaint) { g2.setPaint(outlinePaint); } else { g2.setPaint(p); } double yyMaxOpenClose = Math.max(yyOpen, yyClose); double yyMinOpenClose = Math.min(yyOpen, yyClose); double maxOpenClose = Math.max(yOpen, yClose); double minOpenClose = Math.min(yOpen, yClose); // draw the upper shadow if (yHigh > maxOpenClose) { if (horiz) { g2.draw(new Line2D.Double(yyHigh, xx, yyMaxOpenClose, xx)); } else { g2.draw(new Line2D.Double(xx, yyHigh, xx, yyMaxOpenClose)); } } // draw the lower shadow if (yLow < minOpenClose) { if (horiz) { g2.draw(new Line2D.Double(yyLow, xx, yyMinOpenClose, xx)); } else { g2.draw(new Line2D.Double(xx, yyLow, xx, yyMinOpenClose)); } } // draw the body Rectangle2D body = null; Rectangle2D hotspot = null; double length = Math.abs(yyHigh - yyLow); double base = Math.min(yyHigh, yyLow); if (horiz) { body = new Rectangle2D.Double(yyMinOpenClose, xx - stickWidth / 2, yyMaxOpenClose - yyMinOpenClose, stickWidth); hotspot = new Rectangle2D.Double(base, xx - stickWidth / 2, length, stickWidth); } else { body = new Rectangle2D.Double(xx - stickWidth / 2, yyMinOpenClose, stickWidth, yyMaxOpenClose - yyMinOpenClose); hotspot = new Rectangle2D.Double(xx - stickWidth / 2, base, stickWidth, length); } if (yClose > yOpen) { if (this.upPaint != null) { g2.setPaint(this.upPaint); } else { g2.setPaint(p); } g2.fill(body); } else { if (this.downPaint != null) { g2.setPaint(this.downPaint); } else { g2.setPaint(p); } g2.fill(body); } if (this.useOutlinePaint) { g2.setPaint(outlinePaint); } else { g2.setPaint(p); } g2.draw(body); // add an entity for the item... if (entities != null) { addEntity(entities, hotspot, dataset, series, item, 0.0, 0.0); } } /** * Tests this renderer for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CandlestickRenderer)) { return false; } CandlestickRenderer that = (CandlestickRenderer) obj; if (this.candleWidth != that.candleWidth) { return false; } if (!PaintUtilities.equal(this.upPaint, that.upPaint)) { return false; } if (!PaintUtilities.equal(this.downPaint, that.downPaint)) { return false; } if (this.drawVolume != that.drawVolume) { return false; } if (this.maxCandleWidthInMilliseconds != that.maxCandleWidthInMilliseconds) { return false; } if (this.autoWidthMethod != that.autoWidthMethod) { return false; } if (this.autoWidthFactor != that.autoWidthFactor) { return false; } if (this.autoWidthGap != that.autoWidthGap) { return false; } if (this.useOutlinePaint != that.useOutlinePaint) { return false; } if (!PaintUtilities.equal(this.volumePaint, that.volumePaint)) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.upPaint, stream); SerialUtilities.writePaint(this.downPaint, stream); SerialUtilities.writePaint(this.volumePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.upPaint = SerialUtilities.readPaint(stream); this.downPaint = SerialUtilities.readPaint(stream); this.volumePaint = SerialUtilities.readPaint(stream); } // --- DEPRECATED CODE ---------------------------------------------------- /** * Returns a flag indicating whether or not volume bars are drawn on the * chart. * * @return true if volume bars are drawn on the chart. * * @deprecated As of 1.0.5, you should use the {@link #getDrawVolume()} * method. */ public boolean drawVolume() { return this.drawVolume; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java0000644000175000017500000003476711173030414032112 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * ClusteredXYBarRenderer.java * --------------------------- * (C) Copyright 2003-2008, by Paolo Cova and Contributors. * * Original Author: Paolo Cova; * Contributor(s): David Gilbert (for Object Refinery Limited); * Christian W. Zuckschwerdt; * Matthias Rose; * * Changes * ------- * 24-Jan-2003 : Version 1, contributed by Paolo Cova (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 03-Nov-2003 : In draw method added state parameter and y==null value * handling (MR); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 01-Oct-2004 : Fixed bug where 'drawBarOutline' flag is ignored (DG); * 16-May-2005 : Fixed to used outline stroke for bar outlines. Removed some * redundant code with the result that the renderer now respects * the 'base' setting from the super-class. Added an equals() * method (DG); * 19-May-2005 : Added minimal item label implementation - needs improving (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Dec-2006 : Added support for GradientPaint (DG); * 12-Jun-2007 : Added override to findDomainBounds() to handle cluster offset, * fixed rendering to handle inverted axes, and simplified * entity generation code (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * An extension of {@link XYBarRenderer} that displays bars for different * series values at the same x next to each other. The assumption here is * that for each x (time or else) there is a y value for each series. If * this is not the case, there will be spaces between bars for a given x. * The example shown here is generated by the * ClusteredXYBarRendererDemo1.java program included in the * JFreeChart demo collection: *

* ClusteredXYBarRendererSample.png *

* This renderer does not include code to calculate the crosshair point for the * plot. */ public class ClusteredXYBarRenderer extends XYBarRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5864462149177133147L; /** Determines whether bar center should be interval start. */ private boolean centerBarAtStartValue; /** * Default constructor. Bar margin is set to 0.0. */ public ClusteredXYBarRenderer() { this(0.0, false); } /** * Constructs a new XY clustered bar renderer. * * @param margin the percentage amount to trim from the width of each bar. * @param centerBarAtStartValue if true, bars will be centered on the * start of the time period. */ public ClusteredXYBarRenderer(double margin, boolean centerBarAtStartValue) { super(margin); this.centerBarAtStartValue = centerBarAtStartValue; } /** * Returns the number of passes through the dataset that this renderer * requires. In this case, two passes are required, the first for drawing * the shadows (if visible), and the second for drawing the bars. * * @return 2. */ public int getPassCount() { return 2; } /** * Returns the x-value bounds for the specified dataset. * * @param dataset the dataset (null permitted). * * @return The bounds (possibly null). */ public Range findDomainBounds(XYDataset dataset) { if (dataset == null) { return null; } // need to handle cluster centering as a special case if (this.centerBarAtStartValue) { return findDomainBoundsWithOffset((IntervalXYDataset) dataset); } else { return super.findDomainBounds(dataset); } } /** * Iterates over the items in an {@link IntervalXYDataset} to find * the range of x-values including the interval OFFSET so that it centers * the interval around the start value. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). */ protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue; double uvalue; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getStartXValue(series, item); uvalue = dataset.getEndXValue(series, item); double offset = (uvalue - lvalue) / 2.0; lvalue = lvalue - offset; uvalue = uvalue - offset; minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } } /** * Draws the visual representation of a single data item. This method * is mostly copied from the superclass, the change is that in the * calculated space for a singe bar we draw bars for each series next to * each other. The width of each bar is the available width divided by * the number of series. Bars for each series are drawn in order left to * right. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; double y0; double y1; if (getUseYInterval()) { y0 = intervalDataset.getStartYValue(series, item); y1 = intervalDataset.getEndYValue(series, item); } else { y0 = getBase(); y1 = intervalDataset.getYValue(series, item); } if (Double.isNaN(y0) || Double.isNaN(y1)) { return; } double yy0 = rangeAxis.valueToJava2D(y0, dataArea, plot.getRangeAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge()); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); double x0 = intervalDataset.getStartXValue(series, item); double xx0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double x1 = intervalDataset.getEndXValue(series, item); double xx1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double intervalW = xx1 - xx0; // this may be negative double baseX = xx0; if (this.centerBarAtStartValue) { baseX = baseX - intervalW / 2.0; } double m = getMargin(); if (m > 0.0) { double cut = intervalW * getMargin(); intervalW = intervalW - cut; baseX = baseX + (cut / 2); } double intervalH = Math.abs(yy0 - yy1); // we don't need the sign PlotOrientation orientation = plot.getOrientation(); int numSeries = dataset.getSeriesCount(); double seriesBarWidth = intervalW / numSeries; // may be negative Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { double barY0 = baseX + (seriesBarWidth * series); double barY1 = barY0 + seriesBarWidth; double rx = Math.min(yy0, yy1); double rw = intervalH; double ry = Math.min(barY0, barY1); double rh = Math.abs(barY1 - barY0); bar = new Rectangle2D.Double(rx, ry, rw, rh); } else if (orientation == PlotOrientation.VERTICAL) { double barX0 = baseX + (seriesBarWidth * series); double barX1 = barX0 + seriesBarWidth; double rx = Math.min(barX0, barX1); double rw = Math.abs(barX1 - barX0); double ry = Math.min(yy0, yy1); double rh = intervalH; bar = new Rectangle2D.Double(rx, ry, rw, rh); } boolean positive = (y1 > 0.0); boolean inverted = rangeAxis.isInverted(); RectangleEdge barBase; if (orientation == PlotOrientation.HORIZONTAL) { if (positive && inverted || !positive && !inverted) { barBase = RectangleEdge.RIGHT; } else { barBase = RectangleEdge.LEFT; } } else { if (positive && !inverted || !positive && inverted) { barBase = RectangleEdge.BOTTOM; } else { barBase = RectangleEdge.TOP; } } if (pass == 0 && getShadowsVisible()) { getBarPainter().paintBarShadow(g2, this, series, item, bar, barBase, !getUseYInterval()); } if (pass == 1) { getBarPainter().paintBar(g2, this, series, item, bar, barBase); if (isItemLabelVisible(series, item)) { XYItemLabelGenerator generator = getItemLabelGenerator(series, item); drawItemLabel(g2, dataset, series, item, plot, generator, bar, y1 < 0.0); } // add an entity for the item... if (info != null) { EntityCollection entities = info.getOwner().getEntityCollection(); if (entities != null) { addEntity(entities, bar, dataset, series, item, bar.getCenterX(), bar.getCenterY()); } } } } /** * Tests this renderer for equality with an arbitrary object, returning * true if obj is a * ClusteredXYBarRenderer with the same settings as this * renderer, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ClusteredXYBarRenderer)) { return false; } ClusteredXYBarRenderer that = (ClusteredXYBarRenderer) obj; if (this.centerBarAtStartValue != that.centerBarAtStartValue) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/CyclicXYItemRenderer.java0000644000175000017500000004257411173030414031553 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CyclicXYItemRenderer.java * --------------------------- * (C) Copyright 2003-2008, by Nicolas Brodu and Contributors. * * Original Author: Nicolas Brodu; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Nov-2003 : Initial import to JFreeChart from the JSynoptic project (NB); * 23-Dec-2003 : Added missing Javadocs (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * ------------- JFREECHART 1.0.0 --------------------------------------------- * 06-Jul-2006 : Modified to call only dataset methods that return double * primitives (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.CyclicNumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.DomainOrder; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.general.DatasetGroup; import org.jfree.data.xy.XYDataset; /** * The Cyclic XY item renderer is specially designed to handle cyclic axis. * While the standard renderer would draw a line across the plot when a cycling * occurs, the cyclic renderer splits the line at each cycle end instead. This * is done by interpolating new points at cycle boundary. Thus, correct * appearance is restored. * * The Cyclic XY item renderer works exactly like a standard XY item renderer * with non-cyclic axis. */ public class CyclicXYItemRenderer extends StandardXYItemRenderer implements Serializable { /** For serialization. */ private static final long serialVersionUID = 4035912243303764892L; /** * Default constructor. */ public CyclicXYItemRenderer() { super(); } /** * Creates a new renderer. * * @param type the renderer type. */ public CyclicXYItemRenderer(int type) { super(type); } /** * Creates a new renderer. * * @param type the renderer type. * @param labelGenerator the tooltip generator. */ public CyclicXYItemRenderer(int type, XYToolTipGenerator labelGenerator) { super(type, labelGenerator); } /** * Creates a new renderer. * * @param type the renderer type. * @param labelGenerator the tooltip generator. * @param urlGenerator the url generator. */ public CyclicXYItemRenderer(int type, XYToolTipGenerator labelGenerator, XYURLGenerator urlGenerator) { super(type, labelGenerator, urlGenerator); } /** * Draws the visual representation of a single data item. * When using cyclic axis, do not draw a line from right to left when * cycling as would a standard XY item renderer, but instead draw a line * from the previous point to the cycle bound in the last cycle, and a line * from the cycle bound to current point in the current cycle. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the current pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if ((!getPlotLines()) || ((!(domainAxis instanceof CyclicNumberAxis)) && (!(rangeAxis instanceof CyclicNumberAxis))) || (item <= 0)) { super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); return; } // get the previous data point... double xn = dataset.getXValue(series, item - 1); double yn = dataset.getYValue(series, item - 1); // If null, don't draw line => then delegate to parent if (Double.isNaN(yn)) { super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); return; } double[] x = new double[2]; double[] y = new double[2]; x[0] = xn; y[0] = yn; // get the data point... xn = dataset.getXValue(series, item); yn = dataset.getYValue(series, item); // If null, don't draw line at all if (Double.isNaN(yn)) { return; } x[1] = xn; y[1] = yn; // Now split the segment as needed double xcycleBound = Double.NaN; double ycycleBound = Double.NaN; boolean xBoundMapping = false, yBoundMapping = false; CyclicNumberAxis cnax = null, cnay = null; if (domainAxis instanceof CyclicNumberAxis) { cnax = (CyclicNumberAxis) domainAxis; xcycleBound = cnax.getCycleBound(); xBoundMapping = cnax.isBoundMappedToLastCycle(); // If the segment must be splitted, insert a new point // Strict test forces to have real segments (not 2 equal points) // and avoids division by 0 if ((x[0] != x[1]) && ((xcycleBound >= x[0]) && (xcycleBound <= x[1]) || (xcycleBound >= x[1]) && (xcycleBound <= x[0]))) { double[] nx = new double[3]; double[] ny = new double[3]; nx[0] = x[0]; nx[2] = x[1]; ny[0] = y[0]; ny[2] = y[1]; nx[1] = xcycleBound; ny[1] = (y[1] - y[0]) * (xcycleBound - x[0]) / (x[1] - x[0]) + y[0]; x = nx; y = ny; } } if (rangeAxis instanceof CyclicNumberAxis) { cnay = (CyclicNumberAxis) rangeAxis; ycycleBound = cnay.getCycleBound(); yBoundMapping = cnay.isBoundMappedToLastCycle(); // The split may occur in either x splitted segments, if any, but // not in both if ((y[0] != y[1]) && ((ycycleBound >= y[0]) && (ycycleBound <= y[1]) || (ycycleBound >= y[1]) && (ycycleBound <= y[0]))) { double[] nx = new double[x.length + 1]; double[] ny = new double[y.length + 1]; nx[0] = x[0]; nx[2] = x[1]; ny[0] = y[0]; ny[2] = y[1]; ny[1] = ycycleBound; nx[1] = (x[1] - x[0]) * (ycycleBound - y[0]) / (y[1] - y[0]) + x[0]; if (x.length == 3) { nx[3] = x[2]; ny[3] = y[2]; } x = nx; y = ny; } else if ((x.length == 3) && (y[1] != y[2]) && ((ycycleBound >= y[1]) && (ycycleBound <= y[2]) || (ycycleBound >= y[2]) && (ycycleBound <= y[1]))) { double[] nx = new double[4]; double[] ny = new double[4]; nx[0] = x[0]; nx[1] = x[1]; nx[3] = x[2]; ny[0] = y[0]; ny[1] = y[1]; ny[3] = y[2]; ny[2] = ycycleBound; nx[2] = (x[2] - x[1]) * (ycycleBound - y[1]) / (y[2] - y[1]) + x[1]; x = nx; y = ny; } } // If the line is not wrapping, then parent is OK if (x.length == 2) { super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); return; } OverwriteDataSet newset = new OverwriteDataSet(x, y, dataset); if (cnax != null) { if (xcycleBound == x[0]) { cnax.setBoundMappedToLastCycle(x[1] <= xcycleBound); } if (xcycleBound == x[1]) { cnax.setBoundMappedToLastCycle(x[0] <= xcycleBound); } } if (cnay != null) { if (ycycleBound == y[0]) { cnay.setBoundMappedToLastCycle(y[1] <= ycycleBound); } if (ycycleBound == y[1]) { cnay.setBoundMappedToLastCycle(y[0] <= ycycleBound); } } super.drawItem( g2, state, dataArea, info, plot, domainAxis, rangeAxis, newset, series, 1, crosshairState, pass ); if (cnax != null) { if (xcycleBound == x[1]) { cnax.setBoundMappedToLastCycle(x[2] <= xcycleBound); } if (xcycleBound == x[2]) { cnax.setBoundMappedToLastCycle(x[1] <= xcycleBound); } } if (cnay != null) { if (ycycleBound == y[1]) { cnay.setBoundMappedToLastCycle(y[2] <= ycycleBound); } if (ycycleBound == y[2]) { cnay.setBoundMappedToLastCycle(y[1] <= ycycleBound); } } super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, newset, series, 2, crosshairState, pass); if (x.length == 4) { if (cnax != null) { if (xcycleBound == x[2]) { cnax.setBoundMappedToLastCycle(x[3] <= xcycleBound); } if (xcycleBound == x[3]) { cnax.setBoundMappedToLastCycle(x[2] <= xcycleBound); } } if (cnay != null) { if (ycycleBound == y[2]) { cnay.setBoundMappedToLastCycle(y[3] <= ycycleBound); } if (ycycleBound == y[3]) { cnay.setBoundMappedToLastCycle(y[2] <= ycycleBound); } } super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, newset, series, 3, crosshairState, pass); } if (cnax != null) { cnax.setBoundMappedToLastCycle(xBoundMapping); } if (cnay != null) { cnay.setBoundMappedToLastCycle(yBoundMapping); } } /** * A dataset to hold the interpolated points when drawing new lines. */ protected static class OverwriteDataSet implements XYDataset { /** The delegate dataset. */ protected XYDataset delegateSet; /** Storage for the x and y values. */ Double[] x, y; /** * Creates a new dataset. * * @param x the x values. * @param y the y values. * @param delegateSet the dataset. */ public OverwriteDataSet(double [] x, double[] y, XYDataset delegateSet) { this.delegateSet = delegateSet; this.x = new Double[x.length]; this.y = new Double[y.length]; for (int i = 0; i < x.length; ++i) { this.x[i] = new Double(x[i]); this.y[i] = new Double(y[i]); } } /** * Returns the order of the domain (X) values. * * @return The domain order. */ public DomainOrder getDomainOrder() { return DomainOrder.NONE; } /** * Returns the number of items for the given series. * * @param series the series index (zero-based). * * @return The item count. */ public int getItemCount(int series) { return this.x.length; } /** * Returns the x-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value. */ public Number getX(int series, int item) { return this.x[item]; } /** * Returns the x-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ public double getXValue(int series, int item) { double result = Double.NaN; Number x = getX(series, item); if (x != null) { result = x.doubleValue(); } return result; } /** * Returns the y-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value. */ public Number getY(int series, int item) { return this.y[item]; } /** * Returns the y-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value. */ public double getYValue(int series, int item) { double result = Double.NaN; Number y = getY(series, item); if (y != null) { result = y.doubleValue(); } return result; } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.delegateSet.getSeriesCount(); } /** * Returns the name of the given series. * * @param series the series index (zero-based). * * @return The series name. */ public Comparable getSeriesKey(int series) { return this.delegateSet.getSeriesKey(series); } /** * Returns the index of the named series, or -1. * * @param seriesName the series name. * * @return The index. */ public int indexOf(Comparable seriesName) { return this.delegateSet.indexOf(seriesName); } /** * Does nothing. * * @param listener ignored. */ public void addChangeListener(DatasetChangeListener listener) { // unused in parent } /** * Does nothing. * * @param listener ignored. */ public void removeChangeListener(DatasetChangeListener listener) { // unused in parent } /** * Returns the dataset group. * * @return The dataset group. */ public DatasetGroup getGroup() { // unused but must return something, so while we are at it... return this.delegateSet.getGroup(); } /** * Does nothing. * * @param group ignored. */ public void setGroup(DatasetGroup group) { // unused in parent } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/DefaultXYItemRenderer.java0000644000175000017500000000406711173030414031724 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultXYItemRenderer.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jul-2003 : Version 1 (DG); * 22-Feb-2005 : Now extends XYLineAndShapeRenderer (DG); * */ package org.jfree.chart.renderer.xy; import java.io.Serializable; /** * A default renderer for the {@link org.jfree.chart.plot.XYPlot} class. This * is an alias for the {@link XYLineAndShapeRenderer} class. */ public class DefaultXYItemRenderer extends XYLineAndShapeRenderer implements Serializable { /** For serialization. */ static final long serialVersionUID = 3450423530996888074L; // no new methods } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/DeviationRenderer.java0000644000175000017500000003255711173030414031167 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DeviationRenderer.java * ---------------------- * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Feb-2007 : Version 1 (DG); * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); * 11-Apr-2008 : New override for findRangeBounds() (DG); * 27-Mar-2009 : Updated findRangeBounds() to call new inherited method (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.util.List; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; /** * A specialised subclass of the {@link XYLineAndShapeRenderer} that requires * an {@link IntervalXYDataset} and represents the y-interval by shading an * area behind the y-values on the chart. * The example shown here is generated by the * DeviationRendererDemo1.java program included in the * JFreeChart demo collection: *

* DeviationRendererSample.png * * @since 1.0.5 */ public class DeviationRenderer extends XYLineAndShapeRenderer { /** * A state object that is passed to each call to drawItem. */ public static class State extends XYLineAndShapeRenderer.State { /** * A list of coordinates for the upper y-values in the current series * (after translation into Java2D space). */ public List upperCoordinates; /** * A list of coordinates for the lower y-values in the current series * (after translation into Java2D space). */ public List lowerCoordinates; /** * Creates a new state instance. * * @param info the plot rendering info. */ public State(PlotRenderingInfo info) { super(info); this.lowerCoordinates = new java.util.ArrayList(); this.upperCoordinates = new java.util.ArrayList(); } } /** The alpha transparency for the interval shading. */ private float alpha; /** * Creates a new renderer that displays lines and shapes for the data * items, as well as the shaded area for the y-interval. */ public DeviationRenderer() { this(true, true); } /** * Creates a new renderer. * * @param lines show lines between data items? * @param shapes show a shape for each data item? */ public DeviationRenderer(boolean lines, boolean shapes) { super(lines, shapes); super.setDrawSeriesLineAsPath(true); this.alpha = 0.5f; } /** * Returns the alpha transparency for the background shading. * * @return The alpha transparency. * * @see #setAlpha(float) */ public float getAlpha() { return this.alpha; } /** * Sets the alpha transparency for the background shading, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param alpha the alpha (in the range 0.0f to 1.0f). * * @see #getAlpha() */ public void setAlpha(float alpha) { if (alpha < 0.0f || alpha > 1.0f) { throw new IllegalArgumentException( "Requires 'alpha' in the range 0.0 to 1.0."); } this.alpha = alpha; fireChangeEvent(); } /** * This method is overridden so that this flag cannot be changed---it is * set to true for this renderer. * * @param flag ignored. */ public void setDrawSeriesLineAsPath(boolean flag) { // ignore } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { return findRangeBounds(dataset, true); } /** * Initialises and returns a state object that can be passed to each * invocation of the {@link #drawItem} method. * * @param g2 the graphics target. * @param dataArea the data area. * @param plot the plot. * @param dataset the dataset. * @param info the plot rendering info. * * @return A newly initialised state object. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { State state = new State(info); state.seriesPath = new GeneralPath(); state.setProcessVisibleItemsOnly(false); return state; } /** * Returns the number of passes (through the dataset) used by this * renderer. * * @return 3. */ public int getPassCount() { return 3; } /** * Returns true if this is the pass where the shapes are * drawn. * * @param pass the pass index. * * @return A boolean. * * @see #isLinePass(int) */ protected boolean isItemPass(int pass) { return (pass == 2); } /** * Returns true if this is the pass where the lines are * drawn. * * @param pass the pass index. * * @return A boolean. * * @see #isItemPass(int) */ protected boolean isLinePass(int pass) { return (pass == 1); } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // do nothing if item is not visible if (!getItemVisible(series, item)) { return; } // first pass draws the shading if (pass == 0) { IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; State drState = (State) state; double x = intervalDataset.getXValue(series, item); double yLow = intervalDataset.getStartYValue(series, item); double yHigh = intervalDataset.getEndYValue(series, item); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation); double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { drState.lowerCoordinates.add(new double[] {yyLow, xx}); drState.upperCoordinates.add(new double[] {yyHigh, xx}); } else if (orientation == PlotOrientation.VERTICAL) { drState.lowerCoordinates.add(new double[] {xx, yyLow}); drState.upperCoordinates.add(new double[] {xx, yyHigh}); } if (item == (dataset.getItemCount(series) - 1)) { // last item in series, draw the lot... // set up the alpha-transparency... Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, this.alpha)); g2.setPaint(getItemFillPaint(series, item)); GeneralPath area = new GeneralPath(); double[] coords = (double[]) drState.lowerCoordinates.get(0); area.moveTo((float) coords[0], (float) coords[1]); for (int i = 1; i < drState.lowerCoordinates.size(); i++) { coords = (double[]) drState.lowerCoordinates.get(i); area.lineTo((float) coords[0], (float) coords[1]); } int count = drState.upperCoordinates.size(); coords = (double[]) drState.upperCoordinates.get(count - 1); area.lineTo((float) coords[0], (float) coords[1]); for (int i = count - 2; i >= 0; i--) { coords = (double[]) drState.upperCoordinates.get(i); area.lineTo((float) coords[0], (float) coords[1]); } area.closePath(); g2.fill(area); g2.setComposite(originalComposite); drState.lowerCoordinates.clear(); drState.upperCoordinates.clear(); } } if (isLinePass(pass)) { // the following code handles the line for the y-values...it's // all done by code in the super class if (item == 0) { State s = (State) state; s.seriesPath.reset(); s.setLastPointGood(false); } if (getItemLineVisible(series, item)) { drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); } } // second pass adds shapes where the items are .. else if (isItemPass(pass)) { // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DeviationRenderer)) { return false; } DeviationRenderer that = (DeviationRenderer) obj; if (this.alpha != that.alpha) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java0000644000175000017500000003113011173030414031526 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * GradientXYBarPainter.java * ------------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); * 22-Feb-2009 : Fixed bug drawing outlines (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.ui.RectangleEdge; /** * An implementation of the {@link XYBarPainter} interface that uses several * gradient fills to enrich the appearance of the bars. * * @since 1.0.11 */ public class GradientXYBarPainter implements XYBarPainter, Serializable { /** The division point between the first and second gradient regions. */ private double g1; /** The division point between the second and third gradient regions. */ private double g2; /** The division point between the third and fourth gradient regions. */ private double g3; /** * Creates a new instance. */ public GradientXYBarPainter() { this(0.10, 0.20, 0.80); } /** * Creates a new instance. * * @param g1 * @param g2 * @param g3 */ public GradientXYBarPainter(double g1, double g2, double g3) { this.g1 = g1; this.g2 = g2; this.g3 = g3; } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. */ public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column); Color c0, c1; if (itemPaint instanceof Color) { c0 = (Color) itemPaint; c1 = c0.brighter(); } else if (itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; c0 = gp.getColor1(); c1 = gp.getColor2(); } else { c0 = Color.blue; c1 = Color.blue.brighter(); } // as a special case, if the bar colour has alpha == 0, we draw // nothing. if (c0.getAlpha() == 0) { return; } if (base == RectangleEdge.TOP || base == RectangleEdge.BOTTOM) { Rectangle2D[] regions = splitVerticalBar(bar, this.g1, this.g2, this.g3); GradientPaint gp = new GradientPaint((float) regions[0].getMinX(), 0.0f, c0, (float) regions[0].getMaxX(), 0.0f, Color.white); g2.setPaint(gp); g2.fill(regions[0]); gp = new GradientPaint((float) regions[1].getMinX(), 0.0f, Color.white, (float) regions[1].getMaxX(), 0.0f, c0); g2.setPaint(gp); g2.fill(regions[1]); gp = new GradientPaint((float) regions[2].getMinX(), 0.0f, c0, (float) regions[2].getMaxX(), 0.0f, c1); g2.setPaint(gp); g2.fill(regions[2]); gp = new GradientPaint((float) regions[3].getMinX(), 0.0f, c1, (float) regions[3].getMaxX(), 0.0f, c0); g2.setPaint(gp); g2.fill(regions[3]); } else if (base == RectangleEdge.LEFT || base == RectangleEdge.RIGHT) { Rectangle2D[] regions = splitHorizontalBar(bar, this.g1, this.g2, this.g3); GradientPaint gp = new GradientPaint(0.0f, (float) regions[0].getMinY(), c0, 0.0f, (float) regions[0].getMaxX(), Color.white); g2.setPaint(gp); g2.fill(regions[0]); gp = new GradientPaint(0.0f, (float) regions[1].getMinY(), Color.white, 0.0f, (float) regions[1].getMaxY(), c0); g2.setPaint(gp); g2.fill(regions[1]); gp = new GradientPaint(0.0f, (float) regions[2].getMinY(), c0, 0.0f, (float) regions[2].getMaxY(), c1); g2.setPaint(gp); g2.fill(regions[2]); gp = new GradientPaint(0.0f, (float) regions[3].getMinY(), c1, 0.0f, (float) regions[3].getMaxY(), c0); g2.setPaint(gp); g2.fill(regions[3]); } // draw the outline... if (renderer.isDrawBarOutline()) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. * @param pegShadow peg the shadow to the base of the bar? */ public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow) { // handle a special case - if the bar colour has alpha == 0, it is // invisible so we shouldn't draw any shadow Paint itemPaint = renderer.getItemPaint(row, column); if (itemPaint instanceof Color) { Color c = (Color) itemPaint; if (c.getAlpha() == 0) { return; } } RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); g2.setPaint(Color.gray); g2.fill(shadow); } /** * Creates a shadow for the bar. * * @param bar the bar shape. * @param xOffset the x-offset for the shadow. * @param yOffset the y-offset for the shadow. * @param base the edge that is the base of the bar. * @param pegShadow peg the shadow to the base? * * @return A rectangle for the shadow. */ private Rectangle2D createShadow(RectangularShape bar, double xOffset, double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY(); if (base == RectangleEdge.TOP) { x0 += xOffset; x1 += xOffset; if (!pegShadow) { y0 += yOffset; } y1 += yOffset; } else if (base == RectangleEdge.BOTTOM) { x0 += xOffset; x1 += xOffset; y0 += yOffset; if (!pegShadow) { y1 += yOffset; } } else if (base == RectangleEdge.LEFT) { if (!pegShadow) { x0 += xOffset; } x1 += xOffset; y0 += yOffset; y1 += yOffset; } else if (base == RectangleEdge.RIGHT) { x0 += xOffset; if (!pegShadow) { x1 += xOffset; } y0 += yOffset; y1 += yOffset; } return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); } /** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double x0 = bar.getMinX(); double x1 = Math.rint(x0 + (bar.getWidth() * a)); double x2 = Math.rint(x0 + (bar.getWidth() * b)); double x3 = Math.rint(x0 + (bar.getWidth() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight()); result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight()); result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight()); result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight()); return result; } /** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double y0 = bar.getMinY(); double y1 = Math.rint(y0 + (bar.getHeight() * a)); double y2 = Math.rint(y0 + (bar.getHeight() * b)); double y3 = Math.rint(y0 + (bar.getHeight() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), y1 - y0); result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(), y2 - y1); result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(), y3 - y2); result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(), bar.getMaxY() - y3); return result; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the obj (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GradientXYBarPainter)) { return false; } GradientXYBarPainter that = (GradientXYBarPainter) obj; if (this.g1 != that.g1) { return false; } if (this.g2 != that.g2) { return false; } if (this.g3 != that.g3) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 37; hash = HashUtilities.hashCode(hash, this.g1); hash = HashUtilities.hashCode(hash, this.g2); hash = HashUtilities.hashCode(hash, this.g3); return hash; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/HighLowRenderer.java0000644000175000017500000004515011173030414030577 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * HighLowRenderer.java * -------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Christian W. Zuckschwerdt; * * Changes * ------- * 13-Dec-2001 : Version 1 (DG); * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); * 28-Mar-2002 : Added a property change listener mechanism so that renderers * no longer need to be immutable (DG); * 09-Apr-2002 : Removed translatedRangeZero from the drawItem() method, and * changed the return type of the drawItem method to void, * reflecting a change in the XYItemRenderer interface. Added * tooltip code to drawItem() method (DG); * 05-Aug-2002 : Small modification to drawItem method to support URLs for * HTML image maps (RA); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 31-Jul-2003 : Deprecated constructor (DG); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 29-Jan-2004 : Fixed bug (882392) when rendering with * PlotOrientation.HORIZONTAL (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 01-Nov-2005 : Added optional openTickPaint and closeTickPaint settings (DG); * ------------- JFREECHART 1.0.0 --------------------------------------------- * 06-Jul-2006 : Replace dataset methods getX() --> getXValue() (DG); * 08-Apr-2008 : Added findRangeBounds() override (DG); * 29-Apr-2008 : Added tickLength field (DG); * 25-Sep-2008 : Check for non-null entity collection (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A renderer that draws high/low/open/close markers on an {@link XYPlot} * (requires a {@link OHLCDataset}). This renderer does not include code to * calculate the crosshair point for the plot. * * The example shown here is generated by the * HighLowChartDemo1.java program included in the JFreeChart Demo * Collection: *

* HighLowRendererSample.png */ public class HighLowRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8135673815876552516L; /** A flag that controls whether the open ticks are drawn. */ private boolean drawOpenTicks; /** A flag that controls whether the close ticks are drawn. */ private boolean drawCloseTicks; /** * The paint used for the open ticks (if null, the series * paint is used instead). */ private transient Paint openTickPaint; /** * The paint used for the close ticks (if null, the series * paint is used instead). */ private transient Paint closeTickPaint; /** * The tick length (in Java2D units). * * @since 1.0.10 */ private double tickLength; /** * The default constructor. */ public HighLowRenderer() { super(); this.drawOpenTicks = true; this.drawCloseTicks = true; this.tickLength = 2.0; } /** * Returns the flag that controls whether open ticks are drawn. * * @return A boolean. * * @see #getDrawCloseTicks() * @see #setDrawOpenTicks(boolean) */ public boolean getDrawOpenTicks() { return this.drawOpenTicks; } /** * Sets the flag that controls whether open ticks are drawn, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param draw the flag. * * @see #getDrawOpenTicks() */ public void setDrawOpenTicks(boolean draw) { this.drawOpenTicks = draw; fireChangeEvent(); } /** * Returns the flag that controls whether close ticks are drawn. * * @return A boolean. * * @see #getDrawOpenTicks() * @see #setDrawCloseTicks(boolean) */ public boolean getDrawCloseTicks() { return this.drawCloseTicks; } /** * Sets the flag that controls whether close ticks are drawn, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param draw the flag. * * @see #getDrawCloseTicks() */ public void setDrawCloseTicks(boolean draw) { this.drawCloseTicks = draw; fireChangeEvent(); } /** * Returns the paint used to draw the ticks for the open values. * * @return The paint used to draw the ticks for the open values (possibly * null). * * @see #setOpenTickPaint(Paint) */ public Paint getOpenTickPaint() { return this.openTickPaint; } /** * Sets the paint used to draw the ticks for the open values and sends a * {@link RendererChangeEvent} to all registered listeners. If you set * this to null (the default), the series paint is used * instead. * * @param paint the paint (null permitted). * * @see #getOpenTickPaint() */ public void setOpenTickPaint(Paint paint) { this.openTickPaint = paint; fireChangeEvent(); } /** * Returns the paint used to draw the ticks for the close values. * * @return The paint used to draw the ticks for the close values (possibly * null). * * @see #setCloseTickPaint(Paint) */ public Paint getCloseTickPaint() { return this.closeTickPaint; } /** * Sets the paint used to draw the ticks for the close values and sends a * {@link RendererChangeEvent} to all registered listeners. If you set * this to null (the default), the series paint is used * instead. * * @param paint the paint (null permitted). * * @see #getCloseTickPaint() */ public void setCloseTickPaint(Paint paint) { this.closeTickPaint = paint; fireChangeEvent(); } /** * Returns the tick length (in Java2D units). * * @return The tick length. * * @since 1.0.10 * * @see #setTickLength(double) */ public double getTickLength() { return this.tickLength; } /** * Sets the tick length (in Java2D units) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param length the length. * * @since 1.0.10 * * @see #getTickLength() */ public void setTickLength(double length) { this.tickLength = length; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { return DatasetUtilities.findRangeBounds(dataset, true); } else { return null; } } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { double x = dataset.getXValue(series, item); if (!domainAxis.getRange().contains(x)) { return; // the x value is not within the axis range } double xx = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } PlotOrientation orientation = plot.getOrientation(); RectangleEdge location = plot.getRangeAxisEdge(); Paint itemPaint = getItemPaint(series, item); Stroke itemStroke = getItemStroke(series, item); g2.setPaint(itemPaint); g2.setStroke(itemStroke); if (dataset instanceof OHLCDataset) { OHLCDataset hld = (OHLCDataset) dataset; double yHigh = hld.getHighValue(series, item); double yLow = hld.getLowValue(series, item); if (!Double.isNaN(yHigh) && !Double.isNaN(yLow)) { double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, location); double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, location); if (orientation == PlotOrientation.HORIZONTAL) { g2.draw(new Line2D.Double(yyLow, xx, yyHigh, xx)); entityArea = new Rectangle2D.Double(Math.min(yyLow, yyHigh), xx - 1.0, Math.abs(yyHigh - yyLow), 2.0); } else if (orientation == PlotOrientation.VERTICAL) { g2.draw(new Line2D.Double(xx, yyLow, xx, yyHigh)); entityArea = new Rectangle2D.Double(xx - 1.0, Math.min(yyLow, yyHigh), 2.0, Math.abs(yyHigh - yyLow)); } } double delta = getTickLength(); if (domainAxis.isInverted()) { delta = -delta; } if (getDrawOpenTicks()) { double yOpen = hld.getOpenValue(series, item); if (!Double.isNaN(yOpen)) { double yyOpen = rangeAxis.valueToJava2D(yOpen, dataArea, location); if (this.openTickPaint != null) { g2.setPaint(this.openTickPaint); } else { g2.setPaint(itemPaint); } if (orientation == PlotOrientation.HORIZONTAL) { g2.draw(new Line2D.Double(yyOpen, xx + delta, yyOpen, xx)); } else if (orientation == PlotOrientation.VERTICAL) { g2.draw(new Line2D.Double(xx - delta, yyOpen, xx, yyOpen)); } } } if (getDrawCloseTicks()) { double yClose = hld.getCloseValue(series, item); if (!Double.isNaN(yClose)) { double yyClose = rangeAxis.valueToJava2D( yClose, dataArea, location); if (this.closeTickPaint != null) { g2.setPaint(this.closeTickPaint); } else { g2.setPaint(itemPaint); } if (orientation == PlotOrientation.HORIZONTAL) { g2.draw(new Line2D.Double(yyClose, xx, yyClose, xx - delta)); } else if (orientation == PlotOrientation.VERTICAL) { g2.draw(new Line2D.Double(xx, yyClose, xx + delta, yyClose)); } } } } else { // not a HighLowDataset, so just draw a line connecting this point // with the previous point... if (item > 0) { double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); double y = dataset.getYValue(series, item); if (Double.isNaN(x0) || Double.isNaN(y0) || Double.isNaN(y)) { return; } double xx0 = domainAxis.valueToJava2D(x0, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y0, dataArea, location); double yy = rangeAxis.valueToJava2D(y, dataArea, location); if (orientation == PlotOrientation.HORIZONTAL) { g2.draw(new Line2D.Double(yy0, xx0, yy, xx)); } else if (orientation == PlotOrientation.VERTICAL) { g2.draw(new Line2D.Double(xx0, yy0, xx, yy)); } } } if (entities != null) { addEntity(entities, entityArea, dataset, series, item, 0.0, 0.0); } } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof HighLowRenderer)) { return false; } HighLowRenderer that = (HighLowRenderer) obj; if (this.drawOpenTicks != that.drawOpenTicks) { return false; } if (this.drawCloseTicks != that.drawCloseTicks) { return false; } if (!PaintUtilities.equal(this.openTickPaint, that.openTickPaint)) { return false; } if (!PaintUtilities.equal(this.closeTickPaint, that.closeTickPaint)) { return false; } if (this.tickLength != that.tickLength) { return false; } if (!super.equals(obj)) { return false; } return true; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.openTickPaint = SerialUtilities.readPaint(stream); this.closeTickPaint = SerialUtilities.readPaint(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.openTickPaint, stream); SerialUtilities.writePaint(this.closeTickPaint, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java0000644000175000017500000003501511173030414032100 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * SamplingXYLineRenderer.java * --------------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 02-Oct-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.PathIterator; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that... This renderer is designed for use with the {@link XYPlot} * class. */ public class SamplingXYLineRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** The shape that is used to represent a line in the legend. */ private transient Shape legendLine; /** * Creates a new renderer. */ public SamplingXYLineRenderer() { this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); } /** * Returns the shape used to represent a line in the legend. * * @return The legend line (never null). * * @see #setLegendLine(Shape) */ public Shape getLegendLine() { return this.legendLine; } /** * Sets the shape used as a line in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param line the line (null not permitted). * * @see #getLegendLine() */ public void setLegendLine(Shape line) { if (line == null) { throw new IllegalArgumentException("Null 'line' argument."); } this.legendLine = line; fireChangeEvent(); } /** * Returns the number of passes through the data that the renderer requires * in order to draw the chart. Most charts will require a single pass, but * some require two passes. * * @return The pass count. */ public int getPassCount() { return 1; } /** * Records the state for the renderer. This is used to preserve state * information between calls to the drawItem() method for a single chart * drawing. */ public static class State extends XYItemRendererState { /** The path for the current series. */ GeneralPath seriesPath; /** * A second path that draws vertical intervals to cover any extreme * values. */ GeneralPath intervalPath; /** * The minimum change in the x-value needed to trigger an update to * the seriesPath. */ double dX = 1.0; /** The last x-coordinate visited by the seriesPath. */ double lastX; /** The initial y-coordinate for the current x-coordinate. */ double openY = 0.0; /** The highest y-coordinate for the current x-coordinate. */ double highY = 0.0; /** The lowest y-coordinate for the current x-coordinate. */ double lowY = 0.0; /** The final y-coordinate for the current x-coordinate. */ double closeY = 0.0; /** * A flag that indicates if the last (x, y) point was 'good' * (non-null). */ boolean lastPointGood; /** * Creates a new state instance. * * @param info the plot rendering info. */ public State(PlotRenderingInfo info) { super(info); } /** * This method is called by the {@link XYPlot} at the start of each * series pass. We reset the state for the current series. * * @param dataset the dataset. * @param series the series index. * @param firstItem the first item index for this pass. * @param lastItem the last item index for this pass. * @param pass the current pass index. * @param passCount the number of passes. */ public void startSeriesPass(XYDataset dataset, int series, int firstItem, int lastItem, int pass, int passCount) { this.seriesPath.reset(); this.lastPointGood = false; super.startSeriesPass(dataset, series, firstItem, lastItem, pass, passCount); } } /** * Initialises the renderer. *

* This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { double dpi = 72; // Integer dpiVal = (Integer) g2.getRenderingHint(HintKey.DPI); // if (dpiVal != null) { // dpi = dpiVal.intValue(); // } State state = new State(info); state.seriesPath = new GeneralPath(); state.intervalPath = new GeneralPath(); state.dX = 72.0 / dpi; return state; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // do nothing if item is not visible if (!getItemVisible(series, item)) { return; } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); State s = (State) state; // update path to reflect latest point if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { float x = (float) transX1; float y = (float) transY1; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { x = (float) transY1; y = (float) transX1; } if (s.lastPointGood) { if ((Math.abs(x - s.lastX) > s.dX)) { s.seriesPath.lineTo(x, y); if (s.lowY < s.highY) { s.intervalPath.moveTo((float) s.lastX, (float) s.lowY); s.intervalPath.lineTo((float) s.lastX, (float) s.highY); } s.lastX = x; s.openY = y; s.highY = y; s.lowY = y; s.closeY = y; } else { s.highY = Math.max(s.highY, y); s.lowY = Math.min(s.lowY, y); s.closeY = y; } } else { s.seriesPath.moveTo(x, y); s.lastX = x; s.openY = y; s.highY = y; s.lowY = y; s.closeY = y; } s.lastPointGood = true; } else { s.lastPointGood = false; } // if this is the last item, draw the path ... if (item == s.getLastItemIndex()) { // draw path PathIterator pi = s.seriesPath.getPathIterator(null); int count = 0; while (!pi.isDone()) { count++; pi.next(); } g2.setStroke(getItemStroke(series, item)); g2.setPaint(getItemPaint(series, item)); g2.draw(s.seriesPath); g2.draw(s.intervalPath); } } /** * Returns a legend item for the specified series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { XYPlot plot = getPlot(); if (plot == null) { return null; } LegendItem result = null; XYDataset dataset = plot.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel( dataset, series); result = new LegendItem(label); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); } } return result; } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the clone cannot be created. */ public Object clone() throws CloneNotSupportedException { SamplingXYLineRenderer clone = (SamplingXYLineRenderer) super.clone(); if (this.legendLine != null) { clone.legendLine = ShapeUtilities.clone(this.legendLine); } return clone; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SamplingXYLineRenderer)) { return false; } if (!super.equals(obj)) { return false; } SamplingXYLineRenderer that = (SamplingXYLineRenderer) obj; if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { return false; } return true; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendLine = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendLine, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java0000644000175000017500000006252511173030414031673 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * StackedXYAreaRenderer.java * -------------------------- * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): Christian W. Zuckschwerdt; * David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 27-Jul-2003 : Initial version (RA); * 30-Jul-2003 : Modified entity constructor (CZ); * 18-Aug-2003 : Now handles null values (RA); * 20-Aug-2003 : Implemented Cloneable, PublicCloneable and Serializable (DG); * 22-Sep-2003 : Changed to be a two pass renderer with optional shape Paint * and Stroke (RA); * 07-Oct-2003 : Added renderer state (DG); * 10-Feb-2004 : Updated state object and changed drawItem() method to make * overriding easier (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 10-Sep-2004 : Removed getRangeType() method (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 06-Jan-2005 : Override equals() (DG); * 07-Jan-2005 : Update for method name changes in DatasetUtilities (DG); * 28-Mar-2005 : Use getXValue() and getYValue() from dataset (DG); * 06-Jun-2005 : Fixed null pointer exception, plus problems with equals() and * serialization (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 10-Nov-2006 : Fixed bug 1593156, NullPointerException with line * plotting (DG); * 02-Feb-2007 : Fixed bug 1649686, crosshairs don't stack y-values (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 22-Mar-2007 : Fire change events in setShapePaint() and setShapeStroke() * methods (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Point; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Stack; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.XYItemEntity; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A stacked area renderer for the {@link XYPlot} class. *

* The example shown here is generated by the * StackedXYAreaRendererDemo1.java program included in the * JFreeChart demo collection: *

* StackedXYAreaRendererSample.png *

* SPECIAL NOTE: This renderer does not currently handle negative data values * correctly. This should get fixed at some point, but the current workaround * is to use the {@link StackedXYAreaRenderer2} class instead. */ public class StackedXYAreaRenderer extends XYAreaRenderer implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 5217394318178570889L; /** * A state object for use by this renderer. */ static class StackedXYAreaRendererState extends XYItemRendererState { /** The area for the current series. */ private Polygon seriesArea; /** The line. */ private Line2D line; /** The points from the last series. */ private Stack lastSeriesPoints; /** The points for the current series. */ private Stack currentSeriesPoints; /** * Creates a new state for the renderer. * * @param info the plot rendering info. */ public StackedXYAreaRendererState(PlotRenderingInfo info) { super(info); this.seriesArea = null; this.line = new Line2D.Double(); this.lastSeriesPoints = new Stack(); this.currentSeriesPoints = new Stack(); } /** * Returns the series area. * * @return The series area. */ public Polygon getSeriesArea() { return this.seriesArea; } /** * Sets the series area. * * @param area the area. */ public void setSeriesArea(Polygon area) { this.seriesArea = area; } /** * Returns the working line. * * @return The working line. */ public Line2D getLine() { return this.line; } /** * Returns the current series points. * * @return The current series points. */ public Stack getCurrentSeriesPoints() { return this.currentSeriesPoints; } /** * Sets the current series points. * * @param points the points. */ public void setCurrentSeriesPoints(Stack points) { this.currentSeriesPoints = points; } /** * Returns the last series points. * * @return The last series points. */ public Stack getLastSeriesPoints() { return this.lastSeriesPoints; } /** * Sets the last series points. * * @param points the points. */ public void setLastSeriesPoints(Stack points) { this.lastSeriesPoints = points; } } /** * Custom Paint for drawing all shapes, if null defaults to series shapes */ private transient Paint shapePaint = null; /** * Custom Stroke for drawing all shapes, if null defaults to series * strokes. */ private transient Stroke shapeStroke = null; /** * Creates a new renderer. */ public StackedXYAreaRenderer() { this(AREA); } /** * Constructs a new renderer. * * @param type the type of the renderer. */ public StackedXYAreaRenderer(int type) { this(type, null, null); } /** * Constructs a new renderer. To specify the type of renderer, use one of * the constants: SHAPES, LINES, * SHAPES_AND_LINES, AREA or * AREA_AND_SHAPES. * * @param type the type of renderer. * @param labelGenerator the tool tip generator to use (null * is none). * @param urlGenerator the URL generator (null permitted). */ public StackedXYAreaRenderer(int type, XYToolTipGenerator labelGenerator, XYURLGenerator urlGenerator) { super(type, labelGenerator, urlGenerator); } /** * Returns the paint used for rendering shapes, or null if * using series paints. * * @return The paint (possibly null). * * @see #setShapePaint(Paint) */ public Paint getShapePaint() { return this.shapePaint; } /** * Sets the paint for rendering shapes and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shapePaint the paint (null permitted). * * @see #getShapePaint() */ public void setShapePaint(Paint shapePaint) { this.shapePaint = shapePaint; fireChangeEvent(); } /** * Returns the stroke used for rendering shapes, or null if * using series strokes. * * @return The stroke (possibly null). * * @see #setShapeStroke(Stroke) */ public Stroke getShapeStroke() { return this.shapeStroke; } /** * Sets the stroke for rendering shapes and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shapeStroke the stroke (null permitted). * * @see #getShapeStroke() */ public void setShapeStroke(Stroke shapeStroke) { this.shapeStroke = shapeStroke; fireChangeEvent(); } /** * Initialises the renderer. This method will be called before the first * item is rendered, giving the renderer an opportunity to initialise any * state information it wants to maintain. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return A state object that should be passed to subsequent calls to the * drawItem() method. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { XYItemRendererState state = new StackedXYAreaRendererState(info); // in the rendering process, there is special handling for item // zero, so we can't support processing of visible data items only state.setProcessVisibleItemsOnly(false); return state; } /** * Returns the number of passes required by the renderer. * * @return 2. */ public int getPassCount() { return 2; } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range ([0.0, 0.0] if the dataset contains no values, and * null if the dataset is null). * * @throws ClassCastException if dataset is not an instance * of {@link TableXYDataset}. */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { return DatasetUtilities.findStackedRangeBounds( (TableXYDataset) dataset); } else { return null; } } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState information about crosshairs on a plot. * @param pass the pass index. * * @throws ClassCastException if state is not an instance of * StackedXYAreaRendererState or dataset * is not an instance of {@link TableXYDataset}. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { PlotOrientation orientation = plot.getOrientation(); StackedXYAreaRendererState areaState = (StackedXYAreaRendererState) state; // Get the item count for the series, so that we can know which is the // end of the series. TableXYDataset tdataset = (TableXYDataset) dataset; int itemCount = tdataset.getItemCount(); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); boolean nullPoint = false; if (Double.isNaN(y1)) { y1 = 0.0; nullPoint = true; } // Get height adjustment based on stack and translate to Java2D values double ph1 = getPreviousHeight(tdataset, series, item); double transX1 = domainAxis.valueToJava2D(x1, dataArea, plot.getDomainAxisEdge()); double transY1 = rangeAxis.valueToJava2D(y1 + ph1, dataArea, plot.getRangeAxisEdge()); // Get series Paint and Stroke Paint seriesPaint = getItemPaint(series, item); Stroke seriesStroke = getItemStroke(series, item); if (pass == 0) { // On first pass render the areas, line and outlines if (item == 0) { // Create a new Area for the series areaState.setSeriesArea(new Polygon()); areaState.setLastSeriesPoints( areaState.getCurrentSeriesPoints()); areaState.setCurrentSeriesPoints(new Stack()); // start from previous height (ph1) double transY2 = rangeAxis.valueToJava2D(ph1, dataArea, plot.getRangeAxisEdge()); // The first point is (x, 0) if (orientation == PlotOrientation.VERTICAL) { areaState.getSeriesArea().addPoint((int) transX1, (int) transY2); } else if (orientation == PlotOrientation.HORIZONTAL) { areaState.getSeriesArea().addPoint((int) transY2, (int) transX1); } } // Add each point to Area (x, y) if (orientation == PlotOrientation.VERTICAL) { Point point = new Point((int) transX1, (int) transY1); areaState.getSeriesArea().addPoint((int) point.getX(), (int) point.getY()); areaState.getCurrentSeriesPoints().push(point); } else if (orientation == PlotOrientation.HORIZONTAL) { areaState.getSeriesArea().addPoint((int) transY1, (int) transX1); } if (getPlotLines()) { if (item > 0) { // get the previous data point... double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); double ph0 = getPreviousHeight(tdataset, series, item - 1); double transX0 = domainAxis.valueToJava2D(x0, dataArea, plot.getDomainAxisEdge()); double transY0 = rangeAxis.valueToJava2D(y0 + ph0, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.VERTICAL) { areaState.getLine().setLine(transX0, transY0, transX1, transY1); } else if (orientation == PlotOrientation.HORIZONTAL) { areaState.getLine().setLine(transY0, transX0, transY1, transX1); } g2.draw(areaState.getLine()); } } // Check if the item is the last item for the series and number of // items > 0. We can't draw an area for a single point. if (getPlotArea() && item > 0 && item == (itemCount - 1)) { double transY2 = rangeAxis.valueToJava2D(ph1, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.VERTICAL) { // Add the last point (x,0) areaState.getSeriesArea().addPoint((int) transX1, (int) transY2); } else if (orientation == PlotOrientation.HORIZONTAL) { // Add the last point (x,0) areaState.getSeriesArea().addPoint((int) transY2, (int) transX1); } // Add points from last series to complete the base of the // polygon if (series != 0) { Stack points = areaState.getLastSeriesPoints(); while (!points.empty()) { Point point = (Point) points.pop(); areaState.getSeriesArea().addPoint((int) point.getX(), (int) point.getY()); } } // Fill the polygon g2.setPaint(seriesPaint); g2.setStroke(seriesStroke); g2.fill(areaState.getSeriesArea()); // Draw an outline around the Area. if (isOutline()) { g2.setStroke(lookupSeriesOutlineStroke(series)); g2.setPaint(lookupSeriesOutlinePaint(series)); g2.draw(areaState.getSeriesArea()); } } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, ph1 + y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); } else if (pass == 1) { // On second pass render shapes and collect entity and tooltip // information Shape shape = null; if (getPlotShapes()) { shape = getItemShape(series, item); if (plot.getOrientation() == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } if (!nullPoint) { if (getShapePaint() != null) { g2.setPaint(getShapePaint()); } else { g2.setPaint(seriesPaint); } if (getShapeStroke() != null) { g2.setStroke(getShapeStroke()); } else { g2.setStroke(seriesStroke); } g2.draw(shape); } } else { if (plot.getOrientation() == PlotOrientation.VERTICAL) { shape = new Rectangle2D.Double(transX1 - 3, transY1 - 3, 6.0, 6.0); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { shape = new Rectangle2D.Double(transY1 - 3, transX1 - 3, 6.0, 6.0); } } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null && shape != null && !nullPoint) { String tip = null; XYToolTipGenerator generator = getToolTipGenerator(series, item); if (generator != null) { tip = generator.generateToolTip(dataset, series, item); } String url = null; if (getURLGenerator() != null) { url = getURLGenerator().generateURL(dataset, series, item); } XYItemEntity entity = new XYItemEntity(shape, dataset, series, item, tip, url); entities.add(entity); } } } } /** * Calculates the stacked value of the all series up to, but not including * series for the specified item. It returns 0.0 if * series is the first series, i.e. 0. * * @param dataset the dataset. * @param series the series. * @param index the index. * * @return The cumulative value for all series' values up to but excluding * series for index. */ protected double getPreviousHeight(TableXYDataset dataset, int series, int index) { double result = 0.0; for (int i = 0; i < series; i++) { double value = dataset.getYValue(i, index); if (!Double.isNaN(value)) { result += value; } } return result; } /** * Tests the renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StackedXYAreaRenderer) || !super.equals(obj)) { return false; } StackedXYAreaRenderer that = (StackedXYAreaRenderer) obj; if (!PaintUtilities.equal(this.shapePaint, that.shapePaint)) { return false; } if (!ObjectUtilities.equal(this.shapeStroke, that.shapeStroke)) { return false; } return true; } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.shapePaint = SerialUtilities.readPaint(stream); this.shapeStroke = SerialUtilities.readStroke(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.shapePaint, stream); SerialUtilities.writeStroke(this.shapeStroke, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java0000644000175000017500000005251711173030414031755 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StackedXYAreaRenderer2.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited), based on * the StackedXYAreaRenderer class by Richard Atkinson; * Contributor(s): -; * * Changes: * -------- * 30-Apr-2004 : Version 1 (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 10-Sep-2004 : Removed getRangeType() method (DG); * 06-Jan-2004 : Renamed getRangeExtent() --> findRangeBounds (DG); * 28-Mar-2005 : Use getXValue() and getYValue() from dataset (DG); * 03-Oct-2005 : Add entity generation to drawItem() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 22-Aug-2006 : Handle null and empty datasets correctly in the * findRangeBounds() method (DG); * 22-Sep-2006 : Added a flag to allow rounding of x-coordinates (after * translation to Java2D space) in order to avoid the striping * that can result from anti-aliasing (thanks to Doug * Clayton) (DG); * 30-Nov-2006 : Added accessor methods for the roundXCoordinates flag (DG); * 02-Jun-2008 : Fixed bug with PlotOrientation.HORIZONTAL (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.Range; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A stacked area renderer for the {@link XYPlot} class. * The example shown here is generated by the * StackedXYAreaChartDemo2.java program included in the * JFreeChart demo collection: *

* StackedXYAreaRenderer2Sample.png */ public class StackedXYAreaRenderer2 extends XYAreaRenderer2 implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7752676509764539182L; /** * This flag controls whether or not the x-coordinates (in Java2D space) * are rounded to integers. When set to true, this can avoid the vertical * striping that anti-aliasing can generate. However, the rounding may not * be appropriate for output in high resolution formats (for example, * vector graphics formats such as SVG and PDF). * * @since 1.0.3 */ private boolean roundXCoordinates; /** * Creates a new renderer. */ public StackedXYAreaRenderer2() { this(null, null); } /** * Constructs a new renderer. * * @param labelGenerator the tool tip generator to use. null * is none. * @param urlGenerator the URL generator (null permitted). */ public StackedXYAreaRenderer2(XYToolTipGenerator labelGenerator, XYURLGenerator urlGenerator) { super(labelGenerator, urlGenerator); this.roundXCoordinates = true; } /** * Returns the flag that controls whether or not the x-coordinates (in * Java2D space) are rounded to integer values. * * @return The flag. * * @since 1.0.4 * * @see #setRoundXCoordinates(boolean) */ public boolean getRoundXCoordinates() { return this.roundXCoordinates; } /** * Sets the flag that controls whether or not the x-coordinates (in * Java2D space) are rounded to integer values, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param round the new flag value. * * @since 1.0.4 * * @see #getRoundXCoordinates() */ public void setRoundXCoordinates(boolean round) { this.roundXCoordinates = round; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset == null) { return null; } double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; TableXYDataset d = (TableXYDataset) dataset; int itemCount = d.getItemCount(); for (int i = 0; i < itemCount; i++) { double[] stackValues = getStackValues((TableXYDataset) dataset, d.getSeriesCount(), i); min = Math.min(min, stackValues[0]); max = Math.max(max, stackValues[1]); } if (min == Double.POSITIVE_INFINITY) { return null; } return new Range(min, max); } /** * Returns the number of passes required by the renderer. * * @return 1. */ public int getPassCount() { return 1; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState information about crosshairs on a plot. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } TableXYDataset tdataset = (TableXYDataset) dataset; PlotOrientation orientation = plot.getOrientation(); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1)) { y1 = 0.0; } double[] stack1 = getStackValues(tdataset, series, item); // get the previous point and the next point so we can calculate a // "hot spot" for the area (used by the chart entity)... double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); if (Double.isNaN(y0)) { y0 = 0.0; } double[] stack0 = getStackValues(tdataset, series, Math.max(item - 1, 0)); int itemCount = dataset.getItemCount(series); double x2 = dataset.getXValue(series, Math.min(item + 1, itemCount - 1)); double y2 = dataset.getYValue(series, Math.min(item + 1, itemCount - 1)); if (Double.isNaN(y2)) { y2 = 0.0; } double[] stack2 = getStackValues(tdataset, series, Math.min(item + 1, itemCount - 1)); double xleft = (x0 + x1) / 2.0; double xright = (x1 + x2) / 2.0; double[] stackLeft = averageStackValues(stack0, stack1); double[] stackRight = averageStackValues(stack1, stack2); double[] adjStackLeft = adjustedStackValues(stack0, stack1); double[] adjStackRight = adjustedStackValues(stack1, stack2); RectangleEdge edge0 = plot.getDomainAxisEdge(); float transX1 = (float) domainAxis.valueToJava2D(x1, dataArea, edge0); float transXLeft = (float) domainAxis.valueToJava2D(xleft, dataArea, edge0); float transXRight = (float) domainAxis.valueToJava2D(xright, dataArea, edge0); if (this.roundXCoordinates) { transX1 = Math.round(transX1); transXLeft = Math.round(transXLeft); transXRight = Math.round(transXRight); } float transY1; RectangleEdge edge1 = plot.getRangeAxisEdge(); GeneralPath left = new GeneralPath(); GeneralPath right = new GeneralPath(); if (y1 >= 0.0) { // handle positive value transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea, edge1); float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1], dataArea, edge1); float transStackLeft = (float) rangeAxis.valueToJava2D( adjStackLeft[1], dataArea, edge1); // LEFT POLYGON if (y0 >= 0.0) { double yleft = (y0 + y1) / 2.0 + stackLeft[1]; float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1); if (orientation == PlotOrientation.VERTICAL) { left.moveTo(transX1, transY1); left.lineTo(transX1, transStack1); left.lineTo(transXLeft, transStackLeft); left.lineTo(transXLeft, transYLeft); } else { left.moveTo(transY1, transX1); left.lineTo(transStack1, transX1); left.lineTo(transStackLeft, transXLeft); left.lineTo(transYLeft, transXLeft); } left.closePath(); } else { if (orientation == PlotOrientation.VERTICAL) { left.moveTo(transX1, transStack1); left.lineTo(transX1, transY1); left.lineTo(transXLeft, transStackLeft); } else { left.moveTo(transStack1, transX1); left.lineTo(transY1, transX1); left.lineTo(transStackLeft, transXLeft); } left.closePath(); } float transStackRight = (float) rangeAxis.valueToJava2D( adjStackRight[1], dataArea, edge1); // RIGHT POLYGON if (y2 >= 0.0) { double yright = (y1 + y2) / 2.0 + stackRight[1]; float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1); if (orientation == PlotOrientation.VERTICAL) { right.moveTo(transX1, transStack1); right.lineTo(transX1, transY1); right.lineTo(transXRight, transYRight); right.lineTo(transXRight, transStackRight); } else { right.moveTo(transStack1, transX1); right.lineTo(transY1, transX1); right.lineTo(transYRight, transXRight); right.lineTo(transStackRight, transXRight); } right.closePath(); } else { if (orientation == PlotOrientation.VERTICAL) { right.moveTo(transX1, transStack1); right.lineTo(transX1, transY1); right.lineTo(transXRight, transStackRight); } else { right.moveTo(transStack1, transX1); right.lineTo(transY1, transX1); right.lineTo(transStackRight, transXRight); } right.closePath(); } } else { // handle negative value transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea, edge1); float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0], dataArea, edge1); float transStackLeft = (float) rangeAxis.valueToJava2D( adjStackLeft[0], dataArea, edge1); // LEFT POLYGON if (y0 >= 0.0) { if (orientation == PlotOrientation.VERTICAL) { left.moveTo(transX1, transStack1); left.lineTo(transX1, transY1); left.lineTo(transXLeft, transStackLeft); } else { left.moveTo(transStack1, transX1); left.lineTo(transY1, transX1); left.lineTo(transStackLeft, transXLeft); } left.clone(); } else { double yleft = (y0 + y1) / 2.0 + stackLeft[0]; float transYLeft = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1); if (orientation == PlotOrientation.VERTICAL) { left.moveTo(transX1, transY1); left.lineTo(transX1, transStack1); left.lineTo(transXLeft, transStackLeft); left.lineTo(transXLeft, transYLeft); } else { left.moveTo(transY1, transX1); left.lineTo(transStack1, transX1); left.lineTo(transStackLeft, transXLeft); left.lineTo(transYLeft, transXLeft); } left.closePath(); } float transStackRight = (float) rangeAxis.valueToJava2D( adjStackRight[0], dataArea, edge1); // RIGHT POLYGON if (y2 >= 0.0) { if (orientation == PlotOrientation.VERTICAL) { right.moveTo(transX1, transStack1); right.lineTo(transX1, transY1); right.lineTo(transXRight, transStackRight); } else { right.moveTo(transStack1, transX1); right.lineTo(transY1, transX1); right.lineTo(transStackRight, transXRight); } right.closePath(); } else { double yright = (y1 + y2) / 2.0 + stackRight[0]; float transYRight = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1); if (orientation == PlotOrientation.VERTICAL) { right.moveTo(transX1, transStack1); right.lineTo(transX1, transY1); right.lineTo(transXRight, transYRight); right.lineTo(transXRight, transStackRight); } else { right.moveTo(transStack1, transX1); right.lineTo(transY1, transX1); right.lineTo(transYRight, transXRight); right.lineTo(transStackRight, transXRight); } right.closePath(); } } // Get series Paint and Stroke Paint itemPaint = getItemPaint(series, item); if (pass == 0) { g2.setPaint(itemPaint); g2.fill(left); g2.fill(right); } // add an entity for the item... if (entities != null) { GeneralPath gp = new GeneralPath(left); gp.append(right, false); entityArea = gp; addEntity(entities, entityArea, dataset, series, item, transX1, transY1); } } /** * Calculates the stacked values (one positive and one negative) of all * series up to, but not including, series for the specified * item. It returns [0.0, 0.0] if series is the first series. * * @param dataset the dataset (null not permitted). * @param series the series index. * @param index the item index. * * @return An array containing the cumulative negative and positive values * for all series values up to but excluding series * for index. */ private double[] getStackValues(TableXYDataset dataset, int series, int index) { double[] result = new double[2]; for (int i = 0; i < series; i++) { double v = dataset.getYValue(i, index); if (!Double.isNaN(v)) { if (v >= 0.0) { result[1] += v; } else { result[0] += v; } } } return result; } /** * Returns a pair of "stack" values calculated as the mean of the two * specified stack value pairs. * * @param stack1 the first stack pair. * @param stack2 the second stack pair. * * @return A pair of average stack values. */ private double[] averageStackValues(double[] stack1, double[] stack2) { double[] result = new double[2]; result[0] = (stack1[0] + stack2[0]) / 2.0; result[1] = (stack1[1] + stack2[1]) / 2.0; return result; } /** * Calculates adjusted stack values from the supplied values. The value is * the mean of the supplied values, unless either of the supplied values * is zero, in which case the adjusted value is zero also. * * @param stack1 the first stack pair. * @param stack2 the second stack pair. * * @return A pair of average stack values. */ private double[] adjustedStackValues(double[] stack1, double[] stack2) { double[] result = new double[2]; if (stack1[0] == 0.0 || stack2[0] == 0.0) { result[0] = 0.0; } else { result[0] = (stack1[0] + stack2[0]) / 2.0; } if (stack1[1] == 0.0 || stack2[1] == 0.0) { result[1] = 0.0; } else { result[1] = (stack1[1] + stack2[1]) / 2.0; } return result; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StackedXYAreaRenderer2)) { return false; } StackedXYAreaRenderer2 that = (StackedXYAreaRenderer2) obj; if (this.roundXCoordinates != that.roundXCoordinates) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java0000644000175000017500000004003311173030414031515 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * StackedXYBarRenderer.java * ------------------------- * (C) Copyright 2004-2008, by Andreas Schroeder and Contributors. * * Original Author: Andreas Schroeder; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Apr-2004 : Version 1 (AS); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 15-Aug-2004 : Added drawBarOutline to control draw/don't-draw bar * outlines (BN); * 10-Sep-2004 : drawBarOutline attribute is now inherited from XYBarRenderer * and double primitives are retrieved from the dataset rather * than Number objects (DG); * 07-Jan-2005 : Updated for method name change in DatasetUtilities (DG); * 25-Jan-2005 : Modified to handle negative values correctly (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Dec-2006 : Added support for GradientPaint (DG); * 15-Mar-2007 : Added renderAsPercentages option (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * 23-Sep-2008 : Check shadow visibility before drawing shadow (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; /** * A bar renderer that displays the series items stacked. * The dataset used together with this renderer must be a * {@link org.jfree.data.xy.IntervalXYDataset} and a * {@link org.jfree.data.xy.TableXYDataset}. For example, the * dataset class {@link org.jfree.data.xy.CategoryTableXYDataset} * implements both interfaces. * * The example shown here is generated by the * StackedXYBarChartDemo2.java program included in the * JFreeChart demo collection: *

* StackedXYBarRendererSample.png */ public class StackedXYBarRenderer extends XYBarRenderer { /** For serialization. */ private static final long serialVersionUID = -7049101055533436444L; /** A flag that controls whether the bars display values or percentages. */ private boolean renderAsPercentages; /** * Creates a new renderer. */ public StackedXYBarRenderer() { this(0.0); } /** * Creates a new renderer. * * @param margin the percentual amount of the bars that are cut away. */ public StackedXYBarRenderer(double margin) { super(margin); this.renderAsPercentages = false; // set the default item label positions, which will only be used if // the user requests visible item labels... ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER); setBasePositiveItemLabelPosition(p); setBaseNegativeItemLabelPosition(p); setPositiveItemLabelPositionFallback(null); setNegativeItemLabelPositionFallback(null); } /** * Returns true if the renderer displays each item value as * a percentage (so that the stacked bars add to 100%), and * false otherwise. * * @return A boolean. * * @see #setRenderAsPercentages(boolean) * * @since 1.0.5 */ public boolean getRenderAsPercentages() { return this.renderAsPercentages; } /** * Sets the flag that controls whether the renderer displays each item * value as a percentage (so that the stacked bars add to 100%), and sends * a {@link RendererChangeEvent} to all registered listeners. * * @param asPercentages the flag. * * @see #getRenderAsPercentages() * * @since 1.0.5 */ public void setRenderAsPercentages(boolean asPercentages) { this.renderAsPercentages = asPercentages; fireChangeEvent(); } /** * Returns 3 to indicate that this renderer requires three * passes for drawing (shadows are drawn in the first pass, the bars in the * second, and item labels are drawn in the third pass so that * they always appear in front of all the bars). * * @return 2. */ public int getPassCount() { return 3; } /** * Initialises the renderer and returns a state object that should be * passed to all subsequent calls to the drawItem() method. Here there is * nothing to do. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return A state object. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { return new XYBarRendererState(info); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { if (this.renderAsPercentages) { return new Range(0.0, 1.0); } else { return DatasetUtilities.findStackedRangeBounds( (TableXYDataset) dataset); } } else { return null; } } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!(dataset instanceof IntervalXYDataset && dataset instanceof TableXYDataset)) { String message = "dataset (type " + dataset.getClass().getName() + ") has wrong type:"; boolean and = false; if (!IntervalXYDataset.class.isAssignableFrom(dataset.getClass())) { message += " it is no IntervalXYDataset"; and = true; } if (!TableXYDataset.class.isAssignableFrom(dataset.getClass())) { if (and) { message += " and"; } message += " it is no TableXYDataset"; } throw new IllegalArgumentException(message); } IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; double value = intervalDataset.getYValue(series, item); if (Double.isNaN(value)) { return; } // if we are rendering the values as percentages, we need to calculate // the total for the current item. Unfortunately here we end up // repeating the calculation more times than is strictly necessary - // hopefully I'll come back to this and find a way to add the // total(s) to the renderer state. The other problem is we implicitly // assume the dataset has no negative values...perhaps that can be // fixed too. double total = 0.0; if (this.renderAsPercentages) { total = DatasetUtilities.calculateStackTotal( (TableXYDataset) dataset, item); value = value / total; } double positiveBase = 0.0; double negativeBase = 0.0; for (int i = 0; i < series; i++) { double v = dataset.getYValue(i, item); if (!Double.isNaN(v)) { if (this.renderAsPercentages) { v = v / total; } if (v > 0) { positiveBase = positiveBase + v; } else { negativeBase = negativeBase + v; } } } double translatedBase; double translatedValue; RectangleEdge edgeR = plot.getRangeAxisEdge(); if (value > 0.0) { translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, edgeR); translatedValue = rangeAxis.valueToJava2D(positiveBase + value, dataArea, edgeR); } else { translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, edgeR); translatedValue = rangeAxis.valueToJava2D(negativeBase + value, dataArea, edgeR); } RectangleEdge edgeD = plot.getDomainAxisEdge(); double startX = intervalDataset.getStartXValue(series, item); if (Double.isNaN(startX)) { return; } double translatedStartX = domainAxis.valueToJava2D(startX, dataArea, edgeD); double endX = intervalDataset.getEndXValue(series, item); if (Double.isNaN(endX)) { return; } double translatedEndX = domainAxis.valueToJava2D(endX, dataArea, edgeD); double translatedWidth = Math.max(1, Math.abs(translatedEndX - translatedStartX)); double translatedHeight = Math.abs(translatedValue - translatedBase); if (getMargin() > 0.0) { double cut = translatedWidth * getMargin(); translatedWidth = translatedWidth - cut; translatedStartX = translatedStartX + cut / 2; } Rectangle2D bar = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(Math.min(translatedBase, translatedValue), translatedEndX, translatedHeight, translatedWidth); } else if (orientation == PlotOrientation.VERTICAL) { bar = new Rectangle2D.Double(translatedStartX, Math.min(translatedBase, translatedValue), translatedWidth, translatedHeight); } boolean positive = (value > 0.0); boolean inverted = rangeAxis.isInverted(); RectangleEdge barBase; if (orientation == PlotOrientation.HORIZONTAL) { if (positive && inverted || !positive && !inverted) { barBase = RectangleEdge.RIGHT; } else { barBase = RectangleEdge.LEFT; } } else { if (positive && !inverted || !positive && inverted) { barBase = RectangleEdge.BOTTOM; } else { barBase = RectangleEdge.TOP; } } if (pass == 0) { if (getShadowsVisible()) { getBarPainter().paintBarShadow(g2, this, series, item, bar, barBase, false); } } else if (pass == 1) { getBarPainter().paintBar(g2, this, series, item, bar, barBase); // add an entity for the item... if (info != null) { EntityCollection entities = info.getOwner() .getEntityCollection(); if (entities != null) { addEntity(entities, bar, dataset, series, item, bar.getCenterX(), bar.getCenterY()); } } } else if (pass == 2) { // handle item label drawing, now that we know all the bars have // been drawn... if (isItemLabelVisible(series, item)) { XYItemLabelGenerator generator = getItemLabelGenerator(series, item); drawItemLabel(g2, dataset, series, item, plot, generator, bar, value < 0.0); } } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StackedXYBarRenderer)) { return false; } StackedXYBarRenderer that = (StackedXYBarRenderer) obj; if (this.renderAsPercentages != that.renderAsPercentages) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = result * 37 + (this.renderAsPercentages ? 1 : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/StandardXYBarPainter.java0000644000175000017500000001571211173030414031541 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * StandardXYBarPainter.java * ------------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape; import java.io.Serializable; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; /** * An implementation of the {@link XYBarPainter} interface that preserves the * behaviour of bar painting that existed prior to the introduction of the * {@link XYBarPainter} interface. * * @see GradientXYBarPainter * * @since 1.0.11 */ public class StandardXYBarPainter implements XYBarPainter, Serializable { /** * Creates a new instance. */ public StandardXYBarPainter() { } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. */ public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { Paint itemPaint = renderer.getItemPaint(row, column); GradientPaintTransformer t = renderer.getGradientPaintTransformer(); if (t != null && itemPaint instanceof GradientPaint) { itemPaint = t.transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); // draw the outline... if (renderer.isDrawBarOutline()) { // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } } /** * Paints a single bar instance. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index. * @param column the column index. * @param bar the bar * @param base indicates which side of the rectangle is the base of the * bar. * @param pegShadow peg the shadow to the base of the bar? */ public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow) { // handle a special case - if the bar colour has alpha == 0, it is // invisible so we shouldn't draw any shadow Paint itemPaint = renderer.getItemPaint(row, column); if (itemPaint instanceof Color) { Color c = (Color) itemPaint; if (c.getAlpha() == 0) { return; } } RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); g2.setPaint(Color.gray); g2.fill(shadow); } /** * Creates a shadow for the bar. * * @param bar the bar shape. * @param xOffset the x-offset for the shadow. * @param yOffset the y-offset for the shadow. * @param base the edge that is the base of the bar. * @param pegShadow peg the shadow to the base? * * @return A rectangle for the shadow. */ private Rectangle2D createShadow(RectangularShape bar, double xOffset, double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY(); if (base == RectangleEdge.TOP) { x0 += xOffset; x1 += xOffset; if (!pegShadow) { y0 += yOffset; } y1 += yOffset; } else if (base == RectangleEdge.BOTTOM) { x0 += xOffset; x1 += xOffset; y0 += yOffset; if (!pegShadow) { y1 += yOffset; } } else if (base == RectangleEdge.LEFT) { if (!pegShadow) { x0 += xOffset; } x1 += xOffset; y0 += yOffset; y1 += yOffset; } else if (base == RectangleEdge.RIGHT) { x0 += xOffset; if (!pegShadow) { x1 += xOffset; } y0 += yOffset; y1 += yOffset; } return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the obj (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYBarPainter)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 37; // no fields to compute... return hash; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java0000644000175000017500000012141611173030414032076 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StandardXYItemRenderer.java * --------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Mark Watson (www.markwatson.com); * Jonathan Nash; * Andreas Schneider; * Norbert Kiesel (for TBD Networks); * Christian W. Zuckschwerdt; * Bill Kelemen; * Nicolas Brodu (for Astrium and EADS Corporate Research * Center); * * Changes: * -------- * 19-Oct-2001 : Version 1, based on code by Mark Watson (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 21-Dec-2001 : Added working line instance to improve performance (DG); * 22-Jan-2002 : Added code to lock crosshairs to data points. Based on code * by Jonathan Nash (DG); * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); * 28-Mar-2002 : Added a property change listener mechanism so that the * renderer no longer needs to be immutable (DG); * 02-Apr-2002 : Modified to handle null values (DG); * 09-Apr-2002 : Modified draw method to return void. Removed the translated * zero from the drawItem method. Override the initialise() * method to calculate it (DG); * 13-May-2002 : Added code from Andreas Schneider to allow changing * shapes/colors per item (DG); * 24-May-2002 : Incorporated tooltips into chart entities (DG); * 25-Jun-2002 : Removed redundant code (DG); * 05-Aug-2002 : Incorporated URLs for HTML image maps into chart entities (RA); * 08-Aug-2002 : Added discontinuous lines option contributed by * Norbert Kiesel (DG); * 20-Aug-2002 : Added user definable default values to be returned by * protected methods unless overridden by a subclass (DG); * 23-Sep-2002 : Updated for changes in the XYItemRenderer interface (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 15-May-2003 : Modified to take into account the plot orientation (DG); * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 24-Aug-2003 : Added null/NaN checks in drawItem (BK); * 08-Sep-2003 : Fixed serialization (NB); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 21-Jan-2004 : Override for getLegendItem() method (DG); * 27-Jan-2004 : Moved working line into state object (DG); * 10-Feb-2004 : Changed drawItem() method to make cut-and-paste overriding * easier (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 08-Jun-2004 : Modified to use getX() and getY() methods (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 25-Aug-2004 : Created addEntity() method in superclass (DG); * 08-Oct-2004 : Added 'gapThresholdType' as suggested by Mike Watts (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 23-Feb-2005 : Fixed getLegendItem() method to show lines. Fixed bug * 1077108 (shape not visible for first item in series) (DG); * 10-Apr-2005 : Fixed item label positioning with horizontal orientation (DG); * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); * 27-Apr-2005 : Use generator for series label in legend (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 15-Jun-2006 : Fixed bug (1380480) for rendering series as path (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 14-Mar-2007 : Fixed problems with the equals() and clone() methods (DG); * 23-Mar-2007 : Clean-up of shapesFilled attributes (DG); * 20-Apr-2007 : Updated getLegendItem() and drawItem() for renderer * change (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() * method (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 08-Jun-2007 : Fixed bug in entity creation (DG); * 21-Nov-2007 : Deprecated override flag methods (DG); * 02-Jun-2008 : Fixed tooltips for data items at lower edges of data area (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Paint; import java.awt.Point; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.BooleanList; import org.jfree.util.BooleanUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; import org.jfree.util.UnitType; /** * Standard item renderer for an {@link XYPlot}. This class can draw (a) * shapes at each point, or (b) lines between points, or (c) both shapes and * lines. *

* This renderer has been retained for historical reasons and, in general, you * should use the {@link XYLineAndShapeRenderer} class instead. */ public class StandardXYItemRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3271351259436865995L; /** Constant for the type of rendering (shapes only). */ public static final int SHAPES = 1; /** Constant for the type of rendering (lines only). */ public static final int LINES = 2; /** Constant for the type of rendering (shapes and lines). */ public static final int SHAPES_AND_LINES = SHAPES | LINES; /** Constant for the type of rendering (images only). */ public static final int IMAGES = 4; /** Constant for the type of rendering (discontinuous lines). */ public static final int DISCONTINUOUS = 8; /** Constant for the type of rendering (discontinuous lines). */ public static final int DISCONTINUOUS_LINES = LINES | DISCONTINUOUS; /** A flag indicating whether or not shapes are drawn at each XY point. */ private boolean baseShapesVisible; /** A flag indicating whether or not lines are drawn between XY points. */ private boolean plotLines; /** A flag indicating whether or not images are drawn between XY points. */ private boolean plotImages; /** A flag controlling whether or not discontinuous lines are used. */ private boolean plotDiscontinuous; /** Specifies how the gap threshold value is interpreted. */ private UnitType gapThresholdType = UnitType.RELATIVE; /** Threshold for deciding when to discontinue a line. */ private double gapThreshold = 1.0; /** * A flag that controls whether or not shapes are filled for ALL series. * * @deprecated As of 1.0.8, this override should not be used. */ private Boolean shapesFilled; /** * A table of flags that control (per series) whether or not shapes are * filled. */ private BooleanList seriesShapesFilled; /** The default value returned by the getShapeFilled() method. */ private boolean baseShapesFilled; /** * A flag that controls whether or not each series is drawn as a single * path. */ private boolean drawSeriesLineAsPath; /** * The shape that is used to represent a line in the legend. * This should never be set to null. */ private transient Shape legendLine; /** * Constructs a new renderer. */ public StandardXYItemRenderer() { this(LINES, null); } /** * Constructs a new renderer. To specify the type of renderer, use one of * the constants: {@link #SHAPES}, {@link #LINES} or * {@link #SHAPES_AND_LINES}. * * @param type the type. */ public StandardXYItemRenderer(int type) { this(type, null); } /** * Constructs a new renderer. To specify the type of renderer, use one of * the constants: {@link #SHAPES}, {@link #LINES} or * {@link #SHAPES_AND_LINES}. * * @param type the type of renderer. * @param toolTipGenerator the item label generator (null * permitted). */ public StandardXYItemRenderer(int type, XYToolTipGenerator toolTipGenerator) { this(type, toolTipGenerator, null); } /** * Constructs a new renderer. To specify the type of renderer, use one of * the constants: {@link #SHAPES}, {@link #LINES} or * {@link #SHAPES_AND_LINES}. * * @param type the type of renderer. * @param toolTipGenerator the item label generator (null * permitted). * @param urlGenerator the URL generator. */ public StandardXYItemRenderer(int type, XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); setURLGenerator(urlGenerator); if ((type & SHAPES) != 0) { this.baseShapesVisible = true; } if ((type & LINES) != 0) { this.plotLines = true; } if ((type & IMAGES) != 0) { this.plotImages = true; } if ((type & DISCONTINUOUS) != 0) { this.plotDiscontinuous = true; } this.shapesFilled = null; this.seriesShapesFilled = new BooleanList(); this.baseShapesFilled = true; this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); this.drawSeriesLineAsPath = false; } /** * Returns true if shapes are being plotted by the renderer. * * @return true if shapes are being plotted by the renderer. * * @see #setBaseShapesVisible */ public boolean getBaseShapesVisible() { return this.baseShapesVisible; } /** * Sets the flag that controls whether or not a shape is plotted at each * data point. * * @param flag the flag. * * @see #getBaseShapesVisible */ public void setBaseShapesVisible(boolean flag) { if (this.baseShapesVisible != flag) { this.baseShapesVisible = flag; fireChangeEvent(); } } // SHAPES FILLED /** * Returns the flag used to control whether or not the shape for an item is * filled. *

* The default implementation passes control to the * getSeriesShapesFilled method. You can override this method * if you require different behaviour. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. * * @see #getSeriesShapesFilled(int) */ public boolean getItemShapeFilled(int series, int item) { // return the overall setting, if there is one... if (this.shapesFilled != null) { return this.shapesFilled.booleanValue(); } // otherwise look up the paint table Boolean flag = this.seriesShapesFilled.getBoolean(series); if (flag != null) { return flag.booleanValue(); } else { return this.baseShapesFilled; } } /** * Returns the override flag that controls whether or not shapes are filled * for ALL series. * * @return The flag (possibly null). * * @since 1.0.5 * * @deprecated As of 1.0.8, you should avoid using this method and rely * on just the per-series ({@link #getSeriesShapesFilled(int)}) * and base-level ({@link #getBaseShapesFilled()}) settings. */ public Boolean getShapesFilled() { return this.shapesFilled; } /** * Sets the override flag that controls whether or not shapes are filled * for ALL series and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param filled the flag. * * @see #setShapesFilled(Boolean) * * @deprecated As of 1.0.8, you should avoid using this method and rely * on just the per-series ({@link #setSeriesShapesFilled(int, * Boolean)}) and base-level ({@link #setBaseShapesVisible( * boolean)}) settings. */ public void setShapesFilled(boolean filled) { // here we use BooleanUtilities to remain compatible with JDKs < 1.4 setShapesFilled(BooleanUtilities.valueOf(filled)); } /** * Sets the override flag that controls whether or not shapes are filled * for ALL series and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param filled the flag (null permitted). * * @see #setShapesFilled(boolean) * * @deprecated As of 1.0.8, you should avoid using this method and rely * on just the per-series ({@link #setSeriesShapesFilled(int, * Boolean)}) and base-level ({@link #setBaseShapesVisible( * boolean)}) settings. */ public void setShapesFilled(Boolean filled) { this.shapesFilled = filled; fireChangeEvent(); } /** * Returns the flag used to control whether or not the shapes for a series * are filled. * * @param series the series index (zero-based). * * @return A boolean. */ public Boolean getSeriesShapesFilled(int series) { return this.seriesShapesFilled.getBoolean(series); } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag. * * @see #getSeriesShapesFilled(int) */ public void setSeriesShapesFilled(int series, Boolean flag) { this.seriesShapesFilled.setBoolean(series, flag); fireChangeEvent(); } /** * Returns the base 'shape filled' attribute. * * @return The base flag. * * @see #setBaseShapesFilled(boolean) */ public boolean getBaseShapesFilled() { return this.baseShapesFilled; } /** * Sets the base 'shapes filled' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseShapesFilled() */ public void setBaseShapesFilled(boolean flag) { this.baseShapesFilled = flag; } /** * Returns true if lines are being plotted by the renderer. * * @return true if lines are being plotted by the renderer. * * @see #setPlotLines(boolean) */ public boolean getPlotLines() { return this.plotLines; } /** * Sets the flag that controls whether or not a line is plotted between * each data point and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param flag the flag. * * @see #getPlotLines() */ public void setPlotLines(boolean flag) { if (this.plotLines != flag) { this.plotLines = flag; fireChangeEvent(); } } /** * Returns the gap threshold type (relative or absolute). * * @return The type. * * @see #setGapThresholdType(UnitType) */ public UnitType getGapThresholdType() { return this.gapThresholdType; } /** * Sets the gap threshold type and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param thresholdType the type (null not permitted). * * @see #getGapThresholdType() */ public void setGapThresholdType(UnitType thresholdType) { if (thresholdType == null) { throw new IllegalArgumentException( "Null 'thresholdType' argument."); } this.gapThresholdType = thresholdType; fireChangeEvent(); } /** * Returns the gap threshold for discontinuous lines. * * @return The gap threshold. * * @see #setGapThreshold(double) */ public double getGapThreshold() { return this.gapThreshold; } /** * Sets the gap threshold for discontinuous lines and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param t the threshold. * * @see #getGapThreshold() */ public void setGapThreshold(double t) { this.gapThreshold = t; fireChangeEvent(); } /** * Returns true if images are being plotted by the renderer. * * @return true if images are being plotted by the renderer. * * @see #setPlotImages(boolean) */ public boolean getPlotImages() { return this.plotImages; } /** * Sets the flag that controls whether or not an image is drawn at each * data point and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #getPlotImages() */ public void setPlotImages(boolean flag) { if (this.plotImages != flag) { this.plotImages = flag; fireChangeEvent(); } } /** * Returns a flag that controls whether or not the renderer shows * discontinuous lines. * * @return true if lines should be discontinuous. */ public boolean getPlotDiscontinuous() { return this.plotDiscontinuous; } /** * Sets the flag that controls whether or not the renderer shows * discontinuous lines, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param flag the new flag value. * * @since 1.0.5 */ public void setPlotDiscontinuous(boolean flag) { if (this.plotDiscontinuous != flag) { this.plotDiscontinuous = flag; fireChangeEvent(); } } /** * Returns a flag that controls whether or not each series is drawn as a * single path. * * @return A boolean. * * @see #setDrawSeriesLineAsPath(boolean) */ public boolean getDrawSeriesLineAsPath() { return this.drawSeriesLineAsPath; } /** * Sets the flag that controls whether or not each series is drawn as a * single path. * * @param flag the flag. * * @see #getDrawSeriesLineAsPath() */ public void setDrawSeriesLineAsPath(boolean flag) { this.drawSeriesLineAsPath = flag; } /** * Returns the shape used to represent a line in the legend. * * @return The legend line (never null). * * @see #setLegendLine(Shape) */ public Shape getLegendLine() { return this.legendLine; } /** * Sets the shape used as a line in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param line the line (null not permitted). * * @see #getLegendLine() */ public void setLegendLine(Shape line) { if (line == null) { throw new IllegalArgumentException("Null 'line' argument."); } this.legendLine = line; fireChangeEvent(); } /** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { XYPlot plot = getPlot(); if (plot == null) { return null; } LegendItem result = null; XYDataset dataset = plot.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = lookupLegendShape(series); boolean shapeFilled = getItemShapeFilled(series, 0); Paint paint = lookupSeriesPaint(series); Paint linePaint = paint; Stroke lineStroke = lookupSeriesStroke(series); result = new LegendItem(label, description, toolTipText, urlText, this.baseShapesVisible, shape, shapeFilled, paint, !shapeFilled, paint, lineStroke, this.plotLines, this.legendLine, lineStroke, linePaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } return result; } /** * Records the state for the renderer. This is used to preserve state * information between calls to the drawItem() method for a single chart * drawing. */ public static class State extends XYItemRendererState { /** The path for the current series. */ public GeneralPath seriesPath; /** The series index. */ private int seriesIndex; /** * A flag that indicates if the last (x, y) point was 'good' * (non-null). */ private boolean lastPointGood; /** * Creates a new state instance. * * @param info the plot rendering info. */ public State(PlotRenderingInfo info) { super(info); } /** * Returns a flag that indicates if the last point drawn (in the * current series) was 'good' (non-null). * * @return A boolean. */ public boolean isLastPointGood() { return this.lastPointGood; } /** * Sets a flag that indicates if the last point drawn (in the current * series) was 'good' (non-null). * * @param good the flag. */ public void setLastPointGood(boolean good) { this.lastPointGood = good; } /** * Returns the series index for the current path. * * @return The series index for the current path. */ public int getSeriesIndex() { return this.seriesIndex; } /** * Sets the series index for the current path. * * @param index the index. */ public void setSeriesIndex(int index) { this.seriesIndex = index; } } /** * Initialises the renderer. *

* This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { State state = new State(info); state.seriesPath = new GeneralPath(); state.seriesIndex = -1; return state; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { boolean itemVisible = getItemVisible(series, item); // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } PlotOrientation orientation = plot.getOrientation(); Paint paint = getItemPaint(series, item); Stroke seriesStroke = getItemStroke(series, item); g2.setPaint(paint); g2.setStroke(seriesStroke); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(x1) || Double.isNaN(y1)) { itemVisible = false; } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); if (getPlotLines()) { if (this.drawSeriesLineAsPath) { State s = (State) state; if (s.getSeriesIndex() != series) { // we are starting a new series path s.seriesPath.reset(); s.lastPointGood = false; s.setSeriesIndex(series); } // update path to reflect latest point if (itemVisible && !Double.isNaN(transX1) && !Double.isNaN(transY1)) { float x = (float) transX1; float y = (float) transY1; if (orientation == PlotOrientation.HORIZONTAL) { x = (float) transY1; y = (float) transX1; } if (s.isLastPointGood()) { // TODO: check threshold s.seriesPath.lineTo(x, y); } else { s.seriesPath.moveTo(x, y); } s.setLastPointGood(true); } else { s.setLastPointGood(false); } if (item == dataset.getItemCount(series) - 1) { if (s.seriesIndex == series) { // draw path g2.setStroke(lookupSeriesStroke(series)); g2.setPaint(lookupSeriesPaint(series)); g2.draw(s.seriesPath); } } } else if (item != 0 && itemVisible) { // get the previous data point... double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); if (!Double.isNaN(x0) && !Double.isNaN(y0)) { boolean drawLine = true; if (getPlotDiscontinuous()) { // only draw a line if the gap between the current and // previous data point is within the threshold int numX = dataset.getItemCount(series); double minX = dataset.getXValue(series, 0); double maxX = dataset.getXValue(series, numX - 1); if (this.gapThresholdType == UnitType.ABSOLUTE) { drawLine = Math.abs(x1 - x0) <= this.gapThreshold; } else { drawLine = Math.abs(x1 - x0) <= ((maxX - minX) / numX * getGapThreshold()); } } if (drawLine) { double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } if (state.workingLine.intersects(dataArea)) { g2.draw(state.workingLine); } } } } } // we needed to get this far even for invisible items, to ensure that // seriesPath updates happened, but now there is nothing more we need // to do for non-visible items... if (!itemVisible) { return; } if (getBaseShapesVisible()) { Shape shape = getItemShape(series, item); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } if (shape.intersects(dataArea)) { if (getItemShapeFilled(series, item)) { g2.fill(shape); } else { g2.draw(shape); } } entityArea = shape; } if (getPlotImages()) { Image image = getImage(plot, series, item, transX1, transY1); if (image != null) { Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image); g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null); entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(), image.getWidth(null), image.getHeight(null)); } } double xx = transX1; double yy = transY1; if (orientation == PlotOrientation.HORIZONTAL) { xx = transY1; yy = transX1; } // draw the item label if there is one... if (isItemLabelVisible(series, item)) { drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0)); } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); // add an entity for the item... if (entities != null && isPointInRect(dataArea, xx, yy)) { addEntity(entities, entityArea, dataset, series, item, xx, yy); } } /** * Tests this renderer for equality with another object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYItemRenderer)) { return false; } StandardXYItemRenderer that = (StandardXYItemRenderer) obj; if (this.baseShapesVisible != that.baseShapesVisible) { return false; } if (this.plotLines != that.plotLines) { return false; } if (this.plotImages != that.plotImages) { return false; } if (this.plotDiscontinuous != that.plotDiscontinuous) { return false; } if (this.gapThresholdType != that.gapThresholdType) { return false; } if (this.gapThreshold != that.gapThreshold) { return false; } if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) { return false; } if (!this.seriesShapesFilled.equals(that.seriesShapesFilled)) { return false; } if (this.baseShapesFilled != that.baseShapesFilled) { return false; } if (this.drawSeriesLineAsPath != that.drawSeriesLineAsPath) { return false; } if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { StandardXYItemRenderer clone = (StandardXYItemRenderer) super.clone(); clone.seriesShapesFilled = (BooleanList) this.seriesShapesFilled.clone(); clone.legendLine = ShapeUtilities.clone(this.legendLine); return clone; } //////////////////////////////////////////////////////////////////////////// // PROTECTED METHODS // These provide the opportunity to subclass the standard renderer and // create custom effects. //////////////////////////////////////////////////////////////////////////// /** * Returns the image used to draw a single data item. * * @param plot the plot (can be used to obtain standard color information * etc). * @param series the series index. * @param item the item index. * @param x the x value of the item. * @param y the y value of the item. * * @return The image. * * @see #getPlotImages() */ protected Image getImage(Plot plot, int series, int item, double x, double y) { // this method must be overridden if you want to display images return null; } /** * Returns the hotspot of the image used to draw a single data item. * The hotspot is the point relative to the top left of the image * that should indicate the data item. The default is the center of the * image. * * @param plot the plot (can be used to obtain standard color information * etc). * @param image the image (can be used to get size information about the * image) * @param series the series index * @param item the item index * @param x the x value of the item * @param y the y value of the item * * @return The hotspot used to draw the data item. */ protected Point getImageHotspot(Plot plot, int series, int item, double x, double y, Image image) { int height = image.getHeight(null); int width = image.getWidth(null); return new Point(width / 2, height / 2); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendLine = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendLine, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/VectorRenderer.java0000644000175000017500000003120011173030414030467 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * VectorRenderer.java * ------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Updated for method name changes (DG); * 25-May-2007 : Moved from experimental to the main source tree (DG); * 18-Feb-2008 : Fixed bug 1880114, arrows for horizontal plot * orientation (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * 26-Sep-2008 : Added chart entity support (tooltips etc) (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.xy.VectorXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A renderer that represents data from an {@link VectorXYDataset} by drawing a * line with an arrow at each (x, y) point. * The example shown here is generated by the VectorPlotDemo1.java * program included in the JFreeChart demo collection: *

* VectorRendererSample.png * * @since 1.0.6 */ public class VectorRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** The length of the base. */ private double baseLength = 0.10; /** The length of the head. */ private double headLength = 0.14; /** * Creates a new XYBlockRenderer instance with default * attributes. */ public VectorRenderer() { } /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findDomainBounds(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue; double uvalue; if (dataset instanceof VectorXYDataset) { VectorXYDataset vdataset = (VectorXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double delta = vdataset.getVectorXValue(series, item); if (delta < 0.0) { uvalue = vdataset.getXValue(series, item); lvalue = uvalue + delta; } else { lvalue = vdataset.getXValue(series, item); uvalue = lvalue + delta; } minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } else { for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getXValue(series, item); uvalue = lvalue; minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue; double uvalue; if (dataset instanceof VectorXYDataset) { VectorXYDataset vdataset = (VectorXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double delta = vdataset.getVectorYValue(series, item); if (delta < 0.0) { uvalue = vdataset.getYValue(series, item); lvalue = uvalue + delta; } else { lvalue = vdataset.getYValue(series, item); uvalue = lvalue + delta; } minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } else { for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getYValue(series, item); uvalue = lvalue; minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } } /** * Draws the block representing the specified item. * * @param g2 the graphics device. * @param state the state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the x-axis. * @param rangeAxis the y-axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double dx = 0.0; double dy = 0.0; if (dataset instanceof VectorXYDataset) { dx = ((VectorXYDataset) dataset).getVectorXValue(series, item); dy = ((VectorXYDataset) dataset).getVectorYValue(series, item); } double xx0 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); double xx1 = domainAxis.valueToJava2D(x + dx, dataArea, plot.getDomainAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y + dy, dataArea, plot.getRangeAxisEdge()); Line2D line; PlotOrientation orientation = plot.getOrientation(); if (orientation.equals(PlotOrientation.HORIZONTAL)) { line = new Line2D.Double(yy0, xx0, yy1, xx1); } else { line = new Line2D.Double(xx0, yy0, xx1, yy1); } g2.setPaint(getItemPaint(series, item)); g2.setStroke(getItemStroke(series, item)); g2.draw(line); // calculate the arrow head and draw it... double dxx = (xx1 - xx0); double dyy = (yy1 - yy0); double bx = xx0 + (1.0 - this.baseLength) * dxx; double by = yy0 + (1.0 - this.baseLength) * dyy; double cx = xx0 + (1.0 - this.headLength) * dxx; double cy = yy0 + (1.0 - this.headLength) * dyy; double angle = 0.0; if (dxx != 0.0) { angle = Math.PI / 2.0 - Math.atan(dyy / dxx); } double deltaX = 2.0 * Math.cos(angle); double deltaY = 2.0 * Math.sin(angle); double leftx = cx + deltaX; double lefty = cy - deltaY; double rightx = cx - deltaX; double righty = cy + deltaY; GeneralPath p = new GeneralPath(); if (orientation == PlotOrientation.VERTICAL) { p.moveTo((float) xx1, (float) yy1); p.lineTo((float) rightx, (float) righty); p.lineTo((float) bx, (float) by); p.lineTo((float) leftx, (float) lefty); } else { // orientation is HORIZONTAL p.moveTo((float) yy1, (float) xx1); p.lineTo((float) righty, (float) rightx); p.lineTo((float) by, (float) bx); p.lineTo((float) lefty, (float) leftx); } p.closePath(); g2.draw(p); // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); if (entities != null) { addEntity(entities, line.getBounds(), dataset, series, item, 0.0, 0.0); } } } /** * Tests this VectorRenderer for equality with an arbitrary * object. This method returns true if and only if: *

    *
  • obj is an instance of VectorRenderer (not * null);
  • *
  • obj has the same field values as this * VectorRenderer;
  • *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof VectorRenderer)) { return false; } VectorRenderer that = (VectorRenderer) obj; if (this.baseLength != that.baseLength) { return false; } if (this.headLength != that.headLength) { return false; } return super.equals(obj); } /** * Returns a clone of this renderer. * * @return A clone of this renderer. * * @throws CloneNotSupportedException if there is a problem creating the * clone. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/WindItemRenderer.java0000644000175000017500000002027211173030414030754 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * WindItemRenderer.java * --------------------- * (C) Copyright 2001-2008, by Achilleus Mantzios and Contributors. * * Original Author: Achilleus Mantzios; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 06-Feb-2002 : Version 1, based on code contributed by Achilleus * Mantzios (DG); * 28-Mar-2002 : Added a property change listener mechanism so that renderers * no longer need to be immutable. Changed StrictMath --> Math * to retain JDK1.2 compatibility (DG); * 09-Apr-2002 : Changed return type of the drawItem method to void, reflecting * the change in the XYItemRenderer method (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 21-Jan-2003 : Added new constructor (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.WindDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A specialised renderer for displaying wind intensity/direction data. * The example shown here is generated by the WindChartDemo1.java * program included in the JFreeChart demo collection: *

* WindItemRendererSample.png */ public class WindItemRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8078914101916976844L; /** * Creates a new renderer. */ public WindItemRenderer() { super(); } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param plotArea the area within which the plot is being drawn. * @param info optional information collection. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the horizontal axis. * @param rangeAxis the vertical axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D plotArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { WindDataset windData = (WindDataset) dataset; Paint seriesPaint = getItemPaint(series, item); Stroke seriesStroke = getItemStroke(series, item); g2.setPaint(seriesPaint); g2.setStroke(seriesStroke); // get the data point... Number x = windData.getX(series, item); Number windDir = windData.getWindDirection(series, item); Number wforce = windData.getWindForce(series, item); double windForce = wforce.doubleValue(); double wdirt = Math.toRadians(windDir.doubleValue() * (-30.0) - 90.0); double ax1, ax2, ay1, ay2, rax2, ray2; RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); ax1 = domainAxis.valueToJava2D(x.doubleValue(), plotArea, domainAxisLocation); ay1 = rangeAxis.valueToJava2D(0.0, plotArea, rangeAxisLocation); rax2 = x.doubleValue() + (windForce * Math.cos(wdirt) * 8000000.0); ray2 = windForce * Math.sin(wdirt); ax2 = domainAxis.valueToJava2D(rax2, plotArea, domainAxisLocation); ay2 = rangeAxis.valueToJava2D(ray2, plotArea, rangeAxisLocation); int diri = windDir.intValue(); int forcei = wforce.intValue(); String dirforce = diri + "-" + forcei; Line2D line = new Line2D.Double(ax1, ay1, ax2, ay2); g2.draw(line); g2.setPaint(Color.blue); g2.setFont(new Font("Dialog", 1, 9)); g2.drawString(dirforce, (float) ax1, (float) ay1); g2.setPaint(seriesPaint); g2.setStroke(seriesStroke); double alx2, aly2, arx2, ary2; double ralx2, raly2, rarx2, rary2; double aldir = Math.toRadians(windDir.doubleValue() * (-30.0) - 90.0 - 5.0); ralx2 = wforce.doubleValue() * Math.cos(aldir) * 8000000 * 0.8 + x.doubleValue(); raly2 = wforce.doubleValue() * Math.sin(aldir) * 0.8; alx2 = domainAxis.valueToJava2D(ralx2, plotArea, domainAxisLocation); aly2 = rangeAxis.valueToJava2D(raly2, plotArea, rangeAxisLocation); line = new Line2D.Double(alx2, aly2, ax2, ay2); g2.draw(line); double ardir = Math.toRadians(windDir.doubleValue() * (-30.0) - 90.0 + 5.0); rarx2 = wforce.doubleValue() * Math.cos(ardir) * 8000000 * 0.8 + x.doubleValue(); rary2 = wforce.doubleValue() * Math.sin(ardir) * 0.8; arx2 = domainAxis.valueToJava2D(rarx2, plotArea, domainAxisLocation); ary2 = rangeAxis.valueToJava2D(rary2, plotArea, rangeAxisLocation); line = new Line2D.Double(arx2, ary2, ax2, ay2); g2.draw(line); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYAreaRenderer.java0000644000175000017500000006253711173030414030377 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * XYAreaRenderer.java * ------------------- * (C) Copyright 2002-2008, by Hari and Contributors. * * Original Author: Hari (ourhari@hotmail.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * Richard Atkinson; * Christian W. Zuckschwerdt; * * Changes: * -------- * 03-Apr-2002 : Version 1, contributed by Hari. This class is based on the * StandardXYItemRenderer class (DG); * 09-Apr-2002 : Removed the translated zero from the drawItem method - * overridden the initialise() method to calculate it (DG); * 30-May-2002 : Added tool tip generator to constructor to match super * class (DG); * 25-Jun-2002 : Removed unnecessary local variable (DG); * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML * image maps (RA); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 07-Nov-2002 : Renamed AreaXYItemRenderer --> XYAreaRenderer (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 27-Jul-2003 : Made line and polygon properties protected rather than * private (RA); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 08-Dec-2003 : Modified hotspot for chart entity (DG); * 10-Feb-2004 : Changed the drawItem() method to make cut-and-paste overriding * easier. Also moved state class into this class (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 19-Jan-2005 : Now accesses primitives only from dataset (DG); * 21-Mar-2005 : Override getLegendItem() and equals() methods (DG); * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 14-Feb-2007 : Fixed bug in clone() (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 17-Jun-2008 : Apply legend font and paint attributes (DG); * 31-Dec-2008 : Fix for bug 2471906 - dashed outlines performance issue (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.BasicStroke; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYSeriesLabelGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * Area item renderer for an {@link XYPlot}. This class can draw (a) shapes at * each point, or (b) lines between points, or (c) both shapes and lines, * or (d) filled areas, or (e) filled areas and shapes. The example shown here * is generated by the XYAreaRendererDemo1.java program included * in the JFreeChart demo collection: *

* XYAreaRendererSample.png */ public class XYAreaRenderer extends AbstractXYItemRenderer implements XYItemRenderer, PublicCloneable { /** For serialization. */ private static final long serialVersionUID = -4481971353973876747L; /** * A state object used by this renderer. */ static class XYAreaRendererState extends XYItemRendererState { /** Working storage for the area under one series. */ public Polygon area; /** Working line that can be recycled. */ public Line2D line; /** * Creates a new state. * * @param info the plot rendering info. */ public XYAreaRendererState(PlotRenderingInfo info) { super(info); this.area = new Polygon(); this.line = new Line2D.Double(); } } /** Useful constant for specifying the type of rendering (shapes only). */ public static final int SHAPES = 1; /** Useful constant for specifying the type of rendering (lines only). */ public static final int LINES = 2; /** * Useful constant for specifying the type of rendering (shapes and lines). */ public static final int SHAPES_AND_LINES = 3; /** Useful constant for specifying the type of rendering (area only). */ public static final int AREA = 4; /** * Useful constant for specifying the type of rendering (area and shapes). */ public static final int AREA_AND_SHAPES = 5; /** A flag indicating whether or not shapes are drawn at each XY point. */ private boolean plotShapes; /** A flag indicating whether or not lines are drawn between XY points. */ private boolean plotLines; /** A flag indicating whether or not Area are drawn at each XY point. */ private boolean plotArea; /** A flag that controls whether or not the outline is shown. */ private boolean showOutline; /** * The shape used to represent an area in each legend item (this should * never be null). */ private transient Shape legendArea; /** * Constructs a new renderer. */ public XYAreaRenderer() { this(AREA); } /** * Constructs a new renderer. * * @param type the type of the renderer. */ public XYAreaRenderer(int type) { this(type, null, null); } /** * Constructs a new renderer. To specify the type of renderer, use one of * the constants: SHAPES, LINES, * SHAPES_AND_LINES, AREA or * AREA_AND_SHAPES. * * @param type the type of renderer. * @param toolTipGenerator the tool tip generator to use * (null permitted). * @param urlGenerator the URL generator (null permitted). */ public XYAreaRenderer(int type, XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); setURLGenerator(urlGenerator); if (type == SHAPES) { this.plotShapes = true; } if (type == LINES) { this.plotLines = true; } if (type == SHAPES_AND_LINES) { this.plotShapes = true; this.plotLines = true; } if (type == AREA) { this.plotArea = true; } if (type == AREA_AND_SHAPES) { this.plotArea = true; this.plotShapes = true; } this.showOutline = false; GeneralPath area = new GeneralPath(); area.moveTo(0.0f, -4.0f); area.lineTo(3.0f, -2.0f); area.lineTo(4.0f, 4.0f); area.lineTo(-4.0f, 4.0f); area.lineTo(-3.0f, -2.0f); area.closePath(); this.legendArea = area; } /** * Returns true if shapes are being plotted by the renderer. * * @return true if shapes are being plotted by the renderer. */ public boolean getPlotShapes() { return this.plotShapes; } /** * Returns true if lines are being plotted by the renderer. * * @return true if lines are being plotted by the renderer. */ public boolean getPlotLines() { return this.plotLines; } /** * Returns true if Area is being plotted by the renderer. * * @return true if Area is being plotted by the renderer. */ public boolean getPlotArea() { return this.plotArea; } /** * Returns a flag that controls whether or not outlines of the areas are * drawn. * * @return The flag. * * @see #setOutline(boolean) */ public boolean isOutline() { return this.showOutline; } /** * Sets a flag that controls whether or not outlines of the areas are drawn * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param show the flag. * * @see #isOutline() */ public void setOutline(boolean show) { this.showOutline = show; fireChangeEvent(); } /** * Returns the shape used to represent an area in the legend. * * @return The legend area (never null). */ public Shape getLegendArea() { return this.legendArea; } /** * Sets the shape used as an area in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param area the area (null not permitted). */ public void setLegendArea(Shape area) { if (area == null) { throw new IllegalArgumentException("Null 'area' argument."); } this.legendArea = area; fireChangeEvent(); } /** * Initialises the renderer and returns a state object that should be * passed to all subsequent calls to the drawItem() method. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return A state object for use by the renderer. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { XYAreaRendererState state = new XYAreaRendererState(info); // in the rendering process, there is special handling for item // zero, so we can't support processing of visible data items only state.setProcessVisibleItemsOnly(false); return state; } /** * Returns a default legend item for the specified series. Subclasses * should override this method to generate customised items. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot xyplot = getPlot(); if (xyplot != null) { XYDataset dataset = xyplot.getDataset(datasetIndex); if (dataset != null) { XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); String label = lg.generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Paint paint = lookupSeriesPaint(series); result = new LegendItem(label, description, toolTipText, urlText, this.legendArea, paint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } return result; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!getItemVisible(series, item)) { return; } XYAreaRendererState areaState = (XYAreaRendererState) state; // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1)) { y1 = 0.0; } double transX1 = domainAxis.valueToJava2D(x1, dataArea, plot.getDomainAxisEdge()); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge()); // get the previous point and the next point so we can calculate a // "hot spot" for the area (used by the chart entity)... int itemCount = dataset.getItemCount(series); double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); if (Double.isNaN(y0)) { y0 = 0.0; } double transX0 = domainAxis.valueToJava2D(x0, dataArea, plot.getDomainAxisEdge()); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, plot.getRangeAxisEdge()); double x2 = dataset.getXValue(series, Math.min(item + 1, itemCount - 1)); double y2 = dataset.getYValue(series, Math.min(item + 1, itemCount - 1)); if (Double.isNaN(y2)) { y2 = 0.0; } double transX2 = domainAxis.valueToJava2D(x2, dataArea, plot.getDomainAxisEdge()); double transY2 = rangeAxis.valueToJava2D(y2, dataArea, plot.getRangeAxisEdge()); double transZero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge()); Polygon hotspot = null; if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { hotspot = new Polygon(); hotspot.addPoint((int) transZero, (int) ((transX0 + transX1) / 2.0)); hotspot.addPoint((int) ((transY0 + transY1) / 2.0), (int) ((transX0 + transX1) / 2.0)); hotspot.addPoint((int) transY1, (int) transX1); hotspot.addPoint((int) ((transY1 + transY2) / 2.0), (int) ((transX1 + transX2) / 2.0)); hotspot.addPoint((int) transZero, (int) ((transX1 + transX2) / 2.0)); } else { // vertical orientation hotspot = new Polygon(); hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) transZero); hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) ((transY0 + transY1) / 2.0)); hotspot.addPoint((int) transX1, (int) transY1); hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) ((transY1 + transY2) / 2.0)); hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) transZero); } if (item == 0) { // create a new area polygon for the series areaState.area = new Polygon(); // the first point is (x, 0) double zero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge()); if (plot.getOrientation() == PlotOrientation.VERTICAL) { areaState.area.addPoint((int) transX1, (int) zero); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { areaState.area.addPoint((int) zero, (int) transX1); } } // Add each point to Area (x, y) if (plot.getOrientation() == PlotOrientation.VERTICAL) { areaState.area.addPoint((int) transX1, (int) transY1); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { areaState.area.addPoint((int) transY1, (int) transX1); } PlotOrientation orientation = plot.getOrientation(); Paint paint = getItemPaint(series, item); Stroke stroke = getItemStroke(series, item); g2.setPaint(paint); g2.setStroke(stroke); Shape shape = null; if (getPlotShapes()) { shape = getItemShape(series, item); if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } else if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } g2.draw(shape); } if (getPlotLines()) { if (item > 0) { if (plot.getOrientation() == PlotOrientation.VERTICAL) { areaState.line.setLine(transX0, transY0, transX1, transY1); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { areaState.line.setLine(transY0, transX0, transY1, transX1); } g2.draw(areaState.line); } } // Check if the item is the last item for the series. // and number of items > 0. We can't draw an area for a single point. if (getPlotArea() && item > 0 && item == (itemCount - 1)) { if (orientation == PlotOrientation.VERTICAL) { // Add the last point (x,0) areaState.area.addPoint((int) transX1, (int) transZero); } else if (orientation == PlotOrientation.HORIZONTAL) { // Add the last point (x,0) areaState.area.addPoint((int) transZero, (int) transX1); } g2.fill(areaState.area); // draw an outline around the Area. if (isOutline()) { Shape area = areaState.area; // Java2D has some issues drawing dashed lines around "large" // geometrical shapes - for example, see bug 6620013 in the // Java bug database. So, we'll check if the outline is // dashed and, if it is, do our own clipping before drawing // the outline... Stroke outlineStroke = lookupSeriesOutlineStroke(series); if (outlineStroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke) outlineStroke; if (bs.getDashArray() != null) { Area poly = new Area(areaState.area); // we make the clip region slightly larger than the // dataArea so that the clipped edges don't show lines // on the chart Area clip = new Area(new Rectangle2D.Double( dataArea.getX() - 5.0, dataArea.getY() - 5.0, dataArea.getWidth() + 10.0, dataArea.getHeight() + 10.0)); poly.intersect(clip); area = poly; } } // end of workaround g2.setStroke(outlineStroke); g2.setPaint(lookupSeriesOutlinePaint(series)); g2.draw(area); } } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null && hotspot != null) { addEntity(entities, hotspot, dataset, series, item, 0.0, 0.0); } } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { XYAreaRenderer clone = (XYAreaRenderer) super.clone(); clone.legendArea = ShapeUtilities.clone(this.legendArea); return clone; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYAreaRenderer)) { return false; } XYAreaRenderer that = (XYAreaRenderer) obj; if (this.plotArea != that.plotArea) { return false; } if (this.plotLines != that.plotLines) { return false; } if (this.plotShapes != that.plotShapes) { return false; } if (this.showOutline != that.showOutline) { return false; } if (!ShapeUtilities.equal(this.legendArea, that.legendArea)) { return false; } return true; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendArea = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendArea, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java0000644000175000017500000004425611173030414030457 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYAreaRenderer2.java * -------------------- * (C) Copyright 2004-2008, by Hari and Contributors. * * Original Author: Hari (ourhari@hotmail.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * Richard Atkinson; * Christian W. Zuckschwerdt; * * Changes: * -------- * 03-Apr-2002 : Version 1, contributed by Hari. This class is based on the * StandardXYItemRenderer class (DG); * 09-Apr-2002 : Removed the translated zero from the drawItem method - * overridden the initialise() method to calculate it (DG); * 30-May-2002 : Added tool tip generator to constructor to match super * class (DG); * 25-Jun-2002 : Removed unnecessary local variable (DG); * 05-Aug-2002 : Small modification to drawItem method to support URLs for * HTML image maps (RA); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 07-Nov-2002 : Renamed AreaXYItemRenderer --> XYAreaRenderer (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 27-Jul-2003 : Made line and polygon properties protected rather than * private (RA); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 08-Dec-2003 : Modified hotspot for chart entity (DG); * 10-Feb-2004 : Changed the drawItem() method to make cut-and-paste * overriding easier. Also moved state class into this * class (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 19-Jan-2005 : Now accesses only primitives from the dataset (DG); * 21-Mar-2005 : Override getLegendItem() (DG); * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 30-Nov-2006 : Fixed equals() and clone() implementations (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 20-Apr-2007 : Updated getLegendItem() and drawItem() for renderer * change (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 17-Jun-2008 : Apply legend font and paint attributes (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.XYItemEntity; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYSeriesLabelGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * Area item renderer for an {@link XYPlot}. The example shown here is * generated by the XYAreaRenderer2Demo1.java program included in * the JFreeChart demo collection: *

* XYAreaRenderer2Sample.png */ public class XYAreaRenderer2 extends AbstractXYItemRenderer implements XYItemRenderer, PublicCloneable { /** For serialization. */ private static final long serialVersionUID = -7378069681579984133L; /** A flag that controls whether or not the outline is shown. */ private boolean showOutline; /** * The shape used to represent an area in each legend item (this should * never be null). */ private transient Shape legendArea; /** * Constructs a new renderer. */ public XYAreaRenderer2() { this(null, null); } /** * Constructs a new renderer. * * @param labelGenerator the tool tip generator to use. null * is none. * @param urlGenerator the URL generator (null permitted). */ public XYAreaRenderer2(XYToolTipGenerator labelGenerator, XYURLGenerator urlGenerator) { super(); this.showOutline = false; setBaseToolTipGenerator(labelGenerator); setURLGenerator(urlGenerator); GeneralPath area = new GeneralPath(); area.moveTo(0.0f, -4.0f); area.lineTo(3.0f, -2.0f); area.lineTo(4.0f, 4.0f); area.lineTo(-4.0f, 4.0f); area.lineTo(-3.0f, -2.0f); area.closePath(); this.legendArea = area; } /** * Returns a flag that controls whether or not outlines of the areas are * drawn. * * @return The flag. * * @see #setOutline(boolean) */ public boolean isOutline() { return this.showOutline; } /** * Sets a flag that controls whether or not outlines of the areas are * drawn, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param show the flag. * * @see #isOutline() */ public void setOutline(boolean show) { this.showOutline = show; fireChangeEvent(); } /** * This method should not be used. * * @return false always. * * @deprecated This method was included in the API by mistake and serves * no useful purpose. It has always returned false. * */ public boolean getPlotLines() { return false; } /** * Returns the shape used to represent an area in the legend. * * @return The legend area (never null). * * @see #setLegendArea(Shape) */ public Shape getLegendArea() { return this.legendArea; } /** * Sets the shape used as an area in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param area the area (null not permitted). * * @see #getLegendArea() */ public void setLegendArea(Shape area) { if (area == null) { throw new IllegalArgumentException("Null 'area' argument."); } this.legendArea = area; fireChangeEvent(); } /** * Returns a default legend item for the specified series. Subclasses * should override this method to generate customised items. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot xyplot = getPlot(); if (xyplot != null) { XYDataset dataset = xyplot.getDataset(datasetIndex); if (dataset != null) { XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); String label = lg.generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Paint paint = lookupSeriesPaint(series); result = new LegendItem(label, description, toolTipText, urlText, this.legendArea, paint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } return result; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!getItemVisible(series, item)) { return; } // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1)) { y1 = 0.0; } double transX1 = domainAxis.valueToJava2D(x1, dataArea, plot.getDomainAxisEdge()); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge()); // get the previous point and the next point so we can calculate a // "hot spot" for the area (used by the chart entity)... double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); if (Double.isNaN(y0)) { y0 = 0.0; } double transX0 = domainAxis.valueToJava2D(x0, dataArea, plot.getDomainAxisEdge()); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, plot.getRangeAxisEdge()); int itemCount = dataset.getItemCount(series); double x2 = dataset.getXValue(series, Math.min(item + 1, itemCount - 1)); double y2 = dataset.getYValue(series, Math.min(item + 1, itemCount - 1)); if (Double.isNaN(y2)) { y2 = 0.0; } double transX2 = domainAxis.valueToJava2D(x2, dataArea, plot.getDomainAxisEdge()); double transY2 = rangeAxis.valueToJava2D(y2, dataArea, plot.getRangeAxisEdge()); double transZero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge()); Polygon hotspot = null; if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { hotspot = new Polygon(); hotspot.addPoint((int) transZero, (int) ((transX0 + transX1) / 2.0)); hotspot.addPoint((int) ((transY0 + transY1) / 2.0), (int) ((transX0 + transX1) / 2.0)); hotspot.addPoint((int) transY1, (int) transX1); hotspot.addPoint((int) ((transY1 + transY2) / 2.0), (int) ((transX1 + transX2) / 2.0)); hotspot.addPoint((int) transZero, (int) ((transX1 + transX2) / 2.0)); } else { // vertical orientation hotspot = new Polygon(); hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) transZero); hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) ((transY0 + transY1) / 2.0)); hotspot.addPoint((int) transX1, (int) transY1); hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) ((transY1 + transY2) / 2.0)); hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) transZero); } PlotOrientation orientation = plot.getOrientation(); Paint paint = getItemPaint(series, item); Stroke stroke = getItemStroke(series, item); g2.setPaint(paint); g2.setStroke(stroke); // Check if the item is the last item for the series. // and number of items > 0. We can't draw an area for a single point. g2.fill(hotspot); // draw an outline around the Area. if (isOutline()) { g2.setStroke(lookupSeriesOutlineStroke(series)); g2.setPaint(lookupSeriesOutlinePaint(series)); g2.draw(hotspot); } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getEntityCollection(); if (entities != null && hotspot != null) { String tip = null; XYToolTipGenerator generator = getToolTipGenerator(series, item); if (generator != null) { tip = generator.generateToolTip(dataset, series, item); } String url = null; if (getURLGenerator() != null) { url = getURLGenerator().generateURL(dataset, series, item); } XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item, tip, url); entities.add(entity); } } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null not permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYAreaRenderer2)) { return false; } XYAreaRenderer2 that = (XYAreaRenderer2) obj; if (this.showOutline != that.showOutline) { return false; } if (!ShapeUtilities.equal(this.legendArea, that.legendArea)) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { XYAreaRenderer2 clone = (XYAreaRenderer2) super.clone(); clone.legendArea = ShapeUtilities.clone(this.legendArea); return clone; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendArea = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendArea, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYBarPainter.java0000644000175000017500000000651011173030414030054 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * XYBarPainter.java * ----------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.RectangularShape; import org.jfree.ui.RectangleEdge; /** * The interface for plugin painter for the {@link XYBarRenderer} class. When * developing a class that implements this interface, bear in mind the * following: *
    *
  • the equals(Object) method should be overridden;
  • *
  • instances of the class should be immutable OR implement the * PublicCloneable interface, so that a renderer using the * painter can be cloned reliably; *
  • the class should be Serializable, otherwise chart * serialization will not be supported.
  • *
* * @since 1.0.11 */ public interface XYBarPainter { /** * Paints a single bar on behalf of a renderer. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index for the item. * @param column the column index for the item. * @param bar the bounds for the bar. * @param base the base of the bar. */ public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base); /** * Paints the shadow for a single bar on behalf of a renderer. * * @param g2 the graphics target. * @param renderer the renderer. * @param row the row index for the item. * @param column the column index for the item. * @param bar the bounds for the bar. * @param base the base of the bar. * @param pegShadow peg the shadow to the base of the bar? */ public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base, boolean pegShadow); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYBarRenderer.java0000644000175000017500000013113511173030414030222 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * XYBarRenderer.java * ------------------ * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * Christian W. Zuckschwerdt; * Bill Kelemen; * Marc van Glabbeek (bug 1775452); * Richard West, Advanced Micro Devices, Inc.; * * Changes * ------- * 13-Dec-2001 : Version 1, makes VerticalXYBarPlot class redundant (DG); * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); * 09-Apr-2002 : Removed the translated zero from the drawItem method. Override * the initialise() method to calculate it (DG); * 24-May-2002 : Incorporated tooltips into chart entities (DG); * 25-Jun-2002 : Removed redundant import (DG); * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML * image maps (RA); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 24-Aug-2003 : Added null checks in drawItem (BK); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Added renderer state (DG); * 05-Dec-2003 : Changed call to obtain outline paint (DG); * 10-Feb-2004 : Added state class, updated drawItem() method to make * cut-and-paste overriding easier, and replaced property change * with RendererChangeEvent (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 26-Apr-2004 : Added gradient paint transformer (DG); * 19-May-2004 : Fixed bug (879709) with bar zero value for secondary axis (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 01-Sep-2004 : Added a flag to control whether or not the bar outlines are * drawn (DG); * 03-Sep-2004 : Added option to use y-interval from dataset to determine the * length of the bars (DG); * 08-Sep-2004 : Added equals() method and updated clone() method (DG); * 26-Jan-2005 : Added override for getLegendItem() method (DG); * 20-Apr-2005 : Use generators for label tooltips and URLs (DG); * 19-May-2005 : Added minimal item label implementation - needs improving (DG); * 14-Oct-2005 : Fixed rendering problem with inverted axes (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 21-Jun-2006 : Improved item label handling - see bug 1501768 (DG); * 24-Aug-2006 : Added crosshair support (DG); * 13-Dec-2006 : Updated getLegendItems() to return gradient paint * transformer (DG); * 02-Feb-2007 : Changed setUseYInterval() to only notify when the flag * changes (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 09-Feb-2007 : Updated getLegendItem() to observe drawBarOutline flag (DG); * 05-Mar-2007 : Applied patch 1671126 by Sergei Ivanov, to fix rendering with * LogarithmicAxis (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 15-Jun-2007 : Changed default for drawBarOutline to false (DG); * 26-Sep-2007 : Fixed bug 1775452, problem with bar margins for inverted * axes, thanks to Marc van Glabbeek (DG); * 12-Nov-2007 : Fixed NPE in drawItemLabel() method, thanks to Richard West * (see patch 1827829) (DG); * 17-Jun-2008 : Apply legend font and paint attributes (DG); * 19-Jun-2008 : Added findRangeBounds() method override to fix bug in default * axis range (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); * 03-Feb-2009 : Added defaultShadowsVisible flag (DG); * 05-Feb-2009 : Added barAlignmentFactor (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.labels.XYSeriesLabelGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that draws bars on an {@link XYPlot} (requires an * {@link IntervalXYDataset}). The example shown here is generated by the * XYBarChartDemo1.java program included in the JFreeChart * demo collection: *

* XYBarRendererSample.png */ public class XYBarRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 770559577251370036L; /** * The default bar painter assigned to each new instance of this renderer. * * @since 1.0.11 */ private static XYBarPainter defaultBarPainter = new GradientXYBarPainter(); /** * Returns the default bar painter. * * @return The default bar painter. * * @since 1.0.11 */ public static XYBarPainter getDefaultBarPainter() { return XYBarRenderer.defaultBarPainter; } /** * Sets the default bar painter. * * @param painter the painter (null not permitted). * * @since 1.0.11 */ public static void setDefaultBarPainter(XYBarPainter painter) { if (painter == null) { throw new IllegalArgumentException("Null 'painter' argument."); } XYBarRenderer.defaultBarPainter = painter; } /** * The default value for the initialisation of the shadowsVisible flag. */ private static boolean defaultShadowsVisible = true; /** * Returns the default value for the shadowsVisible flag. * * @return A boolean. * * @see #setDefaultShadowsVisible(boolean) * * @since 1.0.13 */ public static boolean getDefaultShadowsVisible() { return XYBarRenderer.defaultShadowsVisible; } /** * Sets the default value for the shadows visible flag. * * @param visible the new value for the default. * * @see #getDefaultShadowsVisible() * * @since 1.0.13 */ public static void setDefaultShadowsVisible(boolean visible) { XYBarRenderer.defaultShadowsVisible = visible; } /** * The state class used by this renderer. */ protected class XYBarRendererState extends XYItemRendererState { /** Base for bars against the range axis, in Java 2D space. */ private double g2Base; /** * Creates a new state object. * * @param info the plot rendering info. */ public XYBarRendererState(PlotRenderingInfo info) { super(info); } /** * Returns the base (range) value in Java 2D space. * * @return The base value. */ public double getG2Base() { return this.g2Base; } /** * Sets the range axis base in Java2D space. * * @param value the value. */ public void setG2Base(double value) { this.g2Base = value; } } /** The default base value for the bars. */ private double base; /** * A flag that controls whether the bars use the y-interval supplied by the * dataset. */ private boolean useYInterval; /** Percentage margin (to reduce the width of bars). */ private double margin; /** A flag that controls whether or not bar outlines are drawn. */ private boolean drawBarOutline; /** * An optional class used to transform gradient paint objects to fit each * bar. */ private GradientPaintTransformer gradientPaintTransformer; /** * The shape used to represent a bar in each legend item (this should never * be null). */ private transient Shape legendBar; /** * The fallback position if a positive item label doesn't fit inside the * bar. */ private ItemLabelPosition positiveItemLabelPositionFallback; /** * The fallback position if a negative item label doesn't fit inside the * bar. */ private ItemLabelPosition negativeItemLabelPositionFallback; /** * The bar painter (never null). * * @since 1.0.11 */ private XYBarPainter barPainter; /** * The flag that controls whether or not shadows are drawn for the bars. * * @since 1.0.11 */ private boolean shadowsVisible; /** * The x-offset for the shadow effect. * * @since 1.0.11 */ private double shadowXOffset; /** * The y-offset for the shadow effect. * * @since 1.0.11 */ private double shadowYOffset; /** * A factor used to align the bars about the x-value. * * @since 1.0.13 */ private double barAlignmentFactor; /** * The default constructor. */ public XYBarRenderer() { this(0.0); } /** * Constructs a new renderer. * * @param margin the percentage amount to trim from the width of each bar. */ public XYBarRenderer(double margin) { super(); this.margin = margin; this.base = 0.0; this.useYInterval = false; this.gradientPaintTransformer = new StandardGradientPaintTransformer(); this.drawBarOutline = false; this.legendBar = new Rectangle2D.Double(-3.0, -5.0, 6.0, 10.0); this.barPainter = getDefaultBarPainter(); this.shadowsVisible = getDefaultShadowsVisible(); this.shadowXOffset = 4.0; this.shadowYOffset = 4.0; this.barAlignmentFactor = -1.0; } /** * Returns the base value for the bars. * * @return The base value for the bars. * * @see #setBase(double) */ public double getBase() { return this.base; } /** * Sets the base value for the bars and sends a {@link RendererChangeEvent} * to all registered listeners. The base value is not used if the dataset's * y-interval is being used to determine the bar length. * * @param base the new base value. * * @see #getBase() * @see #getUseYInterval() */ public void setBase(double base) { this.base = base; fireChangeEvent(); } /** * Returns a flag that determines whether the y-interval from the dataset is * used to calculate the length of each bar. * * @return A boolean. * * @see #setUseYInterval(boolean) */ public boolean getUseYInterval() { return this.useYInterval; } /** * Sets the flag that determines whether the y-interval from the dataset is * used to calculate the length of each bar, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param use the flag. * * @see #getUseYInterval() */ public void setUseYInterval(boolean use) { if (this.useYInterval != use) { this.useYInterval = use; fireChangeEvent(); } } /** * Returns the margin which is a percentage amount by which the bars are * trimmed. * * @return The margin. * * @see #setMargin(double) */ public double getMargin() { return this.margin; } /** * Sets the percentage amount by which the bars are trimmed and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param margin the new margin. * * @see #getMargin() */ public void setMargin(double margin) { this.margin = margin; fireChangeEvent(); } /** * Returns a flag that controls whether or not bar outlines are drawn. * * @return A boolean. * * @see #setDrawBarOutline(boolean) */ public boolean isDrawBarOutline() { return this.drawBarOutline; } /** * Sets the flag that controls whether or not bar outlines are drawn and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param draw the flag. * * @see #isDrawBarOutline() */ public void setDrawBarOutline(boolean draw) { this.drawBarOutline = draw; fireChangeEvent(); } /** * Returns the gradient paint transformer (an object used to transform * gradient paint objects to fit each bar). * * @return A transformer (null possible). * * @see #setGradientPaintTransformer(GradientPaintTransformer) */ public GradientPaintTransformer getGradientPaintTransformer() { return this.gradientPaintTransformer; } /** * Sets the gradient paint transformer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param transformer the transformer (null permitted). * * @see #getGradientPaintTransformer() */ public void setGradientPaintTransformer( GradientPaintTransformer transformer) { this.gradientPaintTransformer = transformer; fireChangeEvent(); } /** * Returns the shape used to represent bars in each legend item. * * @return The shape used to represent bars in each legend item (never * null). * * @see #setLegendBar(Shape) */ public Shape getLegendBar() { return this.legendBar; } /** * Sets the shape used to represent bars in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param bar the bar shape (null not permitted). * * @see #getLegendBar() */ public void setLegendBar(Shape bar) { if (bar == null) { throw new IllegalArgumentException("Null 'bar' argument."); } this.legendBar = bar; fireChangeEvent(); } /** * Returns the fallback position for positive item labels that don't fit * within a bar. * * @return The fallback position (null possible). * * @see #setPositiveItemLabelPositionFallback(ItemLabelPosition) * @since 1.0.2 */ public ItemLabelPosition getPositiveItemLabelPositionFallback() { return this.positiveItemLabelPositionFallback; } /** * Sets the fallback position for positive item labels that don't fit * within a bar, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * * @see #getPositiveItemLabelPositionFallback() * @since 1.0.2 */ public void setPositiveItemLabelPositionFallback( ItemLabelPosition position) { this.positiveItemLabelPositionFallback = position; fireChangeEvent(); } /** * Returns the fallback position for negative item labels that don't fit * within a bar. * * @return The fallback position (null possible). * * @see #setNegativeItemLabelPositionFallback(ItemLabelPosition) * @since 1.0.2 */ public ItemLabelPosition getNegativeItemLabelPositionFallback() { return this.negativeItemLabelPositionFallback; } /** * Sets the fallback position for negative item labels that don't fit * within a bar, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * * @see #getNegativeItemLabelPositionFallback() * @since 1.0.2 */ public void setNegativeItemLabelPositionFallback( ItemLabelPosition position) { this.negativeItemLabelPositionFallback = position; fireChangeEvent(); } /** * Returns the bar painter. * * @return The bar painter (never null). * * @since 1.0.11 */ public XYBarPainter getBarPainter() { return this.barPainter; } /** * Sets the bar painter and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param painter the painter (null not permitted). * * @since 1.0.11 */ public void setBarPainter(XYBarPainter painter) { if (painter == null) { throw new IllegalArgumentException("Null 'painter' argument."); } this.barPainter = painter; fireChangeEvent(); } /** * Returns the flag that controls whether or not shadows are drawn for * the bars. * * @return A boolean. * * @since 1.0.11 */ public boolean getShadowsVisible() { return this.shadowsVisible; } /** * Sets the flag that controls whether or not the renderer * draws shadows for the bars, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the new flag value. * * @since 1.0.11 */ public void setShadowVisible(boolean visible) { this.shadowsVisible = visible; fireChangeEvent(); } /** * Returns the shadow x-offset. * * @return The shadow x-offset. * * @since 1.0.11 */ public double getShadowXOffset() { return this.shadowXOffset; } /** * Sets the x-offset for the bar shadow and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param offset the offset. * * @since 1.0.11 */ public void setShadowXOffset(double offset) { this.shadowXOffset = offset; fireChangeEvent(); } /** * Returns the shadow y-offset. * * @return The shadow y-offset. * * @since 1.0.11 */ public double getShadowYOffset() { return this.shadowYOffset; } /** * Sets the y-offset for the bar shadow and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param offset the offset. * * @since 1.0.11 */ public void setShadowYOffset(double offset) { this.shadowYOffset = offset; fireChangeEvent(); } /** * Returns the bar alignment factor. * * @return The bar alignment factor. * * @since 1.0.13 */ public double getBarAlignmentFactor() { return this.barAlignmentFactor; } /** * Sets the bar alignment factor and sends a {@link RendererChangeEvent} * to all registered listeners. If the alignment factor is outside the * range 0.0 to 1.0, no alignment will be performed by the renderer. * * @param factor the factor. * * @since 1.0.13 */ public void setBarAlignmentFactor(double factor) { this.barAlignmentFactor = factor; fireChangeEvent(); } /** * Initialises the renderer and returns a state object that should be * passed to all subsequent calls to the drawItem() method. Here we * calculate the Java2D y-coordinate for zero, since all the bars have * their bases fixed at zero. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param dataset the data. * @param info an optional info collection object to return data back to * the caller. * * @return A state object. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { XYBarRendererState state = new XYBarRendererState(info); ValueAxis rangeAxis = plot.getRangeAxisForDataset(plot.indexOf( dataset)); state.setG2Base(rangeAxis.valueToJava2D(this.base, dataArea, plot.getRangeAxisEdge())); return state; } /** * Returns a default legend item for the specified series. Subclasses * should override this method to generate customised items. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot xyplot = getPlot(); if (xyplot != null) { XYDataset dataset = xyplot.getDataset(datasetIndex); if (dataset != null) { XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); String label = lg.generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = this.legendBar; Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); if (this.drawBarOutline) { result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); } else { result = new LegendItem(label, description, toolTipText, urlText, shape, paint); } result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); if (getGradientPaintTransformer() != null) { result.setFillPaintTransformer( getGradientPaintTransformer()); } } } return result; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!getItemVisible(series, item)) { return; } IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; double value0; double value1; if (this.useYInterval) { value0 = intervalDataset.getStartYValue(series, item); value1 = intervalDataset.getEndYValue(series, item); } else { value0 = this.base; value1 = intervalDataset.getYValue(series, item); } if (Double.isNaN(value0) || Double.isNaN(value1)) { return; } if (value0 <= value1) { if (!rangeAxis.getRange().intersects(value0, value1)) { return; } } else { if (!rangeAxis.getRange().intersects(value1, value0)) { return; } } double translatedValue0 = rangeAxis.valueToJava2D(value0, dataArea, plot.getRangeAxisEdge()); double translatedValue1 = rangeAxis.valueToJava2D(value1, dataArea, plot.getRangeAxisEdge()); double bottom = Math.min(translatedValue0, translatedValue1); double top = Math.max(translatedValue0, translatedValue1); double startX = intervalDataset.getStartXValue(series, item); if (Double.isNaN(startX)) { return; } double endX = intervalDataset.getEndXValue(series, item); if (Double.isNaN(endX)) { return; } if (startX <= endX) { if (!domainAxis.getRange().intersects(startX, endX)) { return; } } else { if (!domainAxis.getRange().intersects(endX, startX)) { return; } } // is there an alignment adjustment to be made? if (this.barAlignmentFactor >= 0.0 && this.barAlignmentFactor <= 1.0) { double x = intervalDataset.getXValue(series, item); double interval = endX - startX; startX = x - interval * this.barAlignmentFactor; endX = startX + interval; } RectangleEdge location = plot.getDomainAxisEdge(); double translatedStartX = domainAxis.valueToJava2D(startX, dataArea, location); double translatedEndX = domainAxis.valueToJava2D(endX, dataArea, location); double translatedWidth = Math.max(1, Math.abs(translatedEndX - translatedStartX)); double left = Math.min(translatedStartX, translatedEndX); if (getMargin() > 0.0) { double cut = translatedWidth * getMargin(); translatedWidth = translatedWidth - cut; left = left + cut / 2; } Rectangle2D bar = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { // clip left and right bounds to data area bottom = Math.max(bottom, dataArea.getMinX()); top = Math.min(top, dataArea.getMaxX()); bar = new Rectangle2D.Double( bottom, left, top - bottom, translatedWidth); } else if (orientation == PlotOrientation.VERTICAL) { // clip top and bottom bounds to data area bottom = Math.max(bottom, dataArea.getMinY()); top = Math.min(top, dataArea.getMaxY()); bar = new Rectangle2D.Double(left, bottom, translatedWidth, top - bottom); } boolean positive = (value1 > 0.0); boolean inverted = rangeAxis.isInverted(); RectangleEdge barBase; if (orientation == PlotOrientation.HORIZONTAL) { if (positive && inverted || !positive && !inverted) { barBase = RectangleEdge.RIGHT; } else { barBase = RectangleEdge.LEFT; } } else { if (positive && !inverted || !positive && inverted) { barBase = RectangleEdge.BOTTOM; } else { barBase = RectangleEdge.TOP; } } if (getShadowsVisible()) { this.barPainter.paintBarShadow(g2, this, series, item, bar, barBase, !this.useYInterval); } this.barPainter.paintBar(g2, this, series, item, bar, barBase); if (isItemLabelVisible(series, item)) { XYItemLabelGenerator generator = getItemLabelGenerator(series, item); drawItemLabel(g2, dataset, series, item, plot, generator, bar, value1 < 0.0); } // update the crosshair point double x1 = (startX + endX) / 2.0; double y1 = dataset.getYValue(series, item); double transX1 = domainAxis.valueToJava2D(x1, dataArea, location); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge()); int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, plot.getOrientation()); EntityCollection entities = state.getEntityCollection(); if (entities != null) { addEntity(entities, bar, dataset, series, item, 0.0, 0.0); } } /** * Draws an item label. This method is provided as an alternative to * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, * double, double, boolean)} so that the bar can be used to calculate the * label anchor point. * * @param g2 the graphics device. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param plot the plot. * @param generator the label generator (null permitted, in * which case the method does nothing, just returns). * @param bar the bar. * @param negative a flag indicating a negative value. */ protected void drawItemLabel(Graphics2D g2, XYDataset dataset, int series, int item, XYPlot plot, XYItemLabelGenerator generator, Rectangle2D bar, boolean negative) { if (generator == null) { return; // nothing to do } String label = generator.generateLabel(dataset, series, item); if (label == null) { return; // nothing to do } Font labelFont = getItemLabelFont(series, item); g2.setFont(labelFont); Paint paint = getItemLabelPaint(series, item); g2.setPaint(paint); // find out where to place the label... ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(series, item); } else { position = getNegativeItemLabelPosition(series, item); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); if (isInternalAnchor(position.getItemLabelAnchor())) { Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); if (bounds != null) { if (!bar.contains(bounds.getBounds2D())) { if (!negative) { position = getPositiveItemLabelPositionFallback(); } else { position = getNegativeItemLabelPositionFallback(); } if (position != null) { anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); } } } } if (position != null) { TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } } /** * Calculates the item label anchor point. * * @param anchor the anchor. * @param bar the bar. * @param orientation the plot orientation. * * @return The anchor point. */ private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, Rectangle2D bar, PlotOrientation orientation) { Point2D result = null; double offset = getItemLabelAnchorOffset(); double x0 = bar.getX() - offset; double x1 = bar.getX(); double x2 = bar.getX() + offset; double x3 = bar.getCenterX(); double x4 = bar.getMaxX() - offset; double x5 = bar.getMaxX(); double x6 = bar.getMaxX() + offset; double y0 = bar.getMaxY() + offset; double y1 = bar.getMaxY(); double y2 = bar.getMaxY() - offset; double y3 = bar.getCenterY(); double y4 = bar.getMinY() + offset; double y5 = bar.getMinY(); double y6 = bar.getMinY() - offset; if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x3, y3); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x4, y4); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x4, y3); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x4, y2); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x3, y2); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x2, y2); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x2, y3); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x2, y4); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x3, y4); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double(x5, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double(x6, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x6, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double(x6, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double(x5, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x3, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double(x1, y0); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double(x0, y1); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x0, y3); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double(x0, y5); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double(x1, y6); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x3, y6); } return result; } /** * Returns true if the specified anchor point is inside a bar. * * @param anchor the anchor point. * * @return A boolean. */ private boolean isInternalAnchor(ItemLabelAnchor anchor) { return anchor == ItemLabelAnchor.CENTER || anchor == ItemLabelAnchor.INSIDE1 || anchor == ItemLabelAnchor.INSIDE2 || anchor == ItemLabelAnchor.INSIDE3 || anchor == ItemLabelAnchor.INSIDE4 || anchor == ItemLabelAnchor.INSIDE5 || anchor == ItemLabelAnchor.INSIDE6 || anchor == ItemLabelAnchor.INSIDE7 || anchor == ItemLabelAnchor.INSIDE8 || anchor == ItemLabelAnchor.INSIDE9 || anchor == ItemLabelAnchor.INSIDE10 || anchor == ItemLabelAnchor.INSIDE11 || anchor == ItemLabelAnchor.INSIDE12; } /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. Since this renderer uses the x-interval in the * dataset, this is taken into account for the range. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is * null or empty). */ public Range findDomainBounds(XYDataset dataset) { if (dataset != null) { return DatasetUtilities.findDomainBounds(dataset, true); } else { return null; } } /** * Returns the lower and upper bounds (range) of the y-values in the * specified dataset. If the renderer is plotting the y-interval from the * dataset, this is taken into account for the range. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is * null or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { return DatasetUtilities.findRangeBounds(dataset, this.useYInterval); } else { return null; } } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { XYBarRenderer result = (XYBarRenderer) super.clone(); if (this.gradientPaintTransformer != null) { result.gradientPaintTransformer = (GradientPaintTransformer) ObjectUtilities.clone(this.gradientPaintTransformer); } result.legendBar = ShapeUtilities.clone(this.legendBar); return result; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYBarRenderer)) { return false; } XYBarRenderer that = (XYBarRenderer) obj; if (this.base != that.base) { return false; } if (this.drawBarOutline != that.drawBarOutline) { return false; } if (this.margin != that.margin) { return false; } if (this.useYInterval != that.useYInterval) { return false; } if (!ObjectUtilities.equal( this.gradientPaintTransformer, that.gradientPaintTransformer) ) { return false; } if (!ShapeUtilities.equal(this.legendBar, that.legendBar)) { return false; } if (!ObjectUtilities.equal(this.positiveItemLabelPositionFallback, that.positiveItemLabelPositionFallback)) { return false; } if (!ObjectUtilities.equal(this.negativeItemLabelPositionFallback, that.negativeItemLabelPositionFallback)) { return false; } if (!this.barPainter.equals(that.barPainter)) { return false; } if (this.shadowsVisible != that.shadowsVisible) { return false; } if (this.shadowXOffset != that.shadowXOffset) { return false; } if (this.shadowYOffset != that.shadowYOffset) { return false; } if (this.barAlignmentFactor != that.barAlignmentFactor) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendBar = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendBar, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYBlockRenderer.java0000644000175000017500000003564211173030414030556 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYBlockRenderer.java * -------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 02-Feb-2007 : Added getPaintScale() method (DG); * 09-Mar-2007 : Fixed cloning (DG); * 03-Aug-2007 : Fix for bug 1766646 (DG); * 07-Apr-2008 : Added entity collection code (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.BasicStroke; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.LookupPaintScale; import org.jfree.chart.renderer.PaintScale; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; import org.jfree.ui.RectangleAnchor; import org.jfree.util.PublicCloneable; /** * A renderer that represents data from an {@link XYZDataset} by drawing a * color block at each (x, y) point, where the color is a function of the * z-value from the dataset. The example shown here is generated by the * XYBlockChartDemo1.java program included in the JFreeChart * demo collection: *

* XYBlockRendererSample.png * * @since 1.0.4 */ public class XYBlockRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** * The block width (defaults to 1.0). */ private double blockWidth = 1.0; /** * The block height (defaults to 1.0). */ private double blockHeight = 1.0; /** * The anchor point used to align each block to its (x, y) location. The * default value is RectangleAnchor.CENTER. */ private RectangleAnchor blockAnchor = RectangleAnchor.CENTER; /** Temporary storage for the x-offset used to align the block anchor. */ private double xOffset; /** Temporary storage for the y-offset used to align the block anchor. */ private double yOffset; /** The paint scale. */ private PaintScale paintScale; /** * Creates a new XYBlockRenderer instance with default * attributes. */ public XYBlockRenderer() { updateOffsets(); this.paintScale = new LookupPaintScale(); } /** * Returns the block width, in data/axis units. * * @return The block width. * * @see #setBlockWidth(double) */ public double getBlockWidth() { return this.blockWidth; } /** * Sets the width of the blocks used to represent each data item and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param width the new width, in data/axis units (must be > 0.0). * * @see #getBlockWidth() */ public void setBlockWidth(double width) { if (width <= 0.0) { throw new IllegalArgumentException( "The 'width' argument must be > 0.0"); } this.blockWidth = width; updateOffsets(); fireChangeEvent(); } /** * Returns the block height, in data/axis units. * * @return The block height. * * @see #setBlockHeight(double) */ public double getBlockHeight() { return this.blockHeight; } /** * Sets the height of the blocks used to represent each data item and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param height the new height, in data/axis units (must be > 0.0). * * @see #getBlockHeight() */ public void setBlockHeight(double height) { if (height <= 0.0) { throw new IllegalArgumentException( "The 'height' argument must be > 0.0"); } this.blockHeight = height; updateOffsets(); fireChangeEvent(); } /** * Returns the anchor point used to align a block at its (x, y) location. * The default values is {@link RectangleAnchor#CENTER}. * * @return The anchor point (never null). * * @see #setBlockAnchor(RectangleAnchor) */ public RectangleAnchor getBlockAnchor() { return this.blockAnchor; } /** * Sets the anchor point used to align a block at its (x, y) location and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param anchor the anchor. * * @see #getBlockAnchor() */ public void setBlockAnchor(RectangleAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } if (this.blockAnchor.equals(anchor)) { return; // no change } this.blockAnchor = anchor; updateOffsets(); fireChangeEvent(); } /** * Returns the paint scale used by the renderer. * * @return The paint scale (never null). * * @see #setPaintScale(PaintScale) * @since 1.0.4 */ public PaintScale getPaintScale() { return this.paintScale; } /** * Sets the paint scale used by the renderer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param scale the scale (null not permitted). * * @see #getPaintScale() * @since 1.0.4 */ public void setPaintScale(PaintScale scale) { if (scale == null) { throw new IllegalArgumentException("Null 'scale' argument."); } this.paintScale = scale; fireChangeEvent(); } /** * Updates the offsets to take into account the block width, height and * anchor. */ private void updateOffsets() { if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) { this.xOffset = 0.0; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) { this.xOffset = 0.0; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) { this.xOffset = 0.0; this.yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = -this.blockHeight; } } /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @see #findRangeBounds(XYDataset) */ public Range findDomainBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtilities.findDomainBounds(dataset, false); if (r == null) { return null; } else { return new Range(r.getLowerBound() + this.xOffset, r.getUpperBound() + this.blockWidth + this.xOffset); } } else { return null; } } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @see #findDomainBounds(XYDataset) */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtilities.findRangeBounds(dataset, false); if (r == null) { return null; } else { return new Range(r.getLowerBound() + this.yOffset, r.getUpperBound() + this.blockHeight + this.yOffset); } } else { return null; } } /** * Draws the block representing the specified item. * * @param g2 the graphics device. * @param state the state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the x-axis. * @param rangeAxis the y-axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double z = 0.0; if (dataset instanceof XYZDataset) { z = ((XYZDataset) dataset).getZValue(series, item); } Paint p = this.paintScale.getPaint(z); double xx0 = domainAxis.valueToJava2D(x + this.xOffset, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y + this.yOffset, dataArea, plot.getRangeAxisEdge()); double xx1 = domainAxis.valueToJava2D(x + this.blockWidth + this.xOffset, dataArea, plot.getDomainAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y + this.blockHeight + this.yOffset, dataArea, plot.getRangeAxisEdge()); Rectangle2D block; PlotOrientation orientation = plot.getOrientation(); if (orientation.equals(PlotOrientation.HORIZONTAL)) { block = new Rectangle2D.Double(Math.min(yy0, yy1), Math.min(xx0, xx1), Math.abs(yy1 - yy0), Math.abs(xx0 - xx1)); } else { block = new Rectangle2D.Double(Math.min(xx0, xx1), Math.min(yy0, yy1), Math.abs(xx1 - xx0), Math.abs(yy1 - yy0)); } g2.setPaint(p); g2.fill(block); g2.setStroke(new BasicStroke(1.0f)); g2.draw(block); EntityCollection entities = state.getEntityCollection(); if (entities != null) { addEntity(entities, block, dataset, series, item, 0.0, 0.0); } } /** * Tests this XYBlockRenderer for equality with an arbitrary * object. This method returns true if and only if: *
    *
  • obj is an instance of XYBlockRenderer (not * null);
  • *
  • obj has the same field values as this * XYBlockRenderer;
  • *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYBlockRenderer)) { return false; } XYBlockRenderer that = (XYBlockRenderer) obj; if (this.blockHeight != that.blockHeight) { return false; } if (this.blockWidth != that.blockWidth) { return false; } if (!this.blockAnchor.equals(that.blockAnchor)) { return false; } if (!this.paintScale.equals(that.paintScale)) { return false; } return super.equals(obj); } /** * Returns a clone of this renderer. * * @return A clone of this renderer. * * @throws CloneNotSupportedException if there is a problem creating the * clone. */ public Object clone() throws CloneNotSupportedException { XYBlockRenderer clone = (XYBlockRenderer) super.clone(); if (this.paintScale instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.paintScale; clone.paintScale = (PaintScale) pc.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java0000644000175000017500000010037711173030414032232 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * XYBoxAndWhiskerRenderer.java * ---------------------------- * (C) Copyright 2003-2009, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning. Based on code in the * CandlestickRenderer class. Additional modifications by David * Gilbert to make the code work with 0.9.10 changes (DG); * 08-Aug-2003 : Updated some of the Javadoc * Allowed BoxAndwhiskerDataset Average value to be null - the * average value is an AIMS requirement * Allow the outlier and farout coefficients to be set - though * at the moment this only affects the calculation of farouts. * Added artifactPaint variable and setter/getter * 12-Aug-2003 Rewrote code to sort out and process outliers to take * advantage of changes in DefaultBoxAndWhiskerDataset * Added a limit of 10% for width of box should no width be * specified...maybe this should be setable??? * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 08-Sep-2003 : Changed ValueAxis API (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 23-Apr-2004 : Added fillBox attribute, extended equals() method and fixed * serialization issue (DG); * 29-Apr-2004 : Fixed problem with drawing upper and lower shadows - bug id * 944011 (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 01-Oct-2004 : Renamed 'paint' --> 'boxPaint' to avoid conflict with * inherited attribute (DG); * 10-Jun-2005 : Updated equals() to handle GradientPaint (DG); * 06-Oct-2005 : Removed setPaint() call in drawItem(), it is causing a * loop (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 05-Feb-2007 : Added event notifications and fixed drawing for horizontal * plot orientation (DG); * 13-Jun-2007 : Replaced deprecated method call (DG); * 03-Jan-2008 : Check visibility of average marker before drawing it (DG); * 27-Mar-2008 : If boxPaint is null, revert to itemPaint (DG); * 27-Mar-2009 : Added findRangeBounds() method override (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.BoxAndWhiskerXYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.Outlier; import org.jfree.chart.renderer.OutlierList; import org.jfree.chart.renderer.OutlierListCollection; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.statistics.BoxAndWhiskerXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A renderer that draws box-and-whisker items on an {@link XYPlot}. This * renderer requires a {@link BoxAndWhiskerXYDataset}). The example shown here * is generated by the BoxAndWhiskerChartDemo2.java program * included in the JFreeChart demo collection: *

* XYBoxAndWhiskerRendererSample.png *

* This renderer does not include any code to calculate the crosshair point. */ public class XYBoxAndWhiskerRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8020170108532232324L; /** The box width. */ private double boxWidth; /** The paint used to fill the box. */ private transient Paint boxPaint; /** A flag that controls whether or not the box is filled. */ private boolean fillBox; /** * The paint used to draw various artifacts such as outliers, farout * symbol, average ellipse and median line. */ private transient Paint artifactPaint = Color.black; /** * Creates a new renderer for box and whisker charts. */ public XYBoxAndWhiskerRenderer() { this(-1.0); } /** * Creates a new renderer for box and whisker charts. *

* Use -1 for the box width if you prefer the width to be calculated * automatically. * * @param boxWidth the box width. */ public XYBoxAndWhiskerRenderer(double boxWidth) { super(); this.boxWidth = boxWidth; this.boxPaint = Color.green; this.fillBox = true; setBaseToolTipGenerator(new BoxAndWhiskerXYToolTipGenerator()); } /** * Returns the width of each box. * * @return The box width. * * @see #setBoxWidth(double) */ public double getBoxWidth() { return this.boxWidth; } /** * Sets the box width and sends a {@link RendererChangeEvent} to all * registered listeners. *

* If you set the width to a negative value, the renderer will calculate * the box width automatically based on the space available on the chart. * * @param width the width. * * @see #getBoxWidth() */ public void setBoxWidth(double width) { if (width != this.boxWidth) { this.boxWidth = width; fireChangeEvent(); } } /** * Returns the paint used to fill boxes. * * @return The paint (possibly null). * * @see #setBoxPaint(Paint) */ public Paint getBoxPaint() { return this.boxPaint; } /** * Sets the paint used to fill boxes and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param paint the paint (null permitted). * * @see #getBoxPaint() */ public void setBoxPaint(Paint paint) { this.boxPaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether or not the box is filled. * * @return A boolean. * * @see #setFillBox(boolean) */ public boolean getFillBox() { return this.fillBox; } /** * Sets the flag that controls whether or not the box is filled and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #setFillBox(boolean) */ public void setFillBox(boolean flag) { this.fillBox = flag; fireChangeEvent(); } /** * Returns the paint used to paint the various artifacts such as outliers, * farout symbol, median line and the averages ellipse. * * @return The paint (never null). * * @see #setArtifactPaint(Paint) */ public Paint getArtifactPaint() { return this.artifactPaint; } /** * Sets the paint used to paint the various artifacts such as outliers, * farout symbol, median line and the averages ellipse, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getArtifactPaint() */ public void setArtifactPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.artifactPaint = paint; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). * * @see #findDomainBounds(XYDataset) */ public Range findRangeBounds(XYDataset dataset) { return findRangeBounds(dataset, true); } /** * Returns the box paint or, if this is null, the item * paint. * * @param series the series index. * @param item the item index. * * @return The paint used to fill the box for the specified item (never * null). * * @since 1.0.10 */ protected Paint lookupBoxPaint(int series, int item) { Paint p = getBoxPaint(); if (p != null) { return p; } else { // TODO: could change this to itemFillPaint(). For backwards // compatibility, it might require a useFillPaint flag. return getItemPaint(series, item); } } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects info about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (must be an instance of * {@link BoxAndWhiskerXYDataset}). * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { drawHorizontalItem(g2, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); } else if (orientation == PlotOrientation.VERTICAL) { drawVerticalItem(g2, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); } } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param dataArea the area within which the plot is being drawn. * @param info collects info about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (must be an instance of * {@link BoxAndWhiskerXYDataset}). * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawHorizontalItem(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } BoxAndWhiskerXYDataset boxAndWhiskerData = (BoxAndWhiskerXYDataset) dataset; Number x = boxAndWhiskerData.getX(series, item); Number yMax = boxAndWhiskerData.getMaxRegularValue(series, item); Number yMin = boxAndWhiskerData.getMinRegularValue(series, item); Number yMedian = boxAndWhiskerData.getMedianValue(series, item); Number yAverage = boxAndWhiskerData.getMeanValue(series, item); Number yQ1Median = boxAndWhiskerData.getQ1Value(series, item); Number yQ3Median = boxAndWhiskerData.getQ3Value(series, item); double xx = domainAxis.valueToJava2D(x.doubleValue(), dataArea, plot.getDomainAxisEdge()); RectangleEdge location = plot.getRangeAxisEdge(); double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location); double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location); double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location); double yyAverage = 0.0; if (yAverage != null) { yyAverage = rangeAxis.valueToJava2D(yAverage.doubleValue(), dataArea, location); } double yyQ1Median = rangeAxis.valueToJava2D(yQ1Median.doubleValue(), dataArea, location); double yyQ3Median = rangeAxis.valueToJava2D(yQ3Median.doubleValue(), dataArea, location); double exactBoxWidth = getBoxWidth(); double width = exactBoxWidth; double dataAreaX = dataArea.getHeight(); double maxBoxPercent = 0.1; double maxBoxWidth = dataAreaX * maxBoxPercent; if (exactBoxWidth <= 0.0) { int itemCount = boxAndWhiskerData.getItemCount(series); exactBoxWidth = dataAreaX / itemCount * 4.5 / 7; if (exactBoxWidth < 3) { width = 3; } else if (exactBoxWidth > maxBoxWidth) { width = maxBoxWidth; } else { width = exactBoxWidth; } } g2.setPaint(getItemPaint(series, item)); Stroke s = getItemStroke(series, item); g2.setStroke(s); // draw the upper shadow g2.draw(new Line2D.Double(yyMax, xx, yyQ3Median, xx)); g2.draw(new Line2D.Double(yyMax, xx - width / 2, yyMax, xx + width / 2)); // draw the lower shadow g2.draw(new Line2D.Double(yyMin, xx, yyQ1Median, xx)); g2.draw(new Line2D.Double(yyMin, xx - width / 2, yyMin, xx + width / 2)); // draw the body Shape box = null; if (yyQ1Median < yyQ3Median) { box = new Rectangle2D.Double(yyQ1Median, xx - width / 2, yyQ3Median - yyQ1Median, width); } else { box = new Rectangle2D.Double(yyQ3Median, xx - width / 2, yyQ1Median - yyQ3Median, width); } if (this.fillBox) { g2.setPaint(lookupBoxPaint(series, item)); g2.fill(box); } g2.setStroke(getItemOutlineStroke(series, item)); g2.setPaint(getItemOutlinePaint(series, item)); g2.draw(box); // draw median g2.setPaint(getArtifactPaint()); g2.draw(new Line2D.Double(yyMedian, xx - width / 2, yyMedian, xx + width / 2)); // draw average - SPECIAL AIMS REQUIREMENT if (yAverage != null) { double aRadius = width / 4; // here we check that the average marker will in fact be visible // before drawing it... if ((yyAverage > (dataArea.getMinX() - aRadius)) && (yyAverage < (dataArea.getMaxX() + aRadius))) { Ellipse2D.Double avgEllipse = new Ellipse2D.Double( yyAverage - aRadius, xx - aRadius, aRadius * 2, aRadius * 2); g2.fill(avgEllipse); g2.draw(avgEllipse); } } // FIXME: draw outliers // add an entity for the item... if (entities != null && box.intersects(dataArea)) { addEntity(entities, box, dataset, series, item, yyAverage, xx); } } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param dataArea the area within which the plot is being drawn. * @param info collects info about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset (must be an instance of * {@link BoxAndWhiskerXYDataset}). * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawVerticalItem(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } BoxAndWhiskerXYDataset boxAndWhiskerData = (BoxAndWhiskerXYDataset) dataset; Number x = boxAndWhiskerData.getX(series, item); Number yMax = boxAndWhiskerData.getMaxRegularValue(series, item); Number yMin = boxAndWhiskerData.getMinRegularValue(series, item); Number yMedian = boxAndWhiskerData.getMedianValue(series, item); Number yAverage = boxAndWhiskerData.getMeanValue(series, item); Number yQ1Median = boxAndWhiskerData.getQ1Value(series, item); Number yQ3Median = boxAndWhiskerData.getQ3Value(series, item); List yOutliers = boxAndWhiskerData.getOutliers(series, item); double xx = domainAxis.valueToJava2D(x.doubleValue(), dataArea, plot.getDomainAxisEdge()); RectangleEdge location = plot.getRangeAxisEdge(); double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, location); double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, location); double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location); double yyAverage = 0.0; if (yAverage != null) { yyAverage = rangeAxis.valueToJava2D(yAverage.doubleValue(), dataArea, location); } double yyQ1Median = rangeAxis.valueToJava2D(yQ1Median.doubleValue(), dataArea, location); double yyQ3Median = rangeAxis.valueToJava2D(yQ3Median.doubleValue(), dataArea, location); double yyOutlier; double exactBoxWidth = getBoxWidth(); double width = exactBoxWidth; double dataAreaX = dataArea.getMaxX() - dataArea.getMinX(); double maxBoxPercent = 0.1; double maxBoxWidth = dataAreaX * maxBoxPercent; if (exactBoxWidth <= 0.0) { int itemCount = boxAndWhiskerData.getItemCount(series); exactBoxWidth = dataAreaX / itemCount * 4.5 / 7; if (exactBoxWidth < 3) { width = 3; } else if (exactBoxWidth > maxBoxWidth) { width = maxBoxWidth; } else { width = exactBoxWidth; } } g2.setPaint(getItemPaint(series, item)); Stroke s = getItemStroke(series, item); g2.setStroke(s); // draw the upper shadow g2.draw(new Line2D.Double(xx, yyMax, xx, yyQ3Median)); g2.draw(new Line2D.Double(xx - width / 2, yyMax, xx + width / 2, yyMax)); // draw the lower shadow g2.draw(new Line2D.Double(xx, yyMin, xx, yyQ1Median)); g2.draw(new Line2D.Double(xx - width / 2, yyMin, xx + width / 2, yyMin)); // draw the body Shape box = null; if (yyQ1Median > yyQ3Median) { box = new Rectangle2D.Double(xx - width / 2, yyQ3Median, width, yyQ1Median - yyQ3Median); } else { box = new Rectangle2D.Double(xx - width / 2, yyQ1Median, width, yyQ3Median - yyQ1Median); } if (this.fillBox) { g2.setPaint(lookupBoxPaint(series, item)); g2.fill(box); } g2.setStroke(getItemOutlineStroke(series, item)); g2.setPaint(getItemOutlinePaint(series, item)); g2.draw(box); // draw median g2.setPaint(getArtifactPaint()); g2.draw(new Line2D.Double(xx - width / 2, yyMedian, xx + width / 2, yyMedian)); double aRadius = 0; // average radius double oRadius = width / 3; // outlier radius // draw average - SPECIAL AIMS REQUIREMENT if (yAverage != null) { aRadius = width / 4; // here we check that the average marker will in fact be visible // before drawing it... if ((yyAverage > (dataArea.getMinY() - aRadius)) && (yyAverage < (dataArea.getMaxY() + aRadius))) { Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx - aRadius, yyAverage - aRadius, aRadius * 2, aRadius * 2); g2.fill(avgEllipse); g2.draw(avgEllipse); } } List outliers = new ArrayList(); OutlierListCollection outlierListCollection = new OutlierListCollection(); /* From outlier array sort out which are outliers and put these into * an arraylist. If there are any farouts, set the flag on the * OutlierListCollection */ for (int i = 0; i < yOutliers.size(); i++) { double outlier = ((Number) yOutliers.get(i)).doubleValue(); if (outlier > boxAndWhiskerData.getMaxOutlier(series, item).doubleValue()) { outlierListCollection.setHighFarOut(true); } else if (outlier < boxAndWhiskerData.getMinOutlier(series, item).doubleValue()) { outlierListCollection.setLowFarOut(true); } else if (outlier > boxAndWhiskerData.getMaxRegularValue(series, item).doubleValue()) { yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location); outliers.add(new Outlier(xx, yyOutlier, oRadius)); } else if (outlier < boxAndWhiskerData.getMinRegularValue(series, item).doubleValue()) { yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, location); outliers.add(new Outlier(xx, yyOutlier, oRadius)); } Collections.sort(outliers); } // Process outliers. Each outlier is either added to the appropriate // outlier list or a new outlier list is made for (Iterator iterator = outliers.iterator(); iterator.hasNext();) { Outlier outlier = (Outlier) iterator.next(); outlierListCollection.add(outlier); } // draw yOutliers double maxAxisValue = rangeAxis.valueToJava2D(rangeAxis.getUpperBound(), dataArea, location) + aRadius; double minAxisValue = rangeAxis.valueToJava2D(rangeAxis.getLowerBound(), dataArea, location) - aRadius; // draw outliers for (Iterator iterator = outlierListCollection.iterator(); iterator.hasNext();) { OutlierList list = (OutlierList) iterator.next(); Outlier outlier = list.getAveragedOutlier(); Point2D point = outlier.getPoint(); if (list.isMultiple()) { drawMultipleEllipse(point, width, oRadius, g2); } else { drawEllipse(point, oRadius, g2); } } // draw farout if (outlierListCollection.isHighFarOut()) { drawHighFarOut(aRadius, g2, xx, maxAxisValue); } if (outlierListCollection.isLowFarOut()) { drawLowFarOut(aRadius, g2, xx, minAxisValue); } // add an entity for the item... if (entities != null && box.intersects(dataArea)) { addEntity(entities, box, dataset, series, item, xx, yyAverage); } } /** * Draws an ellipse to represent an outlier. * * @param point the location. * @param oRadius the radius. * @param g2 the graphics device. */ protected void drawEllipse(Point2D point, double oRadius, Graphics2D g2) { Ellipse2D.Double dot = new Ellipse2D.Double(point.getX() + oRadius / 2, point.getY(), oRadius, oRadius); g2.draw(dot); } /** * Draws two ellipses to represent overlapping outliers. * * @param point the location. * @param boxWidth the box width. * @param oRadius the radius. * @param g2 the graphics device. */ protected void drawMultipleEllipse(Point2D point, double boxWidth, double oRadius, Graphics2D g2) { Ellipse2D.Double dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius); Ellipse2D.Double dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), point.getY(), oRadius, oRadius); g2.draw(dot1); g2.draw(dot2); } /** * Draws a triangle to indicate the presence of far out values. * * @param aRadius the radius. * @param g2 the graphics device. * @param xx the x value. * @param m the max y value. */ protected void drawHighFarOut(double aRadius, Graphics2D g2, double xx, double m) { double side = aRadius * 2; g2.draw(new Line2D.Double(xx - side, m + side, xx + side, m + side)); g2.draw(new Line2D.Double(xx - side, m + side, xx, m)); g2.draw(new Line2D.Double(xx + side, m + side, xx, m)); } /** * Draws a triangle to indicate the presence of far out values. * * @param aRadius the radius. * @param g2 the graphics device. * @param xx the x value. * @param m the min y value. */ protected void drawLowFarOut(double aRadius, Graphics2D g2, double xx, double m) { double side = aRadius * 2; g2.draw(new Line2D.Double(xx - side, m - side, xx + side, m - side)); g2.draw(new Line2D.Double(xx - side, m - side, xx, m)); g2.draw(new Line2D.Double(xx + side, m - side, xx, m)); } /** * Tests this renderer for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYBoxAndWhiskerRenderer)) { return false; } if (!super.equals(obj)) { return false; } XYBoxAndWhiskerRenderer that = (XYBoxAndWhiskerRenderer) obj; if (this.boxWidth != that.getBoxWidth()) { return false; } if (!PaintUtilities.equal(this.boxPaint, that.boxPaint)) { return false; } if (!PaintUtilities.equal(this.artifactPaint, that.artifactPaint)) { return false; } if (this.fillBox != that.fillBox) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.boxPaint, stream); SerialUtilities.writePaint(this.artifactPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.boxPaint = SerialUtilities.readPaint(stream); this.artifactPaint = SerialUtilities.readPaint(stream); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java0000644000175000017500000003520611173030414030713 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYBubbleRenderer.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Christian W. Zuckschwerdt; * * Changes * ------- * 28-Jan-2003 : Version 1 (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 10-Feb-2004 : Small change to drawItem() method to make cut-and-paste * overriding easier (DG); * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); * 19-Jan-2005 : Now accesses only primitives from dataset (DG); * 28-Feb-2005 : Modify renderer to use circles in legend (DG); * 17-Mar-2005 : Fixed bug in bubble bounds calculation (DG); * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Dec-2005 : Added support for item labels (bug 1373371) (DG); * 20-Jan-2006 : Check flag for drawing item labels (DG); * 21-Sep-2006 : Respect the outline paint and stroke settings (DG); * 24-Jan-2007 : Added new equals() override (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 13-Jun-2007 : Fixed seriesVisibility bug (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * A renderer that draws a circle at each data point with a diameter that is * determined by the z-value in the dataset (the renderer requires the dataset * to be an instance of {@link XYZDataset}. The example shown here * is generated by the XYBubbleChartDemo1.java program * included in the JFreeChart demo collection: *

* XYBubbleRendererSample.png */ public class XYBubbleRenderer extends AbstractXYItemRenderer implements XYItemRenderer, PublicCloneable { /** For serialization. */ public static final long serialVersionUID = -5221991598674249125L; /** * A constant to specify that the bubbles drawn by this renderer should be * scaled on both axes (see {@link #XYBubbleRenderer(int)}). */ public static final int SCALE_ON_BOTH_AXES = 0; /** * A constant to specify that the bubbles drawn by this renderer should be * scaled on the domain axis (see {@link #XYBubbleRenderer(int)}). */ public static final int SCALE_ON_DOMAIN_AXIS = 1; /** * A constant to specify that the bubbles drawn by this renderer should be * scaled on the range axis (see {@link #XYBubbleRenderer(int)}). */ public static final int SCALE_ON_RANGE_AXIS = 2; /** Controls how the width and height of the bubble are scaled. */ private int scaleType; /** * Constructs a new renderer. */ public XYBubbleRenderer() { this(SCALE_ON_BOTH_AXES); } /** * Constructs a new renderer with the specified type of scaling. * * @param scaleType the type of scaling (must be one of: * {@link #SCALE_ON_BOTH_AXES}, {@link #SCALE_ON_DOMAIN_AXIS}, * {@link #SCALE_ON_RANGE_AXIS}). */ public XYBubbleRenderer(int scaleType) { super(); if (scaleType < 0 || scaleType > 2) { throw new IllegalArgumentException("Invalid 'scaleType'."); } this.scaleType = scaleType; setBaseLegendShape(new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); } /** * Returns the scale type that was set when the renderer was constructed. * * @return The scale type (one of: {@link #SCALE_ON_BOTH_AXES}, * {@link #SCALE_ON_DOMAIN_AXIS}, {@link #SCALE_ON_RANGE_AXIS}). */ public int getScaleType() { return this.scaleType; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain (horizontal) axis. * @param rangeAxis the range (vertical) axis. * @param dataset the dataset (an {@link XYZDataset} is expected). * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // return straight away if the item is not visible if (!getItemVisible(series, item)) { return; } PlotOrientation orientation = plot.getOrientation(); // get the data point... double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double z = Double.NaN; if (dataset instanceof XYZDataset) { XYZDataset xyzData = (XYZDataset) dataset; z = xyzData.getZValue(series, item); } if (!Double.isNaN(z)) { RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, domainAxisLocation); double transY = rangeAxis.valueToJava2D(y, dataArea, rangeAxisLocation); double transDomain = 0.0; double transRange = 0.0; double zero; switch(getScaleType()) { case SCALE_ON_DOMAIN_AXIS: zero = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation); transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero; transRange = transDomain; break; case SCALE_ON_RANGE_AXIS: zero = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation); transRange = zero - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation); transDomain = transRange; break; default: double zero1 = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation); double zero2 = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation); transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero1; transRange = zero2 - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation); } transDomain = Math.abs(transDomain); transRange = Math.abs(transRange); Ellipse2D circle = null; if (orientation == PlotOrientation.VERTICAL) { circle = new Ellipse2D.Double(transX - transDomain / 2.0, transY - transRange / 2.0, transDomain, transRange); } else if (orientation == PlotOrientation.HORIZONTAL) { circle = new Ellipse2D.Double(transY - transRange / 2.0, transX - transDomain / 2.0, transRange, transDomain); } g2.setPaint(getItemPaint(series, item)); g2.fill(circle); g2.setStroke(getItemOutlineStroke(series, item)); g2.setPaint(getItemOutlinePaint(series, item)); g2.draw(circle); if (isItemLabelVisible(series, item)) { if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, series, item, transX, transY, false); } else if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, series, item, transY, transX, false); } } // add an entity if this info is being collected EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); if (entities != null && circle.intersects(dataArea)) { addEntity(entities, circle, dataset, series, item, circle.getCenterX(), circle.getCenterY()); } } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } } /** * Returns a legend item for the specified series. The default method * is overridden so that the legend displays circles for all series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot plot = getPlot(); if (plot == null) { return null; } XYDataset dataset = plot.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } return result; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYBubbleRenderer)) { return false; } XYBubbleRenderer that = (XYBubbleRenderer) obj; if (this.scaleType != that.scaleType) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java0000644000175000017500000014105311173030414031550 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYDifferenceRenderer.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard West, Advanced Micro Devices, Inc. (major rewrite * of difference drawing algorithm); * * Changes: * -------- * 30-Apr-2003 : Version 1 (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 09-Feb-2004 : Updated to support horizontal plot orientation (DG); * 10-Feb-2004 : Added default constructor, setter methods and updated * Javadocs (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 30-Mar-2004 : Fixed bug in getNegativePaint() method (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 25-Aug-2004 : Fixed a bug preventing the use of crosshairs (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 19-Jan-2005 : Now accesses only primitive values from dataset (DG); * 22-Feb-2005 : Override getLegendItem(int, int) to return "line" items (DG); * 13-Apr-2005 : Fixed shape positioning bug (id = 1182062) (DG); * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); * 04-May-2005 : Override equals() method, renamed get/setPlotShapes() --> * get/setShapesVisible (DG); * 09-Jun-2005 : Updated equals() to handle GradientPaint (DG); * 16-Jun-2005 : Fix bug (1221021) affecting stroke used for each series (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Jan-2007 : Added flag to allow rounding of x-coordinates, and fixed * bug in clone() (DG); * 05-Feb-2007 : Added an extra call to updateCrosshairValues() in * drawItemPass1(), to fix bug 1564967 (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 08-Mar-2007 : Fixed entity generation (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 23-Apr-2007 : Rewrite of difference drawing algorithm to allow use of * series with disjoint x-values (RW); * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 05-Nov-2007 : Draw item labels if visible (RW); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Collections; import java.util.LinkedList; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.XYItemEntity; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer for an {@link XYPlot} that highlights the differences between two * series. The example shown here is generated by the * DifferenceChartDemo1.java program included in the JFreeChart * demo collection: *

* XYDifferenceRendererSample.png */ public class XYDifferenceRenderer extends AbstractXYItemRenderer implements XYItemRenderer, PublicCloneable { /** For serialization. */ private static final long serialVersionUID = -8447915602375584857L; /** The paint used to highlight positive differences (y(0) > y(1)). */ private transient Paint positivePaint; /** The paint used to highlight negative differences (y(0) < y(1)). */ private transient Paint negativePaint; /** Display shapes at each point? */ private boolean shapesVisible; /** The shape to display in the legend item. */ private transient Shape legendLine; /** * This flag controls whether or not the x-coordinates (in Java2D space) * are rounded to integers. When set to true, this can avoid the vertical * striping that anti-aliasing can generate. However, the rounding may not * be appropriate for output in high resolution formats (for example, * vector graphics formats such as SVG and PDF). * * @since 1.0.4 */ private boolean roundXCoordinates; /** * Creates a new renderer with default attributes. */ public XYDifferenceRenderer() { this(Color.green, Color.red, false); } /** * Creates a new renderer. * * @param positivePaint the highlight color for positive differences * (null not permitted). * @param negativePaint the highlight color for negative differences * (null not permitted). * @param shapes draw shapes? */ public XYDifferenceRenderer(Paint positivePaint, Paint negativePaint, boolean shapes) { if (positivePaint == null) { throw new IllegalArgumentException( "Null 'positivePaint' argument."); } if (negativePaint == null) { throw new IllegalArgumentException( "Null 'negativePaint' argument."); } this.positivePaint = positivePaint; this.negativePaint = negativePaint; this.shapesVisible = shapes; this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); this.roundXCoordinates = false; } /** * Returns the paint used to highlight positive differences. * * @return The paint (never null). * * @see #setPositivePaint(Paint) */ public Paint getPositivePaint() { return this.positivePaint; } /** * Sets the paint used to highlight positive differences and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getPositivePaint() */ public void setPositivePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.positivePaint = paint; fireChangeEvent(); } /** * Returns the paint used to highlight negative differences. * * @return The paint (never null). * * @see #setNegativePaint(Paint) */ public Paint getNegativePaint() { return this.negativePaint; } /** * Sets the paint used to highlight negative differences. * * @param paint the paint (null not permitted). * * @see #getNegativePaint() */ public void setNegativePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.negativePaint = paint; notifyListeners(new RendererChangeEvent(this)); } /** * Returns a flag that controls whether or not shapes are drawn for each * data value. * * @return A boolean. * * @see #setShapesVisible(boolean) */ public boolean getShapesVisible() { return this.shapesVisible; } /** * Sets a flag that controls whether or not shapes are drawn for each * data value, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #getShapesVisible() */ public void setShapesVisible(boolean flag) { this.shapesVisible = flag; fireChangeEvent(); } /** * Returns the shape used to represent a line in the legend. * * @return The legend line (never null). * * @see #setLegendLine(Shape) */ public Shape getLegendLine() { return this.legendLine; } /** * Sets the shape used as a line in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param line the line (null not permitted). * * @see #getLegendLine() */ public void setLegendLine(Shape line) { if (line == null) { throw new IllegalArgumentException("Null 'line' argument."); } this.legendLine = line; fireChangeEvent(); } /** * Returns the flag that controls whether or not the x-coordinates (in * Java2D space) are rounded to integer values. * * @return The flag. * * @since 1.0.4 * * @see #setRoundXCoordinates(boolean) */ public boolean getRoundXCoordinates() { return this.roundXCoordinates; } /** * Sets the flag that controls whether or not the x-coordinates (in * Java2D space) are rounded to integer values, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param round the new flag value. * * @since 1.0.4 * * @see #getRoundXCoordinates() */ public void setRoundXCoordinates(boolean round) { this.roundXCoordinates = round; fireChangeEvent(); } /** * Initialises the renderer and returns a state object that should be * passed to subsequent calls to the drawItem() method. This method will * be called before the first item is rendered, giving the renderer an * opportunity to initialise any state information it wants to maintain. * The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return A state object. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { XYItemRendererState state = super.initialise(g2, dataArea, plot, data, info); state.setProcessVisibleItemsOnly(false); return state; } /** * Returns 2, the number of passes required by the renderer. * The {@link XYPlot} will run through the dataset this number of times. * * @return The number of passes required by the renderer. */ public int getPassCount() { return 2; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain (horizontal) axis. * @param rangeAxis the range (vertical) axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (pass == 0) { drawItemPass0(g2, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState); } else if (pass == 1) { drawItemPass1(g2, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState); } } /** * Draws the visual representation of a single data item, first pass. * * @param x_graphics the graphics device. * @param x_dataArea the area within which the data is being drawn. * @param x_info collects information about the drawing. * @param x_plot the plot (can be used to obtain standard color * information etc). * @param x_domainAxis the domain (horizontal) axis. * @param x_rangeAxis the range (vertical) axis. * @param x_dataset the dataset. * @param x_series the series index (zero-based). * @param x_item the item index (zero-based). * @param x_crosshairState crosshair information for the plot * (null permitted). */ protected void drawItemPass0(Graphics2D x_graphics, Rectangle2D x_dataArea, PlotRenderingInfo x_info, XYPlot x_plot, ValueAxis x_domainAxis, ValueAxis x_rangeAxis, XYDataset x_dataset, int x_series, int x_item, CrosshairState x_crosshairState) { if (!((0 == x_series) && (0 == x_item))) { return; } boolean b_impliedZeroSubtrahend = (1 == x_dataset.getSeriesCount()); // check if either series is a degenerate case (i.e. less than 2 points) if (isEitherSeriesDegenerate(x_dataset, b_impliedZeroSubtrahend)) { return; } // check if series are disjoint (i.e. domain-spans do not overlap) if (!b_impliedZeroSubtrahend && areSeriesDisjoint(x_dataset)) { return; } // polygon definitions LinkedList l_minuendXs = new LinkedList(); LinkedList l_minuendYs = new LinkedList(); LinkedList l_subtrahendXs = new LinkedList(); LinkedList l_subtrahendYs = new LinkedList(); LinkedList l_polygonXs = new LinkedList(); LinkedList l_polygonYs = new LinkedList(); // state int l_minuendItem = 0; int l_minuendItemCount = x_dataset.getItemCount(0); Double l_minuendCurX = null; Double l_minuendNextX = null; Double l_minuendCurY = null; Double l_minuendNextY = null; double l_minuendMaxY = Double.NEGATIVE_INFINITY; double l_minuendMinY = Double.POSITIVE_INFINITY; int l_subtrahendItem = 0; int l_subtrahendItemCount = 0; // actual value set below Double l_subtrahendCurX = null; Double l_subtrahendNextX = null; Double l_subtrahendCurY = null; Double l_subtrahendNextY = null; double l_subtrahendMaxY = Double.NEGATIVE_INFINITY; double l_subtrahendMinY = Double.POSITIVE_INFINITY; // if a subtrahend is not specified, assume it is zero if (b_impliedZeroSubtrahend) { l_subtrahendItem = 0; l_subtrahendItemCount = 2; l_subtrahendCurX = new Double(x_dataset.getXValue(0, 0)); l_subtrahendNextX = new Double(x_dataset.getXValue(0, (l_minuendItemCount - 1))); l_subtrahendCurY = new Double(0.0); l_subtrahendNextY = new Double(0.0); l_subtrahendMaxY = 0.0; l_subtrahendMinY = 0.0; l_subtrahendXs.add(l_subtrahendCurX); l_subtrahendYs.add(l_subtrahendCurY); } else { l_subtrahendItemCount = x_dataset.getItemCount(1); } boolean b_minuendDone = false; boolean b_minuendAdvanced = true; boolean b_minuendAtIntersect = false; boolean b_minuendFastForward = false; boolean b_subtrahendDone = false; boolean b_subtrahendAdvanced = true; boolean b_subtrahendAtIntersect = false; boolean b_subtrahendFastForward = false; boolean b_colinear = false; boolean b_positive; // coordinate pairs double l_x1 = 0.0, l_y1 = 0.0; // current minuend point double l_x2 = 0.0, l_y2 = 0.0; // next minuend point double l_x3 = 0.0, l_y3 = 0.0; // current subtrahend point double l_x4 = 0.0, l_y4 = 0.0; // next subtrahend point // fast-forward through leading tails boolean b_fastForwardDone = false; while (!b_fastForwardDone) { // get the x and y coordinates l_x1 = x_dataset.getXValue(0, l_minuendItem); l_y1 = x_dataset.getYValue(0, l_minuendItem); l_x2 = x_dataset.getXValue(0, l_minuendItem + 1); l_y2 = x_dataset.getYValue(0, l_minuendItem + 1); l_minuendCurX = new Double(l_x1); l_minuendCurY = new Double(l_y1); l_minuendNextX = new Double(l_x2); l_minuendNextY = new Double(l_y2); if (b_impliedZeroSubtrahend) { l_x3 = l_subtrahendCurX.doubleValue(); l_y3 = l_subtrahendCurY.doubleValue(); l_x4 = l_subtrahendNextX.doubleValue(); l_y4 = l_subtrahendNextY.doubleValue(); } else { l_x3 = x_dataset.getXValue(1, l_subtrahendItem); l_y3 = x_dataset.getYValue(1, l_subtrahendItem); l_x4 = x_dataset.getXValue(1, l_subtrahendItem + 1); l_y4 = x_dataset.getYValue(1, l_subtrahendItem + 1); l_subtrahendCurX = new Double(l_x3); l_subtrahendCurY = new Double(l_y3); l_subtrahendNextX = new Double(l_x4); l_subtrahendNextY = new Double(l_y4); } if (l_x2 <= l_x3) { // minuend needs to be fast forwarded l_minuendItem++; b_minuendFastForward = true; continue; } if (l_x4 <= l_x1) { // subtrahend needs to be fast forwarded l_subtrahendItem++; b_subtrahendFastForward = true; continue; } // check if initial polygon needs to be clipped if ((l_x3 < l_x1) && (l_x1 < l_x4)) { // project onto subtrahend double l_slope = (l_y4 - l_y3) / (l_x4 - l_x3); l_subtrahendCurX = l_minuendCurX; l_subtrahendCurY = new Double((l_slope * l_x1) + (l_y3 - (l_slope * l_x3))); l_subtrahendXs.add(l_subtrahendCurX); l_subtrahendYs.add(l_subtrahendCurY); } if ((l_x1 < l_x3) && (l_x3 < l_x2)) { // project onto minuend double l_slope = (l_y2 - l_y1) / (l_x2 - l_x1); l_minuendCurX = l_subtrahendCurX; l_minuendCurY = new Double((l_slope * l_x3) + (l_y1 - (l_slope * l_x1))); l_minuendXs.add(l_minuendCurX); l_minuendYs.add(l_minuendCurY); } l_minuendMaxY = l_minuendCurY.doubleValue(); l_minuendMinY = l_minuendCurY.doubleValue(); l_subtrahendMaxY = l_subtrahendCurY.doubleValue(); l_subtrahendMinY = l_subtrahendCurY.doubleValue(); b_fastForwardDone = true; } // start of algorithm while (!b_minuendDone && !b_subtrahendDone) { if (!b_minuendDone && !b_minuendFastForward && b_minuendAdvanced) { l_x1 = x_dataset.getXValue(0, l_minuendItem); l_y1 = x_dataset.getYValue(0, l_minuendItem); l_minuendCurX = new Double(l_x1); l_minuendCurY = new Double(l_y1); if (!b_minuendAtIntersect) { l_minuendXs.add(l_minuendCurX); l_minuendYs.add(l_minuendCurY); } l_minuendMaxY = Math.max(l_minuendMaxY, l_y1); l_minuendMinY = Math.min(l_minuendMinY, l_y1); l_x2 = x_dataset.getXValue(0, l_minuendItem + 1); l_y2 = x_dataset.getYValue(0, l_minuendItem + 1); l_minuendNextX = new Double(l_x2); l_minuendNextY = new Double(l_y2); } // never updated the subtrahend if it is implied to be zero if (!b_impliedZeroSubtrahend && !b_subtrahendDone && !b_subtrahendFastForward && b_subtrahendAdvanced) { l_x3 = x_dataset.getXValue(1, l_subtrahendItem); l_y3 = x_dataset.getYValue(1, l_subtrahendItem); l_subtrahendCurX = new Double(l_x3); l_subtrahendCurY = new Double(l_y3); if (!b_subtrahendAtIntersect) { l_subtrahendXs.add(l_subtrahendCurX); l_subtrahendYs.add(l_subtrahendCurY); } l_subtrahendMaxY = Math.max(l_subtrahendMaxY, l_y3); l_subtrahendMinY = Math.min(l_subtrahendMinY, l_y3); l_x4 = x_dataset.getXValue(1, l_subtrahendItem + 1); l_y4 = x_dataset.getYValue(1, l_subtrahendItem + 1); l_subtrahendNextX = new Double(l_x4); l_subtrahendNextY = new Double(l_y4); } // deassert b_*FastForward (only matters for 1st time through loop) b_minuendFastForward = false; b_subtrahendFastForward = false; Double l_intersectX = null; Double l_intersectY = null; boolean b_intersect = false; b_minuendAtIntersect = false; b_subtrahendAtIntersect = false; // check for intersect if ((l_x2 == l_x4) && (l_y2 == l_y4)) { // check if line segments are colinear if ((l_x1 == l_x3) && (l_y1 == l_y3)) { b_colinear = true; } else { // the intersect is at the next point for both the minuend // and subtrahend l_intersectX = new Double(l_x2); l_intersectY = new Double(l_y2); b_intersect = true; b_minuendAtIntersect = true; b_subtrahendAtIntersect = true; } } else { // compute common denominator double l_denominator = ((l_y4 - l_y3) * (l_x2 - l_x1)) - ((l_x4 - l_x3) * (l_y2 - l_y1)); // compute common deltas double l_deltaY = l_y1 - l_y3; double l_deltaX = l_x1 - l_x3; // compute numerators double l_numeratorA = ((l_x4 - l_x3) * l_deltaY) - ((l_y4 - l_y3) * l_deltaX); double l_numeratorB = ((l_x2 - l_x1) * l_deltaY) - ((l_y2 - l_y1) * l_deltaX); // check if line segments are colinear if ((0 == l_numeratorA) && (0 == l_numeratorB) && (0 == l_denominator)) { b_colinear = true; } else { // check if previously colinear if (b_colinear) { // clear colinear points and flag l_minuendXs.clear(); l_minuendYs.clear(); l_subtrahendXs.clear(); l_subtrahendYs.clear(); l_polygonXs.clear(); l_polygonYs.clear(); b_colinear = false; // set new starting point for the polygon boolean b_useMinuend = ((l_x3 <= l_x1) && (l_x1 <= l_x4)); l_polygonXs.add(b_useMinuend ? l_minuendCurX : l_subtrahendCurX); l_polygonYs.add(b_useMinuend ? l_minuendCurY : l_subtrahendCurY); } // compute slope components double l_slopeA = l_numeratorA / l_denominator; double l_slopeB = l_numeratorB / l_denominator; // check if the line segments intersect if ((0 < l_slopeA) && (l_slopeA <= 1) && (0 < l_slopeB) && (l_slopeB <= 1)) { // compute the point of intersection double l_xi = l_x1 + (l_slopeA * (l_x2 - l_x1)); double l_yi = l_y1 + (l_slopeA * (l_y2 - l_y1)); l_intersectX = new Double(l_xi); l_intersectY = new Double(l_yi); b_intersect = true; b_minuendAtIntersect = ((l_xi == l_x2) && (l_yi == l_y2)); b_subtrahendAtIntersect = ((l_xi == l_x4) && (l_yi == l_y4)); // advance minuend and subtrahend to intesect l_minuendCurX = l_intersectX; l_minuendCurY = l_intersectY; l_subtrahendCurX = l_intersectX; l_subtrahendCurY = l_intersectY; } } } if (b_intersect) { // create the polygon // add the minuend's points to polygon l_polygonXs.addAll(l_minuendXs); l_polygonYs.addAll(l_minuendYs); // add intersection point to the polygon l_polygonXs.add(l_intersectX); l_polygonYs.add(l_intersectY); // add the subtrahend's points to the polygon in reverse Collections.reverse(l_subtrahendXs); Collections.reverse(l_subtrahendYs); l_polygonXs.addAll(l_subtrahendXs); l_polygonYs.addAll(l_subtrahendYs); // create an actual polygon b_positive = (l_subtrahendMaxY <= l_minuendMaxY) && (l_subtrahendMinY <= l_minuendMinY); createPolygon(x_graphics, x_dataArea, x_plot, x_domainAxis, x_rangeAxis, b_positive, l_polygonXs, l_polygonYs); // clear the point vectors l_minuendXs.clear(); l_minuendYs.clear(); l_subtrahendXs.clear(); l_subtrahendYs.clear(); l_polygonXs.clear(); l_polygonYs.clear(); // set the maxY and minY values to intersect y-value double l_y = l_intersectY.doubleValue(); l_minuendMaxY = l_y; l_subtrahendMaxY = l_y; l_minuendMinY = l_y; l_subtrahendMinY = l_y; // add interection point to new polygon l_polygonXs.add(l_intersectX); l_polygonYs.add(l_intersectY); } // advance the minuend if needed if (l_x2 <= l_x4) { l_minuendItem++; b_minuendAdvanced = true; } else { b_minuendAdvanced = false; } // advance the subtrahend if needed if (l_x4 <= l_x2) { l_subtrahendItem++; b_subtrahendAdvanced = true; } else { b_subtrahendAdvanced = false; } b_minuendDone = (l_minuendItem == (l_minuendItemCount - 1)); b_subtrahendDone = (l_subtrahendItem == (l_subtrahendItemCount - 1)); } // check if the final polygon needs to be clipped if (b_minuendDone && (l_x3 < l_x2) && (l_x2 < l_x4)) { // project onto subtrahend double l_slope = (l_y4 - l_y3) / (l_x4 - l_x3); l_subtrahendNextX = l_minuendNextX; l_subtrahendNextY = new Double((l_slope * l_x2) + (l_y3 - (l_slope * l_x3))); } if (b_subtrahendDone && (l_x1 < l_x4) && (l_x4 < l_x2)) { // project onto minuend double l_slope = (l_y2 - l_y1) / (l_x2 - l_x1); l_minuendNextX = l_subtrahendNextX; l_minuendNextY = new Double((l_slope * l_x4) + (l_y1 - (l_slope * l_x1))); } // consider last point of minuend and subtrahend for determining // positivity l_minuendMaxY = Math.max(l_minuendMaxY, l_minuendNextY.doubleValue()); l_subtrahendMaxY = Math.max(l_subtrahendMaxY, l_subtrahendNextY.doubleValue()); l_minuendMinY = Math.min(l_minuendMinY, l_minuendNextY.doubleValue()); l_subtrahendMinY = Math.min(l_subtrahendMinY, l_subtrahendNextY.doubleValue()); // add the last point of the minuned and subtrahend l_minuendXs.add(l_minuendNextX); l_minuendYs.add(l_minuendNextY); l_subtrahendXs.add(l_subtrahendNextX); l_subtrahendYs.add(l_subtrahendNextY); // create the polygon // add the minuend's points to polygon l_polygonXs.addAll(l_minuendXs); l_polygonYs.addAll(l_minuendYs); // add the subtrahend's points to the polygon in reverse Collections.reverse(l_subtrahendXs); Collections.reverse(l_subtrahendYs); l_polygonXs.addAll(l_subtrahendXs); l_polygonYs.addAll(l_subtrahendYs); // create an actual polygon b_positive = (l_subtrahendMaxY <= l_minuendMaxY) && (l_subtrahendMinY <= l_minuendMinY); createPolygon(x_graphics, x_dataArea, x_plot, x_domainAxis, x_rangeAxis, b_positive, l_polygonXs, l_polygonYs); } /** * Draws the visual representation of a single data item, second pass. In * the second pass, the renderer draws the lines and shapes for the * individual points in the two series. * * @param x_graphics the graphics device. * @param x_dataArea the area within which the data is being drawn. * @param x_info collects information about the drawing. * @param x_plot the plot (can be used to obtain standard color * information etc). * @param x_domainAxis the domain (horizontal) axis. * @param x_rangeAxis the range (vertical) axis. * @param x_dataset the dataset. * @param x_series the series index (zero-based). * @param x_item the item index (zero-based). * @param x_crosshairState crosshair information for the plot * (null permitted). */ protected void drawItemPass1(Graphics2D x_graphics, Rectangle2D x_dataArea, PlotRenderingInfo x_info, XYPlot x_plot, ValueAxis x_domainAxis, ValueAxis x_rangeAxis, XYDataset x_dataset, int x_series, int x_item, CrosshairState x_crosshairState) { Shape l_entityArea = null; EntityCollection l_entities = null; if (null != x_info) { l_entities = x_info.getOwner().getEntityCollection(); } Paint l_seriesPaint = getItemPaint(x_series, x_item); Stroke l_seriesStroke = getItemStroke(x_series, x_item); x_graphics.setPaint(l_seriesPaint); x_graphics.setStroke(l_seriesStroke); PlotOrientation l_orientation = x_plot.getOrientation(); RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge(); RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge(); double l_x0 = x_dataset.getXValue(x_series, x_item); double l_y0 = x_dataset.getYValue(x_series, x_item); double l_x1 = x_domainAxis.valueToJava2D(l_x0, x_dataArea, l_domainAxisLocation); double l_y1 = x_rangeAxis.valueToJava2D(l_y0, x_dataArea, l_rangeAxisLocation); if (getShapesVisible()) { Shape l_shape = getItemShape(x_series, x_item); if (l_orientation == PlotOrientation.HORIZONTAL) { l_shape = ShapeUtilities.createTranslatedShape(l_shape, l_y1, l_x1); } else { l_shape = ShapeUtilities.createTranslatedShape(l_shape, l_x1, l_y1); } if (l_shape.intersects(x_dataArea)) { x_graphics.setPaint(getItemPaint(x_series, x_item)); x_graphics.fill(l_shape); } l_entityArea = l_shape; } // add an entity for the item... if (null != l_entities) { if (null == l_entityArea) { l_entityArea = new Rectangle2D.Double((l_x1 - 2), (l_y1 - 2), 4, 4); } String l_tip = null; XYToolTipGenerator l_tipGenerator = getToolTipGenerator(x_series, x_item); if (null != l_tipGenerator) { l_tip = l_tipGenerator.generateToolTip(x_dataset, x_series, x_item); } String l_url = null; XYURLGenerator l_urlGenerator = getURLGenerator(); if (null != l_urlGenerator) { l_url = l_urlGenerator.generateURL(x_dataset, x_series, x_item); } XYItemEntity l_entity = new XYItemEntity(l_entityArea, x_dataset, x_series, x_item, l_tip, l_url); l_entities.add(l_entity); } // draw the item label if there is one... if (isItemLabelVisible(x_series, x_item)) { drawItemLabel(x_graphics, l_orientation, x_dataset, x_series, x_item, l_x1, l_y1, (l_y1 < 0.0)); } int l_domainAxisIndex = x_plot.getDomainAxisIndex(x_domainAxis); int l_rangeAxisIndex = x_plot.getRangeAxisIndex(x_rangeAxis); updateCrosshairValues(x_crosshairState, l_x0, l_y0, l_domainAxisIndex, l_rangeAxisIndex, l_x1, l_y1, l_orientation); if (0 == x_item) { return; } double l_x2 = x_domainAxis.valueToJava2D(x_dataset.getXValue(x_series, (x_item - 1)), x_dataArea, l_domainAxisLocation); double l_y2 = x_rangeAxis.valueToJava2D(x_dataset.getYValue(x_series, (x_item - 1)), x_dataArea, l_rangeAxisLocation); Line2D l_line = null; if (PlotOrientation.HORIZONTAL == l_orientation) { l_line = new Line2D.Double(l_y1, l_x1, l_y2, l_x2); } else if (PlotOrientation.VERTICAL == l_orientation) { l_line = new Line2D.Double(l_x1, l_y1, l_x2, l_y2); } if ((null != l_line) && l_line.intersects(x_dataArea)) { x_graphics.setPaint(getItemPaint(x_series, x_item)); x_graphics.setStroke(getItemStroke(x_series, x_item)); x_graphics.draw(l_line); } } /** * Determines if a dataset is degenerate. A degenerate dataset is a * dataset where either series has less than two (2) points. * * @param x_dataset the dataset. * @param x_impliedZeroSubtrahend if false, do not check the subtrahend * * @return true if the dataset is degenerate. */ private boolean isEitherSeriesDegenerate(XYDataset x_dataset, boolean x_impliedZeroSubtrahend) { if (x_impliedZeroSubtrahend) { return (x_dataset.getItemCount(0) < 2); } return ((x_dataset.getItemCount(0) < 2) || (x_dataset.getItemCount(1) < 2)); } /** * Determines if the two (2) series are disjoint. * Disjoint series do not overlap in the domain space. * * @param x_dataset the dataset. * * @return true if the dataset is degenerate. */ private boolean areSeriesDisjoint(XYDataset x_dataset) { int l_minuendItemCount = x_dataset.getItemCount(0); double l_minuendFirst = x_dataset.getXValue(0, 0); double l_minuendLast = x_dataset.getXValue(0, l_minuendItemCount - 1); int l_subtrahendItemCount = x_dataset.getItemCount(1); double l_subtrahendFirst = x_dataset.getXValue(1, 0); double l_subtrahendLast = x_dataset.getXValue(1, l_subtrahendItemCount - 1); return ((l_minuendLast < l_subtrahendFirst) || (l_subtrahendLast < l_minuendFirst)); } /** * Draws the visual representation of a polygon * * @param x_graphics the graphics device. * @param x_dataArea the area within which the data is being drawn. * @param x_plot the plot (can be used to obtain standard color * information etc). * @param x_domainAxis the domain (horizontal) axis. * @param x_rangeAxis the range (vertical) axis. * @param x_positive indicates if the polygon is positive (true) or * negative (false). * @param x_xValues a linked list of the x values (expects values to be * of type Double). * @param x_yValues a linked list of the y values (expects values to be * of type Double). */ private void createPolygon (Graphics2D x_graphics, Rectangle2D x_dataArea, XYPlot x_plot, ValueAxis x_domainAxis, ValueAxis x_rangeAxis, boolean x_positive, LinkedList x_xValues, LinkedList x_yValues) { PlotOrientation l_orientation = x_plot.getOrientation(); RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge(); RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge(); Object[] l_xValues = x_xValues.toArray(); Object[] l_yValues = x_yValues.toArray(); GeneralPath l_path = new GeneralPath(); if (PlotOrientation.VERTICAL == l_orientation) { double l_x = x_domainAxis.valueToJava2D(( (Double) l_xValues[0]).doubleValue(), x_dataArea, l_domainAxisLocation); if (this.roundXCoordinates) { l_x = Math.rint(l_x); } double l_y = x_rangeAxis.valueToJava2D(( (Double) l_yValues[0]).doubleValue(), x_dataArea, l_rangeAxisLocation); l_path.moveTo((float) l_x, (float) l_y); for (int i = 1; i < l_xValues.length; i++) { l_x = x_domainAxis.valueToJava2D(( (Double) l_xValues[i]).doubleValue(), x_dataArea, l_domainAxisLocation); if (this.roundXCoordinates) { l_x = Math.rint(l_x); } l_y = x_rangeAxis.valueToJava2D(( (Double) l_yValues[i]).doubleValue(), x_dataArea, l_rangeAxisLocation); l_path.lineTo((float) l_x, (float) l_y); } l_path.closePath(); } else { double l_x = x_domainAxis.valueToJava2D(( (Double) l_xValues[0]).doubleValue(), x_dataArea, l_domainAxisLocation); if (this.roundXCoordinates) { l_x = Math.rint(l_x); } double l_y = x_rangeAxis.valueToJava2D(( (Double) l_yValues[0]).doubleValue(), x_dataArea, l_rangeAxisLocation); l_path.moveTo((float) l_y, (float) l_x); for (int i = 1; i < l_xValues.length; i++) { l_x = x_domainAxis.valueToJava2D(( (Double) l_xValues[i]).doubleValue(), x_dataArea, l_domainAxisLocation); if (this.roundXCoordinates) { l_x = Math.rint(l_x); } l_y = x_rangeAxis.valueToJava2D(( (Double) l_yValues[i]).doubleValue(), x_dataArea, l_rangeAxisLocation); l_path.lineTo((float) l_y, (float) l_x); } l_path.closePath(); } if (l_path.intersects(x_dataArea)) { x_graphics.setPaint(x_positive ? getPositivePaint() : getNegativePaint()); x_graphics.fill(l_path); } } /** * Returns a default legend item for the specified series. Subclasses * should override this method to generate customised items. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem result = null; XYPlot p = getPlot(); if (p != null) { XYDataset dataset = p.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Paint paint = lookupSeriesPaint(series); Stroke stroke = lookupSeriesStroke(series); Shape line = getLegendLine(); result = new LegendItem(label, description, toolTipText, urlText, line, stroke, paint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); } } } return result; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYDifferenceRenderer)) { return false; } if (!super.equals(obj)) { return false; } XYDifferenceRenderer that = (XYDifferenceRenderer) obj; if (!PaintUtilities.equal(this.positivePaint, that.positivePaint)) { return false; } if (!PaintUtilities.equal(this.negativePaint, that.negativePaint)) { return false; } if (this.shapesVisible != that.shapesVisible) { return false; } if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { return false; } if (this.roundXCoordinates != that.roundXCoordinates) { return false; } return true; } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { XYDifferenceRenderer clone = (XYDifferenceRenderer) super.clone(); clone.legendLine = ShapeUtilities.clone(this.legendLine); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.positivePaint, stream); SerialUtilities.writePaint(this.negativePaint, stream); SerialUtilities.writeShape(this.legendLine, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.positivePaint = SerialUtilities.readPaint(stream); this.negativePaint = SerialUtilities.readPaint(stream); this.legendLine = SerialUtilities.readShape(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYDotRenderer.java0000644000175000017500000003274711173030414030255 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * XYDotRenderer.java * ------------------ * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Christian W. Zuckschwerdt; * * Changes (from 29-Oct-2002) * -------------------------- * 29-Oct-2002 : Added standard header (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 30-Jul-2003 : Modified entity constructor (CZ); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 19-Jan-2005 : Now uses only primitives from dataset (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 10-Jul-2006 : Added dotWidth and dotHeight attributes (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 09-Nov-2007 : Added legend shape attribute, plus override for * getLegendItem() (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that draws a small dot at each data point for an {@link XYPlot}. * The example shown here is generated by the * ScatterPlotDemo4.java program included in the JFreeChart * demo collection: *

* XYDotRendererSample.png */ public class XYDotRenderer extends AbstractXYItemRenderer implements XYItemRenderer, PublicCloneable { /** For serialization. */ private static final long serialVersionUID = -2764344339073566425L; /** The dot width. */ private int dotWidth; /** The dot height. */ private int dotHeight; /** * The shape that is used to represent an item in the legend. * * @since 1.0.7 */ private transient Shape legendShape; /** * Constructs a new renderer. */ public XYDotRenderer() { super(); this.dotWidth = 1; this.dotHeight = 1; this.legendShape = new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0); } /** * Returns the dot width (the default value is 1). * * @return The dot width. * * @since 1.0.2 * @see #setDotWidth(int) */ public int getDotWidth() { return this.dotWidth; } /** * Sets the dot width and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param w the new width (must be greater than zero). * * @throws IllegalArgumentException if w is less than one. * * @since 1.0.2 * @see #getDotWidth() */ public void setDotWidth(int w) { if (w < 1) { throw new IllegalArgumentException("Requires w > 0."); } this.dotWidth = w; fireChangeEvent(); } /** * Returns the dot height (the default value is 1). * * @return The dot height. * * @since 1.0.2 * @see #setDotHeight(int) */ public int getDotHeight() { return this.dotHeight; } /** * Sets the dot height and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param h the new height (must be greater than zero). * * @throws IllegalArgumentException if h is less than one. * * @since 1.0.2 * @see #getDotHeight() */ public void setDotHeight(int h) { if (h < 1) { throw new IllegalArgumentException("Requires h > 0."); } this.dotHeight = h; fireChangeEvent(); } /** * Returns the shape used to represent an item in the legend. * * @return The legend shape (never null). * * @see #setLegendShape(Shape) * * @since 1.0.7 */ public Shape getLegendShape() { return this.legendShape; } /** * Sets the shape used as a line in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null not permitted). * * @see #getLegendShape() * * @since 1.0.7 */ public void setLegendShape(Shape shape) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.legendShape = shape; fireChangeEvent(); } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain (horizontal) axis. * @param rangeAxis the range (vertical) axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // do nothing if item is not visible if (!getItemVisible(series, item)) { return; } // get the data point... double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double adjx = (this.dotWidth - 1) / 2.0; double adjy = (this.dotHeight - 1) / 2.0; if (!Double.isNaN(y)) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx; double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy; g2.setPaint(getItemPaint(series, item)); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { g2.fillRect((int) transY, (int) transX, this.dotHeight, this.dotWidth); } else if (orientation == PlotOrientation.VERTICAL) { g2.fillRect((int) transX, (int) transY, this.dotWidth, this.dotHeight); } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } } /** * Returns a legend item for the specified series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series (possibly null). */ public LegendItem getLegendItem(int datasetIndex, int series) { // if the renderer isn't assigned to a plot, then we don't have a // dataset... XYPlot plot = getPlot(); if (plot == null) { return null; } XYDataset dataset = plot.getDataset(datasetIndex); if (dataset == null) { return null; } LegendItem result = null; if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } Paint fillPaint = lookupSeriesPaint(series); result = new LegendItem(label, description, toolTipText, urlText, getLegendShape(), fillPaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); } return result; } /** * Tests this renderer for equality with an arbitrary object. This method * returns true if and only if: * *

    *
  • obj is not null;
  • *
  • obj is an instance of XYDotRenderer;
  • *
  • both renderers have the same attribute values. *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYDotRenderer)) { return false; } XYDotRenderer that = (XYDotRenderer) obj; if (this.dotWidth != that.dotWidth) { return false; } if (this.dotHeight != that.dotHeight) { return false; } if (!ShapeUtilities.equal(this.legendShape, that.legendShape)) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendShape = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendShape, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYErrorRenderer.java0000644000175000017500000003732411173030414030614 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYErrorRenderer.java * -------------------- * (C) Copyright 2006-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Oct-2006 : Version 1 (DG); * 23-Mar-2007 : Check item visibility before drawing error bars - see bug * 1686178 (DG); * 28-Jan-2009 : Added stroke options for error indicators (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A line and shape renderer that can also display x and/or y-error values. * This renderer expects an {@link IntervalXYDataset}, otherwise it reverts * to the behaviour of the super class. The example shown here is generated by * the XYErrorRendererDemo1.java program included in the * JFreeChart demo collection: *

* XYErrorRendererSample.png * * @since 1.0.3 */ public class XYErrorRenderer extends XYLineAndShapeRenderer { /** For serialization. */ static final long serialVersionUID = 5162283570955172424L; /** A flag that controls whether or not the x-error bars are drawn. */ private boolean drawXError; /** A flag that controls whether or not the y-error bars are drawn. */ private boolean drawYError; /** The length of the cap at the end of the error bars. */ private double capLength; /** * The paint used to draw the error bars (if null we use the * series paint). */ private transient Paint errorPaint; /** * The stroke used to draw the error bars (if null we use the * series outline stroke). * * @since 1.0.13 */ private transient Stroke errorStroke; /** * Creates a new XYErrorRenderer instance. */ public XYErrorRenderer() { super(false, true); this.drawXError = true; this.drawYError = true; this.errorPaint = null; this.errorStroke = null; this.capLength = 4.0; } /** * Returns the flag that controls whether or not the renderer draws error * bars for the x-values. * * @return A boolean. * * @see #setDrawXError(boolean) */ public boolean getDrawXError() { return this.drawXError; } /** * Sets the flag that controls whether or not the renderer draws error * bars for the x-values and, if the flag changes, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param draw the flag value. * * @see #getDrawXError() */ public void setDrawXError(boolean draw) { if (this.drawXError != draw) { this.drawXError = draw; fireChangeEvent(); } } /** * Returns the flag that controls whether or not the renderer draws error * bars for the y-values. * * @return A boolean. * * @see #setDrawYError(boolean) */ public boolean getDrawYError() { return this.drawYError; } /** * Sets the flag that controls whether or not the renderer draws error * bars for the y-values and, if the flag changes, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param draw the flag value. * * @see #getDrawYError() */ public void setDrawYError(boolean draw) { if (this.drawYError != draw) { this.drawYError = draw; fireChangeEvent(); } } /** * Returns the length (in Java2D units) of the cap at the end of the error * bars. * * @return The cap length. * * @see #setCapLength(double) */ public double getCapLength() { return this.capLength; } /** * Sets the length of the cap at the end of the error bars, and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param length the length (in Java2D units). * * @see #getCapLength() */ public void setCapLength(double length) { this.capLength = length; fireChangeEvent(); } /** * Returns the paint used to draw the error bars. If this is * null (the default), the item paint is used instead. * * @return The paint (possibly null). * * @see #setErrorPaint(Paint) */ public Paint getErrorPaint() { return this.errorPaint; } /** * Sets the paint used to draw the error bars and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getErrorPaint() */ public void setErrorPaint(Paint paint) { this.errorPaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the error bars. If this is * null (the default), the item outline stroke is used * instead. * * @return The stroke (possibly null). * * @see #setErrorStroke(Stroke) * * @since 1.0.13 */ public Stroke getErrorStroke() { return this.errorStroke; } /** * Sets the stroke used to draw the error bars and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @see #getErrorStroke() * * @since 1.0.13 */ public void setErrorStroke(Stroke stroke) { this.errorStroke = stroke; fireChangeEvent(); } /** * Returns the range required by this renderer to display all the domain * values in the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range, or null if the dataset is * null. */ public Range findDomainBounds(XYDataset dataset) { if (dataset != null) { return DatasetUtilities.findDomainBounds(dataset, true); } else { return null; } } /** * Returns the range required by this renderer to display all the range * values in the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range, or null if the dataset is * null. */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { return DatasetUtilities.findRangeBounds(dataset, true); } else { return null; } } /** * Draws the visual representation for one data item. * * @param g2 the graphics output target. * @param state the renderer state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (pass == 0 && dataset instanceof IntervalXYDataset && getItemVisible(series, item)) { IntervalXYDataset ixyd = (IntervalXYDataset) dataset; PlotOrientation orientation = plot.getOrientation(); if (this.drawXError) { // draw the error bar for the x-interval double x0 = ixyd.getStartXValue(series, item); double x1 = ixyd.getEndXValue(series, item); double y = ixyd.getYValue(series, item); RectangleEdge edge = plot.getDomainAxisEdge(); double xx0 = domainAxis.valueToJava2D(x0, dataArea, edge); double xx1 = domainAxis.valueToJava2D(x1, dataArea, edge); double yy = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); Line2D line; Line2D cap1 = null; Line2D cap2 = null; double adj = this.capLength / 2.0; if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(xx0, yy, xx1, yy); cap1 = new Line2D.Double(xx0, yy - adj, xx0, yy + adj); cap2 = new Line2D.Double(xx1, yy - adj, xx1, yy + adj); } else { // PlotOrientation.HORIZONTAL line = new Line2D.Double(yy, xx0, yy, xx1); cap1 = new Line2D.Double(yy - adj, xx0, yy + adj, xx0); cap2 = new Line2D.Double(yy - adj, xx1, yy + adj, xx1); } if (this.errorPaint != null) { g2.setPaint(this.errorPaint); } else { g2.setPaint(getItemPaint(series, item)); } if (this.errorStroke != null) { g2.setStroke(this.errorStroke); } else { g2.setStroke(getItemStroke(series, item)); } g2.draw(line); g2.draw(cap1); g2.draw(cap2); } if (this.drawYError) { // draw the error bar for the y-interval double y0 = ixyd.getStartYValue(series, item); double y1 = ixyd.getEndYValue(series, item); double x = ixyd.getXValue(series, item); RectangleEdge edge = plot.getRangeAxisEdge(); double yy0 = rangeAxis.valueToJava2D(y0, dataArea, edge); double yy1 = rangeAxis.valueToJava2D(y1, dataArea, edge); double xx = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); Line2D line; Line2D cap1 = null; Line2D cap2 = null; double adj = this.capLength / 2.0; if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(xx, yy0, xx, yy1); cap1 = new Line2D.Double(xx - adj, yy0, xx + adj, yy0); cap2 = new Line2D.Double(xx - adj, yy1, xx + adj, yy1); } else { // PlotOrientation.HORIZONTAL line = new Line2D.Double(yy0, xx, yy1, xx); cap1 = new Line2D.Double(yy0, xx - adj, yy0, xx + adj); cap2 = new Line2D.Double(yy1, xx - adj, yy1, xx + adj); } if (this.errorPaint != null) { g2.setPaint(this.errorPaint); } else { g2.setPaint(getItemPaint(series, item)); } if (this.errorStroke != null) { g2.setStroke(this.errorStroke); } else { g2.setStroke(getItemStroke(series, item)); } g2.draw(line); g2.draw(cap1); g2.draw(cap2); } } super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYErrorRenderer)) { return false; } XYErrorRenderer that = (XYErrorRenderer) obj; if (this.drawXError != that.drawXError) { return false; } if (this.drawYError != that.drawYError) { return false; } if (this.capLength != that.capLength) { return false; } if (!PaintUtilities.equal(this.errorPaint, that.errorPaint)) { return false; } if (!ObjectUtilities.equal(this.errorStroke, that.errorStroke)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.errorPaint = SerialUtilities.readPaint(stream); this.errorStroke = SerialUtilities.readStroke(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.errorPaint, stream); SerialUtilities.writeStroke(this.errorStroke, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYItemRenderer.java0000644000175000017500000017556311173030414030431 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * XYItemRenderer.java * ------------------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Mark Watson (www.markwatson.com); * Sylvain Vieujot; * Focus Computer Services Limited; * Richard Atkinson; * * Changes * ------- * 19-Oct-2001 : Version 1, based on code by Mark Watson (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 13-Dec-2001 : Changed return type of drawItem from void --> Shape. The area * returned can be used as the tooltip region. * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); * 28-Mar-2002 : Added a property change listener mechanism. Now renderers do * not have to be immutable (DG); * 04-Apr-2002 : Added the initialise() method (DG); * 09-Apr-2002 : Removed the translated zero from the drawItem method, it can * be calculated inside the initialise method if it is required. * Added a new getToolTipGenerator() method. Changed the return * type for drawItem() to void (DG); * 24-May-2002 : Added ChartRenderingInfo the initialise method API (DG); * 25-Jun-2002 : Removed redundant import (DG); * 20-Aug-2002 : Added get/setURLGenerator methods to interface (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 18-Nov-2002 : Added methods for drawing grid lines (DG); * 17-Jan-2003 : Moved plot classes into a separate package (DG); * 27-Jan-2003 : Added shape lookup table (DG); * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer * Services Ltd) (DG); * 27-Jul-2003 : Added getRangeType() to support stacked XY area charts (RA); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 26-Feb-2004 : Added lots of new methods (DG); * 30-Apr-2004 : Added getRangeExtent() method (DG); * 06-May-2004 : Added methods for controlling item label visibility (DG); * 13-May-2004 : Removed property change listener mechanism (DG); * 18-May-2004 : Added item label font and paint methods (DG); * 10-Sep-2004 : Removed redundant getRangeType() method (DG); * 06-Oct-2004 : Replaced getRangeExtent() with findRangeBounds() and added * findDomainBounds (DG); * 23-Nov-2004 : Changed drawRangeGridLine() --> drawRangeLine() (DG); * 07-Jan-2005 : Removed deprecated method (DG); * 24-Feb-2005 : Now extends LegendItemSource (DG); * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG); * 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke, * outlineStroke, shape, itemLabelsVisible, itemLabelFont, * itemLabelPaint, positiveItemLabelPosition, * negativeItemLabelPosition and createEntities override * fields (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemSource; import org.jfree.chart.annotations.XYAnnotation; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.labels.XYSeriesLabelGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.ui.Layer; /** * Interface for rendering the visual representation of a single (x, y) item on * an {@link XYPlot}. *

* To support cloning charts, it is recommended that renderers implement both * the {@link Cloneable} and PublicCloneable interfaces. */ public interface XYItemRenderer extends LegendItemSource { /** * Returns the plot that this renderer has been assigned to. * * @return The plot. */ public XYPlot getPlot(); /** * Sets the plot that this renderer is assigned to. This method will be * called by the plot class...you do not need to call it yourself. * * @param plot the plot. */ public void setPlot(XYPlot plot); /** * Returns the number of passes through the data required by the renderer. * * @return The pass count. */ public int getPassCount(); /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (null permitted). * * @return The range. */ public Range findDomainBounds(XYDataset dataset); /** * Returns the lower and upper bounds (range) of the y-values in the * specified dataset. The implementation of this method will take * into account the presentation used by the renderers (for example, * a renderer that "stacks" values will return a bigger range than * a renderer that doesn't). * * @param dataset the dataset (null permitted). * * @return The range (or null if the dataset is * null or empty). */ public Range findRangeBounds(XYDataset dataset); /** * Add a renderer change listener. * * @param listener the listener. * * @see #removeChangeListener(RendererChangeListener) */ public void addChangeListener(RendererChangeListener listener); /** * Removes a change listener. * * @param listener the listener. * * @see #addChangeListener(RendererChangeListener) */ public void removeChangeListener(RendererChangeListener listener); //// VISIBLE ////////////////////////////////////////////////////////////// /** * Returns a boolean that indicates whether or not the specified item * should be drawn (this is typically used to hide an entire series). * * @param series the series index. * @param item the item index. * * @return A boolean. */ public boolean getItemVisible(int series, int item); /** * Returns a boolean that indicates whether or not the specified series * should be drawn (this is typically used to hide an entire series). * * @param series the series index. * * @return A boolean. */ public boolean isSeriesVisible(int series); /** * Returns the flag that controls whether a series is visible. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesVisible(int, Boolean) */ public Boolean getSeriesVisible(int series); /** * Sets the flag that controls whether a series is visible and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #getSeriesVisible(int) */ public void setSeriesVisible(int series, Boolean visible); /** * Sets the flag that controls whether a series is visible and, if * requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisible(int) */ public void setSeriesVisible(int series, Boolean visible, boolean notify); /** * Returns the base visibility for all series. * * @return The base visibility. * * @see #setBaseSeriesVisible(boolean) */ public boolean getBaseSeriesVisible(); /** * Sets the base visibility and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param visible the flag. * * @see #getBaseSeriesVisible() */ public void setBaseSeriesVisible(boolean visible); /** * Sets the base visibility and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility. * @param notify notify listeners? * * @see #getBaseSeriesVisible() */ public void setBaseSeriesVisible(boolean visible, boolean notify); // SERIES VISIBLE IN LEGEND (not yet respected by all renderers) /** * Returns true if the series should be shown in the legend, * and false otherwise. * * @param series the series index. * * @return A boolean. */ public boolean isSeriesVisibleInLegend(int series); /** * Returns the flag that controls whether a series is visible in the * legend. This method returns only the "per series" settings - to * incorporate the override and base settings as well, you need to use the * {@link #isSeriesVisibleInLegend(int)} method. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesVisibleInLegend(int, Boolean) */ public Boolean getSeriesVisibleInLegend(int series); /** * Sets the flag that controls whether a series is visible in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #getSeriesVisibleInLegend(int) */ public void setSeriesVisibleInLegend(int series, Boolean visible); /** * Sets the flag that controls whether a series is visible in the legend * and, if requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisibleInLegend(int) */ public void setSeriesVisibleInLegend(int series, Boolean visible, boolean notify); /** * Returns the base visibility in the legend for all series. * * @return The base visibility. * * @see #setBaseSeriesVisibleInLegend(boolean) */ public boolean getBaseSeriesVisibleInLegend(); /** * Sets the base visibility in the legend and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getBaseSeriesVisibleInLegend() */ public void setBaseSeriesVisibleInLegend(boolean visible); /** * Sets the base visibility in the legend and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility. * @param notify notify listeners? * * @see #getBaseSeriesVisibleInLegend() */ public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify); //// PAINT //////////////////////////////////////////////////////////////// /** * Returns the paint used to fill data items as they are drawn. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemPaint(int row, int column); /** * Returns the paint used to fill an item drawn by the renderer. * * @param series the series index (zero-based). * * @return The paint (possibly null). * * @see #setSeriesPaint(int, Paint) */ public Paint getSeriesPaint(int series); /** * Sets the paint used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesPaint(int) */ public void setSeriesPaint(int series, Paint paint); // FIXME: add setSeriesPaint(int, Paint, boolean)? /** * Returns the base paint. * * @return The base paint (never null). * * @see #setBasePaint(Paint) */ public Paint getBasePaint(); /** * Sets the base paint and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getBasePaint() */ public void setBasePaint(Paint paint); // FIXME: add setBasePaint(int, Paint, boolean)? // // FILL PAINT // // /** // * Returns the paint used to fill data items as they are drawn. // * // * @param row the row (or series) index (zero-based). // * @param column the column (or category) index (zero-based). // * // * @return The paint (never null). // */ // public Paint getItemFillPaint(int row, int column); // // /** // * Returns the paint used to fill an item drawn by the renderer. // * // * @param series the series index (zero-based). // * // * @return The paint (possibly null). // */ // public Paint getSeriesFillPaint(int series); // // /** // * Sets the paint used for a series and sends a // * {@link RendererChangeEvent} to all registered listeners. // * // * @param series the series index (zero-based). // * @param paint the paint (null permitted). // */ // public void setSeriesFillPaint(int series, Paint paint); // // // FIXME: add setSeriesFillPaint(int, Paint, boolean)? // // /** // * Returns the base paint. // * // * @return The base paint (never null). // */ // public Paint getBaseFillPaint(); // // /** // * Sets the base paint and sends a {@link RendererChangeEvent} to all // * registered listeners. // * // * @param paint the paint (null not permitted). // */ // public void setBaseFillPaint(Paint paint); // // // FIXME: add setBaseFillPaint(int, Paint, boolean)? //// OUTLINE PAINT //////////////////////////////////////////////////////// /** * Returns the paint used to outline data items as they are drawn. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemOutlinePaint(int row, int column); /** * Returns the paint used to outline an item drawn by the renderer. * * @param series the series (zero-based index). * * @return The paint (possibly null). * * @see #setSeriesOutlinePaint(int, Paint) */ public Paint getSeriesOutlinePaint(int series); /** * Sets the paint used for a series outline and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesOutlinePaint(int) */ public void setSeriesOutlinePaint(int series, Paint paint); // FIXME: add setSeriesOutlinePaint(int, Paint, boolean)? /** * Returns the base outline paint. * * @return The paint (never null). * * @see #setBaseOutlinePaint(Paint) */ public Paint getBaseOutlinePaint(); /** * Sets the base outline paint and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseOutlinePaint() */ public void setBaseOutlinePaint(Paint paint); // FIXME: add setBaseOutlinePaint(Paint, boolean)? //// STROKE /////////////////////////////////////////////////////////////// /** * Returns the stroke used to draw data items. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The stroke (never null). */ public Stroke getItemStroke(int row, int column); /** * Returns the stroke used to draw the items in a series. * * @param series the series (zero-based index). * * @return The stroke (possibly null). * * @see #setSeriesStroke(int, Stroke) */ public Stroke getSeriesStroke(int series); /** * Sets the stroke used for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * * @see #getSeriesStroke(int) */ public void setSeriesStroke(int series, Stroke stroke); // FIXME: add setSeriesStroke(int, Stroke, boolean) ? /** * Returns the base stroke. * * @return The base stroke (never null). * * @see #setBaseStroke(Stroke) */ public Stroke getBaseStroke(); /** * Sets the base stroke and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getBaseStroke() */ public void setBaseStroke(Stroke stroke); // FIXME: add setBaseStroke(Stroke, boolean) ? //// OUTLINE STROKE /////////////////////////////////////////////////////// /** * Returns the stroke used to outline data items. The default * implementation passes control to the lookupSeriesOutlineStroke method. * You can override this method if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The stroke (never null). */ public Stroke getItemOutlineStroke(int row, int column); /** * Returns the stroke used to outline the items in a series. * * @param series the series (zero-based index). * * @return The stroke (possibly null). * * @see #setSeriesOutlineStroke(int, Stroke) */ public Stroke getSeriesOutlineStroke(int series); /** * Sets the outline stroke used for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * * @see #getSeriesOutlineStroke(int) */ public void setSeriesOutlineStroke(int series, Stroke stroke); // FIXME: add setSeriesOutlineStroke(int, Stroke, boolean) ? /** * Returns the base outline stroke. * * @return The stroke (never null). * * @see #setBaseOutlineStroke(Stroke) */ public Stroke getBaseOutlineStroke(); /** * Sets the base outline stroke and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getBaseOutlineStroke() */ public void setBaseOutlineStroke(Stroke stroke); // FIXME: add setBaseOutlineStroke(Stroke, boolean) ? //// SHAPE //////////////////////////////////////////////////////////////// /** * Returns a shape used to represent a data item. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The shape (never null). */ public Shape getItemShape(int row, int column); /** * Returns a shape used to represent the items in a series. * * @param series the series (zero-based index). * * @return The shape (possibly null). * * @see #setSeriesShape(int, Shape) */ public Shape getSeriesShape(int series); /** * Sets the shape used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param shape the shape (null permitted). * * @see #getSeriesShape(int) */ public void setSeriesShape(int series, Shape shape); // FIXME: add setSeriesShape(int, Shape, boolean) ? /** * Returns the base shape. * * @return The shape (never null). * * @see #setBaseShape(Shape) */ public Shape getBaseShape(); /** * Sets the base shape and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param shape the shape (null not permitted). * * @see #getBaseShape() */ public void setBaseShape(Shape shape); // FIXME: add setBaseShape(Shape, boolean) ? //// LEGEND ITEMS ///////////////////////////////////////////////////////// /** * Returns a legend item for a series from a dataset. * * @param datasetIndex the dataset index. * @param series the series (zero-based index). * * @return The legend item (possibly null). */ public LegendItem getLegendItem(int datasetIndex, int series); //// LEGEND ITEM LABEL GENERATOR ////////////////////////////////////////// /** * Returns the legend item label generator. * * @return The legend item label generator (never null). * * @see #setLegendItemLabelGenerator(XYSeriesLabelGenerator) */ public XYSeriesLabelGenerator getLegendItemLabelGenerator(); /** * Sets the legend item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null not permitted). */ public void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator); //// TOOL TIP GENERATOR /////////////////////////////////////////////////// /** * Returns the tool tip generator for a data item. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The generator (possibly null). */ public XYToolTipGenerator getToolTipGenerator(int row, int column); /** * Returns the tool tip generator for a series. * * @param series the series index (zero based). * * @return The generator (possibly null). * * @see #setSeriesToolTipGenerator(int, XYToolTipGenerator) */ public XYToolTipGenerator getSeriesToolTipGenerator(int series); /** * Sets the tool tip generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param generator the generator (null permitted). * * @see #getSeriesToolTipGenerator(int) */ public void setSeriesToolTipGenerator(int series, XYToolTipGenerator generator); /** * Returns the base tool tip generator. * * @return The generator (possibly null). * * @see #setBaseToolTipGenerator(XYToolTipGenerator) */ public XYToolTipGenerator getBaseToolTipGenerator(); /** * Sets the base tool tip generator and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param generator the generator (null permitted). * * @see #getBaseToolTipGenerator() */ public void setBaseToolTipGenerator(XYToolTipGenerator generator); //// URL GENERATOR //////////////////////////////////////////////////////// /** * Returns the URL generator for HTML image maps. * * @return The URL generator (possibly null). */ public XYURLGenerator getURLGenerator(); /** * Sets the URL generator for HTML image maps. * * @param urlGenerator the URL generator (null permitted). */ public void setURLGenerator(XYURLGenerator urlGenerator); //// ITEM LABELS VISIBLE ////////////////////////////////////////////////// /** * Returns true if an item label is visible, and * false otherwise. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return A boolean. */ public boolean isItemLabelVisible(int row, int column); /** * Returns true if the item labels for a series are visible, * and false otherwise. * * @param series the series index (zero-based). * * @return A boolean. */ public boolean isSeriesItemLabelsVisible(int series); /** * Sets a flag that controls the visibility of the item labels for a * series and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param visible the flag. * * @see #isSeriesItemLabelsVisible(int) */ public void setSeriesItemLabelsVisible(int series, boolean visible); /** * Sets a flag that controls the visibility of the item labels for a series. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #isSeriesItemLabelsVisible(int) */ public void setSeriesItemLabelsVisible(int series, Boolean visible); /** * Sets the visibility of item labels for a series and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the visible flag. * @param notify a flag that controls whether or not listeners are * notified. * * @see #isSeriesItemLabelsVisible(int) */ public void setSeriesItemLabelsVisible(int series, Boolean visible, boolean notify); /** * Returns the base setting for item label visibility. * * @return A flag (possibly null). * * @see #setBaseItemLabelsVisible(boolean) */ public Boolean getBaseItemLabelsVisible(); /** * Sets the base flag that controls whether or not item labels are visible. * * @param visible the flag. * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(boolean visible); /** * Sets the base setting for item label visibility. * * @param visible the flag (null permitted). * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(Boolean visible); /** * Sets the base visibility for item labels and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility flag. * @param notify a flag that controls whether or not listeners are * notified. * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(Boolean visible, boolean notify); //// ITEM LABEL GENERATOR ///////////////////////////////////////////////// /** * Returns the item label generator for a data item. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The generator (possibly null). */ public XYItemLabelGenerator getItemLabelGenerator(int row, int column); /** * Returns the item label generator for a series. * * @param series the series index (zero based). * * @return The generator (possibly null). * * @see #setSeriesItemLabelGenerator(int, XYItemLabelGenerator) */ public XYItemLabelGenerator getSeriesItemLabelGenerator(int series); /** * Sets the item label generator for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param generator the generator (null permitted). * * @see #getSeriesItemLabelGenerator(int) */ public void setSeriesItemLabelGenerator(int series, XYItemLabelGenerator generator); // FIXME: /** * Returns the base item label generator. * * @return The generator (possibly null). * * @see #setBaseItemLabelGenerator(XYItemLabelGenerator) */ public XYItemLabelGenerator getBaseItemLabelGenerator(); /** * Sets the base item label generator and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @see #getBaseItemLabelGenerator() */ public void setBaseItemLabelGenerator(XYItemLabelGenerator generator); //// ITEM LABEL FONT /////////////////////////////////////////////////////// /** * Returns the font for an item label. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The font (never null). */ public Font getItemLabelFont(int row, int column); /** * Returns the font for all the item labels in a series. * * @param series the series index (zero-based). * * @return The font (possibly null). */ public Font getSeriesItemLabelFont(int series); /** * Sets the item label font for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param font the font (null permitted). * * @see #getSeriesItemLabelFont(int) */ public void setSeriesItemLabelFont(int series, Font font); /** * Returns the base item label font (this is used when no other font * setting is available). * * @return The font (never null). * * @see #setBaseItemLabelFont(Font) */ public Font getBaseItemLabelFont(); /** * Sets the base item label font and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param font the font (null not permitted). * * @see #getBaseItemLabelFont() */ public void setBaseItemLabelFont(Font font); //// ITEM LABEL PAINT ///////////////////////////////////////////////////// /** * Returns the paint used to draw an item label. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The paint (never null). */ public Paint getItemLabelPaint(int row, int column); /** * Returns the paint used to draw the item labels for a series. * * @param series the series index (zero based). * * @return The paint (possibly null). * * @see #setSeriesItemLabelPaint(int, Paint) */ public Paint getSeriesItemLabelPaint(int series); /** * Sets the item label paint for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series (zero based index). * @param paint the paint (null permitted). * * @see #getSeriesItemLabelPaint(int) */ public void setSeriesItemLabelPaint(int series, Paint paint); /** * Returns the base item label paint. * * @return The paint (never null). */ public Paint getBaseItemLabelPaint(); /** * Sets the base item label paint and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param paint the paint (null not permitted). */ public void setBaseItemLabelPaint(Paint paint); // POSITIVE ITEM LABEL POSITION... /** * Returns the item label position for positive values. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The item label position (never null). */ public ItemLabelPosition getPositiveItemLabelPosition(int row, int column); /** * Returns the item label position for all positive values in a series. * * @param series the series index (zero-based). * * @return The item label position (never null). */ public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series); /** * Sets the item label position for all positive values in a series and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). */ public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position); /** * Sets the item label position for all positive values in a series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * @param notify notify registered listeners? */ public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position, boolean notify); /** * Returns the base positive item label position. * * @return The position (never null). */ public ItemLabelPosition getBasePositiveItemLabelPosition(); /** * Sets the base positive item label position. * * @param position the position (null not permitted). */ public void setBasePositiveItemLabelPosition(ItemLabelPosition position); /** * Sets the base positive item label position and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null not permitted). * @param notify notify registered listeners? */ public void setBasePositiveItemLabelPosition(ItemLabelPosition position, boolean notify); // NEGATIVE ITEM LABEL POSITION... /** * Returns the item label position for negative values. This method can be * overridden to provide customisation of the item label position for * individual data items. * * @param row the row index (zero-based). * @param column the column (zero-based). * * @return The item label position (never null). */ public ItemLabelPosition getNegativeItemLabelPosition(int row, int column); /** * Returns the item label position for all negative values in a series. * * @param series the series index (zero-based). * * @return The item label position (never null). */ public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series); /** * Sets the item label position for negative values in a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). */ public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position); /** * Sets the item label position for negative values in a series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * @param notify notify registered listeners? */ public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position, boolean notify); /** * Returns the base item label position for negative values. * * @return The position (never null). */ public ItemLabelPosition getBaseNegativeItemLabelPosition(); /** * Sets the base item label position for negative values and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null not permitted). */ public void setBaseNegativeItemLabelPosition(ItemLabelPosition position); /** * Sets the base negative item label position and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null not permitted). * @param notify notify registered listeners? */ public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, boolean notify); // CREATE ENTITIES // FIXME: these methods should be defined // public boolean getItemCreateEntity(int series, int item); // // public Boolean getSeriesCreateEntities(int series); // // public void setSeriesCreateEntities(int series, Boolean create); // // public void setSeriesCreateEntities(int series, Boolean create, // boolean notify); // // public boolean getBaseCreateEntities(); // // public void setBaseCreateEntities(boolean create); // // public void setBaseCreateEntities(boolean create, boolean notify); //// ANNOTATIONS ////////////////////////////////////////////////////////// /** * Adds an annotation and sends a {@link RendererChangeEvent} to all * registered listeners. The annotation is added to the foreground * layer. * * @param annotation the annotation (null not permitted). */ public void addAnnotation(XYAnnotation annotation); /** * Adds an annotation to the specified layer. * * @param annotation the annotation (null not permitted). * @param layer the layer (null not permitted). */ public void addAnnotation(XYAnnotation annotation, Layer layer); /** * Removes the specified annotation and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param annotation the annotation to remove (null not * permitted). * * @return A boolean to indicate whether or not the annotation was * successfully removed. */ public boolean removeAnnotation(XYAnnotation annotation); /** * Removes all annotations and sends a {@link RendererChangeEvent} * to all registered listeners. */ public void removeAnnotations(); /** * Draws all the annotations for the specified layer. * * @param g2 the graphics device. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param layer the layer. * @param info the plot rendering info. */ public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer, PlotRenderingInfo info); //// DRAWING ////////////////////////////////////////////////////////////// /** * Initialises the renderer then returns the number of 'passes' through the * data that the renderer will require (usually just one). This method * will be called before the first item is rendered, giving the renderer * an opportunity to initialise any state information it wants to maintain. * The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param dataset the dataset. * @param info an optional info collection object to return data back to * the caller. * * @return The number of passes the renderer requires. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset dataset, PlotRenderingInfo info); /** * Called for each item to be plotted. *

* The {@link XYPlot} can make multiple passes through the dataset, * depending on the value returned by the renderer's initialise() method. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being rendered. * @param info collects drawing info. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass); /** * Fills a band between two values on the axis. This can be used to color * bands between the grid lines. * * @param g2 the graphics device. * @param plot the plot. * @param axis the domain axis. * @param dataArea the data area. * @param start the start value. * @param end the end value. */ public void fillDomainGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end); /** * Fills a band between two values on the range axis. This can be used to * color bands between the grid lines. * * @param g2 the graphics device. * @param plot the plot. * @param axis the range axis. * @param dataArea the data area. * @param start the start value. * @param end the end value. */ public void fillRangeGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double start, double end); /** * Draws a grid line against the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the value. */ public void drawDomainGridLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value); /** * Draws a line perpendicular to the range axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param dataArea the area for plotting data. * @param value the data value. * @param paint the paint (null not permitted). * @param stroke the stroke (null not permitted). */ public void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis, Rectangle2D dataArea, double value, Paint paint, Stroke stroke); /** * Draws the specified marker against the domain axis. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param marker the marker. * @param dataArea the axis data area. */ public void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea); /** * Draws a horizontal line across the chart to represent a 'range marker'. * * @param g2 the graphics device. * @param plot the plot. * @param axis the value axis. * @param marker the marker line. * @param dataArea the axis data area. */ public void drawRangeMarker(Graphics2D g2, XYPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea); // DEPRECATED METHODS /** * Returns the flag that controls the visibility of ALL series. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @return The flag (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesVisible(int)} and * {@link #getBaseSeriesVisible()}. */ public Boolean getSeriesVisible(); /** * Sets the flag that controls the visibility of ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @param visible the flag (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} * and {@link #setBaseSeriesVisible(boolean)}. */ public void setSeriesVisible(Boolean visible); /** * Sets the flag that controls the visibility of ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @param visible the flag (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean, * boolean)} and {@link #setBaseSeriesVisible(boolean, boolean)}. */ public void setSeriesVisible(Boolean visible, boolean notify); /** * Returns the flag that controls the visibility of ALL series in the * legend. This flag overrides the per series and default settings - you * must set it to null if you want the other settings to * apply. * * @return The flag (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesVisibleInLegend(int)} * and {@link #getBaseSeriesVisibleInLegend()}. */ public Boolean getSeriesVisibleInLegend(); /** * Sets the flag that controls the visibility of ALL series in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * This flag overrides the per series and default settings - you must set * it to null if you want the other settings to apply. * * @param visible the flag (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, * Boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean)}. */ public void setSeriesVisibleInLegend(Boolean visible); /** * Sets the flag that controls the visibility of ALL series in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * This flag overrides the per series and default settings - you must set * it to null if you want the other settings to apply. * * @param visible the flag (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, * Boolean, boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean, * boolean)}. */ public void setSeriesVisibleInLegend(Boolean visible, boolean notify); /** * Sets the paint to be used for ALL series, and sends a * {@link RendererChangeEvent} to all registered listeners. If this is * null, the renderer will use the paint for the series. * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesPaint(int, Paint)} and * {@link #setBasePaint(Paint)}. */ public void setPaint(Paint paint); /** * Sets the outline paint for ALL series (optional). * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, * Paint)} and {@link #setBaseOutlinePaint(Paint)}. */ public void setOutlinePaint(Paint paint); /** * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param stroke the stroke (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke)} * and {@link #setBaseStroke(Stroke)}. */ public void setStroke(Stroke stroke); /** * Sets the outline stroke for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, * Stroke)} and {@link #setBaseOutlineStroke(Stroke)}. */ public void setOutlineStroke(Stroke stroke); /** * Sets the shape for ALL series (optional) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesShape(int, Shape)} and * {@link #setBaseShape(Shape)}. */ public void setShape(Shape shape); /** * Sets a flag that controls whether or not the item labels for ALL series * are visible. * * @param visible the flag. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. */ public void setItemLabelsVisible(boolean visible); /** * Sets a flag that controls whether or not the item labels for ALL series * are visible. * * @param visible the flag (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. */ public void setItemLabelsVisible(Boolean visible); /** * Sets the visibility of item labels for ALL series and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param visible a flag that controls whether or not the item labels are * visible (null permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean, boolean)} and {@link #setBaseItemLabelsVisible(Boolean, * boolean)}. */ public void setItemLabelsVisible(Boolean visible, boolean notify); /** * Sets the item label generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @deprecated As of version 1.0.6, this override setting should not be * used. You can use the base setting instead * ({@link #setBaseItemLabelGenerator(XYItemLabelGenerator)}). */ public void setItemLabelGenerator(XYItemLabelGenerator generator); /** * Sets the tool tip generator for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param generator the generator (null permitted). * * @deprecated As of version 1.0.6, this override setting should not be * used. You can use the base setting instead * ({@link #setBaseToolTipGenerator(XYToolTipGenerator)}). */ public void setToolTipGenerator(XYToolTipGenerator generator); /** * Returns the font used for all item labels. This may be * null, in which case the per series font settings will apply. * * @return The font (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesItemLabelFont(int)} and * {@link #getBaseItemLabelFont()}. */ public Font getItemLabelFont(); /** * Sets the item label font for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. You can set * this to null if you prefer to set the font on a per series * basis. * * @param font the font (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, * Font)} and {@link #setBaseItemLabelFont(Font)}. */ public void setItemLabelFont(Font font); /** * Returns the paint used for all item labels. This may be * null, in which case the per series paint settings will * apply. * * @return The paint (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesItemLabelPaint(int)} * and {@link #getBaseItemLabelPaint()}. */ public Paint getItemLabelPaint(); /** * Sets the item label paint for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, * Paint)} and {@link #setBaseItemLabelPaint(Paint)}. */ public void setItemLabelPaint(Paint paint); /** * Returns the item label position for positive values in ALL series. * * @return The item label position (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #getSeriesPositiveItemLabelPosition(int)} * and {@link #getBasePositiveItemLabelPosition()}. */ public ItemLabelPosition getPositiveItemLabelPosition(); /** * Sets the item label position for positive values in ALL series, and * sends a {@link RendererChangeEvent} to all registered listeners. You * need to set this to null to expose the settings for * individual series. * * @param position the position (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition)} * and {@link #setBasePositiveItemLabelPosition(ItemLabelPosition)}. */ public void setPositiveItemLabelPosition(ItemLabelPosition position); /** * Sets the positive item label position for ALL series and (if requested) * sends a {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null permitted). * @param notify notify registered listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, * boolean)} and {@link #setBasePositiveItemLabelPosition( * ItemLabelPosition, boolean)}. */ public void setPositiveItemLabelPosition(ItemLabelPosition position, boolean notify); /** * Returns the item label position for negative values in ALL series. * * @return The item label position (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #getSeriesNegativeItemLabelPosition(int)} * and {@link #getBaseNegativeItemLabelPosition()}. */ public ItemLabelPosition getNegativeItemLabelPosition(); /** * Sets the item label position for negative values in ALL series, and * sends a {@link RendererChangeEvent} to all registered listeners. You * need to set this to null to expose the settings for * individual series. * * @param position the position (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition)} * and {@link #setBaseNegativeItemLabelPosition(ItemLabelPosition)}. */ public void setNegativeItemLabelPosition(ItemLabelPosition position); /** * Sets the item label position for negative values in ALL series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * @param notify notify registered listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, * boolean)} and {@link #setBaseNegativeItemLabelPosition( * ItemLabelPosition, boolean)}. */ public void setNegativeItemLabelPosition(ItemLabelPosition position, boolean notify); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYItemRendererState.java0000644000175000017500000001465711173030414031426 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYItemRendererState.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Ulrich Voigt; * Greg Darke; * * Changes: * -------- * 07-Oct-2003 : Version 1 (DG); * 27-Jan-2004 : Added workingLine attribute (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 04-May-2007 : Added processVisibleItemsOnly flag (DG); * 09-Jul-2008 : Added start/endSeriesPass() methods - see patch 1997549 by * Ulrich Voigt (DG); * 19-Sep-2008 : Added first and last item indices, based on patch by Greg * Darke (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.geom.Line2D; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.RendererState; import org.jfree.data.xy.XYDataset; /** * The state for an {@link XYItemRenderer}. */ public class XYItemRendererState extends RendererState { /** * The first item in the series that will be displayed. * * @since 1.0.11 */ private int firstItemIndex; /** * The last item in the current series that will be displayed. * * @since 1.0.11 */ private int lastItemIndex; /** * A line object that the renderer can reuse to save instantiating a lot * of objects. */ public Line2D workingLine; /** * A flag that controls whether the plot should pass ALL data items to the * renderer, or just the items that will be visible. * * @since 1.0.6 */ private boolean processVisibleItemsOnly; /** * Creates a new state. * * @param info the plot rendering info. */ public XYItemRendererState(PlotRenderingInfo info) { super(info); this.workingLine = new Line2D.Double(); this.processVisibleItemsOnly = true; } /** * Returns the flag that controls whether the plot passes all data * items in each series to the renderer, or just the visible items. The * default value is true. * * @return A boolean. * * @since 1.0.6 * * @see #setProcessVisibleItemsOnly(boolean) */ public boolean getProcessVisibleItemsOnly() { return this.processVisibleItemsOnly; } /** * Sets the flag that controls whether the plot passes all data * items in each series to the renderer, or just the visible items. * * @param flag the new flag value. * * @since 1.0.6 */ public void setProcessVisibleItemsOnly(boolean flag) { this.processVisibleItemsOnly = flag; } /** * Returns the first item index (this is updated with each call to * {@link #startSeriesPass(XYDataset, int, int, int, int, int)}. * * @return The first item index. * * @since 1.0.11 */ public int getFirstItemIndex() { return this.firstItemIndex; } /** * Returns the last item index (this is updated with each call to * {@link #startSeriesPass(XYDataset, int, int, int, int, int)}. * * @return The last item index. * * @since 1.0.11 */ public int getLastItemIndex() { return this.lastItemIndex; } /** * This method is called by the {@link XYPlot} when it starts a pass * through the (visible) items in a series. The default implementation * records the first and last item indices - override this method to * implement additional specialised behaviour. * * @param dataset the dataset. * @param series the series index. * @param firstItem the index of the first item in the series. * @param lastItem the index of the last item in the series. * @param pass the pass index. * @param passCount the number of passes. * * @see #endSeriesPass(XYDataset, int, int, int, int, int) * * @since 1.0.11 */ public void startSeriesPass(XYDataset dataset, int series, int firstItem, int lastItem, int pass, int passCount) { this.firstItemIndex = firstItem; this.lastItemIndex = lastItem; } /** * This method is called by the {@link XYPlot} when it ends a pass * through the (visible) items in a series. The default implementation * does nothing, but you can override this method to implement specialised * behaviour. * * @param dataset the dataset. * @param series the series index. * @param firstItem the index of the first item in the series. * @param lastItem the index of the last item in the series. * @param pass the pass index. * @param passCount the number of passes. * * @see #startSeriesPass(XYDataset, int, int, int, int, int) * * @since 1.0.11 */ public void endSeriesPass(XYDataset dataset, int series, int firstItem, int lastItem, int pass, int passCount) { // do nothing...this is just a hook for subclasses } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java0000644000175000017500000002045111173030414030572 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYLine3DRenderer.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: Thomas Morgner; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 14-Jan-2005 : Added standard header (DG); * 01-May-2007 : Fixed equals() and serialization bugs (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.Effect3D; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; /** * A XYLineAndShapeRenderer that adds a shadow line to the graph * to emulate a 3D-effect. */ public class XYLine3DRenderer extends XYLineAndShapeRenderer implements Effect3D, Serializable { /** For serialization. */ private static final long serialVersionUID = 588933208243446087L; /** The default x-offset for the 3D effect. */ public static final double DEFAULT_X_OFFSET = 12.0; /** The default y-offset for the 3D effect. */ public static final double DEFAULT_Y_OFFSET = 8.0; /** The default wall paint. */ public static final Paint DEFAULT_WALL_PAINT = new Color(0xDD, 0xDD, 0xDD); /** The size of x-offset for the 3D effect. */ private double xOffset; /** The size of y-offset for the 3D effect. */ private double yOffset; /** The paint used to shade the left and lower 3D wall. */ private transient Paint wallPaint; /** * Creates a new renderer. */ public XYLine3DRenderer() { this.wallPaint = DEFAULT_WALL_PAINT; this.xOffset = DEFAULT_X_OFFSET; this.yOffset = DEFAULT_Y_OFFSET; } /** * Returns the x-offset for the 3D effect. * * @return The 3D effect. */ public double getXOffset() { return this.xOffset; } /** * Returns the y-offset for the 3D effect. * * @return The 3D effect. */ public double getYOffset() { return this.yOffset; } /** * Sets the x-offset and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param xOffset the x-offset. */ public void setXOffset(double xOffset) { this.xOffset = xOffset; fireChangeEvent(); } /** * Sets the y-offset and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param yOffset the y-offset. */ public void setYOffset(double yOffset) { this.yOffset = yOffset; fireChangeEvent(); } /** * Returns the paint used to highlight the left and bottom wall in the plot * background. * * @return The paint. */ public Paint getWallPaint() { return this.wallPaint; } /** * Sets the paint used to hightlight the left and bottom walls in the plot * background and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param paint the paint. */ public void setWallPaint(Paint paint) { this.wallPaint = paint; fireChangeEvent(); } /** * Returns the number of passes through the data that the renderer requires * in order to draw the chart. Most charts will require a single pass, * but some require two passes. * * @return The pass count. */ public int getPassCount() { return 3; } /** * Returns true if the specified pass involves drawing lines. * * @param pass the pass. * * @return A boolean. */ protected boolean isLinePass(int pass) { return pass == 0 || pass == 1; } /** * Returns true if the specified pass involves drawing items. * * @param pass the pass. * * @return A boolean. */ protected boolean isItemPass(int pass) { return pass == 2; } /** * Returns true if the specified pass involves drawing shadows. * * @param pass the pass. * * @return A boolean. */ protected boolean isShadowPass (int pass) { return pass == 0; } /** * Overrides the method in the subclass to draw a shadow in the first pass. * * @param g2 the graphics device. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param shape the shape. */ protected void drawFirstPassShape(Graphics2D g2, int pass, int series, int item, Shape shape) { if (isShadowPass(pass)) { if (getWallPaint() != null) { g2.setStroke(getItemStroke(series, item)); g2.setPaint(getWallPaint()); g2.translate(getXOffset(), getYOffset()); g2.draw(shape); g2.translate(-getXOffset(), -getYOffset()); } } else { // now draw the real shape super.drawFirstPassShape(g2, pass, series, item, shape); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYLine3DRenderer)) { return false; } XYLine3DRenderer that = (XYLine3DRenderer) obj; if (this.xOffset != that.xOffset) { return false; } if (this.yOffset != that.yOffset) { return false; } if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.wallPaint = SerialUtilities.readPaint(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.wallPaint, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java0000644000175000017500000013621011173030414032010 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XYLineAndShapeRenderer.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 27-Jan-2004 : Version 1 (DG); * 10-Feb-2004 : Minor change to drawItem() method to make cut-and-paste * overriding easier (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 25-Aug-2004 : Added support for chart entities (required for tooltips) (DG); * 24-Sep-2004 : Added flag to allow whole series to be drawn as a path * (necessary when using a dashed stroke with many data * items) (DG); * 04-Oct-2004 : Renamed BooleanUtils --> BooleanUtilities (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 27-Jan-2005 : The getLegendItem() method now omits hidden series (DG); * 28-Jan-2005 : Added new constructor (DG); * 09-Mar-2005 : Added fillPaint settings (DG); * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); * 22-Jul-2005 : Renamed defaultLinesVisible --> baseLinesVisible, * defaultShapesVisible --> baseShapesVisible and * defaultShapesFilled --> baseShapesFilled (DG); * 29-Jul-2005 : Added code to draw item labels (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 21-Feb-2007 : Fixed bugs in clone() and equals() (DG); * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); * 08-Jun-2007 : Fix for bug 1731912 where entities are created even for data * items that are not displayed (DG); * 26-Oct-2007 : Deprecated override attributes (DG); * 02-Jun-2008 : Fixed tooltips at lower edges of data area (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 19-Sep-2008 : Fixed bug with drawSeriesLineAsPath - patch by Greg Darke (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.BooleanList; import org.jfree.util.BooleanUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that connects data points with lines and/or draws shapes at each * data point. This renderer is designed for use with the {@link XYPlot} * class. The example shown here is generated by * the XYLineAndShapeRendererDemo2.java program included in the * JFreeChart demo collection: *

* XYLineAndShapeRendererSample.png * */ public class XYLineAndShapeRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7435246895986425885L; /** * A flag that controls whether or not lines are visible for ALL series. * * @deprecated As of 1.0.7. */ private Boolean linesVisible; /** * A table of flags that control (per series) whether or not lines are * visible. */ private BooleanList seriesLinesVisible; /** The default value returned by the getLinesVisible() method. */ private boolean baseLinesVisible; /** The shape that is used to represent a line in the legend. */ private transient Shape legendLine; /** * A flag that controls whether or not shapes are visible for ALL series. * * @deprecated As of 1.0.7. */ private Boolean shapesVisible; /** * A table of flags that control (per series) whether or not shapes are * visible. */ private BooleanList seriesShapesVisible; /** The default value returned by the getShapeVisible() method. */ private boolean baseShapesVisible; /** * A flag that controls whether or not shapes are filled for ALL series. * * @deprecated As of 1.0.7. */ private Boolean shapesFilled; /** * A table of flags that control (per series) whether or not shapes are * filled. */ private BooleanList seriesShapesFilled; /** The default value returned by the getShapeFilled() method. */ private boolean baseShapesFilled; /** A flag that controls whether outlines are drawn for shapes. */ private boolean drawOutlines; /** * A flag that controls whether the fill paint is used for filling * shapes. */ private boolean useFillPaint; /** * A flag that controls whether the outline paint is used for drawing shape * outlines. */ private boolean useOutlinePaint; /** * A flag that controls whether or not each series is drawn as a single * path. */ private boolean drawSeriesLineAsPath; /** * Creates a new renderer with both lines and shapes visible. */ public XYLineAndShapeRenderer() { this(true, true); } /** * Creates a new renderer. * * @param lines lines visible? * @param shapes shapes visible? */ public XYLineAndShapeRenderer(boolean lines, boolean shapes) { this.linesVisible = null; this.seriesLinesVisible = new BooleanList(); this.baseLinesVisible = lines; this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); this.shapesVisible = null; this.seriesShapesVisible = new BooleanList(); this.baseShapesVisible = shapes; this.shapesFilled = null; this.useFillPaint = false; // use item paint for fills by default this.seriesShapesFilled = new BooleanList(); this.baseShapesFilled = true; this.drawOutlines = true; this.useOutlinePaint = false; // use item paint for outlines by // default, not outline paint this.drawSeriesLineAsPath = false; } /** * Returns a flag that controls whether or not each series is drawn as a * single path. * * @return A boolean. * * @see #setDrawSeriesLineAsPath(boolean) */ public boolean getDrawSeriesLineAsPath() { return this.drawSeriesLineAsPath; } /** * Sets the flag that controls whether or not each series is drawn as a * single path and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #getDrawSeriesLineAsPath() */ public void setDrawSeriesLineAsPath(boolean flag) { if (this.drawSeriesLineAsPath != flag) { this.drawSeriesLineAsPath = flag; fireChangeEvent(); } } /** * Returns the number of passes through the data that the renderer requires * in order to draw the chart. Most charts will require a single pass, but * some require two passes. * * @return The pass count. */ public int getPassCount() { return 2; } // LINES VISIBLE /** * Returns the flag used to control whether or not the shape for an item is * visible. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. */ public boolean getItemLineVisible(int series, int item) { Boolean flag = this.linesVisible; if (flag == null) { flag = getSeriesLinesVisible(series); } if (flag != null) { return flag.booleanValue(); } else { return this.baseLinesVisible; } } /** * Returns a flag that controls whether or not lines are drawn for ALL * series. If this flag is null, then the "per series" * settings will apply. * * @return A flag (possibly null). * * @see #setLinesVisible(Boolean) * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public Boolean getLinesVisible() { return this.linesVisible; } /** * Sets a flag that controls whether or not lines are drawn between the * items in ALL series, and sends a {@link RendererChangeEvent} to all * registered listeners. You need to set this to null if you * want the "per series" settings to apply. * * @param visible the flag (null permitted). * * @see #getLinesVisible() * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public void setLinesVisible(Boolean visible) { this.linesVisible = visible; fireChangeEvent(); } /** * Sets a flag that controls whether or not lines are drawn between the * items in ALL series, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param visible the flag. * * @see #getLinesVisible() * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public void setLinesVisible(boolean visible) { // we use BooleanUtilities here to preserve JRE 1.3.1 compatibility setLinesVisible(BooleanUtilities.valueOf(visible)); } /** * Returns the flag used to control whether or not the lines for a series * are visible. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesLinesVisible(int, Boolean) */ public Boolean getSeriesLinesVisible(int series) { return this.seriesLinesVisible.getBoolean(series); } /** * Sets the 'lines visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag (null permitted). * * @see #getSeriesLinesVisible(int) */ public void setSeriesLinesVisible(int series, Boolean flag) { this.seriesLinesVisible.setBoolean(series, flag); fireChangeEvent(); } /** * Sets the 'lines visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag. * * @see #getSeriesLinesVisible(int) */ public void setSeriesLinesVisible(int series, boolean visible) { setSeriesLinesVisible(series, BooleanUtilities.valueOf(visible)); } /** * Returns the base 'lines visible' attribute. * * @return The base flag. * * @see #setBaseLinesVisible(boolean) */ public boolean getBaseLinesVisible() { return this.baseLinesVisible; } /** * Sets the base 'lines visible' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseLinesVisible() */ public void setBaseLinesVisible(boolean flag) { this.baseLinesVisible = flag; fireChangeEvent(); } /** * Returns the shape used to represent a line in the legend. * * @return The legend line (never null). * * @see #setLegendLine(Shape) */ public Shape getLegendLine() { return this.legendLine; } /** * Sets the shape used as a line in each legend item and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param line the line (null not permitted). * * @see #getLegendLine() */ public void setLegendLine(Shape line) { if (line == null) { throw new IllegalArgumentException("Null 'line' argument."); } this.legendLine = line; fireChangeEvent(); } // SHAPES VISIBLE /** * Returns the flag used to control whether or not the shape for an item is * visible. *

* The default implementation passes control to the * getSeriesShapesVisible method. You can override this method * if you require different behaviour. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. */ public boolean getItemShapeVisible(int series, int item) { Boolean flag = this.shapesVisible; if (flag == null) { flag = getSeriesShapesVisible(series); } if (flag != null) { return flag.booleanValue(); } else { return this.baseShapesVisible; } } /** * Returns the flag that controls whether the shapes are visible for the * items in ALL series. * * @return The flag (possibly null). * * @see #setShapesVisible(Boolean) * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public Boolean getShapesVisible() { return this.shapesVisible; } /** * Sets the 'shapes visible' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag (null permitted). * * @see #getShapesVisible() * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public void setShapesVisible(Boolean visible) { this.shapesVisible = visible; fireChangeEvent(); } /** * Sets the 'shapes visible' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getShapesVisible() * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public void setShapesVisible(boolean visible) { setShapesVisible(BooleanUtilities.valueOf(visible)); } /** * Returns the flag used to control whether or not the shapes for a series * are visible. * * @param series the series index (zero-based). * * @return A boolean. * * @see #setSeriesShapesVisible(int, Boolean) */ public Boolean getSeriesShapesVisible(int series) { return this.seriesShapesVisible.getBoolean(series); } /** * Sets the 'shapes visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag. * * @see #getSeriesShapesVisible(int) */ public void setSeriesShapesVisible(int series, boolean visible) { setSeriesShapesVisible(series, BooleanUtilities.valueOf(visible)); } /** * Sets the 'shapes visible' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag. * * @see #getSeriesShapesVisible(int) */ public void setSeriesShapesVisible(int series, Boolean flag) { this.seriesShapesVisible.setBoolean(series, flag); fireChangeEvent(); } /** * Returns the base 'shape visible' attribute. * * @return The base flag. * * @see #setBaseShapesVisible(boolean) */ public boolean getBaseShapesVisible() { return this.baseShapesVisible; } /** * Sets the base 'shapes visible' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseShapesVisible() */ public void setBaseShapesVisible(boolean flag) { this.baseShapesVisible = flag; fireChangeEvent(); } // SHAPES FILLED /** * Returns the flag used to control whether or not the shape for an item * is filled. *

* The default implementation passes control to the * getSeriesShapesFilled method. You can override this method * if you require different behaviour. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A boolean. */ public boolean getItemShapeFilled(int series, int item) { Boolean flag = this.shapesFilled; if (flag == null) { flag = getSeriesShapesFilled(series); } if (flag != null) { return flag.booleanValue(); } else { return this.baseShapesFilled; } } /** * Sets the 'shapes filled' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param filled the flag. * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public void setShapesFilled(boolean filled) { setShapesFilled(BooleanUtilities.valueOf(filled)); } /** * Sets the 'shapes filled' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param filled the flag (null permitted). * * @deprecated As of 1.0.7, use the per-series and base level settings. */ public void setShapesFilled(Boolean filled) { this.shapesFilled = filled; fireChangeEvent(); } /** * Returns the flag used to control whether or not the shapes for a series * are filled. * * @param series the series index (zero-based). * * @return A boolean. * * @see #setSeriesShapesFilled(int, Boolean) */ public Boolean getSeriesShapesFilled(int series) { return this.seriesShapesFilled.getBoolean(series); } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag. * * @see #getSeriesShapesFilled(int) */ public void setSeriesShapesFilled(int series, boolean flag) { setSeriesShapesFilled(series, BooleanUtilities.valueOf(flag)); } /** * Sets the 'shapes filled' flag for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param flag the flag. * * @see #getSeriesShapesFilled(int) */ public void setSeriesShapesFilled(int series, Boolean flag) { this.seriesShapesFilled.setBoolean(series, flag); fireChangeEvent(); } /** * Returns the base 'shape filled' attribute. * * @return The base flag. * * @see #setBaseShapesFilled(boolean) */ public boolean getBaseShapesFilled() { return this.baseShapesFilled; } /** * Sets the base 'shapes filled' flag and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param flag the flag. * * @see #getBaseShapesFilled() */ public void setBaseShapesFilled(boolean flag) { this.baseShapesFilled = flag; fireChangeEvent(); } /** * Returns true if outlines should be drawn for shapes, and * false otherwise. * * @return A boolean. * * @see #setDrawOutlines(boolean) */ public boolean getDrawOutlines() { return this.drawOutlines; } /** * Sets the flag that controls whether outlines are drawn for * shapes, and sends a {@link RendererChangeEvent} to all registered * listeners. *

* In some cases, shapes look better if they do NOT have an outline, but * this flag allows you to set your own preference. * * @param flag the flag. * * @see #getDrawOutlines() */ public void setDrawOutlines(boolean flag) { this.drawOutlines = flag; fireChangeEvent(); } /** * Returns true if the renderer should use the fill paint * setting to fill shapes, and false if it should just * use the regular paint. *

* Refer to XYLineAndShapeRendererDemo2.java to see the * effect of this flag. * * @return A boolean. * * @see #setUseFillPaint(boolean) * @see #getUseOutlinePaint() */ public boolean getUseFillPaint() { return this.useFillPaint; } /** * Sets the flag that controls whether the fill paint is used to fill * shapes, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param flag the flag. * * @see #getUseFillPaint() */ public void setUseFillPaint(boolean flag) { this.useFillPaint = flag; fireChangeEvent(); } /** * Returns true if the renderer should use the outline paint * setting to draw shape outlines, and false if it should just * use the regular paint. * * @return A boolean. * * @see #setUseOutlinePaint(boolean) * @see #getUseFillPaint() */ public boolean getUseOutlinePaint() { return this.useOutlinePaint; } /** * Sets the flag that controls whether the outline paint is used to draw * shape outlines, and sends a {@link RendererChangeEvent} to all * registered listeners. *

* Refer to XYLineAndShapeRendererDemo2.java to see the * effect of this flag. * * @param flag the flag. * * @see #getUseOutlinePaint() */ public void setUseOutlinePaint(boolean flag) { this.useOutlinePaint = flag; fireChangeEvent(); } /** * Records the state for the renderer. This is used to preserve state * information between calls to the drawItem() method for a single chart * drawing. */ public static class State extends XYItemRendererState { /** The path for the current series. */ public GeneralPath seriesPath; /** * A flag that indicates if the last (x, y) point was 'good' * (non-null). */ private boolean lastPointGood; /** * Creates a new state instance. * * @param info the plot rendering info. */ public State(PlotRenderingInfo info) { super(info); } /** * Returns a flag that indicates if the last point drawn (in the * current series) was 'good' (non-null). * * @return A boolean. */ public boolean isLastPointGood() { return this.lastPointGood; } /** * Sets a flag that indicates if the last point drawn (in the current * series) was 'good' (non-null). * * @param good the flag. */ public void setLastPointGood(boolean good) { this.lastPointGood = good; } /** * This method is called by the {@link XYPlot} at the start of each * series pass. We reset the state for the current series. * * @param dataset the dataset. * @param series the series index. * @param firstItem the first item index for this pass. * @param lastItem the last item index for this pass. * @param pass the current pass index. * @param passCount the number of passes. */ public void startSeriesPass(XYDataset dataset, int series, int firstItem, int lastItem, int pass, int passCount) { this.seriesPath.reset(); this.lastPointGood = false; super.startSeriesPass(dataset, series, firstItem, lastItem, pass, passCount); } } /** * Initialises the renderer. *

* This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { State state = new State(info); state.seriesPath = new GeneralPath(); return state; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // do nothing if item is not visible if (!getItemVisible(series, item)) { return; } // first pass draws the background (lines, for instance) if (isLinePass(pass)) { if (getItemLineVisible(series, item)) { if (this.drawSeriesLineAsPath) { drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); } else { drawPrimaryLine(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); } } } // second pass adds shapes where the items are .. else if (isItemPass(pass)) { // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities); } } /** * Returns true if the specified pass is the one for drawing * lines. * * @param pass the pass. * * @return A boolean. */ protected boolean isLinePass(int pass) { return pass == 0; } /** * Returns true if the specified pass is the one for drawing * items. * * @param pass the pass. * * @return A boolean. */ protected boolean isItemPass(int pass) { return pass == 1; } /** * Draws the item (first pass). This method draws the lines * connecting the items. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). */ protected void drawPrimaryLine(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { if (item == 0) { return; } // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1) || Double.isNaN(x1)) { return; } double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); if (Double.isNaN(y0) || Double.isNaN(x0)) { return; } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } if (state.workingLine.intersects(dataArea)) { drawFirstPassShape(g2, pass, series, item, state.workingLine); } } /** * Draws the first pass shape. * * @param g2 the graphics device. * @param pass the pass. * @param series the series index. * @param item the item index. * @param shape the shape. */ protected void drawFirstPassShape(Graphics2D g2, int pass, int series, int item, Shape shape) { g2.setStroke(getItemStroke(series, item)); g2.setPaint(getItemPaint(series, item)); g2.draw(shape); } /** * Draws the item (first pass). This method draws the lines * connecting the items. Instead of drawing separate lines, * a GeneralPath is constructed and drawn at the end of * the series painting. * * @param g2 the graphics device. * @param state the renderer state. * @param plot the plot (can be used to obtain standard color information * etc). * @param dataset the dataset. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataArea the area within which the data is being drawn. */ protected void drawPrimaryLineAsPath(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); State s = (State) state; // update path to reflect latest point if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { float x = (float) transX1; float y = (float) transY1; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { x = (float) transY1; y = (float) transX1; } if (s.isLastPointGood()) { s.seriesPath.lineTo(x, y); } else { s.seriesPath.moveTo(x, y); } s.setLastPointGood(true); } else { s.setLastPointGood(false); } // if this is the last item, draw the path ... if (item == s.getLastItemIndex()) { // draw path drawFirstPassShape(g2, pass, series, item, s.seriesPath); } } /** * Draws the item shapes and adds chart entities (second pass). This method * draws the shapes which mark the item positions. If entities * is not null it will be populated with entity information * for points that fall within the data area. * * @param g2 the graphics device. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param dataArea the area within which the data is being drawn. * @param rangeAxis the range axis. * @param dataset the dataset. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState the crosshair state. * @param entities the entity collection. */ protected void drawSecondaryPass(Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, Rectangle2D dataArea, ValueAxis rangeAxis, CrosshairState crosshairState, EntityCollection entities) { Shape entityArea = null; // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); if (Double.isNaN(y1) || Double.isNaN(x1)) { return; } PlotOrientation orientation = plot.getOrientation(); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); if (getItemShapeVisible(series, item)) { Shape shape = getItemShape(series, item); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } entityArea = shape; if (shape.intersects(dataArea)) { if (getItemShapeFilled(series, item)) { if (this.useFillPaint) { g2.setPaint(getItemFillPaint(series, item)); } else { g2.setPaint(getItemPaint(series, item)); } g2.fill(shape); } if (this.drawOutlines) { if (getUseOutlinePaint()) { g2.setPaint(getItemOutlinePaint(series, item)); } else { g2.setPaint(getItemPaint(series, item)); } g2.setStroke(getItemOutlineStroke(series, item)); g2.draw(shape); } } } double xx = transX1; double yy = transY1; if (orientation == PlotOrientation.HORIZONTAL) { xx = transY1; yy = transX1; } // draw the item label if there is one... if (isItemLabelVisible(series, item)) { drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0)); } int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); // add an entity for the item, but only if it falls within the data // area... if (entities != null && isPointInRect(dataArea, xx, yy)) { addEntity(entities, entityArea, dataset, series, item, xx, yy); } } /** * Returns a legend item for the specified series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return A legend item for the series. */ public LegendItem getLegendItem(int datasetIndex, int series) { XYPlot plot = getPlot(); if (plot == null) { return null; } LegendItem result = null; XYDataset dataset = plot.getDataset(datasetIndex); if (dataset != null) { if (getItemVisible(series, 0)) { String label = getLegendItemLabelGenerator().generateLabel( dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel( dataset, series); } boolean shapeIsVisible = getItemShapeVisible(series, 0); Shape shape = lookupLegendShape(series); boolean shapeIsFilled = getItemShapeFilled(series, 0); Paint fillPaint = (this.useFillPaint ? lookupSeriesFillPaint(series) : lookupSeriesPaint(series)); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? lookupSeriesOutlinePaint(series) : lookupSeriesPaint(series)); Stroke outlineStroke = lookupSeriesOutlineStroke(series); boolean lineVisible = getItemLineVisible(series, 0); Stroke lineStroke = lookupSeriesStroke(series); Paint linePaint = lookupSeriesPaint(series); result = new LegendItem(label, description, toolTipText, urlText, shapeIsVisible, shape, shapeIsFilled, fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, this.legendLine, lineStroke, linePaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setSeriesKey(dataset.getSeriesKey(series)); result.setSeriesIndex(series); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); } } return result; } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the clone cannot be created. */ public Object clone() throws CloneNotSupportedException { XYLineAndShapeRenderer clone = (XYLineAndShapeRenderer) super.clone(); clone.seriesLinesVisible = (BooleanList) this.seriesLinesVisible.clone(); if (this.legendLine != null) { clone.legendLine = ShapeUtilities.clone(this.legendLine); } clone.seriesShapesVisible = (BooleanList) this.seriesShapesVisible.clone(); clone.seriesShapesFilled = (BooleanList) this.seriesShapesFilled.clone(); return clone; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYLineAndShapeRenderer)) { return false; } if (!super.equals(obj)) { return false; } XYLineAndShapeRenderer that = (XYLineAndShapeRenderer) obj; if (!ObjectUtilities.equal(this.linesVisible, that.linesVisible)) { return false; } if (!ObjectUtilities.equal( this.seriesLinesVisible, that.seriesLinesVisible) ) { return false; } if (this.baseLinesVisible != that.baseLinesVisible) { return false; } if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { return false; } if (!ObjectUtilities.equal(this.shapesVisible, that.shapesVisible)) { return false; } if (!ObjectUtilities.equal( this.seriesShapesVisible, that.seriesShapesVisible) ) { return false; } if (this.baseShapesVisible != that.baseShapesVisible) { return false; } if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) { return false; } if (!ObjectUtilities.equal( this.seriesShapesFilled, that.seriesShapesFilled) ) { return false; } if (this.baseShapesFilled != that.baseShapesFilled) { return false; } if (this.drawOutlines != that.drawOutlines) { return false; } if (this.useOutlinePaint != that.useOutlinePaint) { return false; } if (this.useFillPaint != that.useFillPaint) { return false; } if (this.drawSeriesLineAsPath != that.drawSeriesLineAsPath) { return false; } return true; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.legendLine = SerialUtilities.readShape(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.legendLine, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java0000644000175000017500000004755311173030414030570 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYShapeRenderer.java * -------------------- * (C) Copyright 2008, by Andreas Haumer, xS+S and Contributors. * * Original Author: Martin Hoeller (x Software + Systeme xS+S - Andreas * Haumer); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 17-Sep-2008 : Version 1, based on a contribution from Martin Hoeller with * amendments by David Gilbert (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.LookupPaintScale; import org.jfree.chart.renderer.PaintScale; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; import org.jfree.io.SerialUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that draws shapes at (x, y) coordinates and, if the dataset * is an instance of {@link XYZDataset}, fills the shapes with a paint that * is based on the z-value (the paint is obtained from a lookup table). The * renderer also allows for optional guidelines, horizontal and vertical lines * connecting the shape to the edges of the plot. *

* The example shown here is generated by the * XYShapeRendererDemo1.java program included in the JFreeChart * demo collection: *

* XYShapeRendererSample.png *

* This renderer has similarities to, but also differences from, the * {@link XYLineAndShapeRenderer}. * * @since 1.0.11 */ public class XYShapeRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, Serializable { /** Auto generated serial version id. */ private static final long serialVersionUID = 8320552104211173221L; /** The paint scale. */ private PaintScale paintScale; /** A flag that controls whether or not the shape outlines are drawn. */ private boolean drawOutlines; /** * A flag that controls whether or not the outline paint is used (if not, * the regular paint is used). */ private boolean useOutlinePaint; /** * A flag that controls whether or not the fill paint is used (if not, * the fill paint is used). */ private boolean useFillPaint; /** Flag indicating if guide lines should be drawn for every item. */ private boolean guideLinesVisible; /** The paint used for drawing the guide lines. */ private transient Paint guideLinePaint; /** The stroke used for drawing the guide lines. */ private transient Stroke guideLineStroke; /** * Creates a new XYShapeRenderer instance with default * attributes. */ public XYShapeRenderer() { this.paintScale = new LookupPaintScale(); this.useFillPaint = false; this.drawOutlines = false; this.useOutlinePaint = true; this.guideLinesVisible = false; this.guideLinePaint = Color.darkGray; this.guideLineStroke = new BasicStroke(); setBaseShape(new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); setAutoPopulateSeriesShape(false); } /** * Returns the paint scale used by the renderer. * * @return The paint scale (never null). * * @see #setPaintScale(PaintScale) */ public PaintScale getPaintScale() { return this.paintScale; } /** * Sets the paint scale used by the renderer and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param scale the scale (null not permitted). * * @see #getPaintScale() */ public void setPaintScale(PaintScale scale) { if (scale == null) { throw new IllegalArgumentException("Null 'scale' argument."); } this.paintScale = scale; notifyListeners(new RendererChangeEvent(this)); } /** * Returns true if outlines should be drawn for shapes, and * false otherwise. * * @return A boolean. * * @see #setDrawOutlines(boolean) */ public boolean getDrawOutlines() { return this.drawOutlines; } /** * Sets the flag that controls whether outlines are drawn for * shapes, and sends a {@link RendererChangeEvent} to all registered * listeners. *

* In some cases, shapes look better if they do NOT have an outline, but * this flag allows you to set your own preference. * * @param flag the flag. * * @see #getDrawOutlines() */ public void setDrawOutlines(boolean flag) { this.drawOutlines = flag; fireChangeEvent(); } /** * Returns true if the renderer should use the fill paint * setting to fill shapes, and false if it should just * use the regular paint. *

* Refer to XYLineAndShapeRendererDemo2.java to see the * effect of this flag. * * @return A boolean. * * @see #setUseFillPaint(boolean) * @see #getUseOutlinePaint() */ public boolean getUseFillPaint() { return this.useFillPaint; } /** * Sets the flag that controls whether the fill paint is used to fill * shapes, and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param flag the flag. * * @see #getUseFillPaint() */ public void setUseFillPaint(boolean flag) { this.useFillPaint = flag; fireChangeEvent(); } /** * Returns the flag that controls whether the outline paint is used for * shape outlines. If not, the regular series paint is used. * * @return A boolean. * * @see #setUseOutlinePaint(boolean) */ public boolean getUseOutlinePaint() { return this.useOutlinePaint; } /** * Sets the flag that controls whether the outline paint is used for shape * outlines, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param use the flag. * * @see #getUseOutlinePaint() */ public void setUseOutlinePaint(boolean use) { this.useOutlinePaint = use; fireChangeEvent(); } /** * Returns a flag that controls whether or not guide lines are drawn for * each data item (the lines are horizontal and vertical "crosshairs" * linking the data point to the axes). * * @return A boolean. * * @see #setGuideLinesVisible(boolean) */ public boolean isGuideLinesVisible() { return this.guideLinesVisible; } /** * Sets the flag that controls whether or not guide lines are drawn for * each data item and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param visible the new flag value. * * @see #isGuideLinesVisible() */ public void setGuideLinesVisible(boolean visible) { this.guideLinesVisible = visible; fireChangeEvent(); } /** * Returns the paint used to draw the guide lines. * * @return The paint (never null). * * @see #setGuideLinePaint(Paint) */ public Paint getGuideLinePaint() { return this.guideLinePaint; } /** * Sets the paint used to draw the guide lines and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getGuideLinePaint() */ public void setGuideLinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.guideLinePaint = paint; fireChangeEvent(); } /** * Returns the stroke used to draw the guide lines. * * @return The stroke. * * @see #setGuideLineStroke(Stroke) */ public Stroke getGuideLineStroke() { return this.guideLineStroke; } /** * Sets the stroke used to draw the guide lines and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getGuideLineStroke() */ public void setGuideLineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.guideLineStroke = stroke; fireChangeEvent(); } /** * Returns the lower and upper bounds (range) of the x-values in the * specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findDomainBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtilities.findDomainBounds(dataset, false); double offset = 0; // TODO getSeriesShape(n).getBounds().width / 2; return new Range(r.getLowerBound() + offset, r.getUpperBound() + offset); } else { return null; } } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { if (dataset != null) { Range r = DatasetUtilities.findRangeBounds(dataset, false); double offset = 0; // TODO getSeriesShape(n).getBounds().height / 2; return new Range(r.getLowerBound() + offset, r.getUpperBound() + offset); } else { return null; } } /** * Returns the number of passes required by this renderer. * * @return 2. */ public int getPassCount() { return 2; } /** * Draws the block representing the specified item. * * @param g2 the graphics device. * @param state the state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the x-axis. * @param rangeAxis the y-axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { Shape hotspot = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); if (Double.isNaN(x) || Double.isNaN(y)) { // can't draw anything return; } double transX = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); double transY = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); PlotOrientation orientation = plot.getOrientation(); // draw optional guide lines if ((pass == 0) && this.guideLinesVisible) { g2.setStroke(this.guideLineStroke); g2.setPaint(this.guideLinePaint); if (orientation == PlotOrientation.HORIZONTAL) { g2.draw(new Line2D.Double(transY, dataArea.getMinY(), transY, dataArea.getMaxY())); g2.draw(new Line2D.Double(dataArea.getMinX(), transX, dataArea.getMaxX(), transX)); } else { g2.draw(new Line2D.Double(transX, dataArea.getMinY(), transX, dataArea.getMaxY())); g2.draw(new Line2D.Double(dataArea.getMinX(), transY, dataArea.getMaxX(), transY)); } } else if (pass == 1) { Shape shape = getItemShape(series, item); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY, transX); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX, transY); } hotspot = shape; if (shape.intersects(dataArea)) { //if (getItemShapeFilled(series, item)) { g2.setPaint(getPaint(dataset, series, item)); g2.fill(shape); //} if (this.drawOutlines) { if (getUseOutlinePaint()) { g2.setPaint(getItemOutlinePaint(series, item)); } else { g2.setPaint(getItemPaint(series, item)); } g2.setStroke(getItemOutlineStroke(series, item)); g2.draw(shape); } } // add an entity for the item... if (entities != null) { addEntity(entities, hotspot, dataset, series, item, transX, transY); } } } /** * Get the paint for a given series and item from a dataset. * * @param dataset the dataset.. * @param series the series index. * @param item the item index. * * @return The paint. */ protected Paint getPaint(XYDataset dataset, int series, int item) { Paint p = null; if (dataset instanceof XYZDataset) { double z = ((XYZDataset) dataset).getZValue(series, item); p = this.paintScale.getPaint(z); } else { if (this.useFillPaint) { p = getItemFillPaint(series, item); } else { p = getItemPaint(series, item); } } return p; } /** * Tests this instance for equality with an arbitrary object. This method * returns true if and only if: *

    *
  • obj is an instance of XYShapeRenderer (not * null);
  • *
  • obj has the same field values as this * XYShapeRenderer;
  • *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYShapeRenderer)) { return false; } XYShapeRenderer that = (XYShapeRenderer) obj; if ((this.paintScale == null && that.paintScale != null) || (!this.paintScale.equals(that.paintScale))) { return false; } if (this.drawOutlines != that.drawOutlines) { return false; } if (this.useOutlinePaint != that.useOutlinePaint) { return false; } if (this.useFillPaint != that.useFillPaint) { return false; } if (this.guideLinesVisible != that.guideLinesVisible) { return false; } if ((this.guideLinePaint == null && that.guideLinePaint != null) || (!this.guideLinePaint.equals(that.guideLinePaint))) return false; if ((this.guideLineStroke == null && that.guideLineStroke != null) || (!this.guideLineStroke.equals(that.guideLineStroke))) return false; return super.equals(obj); } /** * Returns a clone of this renderer. * * @return A clone of this renderer. * * @throws CloneNotSupportedException if there is a problem creating the * clone. */ public Object clone() throws CloneNotSupportedException { XYShapeRenderer clone = (XYShapeRenderer) super.clone(); if (this.paintScale instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.paintScale; clone.paintScale = (PaintScale) pc.clone(); } return clone; } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.guideLinePaint = SerialUtilities.readPaint(stream); this.guideLineStroke = SerialUtilities.readStroke(stream); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.guideLinePaint, stream); SerialUtilities.writeStroke(this.guideLineStroke, stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYSplineRenderer.java0000644000175000017500000003176411173030414030757 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYSplineRenderer.java * --------------------- * (C) Copyright 2007, 2008, by Klaus Rheinwald and Contributors. * * Original Author: Klaus Rheinwald; * Contributor(s): Tobias von Petersdorff (tvp@math.umd.edu, * http://www.wam.umd.edu/~petersd/); * David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 25-Jul-2007 : Version 1, contributed by Klaus Rheinwald (DG); * 03-Aug-2007 : Added new constructor (KR); * 25-Oct-2007 : Prevent duplicate control points (KR); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.util.Vector; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; /** * A renderer that connects data points with natural cubic splines and/or * draws shapes at each data point. This renderer is designed for use with * the {@link XYPlot} class. The example shown here is generated by the * XYSplineRendererDemo1.java program included in the JFreeChart * demo collection: *

* XYSplineRendererSample.png * * @since 1.0.7 */ public class XYSplineRenderer extends XYLineAndShapeRenderer { /** * To collect data points for later splining. */ private Vector points; /** * Resolution of splines (number of line segments between points) */ private int precision; /** * Creates a new instance with the 'precision' attribute defaulting to * 5. */ public XYSplineRenderer() { this(5); } /** * Creates a new renderer with the specified precision. * * @param precision the number of points between data items. */ public XYSplineRenderer(int precision) { super(); if (precision <= 0) { throw new IllegalArgumentException("Requires precision > 0."); } this.precision = precision; } /** * Get the resolution of splines. * * @return Number of line segments between points. * * @see #setPrecision(int) */ public int getPrecision() { return this.precision; } /** * Set the resolution of splines and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param p number of line segments between points (must be > 0). * * @see #getPrecision() */ public void setPrecision(int p) { if (p <= 0) { throw new IllegalArgumentException("Requires p > 0."); } this.precision = p; fireChangeEvent(); } /** * Initialises the renderer. *

* This method will be called before the first item is rendered, giving the * renderer an opportunity to initialise any state information it wants to * maintain. The renderer can do nothing if it chooses. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The renderer state. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { State state = (State) super.initialise(g2, dataArea, plot, data, info); state.setProcessVisibleItemsOnly(false); this.points = new Vector(); setDrawSeriesLineAsPath(true); return state; } /** * Draws the item (first pass). This method draws the lines * connecting the items. Instead of drawing separate lines, * a GeneralPath is constructed and drawn at the end of * the series painting. * * @param g2 the graphics device. * @param state the renderer state. * @param plot the plot (can be used to obtain standard color information * etc). * @param dataset the dataset. * @param pass the pass. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataArea the area within which the data is being drawn. */ protected void drawPrimaryLineAsPath(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); // get the data points double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); // collect points if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { ControlPoint p = new ControlPoint(plot.getOrientation() == PlotOrientation.HORIZONTAL ? (float) transY1 : (float) transX1, plot.getOrientation() == PlotOrientation.HORIZONTAL ? (float) transX1 : (float) transY1); if (!this.points.contains(p)) { this.points.add(p); } } if (item == dataset.getItemCount(series) - 1) { State s = (State) state; // construct path if (this.points.size() > 1) { // we need at least two points to draw something ControlPoint cp0 = (ControlPoint) this.points.get(0); s.seriesPath.moveTo(cp0.x, cp0.y); if (this.points.size() == 2) { // we need at least 3 points to spline. Draw simple line // for two points ControlPoint cp1 = (ControlPoint) this.points.get(1); s.seriesPath.lineTo(cp1.x, cp1.y); } else { // construct spline int np = this.points.size(); // number of points float[] d = new float[np]; // Newton form coefficients float[] x = new float[np]; // x-coordinates of nodes float y; float t; float oldy = 0; float oldt = 0; float[] a = new float[np]; float t1; float t2; float[] h = new float[np]; for (int i = 0; i < np; i++) { ControlPoint cpi = (ControlPoint) this.points.get(i); x[i] = cpi.x; d[i] = cpi.y; } for (int i = 1; i <= np - 1; i++) { h[i] = x[i] - x[i - 1]; } float[] sub = new float[np - 1]; float[] diag = new float[np - 1]; float[] sup = new float[np - 1]; for (int i = 1; i <= np - 2; i++) { diag[i] = (h[i] + h[i + 1]) / 3; sup[i] = h[i + 1] / 6; sub[i] = h[i] / 6; a[i] = (d[i + 1] - d[i]) / h[i + 1] - (d[i] - d[i - 1]) / h[i]; } solveTridiag(sub, diag, sup, a, np - 2); // note that a[0]=a[np-1]=0 // draw oldt = x[0]; oldy = d[0]; s.seriesPath.moveTo(oldt, oldy); for (int i = 1; i <= np - 1; i++) { // loop over intervals between nodes for (int j = 1; j <= this.precision; j++) { t1 = (h[i] * j) / this.precision; t2 = h[i] - t1; y = ((-a[i - 1] / 6 * (t2 + h[i]) * t1 + d[i - 1]) * t2 + (-a[i] / 6 * (t1 + h[i]) * t2 + d[i]) * t1) / h[i]; t = x[i - 1] + t1; s.seriesPath.lineTo(t, y); oldt = t; oldy = y; } } } // draw path drawFirstPassShape(g2, pass, series, item, s.seriesPath); } // reset points vector this.points = new Vector(); } } private void solveTridiag(float[] sub, float[] diag, float[] sup, float[] b, int n) { /* solve linear system with tridiagonal n by n matrix a using Gaussian elimination *without* pivoting where a(i,i-1) = sub[i] for 2<=i<=n a(i,i) = diag[i] for 1<=i<=n a(i,i+1) = sup[i] for 1<=i<=n-1 (the values sub[1], sup[n] are ignored) right hand side vector b[1:n] is overwritten with solution NOTE: 1...n is used in all arrays, 0 is unused */ int i; /* factorization and forward substitution */ for (i = 2; i <= n; i++) { sub[i] = sub[i] / diag[i - 1]; diag[i] = diag[i] - sub[i] * sup[i - 1]; b[i] = b[i] - sub[i] * b[i - 1]; } b[n] = b[n] / diag[n]; for (i = n - 1; i >= 1; i--) { b[i] = (b[i] - sup[i] * b[i + 1]) / diag[i]; } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYSplineRenderer)) { return false; } XYSplineRenderer that = (XYSplineRenderer) obj; if (this.precision != that.precision) { return false; } return super.equals(obj); } /** * Represents a control point. */ class ControlPoint { /** The x-coordinate. */ public float x; /** The y-coordinate. */ public float y; /** * Creates a new control point. * * @param x the x-coordinate. * @param y the y-coordinate. */ public ControlPoint(float x, float y) { this.x = x; this.y = y; } /** * Tests this point for equality with an arbitrary object. * * @param obj the object (null permitted. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ControlPoint)) { return false; } ControlPoint that = (ControlPoint) obj; if (this.x != that.x) { return false; } /*&& y == ((ControlPoint) obj).y*/; return true; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java0000644000175000017500000005272111173030414031225 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYStepAreaRenderer.java * ----------------------- * (C) Copyright 2003-2008, by Matthias Rose and Contributors. * * Original Author: Matthias Rose (based on XYAreaRenderer.java); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 07-Oct-2003 : Version 1, contributed by Matthias Rose (DG); * 10-Feb-2004 : Added some getter and setter methods (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 06-Jul-2005 : Renamed get/setPlotShapes() --> get/setShapesVisible() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Jul-2006 : Modified to call dataset methods that return double * primitives only (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 14-Feb-2007 : Added equals() method override (DG); * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); * 14-May-2008 : Call addEntity() from within drawItem() (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A step chart renderer that fills the area between the step and the x-axis. * The example shown here is generated by the * XYStepAreaRendererDemo1.java program included in the JFreeChart * demo collection: *

* XYStepAreaRendererSample.png */ public class XYStepAreaRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7311560779702649635L; /** Useful constant for specifying the type of rendering (shapes only). */ public static final int SHAPES = 1; /** Useful constant for specifying the type of rendering (area only). */ public static final int AREA = 2; /** * Useful constant for specifying the type of rendering (area and shapes). */ public static final int AREA_AND_SHAPES = 3; /** A flag indicating whether or not shapes are drawn at each XY point. */ private boolean shapesVisible; /** A flag that controls whether or not shapes are filled for ALL series. */ private boolean shapesFilled; /** A flag indicating whether or not Area are drawn at each XY point. */ private boolean plotArea; /** A flag that controls whether or not the outline is shown. */ private boolean showOutline; /** Area of the complete series */ protected transient Polygon pArea = null; /** * The value on the range axis which defines the 'lower' border of the * area. */ private double rangeBase; /** * Constructs a new renderer. */ public XYStepAreaRenderer() { this(AREA); } /** * Constructs a new renderer. * * @param type the type of the renderer. */ public XYStepAreaRenderer(int type) { this(type, null, null); } /** * Constructs a new renderer. *

* To specify the type of renderer, use one of the constants: * AREA, SHAPES or AREA_AND_SHAPES. * * @param type the type of renderer. * @param toolTipGenerator the tool tip generator to use * (null permitted). * @param urlGenerator the URL generator (null permitted). */ public XYStepAreaRenderer(int type, XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); setURLGenerator(urlGenerator); if (type == AREA) { this.plotArea = true; } else if (type == SHAPES) { this.shapesVisible = true; } else if (type == AREA_AND_SHAPES) { this.plotArea = true; this.shapesVisible = true; } this.showOutline = false; } /** * Returns a flag that controls whether or not outlines of the areas are * drawn. * * @return The flag. * * @see #setOutline(boolean) */ public boolean isOutline() { return this.showOutline; } /** * Sets a flag that controls whether or not outlines of the areas are * drawn, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param show the flag. * * @see #isOutline() */ public void setOutline(boolean show) { this.showOutline = show; fireChangeEvent(); } /** * Returns true if shapes are being plotted by the renderer. * * @return true if shapes are being plotted by the renderer. * * @see #setShapesVisible(boolean) */ public boolean getShapesVisible() { return this.shapesVisible; } /** * Sets the flag that controls whether or not shapes are displayed for each * data item, and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #getShapesVisible() */ public void setShapesVisible(boolean flag) { this.shapesVisible = flag; fireChangeEvent(); } /** * Returns the flag that controls whether or not the shapes are filled. * * @return A boolean. * * @see #setShapesFilled(boolean) */ public boolean isShapesFilled() { return this.shapesFilled; } /** * Sets the 'shapes filled' for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param filled the flag. * * @see #isShapesFilled() */ public void setShapesFilled(boolean filled) { this.shapesFilled = filled; fireChangeEvent(); } /** * Returns true if Area is being plotted by the renderer. * * @return true if Area is being plotted by the renderer. * * @see #setPlotArea(boolean) */ public boolean getPlotArea() { return this.plotArea; } /** * Sets a flag that controls whether or not areas are drawn for each data * item and sends a {@link RendererChangeEvent} to all registered * listeners. * * @param flag the flag. * * @see #getPlotArea() */ public void setPlotArea(boolean flag) { this.plotArea = flag; fireChangeEvent(); } /** * Returns the value on the range axis which defines the 'lower' border of * the area. * * @return double the value on the range axis which defines * the 'lower' border of the area. * * @see #setRangeBase(double) */ public double getRangeBase() { return this.rangeBase; } /** * Sets the value on the range axis which defines the default border of the * area, and sends a {@link RendererChangeEvent} to all registered * listeners. E.g. setRangeBase(Double.NEGATIVE_INFINITY) lets areas always * reach the lower border of the plotArea. * * @param val the value on the range axis which defines the default border * of the area. * * @see #getRangeBase() */ public void setRangeBase(double val) { this.rangeBase = val; fireChangeEvent(); } /** * Initialises the renderer. Here we calculate the Java2D y-coordinate for * zero, since all the bars have their bases fixed at zero. * * @param g2 the graphics device. * @param dataArea the area inside the axes. * @param plot the plot. * @param data the data. * @param info an optional info collection object to return data back to * the caller. * * @return The number of passes required by the renderer. */ public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, PlotRenderingInfo info) { XYItemRendererState state = super.initialise(g2, dataArea, plot, data, info); // disable visible items optimisation - it doesn't work for this // renderer... state.setProcessVisibleItemsOnly(false); return state; } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color information * etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { PlotOrientation orientation = plot.getOrientation(); // Get the item count for the series, so that we can know which is the // end of the series. int itemCount = dataset.getItemCount(series); Paint paint = getItemPaint(series, item); Stroke seriesStroke = getItemStroke(series, item); g2.setPaint(paint); g2.setStroke(seriesStroke); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); double x = x1; double y = Double.isNaN(y1) ? getRangeBase() : y1; double transX1 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); double transY1 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); // avoid possible sun.dc.pr.PRException: endPath: bad path transY1 = restrictValueToDataArea(transY1, plot, dataArea); if (this.pArea == null && !Double.isNaN(y1)) { // Create a new Area for the series this.pArea = new Polygon(); // start from Y = rangeBase double transY2 = rangeAxis.valueToJava2D(getRangeBase(), dataArea, plot.getRangeAxisEdge()); // avoid possible sun.dc.pr.PRException: endPath: bad path transY2 = restrictValueToDataArea(transY2, plot, dataArea); // The first point is (x, this.baseYValue) if (orientation == PlotOrientation.VERTICAL) { this.pArea.addPoint((int) transX1, (int) transY2); } else if (orientation == PlotOrientation.HORIZONTAL) { this.pArea.addPoint((int) transY2, (int) transX1); } } double transX0 = 0; double transY0 = restrictValueToDataArea(getRangeBase(), plot, dataArea); double x0; double y0; if (item > 0) { // get the previous data point... x0 = dataset.getXValue(series, item - 1); y0 = Double.isNaN(y1) ? y1 : dataset.getYValue(series, item - 1); x = x0; y = Double.isNaN(y0) ? getRangeBase() : y0; transX0 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); transY0 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); // avoid possible sun.dc.pr.PRException: endPath: bad path transY0 = restrictValueToDataArea(transY0, plot, dataArea); if (Double.isNaN(y1)) { // NULL value -> insert point on base line // instead of 'step point' transX1 = transX0; transY0 = transY1; } if (transY0 != transY1) { // not just a horizontal bar but need to perform a 'step'. if (orientation == PlotOrientation.VERTICAL) { this.pArea.addPoint((int) transX1, (int) transY0); } else if (orientation == PlotOrientation.HORIZONTAL) { this.pArea.addPoint((int) transY0, (int) transX1); } } } Shape shape = null; if (!Double.isNaN(y1)) { // Add each point to Area (x, y) if (orientation == PlotOrientation.VERTICAL) { this.pArea.addPoint((int) transX1, (int) transY1); } else if (orientation == PlotOrientation.HORIZONTAL) { this.pArea.addPoint((int) transY1, (int) transX1); } if (getShapesVisible()) { shape = getItemShape(series, item); if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } else if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } if (isShapesFilled()) { g2.fill(shape); } else { g2.draw(shape); } } else { if (orientation == PlotOrientation.VERTICAL) { shape = new Rectangle2D.Double(transX1 - 2, transY1 - 2, 4.0, 4.0); } else if (orientation == PlotOrientation.HORIZONTAL) { shape = new Rectangle2D.Double(transY1 - 2, transX1 - 2, 4.0, 4.0); } } } // Check if the item is the last item for the series or if it // is a NULL value and number of items > 0. We can't draw an area for // a single point. if (getPlotArea() && item > 0 && this.pArea != null && (item == (itemCount - 1) || Double.isNaN(y1))) { double transY2 = rangeAxis.valueToJava2D(getRangeBase(), dataArea, plot.getRangeAxisEdge()); // avoid possible sun.dc.pr.PRException: endPath: bad path transY2 = restrictValueToDataArea(transY2, plot, dataArea); if (orientation == PlotOrientation.VERTICAL) { // Add the last point (x,0) this.pArea.addPoint((int) transX1, (int) transY2); } else if (orientation == PlotOrientation.HORIZONTAL) { // Add the last point (x,0) this.pArea.addPoint((int) transY2, (int) transX1); } // fill the polygon g2.fill(this.pArea); // draw an outline around the Area. if (isOutline()) { g2.setStroke(plot.getOutlineStroke()); g2.setPaint(plot.getOutlinePaint()); g2.draw(this.pArea); } // start new area when needed (see above) this.pArea = null; } // do we need to update the crosshair values? if (!Double.isNaN(y1)) { int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); } // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addEntity(entities, shape, dataset, series, item, transX1, transY1); } } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYStepAreaRenderer)) { return false; } XYStepAreaRenderer that = (XYStepAreaRenderer) obj; if (this.showOutline != that.showOutline) { return false; } if (this.shapesVisible != that.shapesVisible) { return false; } if (this.shapesFilled != that.shapesFilled) { return false; } if (this.plotArea != that.plotArea) { return false; } if (this.rangeBase != that.rangeBase) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Helper method which returns a value if it lies * inside the visible dataArea and otherwise the corresponding * coordinate on the border of the dataArea. The PlotOrientation * is taken into account. * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path * which occurs when trying to draw lines/shapes which in large part * lie outside of the visible dataArea. * * @param value the value which shall be * @param dataArea the area within which the data is being drawn. * @param plot the plot (can be used to obtain standard color * information etc). * @return double value inside the data area. */ protected static double restrictValueToDataArea(double value, XYPlot plot, Rectangle2D dataArea) { double min = 0; double max = 0; if (plot.getOrientation() == PlotOrientation.VERTICAL) { min = dataArea.getMinY(); max = dataArea.getMaxY(); } else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { min = dataArea.getMinX(); max = dataArea.getMaxX(); } if (value < min) { value = min; } else if (value > max) { value = max; } return value; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/XYStepRenderer.java0000644000175000017500000003445611173030414030441 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * XYStepRenderer.java * ------------------- * (C) Copyright 2002-2009, by Roger Studner and Contributors. * * Original Author: Roger Studner; * Contributor(s): David Gilbert (for Object Refinery Limited); * Matthias Rose; * Gerald Struck (fix for bug 1569094); * Ulrich Voigt (patch 1874890); * Martin Hoeller (contribution to patch 1874890); * * Changes * ------- * 13-May-2002 : Version 1, contributed by Roger Studner (DG); * 25-Jun-2002 : Updated import statements (DG); * 22-Jul-2002 : Added check for null data items (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 28-Oct-2003 : Added tooltips, code contributed by Matthias Rose * (RFE 824857) (DG); * 10-Feb-2004 : Removed working line (use line from state object instead) (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed * XYToolTipGenerator --> XYItemLabelGenerator (DG); * 19-Jan-2005 : Now accesses only primitives from dataset (DG); * 15-Mar-2005 : Fix silly bug in drawItem() method (DG); * 19-Sep-2005 : Extend XYLineAndShapeRenderer (fixes legend shapes), added * support for series visibility, and use getDefaultEntityRadius() * for entity hotspot size (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 15-Jun-2006 : Added basic support for item labels (DG); * 11-Oct-2006 : Fixed rendering with horizontal orientation (see bug 1569094), * thanks to Gerald Struck (DG); * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); * 14-Feb-2008 : Applied patch 1874890 by Ulrich Voigt (with contribution from * Martin Hoeller) (DG); * 14-May-2008 : Call addEntity() in drawItem() (DG); * 24-Sep-2008 : Fixed bug 2113627 by utilising second pass to draw item * labels (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleEdge; import org.jfree.util.PublicCloneable; /** * Line/Step item renderer for an {@link XYPlot}. This class draws lines * between data points, only allowing horizontal or vertical lines (steps). * The example shown here is generated by the * XYStepRendererDemo1.java program included in the JFreeChart * demo collection: *

* XYStepRendererSample.png */ public class XYStepRenderer extends XYLineAndShapeRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8918141928884796108L; /** * The factor (from 0.0 to 1.0) that determines the position of the * step. * * @since 1.0.10. */ private double stepPoint = 1.0d; /** * Constructs a new renderer with no tooltip or URL generation. */ public XYStepRenderer() { this(null, null); } /** * Constructs a new renderer with the specified tool tip and URL * generators. * * @param toolTipGenerator the item label generator (null * permitted). * @param urlGenerator the URL generator (null permitted). */ public XYStepRenderer(XYToolTipGenerator toolTipGenerator, XYURLGenerator urlGenerator) { super(); setBaseToolTipGenerator(toolTipGenerator); setURLGenerator(urlGenerator); setBaseShapesVisible(false); } /** * Returns the fraction of the domain position between two points on which * the step is drawn. The default is 1.0d, which means the step is drawn * at the domain position of the second`point. If the stepPoint is 0.5d the * step is drawn at half between the two points. * * @return The fraction of the domain position between two points where the * step is drawn. * * @see #setStepPoint(double) * * @since 1.0.10 */ public double getStepPoint() { return this.stepPoint; } /** * Sets the step point and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param stepPoint the step point (in the range 0.0 to 1.0) * * @see #getStepPoint() * * @since 1.0.10 */ public void setStepPoint(double stepPoint) { if (stepPoint < 0.0d || stepPoint > 1.0d) { throw new IllegalArgumentException( "Requires stepPoint in [0.0;1.0]"); } this.stepPoint = stepPoint; fireChangeEvent(); } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the data is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the vertical axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // do nothing if item is not visible if (!getItemVisible(series, item)) { return; } PlotOrientation orientation = plot.getOrientation(); Paint seriesPaint = getItemPaint(series, item); Stroke seriesStroke = getItemStroke(series, item); g2.setPaint(seriesPaint); g2.setStroke(seriesStroke); // get the data point... double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = (Double.isNaN(y1) ? Double.NaN : rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation)); if (pass == 0 && item > 0) { // get the previous data point... double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double transY0 = (Double.isNaN(y0) ? Double.NaN : rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation)); if (orientation == PlotOrientation.HORIZONTAL) { if (transY0 == transY1) { // this represents the situation // for drawing a horizontal bar. drawLine(g2, state.workingLine, transY0, transX0, transY1, transX1); } else { //this handles the need to perform a 'step'. // calculate the step point double transXs = transX0 + (getStepPoint() * (transX1 - transX0)); drawLine(g2, state.workingLine, transY0, transX0, transY0, transXs); drawLine(g2, state.workingLine, transY0, transXs, transY1, transXs); drawLine(g2, state.workingLine, transY1, transXs, transY1, transX1); } } else if (orientation == PlotOrientation.VERTICAL) { if (transY0 == transY1) { // this represents the situation // for drawing a horizontal bar. drawLine(g2, state.workingLine, transX0, transY0, transX1, transY1); } else { //this handles the need to perform a 'step'. // calculate the step point double transXs = transX0 + (getStepPoint() * (transX1 - transX0)); drawLine(g2, state.workingLine, transX0, transY0, transXs, transY0); drawLine(g2, state.workingLine, transXs, transY0, transXs, transY1); drawLine(g2, state.workingLine, transXs, transY1, transX1, transY1); } } // submit this data item as a candidate for the crosshair point int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1, orientation); // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addEntity(entities, null, dataset, series, item, transX1, transY1); } } if (pass == 1) { // draw the item label if there is one... if (isItemLabelVisible(series, item)) { double xx = transX1; double yy = transY1; if (orientation == PlotOrientation.HORIZONTAL) { xx = transY1; yy = transX1; } drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0)); } } } /** * A utility method that draws a line but only if none of the coordinates * are NaN values. * * @param g2 the graphics target. * @param line the line object. * @param x0 the x-coordinate for the starting point of the line. * @param y0 the y-coordinate for the starting point of the line. * @param x1 the x-coordinate for the ending point of the line. * @param y1 the y-coordinate for the ending point of the line. */ private void drawLine(Graphics2D g2, Line2D line, double x0, double y0, double x1, double y1) { if (Double.isNaN(x0) || Double.isNaN(x1) || Double.isNaN(y0) || Double.isNaN(y1)) { return; } line.setLine(x0, y0, x1, y1); g2.draw(line); } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYLineAndShapeRenderer)) { return false; } XYStepRenderer that = (XYStepRenderer) obj; if (this.stepPoint != that.stepPoint) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { return HashUtilities.hashCode(super.hashCode(), this.stepPoint); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/YIntervalRenderer.java0000644000175000017500000002770111173030414031155 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * YIntervalRenderer.java * ---------------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Nov-2002 : Version 1 (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Modified drawItem() method signature (DG); * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); * 27-Sep-2004 : Access double values from dataset (DG); * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); * 11-Apr-2008 : New override for findRangeBounds() (DG); * 26-May-2008 : Added item label support (DG); * 27-Mar-2009 : Updated findRangeBounds() (DG); * */ package org.jfree.chart.renderer.xy; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.text.TextUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A renderer that draws a line connecting the start and end Y values for an * {@link XYPlot}. The example shown here is generated by the * YIntervalRendererDemo1.java program included in the JFreeChart * demo collection: *

* YIntervalRendererSample.png */ public class YIntervalRenderer extends AbstractXYItemRenderer implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2951586537224143260L; /** * An additional item label generator. If this is non-null, the item * label generated will be displayed near the lower y-value at the * position given by getNegativeItemLabelPosition(). * * @since 1.0.10 */ private XYItemLabelGenerator additionalItemLabelGenerator; /** * The default constructor. */ public YIntervalRenderer() { super(); this.additionalItemLabelGenerator = null; } /** * Returns the generator for the item labels that appear near the lower * y-value. * * @return The generator (possibly null). * * @see #setAdditionalItemLabelGenerator(XYItemLabelGenerator) * * @since 1.0.10 */ public XYItemLabelGenerator getAdditionalItemLabelGenerator() { return this.additionalItemLabelGenerator; } /** * Sets the generator for the item labels that appear near the lower * y-value and sends a {@link RendererChangeEvent} to all registered * listeners. If this is set to null, no item labels will be * drawn. * * @param generator the generator (null permitted). * * @see #getAdditionalItemLabelGenerator() * * @since 1.0.10 */ public void setAdditionalItemLabelGenerator( XYItemLabelGenerator generator) { this.additionalItemLabelGenerator = generator; fireChangeEvent(); } /** * Returns the range of values the renderer requires to display all the * items from the specified dataset. * * @param dataset the dataset (null permitted). * * @return The range (null if the dataset is null * or empty). */ public Range findRangeBounds(XYDataset dataset) { return findRangeBounds(dataset, true); } /** * Draws the visual representation of a single data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the area within which the plot is being drawn. * @param info collects information about the drawing. * @param plot the plot (can be used to obtain standard color * information etc). * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (null permitted). * @param pass the pass index (ignored here). */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // setup for collecting optional entity info... EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; double x = intervalDataset.getXValue(series, item); double yLow = intervalDataset.getStartYValue(series, item); double yHigh = intervalDataset.getEndYValue(series, item); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation); double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation); Paint p = getItemPaint(series, item); Stroke s = getItemStroke(series, item); Line2D line = null; Shape shape = getItemShape(series, item); Shape top = null; Shape bottom = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(yyLow, xx, yyHigh, xx); top = ShapeUtilities.createTranslatedShape(shape, yyHigh, xx); bottom = ShapeUtilities.createTranslatedShape(shape, yyLow, xx); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(xx, yyLow, xx, yyHigh); top = ShapeUtilities.createTranslatedShape(shape, xx, yyHigh); bottom = ShapeUtilities.createTranslatedShape(shape, xx, yyLow); } g2.setPaint(p); g2.setStroke(s); g2.draw(line); g2.fill(top); g2.fill(bottom); // for item labels, we have a special case because there is the // possibility to draw (a) the regular item label near to just the // upper y-value, or (b) the regular item label near the upper y-value // PLUS an additional item label near the lower y-value. if (isItemLabelVisible(series, item)) { drawItemLabel(g2, orientation, dataset, series, item, xx, yyHigh, false); drawAdditionalItemLabel(g2, orientation, dataset, series, item, xx, yyLow); } // add an entity for the item... if (entities != null) { addEntity(entities, line.getBounds(), dataset, series, item, 0.0, 0.0); } } /** * Draws an item label. * * @param g2 the graphics device. * @param orientation the orientation. * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * @param x the x coordinate (in Java2D space). * @param y the y coordinate (in Java2D space). * @param negative indicates a negative value (which affects the item * label position). */ private void drawAdditionalItemLabel(Graphics2D g2, PlotOrientation orientation, XYDataset dataset, int series, int item, double x, double y) { if (this.additionalItemLabelGenerator == null) { return; } Font labelFont = getItemLabelFont(series, item); Paint paint = getItemLabelPaint(series, item); g2.setFont(labelFont); g2.setPaint(paint); String label = this.additionalItemLabelGenerator.generateLabel(dataset, series, item); ItemLabelPosition position = getNegativeItemLabelPosition(series, item); Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), x, y, orientation); TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof YIntervalRenderer)) { return false; } YIntervalRenderer that = (YIntervalRenderer) obj; if (!ObjectUtilities.equal(this.additionalItemLabelGenerator, that.additionalItemLabelGenerator)) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/xy/package.html0000644000175000017500000000026111173030414027157 0ustar vincentvincent Plug-in renderers for the {@link org.jfree.chart.plot.XYPlot} class. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/AbstractRenderer.java0000644000175000017500000042441011173030414030341 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * AbstractRenderer.java * --------------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; * * Changes: * -------- * 22-Aug-2002 : Version 1, draws code out of AbstractXYItemRenderer to share * with AbstractCategoryItemRenderer (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 06-Nov-2002 : Moved to the com.jrefinery.chart.renderer package (DG); * 21-Nov-2002 : Added a paint table for the renderer to use (DG); * 17-Jan-2003 : Moved plot classes into a separate package (DG); * 25-Mar-2003 : Implemented Serializable (DG); * 29-Apr-2003 : Added valueLabelFont and valueLabelPaint attributes, based on * code from Arnaud Lelievre (DG); * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 15-Sep-2003 : Fixed serialization (NB); * 17-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 07-Oct-2003 : Moved PlotRenderingInfo into RendererState to allow for * multiple threads using a single renderer (DG); * 20-Oct-2003 : Added missing setOutlinePaint() method (DG); * 23-Oct-2003 : Split item label attributes into 'positive' and 'negative' * values (DG); * 26-Nov-2003 : Added methods to get the positive and negative item label * positions (DG); * 01-Mar-2004 : Modified readObject() method to prevent null pointer exceptions * after deserialization (DG); * 19-Jul-2004 : Fixed bug in getItemLabelFont(int, int) method (DG); * 04-Oct-2004 : Updated equals() method, eliminated use of NumberUtils, * renamed BooleanUtils --> BooleanUtilities, ShapeUtils --> * ShapeUtilities (DG); * 15-Mar-2005 : Fixed serialization of baseFillPaint (DG); * 16-May-2005 : Base outline stroke should never be null (DG); * 01-Jun-2005 : Added hasListener() method for unit testing (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Minor API doc update (DG); * 19-Feb-2007 : Fixes for clone() method (DG); * 28-Feb-2007 : Use cached event to signal changes (DG); * 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG); * 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke, * outlineStroke, shape, itemLabelsVisible, itemLabelFont, * itemLabelPaint, positiveItemLabelPosition, * negativeItemLabelPosition and createEntities override * fields (DG); * 13-Jun-2007 : Added new autoPopulate flags for core series attributes (DG); * 23-Oct-2007 : Updated lookup methods to better handle overridden * methods (DG); * 04-Dec-2007 : Modified hashCode() implementation (DG); * 29-Apr-2008 : Minor API doc update (DG); * 17-Jun-2008 : Added legendShape, legendTextFont and legendTextPaint * attributes (DG); * 18-Aug-2008 : Added clearSeriesPaints() and clearSeriesStrokes() (DG); * 28-Jan-2009 : Equals method doesn't test Shape equality correctly (DG); * 27-Mar-2009 : Added dataBoundsIncludesVisibleSeriesOnly attribute, and * updated renderer events for series visibility changes (DG); * 01-Apr-2009 : Factored up the defaultEntityRadius field from the * AbstractXYItemRenderer class (DG); */ package org.jfree.chart.renderer; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Arrays; import java.util.EventListener; import java.util.List; import javax.swing.event.EventListenerList; import org.jfree.chart.HashUtilities; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.DrawingSupplier; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.title.LegendTitle; import org.jfree.io.SerialUtilities; import org.jfree.ui.TextAnchor; import org.jfree.util.BooleanList; import org.jfree.util.BooleanUtilities; import org.jfree.util.ObjectList; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintList; import org.jfree.util.PaintUtilities; import org.jfree.util.ShapeList; import org.jfree.util.ShapeUtilities; import org.jfree.util.StrokeList; /** * Base class providing common services for renderers. Most methods that update * attributes of the renderer will fire a {@link RendererChangeEvent}, which * normally means the plot that owns the renderer will receive notification that * the renderer has been changed (the plot will, in turn, notify the chart). */ public abstract class AbstractRenderer implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -828267569428206075L; /** Zero represented as a Double. */ public static final Double ZERO = new Double(0.0); /** The default paint. */ public static final Paint DEFAULT_PAINT = Color.blue; /** The default outline paint. */ public static final Paint DEFAULT_OUTLINE_PAINT = Color.gray; /** The default stroke. */ public static final Stroke DEFAULT_STROKE = new BasicStroke(1.0f); /** The default outline stroke. */ public static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(1.0f); /** The default shape. */ public static final Shape DEFAULT_SHAPE = new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0); /** The default value label font. */ public static final Font DEFAULT_VALUE_LABEL_FONT = new Font("SansSerif", Font.PLAIN, 10); /** The default value label paint. */ public static final Paint DEFAULT_VALUE_LABEL_PAINT = Color.black; /** A list of flags that controls whether or not each series is visible. */ private BooleanList seriesVisibleList; /** The default visibility for each series. */ private boolean baseSeriesVisible; /** * A list of flags that controls whether or not each series is visible in * the legend. */ private BooleanList seriesVisibleInLegendList; /** The default visibility for each series in the legend. */ private boolean baseSeriesVisibleInLegend; /** The paint list. */ private PaintList paintList; /** * A flag that controls whether or not the paintList is auto-populated * in the {@link #lookupSeriesPaint(int)} method. * * @since 1.0.6 */ private boolean autoPopulateSeriesPaint; /** The base paint. */ private transient Paint basePaint; /** The fill paint list. */ private PaintList fillPaintList; /** * A flag that controls whether or not the fillPaintList is auto-populated * in the {@link #lookupSeriesFillPaint(int)} method. * * @since 1.0.6 */ private boolean autoPopulateSeriesFillPaint; /** The base fill paint. */ private transient Paint baseFillPaint; /** The outline paint list. */ private PaintList outlinePaintList; /** * A flag that controls whether or not the outlinePaintList is * auto-populated in the {@link #lookupSeriesOutlinePaint(int)} method. * * @since 1.0.6 */ private boolean autoPopulateSeriesOutlinePaint; /** The base outline paint. */ private transient Paint baseOutlinePaint; /** The stroke list. */ private StrokeList strokeList; /** * A flag that controls whether or not the strokeList is auto-populated * in the {@link #lookupSeriesStroke(int)} method. * * @since 1.0.6 */ private boolean autoPopulateSeriesStroke; /** The base stroke. */ private transient Stroke baseStroke; /** The outline stroke list. */ private StrokeList outlineStrokeList; /** The base outline stroke. */ private transient Stroke baseOutlineStroke; /** * A flag that controls whether or not the outlineStrokeList is * auto-populated in the {@link #lookupSeriesOutlineStroke(int)} method. * * @since 1.0.6 */ private boolean autoPopulateSeriesOutlineStroke; /** A shape list. */ private ShapeList shapeList; /** * A flag that controls whether or not the shapeList is auto-populated * in the {@link #lookupSeriesShape(int)} method. * * @since 1.0.6 */ private boolean autoPopulateSeriesShape; /** The base shape. */ private transient Shape baseShape; /** Visibility of the item labels PER series. */ private BooleanList itemLabelsVisibleList; /** The base item labels visible. */ private Boolean baseItemLabelsVisible; /** The item label font list (one font per series). */ private ObjectList itemLabelFontList; /** The base item label font. */ private Font baseItemLabelFont; /** The item label paint list (one paint per series). */ private PaintList itemLabelPaintList; /** The base item label paint. */ private transient Paint baseItemLabelPaint; /** The positive item label position (per series). */ private ObjectList positiveItemLabelPositionList; /** The fallback positive item label position. */ private ItemLabelPosition basePositiveItemLabelPosition; /** The negative item label position (per series). */ private ObjectList negativeItemLabelPositionList; /** The fallback negative item label position. */ private ItemLabelPosition baseNegativeItemLabelPosition; /** The item label anchor offset. */ private double itemLabelAnchorOffset = 2.0; /** * Flags that control whether or not entities are generated for each * series. This will be overridden by 'createEntities'. */ private BooleanList createEntitiesList; /** * The default flag that controls whether or not entities are generated. * This flag is used when both the above flags return null. */ private boolean baseCreateEntities; /** * The per-series legend shape settings. * * @since 1.0.11 */ private ShapeList legendShape; /** * The base shape for legend items. If this is null, the * series shape will be used. * * @since 1.0.11 */ private transient Shape baseLegendShape; /** * The per-series legend text font. * * @since 1.0.11 */ private ObjectList legendTextFont; /** * The base legend font. * * @since 1.0.11 */ private Font baseLegendTextFont; /** * The per series legend text paint settings. * * @since 1.0.11 */ private PaintList legendTextPaint; /** * The default paint for the legend text items (if this is * null, the {@link LegendTitle} class will determine the * text paint to use. * * @since 1.0.11 */ private transient Paint baseLegendTextPaint; /** * A flag that controls whether or not the renderer will include the * non-visible series when calculating the data bounds. * * @since 1.0.13 */ private boolean dataBoundsIncludesVisibleSeriesOnly = true; /** The default radius for the entity 'hotspot' */ private int defaultEntityRadius; /** Storage for registered change listeners. */ private transient EventListenerList listenerList; /** An event for re-use. */ private transient RendererChangeEvent event; /** * Default constructor. */ public AbstractRenderer() { this.seriesVisible = null; this.seriesVisibleList = new BooleanList(); this.baseSeriesVisible = true; this.seriesVisibleInLegend = null; this.seriesVisibleInLegendList = new BooleanList(); this.baseSeriesVisibleInLegend = true; this.paint = null; this.paintList = new PaintList(); this.basePaint = DEFAULT_PAINT; this.autoPopulateSeriesPaint = true; this.fillPaint = null; this.fillPaintList = new PaintList(); this.baseFillPaint = Color.white; this.autoPopulateSeriesFillPaint = false; this.outlinePaint = null; this.outlinePaintList = new PaintList(); this.baseOutlinePaint = DEFAULT_OUTLINE_PAINT; this.autoPopulateSeriesOutlinePaint = false; this.stroke = null; this.strokeList = new StrokeList(); this.baseStroke = DEFAULT_STROKE; this.autoPopulateSeriesStroke = true; this.outlineStroke = null; this.outlineStrokeList = new StrokeList(); this.baseOutlineStroke = DEFAULT_OUTLINE_STROKE; this.autoPopulateSeriesOutlineStroke = false; this.shape = null; this.shapeList = new ShapeList(); this.baseShape = DEFAULT_SHAPE; this.autoPopulateSeriesShape = true; this.itemLabelsVisible = null; this.itemLabelsVisibleList = new BooleanList(); this.baseItemLabelsVisible = Boolean.FALSE; this.itemLabelFont = null; this.itemLabelFontList = new ObjectList(); this.baseItemLabelFont = new Font("SansSerif", Font.PLAIN, 10); this.itemLabelPaint = null; this.itemLabelPaintList = new PaintList(); this.baseItemLabelPaint = Color.black; this.positiveItemLabelPosition = null; this.positiveItemLabelPositionList = new ObjectList(); this.basePositiveItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); this.negativeItemLabelPosition = null; this.negativeItemLabelPositionList = new ObjectList(); this.baseNegativeItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); this.createEntities = null; this.createEntitiesList = new BooleanList(); this.baseCreateEntities = true; this.defaultEntityRadius = 3; this.legendShape = new ShapeList(); this.baseLegendShape = null; this.legendTextFont = new ObjectList(); this.baseLegendTextFont = null; this.legendTextPaint = new PaintList(); this.baseLegendTextPaint = null; this.listenerList = new EventListenerList(); } /** * Returns the drawing supplier from the plot. * * @return The drawing supplier. */ public abstract DrawingSupplier getDrawingSupplier(); // SERIES VISIBLE (not yet respected by all renderers) /** * Returns a boolean that indicates whether or not the specified item * should be drawn (this is typically used to hide an entire series). * * @param series the series index. * @param item the item index. * * @return A boolean. */ public boolean getItemVisible(int series, int item) { return isSeriesVisible(series); } /** * Returns a boolean that indicates whether or not the specified series * should be drawn. * * @param series the series index. * * @return A boolean. */ public boolean isSeriesVisible(int series) { boolean result = this.baseSeriesVisible; if (this.seriesVisible != null) { result = this.seriesVisible.booleanValue(); } else { Boolean b = this.seriesVisibleList.getBoolean(series); if (b != null) { result = b.booleanValue(); } } return result; } /** * Returns the flag that controls whether a series is visible. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesVisible(int, Boolean) */ public Boolean getSeriesVisible(int series) { return this.seriesVisibleList.getBoolean(series); } /** * Sets the flag that controls whether a series is visible and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #getSeriesVisible(int) */ public void setSeriesVisible(int series, Boolean visible) { setSeriesVisible(series, visible, true); } /** * Sets the flag that controls whether a series is visible and, if * requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisible(int) */ public void setSeriesVisible(int series, Boolean visible, boolean notify) { this.seriesVisibleList.setBoolean(series, visible); if (notify) { // we create an event with a special flag set...the purpose of // this is to communicate to the plot (the default receiver of // the event) that series visibility has changed so the axis // ranges might need updating... RendererChangeEvent e = new RendererChangeEvent(this, true); notifyListeners(e); } } /** * Returns the base visibility for all series. * * @return The base visibility. * * @see #setBaseSeriesVisible(boolean) */ public boolean getBaseSeriesVisible() { return this.baseSeriesVisible; } /** * Sets the base visibility and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param visible the flag. * * @see #getBaseSeriesVisible() */ public void setBaseSeriesVisible(boolean visible) { // defer argument checking... setBaseSeriesVisible(visible, true); } /** * Sets the base visibility and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility. * @param notify notify listeners? * * @see #getBaseSeriesVisible() */ public void setBaseSeriesVisible(boolean visible, boolean notify) { this.baseSeriesVisible = visible; if (notify) { // we create an event with a special flag set...the purpose of // this is to communicate to the plot (the default receiver of // the event) that series visibility has changed so the axis // ranges might need updating... RendererChangeEvent e = new RendererChangeEvent(this, true); notifyListeners(e); } } // SERIES VISIBLE IN LEGEND (not yet respected by all renderers) /** * Returns true if the series should be shown in the legend, * and false otherwise. * * @param series the series index. * * @return A boolean. */ public boolean isSeriesVisibleInLegend(int series) { boolean result = this.baseSeriesVisibleInLegend; if (this.seriesVisibleInLegend != null) { result = this.seriesVisibleInLegend.booleanValue(); } else { Boolean b = this.seriesVisibleInLegendList.getBoolean(series); if (b != null) { result = b.booleanValue(); } } return result; } /** * Returns the flag that controls whether a series is visible in the * legend. This method returns only the "per series" settings - to * incorporate the override and base settings as well, you need to use the * {@link #isSeriesVisibleInLegend(int)} method. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesVisibleInLegend(int, Boolean) */ public Boolean getSeriesVisibleInLegend(int series) { return this.seriesVisibleInLegendList.getBoolean(series); } /** * Sets the flag that controls whether a series is visible in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). * * @see #getSeriesVisibleInLegend(int) */ public void setSeriesVisibleInLegend(int series, Boolean visible) { setSeriesVisibleInLegend(series, visible, true); } /** * Sets the flag that controls whether a series is visible in the legend * and, if requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisibleInLegend(int) */ public void setSeriesVisibleInLegend(int series, Boolean visible, boolean notify) { this.seriesVisibleInLegendList.setBoolean(series, visible); if (notify) { fireChangeEvent(); } } /** * Returns the base visibility in the legend for all series. * * @return The base visibility. * * @see #setBaseSeriesVisibleInLegend(boolean) */ public boolean getBaseSeriesVisibleInLegend() { return this.baseSeriesVisibleInLegend; } /** * Sets the base visibility in the legend and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getBaseSeriesVisibleInLegend() */ public void setBaseSeriesVisibleInLegend(boolean visible) { // defer argument checking... setBaseSeriesVisibleInLegend(visible, true); } /** * Sets the base visibility in the legend and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param visible the visibility. * @param notify notify listeners? * * @see #getBaseSeriesVisibleInLegend() */ public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify) { this.baseSeriesVisibleInLegend = visible; if (notify) { fireChangeEvent(); } } // PAINT /** * Returns the paint used to fill data items as they are drawn. *

* The default implementation passes control to the * lookupSeriesPaint() method. You can override this method * if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemPaint(int row, int column) { return lookupSeriesPaint(row); } /** * Returns the paint used to fill an item drawn by the renderer. * * @param series the series index (zero-based). * * @return The paint (never null). * * @since 1.0.6 */ public Paint lookupSeriesPaint(int series) { // return the override, if there is one... if (this.paint != null) { return this.paint; } // otherwise look up the paint list Paint seriesPaint = getSeriesPaint(series); if (seriesPaint == null && this.autoPopulateSeriesPaint) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { seriesPaint = supplier.getNextPaint(); setSeriesPaint(series, seriesPaint, false); } } if (seriesPaint == null) { seriesPaint = this.basePaint; } return seriesPaint; } /** * Returns the paint used to fill an item drawn by the renderer. * * @param series the series index (zero-based). * * @return The paint (possibly null). * * @see #setSeriesPaint(int, Paint) */ public Paint getSeriesPaint(int series) { return this.paintList.getPaint(series); } /** * Sets the paint used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesPaint(int) */ public void setSeriesPaint(int series, Paint paint) { setSeriesPaint(series, paint, true); } /** * Sets the paint used for a series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index. * @param paint the paint (null permitted). * @param notify notify listeners? * * @see #getSeriesPaint(int) */ public void setSeriesPaint(int series, Paint paint, boolean notify) { this.paintList.setPaint(series, paint); if (notify) { fireChangeEvent(); } } /** * Clears the series paint settings for this renderer and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param notify notify listeners? * * @since 1.0.11 */ public void clearSeriesPaints(boolean notify) { this.paintList.clear(); if (notify) { fireChangeEvent(); } } /** * Returns the base paint. * * @return The base paint (never null). * * @see #setBasePaint(Paint) */ public Paint getBasePaint() { return this.basePaint; } /** * Sets the base paint and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param paint the paint (null not permitted). * * @see #getBasePaint() */ public void setBasePaint(Paint paint) { // defer argument checking... setBasePaint(paint, true); } /** * Sets the base paint and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * @param notify notify listeners? * * @see #getBasePaint() */ public void setBasePaint(Paint paint, boolean notify) { this.basePaint = paint; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not the series paint list is * automatically populated when {@link #lookupSeriesPaint(int)} is called. * * @return A boolean. * * @since 1.0.6 * * @see #setAutoPopulateSeriesPaint(boolean) */ public boolean getAutoPopulateSeriesPaint() { return this.autoPopulateSeriesPaint; } /** * Sets the flag that controls whether or not the series paint list is * automatically populated when {@link #lookupSeriesPaint(int)} is called. * * @param auto the new flag value. * * @since 1.0.6 * * @see #getAutoPopulateSeriesPaint() */ public void setAutoPopulateSeriesPaint(boolean auto) { this.autoPopulateSeriesPaint = auto; } //// FILL PAINT ////////////////////////////////////////////////////////// /** * Returns the paint used to fill data items as they are drawn. The * default implementation passes control to the * {@link #lookupSeriesFillPaint(int)} method - you can override this * method if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemFillPaint(int row, int column) { return lookupSeriesFillPaint(row); } /** * Returns the paint used to fill an item drawn by the renderer. * * @param series the series (zero-based index). * * @return The paint (never null). * * @since 1.0.6 */ public Paint lookupSeriesFillPaint(int series) { // return the override, if there is one... if (this.fillPaint != null) { return this.fillPaint; } // otherwise look up the paint table Paint seriesFillPaint = getSeriesFillPaint(series); if (seriesFillPaint == null && this.autoPopulateSeriesFillPaint) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { seriesFillPaint = supplier.getNextFillPaint(); setSeriesFillPaint(series, seriesFillPaint, false); } } if (seriesFillPaint == null) { seriesFillPaint = this.baseFillPaint; } return seriesFillPaint; } /** * Returns the paint used to fill an item drawn by the renderer. * * @param series the series (zero-based index). * * @return The paint (never null). * * @see #setSeriesFillPaint(int, Paint) */ public Paint getSeriesFillPaint(int series) { return this.fillPaintList.getPaint(series); } /** * Sets the paint used for a series fill and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesFillPaint(int) */ public void setSeriesFillPaint(int series, Paint paint) { setSeriesFillPaint(series, paint, true); } /** * Sets the paint used to fill a series and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * @param notify notify listeners? * * @see #getSeriesFillPaint(int) */ public void setSeriesFillPaint(int series, Paint paint, boolean notify) { this.fillPaintList.setPaint(series, paint); if (notify) { fireChangeEvent(); } } /** * Returns the base fill paint. * * @return The paint (never null). * * @see #setBaseFillPaint(Paint) */ public Paint getBaseFillPaint() { return this.baseFillPaint; } /** * Sets the base fill paint and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseFillPaint() */ public void setBaseFillPaint(Paint paint) { // defer argument checking... setBaseFillPaint(paint, true); } /** * Sets the base fill paint and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * @param notify notify listeners? * * @see #getBaseFillPaint() */ public void setBaseFillPaint(Paint paint, boolean notify) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseFillPaint = paint; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not the series fill paint list * is automatically populated when {@link #lookupSeriesFillPaint(int)} is * called. * * @return A boolean. * * @since 1.0.6 * * @see #setAutoPopulateSeriesFillPaint(boolean) */ public boolean getAutoPopulateSeriesFillPaint() { return this.autoPopulateSeriesFillPaint; } /** * Sets the flag that controls whether or not the series fill paint list is * automatically populated when {@link #lookupSeriesFillPaint(int)} is * called. * * @param auto the new flag value. * * @since 1.0.6 * * @see #getAutoPopulateSeriesFillPaint() */ public void setAutoPopulateSeriesFillPaint(boolean auto) { this.autoPopulateSeriesFillPaint = auto; } // OUTLINE PAINT ////////////////////////////////////////////////////////// /** * Returns the paint used to outline data items as they are drawn. *

* The default implementation passes control to the * {@link #lookupSeriesOutlinePaint} method. You can override this method * if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never null). */ public Paint getItemOutlinePaint(int row, int column) { return lookupSeriesOutlinePaint(row); } /** * Returns the paint used to outline an item drawn by the renderer. * * @param series the series (zero-based index). * * @return The paint (never null). * * @since 1.0.6 */ public Paint lookupSeriesOutlinePaint(int series) { // return the override, if there is one... if (this.outlinePaint != null) { return this.outlinePaint; } // otherwise look up the paint table Paint seriesOutlinePaint = getSeriesOutlinePaint(series); if (seriesOutlinePaint == null && this.autoPopulateSeriesOutlinePaint) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { seriesOutlinePaint = supplier.getNextOutlinePaint(); setSeriesOutlinePaint(series, seriesOutlinePaint, false); } } if (seriesOutlinePaint == null) { seriesOutlinePaint = this.baseOutlinePaint; } return seriesOutlinePaint; } /** * Returns the paint used to outline an item drawn by the renderer. * * @param series the series (zero-based index). * * @return The paint (possibly null). * * @see #setSeriesOutlinePaint(int, Paint) */ public Paint getSeriesOutlinePaint(int series) { return this.outlinePaintList.getPaint(series); } /** * Sets the paint used for a series outline and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * * @see #getSeriesOutlinePaint(int) */ public void setSeriesOutlinePaint(int series, Paint paint) { setSeriesOutlinePaint(series, paint, true); } /** * Sets the paint used to draw the outline for a series and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param paint the paint (null permitted). * @param notify notify listeners? * * @see #getSeriesOutlinePaint(int) */ public void setSeriesOutlinePaint(int series, Paint paint, boolean notify) { this.outlinePaintList.setPaint(series, paint); if (notify) { fireChangeEvent(); } } /** * Returns the base outline paint. * * @return The paint (never null). * * @see #setBaseOutlinePaint(Paint) */ public Paint getBaseOutlinePaint() { return this.baseOutlinePaint; } /** * Sets the base outline paint and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseOutlinePaint() */ public void setBaseOutlinePaint(Paint paint) { // defer argument checking... setBaseOutlinePaint(paint, true); } /** * Sets the base outline paint and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * @param notify notify listeners? * * @see #getBaseOutlinePaint() */ public void setBaseOutlinePaint(Paint paint, boolean notify) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseOutlinePaint = paint; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not the series outline paint * list is automatically populated when * {@link #lookupSeriesOutlinePaint(int)} is called. * * @return A boolean. * * @since 1.0.6 * * @see #setAutoPopulateSeriesOutlinePaint(boolean) */ public boolean getAutoPopulateSeriesOutlinePaint() { return this.autoPopulateSeriesOutlinePaint; } /** * Sets the flag that controls whether or not the series outline paint list * is automatically populated when {@link #lookupSeriesOutlinePaint(int)} * is called. * * @param auto the new flag value. * * @since 1.0.6 * * @see #getAutoPopulateSeriesOutlinePaint() */ public void setAutoPopulateSeriesOutlinePaint(boolean auto) { this.autoPopulateSeriesOutlinePaint = auto; } // STROKE /** * Returns the stroke used to draw data items. *

* The default implementation passes control to the getSeriesStroke method. * You can override this method if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The stroke (never null). */ public Stroke getItemStroke(int row, int column) { return lookupSeriesStroke(row); } /** * Returns the stroke used to draw the items in a series. * * @param series the series (zero-based index). * * @return The stroke (never null). * * @since 1.0.6 */ public Stroke lookupSeriesStroke(int series) { // return the override, if there is one... if (this.stroke != null) { return this.stroke; } // otherwise look up the paint table Stroke result = getSeriesStroke(series); if (result == null && this.autoPopulateSeriesStroke) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { result = supplier.getNextStroke(); setSeriesStroke(series, result, false); } } if (result == null) { result = this.baseStroke; } return result; } /** * Returns the stroke used to draw the items in a series. * * @param series the series (zero-based index). * * @return The stroke (possibly null). * * @see #setSeriesStroke(int, Stroke) */ public Stroke getSeriesStroke(int series) { return this.strokeList.getStroke(series); } /** * Sets the stroke used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * * @see #getSeriesStroke(int) */ public void setSeriesStroke(int series, Stroke stroke) { setSeriesStroke(series, stroke, true); } /** * Sets the stroke for a series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * @param notify notify listeners? * * @see #getSeriesStroke(int) */ public void setSeriesStroke(int series, Stroke stroke, boolean notify) { this.strokeList.setStroke(series, stroke); if (notify) { fireChangeEvent(); } } /** * Clears the series stroke settings for this renderer and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param notify notify listeners? * * @since 1.0.11 */ public void clearSeriesStrokes(boolean notify) { this.strokeList.clear(); if (notify) { fireChangeEvent(); } } /** * Returns the base stroke. * * @return The base stroke (never null). * * @see #setBaseStroke(Stroke) */ public Stroke getBaseStroke() { return this.baseStroke; } /** * Sets the base stroke and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getBaseStroke() */ public void setBaseStroke(Stroke stroke) { // defer argument checking... setBaseStroke(stroke, true); } /** * Sets the base stroke and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * @param notify notify listeners? * * @see #getBaseStroke() */ public void setBaseStroke(Stroke stroke, boolean notify) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.baseStroke = stroke; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not the series stroke list is * automatically populated when {@link #lookupSeriesStroke(int)} is called. * * @return A boolean. * * @since 1.0.6 * * @see #setAutoPopulateSeriesStroke(boolean) */ public boolean getAutoPopulateSeriesStroke() { return this.autoPopulateSeriesStroke; } /** * Sets the flag that controls whether or not the series stroke list is * automatically populated when {@link #lookupSeriesStroke(int)} is called. * * @param auto the new flag value. * * @since 1.0.6 * * @see #getAutoPopulateSeriesStroke() */ public void setAutoPopulateSeriesStroke(boolean auto) { this.autoPopulateSeriesStroke = auto; } // OUTLINE STROKE /** * Returns the stroke used to outline data items. The default * implementation passes control to the * {@link #lookupSeriesOutlineStroke(int)} method. You can override this * method if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The stroke (never null). */ public Stroke getItemOutlineStroke(int row, int column) { return lookupSeriesOutlineStroke(row); } /** * Returns the stroke used to outline the items in a series. * * @param series the series (zero-based index). * * @return The stroke (never null). * * @since 1.0.6 */ public Stroke lookupSeriesOutlineStroke(int series) { // return the override, if there is one... if (this.outlineStroke != null) { return this.outlineStroke; } // otherwise look up the stroke table Stroke result = getSeriesOutlineStroke(series); if (result == null && this.autoPopulateSeriesOutlineStroke) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { result = supplier.getNextOutlineStroke(); setSeriesOutlineStroke(series, result, false); } } if (result == null) { result = this.baseOutlineStroke; } return result; } /** * Returns the stroke used to outline the items in a series. * * @param series the series (zero-based index). * * @return The stroke (possibly null). * * @see #setSeriesOutlineStroke(int, Stroke) */ public Stroke getSeriesOutlineStroke(int series) { return this.outlineStrokeList.getStroke(series); } /** * Sets the outline stroke used for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param stroke the stroke (null permitted). * * @see #getSeriesOutlineStroke(int) */ public void setSeriesOutlineStroke(int series, Stroke stroke) { setSeriesOutlineStroke(series, stroke, true); } /** * Sets the outline stroke for a series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index. * @param stroke the stroke (null permitted). * @param notify notify listeners? * * @see #getSeriesOutlineStroke(int) */ public void setSeriesOutlineStroke(int series, Stroke stroke, boolean notify) { this.outlineStrokeList.setStroke(series, stroke); if (notify) { fireChangeEvent(); } } /** * Returns the base outline stroke. * * @return The stroke (never null). * * @see #setBaseOutlineStroke(Stroke) */ public Stroke getBaseOutlineStroke() { return this.baseOutlineStroke; } /** * Sets the base outline stroke and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getBaseOutlineStroke() */ public void setBaseOutlineStroke(Stroke stroke) { setBaseOutlineStroke(stroke, true); } /** * Sets the base outline stroke and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @see #getBaseOutlineStroke() */ public void setBaseOutlineStroke(Stroke stroke, boolean notify) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.baseOutlineStroke = stroke; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not the series outline stroke * list is automatically populated when * {@link #lookupSeriesOutlineStroke(int)} is called. * * @return A boolean. * * @since 1.0.6 * * @see #setAutoPopulateSeriesOutlineStroke(boolean) */ public boolean getAutoPopulateSeriesOutlineStroke() { return this.autoPopulateSeriesOutlineStroke; } /** * Sets the flag that controls whether or not the series outline stroke list * is automatically populated when {@link #lookupSeriesOutlineStroke(int)} * is called. * * @param auto the new flag value. * * @since 1.0.6 * * @see #getAutoPopulateSeriesOutlineStroke() */ public void setAutoPopulateSeriesOutlineStroke(boolean auto) { this.autoPopulateSeriesOutlineStroke = auto; } // SHAPE /** * Returns a shape used to represent a data item. *

* The default implementation passes control to the getSeriesShape method. * You can override this method if you require different behaviour. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The shape (never null). */ public Shape getItemShape(int row, int column) { return lookupSeriesShape(row); } /** * Returns a shape used to represent the items in a series. * * @param series the series (zero-based index). * * @return The shape (never null). * * @since 1.0.6 */ public Shape lookupSeriesShape(int series) { // return the override, if there is one... if (this.shape != null) { return this.shape; } // otherwise look up the shape list Shape result = getSeriesShape(series); if (result == null && this.autoPopulateSeriesShape) { DrawingSupplier supplier = getDrawingSupplier(); if (supplier != null) { result = supplier.getNextShape(); setSeriesShape(series, result, false); } } if (result == null) { result = this.baseShape; } return result; } /** * Returns a shape used to represent the items in a series. * * @param series the series (zero-based index). * * @return The shape (possibly null). * * @see #setSeriesShape(int, Shape) */ public Shape getSeriesShape(int series) { return this.shapeList.getShape(series); } /** * Sets the shape used for a series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param series the series index (zero-based). * @param shape the shape (null permitted). * * @see #getSeriesShape(int) */ public void setSeriesShape(int series, Shape shape) { setSeriesShape(series, shape, true); } /** * Sets the shape for a series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param shape the shape (null permitted). * @param notify notify listeners? * * @see #getSeriesShape(int) */ public void setSeriesShape(int series, Shape shape, boolean notify) { this.shapeList.setShape(series, shape); if (notify) { fireChangeEvent(); } } /** * Returns the base shape. * * @return The shape (never null). * * @see #setBaseShape(Shape) */ public Shape getBaseShape() { return this.baseShape; } /** * Sets the base shape and sends a {@link RendererChangeEvent} to all * registered listeners. * * @param shape the shape (null not permitted). * * @see #getBaseShape() */ public void setBaseShape(Shape shape) { // defer argument checking... setBaseShape(shape, true); } /** * Sets the base shape and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null not permitted). * @param notify notify listeners? * * @see #getBaseShape() */ public void setBaseShape(Shape shape, boolean notify) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } this.baseShape = shape; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not the series shape list is * automatically populated when {@link #lookupSeriesShape(int)} is called. * * @return A boolean. * * @since 1.0.6 * * @see #setAutoPopulateSeriesShape(boolean) */ public boolean getAutoPopulateSeriesShape() { return this.autoPopulateSeriesShape; } /** * Sets the flag that controls whether or not the series shape list is * automatically populated when {@link #lookupSeriesShape(int)} is called. * * @param auto the new flag value. * * @since 1.0.6 * * @see #getAutoPopulateSeriesShape() */ public void setAutoPopulateSeriesShape(boolean auto) { this.autoPopulateSeriesShape = auto; } // ITEM LABEL VISIBILITY... /** * Returns true if an item label is visible, and * false otherwise. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return A boolean. */ public boolean isItemLabelVisible(int row, int column) { return isSeriesItemLabelsVisible(row); } /** * Returns true if the item labels for a series are visible, * and false otherwise. * * @param series the series index (zero-based). * * @return A boolean. */ public boolean isSeriesItemLabelsVisible(int series) { // return the override, if there is one... if (this.itemLabelsVisible != null) { return this.itemLabelsVisible.booleanValue(); } // otherwise look up the boolean table Boolean b = this.itemLabelsVisibleList.getBoolean(series); if (b == null) { b = this.baseItemLabelsVisible; } if (b == null) { b = Boolean.FALSE; } return b.booleanValue(); } /** * Sets a flag that controls the visibility of the item labels for a series, * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag. */ public void setSeriesItemLabelsVisible(int series, boolean visible) { setSeriesItemLabelsVisible(series, BooleanUtilities.valueOf(visible)); } /** * Sets the visibility of the item labels for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the flag (null permitted). */ public void setSeriesItemLabelsVisible(int series, Boolean visible) { setSeriesItemLabelsVisible(series, visible, true); } /** * Sets the visibility of item labels for a series and, if requested, sends * a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param visible the visible flag. * @param notify a flag that controls whether or not listeners are * notified. */ public void setSeriesItemLabelsVisible(int series, Boolean visible, boolean notify) { this.itemLabelsVisibleList.setBoolean(series, visible); if (notify) { fireChangeEvent(); } } /** * Returns the base setting for item label visibility. A null * result should be interpreted as equivalent to Boolean.FALSE. * * @return A flag (possibly null). * * @see #setBaseItemLabelsVisible(boolean) */ public Boolean getBaseItemLabelsVisible() { // this should have been defined as a boolean primitive, because // allowing null values is a nuisance...but it is part of the final // API now, so we'll have to support it. return this.baseItemLabelsVisible; } /** * Sets the base flag that controls whether or not item labels are visible, * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag. * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(boolean visible) { setBaseItemLabelsVisible(BooleanUtilities.valueOf(visible)); } /** * Sets the base setting for item label visibility and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag (null is permitted, and viewed * as equivalent to Boolean.FALSE). */ public void setBaseItemLabelsVisible(Boolean visible) { setBaseItemLabelsVisible(visible, true); } /** * Sets the base visibility for item labels and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visible the flag (null is permitted, and viewed * as equivalent to Boolean.FALSE). * @param notify a flag that controls whether or not listeners are * notified. * * @see #getBaseItemLabelsVisible() */ public void setBaseItemLabelsVisible(Boolean visible, boolean notify) { this.baseItemLabelsVisible = visible; if (notify) { fireChangeEvent(); } } //// ITEM LABEL FONT ////////////////////////////////////////////////////// /** * Returns the font for an item label. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The font (never null). */ public Font getItemLabelFont(int row, int column) { Font result = this.itemLabelFont; if (result == null) { result = getSeriesItemLabelFont(row); if (result == null) { result = this.baseItemLabelFont; } } return result; } /** * Returns the font for all the item labels in a series. * * @param series the series index (zero-based). * * @return The font (possibly null). * * @see #setSeriesItemLabelFont(int, Font) */ public Font getSeriesItemLabelFont(int series) { return (Font) this.itemLabelFontList.get(series); } /** * Sets the item label font for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param font the font (null permitted). * * @see #getSeriesItemLabelFont(int) */ public void setSeriesItemLabelFont(int series, Font font) { setSeriesItemLabelFont(series, font, true); } /** * Sets the item label font for a series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param font the font (null permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @see #getSeriesItemLabelFont(int) */ public void setSeriesItemLabelFont(int series, Font font, boolean notify) { this.itemLabelFontList.set(series, font); if (notify) { fireChangeEvent(); } } /** * Returns the base item label font (this is used when no other font * setting is available). * * @return The font (never null). * * @see #setBaseItemLabelFont(Font) */ public Font getBaseItemLabelFont() { return this.baseItemLabelFont; } /** * Sets the base item label font and sends a {@link RendererChangeEvent} to * all registered listeners. * * @param font the font (null not permitted). * * @see #getBaseItemLabelFont() */ public void setBaseItemLabelFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } setBaseItemLabelFont(font, true); } /** * Sets the base item label font and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param font the font (null not permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @see #getBaseItemLabelFont() */ public void setBaseItemLabelFont(Font font, boolean notify) { this.baseItemLabelFont = font; if (notify) { fireChangeEvent(); } } //// ITEM LABEL PAINT //////////////////////////////////////////////////// /** * Returns the paint used to draw an item label. * * @param row the row index (zero based). * @param column the column index (zero based). * * @return The paint (never null). */ public Paint getItemLabelPaint(int row, int column) { Paint result = this.itemLabelPaint; if (result == null) { result = getSeriesItemLabelPaint(row); if (result == null) { result = this.baseItemLabelPaint; } } return result; } /** * Returns the paint used to draw the item labels for a series. * * @param series the series index (zero based). * * @return The paint (possibly null). * * @see #setSeriesItemLabelPaint(int, Paint) */ public Paint getSeriesItemLabelPaint(int series) { return this.itemLabelPaintList.getPaint(series); } /** * Sets the item label paint for a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series (zero based index). * @param paint the paint (null permitted). * * @see #getSeriesItemLabelPaint(int) */ public void setSeriesItemLabelPaint(int series, Paint paint) { setSeriesItemLabelPaint(series, paint, true); } /** * Sets the item label paint for a series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero based). * @param paint the paint (null permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @see #getSeriesItemLabelPaint(int) */ public void setSeriesItemLabelPaint(int series, Paint paint, boolean notify) { this.itemLabelPaintList.setPaint(series, paint); if (notify) { fireChangeEvent(); } } /** * Returns the base item label paint. * * @return The paint (never null). * * @see #setBaseItemLabelPaint(Paint) */ public Paint getBaseItemLabelPaint() { return this.baseItemLabelPaint; } /** * Sets the base item label paint and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getBaseItemLabelPaint() */ public void setBaseItemLabelPaint(Paint paint) { // defer argument checking... setBaseItemLabelPaint(paint, true); } /** * Sets the base item label paint and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners.. * * @param paint the paint (null not permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @see #getBaseItemLabelPaint() */ public void setBaseItemLabelPaint(Paint paint, boolean notify) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baseItemLabelPaint = paint; if (notify) { fireChangeEvent(); } } // POSITIVE ITEM LABEL POSITION... /** * Returns the item label position for positive values. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The item label position (never null). * * @see #getNegativeItemLabelPosition(int, int) */ public ItemLabelPosition getPositiveItemLabelPosition(int row, int column) { return getSeriesPositiveItemLabelPosition(row); } /** * Returns the item label position for all positive values in a series. * * @param series the series index (zero-based). * * @return The item label position (never null). * * @see #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition) */ public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series) { // return the override, if there is one... if (this.positiveItemLabelPosition != null) { return this.positiveItemLabelPosition; } // otherwise look up the position table ItemLabelPosition position = (ItemLabelPosition) this.positiveItemLabelPositionList.get(series); if (position == null) { position = this.basePositiveItemLabelPosition; } return position; } /** * Sets the item label position for all positive values in a series and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * * @see #getSeriesPositiveItemLabelPosition(int) */ public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position) { setSeriesPositiveItemLabelPosition(series, position, true); } /** * Sets the item label position for all positive values in a series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getSeriesPositiveItemLabelPosition(int) */ public void setSeriesPositiveItemLabelPosition(int series, ItemLabelPosition position, boolean notify) { this.positiveItemLabelPositionList.set(series, position); if (notify) { fireChangeEvent(); } } /** * Returns the base positive item label position. * * @return The position (never null). * * @see #setBasePositiveItemLabelPosition(ItemLabelPosition) */ public ItemLabelPosition getBasePositiveItemLabelPosition() { return this.basePositiveItemLabelPosition; } /** * Sets the base positive item label position. * * @param position the position (null not permitted). * * @see #getBasePositiveItemLabelPosition() */ public void setBasePositiveItemLabelPosition(ItemLabelPosition position) { // defer argument checking... setBasePositiveItemLabelPosition(position, true); } /** * Sets the base positive item label position and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null not permitted). * @param notify notify registered listeners? * * @see #getBasePositiveItemLabelPosition() */ public void setBasePositiveItemLabelPosition(ItemLabelPosition position, boolean notify) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } this.basePositiveItemLabelPosition = position; if (notify) { fireChangeEvent(); } } // NEGATIVE ITEM LABEL POSITION... /** * Returns the item label position for negative values. This method can be * overridden to provide customisation of the item label position for * individual data items. * * @param row the row index (zero-based). * @param column the column (zero-based). * * @return The item label position (never null). * * @see #getPositiveItemLabelPosition(int, int) */ public ItemLabelPosition getNegativeItemLabelPosition(int row, int column) { return getSeriesNegativeItemLabelPosition(row); } /** * Returns the item label position for all negative values in a series. * * @param series the series index (zero-based). * * @return The item label position (never null). * * @see #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition) */ public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series) { // return the override, if there is one... if (this.negativeItemLabelPosition != null) { return this.negativeItemLabelPosition; } // otherwise look up the position list ItemLabelPosition position = (ItemLabelPosition) this.negativeItemLabelPositionList.get(series); if (position == null) { position = this.baseNegativeItemLabelPosition; } return position; } /** * Sets the item label position for negative values in a series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * * @see #getSeriesNegativeItemLabelPosition(int) */ public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position) { setSeriesNegativeItemLabelPosition(series, position, true); } /** * Sets the item label position for negative values in a series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index (zero-based). * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getSeriesNegativeItemLabelPosition(int) */ public void setSeriesNegativeItemLabelPosition(int series, ItemLabelPosition position, boolean notify) { this.negativeItemLabelPositionList.set(series, position); if (notify) { fireChangeEvent(); } } /** * Returns the base item label position for negative values. * * @return The position (never null). * * @see #setBaseNegativeItemLabelPosition(ItemLabelPosition) */ public ItemLabelPosition getBaseNegativeItemLabelPosition() { return this.baseNegativeItemLabelPosition; } /** * Sets the base item label position for negative values and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null not permitted). * * @see #getBaseNegativeItemLabelPosition() */ public void setBaseNegativeItemLabelPosition(ItemLabelPosition position) { setBaseNegativeItemLabelPosition(position, true); } /** * Sets the base negative item label position and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null not permitted). * @param notify notify registered listeners? * * @see #getBaseNegativeItemLabelPosition() */ public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, boolean notify) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } this.baseNegativeItemLabelPosition = position; if (notify) { fireChangeEvent(); } } /** * Returns the item label anchor offset. * * @return The offset. * * @see #setItemLabelAnchorOffset(double) */ public double getItemLabelAnchorOffset() { return this.itemLabelAnchorOffset; } /** * Sets the item label anchor offset. * * @param offset the offset. * * @see #getItemLabelAnchorOffset() */ public void setItemLabelAnchorOffset(double offset) { this.itemLabelAnchorOffset = offset; fireChangeEvent(); } /** * Returns a boolean that indicates whether or not the specified item * should have a chart entity created for it. * * @param series the series index. * @param item the item index. * * @return A boolean. */ public boolean getItemCreateEntity(int series, int item) { if (this.createEntities != null) { return this.createEntities.booleanValue(); } else { Boolean b = getSeriesCreateEntities(series); if (b != null) { return b.booleanValue(); } else { return this.baseCreateEntities; } } } /** * Returns the flag that controls whether entities are created for a * series. * * @param series the series index (zero-based). * * @return The flag (possibly null). * * @see #setSeriesCreateEntities(int, Boolean) */ public Boolean getSeriesCreateEntities(int series) { return this.createEntitiesList.getBoolean(series); } /** * Sets the flag that controls whether entities are created for a series, * and sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * @param create the flag (null permitted). * * @see #getSeriesCreateEntities(int) */ public void setSeriesCreateEntities(int series, Boolean create) { setSeriesCreateEntities(series, create, true); } /** * Sets the flag that controls whether entities are created for a series * and, if requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param series the series index. * @param create the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesCreateEntities(int) */ public void setSeriesCreateEntities(int series, Boolean create, boolean notify) { this.createEntitiesList.setBoolean(series, create); if (notify) { fireChangeEvent(); } } /** * Returns the base visibility for all series. * * @return The base visibility. * * @see #setBaseCreateEntities(boolean) */ public boolean getBaseCreateEntities() { return this.baseCreateEntities; } /** * Sets the base flag that controls whether entities are created * for a series, and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param create the flag. * * @see #getBaseCreateEntities() */ public void setBaseCreateEntities(boolean create) { // defer argument checking... setBaseCreateEntities(create, true); } /** * Sets the base flag that controls whether entities are created and, * if requested, sends a {@link RendererChangeEvent} to all registered * listeners. * * @param create the visibility. * @param notify notify listeners? * * @see #getBaseCreateEntities() */ public void setBaseCreateEntities(boolean create, boolean notify) { this.baseCreateEntities = create; if (notify) { fireChangeEvent(); } } /** * Returns the radius of the circle used for the default entity area * when no area is specified. * * @return A radius. * * @see #setDefaultEntityRadius(int) */ public int getDefaultEntityRadius() { return this.defaultEntityRadius; } /** * Sets the radius of the circle used for the default entity area * when no area is specified. * * @param radius the radius. * * @see #getDefaultEntityRadius() */ public void setDefaultEntityRadius(int radius) { this.defaultEntityRadius = radius; } /** * Performs a lookup for the legend shape. * * @param series the series index. * * @return The shape (possibly null). * * @since 1.0.11 */ public Shape lookupLegendShape(int series) { Shape result = getLegendShape(series); if (result == null) { result = this.baseLegendShape; } if (result == null) { result = lookupSeriesShape(series); } return result; } /** * Returns the legend shape defined for the specified series (possibly * null). * * @param series the series index. * * @return The shape (possibly null). * * @see #lookupLegendShape(int) * * @since 1.0.11 */ public Shape getLegendShape(int series) { return this.legendShape.getShape(series); } /** * Sets the shape used for the legend item for the specified series, and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index. * @param shape the shape (null permitted). * * @since 1.0.11 */ public void setLegendShape(int series, Shape shape) { this.legendShape.setShape(series, shape); fireChangeEvent(); } /** * Returns the default legend shape, which may be null. * * @return The default legend shape. * * @since 1.0.11 */ public Shape getBaseLegendShape() { return this.baseLegendShape; } /** * Sets the default legend shape and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null permitted). * * @since 1.0.11 */ public void setBaseLegendShape(Shape shape) { this.baseLegendShape = shape; fireChangeEvent(); } /** * Performs a lookup for the legend text font. * * @param series the series index. * * @return The font (possibly null). * * @since 1.0.11 */ public Font lookupLegendTextFont(int series) { Font result = getLegendTextFont(series); if (result == null) { result = this.baseLegendTextFont; } return result; } /** * Returns the legend text font defined for the specified series (possibly * null). * * @param series the series index. * * @return The font (possibly null). * * @see #lookupLegendTextFont(int) * * @since 1.0.11 */ public Font getLegendTextFont(int series) { return (Font) this.legendTextFont.get(series); } /** * Sets the font used for the legend text for the specified series, and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index. * @param font the font (null permitted). * * @since 1.0.11 */ public void setLegendTextFont(int series, Font font) { this.legendTextFont.set(series, font); fireChangeEvent(); } /** * Returns the default legend text font, which may be null. * * @return The default legend text font. * * @since 1.0.11 */ public Font getBaseLegendTextFont() { return this.baseLegendTextFont; } /** * Sets the default legend text font and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param font the font (null permitted). * * @since 1.0.11 */ public void setBaseLegendTextFont(Font font) { this.baseLegendTextFont = font; fireChangeEvent(); } /** * Performs a lookup for the legend text paint. * * @param series the series index. * * @return The paint (possibly null). * * @since 1.0.11 */ public Paint lookupLegendTextPaint(int series) { Paint result = getLegendTextPaint(series); if (result == null) { result = this.baseLegendTextPaint; } return result; } /** * Returns the legend text paint defined for the specified series (possibly * null). * * @param series the series index. * * @return The paint (possibly null). * * @see #lookupLegendTextPaint(int) * * @since 1.0.11 */ public Paint getLegendTextPaint(int series) { return this.legendTextPaint.getPaint(series); } /** * Sets the paint used for the legend text for the specified series, and * sends a {@link RendererChangeEvent} to all registered listeners. * * @param series the series index. * @param paint the paint (null permitted). * * @since 1.0.11 */ public void setLegendTextPaint(int series, Paint paint) { this.legendTextPaint.setPaint(series, paint); fireChangeEvent(); } /** * Returns the default legend text paint, which may be null. * * @return The default legend text paint. * * @since 1.0.11 */ public Paint getBaseLegendTextPaint() { return this.baseLegendTextPaint; } /** * Sets the default legend text paint and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @since 1.0.11 */ public void setBaseLegendTextPaint(Paint paint) { this.baseLegendTextPaint = paint; fireChangeEvent(); } /** * Returns the flag that controls whether or not the data bounds reported * by this renderer will exclude non-visible series. * * @return A boolean. * * @since 1.0.13 */ public boolean getDataBoundsIncludesVisibleSeriesOnly() { return this.dataBoundsIncludesVisibleSeriesOnly; } /** * Sets the flag that controls whether or not the data bounds reported * by this renderer will exclude non-visible series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param visibleOnly include only visible series. * * @since 1.0.13 */ public void setDataBoundsIncludesVisibleSeriesOnly(boolean visibleOnly) { this.dataBoundsIncludesVisibleSeriesOnly = visibleOnly; notifyListeners(new RendererChangeEvent(this, true)); } /** The adjacent offset. */ private static final double ADJ = Math.cos(Math.PI / 6.0); /** The opposite offset. */ private static final double OPP = Math.sin(Math.PI / 6.0); /** * Calculates the item label anchor point. * * @param anchor the anchor. * @param x the x coordinate. * @param y the y coordinate. * @param orientation the plot orientation. * * @return The anchor point (never null). */ protected Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, double x, double y, PlotOrientation orientation) { Point2D result = null; if (anchor == ItemLabelAnchor.CENTER) { result = new Point2D.Double(x, y); } else if (anchor == ItemLabelAnchor.INSIDE1) { result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE2) { result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE3) { result = new Point2D.Double(x + this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.INSIDE4) { result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE5) { result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE6) { result = new Point2D.Double(x, y + this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE7) { result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, y + ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE8) { result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, y + OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE9) { result = new Point2D.Double(x - this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.INSIDE10) { result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, y - OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE11) { result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, y - ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.INSIDE12) { result = new Point2D.Double(x, y - this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE1) { result = new Point2D.Double( x + 2.0 * OPP * this.itemLabelAnchorOffset, y - 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE2) { result = new Point2D.Double( x + 2.0 * ADJ * this.itemLabelAnchorOffset, y - 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE3) { result = new Point2D.Double(x + 2.0 * this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.OUTSIDE4) { result = new Point2D.Double( x + 2.0 * ADJ * this.itemLabelAnchorOffset, y + 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE5) { result = new Point2D.Double( x + 2.0 * OPP * this.itemLabelAnchorOffset, y + 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE6) { result = new Point2D.Double(x, y + 2.0 * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE7) { result = new Point2D.Double( x - 2.0 * OPP * this.itemLabelAnchorOffset, y + 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE8) { result = new Point2D.Double( x - 2.0 * ADJ * this.itemLabelAnchorOffset, y + 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE9) { result = new Point2D.Double(x - 2.0 * this.itemLabelAnchorOffset, y); } else if (anchor == ItemLabelAnchor.OUTSIDE10) { result = new Point2D.Double( x - 2.0 * ADJ * this.itemLabelAnchorOffset, y - 2.0 * OPP * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE11) { result = new Point2D.Double( x - 2.0 * OPP * this.itemLabelAnchorOffset, y - 2.0 * ADJ * this.itemLabelAnchorOffset); } else if (anchor == ItemLabelAnchor.OUTSIDE12) { result = new Point2D.Double(x, y - 2.0 * this.itemLabelAnchorOffset); } return result; } /** * Registers an object to receive notification of changes to the renderer. * * @param listener the listener (null not permitted). * * @see #removeChangeListener(RendererChangeListener) */ public void addChangeListener(RendererChangeListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.listenerList.add(RendererChangeListener.class, listener); } /** * Deregisters an object so that it no longer receives * notification of changes to the renderer. * * @param listener the object (null not permitted). * * @see #addChangeListener(RendererChangeListener) */ public void removeChangeListener(RendererChangeListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.listenerList.remove(RendererChangeListener.class, listener); } /** * Returns true if the specified object is registered with * the dataset as a listener. Most applications won't need to call this * method, it exists mainly for use by unit testing code. * * @param listener the listener. * * @return A boolean. */ public boolean hasListener(EventListener listener) { List list = Arrays.asList(this.listenerList.getListenerList()); return list.contains(listener); } /** * Sends a {@link RendererChangeEvent} to all registered listeners. * * @since 1.0.5 */ protected void fireChangeEvent() { // the commented out code would be better, but only if // RendererChangeEvent is immutable, which it isn't. See if there is // a way to fix this... //if (this.event == null) { // this.event = new RendererChangeEvent(this); //} //notifyListeners(this.event); notifyListeners(new RendererChangeEvent(this)); } /** * Notifies all registered listeners that the renderer has been modified. * * @param event information about the change event. */ public void notifyListeners(RendererChangeEvent event) { Object[] ls = this.listenerList.getListenerList(); for (int i = ls.length - 2; i >= 0; i -= 2) { if (ls[i] == RendererChangeListener.class) { ((RendererChangeListener) ls[i + 1]).rendererChanged(event); } } } /** * Tests this renderer for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof AbstractRenderer)) { return false; } AbstractRenderer that = (AbstractRenderer) obj; if (this.dataBoundsIncludesVisibleSeriesOnly != that.dataBoundsIncludesVisibleSeriesOnly) { return false; } if (this.defaultEntityRadius != that.defaultEntityRadius) { return false; } if (!ObjectUtilities.equal(this.seriesVisible, that.seriesVisible)) { return false; } if (!this.seriesVisibleList.equals(that.seriesVisibleList)) { return false; } if (this.baseSeriesVisible != that.baseSeriesVisible) { return false; } if (!ObjectUtilities.equal(this.seriesVisibleInLegend, that.seriesVisibleInLegend)) { return false; } if (!this.seriesVisibleInLegendList.equals( that.seriesVisibleInLegendList)) { return false; } if (this.baseSeriesVisibleInLegend != that.baseSeriesVisibleInLegend) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (!ObjectUtilities.equal(this.paintList, that.paintList)) { return false; } if (!PaintUtilities.equal(this.basePaint, that.basePaint)) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } if (!ObjectUtilities.equal(this.fillPaintList, that.fillPaintList)) { return false; } if (!PaintUtilities.equal(this.baseFillPaint, that.baseFillPaint)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!ObjectUtilities.equal(this.outlinePaintList, that.outlinePaintList)) { return false; } if (!PaintUtilities.equal(this.baseOutlinePaint, that.baseOutlinePaint)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!ObjectUtilities.equal(this.strokeList, that.strokeList)) { return false; } if (!ObjectUtilities.equal(this.baseStroke, that.baseStroke)) { return false; } if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { return false; } if (!ObjectUtilities.equal(this.outlineStrokeList, that.outlineStrokeList)) { return false; } if (!ObjectUtilities.equal( this.baseOutlineStroke, that.baseOutlineStroke) ) { return false; } if (!ShapeUtilities.equal(this.shape, that.shape)) { return false; } if (!ObjectUtilities.equal(this.shapeList, that.shapeList)) { return false; } if (!ShapeUtilities.equal(this.baseShape, that.baseShape)) { return false; } if (!ObjectUtilities.equal(this.itemLabelsVisible, that.itemLabelsVisible)) { return false; } if (!ObjectUtilities.equal(this.itemLabelsVisibleList, that.itemLabelsVisibleList)) { return false; } if (!ObjectUtilities.equal(this.baseItemLabelsVisible, that.baseItemLabelsVisible)) { return false; } if (!ObjectUtilities.equal(this.itemLabelFont, that.itemLabelFont)) { return false; } if (!ObjectUtilities.equal(this.itemLabelFontList, that.itemLabelFontList)) { return false; } if (!ObjectUtilities.equal(this.baseItemLabelFont, that.baseItemLabelFont)) { return false; } if (!PaintUtilities.equal(this.itemLabelPaint, that.itemLabelPaint)) { return false; } if (!ObjectUtilities.equal(this.itemLabelPaintList, that.itemLabelPaintList)) { return false; } if (!PaintUtilities.equal(this.baseItemLabelPaint, that.baseItemLabelPaint)) { return false; } if (!ObjectUtilities.equal(this.positiveItemLabelPosition, that.positiveItemLabelPosition)) { return false; } if (!ObjectUtilities.equal(this.positiveItemLabelPositionList, that.positiveItemLabelPositionList)) { return false; } if (!ObjectUtilities.equal(this.basePositiveItemLabelPosition, that.basePositiveItemLabelPosition)) { return false; } if (!ObjectUtilities.equal(this.negativeItemLabelPosition, that.negativeItemLabelPosition)) { return false; } if (!ObjectUtilities.equal(this.negativeItemLabelPositionList, that.negativeItemLabelPositionList)) { return false; } if (!ObjectUtilities.equal(this.baseNegativeItemLabelPosition, that.baseNegativeItemLabelPosition)) { return false; } if (this.itemLabelAnchorOffset != that.itemLabelAnchorOffset) { return false; } if (!ObjectUtilities.equal(this.createEntities, that.createEntities)) { return false; } if (!ObjectUtilities.equal(this.createEntitiesList, that.createEntitiesList)) { return false; } if (this.baseCreateEntities != that.baseCreateEntities) { return false; } if (!ObjectUtilities.equal(this.legendShape, that.legendShape)) { return false; } if (!ShapeUtilities.equal(this.baseLegendShape, that.baseLegendShape)) { return false; } if (!ObjectUtilities.equal(this.legendTextFont, that.legendTextFont)) { return false; } if (!ObjectUtilities.equal(this.baseLegendTextFont, that.baseLegendTextFont)) { return false; } if (!ObjectUtilities.equal(this.legendTextPaint, that.legendTextPaint)) { return false; } if (!PaintUtilities.equal(this.baseLegendTextPaint, that.baseLegendTextPaint)) { return false; } return true; } /** * Returns a hashcode for the renderer. * * @return The hashcode. */ public int hashCode() { int result = 193; result = HashUtilities.hashCode(result, this.seriesVisibleList); result = HashUtilities.hashCode(result, this.baseSeriesVisible); result = HashUtilities.hashCode(result, this.seriesVisibleInLegendList); result = HashUtilities.hashCode(result, this.baseSeriesVisibleInLegend); result = HashUtilities.hashCode(result, this.paintList); result = HashUtilities.hashCode(result, this.basePaint); result = HashUtilities.hashCode(result, this.fillPaintList); result = HashUtilities.hashCode(result, this.baseFillPaint); result = HashUtilities.hashCode(result, this.outlinePaintList); result = HashUtilities.hashCode(result, this.baseOutlinePaint); result = HashUtilities.hashCode(result, this.strokeList); result = HashUtilities.hashCode(result, this.baseStroke); result = HashUtilities.hashCode(result, this.outlineStrokeList); result = HashUtilities.hashCode(result, this.baseOutlineStroke); // shapeList // baseShape result = HashUtilities.hashCode(result, this.itemLabelsVisibleList); result = HashUtilities.hashCode(result, this.baseItemLabelsVisible); // itemLabelFontList // baseItemLabelFont // itemLabelPaintList // baseItemLabelPaint // positiveItemLabelPositionList // basePositiveItemLabelPosition // negativeItemLabelPositionList // baseNegativeItemLabelPosition // itemLabelAnchorOffset // createEntityList // baseCreateEntities return result; } /** * Returns an independent copy of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if some component of the renderer * does not support cloning. */ protected Object clone() throws CloneNotSupportedException { AbstractRenderer clone = (AbstractRenderer) super.clone(); if (this.seriesVisibleList != null) { clone.seriesVisibleList = (BooleanList) this.seriesVisibleList.clone(); } if (this.seriesVisibleInLegendList != null) { clone.seriesVisibleInLegendList = (BooleanList) this.seriesVisibleInLegendList.clone(); } // 'paint' : immutable, no need to clone reference if (this.paintList != null) { clone.paintList = (PaintList) this.paintList.clone(); } // 'basePaint' : immutable, no need to clone reference if (this.fillPaintList != null) { clone.fillPaintList = (PaintList) this.fillPaintList.clone(); } // 'outlinePaint' : immutable, no need to clone reference if (this.outlinePaintList != null) { clone.outlinePaintList = (PaintList) this.outlinePaintList.clone(); } // 'baseOutlinePaint' : immutable, no need to clone reference // 'stroke' : immutable, no need to clone reference if (this.strokeList != null) { clone.strokeList = (StrokeList) this.strokeList.clone(); } // 'baseStroke' : immutable, no need to clone reference // 'outlineStroke' : immutable, no need to clone reference if (this.outlineStrokeList != null) { clone.outlineStrokeList = (StrokeList) this.outlineStrokeList.clone(); } // 'baseOutlineStroke' : immutable, no need to clone reference if (this.shape != null) { clone.shape = ShapeUtilities.clone(this.shape); } if (this.shapeList != null) { clone.shapeList = (ShapeList) this.shapeList.clone(); } if (this.baseShape != null) { clone.baseShape = ShapeUtilities.clone(this.baseShape); } // 'itemLabelsVisible' : immutable, no need to clone reference if (this.itemLabelsVisibleList != null) { clone.itemLabelsVisibleList = (BooleanList) this.itemLabelsVisibleList.clone(); } // 'basePaint' : immutable, no need to clone reference // 'itemLabelFont' : immutable, no need to clone reference if (this.itemLabelFontList != null) { clone.itemLabelFontList = (ObjectList) this.itemLabelFontList.clone(); } // 'baseItemLabelFont' : immutable, no need to clone reference // 'itemLabelPaint' : immutable, no need to clone reference if (this.itemLabelPaintList != null) { clone.itemLabelPaintList = (PaintList) this.itemLabelPaintList.clone(); } // 'baseItemLabelPaint' : immutable, no need to clone reference // 'postiveItemLabelAnchor' : immutable, no need to clone reference if (this.positiveItemLabelPositionList != null) { clone.positiveItemLabelPositionList = (ObjectList) this.positiveItemLabelPositionList.clone(); } // 'baseItemLabelAnchor' : immutable, no need to clone reference // 'negativeItemLabelAnchor' : immutable, no need to clone reference if (this.negativeItemLabelPositionList != null) { clone.negativeItemLabelPositionList = (ObjectList) this.negativeItemLabelPositionList.clone(); } // 'baseNegativeItemLabelAnchor' : immutable, no need to clone reference if (this.createEntitiesList != null) { clone.createEntitiesList = (BooleanList) this.createEntitiesList.clone(); } if (this.legendShape != null) { clone.legendShape = (ShapeList) this.legendShape.clone(); } if (this.legendTextFont != null) { clone.legendTextFont = (ObjectList) this.legendTextFont.clone(); } if (this.legendTextPaint != null) { clone.legendTextPaint = (PaintList) this.legendTextPaint.clone(); } clone.listenerList = new EventListenerList(); clone.event = null; return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writePaint(this.basePaint, stream); SerialUtilities.writePaint(this.fillPaint, stream); SerialUtilities.writePaint(this.baseFillPaint, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writePaint(this.baseOutlinePaint, stream); SerialUtilities.writeStroke(this.stroke, stream); SerialUtilities.writeStroke(this.baseStroke, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writeStroke(this.baseOutlineStroke, stream); SerialUtilities.writeShape(this.shape, stream); SerialUtilities.writeShape(this.baseShape, stream); SerialUtilities.writePaint(this.itemLabelPaint, stream); SerialUtilities.writePaint(this.baseItemLabelPaint, stream); SerialUtilities.writeShape(this.baseLegendShape, stream); SerialUtilities.writePaint(this.baseLegendTextPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.basePaint = SerialUtilities.readPaint(stream); this.fillPaint = SerialUtilities.readPaint(stream); this.baseFillPaint = SerialUtilities.readPaint(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.baseOutlinePaint = SerialUtilities.readPaint(stream); this.stroke = SerialUtilities.readStroke(stream); this.baseStroke = SerialUtilities.readStroke(stream); this.outlineStroke = SerialUtilities.readStroke(stream); this.baseOutlineStroke = SerialUtilities.readStroke(stream); this.shape = SerialUtilities.readShape(stream); this.baseShape = SerialUtilities.readShape(stream); this.itemLabelPaint = SerialUtilities.readPaint(stream); this.baseItemLabelPaint = SerialUtilities.readPaint(stream); this.baseLegendShape = SerialUtilities.readShape(stream); this.baseLegendTextPaint = SerialUtilities.readPaint(stream); // listeners are not restored automatically, but storage must be // provided... this.listenerList = new EventListenerList(); } // === DEPRECATED CODE === /** * A flag that controls the visibility of ALL series. * * @deprecated This field is redundant, you can rely on seriesVisibleList * and baseSeriesVisible. Deprecated from version 1.0.6 onwards. */ private Boolean seriesVisible; /** * A flag that controls the visibility of ALL series in the legend. * * @deprecated This field is redundant, you can rely on * seriesVisibleInLegendList and baseSeriesVisibleInLegend. * Deprecated from version 1.0.6 onwards. */ private Boolean seriesVisibleInLegend; /** * The paint for ALL series (optional). * * @deprecated This field is redundant, you can rely on paintList and * basePaint. Deprecated from version 1.0.6 onwards. */ private transient Paint paint; /** * The fill paint for ALL series (optional). * * @deprecated This field is redundant, you can rely on fillPaintList and * baseFillPaint. Deprecated from version 1.0.6 onwards. */ private transient Paint fillPaint; /** * The outline paint for ALL series (optional). * * @deprecated This field is redundant, you can rely on outlinePaintList * and baseOutlinePaint. Deprecated from version 1.0.6 onwards. */ private transient Paint outlinePaint; /** * The stroke for ALL series (optional). * * @deprecated This field is redundant, you can rely on strokeList and * baseStroke. Deprecated from version 1.0.6 onwards. */ private transient Stroke stroke; /** * The outline stroke for ALL series (optional). * * @deprecated This field is redundant, you can rely on strokeList and * baseStroke. Deprecated from version 1.0.6 onwards. */ private transient Stroke outlineStroke; /** * The shape for ALL series (optional). * * @deprecated This field is redundant, you can rely on shapeList and * baseShape. Deprecated from version 1.0.6 onwards. */ private transient Shape shape; /** * Visibility of the item labels for ALL series (optional). * * @deprecated This field is redundant, you can rely on * itemLabelsVisibleList and baseItemLabelsVisible. Deprecated from * version 1.0.6 onwards. */ private Boolean itemLabelsVisible; /** * The item label font for ALL series (optional). * * @deprecated This field is redundant, you can rely on itemLabelFontList * and baseItemLabelFont. Deprecated from version 1.0.6 onwards. */ private Font itemLabelFont; /** * The item label paint for ALL series. * * @deprecated This field is redundant, you can rely on itemLabelPaintList * and baseItemLabelPaint. Deprecated from version 1.0.6 onwards. */ private transient Paint itemLabelPaint; /** * The positive item label position for ALL series (optional). * * @deprecated This field is redundant, you can rely on the * positiveItemLabelPositionList and basePositiveItemLabelPosition * fields. Deprecated from version 1.0.6 onwards. */ private ItemLabelPosition positiveItemLabelPosition; /** * The negative item label position for ALL series (optional). * * @deprecated This field is redundant, you can rely on the * negativeItemLabelPositionList and baseNegativeItemLabelPosition * fields. Deprecated from version 1.0.6 onwards. */ private ItemLabelPosition negativeItemLabelPosition; /** * A flag that controls whether or not entities are generated for * ALL series (optional). * * @deprecated This field is redundant, you can rely on the * createEntitiesList and baseCreateEntities fields. Deprecated from * version 1.0.6 onwards. */ private Boolean createEntities; /** * Returns the flag that controls the visibility of ALL series. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @return The flag (possibly null). * * @see #setSeriesVisible(Boolean) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesVisible(int)} and * {@link #getBaseSeriesVisible()}. */ public Boolean getSeriesVisible() { return this.seriesVisible; } /** * Sets the flag that controls the visibility of ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @param visible the flag (null permitted). * * @see #getSeriesVisible() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} * and {@link #setBaseSeriesVisible(boolean)}. */ public void setSeriesVisible(Boolean visible) { setSeriesVisible(visible, true); } /** * Sets the flag that controls the visibility of ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. This flag * overrides the per series and default settings - you must set it to * null if you want the other settings to apply. * * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisible() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} * and {@link #setBaseSeriesVisible(boolean)}. */ public void setSeriesVisible(Boolean visible, boolean notify) { this.seriesVisible = visible; if (notify) { // we create an event with a special flag set...the purpose of // this is to communicate to the plot (the default receiver of // the event) that series visibility has changed so the axis // ranges might need updating... RendererChangeEvent e = new RendererChangeEvent(this, true); notifyListeners(e); } } /** * Returns the flag that controls the visibility of ALL series in the * legend. This flag overrides the per series and default settings - you * must set it to null if you want the other settings to * apply. * * @return The flag (possibly null). * * @see #setSeriesVisibleInLegend(Boolean) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesVisibleInLegend(int)} * and {@link #getBaseSeriesVisibleInLegend()}. */ public Boolean getSeriesVisibleInLegend() { return this.seriesVisibleInLegend; } /** * Sets the flag that controls the visibility of ALL series in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * This flag overrides the per series and default settings - you must set * it to null if you want the other settings to apply. * * @param visible the flag (null permitted). * * @see #getSeriesVisibleInLegend() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, * Boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean)}. */ public void setSeriesVisibleInLegend(Boolean visible) { setSeriesVisibleInLegend(visible, true); } /** * Sets the flag that controls the visibility of ALL series in the legend * and sends a {@link RendererChangeEvent} to all registered listeners. * This flag overrides the per series and default settings - you must set * it to null if you want the other settings to apply. * * @param visible the flag (null permitted). * @param notify notify listeners? * * @see #getSeriesVisibleInLegend() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, * Boolean, boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean, * boolean)}. */ public void setSeriesVisibleInLegend(Boolean visible, boolean notify) { this.seriesVisibleInLegend = visible; if (notify) { fireChangeEvent(); } } /** * Sets the paint to be used for ALL series, and sends a * {@link RendererChangeEvent} to all registered listeners. If this is * null, the renderer will use the paint for the series. * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesPaint(int, Paint)} and * {@link #setBasePaint(Paint)}. */ public void setPaint(Paint paint) { setPaint(paint, true); } /** * Sets the paint to be used for all series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesPaint(int, Paint, * boolean)} and {@link #setBasePaint(Paint, boolean)}. */ public void setPaint(Paint paint, boolean notify) { this.paint = paint; if (notify) { fireChangeEvent(); } } /** * Sets the fill paint for ALL series (optional). * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesFillPaint(int, Paint)} * and {@link #setBaseFillPaint(Paint)}. */ public void setFillPaint(Paint paint) { setFillPaint(paint, true); } /** * Sets the fill paint for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesFillPaint(int, Paint, * boolean)} and {@link #setBaseFillPaint(Paint, boolean)}. */ public void setFillPaint(Paint paint, boolean notify) { this.fillPaint = paint; if (notify) { fireChangeEvent(); } } /** * Sets the outline paint for ALL series (optional) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, * Paint)} and {@link #setBaseOutlinePaint(Paint)}. */ public void setOutlinePaint(Paint paint) { setOutlinePaint(paint, true); } /** * Sets the outline paint for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, * Paint, boolean)} and {@link #setBaseOutlinePaint(Paint, boolean)}. */ public void setOutlinePaint(Paint paint, boolean notify) { this.outlinePaint = paint; if (notify) { fireChangeEvent(); } } /** * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} * to all registered listeners. * * @param stroke the stroke (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke)} * and {@link #setBaseStroke(Stroke)}. */ public void setStroke(Stroke stroke) { setStroke(stroke, true); } /** * Sets the stroke for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke, * boolean)} and {@link #setBaseStroke(Stroke, boolean)}. */ public void setStroke(Stroke stroke, boolean notify) { this.stroke = stroke; if (notify) { fireChangeEvent(); } } /** * Sets the outline stroke for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, * Stroke)} and {@link #setBaseOutlineStroke(Stroke)}. */ public void setOutlineStroke(Stroke stroke) { setOutlineStroke(stroke, true); } /** * Sets the outline stroke for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param stroke the stroke (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, * Stroke, boolean)} and {@link #setBaseOutlineStroke(Stroke, boolean)}. */ public void setOutlineStroke(Stroke stroke, boolean notify) { this.outlineStroke = stroke; if (notify) { fireChangeEvent(); } } /** * Sets the shape for ALL series (optional) and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesShape(int, Shape)} * and {@link #setBaseShape(Shape)}. */ public void setShape(Shape shape) { setShape(shape, true); } /** * Sets the shape for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param shape the shape (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesShape(int, Shape, * boolean)} and {@link #setBaseShape(Shape, boolean)}. */ public void setShape(Shape shape, boolean notify) { this.shape = shape; if (notify) { fireChangeEvent(); } } /** * Sets the visibility of the item labels for ALL series. * * @param visible the flag. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. */ public void setItemLabelsVisible(boolean visible) { setItemLabelsVisible(BooleanUtilities.valueOf(visible)); // The following alternative is only supported in JDK 1.4 - we support // JDK 1.3.1 onwards // setItemLabelsVisible(Boolean.valueOf(visible)); } /** * Sets the visibility of the item labels for ALL series (optional). * * @param visible the flag (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. */ public void setItemLabelsVisible(Boolean visible) { setItemLabelsVisible(visible, true); } /** * Sets the visibility of item labels for ALL series and, if requested, * sends a {@link RendererChangeEvent} to all registered listeners. * * @param visible a flag that controls whether or not the item labels are * visible (null permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, * Boolean, boolean)} and {@link #setBaseItemLabelsVisible(Boolean, * boolean)}. */ public void setItemLabelsVisible(Boolean visible, boolean notify) { this.itemLabelsVisible = visible; if (notify) { fireChangeEvent(); } } /** * Returns the font used for all item labels. This may be * null, in which case the per series font settings will apply. * * @return The font (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesItemLabelFont(int)} and * {@link #getBaseItemLabelFont()}. */ public Font getItemLabelFont() { return this.itemLabelFont; } /** * Sets the item label font for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. You can set * this to null if you prefer to set the font on a per series * basis. * * @param font the font (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, * Font)} and {@link #setBaseItemLabelFont(Font)}. */ public void setItemLabelFont(Font font) { setItemLabelFont(font, true); } /** * Sets the item label font for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param font the font (null permitted). * @param notify a flag that controls whether or not listeners are * notified. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, * Font, boolean)} and {@link #setBaseItemLabelFont(Font, boolean)}. */ public void setItemLabelFont(Font font, boolean notify) { this.itemLabelFont = font; if (notify) { fireChangeEvent(); } } /** * Returns the paint used for all item labels. This may be * null, in which case the per series paint settings will * apply. * * @return The paint (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesItemLabelPaint(int)} * and {@link #getBaseItemLabelPaint()}. */ public Paint getItemLabelPaint() { return this.itemLabelPaint; } /** * Sets the item label paint for ALL series and sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, * Paint)} and {@link #setBaseItemLabelPaint(Paint)}. */ public void setItemLabelPaint(Paint paint) { setItemLabelPaint(paint, true); } /** * Sets the item label paint for ALL series and, if requested, sends a * {@link RendererChangeEvent} to all registered listeners. * * @param paint the paint. * @param notify a flag that controls whether or not listeners are * notified. * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, * Paint, boolean)} and {@link #setBaseItemLabelPaint(Paint, boolean)}. */ public void setItemLabelPaint(Paint paint, boolean notify) { this.itemLabelPaint = paint; if (notify) { fireChangeEvent(); } } /** * Returns the item label position for positive values in ALL series. * * @return The item label position (possibly null). * * @see #setPositiveItemLabelPosition(ItemLabelPosition) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #getSeriesPositiveItemLabelPosition(int)} * and {@link #getBasePositiveItemLabelPosition()}. */ public ItemLabelPosition getPositiveItemLabelPosition() { return this.positiveItemLabelPosition; } /** * Sets the item label position for positive values in ALL series, and * sends a {@link RendererChangeEvent} to all registered listeners. You * need to set this to null to expose the settings for * individual series. * * @param position the position (null permitted). * * @see #getPositiveItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition)} * and {@link #setBasePositiveItemLabelPosition(ItemLabelPosition)}. */ public void setPositiveItemLabelPosition(ItemLabelPosition position) { setPositiveItemLabelPosition(position, true); } /** * Sets the positive item label position for ALL series and (if requested) * sends a {@link RendererChangeEvent} to all registered listeners. * * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getPositiveItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, * boolean)} and {@link #setBasePositiveItemLabelPosition( * ItemLabelPosition, boolean)}. */ public void setPositiveItemLabelPosition(ItemLabelPosition position, boolean notify) { this.positiveItemLabelPosition = position; if (notify) { fireChangeEvent(); } } /** * Returns the item label position for negative values in ALL series. * * @return The item label position (possibly null). * * @see #setNegativeItemLabelPosition(ItemLabelPosition) * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #getSeriesNegativeItemLabelPosition(int)} * and {@link #getBaseNegativeItemLabelPosition()}. */ public ItemLabelPosition getNegativeItemLabelPosition() { return this.negativeItemLabelPosition; } /** * Sets the item label position for negative values in ALL series, and * sends a {@link RendererChangeEvent} to all registered listeners. You * need to set this to null to expose the settings for * individual series. * * @param position the position (null permitted). * * @see #getNegativeItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition)} * and {@link #setBaseNegativeItemLabelPosition(ItemLabelPosition)}. */ public void setNegativeItemLabelPosition(ItemLabelPosition position) { setNegativeItemLabelPosition(position, true); } /** * Sets the item label position for negative values in ALL series and (if * requested) sends a {@link RendererChangeEvent} to all registered * listeners. * * @param position the position (null permitted). * @param notify notify registered listeners? * * @see #getNegativeItemLabelPosition() * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, * boolean)} and {@link #setBaseNegativeItemLabelPosition( * ItemLabelPosition, boolean)}. */ public void setNegativeItemLabelPosition(ItemLabelPosition position, boolean notify) { this.negativeItemLabelPosition = position; if (notify) { fireChangeEvent(); } } /** * Returns the flag that controls whether or not chart entities are created * for the items in ALL series. This flag overrides the per series and * default settings - you must set it to null if you want the * other settings to apply. * * @return The flag (possibly null). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #getSeriesCreateEntities(int)} * and {@link #getBaseCreateEntities()}. */ public Boolean getCreateEntities() { return this.createEntities; } /** * Sets the flag that controls whether or not chart entities are created * for the items in ALL series, and sends a {@link RendererChangeEvent} to * all registered listeners. This flag overrides the per series and * default settings - you must set it to null if you want the * other settings to apply. * * @param create the flag (null permitted). * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesCreateEntities(int, * Boolean)} and {@link #setBaseCreateEntities(boolean)}. */ public void setCreateEntities(Boolean create) { setCreateEntities(create, true); } /** * Sets the flag that controls whether or not chart entities are created * for the items in ALL series, and sends a {@link RendererChangeEvent} to * all registered listeners. This flag overrides the per series and * default settings - you must set it to null if you want the * other settings to apply. * * @param create the flag (null permitted). * @param notify notify listeners? * * @deprecated This method should no longer be used (as of version 1.0.6). * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, * Font, boolean)} and {@link #setBaseItemLabelFont(Font, boolean)}. */ public void setCreateEntities(Boolean create, boolean notify) { this.createEntities = create; if (notify) { fireChangeEvent(); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/AreaRendererEndType.java0000644000175000017500000001016411173030414030734 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * AreaRendererEndType.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 29-April-2004 : Version 1 (DG); * */ package org.jfree.chart.renderer; import java.io.ObjectStreamException; import java.io.Serializable; /** * An enumeration of the 'end types' for an area renderer. */ public final class AreaRendererEndType implements Serializable { /** For serialization. */ private static final long serialVersionUID = -1774146392916359839L; /** * The area tapers from the first or last value down to zero. */ public static final AreaRendererEndType TAPER = new AreaRendererEndType( "AreaRendererEndType.TAPER"); /** * The area is truncated at the first or last value. */ public static final AreaRendererEndType TRUNCATE = new AreaRendererEndType( "AreaRendererEndType.TRUNCATE"); /** * The area is levelled at the first or last value. */ public static final AreaRendererEndType LEVEL = new AreaRendererEndType( "AreaRendererEndType.LEVEL"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private AreaRendererEndType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof AreaRendererEndType)) { return false; } AreaRendererEndType t = (AreaRendererEndType) obj; if (!this.name.equals(t.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { Object result = null; if (this.equals(AreaRendererEndType.LEVEL)) { result = AreaRendererEndType.LEVEL; } else if (this.equals(AreaRendererEndType.TAPER)) { result = AreaRendererEndType.TAPER; } else if (this.equals(AreaRendererEndType.TRUNCATE)) { result = AreaRendererEndType.TRUNCATE; } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java0000644000175000017500000002731011173030414031775 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * DefaultPolarItemRenderer.java * ----------------------------- * (C) Copyright 2004-2008, by Solution Engineering, Inc. and * Contributors. * * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 04-Oct-2004 : Renamed BooleanUtils --> BooleanUtilities (DG); * 20-Apr-2005 : Update for change to LegendItem class (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 04-Aug-2006 : Implemented equals() and clone() (DG); * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 14-Mar-2007 : Fixed clone() method (DG); * 04-May-2007 : Fixed lookup for series paint and stroke (DG); * 18-May-2007 : Set dataset for LegendItem (DG); * */ package org.jfree.chart.renderer; import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Point; import java.awt.Polygon; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.util.Iterator; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberTick; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.DrawingSupplier; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.PolarPlot; import org.jfree.data.xy.XYDataset; import org.jfree.text.TextUtilities; import org.jfree.ui.TextAnchor; import org.jfree.util.BooleanList; import org.jfree.util.BooleanUtilities; /** * A renderer that can be used with the {@link PolarPlot} class. */ public class DefaultPolarItemRenderer extends AbstractRenderer implements PolarItemRenderer { /** The plot that the renderer is assigned to. */ private PolarPlot plot; /** Flags that control whether the renderer fills each series or not. */ private BooleanList seriesFilled; /** * Creates a new instance of DefaultPolarItemRenderer */ public DefaultPolarItemRenderer() { this.seriesFilled = new BooleanList(); } /** * Set the plot associated with this renderer. * * @param plot the plot. * * @see #getPlot() */ public void setPlot(PolarPlot plot) { this.plot = plot; } /** * Return the plot associated with this renderer. * * @return The plot. * * @see #setPlot(PolarPlot) */ public PolarPlot getPlot() { return this.plot; } /** * Returns the drawing supplier from the plot. * * @return The drawing supplier. */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; PolarPlot p = getPlot(); if (p != null) { result = p.getDrawingSupplier(); } return result; } /** * Returns true if the renderer should fill the specified * series, and false otherwise. * * @param series the series index (zero-based). * * @return A boolean. */ public boolean isSeriesFilled(int series) { boolean result = false; Boolean b = this.seriesFilled.getBoolean(series); if (b != null) { result = b.booleanValue(); } return result; } /** * Sets a flag that controls whether or not a series is filled. * * @param series the series index. * @param filled the flag. */ public void setSeriesFilled(int series, boolean filled) { this.seriesFilled.setBoolean(series, BooleanUtilities.valueOf(filled)); } /** * Plots the data for a given series. * * @param g2 the drawing surface. * @param dataArea the data area. * @param info collects plot rendering info. * @param plot the plot. * @param dataset the dataset. * @param seriesIndex the series index. */ public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { Polygon poly = new Polygon(); int numPoints = dataset.getItemCount(seriesIndex); for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); double radius = dataset.getYValue(seriesIndex, i); Point p = plot.translateValueThetaRadiusToJava2D(theta, radius, dataArea); poly.addPoint(p.x, p.y); } g2.setPaint(lookupSeriesPaint(seriesIndex)); g2.setStroke(lookupSeriesStroke(seriesIndex)); if (isSeriesFilled(seriesIndex)) { Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f)); g2.fill(poly); g2.setComposite(savedComposite); } else { g2.draw(poly); } } /** * Draw the angular gridlines - the spokes. * * @param g2 the drawing surface. * @param plot the plot. * @param ticks the ticks. * @param dataArea the data area. */ public void drawAngularGridLines(Graphics2D g2, PolarPlot plot, List ticks, Rectangle2D dataArea) { g2.setFont(plot.getAngleLabelFont()); g2.setStroke(plot.getAngleGridlineStroke()); g2.setPaint(plot.getAngleGridlinePaint()); double axisMin = plot.getAxis().getLowerBound(); double maxRadius = plot.getMaxRadius(); Point center = plot.translateValueThetaRadiusToJava2D(axisMin, axisMin, dataArea); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { NumberTick tick = (NumberTick) iterator.next(); Point p = plot.translateValueThetaRadiusToJava2D( tick.getNumber().doubleValue(), maxRadius, dataArea); g2.setPaint(plot.getAngleGridlinePaint()); g2.drawLine(center.x, center.y, p.x, p.y); if (plot.isAngleLabelsVisible()) { int x = p.x; int y = p.y; g2.setPaint(plot.getAngleLabelPaint()); TextUtilities.drawAlignedString(tick.getText(), g2, x, y, TextAnchor.CENTER); } } } /** * Draw the radial gridlines - the rings. * * @param g2 the drawing surface. * @param plot the plot. * @param radialAxis the radial axis. * @param ticks the ticks. * @param dataArea the data area. */ public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea) { g2.setFont(radialAxis.getTickLabelFont()); g2.setPaint(plot.getRadiusGridlinePaint()); g2.setStroke(plot.getRadiusGridlineStroke()); double axisMin = radialAxis.getLowerBound(); Point center = plot.translateValueThetaRadiusToJava2D(axisMin, axisMin, dataArea); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { NumberTick tick = (NumberTick) iterator.next(); Point p = plot.translateValueThetaRadiusToJava2D(90.0, tick.getNumber().doubleValue(), dataArea); int r = p.x - center.x; int upperLeftX = center.x - r; int upperLeftY = center.y - r; int d = 2 * r; Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d); g2.setPaint(plot.getRadiusGridlinePaint()); g2.draw(ring); } } /** * Return the legend for the given series. * * @param series the series index. * * @return The legend item. */ public LegendItem getLegendItem(int series) { LegendItem result = null; PolarPlot polarPlot = getPlot(); if (polarPlot != null) { XYDataset dataset = polarPlot.getDataset(); if (dataset != null) { String label = dataset.getSeriesKey(series).toString(); String description = label; Shape shape = lookupSeriesShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); result = new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint); result.setDataset(dataset); } } return result; } /** * Tests this renderer for equality with an arbitrary object. * * @param obj the object (null not permitted). * * @return true if this renderer is equal to obj, * and false otherwise. */ public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof DefaultPolarItemRenderer)) { return false; } DefaultPolarItemRenderer that = (DefaultPolarItemRenderer) obj; if (!this.seriesFilled.equals(that.seriesFilled)) { return false; } return super.equals(obj); } /** * Returns a clone of the renderer. * * @return A clone. * * @throws CloneNotSupportedException if the renderer cannot be cloned. */ public Object clone() throws CloneNotSupportedException { DefaultPolarItemRenderer clone = (DefaultPolarItemRenderer) super.clone(); clone.seriesFilled = (BooleanList) this.seriesFilled.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/GrayPaintScale.java0000644000175000017500000001552611173030414027761 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * GrayPaintScale.java * ------------------- * (C) Copyright 2006-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 31-Jan-2007 : Renamed min and max to lowerBound and upperBound (DG); * 26-Sep-2007 : Fixed bug 1767315, problem in getPaint() method (DG); * 29-Jan-2009 : Added alpha transparency field and hashCode() method (DG); * */ package org.jfree.chart.renderer; import java.awt.Color; import java.awt.Paint; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.util.PublicCloneable; /** * A paint scale that returns shades of gray. * * @since 1.0.4 */ public class GrayPaintScale implements PaintScale, PublicCloneable, Serializable { /** The lower bound. */ private double lowerBound; /** The upper bound. */ private double upperBound; /** * The alpha transparency (0-255). * * @since 1.0.13 */ private int alpha; /** * Creates a new GrayPaintScale instance with default values. */ public GrayPaintScale() { this(0.0, 1.0); } /** * Creates a new paint scale for values in the specified range. * * @param lowerBound the lower bound. * @param upperBound the upper bound. * * @throws IllegalArgumentException if lowerBound is not * less than upperBound. */ public GrayPaintScale(double lowerBound, double upperBound) { this(lowerBound, upperBound, 255); } /** * Creates a new paint scale for values in the specified range. * * @param lowerBound the lower bound. * @param upperBound the upper bound. * @param alpha the alpha transparency (0-255). * * @throws IllegalArgumentException if lowerBound is not * less than upperBound, or alpha is not in * the range 0 to 255. * * @since 1.0.13 */ public GrayPaintScale(double lowerBound, double upperBound, int alpha) { if (lowerBound >= upperBound) { throw new IllegalArgumentException( "Requires lowerBound < upperBound."); } if (alpha < 0 || alpha > 255) { throw new IllegalArgumentException( "Requires alpha in the range 0 to 255."); } this.lowerBound = lowerBound; this.upperBound = upperBound; this.alpha = alpha; } /** * Returns the lower bound. * * @return The lower bound. * * @see #getUpperBound() */ public double getLowerBound() { return this.lowerBound; } /** * Returns the upper bound. * * @return The upper bound. * * @see #getLowerBound() */ public double getUpperBound() { return this.upperBound; } /** * Returns the alpha transparency that was specified in the constructor. * * @return The alpha transparency (in the range 0 to 255). * * @since 1.0.13 */ public int getAlpha() { return this.alpha; } /** * Returns a paint for the specified value. * * @param value the value (must be within the range specified by the * lower and upper bounds for the scale). * * @return A paint for the specified value. */ public Paint getPaint(double value) { double v = Math.max(value, this.lowerBound); v = Math.min(v, this.upperBound); int g = (int) ((v - this.lowerBound) / (this.upperBound - this.lowerBound) * 255.0); // FIXME: it probably makes sense to allocate an array of 256 Colors // and lazily populate this array... return new Color(g, g, g, this.alpha); } /** * Tests this GrayPaintScale instance for equality with an * arbitrary object. This method returns true if and only * if: *

    *
  • obj is not null;
  • *
  • obj is an instance of GrayPaintScale;
  • *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GrayPaintScale)) { return false; } GrayPaintScale that = (GrayPaintScale) obj; if (this.lowerBound != that.lowerBound) { return false; } if (this.upperBound != that.upperBound) { return false; } if (this.alpha != that.alpha) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 7; hash = HashUtilities.hashCode(hash, this.lowerBound); hash = HashUtilities.hashCode(hash, this.upperBound); hash = 43 * hash + this.alpha; return hash; } /** * Returns a clone of this GrayPaintScale instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning this * instance. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/LookupPaintScale.java0000644000175000017500000002706311173030414030327 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * LookupPaintScale.java * --------------------- * (C) Copyright 2006-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 31-Jan-2007 : Fixed serialization support (DG); * 09-Mar-2007 : Fixed cloning (DG); * 14-Jun-2007 : Use double primitive in PaintItem (DG); * 28-Mar-2009 : Made PaintItem inner class static (DG); * */ package org.jfree.chart.renderer; import java.awt.Color; import java.awt.Paint; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Collections; import java.util.List; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A paint scale that uses a lookup table to associate paint instances * with data value ranges. * * @since 1.0.4 */ public class LookupPaintScale implements PaintScale, PublicCloneable, Serializable { /** * Stores the paint for a value. */ static class PaintItem implements Comparable, Serializable { /** For serialization. */ static final long serialVersionUID = 698920578512361570L; /** The value. */ double value; /** The paint. */ transient Paint paint; /** * Creates a new instance. * * @param value the value. * @param paint the paint. */ public PaintItem(double value, Paint paint) { this.value = value; this.paint = paint; } /* (non-Javadoc) * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object obj) { PaintItem that = (PaintItem) obj; double d1 = this.value; double d2 = that.value; if (d1 > d2) { return 1; } if (d1 < d2) { return -1; } return 0; } /** * Tests this item for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintItem)) { return false; } PaintItem that = (PaintItem) obj; if (this.value != that.value) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); } } /** For serialization. */ static final long serialVersionUID = -5239384246251042006L; /** The lower bound. */ private double lowerBound; /** The upper bound. */ private double upperBound; /** The default paint. */ private transient Paint defaultPaint; /** The lookup table. */ private List lookupTable; /** * Creates a new paint scale. */ public LookupPaintScale() { this(0.0, 1.0, Color.lightGray); } /** * Creates a new paint scale with the specified default paint. * * @param lowerBound the lower bound. * @param upperBound the upper bound. * @param defaultPaint the default paint (null not * permitted). */ public LookupPaintScale(double lowerBound, double upperBound, Paint defaultPaint) { if (lowerBound >= upperBound) { throw new IllegalArgumentException( "Requires lowerBound < upperBound."); } if (defaultPaint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.lowerBound = lowerBound; this.upperBound = upperBound; this.defaultPaint = defaultPaint; this.lookupTable = new java.util.ArrayList(); } /** * Returns the default paint (never null). * * @return The default paint. */ public Paint getDefaultPaint() { return this.defaultPaint; } /** * Returns the lower bound. * * @return The lower bound. * * @see #getUpperBound() */ public double getLowerBound() { return this.lowerBound; } /** * Returns the upper bound. * * @return The upper bound. * * @see #getLowerBound() */ public double getUpperBound() { return this.upperBound; } /** * Adds an entry to the lookup table. Any values from n up * to but not including the next value in the table take on the specified * paint. * * @param value the data value (null not permitted). * @param paint the paint. * * @deprecated Use {@link #add(double, Paint)}. */ public void add(Number value, Paint paint) { add(value.doubleValue(), paint); } /** * Adds an entry to the lookup table. Any values from n up * to but not including the next value in the table take on the specified * paint. * * @param value the data value. * @param paint the paint. * * @since 1.0.6 */ public void add(double value, Paint paint) { PaintItem item = new PaintItem(value, paint); int index = Collections.binarySearch(this.lookupTable, item); if (index >= 0) { this.lookupTable.set(index, item); } else { this.lookupTable.add(-(index + 1), item); } } /** * Returns the paint associated with the specified value. * * @param value the value. * * @return The paint. * * @see #getDefaultPaint() */ public Paint getPaint(double value) { // handle value outside bounds... if (value < this.lowerBound) { return this.defaultPaint; } if (value > this.upperBound) { return this.defaultPaint; } int count = this.lookupTable.size(); if (count == 0) { return this.defaultPaint; } // handle special case where value is less that item zero PaintItem item = (PaintItem) this.lookupTable.get(0); if (value < item.value) { return this.defaultPaint; } // for value in bounds, do the lookup... int low = 0; int high = this.lookupTable.size() - 1; while (high - low > 1) { int current = (low + high) / 2; item = (PaintItem) this.lookupTable.get(current); if (value >= item.value) { low = current; } else { high = current; } } if (high > low) { item = (PaintItem) this.lookupTable.get(high); if (value < item.value) { item = (PaintItem) this.lookupTable.get(low); } } return (item != null ? item.paint : this.defaultPaint); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LookupPaintScale)) { return false; } LookupPaintScale that = (LookupPaintScale) obj; if (this.lowerBound != that.lowerBound) { return false; } if (this.upperBound != that.upperBound) { return false; } if (!PaintUtilities.equal(this.defaultPaint, that.defaultPaint)) { return false; } if (!this.lookupTable.equals(that.lookupTable)) { return false; } return true; } /** * Returns a clone of the instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * instance. */ public Object clone() throws CloneNotSupportedException { LookupPaintScale clone = (LookupPaintScale) super.clone(); clone.lookupTable = new java.util.ArrayList(this.lookupTable); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.defaultPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.defaultPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/NotOutlierException.java0000644000175000017500000000422611173030414031071 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * NotOutlierException.java * ------------------------ * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): -; * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.chart.renderer; /** * An exception that is generated by the {@link Outlier}, {@link OutlierList} * and {@link OutlierListCollection} classes. */ public class NotOutlierException extends Exception { /** * Creates a new exception. * * @param message the exception message. */ public NotOutlierException(String message) { super(message); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/Outlier.java0000644000175000017500000001431511173030414026531 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * Outlier.java * ------------ * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 28-Aug-2003 : Minor tidy-up (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 21-Nov-2007 : Implemented equals() to shut up FindBugs (DG); * */ package org.jfree.chart.renderer; import java.awt.geom.Point2D; /** * Represents one outlier in the box and whisker plot. *

* All the coordinates in this class are in Java2D space. */ public class Outlier implements Comparable { /** * The xy coordinates of the bounding box containing the outlier ellipse. */ private Point2D point; /** The radius of the ellipse */ private double radius; /** * Constructs an outlier item consisting of a point and the radius of the * outlier ellipse * * @param xCoord the x coordinate of the point. * @param yCoord the y coordinate of the point. * @param radius the radius of the ellipse. */ public Outlier(double xCoord, double yCoord, double radius) { this.point = new Point2D.Double(xCoord - radius, yCoord - radius); this.radius = radius; } /** * Returns the xy coordinates of the bounding box containing the outlier * ellipse. * * @return The location of the outlier ellipse. */ public Point2D getPoint() { return this.point; } /** * Sets the xy coordinates of the bounding box containing the outlier * ellipse. * * @param point the location. */ public void setPoint(Point2D point) { this.point = point; } /** * Returns the x coordinate of the bounding box containing the outlier * ellipse. * * @return The x coordinate. */ public double getX() { return getPoint().getX(); } /** * Returns the y coordinate of the bounding box containing the outlier * ellipse. * * @return The y coordinate. */ public double getY() { return getPoint().getY(); } /** * Returns the radius of the outlier ellipse. * * @return The radius. */ public double getRadius() { return this.radius; } /** * Sets the radius of the outlier ellipse. * * @param radius the new radius. */ public void setRadius(double radius) { this.radius = radius; } /** * Compares this object with the specified object for order, based on * the outlier's point. * * @param o the Object to be compared. * @return A negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. * */ public int compareTo(Object o) { Outlier outlier = (Outlier) o; Point2D p1 = getPoint(); Point2D p2 = outlier.getPoint(); if (p1.equals(p2)) { return 0; } else if ((p1.getX() < p2.getX()) || (p1.getY() < p2.getY())) { return -1; } else { return 1; } } /** * Returns a true if outlier is overlapped and false if it is not. * Overlapping is determined by the respective bounding boxes plus * a small margin. * * @param other the other outlier. * * @return A boolean indicating whether or not an overlap has * occurred. */ public boolean overlaps(Outlier other) { return ((other.getX() >= getX() - (this.radius * 1.1)) && (other.getX() <= getX() + (this.radius * 1.1)) && (other.getY() >= getY() - (this.radius * 1.1)) && (other.getY() <= getY() + (this.radius * 1.1))); } /** * Tests this outlier for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Outlier)) { return false; } Outlier that = (Outlier) obj; if (!this.point.equals(that.point)) { return false; } if (this.radius != that.radius) { return false; } return true; } /** * Returns a textual representation of the outlier. * * @return A String representing the outlier. */ public String toString() { return "{" + getX() + "," + getY() + "}"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/OutlierList.java0000644000175000017500000001266211173030414027370 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * OutlierList.java * ---------------- * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 28-Aug-2003 : Minor tidy-up including Javadocs (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.chart.renderer; import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * A collection of outliers for a single entity in a box and whisker plot. * * Outliers are grouped in lists for each entity. Lists contain * one or more outliers, determined by whether overlaps have * occured. Overlapping outliers are grouped in the same list. * * Each list contains an averaged outlier, which is the same as a single * outlier if there is only one outlier in the list, but the average of * all the outliers in the list if there is more than one. * * NB This is simply my scheme for displaying outliers, and might not be * acceptable by the wider community. */ public class OutlierList { /** Storage for the outliers. */ private List outliers; /** The averaged outlier. */ private Outlier averagedOutlier; /** * A flag that indicates whether or not there are multiple outliers in the * list. */ private boolean multiple = false; /** * Creates a new list containing a single outlier. * * @param outlier the outlier. */ public OutlierList(Outlier outlier) { this.outliers = new ArrayList(); setAveragedOutlier(outlier); } /** * Adds an outlier to the list. * * @param outlier the outlier. * * @return A boolean. */ public boolean add(Outlier outlier) { return this.outliers.add(outlier); } /** * Returns the number of outliers in the list. * * @return The item count. */ public int getItemCount() { return this.outliers.size(); } /** * Returns the averaged outlier. * * @return The averaged outlier. */ public Outlier getAveragedOutlier() { return this.averagedOutlier; } /** * Sets the averaged outlier. * * @param averagedOutlier the averaged outlier. */ public void setAveragedOutlier(Outlier averagedOutlier) { this.averagedOutlier = averagedOutlier; } /** * Returns true if the list contains multiple outliers, and * false otherwise. * * @return A boolean. */ public boolean isMultiple() { return this.multiple; } /** * Sets the flag that indicates whether or not this list represents * multiple outliers. * * @param multiple the flag. */ public void setMultiple(boolean multiple) { this.multiple = multiple; } /** * Returns true if the outlier overlaps, and * false otherwise. * * @param other the outlier. * * @return A boolean. */ public boolean isOverlapped(Outlier other) { if (other == null) { return false; } boolean result = other.overlaps(getAveragedOutlier()); return result; } /** * Updates the averaged outlier. * */ public void updateAveragedOutlier() { double totalXCoords = 0.0; double totalYCoords = 0.0; int size = getItemCount(); for (Iterator iterator = this.outliers.iterator(); iterator.hasNext();) { Outlier o = (Outlier) iterator.next(); totalXCoords += o.getX(); totalYCoords += o.getY(); } getAveragedOutlier().getPoint().setLocation( new Point2D.Double(totalXCoords / size, totalYCoords / size)); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/OutlierListCollection.java0000644000175000017500000001401411173030414031375 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * OutlierListCollection.java * -------------------------- * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): -; * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 01-Sep-2003 : Made storage internal rather than extending ArrayList (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.chart.renderer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * A collection of outlier lists for a box and whisker plot. Each collection is * associated with a single box and whisker entity. * * Outliers are grouped in lists for each entity. Lists contain * one or more outliers, determined by whether overlaps have * occurred. Overlapping outliers are grouped in the same list. * * @see org.jfree.chart.renderer.OutlierList */ public class OutlierListCollection { /** Storage for the outlier lists. */ private List outlierLists; /** * Unbelievably, outliers which are more than 2 * interquartile range are * called far outs... See Tukey EDA (a classic one of a kind...) */ private boolean highFarOut = false; /** * A flag that indicates whether or not the collection contains low far * out values. */ private boolean lowFarOut = false; /** * Creates a new empty collection. */ public OutlierListCollection() { this.outlierLists = new ArrayList(); } /** * A flag to indicate the presence of one or more far out values at the * top end of the range. * * @return A boolean. */ public boolean isHighFarOut() { return this.highFarOut; } /** * Sets the flag that indicates the presence of one or more far out values * at the top end of the range. * * @param farOut the flag. */ public void setHighFarOut(boolean farOut) { this.highFarOut = farOut; } /** * A flag to indicate the presence of one or more far out values at the * bottom end of the range. * * @return A boolean. */ public boolean isLowFarOut() { return this.lowFarOut; } /** * Sets the flag that indicates the presence of one or more far out values * at the bottom end of the range. * * @param farOut the flag. */ public void setLowFarOut(boolean farOut) { this.lowFarOut = farOut; } /** * Appends the specified element as a new OutlierList to the * end of this list if it does not overlap an outlier in an existing list. * * If it does overlap, it is appended to the outlier list which it overlaps * and that list is updated. * * @param outlier element to be appended to this list. * * @return true (as per the general contract of Collection.add). */ public boolean add(Outlier outlier) { if (this.outlierLists.isEmpty()) { return this.outlierLists.add(new OutlierList(outlier)); } else { boolean updated = false; for (Iterator iterator = this.outlierLists.iterator(); iterator.hasNext();) { OutlierList list = (OutlierList) iterator.next(); if (list.isOverlapped(outlier)) { updated = updateOutlierList(list, outlier); } } if (!updated) { //System.err.print(" creating new outlier list "); updated = this.outlierLists.add(new OutlierList(outlier)); } return updated; } } /** * Returns an iterator for the outlier lists. * * @return An iterator. */ public Iterator iterator() { return this.outlierLists.iterator(); } /** * Updates the outlier list by adding the outlier to the end of the list and * setting the averaged outlier to the average x and y coordinnate values * of the outliers in the list. * * @param list the outlier list to be updated. * @param outlier the outlier to be added * * @return true (as per the general contract of Collection.add). */ private boolean updateOutlierList(OutlierList list, Outlier outlier) { boolean result = false; result = list.add(outlier); list.updateAveragedOutlier(); list.setMultiple(true); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/PaintScale.java0000644000175000017500000000531411173030414027130 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * PaintScale.java * --------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 31-Jan-2007 : Added getLowerBound() and getUpperBound() methods (DG); * */ package org.jfree.chart.renderer; import java.awt.Paint; import org.jfree.chart.renderer.xy.XYBlockRenderer; /** * A source for Paint instances, used by the * {@link XYBlockRenderer}. *

* NOTE: Classes that implement this interface should also implement * PublicCloneable and Serializable, so * that any renderer (or other object instance) that references an instance of * this interface can still be cloned or serialized. * * @since 1.0.4 */ public interface PaintScale { /** * Returns the lower bound for the scale. * * @return The lower bound. * * @see #getUpperBound() */ public double getLowerBound(); /** * Returns the upper bound for the scale. * * @return The upper bound. * * @see #getLowerBound() */ public double getUpperBound(); /** * Returns a Paint instance for the specified value. * * @param value the value. * * @return A Paint instance (never null). */ public Paint getPaint(double value); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/PolarItemRenderer.java0000644000175000017500000001115011173030414030463 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * PolarItemRenderer.java * ---------------------- * (C) Copyright 2004-2008, by Solution Engineering, Inc. and Contributors. * * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG); * */ package org.jfree.chart.renderer; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.util.List; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.PolarPlot; import org.jfree.data.xy.XYDataset; /** * The interface for a renderer that can be used by the {@link PolarPlot} class. */ public interface PolarItemRenderer { /** * Plots the data for a given series. * * @param g2 the drawing surface. * @param dataArea the data area. * @param info collects plot rendering info. * @param plot the plot. * @param dataset the dataset. * @param seriesIndex the series index. */ public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex); /** * Draw the angular gridlines - the spokes. * * @param g2 the drawing surface. * @param plot the plot. * @param ticks the ticks. * @param dataArea the data area. */ public void drawAngularGridLines(Graphics2D g2, PolarPlot plot, List ticks, Rectangle2D dataArea); /** * Draw the radial gridlines - the rings. * * @param g2 the drawing surface. * @param plot the plot. * @param radialAxis the radial axis. * @param ticks the ticks. * @param dataArea the data area. */ public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea); /** * Return the legend for the given series. * * @param series the series index. * * @return The legend item. */ public LegendItem getLegendItem(int series); /** * Returns the plot that this renderer has been assigned to. * * @return The plot. */ public PolarPlot getPlot(); /** * Sets the plot that this renderer is assigned to. *

* This method will be called by the plot class...you do not need to call * it yourself. * * @param plot the plot. */ public void setPlot(PolarPlot plot); /** * Adds a change listener. * * @param listener the listener. */ public void addChangeListener(RendererChangeListener listener); /** * Removes a change listener. * * @param listener the listener. */ public void removeChangeListener(RendererChangeListener listener); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/RendererState.java0000644000175000017500000000556511173030414027664 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * RendererState.java * ------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 07-Oct-2003 : Version 1 (DG); * 09-Jun-2005 : Added a convenience method to access the entity * collection (DG); * */ package org.jfree.chart.renderer; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.plot.PlotRenderingInfo; /** * Represents the current state of a renderer. */ public class RendererState { /** The plot rendering info. */ private PlotRenderingInfo info; /** * Creates a new state object. * * @param info the plot rendering info. */ public RendererState(PlotRenderingInfo info) { this.info = info; } /** * Returns the plot rendering info. * * @return The info. */ public PlotRenderingInfo getInfo() { return this.info; } /** * A convenience method that returns a reference to the entity * collection (may be null) being used to record * chart entities. * * @return The entity collection (possibly null). */ public EntityCollection getEntityCollection() { EntityCollection result = null; if (this.info != null) { ChartRenderingInfo owner = this.info.getOwner(); if (owner != null) { result = owner.getEntityCollection(); } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/RendererUtilities.java0000644000175000017500000002326211173030414030551 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * RendererUtilities.java * ---------------------- * (C) Copyright 2007-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Apr-2007 : Version 1 (DG); * 27-Mar-2009 : Fixed results for unsorted datasets (DG); * */ package org.jfree.chart.renderer; import org.jfree.data.DomainOrder; import org.jfree.data.xy.XYDataset; /** * Utility methods related to the rendering process. * * @since 1.0.6 */ public class RendererUtilities { /** * Finds the lower index of the range of live items in the specified data * series. * * @param dataset the dataset (null not permitted). * @param series the series index. * @param xLow the lowest x-value in the live range. * @param xHigh the highest x-value in the live range. * * @return The index of the required item. * * @since 1.0.6 * * @see #findLiveItemsUpperBound(XYDataset, int, double, double) */ public static int findLiveItemsLowerBound(XYDataset dataset, int series, double xLow, double xHigh) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (xLow >= xHigh) { throw new IllegalArgumentException("Requires xLow < xHigh."); } int itemCount = dataset.getItemCount(series); if (itemCount <= 1) { return 0; } if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { // for data in ascending order by x-value, we are (broadly) looking // for the index of the highest x-value that is less than xLow int low = 0; int high = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue >= xLow) { // special case where the lowest x-value is >= xLow return low; } double highValue = dataset.getXValue(series, high); if (highValue < xLow) { // special case where the highest x-value is < xLow return high; } while (high - low > 1) { int mid = (low + high) / 2; double midV = dataset.getXValue(series, mid); if (midV >= xLow) { high = mid; } else { low = mid; } } return high; } else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { // when the x-values are sorted in descending order, the lower // bound is found by calculating relative to the xHigh value int low = 0; int high = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue <= xHigh) { return low; } double highValue = dataset.getXValue(series, high); if (highValue > xHigh) { return high; } while (high - low > 1) { int mid = (low + high) / 2; double midV = dataset.getXValue(series, mid); if (midV > xHigh) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return high; } else { // we don't know anything about the ordering of the x-values, // but we can still skip any initial values that fall outside the // range... int index = 0; // skip any items that don't need including... double x = dataset.getXValue(series, index); while (index < itemCount && (x < xLow || x > xHigh)) { index++; if (index < itemCount) { x = dataset.getXValue(series, index); } } return Math.min(Math.max(0, index), itemCount - 1); } } /** * Finds the upper index of the range of live items in the specified data * series. * * @param dataset the dataset (null not permitted). * @param series the series index. * @param xLow the lowest x-value in the live range. * @param xHigh the highest x-value in the live range. * * @return The index of the required item. * * @since 1.0.6 * * @see #findLiveItemsLowerBound(XYDataset, int, double, double) */ public static int findLiveItemsUpperBound(XYDataset dataset, int series, double xLow, double xHigh) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (xLow >= xHigh) { throw new IllegalArgumentException("Requires xLow < xHigh."); } int itemCount = dataset.getItemCount(series); if (itemCount <= 1) { return 0; } if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { int low = 0; int high = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue > xHigh) { return low; } double highValue = dataset.getXValue(series, high); if (highValue <= xHigh) { return high; } int mid = (low + high) / 2; while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (midV <= xHigh) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return mid; } else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { // when the x-values are descending, the upper bound is found by // comparing against xLow int low = 0; int high = itemCount - 1; int mid = (low + high) / 2; double lowValue = dataset.getXValue(series, low); if (lowValue < xLow) { return low; } double highValue = dataset.getXValue(series, high); if (highValue >= xLow) { return high; } while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (midV >= xLow) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return mid; } else { // we don't know anything about the ordering of the x-values, // but we can still skip any trailing values that fall outside the // range... int index = itemCount - 1; // skip any items that don't need including... double x = dataset.getXValue(series, index); while (index >= 0 && (x < xLow || x > xHigh)) { index--; if (index >= 0) { x = dataset.getXValue(series, index); } } return Math.max(index, 0); } } /** * Finds a range of item indices that is guaranteed to contain all the * x-values from x0 to x1 (inclusive). * * @param dataset the dataset (null not permitted). * @param series the series index. * @param xLow the lower bound of the x-value range. * @param xHigh the upper bound of the x-value range. * * @return The indices of the boundary items. */ public static int[] findLiveItems(XYDataset dataset, int series, double xLow, double xHigh) { // here we could probably be a little faster by searching for both // indices simultaneously, but I'll look at that later if it seems // like it matters... int i0 = findLiveItemsLowerBound(dataset, series, xLow, xHigh); int i1 = findLiveItemsUpperBound(dataset, series, xLow, xHigh); if (i0 > i1) { i0 = i1; } return new int[] {i0, i1}; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/WaferMapRenderer.java0000644000175000017500000003142211173030414030275 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * WaferMapRenderer.java * --------------------- * (C) Copyright 2003-2008, by Robert Redburn and Contributors. * * Original Author: Robert Redburn; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 25-Nov-2003 : Version 1, contributed by Robert Redburn. Changes have been * made to fit the JFreeChart coding style (DG); * 20-Apr-2005 : Small update for changes to LegendItem class (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.chart.renderer; import java.awt.Color; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.plot.DrawingSupplier; import org.jfree.chart.plot.WaferMapPlot; import org.jfree.data.general.WaferMapDataset; /** * A renderer for wafer map plots. Provides color managment facilities. */ public class WaferMapRenderer extends AbstractRenderer { /** paint index */ private Map paintIndex; /** plot */ private WaferMapPlot plot; /** paint limit */ private int paintLimit; /** default paint limit */ private static final int DEFAULT_PAINT_LIMIT = 35; /** default multivalue paint calculation */ public static final int POSITION_INDEX = 0; /** The default value index. */ public static final int VALUE_INDEX = 1; /** paint index method */ private int paintIndexMethod; /** * Creates a new renderer. */ public WaferMapRenderer() { this(null, null); } /** * Creates a new renderer. * * @param paintLimit the paint limit. * @param paintIndexMethod the paint index method. */ public WaferMapRenderer(int paintLimit, int paintIndexMethod) { this(new Integer(paintLimit), new Integer(paintIndexMethod)); } /** * Creates a new renderer. * * @param paintLimit the paint limit. * @param paintIndexMethod the paint index method. */ public WaferMapRenderer(Integer paintLimit, Integer paintIndexMethod) { super(); this.paintIndex = new HashMap(); if (paintLimit == null) { this.paintLimit = DEFAULT_PAINT_LIMIT; } else { this.paintLimit = paintLimit.intValue(); } this.paintIndexMethod = VALUE_INDEX; if (paintIndexMethod != null) { if (isMethodValid(paintIndexMethod.intValue())) { this.paintIndexMethod = paintIndexMethod.intValue(); } } } /** * Verifies that the passed paint index method is valid. * * @param method the method. * * @return true or false. */ private boolean isMethodValid(int method) { switch (method) { case POSITION_INDEX: return true; case VALUE_INDEX: return true; default: return false; } } /** * Returns the drawing supplier from the plot. * * @return The drawing supplier. */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; WaferMapPlot p = getPlot(); if (p != null) { result = p.getDrawingSupplier(); } return result; } /** * Returns the plot. * * @return The plot. */ public WaferMapPlot getPlot() { return this.plot; } /** * Sets the plot and build the paint index. * * @param plot the plot. */ public void setPlot(WaferMapPlot plot) { this.plot = plot; makePaintIndex(); } /** * Returns the paint for a given chip value. * * @param value the value. * * @return The paint. */ public Paint getChipColor(Number value) { return getSeriesPaint(getPaintIndex(value)); } /** * Returns the paint index for a given chip value. * * @param value the value. * * @return The paint index. */ private int getPaintIndex(Number value) { return ((Integer) this.paintIndex.get(value)).intValue(); } /** * Builds a map of chip values to paint colors. * paintlimit is the maximum allowed number of colors. */ private void makePaintIndex() { if (this.plot == null) { return; } WaferMapDataset data = this.plot.getDataset(); Number dataMin = data.getMinValue(); Number dataMax = data.getMaxValue(); Set uniqueValues = data.getUniqueValues(); if (uniqueValues.size() <= this.paintLimit) { int count = 0; // assign a color for each unique value for (Iterator i = uniqueValues.iterator(); i.hasNext();) { this.paintIndex.put(i.next(), new Integer(count++)); } } else { // more values than paints so map // multiple values to the same color switch (this.paintIndexMethod) { case POSITION_INDEX: makePositionIndex(uniqueValues); break; case VALUE_INDEX: makeValueIndex(dataMax, dataMin, uniqueValues); break; default: break; } } } /** * Builds the paintindex by assigning colors based on the number * of unique values: totalvalues/totalcolors. * * @param uniqueValues the set of unique values. */ private void makePositionIndex(Set uniqueValues) { int valuesPerColor = (int) Math.ceil( (double) uniqueValues.size() / this.paintLimit ); int count = 0; // assign a color for each unique value int paint = 0; for (Iterator i = uniqueValues.iterator(); i.hasNext();) { this.paintIndex.put(i.next(), new Integer(paint)); if (++count % valuesPerColor == 0) { paint++; } if (paint > this.paintLimit) { paint = this.paintLimit; } } } /** * Builds the paintindex by assigning colors evenly across the range * of values: maxValue-minValue/totalcolors * * @param max the maximum value. * @param min the minumum value. * @param uniqueValues the unique values. */ private void makeValueIndex(Number max, Number min, Set uniqueValues) { double valueRange = max.doubleValue() - min.doubleValue(); double valueStep = valueRange / this.paintLimit; int paint = 0; double cutPoint = min.doubleValue() + valueStep; for (Iterator i = uniqueValues.iterator(); i.hasNext();) { Number value = (Number) i.next(); while (value.doubleValue() > cutPoint) { cutPoint += valueStep; paint++; if (paint > this.paintLimit) { paint = this.paintLimit; } } this.paintIndex.put(value, new Integer(paint)); } } /** * Builds the list of legend entries. called by getLegendItems in * WaferMapPlot to populate the plot legend. * * @return The legend items. */ public LegendItemCollection getLegendCollection() { LegendItemCollection result = new LegendItemCollection(); if (this.paintIndex != null && this.paintIndex.size() > 0) { if (this.paintIndex.size() <= this.paintLimit) { for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext();) { // in this case, every color has a unique value Map.Entry entry = (Map.Entry) i.next(); String label = entry.getKey().toString(); String description = label; Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d); Paint paint = lookupSeriesPaint( ((Integer) entry.getValue()).intValue()); Paint outlinePaint = Color.black; Stroke outlineStroke = DEFAULT_STROKE; result.add(new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint)); } } else { // in this case, every color has a range of values Set unique = new HashSet(); for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); if (unique.add(entry.getValue())) { String label = getMinPaintValue( (Integer) entry.getValue()).toString() + " - " + getMaxPaintValue( (Integer) entry.getValue()).toString(); String description = label; Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d); Paint paint = getSeriesPaint( ((Integer) entry.getValue()).intValue() ); Paint outlinePaint = Color.black; Stroke outlineStroke = DEFAULT_STROKE; result.add(new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint)); } } // end foreach map entry } // end else } return result; } /** * Returns the minimum chip value assigned to a color * in the paintIndex * * @param index the index. * * @return The value. */ private Number getMinPaintValue(Integer index) { double minValue = Double.POSITIVE_INFINITY; for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); if (((Integer) entry.getValue()).equals(index)) { if (((Number) entry.getKey()).doubleValue() < minValue) { minValue = ((Number) entry.getKey()).doubleValue(); } } } return new Double(minValue); } /** * Returns the maximum chip value assigned to a color * in the paintIndex * * @param index the index. * * @return The value */ private Number getMaxPaintValue(Integer index) { double maxValue = Double.NEGATIVE_INFINITY; for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); if (((Integer) entry.getValue()).equals(index)) { if (((Number) entry.getKey()).doubleValue() > maxValue) { maxValue = ((Number) entry.getKey()).doubleValue(); } } } return new Double(maxValue); } } // end class wafermaprenderer libjfreechart-java-1.0.13.orig/source/org/jfree/chart/renderer/package.html0000644000175000017500000000037211173030414026522 0ustar vincentvincent Core support for the plug-in renderers used by the {@link org.jfree.chart.plot.CategoryPlot} and {@link org.jfree.chart.plot.XYPlot} classes. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/resources/0000755000175000017500000000000011216245562024455 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/resources/JFreeChartResources.java0000644000175000017500000000430711173030414031162 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * JFreeChartResources.java * ------------------------ * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * */ package org.jfree.chart.resources; import java.util.ListResourceBundle; /** * Localised resources for JFreeChart. */ public class JFreeChartResources extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"project.name", "JFreeChart"}, {"project.version", "1.0.13"}, {"project.info", "http://www.jfree.org/jfreechart/index.html"}, {"project.copyright", "(C)opyright 2000-2009, by Object Refinery Limited and Contributors"} }; } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/resources/package.html0000644000175000017500000000024211173030414026722 0ustar vincentvincent Localised resources for the JFreeChart class library. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/servlet/0000755000175000017500000000000011216245562024127 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/servlet/ChartDeleter.java0000644000175000017500000000756711173030414027345 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ChartDeleter.java * ----------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): -; * * Changes * ------- * 19-Aug-2002 : Version 1; * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.servlet; import java.io.File; import java.io.Serializable; import java.util.Iterator; import java.util.List; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; /** * Used for deleting charts from the temporary directory when the users session * expires. */ public class ChartDeleter implements HttpSessionBindingListener, Serializable { /** The chart names. */ private List chartNames = new java.util.ArrayList(); /** * Blank constructor. */ public ChartDeleter() { super(); } /** * Add a chart to be deleted when the session expires * * @param filename the name of the chart in the temporary directory to be * deleted. */ public void addChart(String filename) { this.chartNames.add(filename); } /** * Checks to see if a chart is in the list of charts to be deleted * * @param filename the name of the chart in the temporary directory. * * @return A boolean value indicating whether the chart is present in the * list. */ public boolean isChartAvailable(String filename) { return (this.chartNames.contains(filename)); } /** * Binding this object to the session has no additional effects. * * @param event the session bind event. */ public void valueBound(HttpSessionBindingEvent event) { return; } /** * When this object is unbound from the session (including upon session * expiry) the files that have been added to the ArrayList are iterated * and deleted. * * @param event the session unbind event. */ public void valueUnbound(HttpSessionBindingEvent event) { Iterator iter = this.chartNames.listIterator(); while (iter.hasNext()) { String filename = (String) iter.next(); File file = new File( System.getProperty("java.io.tmpdir"), filename ); if (file.exists()) { file.delete(); } } return; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/servlet/DisplayChart.java0000644000175000017500000001214711173030414027354 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * DisplayChart.java * ----------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Aug-2002 : Version 1; * 09-Mar-2005 : Added facility to serve up "one time" charts - see * ServletUtilities.java (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.servlet; import java.io.File; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * Servlet used for streaming charts to the client browser from the temporary * directory. You need to add this servlet and mapping to your deployment * descriptor (web.xml) in order to get it to work. The syntax is as follows: *

* <servlet> * <servlet-name>DisplayChart</servlet-name> * <servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class> * </servlet> * <servlet-mapping> * <servlet-name>DisplayChart</servlet-name> * <url-pattern>/servlet/DisplayChart</url-pattern> * </servlet-mapping> * */ public class DisplayChart extends HttpServlet { /** * Default constructor. */ public DisplayChart() { super(); } /** * Init method. * * @throws ServletException never. */ public void init() throws ServletException { return; } /** * Service method. * * @param request the request. * @param response the response. * * @throws ServletException ??. * @throws IOException ??. */ public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); String filename = request.getParameter("filename"); if (filename == null) { throw new ServletException("Parameter 'filename' must be supplied"); } // Replace ".." with "" // This is to prevent access to the rest of the file system filename = ServletUtilities.searchReplace(filename, "..", ""); // Check the file exists File file = new File(System.getProperty("java.io.tmpdir"), filename); if (!file.exists()) { throw new ServletException("File '" + file.getAbsolutePath() + "' does not exist"); } // Check that the graph being served was created by the current user // or that it begins with "public" boolean isChartInUserList = false; ChartDeleter chartDeleter = (ChartDeleter) session.getAttribute( "JFreeChart_Deleter"); if (chartDeleter != null) { isChartInUserList = chartDeleter.isChartAvailable(filename); } boolean isChartPublic = false; if (filename.length() >= 6) { if (filename.substring(0, 6).equals("public")) { isChartPublic = true; } } boolean isOneTimeChart = false; if (filename.startsWith(ServletUtilities.getTempOneTimeFilePrefix())) { isOneTimeChart = true; } if (isChartInUserList || isChartPublic || isOneTimeChart) { // Serve it up ServletUtilities.sendTempFile(file, response); if (isOneTimeChart) { file.delete(); } } else { throw new ServletException("Chart image not found"); } return; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/servlet/ServletUtilities.java0000644000175000017500000004170611173030414030310 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ServletUtilities.java * --------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): J?rgen Hoffman; * David Gilbert (for Object Refinery Limited); * Douglas Clayton; * * Changes * ------- * 19-Aug-2002 : Version 1; * 20-Apr-2003 : Added additional sendTempFile method to allow MIME type * specification and modified original sendTempFile method to * automatically set MIME type for JPEG and PNG files * 23-Jun-2003 : Added additional sendTempFile method at the request of * J?rgen Hoffman; * 07-Jul-2003 : Added more header information to streamed images; * 19-Aug-2003 : Forced images to be stored in the temporary directory defined * by System property java.io.tmpdir, rather than default (RA); * 24-Mar-2004 : Added temp filename prefix attribute (DG); * 09-Mar-2005 : Added "one time" file option (DG); * ------------- JFREECHART 1.0.x RELEASED ------------------------------------ * 10-Jan-2006 : Updated API docs and reformatted (DG); * 13-Sep-2006 : Format date in response header in English, not locale default * (see bug 1557141) (DG); * */ package org.jfree.chart.servlet; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; /** * Utility class used for servlet related JFreeChart operations. */ public class ServletUtilities { /** The filename prefix. */ private static String tempFilePrefix = "jfreechart-"; /** A prefix for "one time" charts. */ private static String tempOneTimeFilePrefix = "jfreechart-onetime-"; /** * Returns the prefix for the temporary file names generated by this class. * * @return The prefix (never null). */ public static String getTempFilePrefix() { return ServletUtilities.tempFilePrefix; } /** * Sets the prefix for the temporary file names generated by this class. * * @param prefix the prefix (null not permitted). */ public static void setTempFilePrefix(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } ServletUtilities.tempFilePrefix = prefix; } /** * Returns the prefix for "one time" temporary file names generated by * this class. * * @return The prefix. */ public static String getTempOneTimeFilePrefix() { return ServletUtilities.tempOneTimeFilePrefix; } /** * Sets the prefix for the "one time" temporary file names generated by * this class. * * @param prefix the prefix (null not permitted). */ public static void setTempOneTimeFilePrefix(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } ServletUtilities.tempOneTimeFilePrefix = prefix; } /** * Saves the chart as a PNG format file in the temporary directory. * * @param chart the JFreeChart to be saved. * @param width the width of the chart. * @param height the height of the chart. * @param session the HttpSession of the client (if null, the * temporary file is marked as "one-time" and deleted by * the {@link DisplayChart} servlet right after it is * streamed to the client). * * @return The filename of the chart saved in the temporary directory. * * @throws IOException if there is a problem saving the file. */ public static String saveChartAsPNG(JFreeChart chart, int width, int height, HttpSession session) throws IOException { return ServletUtilities.saveChartAsPNG(chart, width, height, null, session); } /** * Saves the chart as a PNG format file in the temporary directory and * populates the {@link ChartRenderingInfo} object which can be used to * generate an HTML image map. * * @param chart the chart to be saved (null not permitted). * @param width the width of the chart. * @param height the height of the chart. * @param info the ChartRenderingInfo object to be populated * (null permitted). * @param session the HttpSession of the client (if null, the * temporary file is marked as "one-time" and deleted by * the {@link DisplayChart} servlet right after it is * streamed to the client). * * @return The filename of the chart saved in the temporary directory. * * @throws IOException if there is a problem saving the file. */ public static String saveChartAsPNG(JFreeChart chart, int width, int height, ChartRenderingInfo info, HttpSession session) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } ServletUtilities.createTempDir(); String prefix = ServletUtilities.tempFilePrefix; if (session == null) { prefix = ServletUtilities.tempOneTimeFilePrefix; } File tempFile = File.createTempFile(prefix, ".png", new File(System.getProperty("java.io.tmpdir"))); ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info); if (session != null) { ServletUtilities.registerChartForDeletion(tempFile, session); } return tempFile.getName(); } /** * Saves the chart as a JPEG format file in the temporary directory. *

* SPECIAL NOTE: Please avoid using JPEG as an image format for charts, * it is a "lossy" format that introduces visible distortions in the * resulting image - use PNG instead. In addition, note that JPEG output * is supported by JFreeChart only for JRE 1.4.2 or later. * * @param chart the JFreeChart to be saved. * @param width the width of the chart. * @param height the height of the chart. * @param session the HttpSession of the client (if null, the * temporary file is marked as "one-time" and deleted by * the {@link DisplayChart} servlet right after it is * streamed to the client). * * @return The filename of the chart saved in the temporary directory. * * @throws IOException if there is a problem saving the file. */ public static String saveChartAsJPEG(JFreeChart chart, int width, int height, HttpSession session) throws IOException { return ServletUtilities.saveChartAsJPEG(chart, width, height, null, session); } /** * Saves the chart as a JPEG format file in the temporary directory and * populates the ChartRenderingInfo object which can be used * to generate an HTML image map. *

* SPECIAL NOTE: Please avoid using JPEG as an image format for charts, * it is a "lossy" format that introduces visible distortions in the * resulting image - use PNG instead. In addition, note that JPEG output * is supported by JFreeChart only for JRE 1.4.2 or later. * * @param chart the chart to be saved (null not permitted). * @param width the width of the chart * @param height the height of the chart * @param info the ChartRenderingInfo object to be populated * @param session the HttpSession of the client (if null, the * temporary file is marked as "one-time" and deleted by * the {@link DisplayChart} servlet right after it is * streamed to the client). * * @return The filename of the chart saved in the temporary directory * * @throws IOException if there is a problem saving the file. */ public static String saveChartAsJPEG(JFreeChart chart, int width, int height, ChartRenderingInfo info, HttpSession session) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } ServletUtilities.createTempDir(); String prefix = ServletUtilities.tempFilePrefix; if (session == null) { prefix = ServletUtilities.tempOneTimeFilePrefix; } File tempFile = File.createTempFile(prefix, ".jpeg", new File(System.getProperty("java.io.tmpdir"))); ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info); if (session != null) { ServletUtilities.registerChartForDeletion(tempFile, session); } return tempFile.getName(); } /** * Creates the temporary directory if it does not exist. Throws a * RuntimeException if the temporary directory is * null. Uses the system property java.io.tmpdir * as the temporary directory. This sounds like a strange thing to do but * my temporary directory was not created on my default Tomcat 4.0.3 * installation. Could save some questions on the forum if it is created * when not present. */ protected static void createTempDir() { String tempDirName = System.getProperty("java.io.tmpdir"); if (tempDirName == null) { throw new RuntimeException("Temporary directory system property " + "(java.io.tmpdir) is null."); } // create the temporary directory if it doesn't exist File tempDir = new File(tempDirName); if (!tempDir.exists()) { tempDir.mkdirs(); } } /** * Adds a {@link ChartDeleter} object to the session object with the name * JFreeChart_Deleter if there is not already one bound to the * session and adds the filename to the list of charts to be deleted. * * @param tempFile the file to be deleted. * @param session the HTTP session of the client. */ protected static void registerChartForDeletion(File tempFile, HttpSession session) { // Add chart to deletion list in session if (session != null) { ChartDeleter chartDeleter = (ChartDeleter) session.getAttribute("JFreeChart_Deleter"); if (chartDeleter == null) { chartDeleter = new ChartDeleter(); session.setAttribute("JFreeChart_Deleter", chartDeleter); } chartDeleter.addChart(tempFile.getName()); } else { System.out.println("Session is null - chart will not be deleted"); } } /** * Binary streams the specified file in the temporary directory to the * HTTP response in 1KB chunks. * * @param filename the name of the file in the temporary directory. * @param response the HTTP response object. * * @throws IOException if there is an I/O problem. */ public static void sendTempFile(String filename, HttpServletResponse response) throws IOException { File file = new File(System.getProperty("java.io.tmpdir"), filename); ServletUtilities.sendTempFile(file, response); } /** * Binary streams the specified file to the HTTP response in 1KB chunks. * * @param file the file to be streamed. * @param response the HTTP response object. * * @throws IOException if there is an I/O problem. */ public static void sendTempFile(File file, HttpServletResponse response) throws IOException { String mimeType = null; String filename = file.getName(); if (filename.length() > 5) { if (filename.substring(filename.length() - 5, filename.length()).equals(".jpeg")) { mimeType = "image/jpeg"; } else if (filename.substring(filename.length() - 4, filename.length()).equals(".png")) { mimeType = "image/png"; } } ServletUtilities.sendTempFile(file, response, mimeType); } /** * Binary streams the specified file to the HTTP response in 1KB chunks. * * @param file the file to be streamed. * @param response the HTTP response object. * @param mimeType the mime type of the file, null allowed. * * @throws IOException if there is an I/O problem. */ public static void sendTempFile(File file, HttpServletResponse response, String mimeType) throws IOException { if (file.exists()) { BufferedInputStream bis = new BufferedInputStream( new FileInputStream(file)); // Set HTTP headers if (mimeType != null) { response.setHeader("Content-Type", mimeType); } response.setHeader("Content-Length", String.valueOf(file.length())); SimpleDateFormat sdf = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); response.setHeader("Last-Modified", sdf.format(new Date(file.lastModified()))); BufferedOutputStream bos = new BufferedOutputStream( response.getOutputStream()); byte[] input = new byte[1024]; boolean eof = false; while (!eof) { int length = bis.read(input); if (length == -1) { eof = true; } else { bos.write(input, 0, length); } } bos.flush(); bis.close(); bos.close(); } else { throw new FileNotFoundException(file.getAbsolutePath()); } return; } /** * Perform a search/replace operation on a String * There are String methods to do this since (JDK 1.4) * * @param inputString the String to have the search/replace operation. * @param searchString the search String. * @param replaceString the replace String. * * @return The String with the replacements made. */ public static String searchReplace(String inputString, String searchString, String replaceString) { int i = inputString.indexOf(searchString); if (i == -1) { return inputString; } String r = ""; r += inputString.substring(0, i) + replaceString; if (i + searchString.length() < inputString.length()) { r += searchReplace(inputString.substring(i + searchString.length()), searchString, replaceString); } return r; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/servlet/package.html0000644000175000017500000000025011173030414026373 0ustar vincentvincent Classes for providing useful servlet and JSP functionality. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/0000755000175000017500000000000011216245562023564 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/CompositeTitle.java0000644000175000017500000002002611173030414027361 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CompositeTitle.java * ------------------- * (C) Copyright 2005-2008, by David Gilbert and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Eric Penfold (patch 2006826); * * Changes * ------- * 19-Nov-2004 : Version 1 (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 04-Feb-2005 : Implemented MAXIMUM_WIDTH in calculateSize (DG); * 20-Apr-2005 : Added new draw() method (DG); * 03-May-2005 : Implemented equals() method (DG); * 02-Jul-2008 : Applied patch 2006826 by Eric Penfold, to enable chart * entities to be generated (DG); * 09-Jul-2008 : Added backgroundPaint field (DG); * */ package org.jfree.chart.title; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.BorderArrangement; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.io.SerialUtilities; import org.jfree.ui.Size2D; import org.jfree.util.PaintUtilities; /** * A title that contains multiple titles within a {@link BlockContainer}. */ public class CompositeTitle extends Title implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6770854036232562290L; /** * The background paint. * * @since 1.0.11 */ private transient Paint backgroundPaint; /** A container for the individual titles. */ private BlockContainer container; /** * Creates a new composite title with a default border arrangement. */ public CompositeTitle() { this(new BlockContainer(new BorderArrangement())); } /** * Creates a new title using the specified container. * * @param container the container (null not permitted). */ public CompositeTitle(BlockContainer container) { if (container == null) { throw new IllegalArgumentException("Null 'container' argument."); } this.container = container; this.backgroundPaint = null; } /** * Returns the background paint. * * @return The paint (possibly null). * * @since 1.0.11 */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint and sends a {@link TitleChangeEvent} to all * registered listeners. If you set this attribute to null, * no background is painted (which makes the title background transparent). * * @param paint the background paint (null permitted). * * @since 1.0.11 */ public void setBackgroundPaint(Paint paint) { this.backgroundPaint = paint; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the container holding the titles. * * @return The title container (never null). */ public BlockContainer getContainer() { return this.container; } /** * Sets the title container. * * @param container the container (null not permitted). */ public void setTitleContainer(BlockContainer container) { if (container == null) { throw new IllegalArgumentException("Null 'container' argument."); } this.container = container; } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint contentConstraint = toContentConstraint(constraint); Size2D contentSize = this.container.arrange(g2, contentConstraint); return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight())); } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area allocated for the title. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return Always null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = trimMargin(area); drawBorder(g2, area); area = trimBorder(area); if (this.backgroundPaint != null) { g2.setPaint(this.backgroundPaint); g2.fill(area); } area = trimPadding(area); return this.container.draw(g2, area, params); } /** * Tests this title for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CompositeTitle)) { return false; } CompositeTitle that = (CompositeTitle) obj; if (!this.container.equals(that.container)) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.backgroundPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.backgroundPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/DateTitle.java0000644000175000017500000001554211173030414026303 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * DateTitle.java * -------------- * (C) Copyright 2000-2008, by David Berry and Contributors. * * Original Author: David Berry; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header (DG); * 09-Jan-2002 : Updated Javadoc comments (DG); * 07-Feb-2002 : Changed blank space around title from Insets --> Spacer, to * allow for relative or absolute spacing (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 31-Jan-2005 : Updated for changes to super class (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.title; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.io.Serializable; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.VerticalAlignment; /** * A chart title that displays the date. *

* Keep in mind that a chart can have several titles, and that they can appear * at the top, left, right or bottom of the chart - a DateTitle * will commonly appear at the bottom of a chart, although you can place it * anywhere. *

* By specifying the locale, dates are formatted to the correct standard for * the given locale. For example, a date would appear as "January 17, 2000" in * the US, but "17 January 2000" in most European locales. */ public class DateTitle extends TextTitle implements Serializable { /** For serialization. */ private static final long serialVersionUID = -465434812763159881L; /** * Creates a new chart title that displays the current date in the default * (LONG) format for the locale, positioned to the bottom right of the * chart. *

* The color will be black in 12 point, plain Helvetica font (maps to Arial * on Win32 systems without Helvetica). */ public DateTitle() { this(DateFormat.LONG); } /** * Creates a new chart title that displays the current date with the * specified style (for the default locale). *

* The date style should be one of: SHORT, * MEDIUM, LONG or FULL * (defined in java.util.DateFormat). * * @param style the date style. */ public DateTitle(int style) { this(style, Locale.getDefault(), new Font("Dialog", Font.PLAIN, 12), Color.black); } /** * Creates a new chart title that displays the current date. *

* The date style should be one of: SHORT, * MEDIUM, LONG or FULL (defined * in java.util.DateFormat). *

* For the locale, you can use Locale.getDefault() for the * default locale. * * @param style the date style. * @param locale the locale. * @param font the font. * @param paint the text color. */ public DateTitle(int style, Locale locale, Font font, Paint paint) { this(style, locale, font, paint, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.CENTER, Title.DEFAULT_PADDING); } /** * Creates a new chart title that displays the current date. *

* The date style should be one of: SHORT, * MEDIUM, LONG or FULL (defined * in java.util.DateFormat). *

* For the locale, you can use Locale.getDefault() for the * default locale. * * @param style the date style. * @param locale the locale. * @param font the font (not null). * @param paint the text color (not null). * @param position the relative location of this title (use constants in * Title). * @param horizontalAlignment the horizontal text alignment of this title * (use constants in Title). * @param verticalAlignment the vertical text alignment of this title (use * constants in Title). * @param padding determines the blank space around the outside of the * title (not null). */ public DateTitle(int style, Locale locale, Font font, Paint paint, RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding) { super(DateFormat.getDateInstance(style, locale).format(new Date()), font, paint, position, horizontalAlignment, verticalAlignment, padding); } /** * Set the format of the date. *

* The date style should be one of: SHORT, * MEDIUM, LONG or FULL (defined * in java.util.DateFormat). *

* For the locale, you can use Locale.getDefault() for the * default locale. * * @param style the date style. * @param locale the locale. */ public void setDateFormat(int style, Locale locale) { setText(DateFormat.getDateInstance(style, locale).format(new Date())); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/ImageTitle.java0000644000175000017500000003223411173030414026445 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ImageTitle.java * --------------- * (C) Copyright 2000-2008, by David Berry and Contributors; * * Original Author: David Berry; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header (DG); * 07-Nov-2001 : Separated the JCommon Class Library classes, JFreeChart now * requires jcommon.jar (DG); * 09-Jan-2002 : Updated Javadoc comments (DG); * 07-Feb-2002 : Changed blank space around title from Insets --> Spacer, to * allow for relative or absolute spacing (DG); * 25-Jun-2002 : Updated import statements (DG); * 23-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 26-Nov-2002 : Added method for drawing images at left or right (DG); * 22-Sep-2003 : Added checks that the Image can never be null (TM). * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 02-Feb-2005 : Changed padding mechanism for all titles (DG); * 20-Apr-2005 : Added new draw() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 11-Apr-2008 : Added arrange() method override to account for margin, border * and padding (DG); * 21-Apr-2008 : Added equals() method override (DG); * */ package org.jfree.chart.title; import java.awt.Graphics2D; import java.awt.Image; import java.awt.geom.Rectangle2D; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.ui.VerticalAlignment; import org.jfree.util.ObjectUtilities; /** * A chart title that displays an image. This is useful, for example, if you * have an image of your corporate logo and want to use as a footnote or part * of a title in a chart you create. *

* ImageTitle needs an image passed to it in the constructor. For ImageTitle * to work, you must have already loaded this image from its source (disk or * URL). It is recommended you use something like * Toolkit.getDefaultToolkit().getImage() to get the image. Then, use * MediaTracker or some other message to make sure the image is fully loaded * from disk. *

* SPECIAL NOTE: this class fails to serialize, so if you are * relying on your charts to be serializable, please avoid using this class. */ public class ImageTitle extends Title { /** The title image. */ private Image image; /** * Creates a new image title. * * @param image the image (null not permitted). */ public ImageTitle(Image image) { this(image, image.getHeight(null), image.getWidth(null), Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); } /** * Creates a new image title. * * @param image the image (null not permitted). * @param position the title position. * @param horizontalAlignment the horizontal alignment. * @param verticalAlignment the vertical alignment. */ public ImageTitle(Image image, RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { this(image, image.getHeight(null), image.getWidth(null), position, horizontalAlignment, verticalAlignment, Title.DEFAULT_PADDING); } /** * Creates a new image title with the given image scaled to the given * width and height in the given location. * * @param image the image (null not permitted). * @param height the height used to draw the image. * @param width the width used to draw the image. * @param position the title position. * @param horizontalAlignment the horizontal alignment. * @param verticalAlignment the vertical alignment. * @param padding the amount of space to leave around the outside of the * title. */ public ImageTitle(Image image, int height, int width, RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding) { super(position, horizontalAlignment, verticalAlignment, padding); if (image == null) { throw new NullPointerException("Null 'image' argument."); } this.image = image; setHeight(height); setWidth(width); } /** * Returns the image for the title. * * @return The image for the title (never null). */ public Image getImage() { return this.image; } /** * Sets the image for the title and notifies registered listeners that the * title has been modified. * * @param image the new image (null not permitted). */ public void setImage(Image image) { if (image == null) { throw new NullPointerException("Null 'image' argument."); } this.image = image; notifyListeners(new TitleChangeEvent(this)); } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { Size2D s = new Size2D(this.image.getWidth(null), this.image.getHeight(null)); return new Size2D(calculateTotalWidth(s.getWidth()), calculateTotalHeight(s.getHeight())); } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area allocated for the title. */ public void draw(Graphics2D g2, Rectangle2D area) { RectangleEdge position = getPosition(); if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { drawHorizontal(g2, area); } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { drawVertical(g2, area); } else { throw new RuntimeException("Invalid title position."); } } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param chartArea the area within which the title (and plot) should be * drawn. * * @return The size of the area used by the title. */ protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) { double startY = 0.0; double topSpace = 0.0; double bottomSpace = 0.0; double leftSpace = 0.0; double rightSpace = 0.0; double w = getWidth(); double h = getHeight(); RectangleInsets padding = getPadding(); topSpace = padding.calculateTopOutset(h); bottomSpace = padding.calculateBottomOutset(h); leftSpace = padding.calculateLeftOutset(w); rightSpace = padding.calculateRightOutset(w); if (getPosition() == RectangleEdge.TOP) { startY = chartArea.getY() + topSpace; } else { startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h; } // what is our alignment? HorizontalAlignment horizontalAlignment = getHorizontalAlignment(); double startX = 0.0; if (horizontalAlignment == HorizontalAlignment.CENTER) { startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0 - w / 2.0; } else if (horizontalAlignment == HorizontalAlignment.LEFT) { startX = chartArea.getX() + leftSpace; } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w; } g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, null); return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, h + topSpace + bottomSpace); } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param chartArea the area within which the title (and plot) should be * drawn. * * @return The size of the area used by the title. */ protected Size2D drawVertical(Graphics2D g2, Rectangle2D chartArea) { double startX = 0.0; double topSpace = 0.0; double bottomSpace = 0.0; double leftSpace = 0.0; double rightSpace = 0.0; double w = getWidth(); double h = getHeight(); RectangleInsets padding = getPadding(); if (padding != null) { topSpace = padding.calculateTopOutset(h); bottomSpace = padding.calculateBottomOutset(h); leftSpace = padding.calculateLeftOutset(w); rightSpace = padding.calculateRightOutset(w); } if (getPosition() == RectangleEdge.LEFT) { startX = chartArea.getX() + leftSpace; } else { startX = chartArea.getMaxX() - rightSpace - w; } // what is our alignment? VerticalAlignment alignment = getVerticalAlignment(); double startY = 0.0; if (alignment == VerticalAlignment.CENTER) { startY = chartArea.getMinY() + topSpace + chartArea.getHeight() / 2.0 - h / 2.0; } else if (alignment == VerticalAlignment.TOP) { startY = chartArea.getMinY() + topSpace; } else if (alignment == VerticalAlignment.BOTTOM) { startY = chartArea.getMaxY() - bottomSpace - h; } g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, null); return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, h + topSpace + bottomSpace); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return Always null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { draw(g2, area); return null; } /** * Tests this ImageTitle for equality with an arbitrary * object. Returns true if: *

    *
  • obj is an instance of ImageTitle; *
  • obj references the same image as this * ImageTitle; *
  • super.equals(obj) returns true; *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ImageTitle)) { return false; } ImageTitle that = (ImageTitle) obj; if (!ObjectUtilities.equal(this.image, that.image)) { return false; } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/LegendGraphic.java0000644000175000017500000005472411173030414027125 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * LegendGraphic.java * ------------------ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Oct-2004 : Version 1 (DG); * 21-Jan-2005 : Modified return type of RectangleAnchor.coordinates() * method (DG); * 20-Apr-2005 : Added new draw() method (DG); * 13-May-2005 : Fixed to respect margin, border and padding settings (DG); * 01-Sep-2005 : Implemented PublicCloneable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Dec-2006 : Added fillPaintTransformer attribute, so legend graphics can * display gradient paint correctly, updated equals() and * corrected clone() (DG); * 01-Aug-2007 : Updated API docs (DG); * */ package org.jfree.chart.title; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.block.AbstractBlock; import org.jfree.chart.block.Block; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.io.SerialUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.Size2D; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * The graphical item within a legend item. */ public class LegendGraphic extends AbstractBlock implements Block, PublicCloneable { /** For serialization. */ static final long serialVersionUID = -1338791523854985009L; /** * A flag that controls whether or not the shape is visible - see also * lineVisible. */ private boolean shapeVisible; /** * The shape to display. To allow for accurate positioning, the center * of the shape should be at (0, 0). */ private transient Shape shape; /** * Defines the location within the block to which the shape will be aligned. */ private RectangleAnchor shapeLocation; /** * Defines the point on the shape's bounding rectangle that will be * aligned to the drawing location when the shape is rendered. */ private RectangleAnchor shapeAnchor; /** A flag that controls whether or not the shape is filled. */ private boolean shapeFilled; /** The fill paint for the shape. */ private transient Paint fillPaint; /** * The fill paint transformer (used if the fillPaint is an instance of * GradientPaint). * * @since 1.0.4 */ private GradientPaintTransformer fillPaintTransformer; /** A flag that controls whether or not the shape outline is visible. */ private boolean shapeOutlineVisible; /** The outline paint for the shape. */ private transient Paint outlinePaint; /** The outline stroke for the shape. */ private transient Stroke outlineStroke; /** * A flag that controls whether or not the line is visible - see also * shapeVisible. */ private boolean lineVisible; /** The line. */ private transient Shape line; /** The line stroke. */ private transient Stroke lineStroke; /** The line paint. */ private transient Paint linePaint; /** * Creates a new legend graphic. * * @param shape the shape (null not permitted). * @param fillPaint the fill paint (null not permitted). */ public LegendGraphic(Shape shape, Paint fillPaint) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } if (fillPaint == null) { throw new IllegalArgumentException("Null 'fillPaint' argument."); } this.shapeVisible = true; this.shape = shape; this.shapeAnchor = RectangleAnchor.CENTER; this.shapeLocation = RectangleAnchor.CENTER; this.shapeFilled = true; this.fillPaint = fillPaint; this.fillPaintTransformer = new StandardGradientPaintTransformer(); setPadding(2.0, 2.0, 2.0, 2.0); } /** * Returns a flag that controls whether or not the shape * is visible. * * @return A boolean. * * @see #setShapeVisible(boolean) */ public boolean isShapeVisible() { return this.shapeVisible; } /** * Sets a flag that controls whether or not the shape is * visible. * * @param visible the flag. * * @see #isShapeVisible() */ public void setShapeVisible(boolean visible) { this.shapeVisible = visible; } /** * Returns the shape. * * @return The shape. * * @see #setShape(Shape) */ public Shape getShape() { return this.shape; } /** * Sets the shape. * * @param shape the shape. * * @see #getShape() */ public void setShape(Shape shape) { this.shape = shape; } /** * Returns a flag that controls whether or not the shapes * are filled. * * @return A boolean. * * @see #setShapeFilled(boolean) */ public boolean isShapeFilled() { return this.shapeFilled; } /** * Sets a flag that controls whether or not the shape is * filled. * * @param filled the flag. * * @see #isShapeFilled() */ public void setShapeFilled(boolean filled) { this.shapeFilled = filled; } /** * Returns the paint used to fill the shape. * * @return The fill paint. * * @see #setFillPaint(Paint) */ public Paint getFillPaint() { return this.fillPaint; } /** * Sets the paint used to fill the shape. * * @param paint the paint. * * @see #getFillPaint() */ public void setFillPaint(Paint paint) { this.fillPaint = paint; } /** * Returns the transformer used when the fill paint is an instance of * GradientPaint. * * @return The transformer (never null). * * @since 1.0.4. * * @see #setFillPaintTransformer(GradientPaintTransformer) */ public GradientPaintTransformer getFillPaintTransformer() { return this.fillPaintTransformer; } /** * Sets the transformer used when the fill paint is an instance of * GradientPaint. * * @param transformer the transformer (null not permitted). * * @since 1.0.4 * * @see #getFillPaintTransformer() */ public void setFillPaintTransformer(GradientPaintTransformer transformer) { if (transformer == null) { throw new IllegalArgumentException("Null 'transformer' argument."); } this.fillPaintTransformer = transformer; } /** * Returns a flag that controls whether the shape outline is visible. * * @return A boolean. * * @see #setShapeOutlineVisible(boolean) */ public boolean isShapeOutlineVisible() { return this.shapeOutlineVisible; } /** * Sets a flag that controls whether or not the shape outline * is visible. * * @param visible the flag. * * @see #isShapeOutlineVisible() */ public void setShapeOutlineVisible(boolean visible) { this.shapeOutlineVisible = visible; } /** * Returns the outline paint. * * @return The paint. * * @see #setOutlinePaint(Paint) */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint. * * @param paint the paint. * * @see #getOutlinePaint() */ public void setOutlinePaint(Paint paint) { this.outlinePaint = paint; } /** * Returns the outline stroke. * * @return The stroke. * * @see #setOutlineStroke(Stroke) */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Sets the outline stroke. * * @param stroke the stroke. * * @see #getOutlineStroke() */ public void setOutlineStroke(Stroke stroke) { this.outlineStroke = stroke; } /** * Returns the shape anchor. * * @return The shape anchor. * * @see #getShapeAnchor() */ public RectangleAnchor getShapeAnchor() { return this.shapeAnchor; } /** * Sets the shape anchor. This defines a point on the shapes bounding * rectangle that will be used to align the shape to a location. * * @param anchor the anchor (null not permitted). * * @see #setShapeAnchor(RectangleAnchor) */ public void setShapeAnchor(RectangleAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.shapeAnchor = anchor; } /** * Returns the shape location. * * @return The shape location. * * @see #setShapeLocation(RectangleAnchor) */ public RectangleAnchor getShapeLocation() { return this.shapeLocation; } /** * Sets the shape location. This defines a point within the drawing * area that will be used to align the shape to. * * @param location the location (null not permitted). * * @see #getShapeLocation() */ public void setShapeLocation(RectangleAnchor location) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } this.shapeLocation = location; } /** * Returns the flag that controls whether or not the line is visible. * * @return A boolean. * * @see #setLineVisible(boolean) */ public boolean isLineVisible() { return this.lineVisible; } /** * Sets the flag that controls whether or not the line is visible. * * @param visible the flag. * * @see #isLineVisible() */ public void setLineVisible(boolean visible) { this.lineVisible = visible; } /** * Returns the line centered about (0, 0). * * @return The line. * * @see #setLine(Shape) */ public Shape getLine() { return this.line; } /** * Sets the line. A Shape is used here, because then you can use Line2D, * GeneralPath or any other Shape to represent the line. * * @param line the line. * * @see #getLine() */ public void setLine(Shape line) { this.line = line; } /** * Returns the line paint. * * @return The paint. * * @see #setLinePaint(Paint) */ public Paint getLinePaint() { return this.linePaint; } /** * Sets the line paint. * * @param paint the paint. * * @see #getLinePaint() */ public void setLinePaint(Paint paint) { this.linePaint = paint; } /** * Returns the line stroke. * * @return The stroke. * * @see #setLineStroke(Stroke) */ public Stroke getLineStroke() { return this.lineStroke; } /** * Sets the line stroke. * * @param stroke the stroke. * * @see #getLineStroke() */ public void setLineStroke(Stroke stroke) { this.lineStroke = stroke; } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint contentConstraint = toContentConstraint(constraint); LengthConstraintType w = contentConstraint.getWidthConstraintType(); LengthConstraintType h = contentConstraint.getHeightConstraintType(); Size2D contentSize = null; if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeNN(g2); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { contentSize = new Size2D( contentConstraint.getWidth(), contentConstraint.getHeight() ); } } return new Size2D( calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight()) ); } /** * Performs the layout with no constraint, so the content size is * determined by the bounds of the shape and/or line drawn to represent * the series. * * @param g2 the graphics device. * * @return The content size. */ protected Size2D arrangeNN(Graphics2D g2) { Rectangle2D contentSize = new Rectangle2D.Double(); if (this.line != null) { contentSize.setRect(this.line.getBounds2D()); } if (this.shape != null) { contentSize = contentSize.createUnion(this.shape.getBounds2D()); } return new Size2D(contentSize.getWidth(), contentSize.getHeight()); } /** * Draws the graphic item within the specified area. * * @param g2 the graphics device. * @param area the area. */ public void draw(Graphics2D g2, Rectangle2D area) { area = trimMargin(area); drawBorder(g2, area); area = trimBorder(area); area = trimPadding(area); if (this.lineVisible) { Point2D location = RectangleAnchor.coordinates(area, this.shapeLocation); Shape aLine = ShapeUtilities.createTranslatedShape(getLine(), this.shapeAnchor, location.getX(), location.getY()); g2.setPaint(this.linePaint); g2.setStroke(this.lineStroke); g2.draw(aLine); } if (this.shapeVisible) { Point2D location = RectangleAnchor.coordinates(area, this.shapeLocation); Shape s = ShapeUtilities.createTranslatedShape(this.shape, this.shapeAnchor, location.getX(), location.getY()); if (this.shapeFilled) { Paint p = this.fillPaint; if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) this.fillPaint; p = this.fillPaintTransformer.transform(gp, s); } g2.setPaint(p); g2.fill(s); } if (this.shapeOutlineVisible) { g2.setPaint(this.outlinePaint); g2.setStroke(this.outlineStroke); g2.draw(s); } } } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return Always null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { draw(g2, area); return null; } /** * Tests this LegendGraphic instance for equality with an * arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (!(obj instanceof LegendGraphic)) { return false; } LegendGraphic that = (LegendGraphic) obj; if (this.shapeVisible != that.shapeVisible) { return false; } if (!ShapeUtilities.equal(this.shape, that.shape)) { return false; } if (this.shapeFilled != that.shapeFilled) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } if (!ObjectUtilities.equal(this.fillPaintTransformer, that.fillPaintTransformer)) { return false; } if (this.shapeOutlineVisible != that.shapeOutlineVisible) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { return false; } if (this.shapeAnchor != that.shapeAnchor) { return false; } if (this.shapeLocation != that.shapeLocation) { return false; } if (this.lineVisible != that.lineVisible) { return false; } if (!ShapeUtilities.equal(this.line, that.line)) { return false; } if (!PaintUtilities.equal(this.linePaint, that.linePaint)) { return false; } if (!ObjectUtilities.equal(this.lineStroke, that.lineStroke)) { return false; } return super.equals(obj); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * result + ObjectUtilities.hashCode(this.fillPaint); // FIXME: use other fields too return result; } /** * Returns a clone of this LegendGraphic instance. * * @return A clone of this LegendGraphic instance. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { LegendGraphic clone = (LegendGraphic) super.clone(); clone.shape = ShapeUtilities.clone(this.shape); clone.line = ShapeUtilities.clone(this.line); return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.shape, stream); SerialUtilities.writePaint(this.fillPaint, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writeShape(this.line, stream); SerialUtilities.writePaint(this.linePaint, stream); SerialUtilities.writeStroke(this.lineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.shape = SerialUtilities.readShape(stream); this.fillPaint = SerialUtilities.readPaint(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); this.line = SerialUtilities.readShape(stream); this.linePaint = SerialUtilities.readPaint(stream); this.lineStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/LegendItemBlockContainer.java0000644000175000017500000001542511173030414031257 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * LegendItemBlockContainer.java * ----------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jul-2006 : Version 1 (DG); * 06-Oct-2006 : Added tooltip and URL text fields (DG); * 18-May-2007 : Added seriesKey and dataset fields (DG); * */ package org.jfree.chart.title; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.geom.Rectangle2D; import org.jfree.chart.block.Arrangement; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.BlockResult; import org.jfree.chart.block.EntityBlockParams; import org.jfree.chart.block.EntityBlockResult; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.LegendItemEntity; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.data.general.Dataset; /** * A container that holds all the pieces of a single legend item. * * @since 1.0.2 */ public class LegendItemBlockContainer extends BlockContainer { /** * The dataset. * * @since 1.0.6 */ private Dataset dataset; /** * The series key. * * @since 1.0.6 */ private Comparable seriesKey; /** The dataset index. */ private int datasetIndex; /** The series index. */ private int series; /** The tool tip text (can be null). */ private String toolTipText; /** The URL text (can be null). */ private String urlText; /** * Creates a new legend item block. * * @param arrangement the arrangement. * @param datasetIndex the dataset index. * @param series the series index. * * @deprecated As of 1.0.6, use the other constructor. */ public LegendItemBlockContainer(Arrangement arrangement, int datasetIndex, int series) { super(arrangement); this.datasetIndex = datasetIndex; this.series = series; } /** * Creates a new legend item block. * * @param arrangement the arrangement. * @param dataset the dataset. * @param seriesKey the series key. * * @since 1.0.6 */ public LegendItemBlockContainer(Arrangement arrangement, Dataset dataset, Comparable seriesKey) { super(arrangement); this.dataset = dataset; this.seriesKey = seriesKey; } /** * Returns a reference to the dataset for the associated legend item. * * @return A dataset reference. * * @since 1.0.6 */ public Dataset getDataset() { return this.dataset; } /** * Returns the series key. * * @return The series key. * * @since 1.0.6 */ public Comparable getSeriesKey() { return this.seriesKey; } /** * Returns the dataset index. * * @return The dataset index. * * @deprecated As of 1.0.6, use the {@link #getDataset()} method. */ public int getDatasetIndex() { return this.datasetIndex; } /** * Returns the series index. * * @return The series index. */ public int getSeriesIndex() { return this.series; } /** * Returns the tool tip text. * * @return The tool tip text (possibly null). * * @since 1.0.3 */ public String getToolTipText() { return this.toolTipText; } /** * Sets the tool tip text. * * @param text the text (null permitted). * * @since 1.0.3 */ public void setToolTipText(String text) { this.toolTipText = text; } /** * Returns the URL text. * * @return The URL text (possibly null). * * @since 1.0.3 */ public String getURLText() { return this.urlText; } /** * Sets the URL text. * * @param text the text (null permitted). * * @since 1.0.3 */ public void setURLText(String text) { this.urlText = text; } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params passed on to blocks within the container * (null permitted). * * @return An instance of {@link EntityBlockResult}, or null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { // draw the block without collecting entities super.draw(g2, area, null); EntityBlockParams ebp = null; BlockResult r = new BlockResult(); if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { EntityCollection ec = new StandardEntityCollection(); LegendItemEntity entity = new LegendItemEntity( (Shape) area.clone()); entity.setSeriesIndex(this.series); entity.setSeriesKey(this.seriesKey); entity.setDataset(this.dataset); entity.setToolTipText(getToolTipText()); entity.setURLText(getURLText()); ec.add(entity); r.setEntityCollection(ec); } } return r; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/LegendTitle.java0000644000175000017500000005355711173030414026634 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * LegendTitle.java * ---------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Pierre-Marie Le Biot; * * Changes * ------- * 25-Nov-2004 : First working version (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 08-Feb-2005 : Updated for changes in RectangleConstraint class (DG); * 11-Feb-2005 : Implemented PublicCloneable (DG); * 23-Feb-2005 : Replaced chart reference with LegendItemSource (DG); * 16-Mar-2005 : Added itemFont attribute (DG); * 17-Mar-2005 : Fixed missing fillShape setting (DG); * 20-Apr-2005 : Added new draw() method (DG); * 03-May-2005 : Modified equals() method to ignore sources (DG); * 13-May-2005 : Added settings for legend item label and graphic padding (DG); * 09-Jun-2005 : Fixed serialization bug (DG); * 01-Sep-2005 : Added itemPaint attribute (PMLB); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Use new LegendItemBlockContainer to restore support for * LegendItemEntities (DG); * 06-Oct-2006 : Add tooltip and URL text to legend item (DG); * 13-Dec-2006 : Added support for GradientPaint in legend items (DG); * 16-Mar-2007 : Updated border drawing for changes in AbstractBlock (DG); * 18-May-2007 : Pass seriesKey and dataset to legend item block (DG); * 15-Aug-2008 : Added getWrapper() method (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart.title; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.LegendItemSource; import org.jfree.chart.block.Arrangement; import org.jfree.chart.block.Block; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.BlockFrame; import org.jfree.chart.block.BlockResult; import org.jfree.chart.block.BorderArrangement; import org.jfree.chart.block.CenterArrangement; import org.jfree.chart.block.ColumnArrangement; import org.jfree.chart.block.EntityBlockParams; import org.jfree.chart.block.FlowArrangement; import org.jfree.chart.block.LabelBlock; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.chart.entity.TitleEntity; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A chart title that displays a legend for the data in the chart. *

* The title can be populated with legend items manually, or you can assign a * reference to the plot, in which case the legend items will be automatically * created to match the dataset(s). */ public class LegendTitle extends Title implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2644010518533854633L; /** The default item font. */ public static final Font DEFAULT_ITEM_FONT = new Font("SansSerif", Font.PLAIN, 12); /** The default item paint. */ public static final Paint DEFAULT_ITEM_PAINT = Color.black; /** The sources for legend items. */ private LegendItemSource[] sources; /** The background paint (possibly null). */ private transient Paint backgroundPaint; /** The edge for the legend item graphic relative to the text. */ private RectangleEdge legendItemGraphicEdge; /** The anchor point for the legend item graphic. */ private RectangleAnchor legendItemGraphicAnchor; /** The legend item graphic location. */ private RectangleAnchor legendItemGraphicLocation; /** The padding for the legend item graphic. */ private RectangleInsets legendItemGraphicPadding; /** The item font. */ private Font itemFont; /** The item paint. */ private transient Paint itemPaint; /** The padding for the item labels. */ private RectangleInsets itemLabelPadding; /** * A container that holds and displays the legend items. */ private BlockContainer items; /** * The layout for the legend when it is positioned at the top or bottom * of the chart. */ private Arrangement hLayout; /** * The layout for the legend when it is positioned at the left or right * of the chart. */ private Arrangement vLayout; /** * An optional container for wrapping the legend items (allows for adding * a title or other text to the legend). */ private BlockContainer wrapper; /** * Constructs a new (empty) legend for the specified source. * * @param source the source. */ public LegendTitle(LegendItemSource source) { this(source, new FlowArrangement(), new ColumnArrangement()); } /** * Creates a new legend title with the specified arrangement. * * @param source the source. * @param hLayout the horizontal item arrangement (null not * permitted). * @param vLayout the vertical item arrangement (null not * permitted). */ public LegendTitle(LegendItemSource source, Arrangement hLayout, Arrangement vLayout) { this.sources = new LegendItemSource[] {source}; this.items = new BlockContainer(hLayout); this.hLayout = hLayout; this.vLayout = vLayout; this.backgroundPaint = null; this.legendItemGraphicEdge = RectangleEdge.LEFT; this.legendItemGraphicAnchor = RectangleAnchor.CENTER; this.legendItemGraphicLocation = RectangleAnchor.CENTER; this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0); this.itemFont = DEFAULT_ITEM_FONT; this.itemPaint = DEFAULT_ITEM_PAINT; this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0); } /** * Returns the legend item sources. * * @return The sources. */ public LegendItemSource[] getSources() { return this.sources; } /** * Sets the legend item sources and sends a {@link TitleChangeEvent} to * all registered listeners. * * @param sources the sources (null not permitted). */ public void setSources(LegendItemSource[] sources) { if (sources == null) { throw new IllegalArgumentException("Null 'sources' argument."); } this.sources = sources; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the background paint. * * @return The background paint (possibly null). */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint for the legend and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). */ public void setBackgroundPaint(Paint paint) { this.backgroundPaint = paint; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the location of the shape within each legend item. * * @return The location (never null). */ public RectangleEdge getLegendItemGraphicEdge() { return this.legendItemGraphicEdge; } /** * Sets the location of the shape within each legend item. * * @param edge the edge (null not permitted). */ public void setLegendItemGraphicEdge(RectangleEdge edge) { if (edge == null) { throw new IllegalArgumentException("Null 'edge' argument."); } this.legendItemGraphicEdge = edge; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the legend item graphic anchor. * * @return The graphic anchor (never null). */ public RectangleAnchor getLegendItemGraphicAnchor() { return this.legendItemGraphicAnchor; } /** * Sets the anchor point used for the graphic in each legend item. * * @param anchor the anchor point (null not permitted). */ public void setLegendItemGraphicAnchor(RectangleAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' point."); } this.legendItemGraphicAnchor = anchor; } /** * Returns the legend item graphic location. * * @return The location (never null). */ public RectangleAnchor getLegendItemGraphicLocation() { return this.legendItemGraphicLocation; } /** * Sets the legend item graphic location. * * @param anchor the anchor (null not permitted). */ public void setLegendItemGraphicLocation(RectangleAnchor anchor) { this.legendItemGraphicLocation = anchor; } /** * Returns the padding that will be applied to each item graphic. * * @return The padding (never null). */ public RectangleInsets getLegendItemGraphicPadding() { return this.legendItemGraphicPadding; } /** * Sets the padding that will be applied to each item graphic in the * legend and sends a {@link TitleChangeEvent} to all registered listeners. * * @param padding the padding (null not permitted). */ public void setLegendItemGraphicPadding(RectangleInsets padding) { if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } this.legendItemGraphicPadding = padding; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the item font. * * @return The font (never null). */ public Font getItemFont() { return this.itemFont; } /** * Sets the item font and sends a {@link TitleChangeEvent} to * all registered listeners. * * @param font the font (null not permitted). */ public void setItemFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.itemFont = font; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the item paint. * * @return The paint (never null). */ public Paint getItemPaint() { return this.itemPaint; } /** * Sets the item paint. * * @param paint the paint (null not permitted). */ public void setItemPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.itemPaint = paint; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the padding used for the items labels. * * @return The padding (never null). */ public RectangleInsets getItemLabelPadding() { return this.itemLabelPadding; } /** * Sets the padding used for the item labels in the legend. * * @param padding the padding (null not permitted). */ public void setItemLabelPadding(RectangleInsets padding) { if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } this.itemLabelPadding = padding; notifyListeners(new TitleChangeEvent(this)); } /** * Fetches the latest legend items. */ protected void fetchLegendItems() { this.items.clear(); RectangleEdge p = getPosition(); if (RectangleEdge.isTopOrBottom(p)) { this.items.setArrangement(this.hLayout); } else { this.items.setArrangement(this.vLayout); } for (int s = 0; s < this.sources.length; s++) { LegendItemCollection legendItems = this.sources[s].getLegendItems(); if (legendItems != null) { for (int i = 0; i < legendItems.getItemCount(); i++) { LegendItem item = legendItems.get(i); Block block = createLegendItemBlock(item); this.items.add(block); } } } } /** * Creates a legend item block. * * @param item the legend item. * * @return The block. */ protected Block createLegendItemBlock(LegendItem item) { BlockContainer result = null; LegendGraphic lg = new LegendGraphic(item.getShape(), item.getFillPaint()); lg.setFillPaintTransformer(item.getFillPaintTransformer()); lg.setShapeFilled(item.isShapeFilled()); lg.setLine(item.getLine()); lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getLinePaint()); lg.setLineVisible(item.isLineVisible()); lg.setShapeVisible(item.isShapeVisible()); lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); lg.setOutlinePaint(item.getOutlinePaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(this.legendItemGraphicPadding); LegendItemBlockContainer legendItem = new LegendItemBlockContainer( new BorderArrangement(), item.getDataset(), item.getSeriesKey()); lg.setShapeAnchor(getLegendItemGraphicAnchor()); lg.setShapeLocation(getLegendItemGraphicLocation()); legendItem.add(lg, this.legendItemGraphicEdge); Font textFont = item.getLabelFont(); if (textFont == null) { textFont = this.itemFont; } Paint textPaint = item.getLabelPaint(); if (textPaint == null) { textPaint = this.itemPaint; } LabelBlock labelBlock = new LabelBlock(item.getLabel(), textFont, textPaint); labelBlock.setPadding(this.itemLabelPadding); legendItem.add(labelBlock); legendItem.setToolTipText(item.getToolTipText()); legendItem.setURLText(item.getURLText()); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); return result; } /** * Returns the container that holds the legend items. * * @return The container for the legend items. */ public BlockContainer getItemContainer() { return this.items; } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { Size2D result = new Size2D(); fetchLegendItems(); if (this.items.isEmpty()) { return result; } BlockContainer container = this.wrapper; if (container == null) { container = this.items; } RectangleConstraint c = toContentConstraint(constraint); Size2D size = container.arrange(g2, c); result.height = calculateTotalHeight(size.height); result.width = calculateTotalWidth(size.width); return result; } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the available area for the title. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params ignored (null permitted). * * @return An {@link org.jfree.chart.block.EntityBlockResult} or * null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { Rectangle2D target = (Rectangle2D) area.clone(); Rectangle2D hotspot = (Rectangle2D) area.clone(); StandardEntityCollection sec = null; if (params instanceof EntityBlockParams && ((EntityBlockParams) params).getGenerateEntities()) { sec = new StandardEntityCollection(); sec.add(new TitleEntity(hotspot,this)); } target = trimMargin(target); if (this.backgroundPaint != null) { g2.setPaint(this.backgroundPaint); g2.fill(target); } BlockFrame border = getFrame(); border.draw(g2, target); border.getInsets().trim(target); BlockContainer container = this.wrapper; if (container == null) { container = this.items; } target = trimPadding(target); Object val = container.draw(g2, target, params); if (val instanceof BlockResult){ EntityCollection ec = ((BlockResult) val).getEntityCollection(); if (ec != null && sec != null){ sec.addAll(ec); ((BlockResult) val).setEntityCollection(sec); } } return val; } /** * Returns the wrapper container, if any. * * @return The wrapper container (possibly null). * * @since 1.0.11 */ public BlockContainer getWrapper() { return this.wrapper; } /** * Sets the wrapper container for the legend. * * @param wrapper the wrapper container. */ public void setWrapper(BlockContainer wrapper) { this.wrapper = wrapper; } /** * Tests this title for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LegendTitle)) { return false; } if (!super.equals(obj)) { return false; } LegendTitle that = (LegendTitle) obj; if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (this.legendItemGraphicEdge != that.legendItemGraphicEdge) { return false; } if (this.legendItemGraphicAnchor != that.legendItemGraphicAnchor) { return false; } if (this.legendItemGraphicLocation != that.legendItemGraphicLocation) { return false; } if (!this.itemFont.equals(that.itemFont)) { return false; } if (!this.itemPaint.equals(that.itemPaint)) { return false; } if (!this.hLayout.equals(that.hLayout)) { return false; } if (!this.vLayout.equals(that.vLayout)) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.backgroundPaint, stream); SerialUtilities.writePaint(this.itemPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.backgroundPaint = SerialUtilities.readPaint(stream); this.itemPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/PaintScaleLegend.java0000644000175000017500000006341011173030414027563 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * PaintScaleLegend.java * --------------------- * (C) Copyright 2007-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Peter Kolb - see patch 2686872; * * Changes * ------- * 22-Jan-2007 : Version 1 (DG); * 18-Jun-2008 : Fixed bug drawing scale with log axis (DG); * 16-Apr-2009 : Patch 2686872 implementing AxisChangeListener, and fix for * ignored stripOutlineVisible flag (DG); * */ package org.jfree.chart.title; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.event.AxisChangeListener; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.PaintScale; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.ui.Size2D; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A legend that shows a range of values and their associated colors, driven * by an underlying {@link PaintScale} implementation. * * @since 1.0.4 */ public class PaintScaleLegend extends Title implements AxisChangeListener, PublicCloneable { /** For serialization. */ static final long serialVersionUID = -1365146490993227503L; /** The paint scale (never null). */ private PaintScale scale; /** The value axis (never null). */ private ValueAxis axis; /** * The axis location (handles both orientations, never * null). */ private AxisLocation axisLocation; /** The offset between the axis and the paint strip (in Java2D units). */ private double axisOffset; /** The thickness of the paint strip (in Java2D units). */ private double stripWidth; /** * A flag that controls whether or not an outline is drawn around the * paint strip. */ private boolean stripOutlineVisible; /** The paint used to draw an outline around the paint strip. */ private transient Paint stripOutlinePaint; /** The stroke used to draw an outline around the paint strip. */ private transient Stroke stripOutlineStroke; /** The background paint (never null). */ private transient Paint backgroundPaint; /** * The number of subdivisions for the scale when rendering. * * @since 1.0.11 */ private int subdivisions; /** * Creates a new instance. * * @param scale the scale (null not permitted). * @param axis the axis (null not permitted). */ public PaintScaleLegend(PaintScale scale, ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } this.scale = scale; this.axis = axis; this.axis.addChangeListener(this); this.axisLocation = AxisLocation.BOTTOM_OR_LEFT; this.axisOffset = 0.0; this.axis.setRange(scale.getLowerBound(), scale.getUpperBound()); this.stripWidth = 15.0; this.stripOutlineVisible = true; this.stripOutlinePaint = Color.gray; this.stripOutlineStroke = new BasicStroke(0.5f); this.backgroundPaint = Color.white; this.subdivisions = 100; } /** * Returns the scale used to convert values to colors. * * @return The scale (never null). * * @see #setScale(PaintScale) */ public PaintScale getScale() { return this.scale; } /** * Sets the scale and sends a {@link TitleChangeEvent} to all registered * listeners. * * @param scale the scale (null not permitted). * * @see #getScale() */ public void setScale(PaintScale scale) { if (scale == null) { throw new IllegalArgumentException("Null 'scale' argument."); } this.scale = scale; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the axis for the paint scale. * * @return The axis (never null). * * @see #setAxis(ValueAxis) */ public ValueAxis getAxis() { return this.axis; } /** * Sets the axis for the paint scale and sends a {@link TitleChangeEvent} * to all registered listeners. * * @param axis the axis (null not permitted). * * @see #getAxis() */ public void setAxis(ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } this.axis.removeChangeListener(this); this.axis = axis; this.axis.addChangeListener(this); notifyListeners(new TitleChangeEvent(this)); } /** * Returns the axis location. * * @return The axis location (never null). * * @see #setAxisLocation(AxisLocation) */ public AxisLocation getAxisLocation() { return this.axisLocation; } /** * Sets the axis location and sends a {@link TitleChangeEvent} to all * registered listeners. * * @param location the location (null not permitted). * * @see #getAxisLocation() */ public void setAxisLocation(AxisLocation location) { if (location == null) { throw new IllegalArgumentException("Null 'location' argument."); } this.axisLocation = location; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the offset between the axis and the paint strip. * * @return The offset between the axis and the paint strip. * * @see #setAxisOffset(double) */ public double getAxisOffset() { return this.axisOffset; } /** * Sets the offset between the axis and the paint strip and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param offset the offset. */ public void setAxisOffset(double offset) { this.axisOffset = offset; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the width of the paint strip, in Java2D units. * * @return The width of the paint strip. * * @see #setStripWidth(double) */ public double getStripWidth() { return this.stripWidth; } /** * Sets the width of the paint strip and sends a {@link TitleChangeEvent} * to all registered listeners. * * @param width the width. * * @see #getStripWidth() */ public void setStripWidth(double width) { this.stripWidth = width; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the flag that controls whether or not an outline is drawn * around the paint strip. * * @return A boolean. * * @see #setStripOutlineVisible(boolean) */ public boolean isStripOutlineVisible() { return this.stripOutlineVisible; } /** * Sets the flag that controls whether or not an outline is drawn around * the paint strip, and sends a {@link TitleChangeEvent} to all registered * listeners. * * @param visible the flag. * * @see #isStripOutlineVisible() */ public void setStripOutlineVisible(boolean visible) { this.stripOutlineVisible = visible; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the paint used to draw the outline of the paint strip. * * @return The paint (never null). * * @see #setStripOutlinePaint(Paint) */ public Paint getStripOutlinePaint() { return this.stripOutlinePaint; } /** * Sets the paint used to draw the outline of the paint strip, and sends * a {@link TitleChangeEvent} to all registered listeners. * * @param paint the paint (null not permitted). * * @see #getStripOutlinePaint() */ public void setStripOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.stripOutlinePaint = paint; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the stroke used to draw the outline around the paint strip. * * @return The stroke (never null). * * @see #setStripOutlineStroke(Stroke) */ public Stroke getStripOutlineStroke() { return this.stripOutlineStroke; } /** * Sets the stroke used to draw the outline around the paint strip and * sends a {@link TitleChangeEvent} to all registered listeners. * * @param stroke the stroke (null not permitted). * * @see #getStripOutlineStroke() */ public void setStripOutlineStroke(Stroke stroke) { if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } this.stripOutlineStroke = stroke; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the background paint. * * @return The background paint. */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint and sends a {@link TitleChangeEvent} to all * registered listeners. * * @param paint the paint (null permitted). */ public void setBackgroundPaint(Paint paint) { this.backgroundPaint = paint; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the number of subdivisions used to draw the scale. * * @return The subdivision count. * * @since 1.0.11 */ public int getSubdivisionCount() { return this.subdivisions; } /** * Sets the subdivision count and sends a {@link TitleChangeEvent} to * all registered listeners. * * @param count the count. * * @since 1.0.11 */ public void setSubdivisionCount(int count) { if (count <= 0) { throw new IllegalArgumentException("Requires 'count' > 0."); } this.subdivisions = count; notifyListeners(new TitleChangeEvent(this)); } /** * Receives notification of an axis change event and responds by firing * a title change event. * * @param event the event. * * @since 1.0.13 */ public void axisChanged(AxisChangeEvent event) { if (this.axis == event.getAxis()) { notifyListeners(new TitleChangeEvent(this)); } } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint cc = toContentConstraint(constraint); LengthConstraintType w = cc.getWidthConstraintType(); LengthConstraintType h = cc.getHeightConstraintType(); Size2D contentSize = null; if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = new Size2D(getWidth(), getHeight()); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange()); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight())); } /** * Returns the content size for the title. This will reflect the fact that * a text title positioned on the left or right of a chart will be rotated * 90 degrees. * * @param g2 the graphics device. * @param widthRange the width range. * @param heightRange the height range. * * @return The content size. */ protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) { RectangleEdge position = getPosition(); if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { float maxWidth = (float) widthRange.getUpperBound(); // determine the space required for the axis AxisSpace space = this.axis.reserveSpace(g2, null, new Rectangle2D.Double(0, 0, maxWidth, 100), RectangleEdge.BOTTOM, null); return new Size2D(maxWidth, this.stripWidth + this.axisOffset + space.getTop() + space.getBottom()); } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { float maxHeight = (float) heightRange.getUpperBound(); AxisSpace space = this.axis.reserveSpace(g2, null, new Rectangle2D.Double(0, 0, 100, maxHeight), RectangleEdge.RIGHT, null); return new Size2D(this.stripWidth + this.axisOffset + space.getLeft() + space.getRight(), maxHeight); } else { throw new RuntimeException("Unrecognised position."); } } /** * Draws the legend within the specified area. * * @param g2 the graphics target (null not permitted). * @param area the drawing area (null not permitted). */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the legend within the specified area. * * @param g2 the graphics target (null not permitted). * @param area the drawing area (null not permitted). * @param params drawing parameters (ignored here). * * @return null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { Rectangle2D target = (Rectangle2D) area.clone(); target = trimMargin(target); if (this.backgroundPaint != null) { g2.setPaint(this.backgroundPaint); g2.fill(target); } getFrame().draw(g2, target); getFrame().getInsets().trim(target); target = trimPadding(target); double base = this.axis.getLowerBound(); double increment = this.axis.getRange().getLength() / this.subdivisions; Rectangle2D r = new Rectangle2D.Double(); if (RectangleEdge.isTopOrBottom(getPosition())) { RectangleEdge axisEdge = Plot.resolveRangeAxisLocation( this.axisLocation, PlotOrientation.HORIZONTAL); if (axisEdge == RectangleEdge.TOP) { for (int i = 0; i < this.subdivisions; i++) { double v = base + (i * increment); Paint p = this.scale.getPaint(v); double vv0 = this.axis.valueToJava2D(v, target, RectangleEdge.TOP); double vv1 = this.axis.valueToJava2D(v + increment, target, RectangleEdge.TOP); double ww = Math.abs(vv1 - vv0) + 1.0; r.setRect(Math.min(vv0, vv1), target.getMaxY() - this.stripWidth, ww, this.stripWidth); g2.setPaint(p); g2.fill(r); } if (isStripOutlineVisible()) { g2.setPaint(this.stripOutlinePaint); g2.setStroke(this.stripOutlineStroke); g2.draw(new Rectangle2D.Double(target.getMinX(), target.getMaxY() - this.stripWidth, target.getWidth(), this.stripWidth)); } this.axis.draw(g2, target.getMaxY() - this.stripWidth - this.axisOffset, target, target, RectangleEdge.TOP, null); } else if (axisEdge == RectangleEdge.BOTTOM) { for (int i = 0; i < this.subdivisions; i++) { double v = base + (i * increment); Paint p = this.scale.getPaint(v); double vv0 = this.axis.valueToJava2D(v, target, RectangleEdge.BOTTOM); double vv1 = this.axis.valueToJava2D(v + increment, target, RectangleEdge.BOTTOM); double ww = Math.abs(vv1 - vv0) + 1.0; r.setRect(Math.min(vv0, vv1), target.getMinY(), ww, this.stripWidth); g2.setPaint(p); g2.fill(r); } if (isStripOutlineVisible()) { g2.setPaint(this.stripOutlinePaint); g2.setStroke(this.stripOutlineStroke); g2.draw(new Rectangle2D.Double(target.getMinX(), target.getMinY(), target.getWidth(), this.stripWidth)); } this.axis.draw(g2, target.getMinY() + this.stripWidth + this.axisOffset, target, target, RectangleEdge.BOTTOM, null); } } else { RectangleEdge axisEdge = Plot.resolveRangeAxisLocation( this.axisLocation, PlotOrientation.VERTICAL); if (axisEdge == RectangleEdge.LEFT) { for (int i = 0; i < this.subdivisions; i++) { double v = base + (i * increment); Paint p = this.scale.getPaint(v); double vv0 = this.axis.valueToJava2D(v, target, RectangleEdge.LEFT); double vv1 = this.axis.valueToJava2D(v + increment, target, RectangleEdge.LEFT); double hh = Math.abs(vv1 - vv0) + 1.0; r.setRect(target.getMaxX() - this.stripWidth, Math.min(vv0, vv1), this.stripWidth, hh); g2.setPaint(p); g2.fill(r); } if (isStripOutlineVisible()) { g2.setPaint(this.stripOutlinePaint); g2.setStroke(this.stripOutlineStroke); g2.draw(new Rectangle2D.Double(target.getMaxX() - this.stripWidth, target.getMinY(), this.stripWidth, target.getHeight())); } this.axis.draw(g2, target.getMaxX() - this.stripWidth - this.axisOffset, target, target, RectangleEdge.LEFT, null); } else if (axisEdge == RectangleEdge.RIGHT) { for (int i = 0; i < this.subdivisions; i++) { double v = base + (i * increment); Paint p = this.scale.getPaint(v); double vv0 = this.axis.valueToJava2D(v, target, RectangleEdge.LEFT); double vv1 = this.axis.valueToJava2D(v + increment, target, RectangleEdge.LEFT); double hh = Math.abs(vv1 - vv0) + 1.0; r.setRect(target.getMinX(), Math.min(vv0, vv1), this.stripWidth, hh); g2.setPaint(p); g2.fill(r); } if (isStripOutlineVisible()) { g2.setPaint(this.stripOutlinePaint); g2.setStroke(this.stripOutlineStroke); g2.draw(new Rectangle2D.Double(target.getMinX(), target.getMinY(), this.stripWidth, target.getHeight())); } this.axis.draw(g2, target.getMinX() + this.stripWidth + this.axisOffset, target, target, RectangleEdge.RIGHT, null); } } return null; } /** * Tests this legend for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (!(obj instanceof PaintScaleLegend)) { return false; } PaintScaleLegend that = (PaintScaleLegend) obj; if (!this.scale.equals(that.scale)) { return false; } if (!this.axis.equals(that.axis)) { return false; } if (!this.axisLocation.equals(that.axisLocation)) { return false; } if (this.axisOffset != that.axisOffset) { return false; } if (this.stripWidth != that.stripWidth) { return false; } if (this.stripOutlineVisible != that.stripOutlineVisible) { return false; } if (!PaintUtilities.equal(this.stripOutlinePaint, that.stripOutlinePaint)) { return false; } if (!this.stripOutlineStroke.equals(that.stripOutlineStroke)) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (this.subdivisions != that.subdivisions) { return false; } return super.equals(obj); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.backgroundPaint, stream); SerialUtilities.writePaint(this.stripOutlinePaint, stream); SerialUtilities.writeStroke(this.stripOutlineStroke, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.backgroundPaint = SerialUtilities.readPaint(stream); this.stripOutlinePaint = SerialUtilities.readPaint(stream); this.stripOutlineStroke = SerialUtilities.readStroke(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/ShortTextTitle.java0000644000175000017500000002017511173030414027370 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * ShortTextTitle.java * ------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Apr-2008 : Version 1 (DG); * */ package org.jfree.chart.title; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.data.Range; import org.jfree.text.TextUtilities; import org.jfree.ui.Size2D; import org.jfree.ui.TextAnchor; /** * A text title that is only displayed if the entire text will be visible * without line wrapping. It is only intended for use with short titles - for * general purpose titles, you should use the {@link TextTitle} class. * * @since 1.0.10 * * @see TextTitle */ public class ShortTextTitle extends TextTitle { /** * Creates a new title. * * @param text the text (null not permitted). */ public ShortTextTitle(String text) { setText(text); } /** * Performs a layout for this title, subject to the supplied constraint, * and returns the dimensions required for the title (if the title * cannot be displayed in the available space, this method will return * zero width and height for the dimensions). * * @param g2 the graphics target. * @param constraint the layout constraints. * * @return The dimensions for the title. */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint cc = toContentConstraint(constraint); LengthConstraintType w = cc.getWidthConstraintType(); LengthConstraintType h = cc.getHeightConstraintType(); Size2D contentSize = null; if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeNN(g2); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeRN(g2, cc.getWidthRange()); } else if (h == LengthConstraintType.RANGE) { contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange()); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { contentSize = arrangeFN(g2, cc.getWidth()); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } if (contentSize.width <= 0.0 || contentSize.height <= 0.0) { return new Size2D(0.0, 0.0); } else { return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight())); } } /** * Arranges the content for this title assuming no bounds on the width * or the height, and returns the required size. * * @param g2 the graphics target. * * @return The content size. */ protected Size2D arrangeNN(Graphics2D g2) { Range max = new Range(0.0, Float.MAX_VALUE); return arrangeRR(g2, max, max); } /** * Arranges the content for this title assuming a range constraint for the * width and no bounds on the height, and returns the required size. * * @param g2 the graphics target. * @param widthRange the range for the width. * * @return The content size. */ protected Size2D arrangeRN(Graphics2D g2, Range widthRange) { Size2D s = arrangeNN(g2); if (widthRange.contains(s.getWidth())) { return s; } double ww = widthRange.constrain(s.getWidth()); return arrangeFN(g2, ww); } /** * Arranges the content for this title assuming a fixed width and no bounds * on the height, and returns the required size. This will reflect the * fact that a text title positioned on the left or right of a chart will * be rotated by 90 degrees. * * @param g2 the graphics target. * @param w the width. * * @return The content size. */ protected Size2D arrangeFN(Graphics2D g2, double w) { g2.setFont(getFont()); FontMetrics fm = g2.getFontMetrics(getFont()); Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); if (bounds.getWidth() <= w) { return new Size2D(w, bounds.getHeight()); } else { return new Size2D(0.0, 0.0); } } /** * Returns the content size for the title. * * @param g2 the graphics device. * @param widthRange the width range. * @param heightRange the height range. * * @return The content size. */ protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) { g2.setFont(getFont()); FontMetrics fm = g2.getFontMetrics(getFont()); Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); if (bounds.getWidth() <= widthRange.getUpperBound() && bounds.getHeight() <= heightRange.getUpperBound()) { return new Size2D(bounds.getWidth(), bounds.getHeight()); } else { return new Size2D(0.0, 0.0); } } /** * Draws the title using the current font and paint. * * @param g2 the graphics target. * @param area the title area. * @param params optional parameters (ignored here). * * @return null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { if (area.isEmpty()) { return null; } area = trimMargin(area); drawBorder(g2, area); area = trimBorder(area); area = trimPadding(area); g2.setFont(getFont()); g2.setPaint(getPaint()); TextUtilities.drawAlignedString(getText(), g2, (float) area.getMinX(), (float) area.getMinY(), TextAnchor.TOP_LEFT); return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/TextTitle.java0000644000175000017500000010135411173030414026347 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * TextTitle.java * -------------- * (C) Copyright 2000-2009, by David Berry and Contributors. * * Original Author: David Berry; * Contributor(s): David Gilbert (for Object Refinery Limited); * Nicolas Brodu; * Peter Kolb - patch 2603321; * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header (DG); * 07-Nov-2001 : Separated the JCommon Class Library classes, JFreeChart now * requires jcommon.jar (DG); * 09-Jan-2002 : Updated Javadoc comments (DG); * 07-Feb-2002 : Changed Insets --> Spacer in AbstractTitle.java (DG); * 06-Mar-2002 : Updated import statements (DG); * 25-Jun-2002 : Removed redundant imports (DG); * 18-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 28-Oct-2002 : Small modifications while changing JFreeChart class (DG); * 13-Mar-2003 : Changed width used for relative spacing to fix bug 703050 (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 15-Jul-2003 : Fixed null pointer exception (DG); * 11-Sep-2003 : Implemented Cloneable (NB) * 22-Sep-2003 : Added checks for null values and throw nullpointer * exceptions (TM); * Background paint was not serialized. * 07-Oct-2003 : Added fix for exception caused by empty string in title (DG); * 29-Oct-2003 : Added workaround for text alignment in PDF output (DG); * 03-Feb-2004 : Fixed bug in getPreferredWidth() method (DG); * 17-Feb-2004 : Added clone() method and fixed bug in equals() method (DG); * 01-Apr-2004 : Changed java.awt.geom.Dimension2D to org.jfree.ui.Size2D * because of JDK bug 4976448 which persists on JDK 1.3.1. Also * fixed bug in getPreferredHeight() method (DG); * 29-Apr-2004 : Fixed bug in getPreferredWidth() method - see bug id * 944173 (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 08-Feb-2005 : Updated for changes in RectangleConstraint class (DG); * 11-Feb-2005 : Implemented PublicCloneable (DG); * 20-Apr-2005 : Added support for tooltips (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 06-Jun-2005 : Modified equals() to handle GradientPaint (DG); * 06-Jul-2005 : Added flag to control whether or not the title expands to * fit the available space (DG); * 07-Oct-2005 : Added textAlignment attribute (DG); * ------------- JFREECHART 1.0.x RELEASED ------------------------------------ * 13-Dec-2005 : Fixed bug 1379331 - incorrect drawing with LEFT or RIGHT * title placement (DG); * 19-Dec-2007 : Implemented some of the missing arrangement options (DG); * 28-Apr-2008 : Added option for maximum lines, and fixed minor bugs in * equals() method (DG); * 19-Mar-2009 : Changed ChartEntity to TitleEntity - see patch 2603321 by * Peter Kolb (DG); * */ package org.jfree.chart.title; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.block.BlockResult; import org.jfree.chart.block.EntityBlockParams; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.chart.entity.TitleEntity; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.text.G2TextMeasurer; import org.jfree.text.TextBlock; import org.jfree.text.TextBlockAnchor; import org.jfree.text.TextUtilities; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.ui.VerticalAlignment; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A chart title that displays a text string with automatic wrapping as * required. */ public class TextTitle extends Title implements Serializable, Cloneable, PublicCloneable { /** For serialization. */ private static final long serialVersionUID = 8372008692127477443L; /** The default font. */ public static final Font DEFAULT_FONT = new Font("SansSerif", Font.BOLD, 12); /** The default text color. */ public static final Paint DEFAULT_TEXT_PAINT = Color.black; /** The title text. */ private String text; /** The font used to display the title. */ private Font font; /** The text alignment. */ private HorizontalAlignment textAlignment; /** The paint used to display the title text. */ private transient Paint paint; /** The background paint. */ private transient Paint backgroundPaint; /** The tool tip text (can be null). */ private String toolTipText; /** The URL text (can be null). */ private String urlText; /** The content. */ private TextBlock content; /** * A flag that controls whether the title expands to fit the available * space.. */ private boolean expandToFitSpace = false; /** * The maximum number of lines to display. * * @since 1.0.10 */ private int maximumLinesToDisplay = Integer.MAX_VALUE; /** * Creates a new title, using default attributes where necessary. */ public TextTitle() { this(""); } /** * Creates a new title, using default attributes where necessary. * * @param text the title text (null not permitted). */ public TextTitle(String text) { this(text, TextTitle.DEFAULT_FONT, TextTitle.DEFAULT_TEXT_PAINT, Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); } /** * Creates a new title, using default attributes where necessary. * * @param text the title text (null not permitted). * @param font the title font (null not permitted). */ public TextTitle(String text, Font font) { this(text, font, TextTitle.DEFAULT_TEXT_PAINT, Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); } /** * Creates a new title. * * @param text the text for the title (null not permitted). * @param font the title font (null not permitted). * @param paint the title paint (null not permitted). * @param position the title position (null not permitted). * @param horizontalAlignment the horizontal alignment (null * not permitted). * @param verticalAlignment the vertical alignment (null not * permitted). * @param padding the space to leave around the outside of the title. */ public TextTitle(String text, Font font, Paint paint, RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding) { super(position, horizontalAlignment, verticalAlignment, padding); if (text == null) { throw new NullPointerException("Null 'text' argument."); } if (font == null) { throw new NullPointerException("Null 'font' argument."); } if (paint == null) { throw new NullPointerException("Null 'paint' argument."); } this.text = text; this.font = font; this.paint = paint; // the textAlignment and the horizontalAlignment are separate things, // but it makes sense for the default textAlignment to match the // title's horizontal alignment... this.textAlignment = horizontalAlignment; this.backgroundPaint = null; this.content = null; this.toolTipText = null; this.urlText = null; } /** * Returns the title text. * * @return The text (never null). * * @see #setText(String) */ public String getText() { return this.text; } /** * Sets the title to the specified text and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param text the text (null not permitted). */ public void setText(String text) { if (text == null) { throw new IllegalArgumentException("Null 'text' argument."); } if (!this.text.equals(text)) { this.text = text; notifyListeners(new TitleChangeEvent(this)); } } /** * Returns the text alignment. This controls how the text is aligned * within the title's bounds, whereas the title's horizontal alignment * controls how the title's bounding rectangle is aligned within the * drawing space. * * @return The text alignment. */ public HorizontalAlignment getTextAlignment() { return this.textAlignment; } /** * Sets the text alignment and sends a {@link TitleChangeEvent} to * all registered listeners. * * @param alignment the alignment (null not permitted). */ public void setTextAlignment(HorizontalAlignment alignment) { if (alignment == null) { throw new IllegalArgumentException("Null 'alignment' argument."); } this.textAlignment = alignment; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the font used to display the title string. * * @return The font (never null). * * @see #setFont(Font) */ public Font getFont() { return this.font; } /** * Sets the font used to display the title string. Registered listeners * are notified that the title has been modified. * * @param font the new font (null not permitted). * * @see #getFont() */ public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } if (!this.font.equals(font)) { this.font = font; notifyListeners(new TitleChangeEvent(this)); } } /** * Returns the paint used to display the title string. * * @return The paint (never null). * * @see #setPaint(Paint) */ public Paint getPaint() { return this.paint; } /** * Sets the paint used to display the title string. Registered listeners * are notified that the title has been modified. * * @param paint the new paint (null not permitted). * * @see #getPaint() */ public void setPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (!this.paint.equals(paint)) { this.paint = paint; notifyListeners(new TitleChangeEvent(this)); } } /** * Returns the background paint. * * @return The paint (possibly null). */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the background paint and sends a {@link TitleChangeEvent} to all * registered listeners. If you set this attribute to null, * no background is painted (which makes the title background transparent). * * @param paint the background paint (null permitted). */ public void setBackgroundPaint(Paint paint) { this.backgroundPaint = paint; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the tool tip text. * * @return The tool tip text (possibly null). */ public String getToolTipText() { return this.toolTipText; } /** * Sets the tool tip text to the specified text and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param text the text (null permitted). */ public void setToolTipText(String text) { this.toolTipText = text; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the URL text. * * @return The URL text (possibly null). */ public String getURLText() { return this.urlText; } /** * Sets the URL text to the specified text and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param text the text (null permitted). */ public void setURLText(String text) { this.urlText = text; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the flag that controls whether or not the title expands to fit * the available space. * * @return The flag. */ public boolean getExpandToFitSpace() { return this.expandToFitSpace; } /** * Sets the flag that controls whether the title expands to fit the * available space, and sends a {@link TitleChangeEvent} to all registered * listeners. * * @param expand the flag. */ public void setExpandToFitSpace(boolean expand) { this.expandToFitSpace = expand; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the maximum number of lines to display. * * @return The maximum. * * @since 1.0.10 * * @see #setMaximumLinesToDisplay(int) */ public int getMaximumLinesToDisplay() { return this.maximumLinesToDisplay; } /** * Sets the maximum number of lines to display and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param max the maximum. * * @since 1.0.10. * * @see #getMaximumLinesToDisplay() */ public void setMaximumLinesToDisplay(int max) { this.maximumLinesToDisplay = max; notifyListeners(new TitleChangeEvent(this)); } /** * Arranges the contents of the block, within the given constraints, and * returns the block size. * * @param g2 the graphics device. * @param constraint the constraint (null not permitted). * * @return The block size (in Java2D units, never null). */ public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { RectangleConstraint cc = toContentConstraint(constraint); LengthConstraintType w = cc.getWidthConstraintType(); LengthConstraintType h = cc.getHeightConstraintType(); Size2D contentSize = null; if (w == LengthConstraintType.NONE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeNN(g2); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.RANGE) { if (h == LengthConstraintType.NONE) { contentSize = arrangeRN(g2, cc.getWidthRange()); } else if (h == LengthConstraintType.RANGE) { contentSize = arrangeRR(g2, cc.getWidthRange(), cc.getHeightRange()); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } else if (w == LengthConstraintType.FIXED) { if (h == LengthConstraintType.NONE) { contentSize = arrangeFN(g2, cc.getWidth()); } else if (h == LengthConstraintType.RANGE) { throw new RuntimeException("Not yet implemented."); } else if (h == LengthConstraintType.FIXED) { throw new RuntimeException("Not yet implemented."); } } return new Size2D(calculateTotalWidth(contentSize.getWidth()), calculateTotalHeight(contentSize.getHeight())); } /** * Arranges the content for this title assuming no bounds on the width * or the height, and returns the required size. This will reflect the * fact that a text title positioned on the left or right of a chart will * be rotated by 90 degrees. * * @param g2 the graphics target. * * @return The content size. * * @since 1.0.9 */ protected Size2D arrangeNN(Graphics2D g2) { Range max = new Range(0.0, Float.MAX_VALUE); return arrangeRR(g2, max, max); } /** * Arranges the content for this title assuming a fixed width and no bounds * on the height, and returns the required size. This will reflect the * fact that a text title positioned on the left or right of a chart will * be rotated by 90 degrees. * * @param g2 the graphics target. * @param w the width. * * @return The content size. * * @since 1.0.9 */ protected Size2D arrangeFN(Graphics2D g2, double w) { RectangleEdge position = getPosition(); if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { float maxWidth = (float) w; g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); if (this.expandToFitSpace) { return new Size2D(maxWidth, contentSize.getHeight()); } else { return contentSize; } } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { float maxWidth = Float.MAX_VALUE; g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); // transpose the dimensions, because the title is rotated if (this.expandToFitSpace) { return new Size2D(contentSize.getHeight(), maxWidth); } else { return new Size2D(contentSize.height, contentSize.width); } } else { throw new RuntimeException("Unrecognised exception."); } } /** * Arranges the content for this title assuming a range constraint for the * width and no bounds on the height, and returns the required size. This * will reflect the fact that a text title positioned on the left or right * of a chart will be rotated by 90 degrees. * * @param g2 the graphics target. * @param widthRange the range for the width. * * @return The content size. * * @since 1.0.9 */ protected Size2D arrangeRN(Graphics2D g2, Range widthRange) { Size2D s = arrangeNN(g2); if (widthRange.contains(s.getWidth())) { return s; } double ww = widthRange.constrain(s.getWidth()); return arrangeFN(g2, ww); } /** * Returns the content size for the title. This will reflect the fact that * a text title positioned on the left or right of a chart will be rotated * 90 degrees. * * @param g2 the graphics device. * @param widthRange the width range. * @param heightRange the height range. * * @return The content size. */ protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange) { RectangleEdge position = getPosition(); if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { float maxWidth = (float) widthRange.getUpperBound(); g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); if (this.expandToFitSpace) { return new Size2D(maxWidth, contentSize.getHeight()); } else { return contentSize; } } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { float maxWidth = (float) heightRange.getUpperBound(); g2.setFont(this.font); this.content = TextUtilities.createTextBlock(this.text, this.font, this.paint, maxWidth, this.maximumLinesToDisplay, new G2TextMeasurer(g2)); this.content.setLineAlignment(this.textAlignment); Size2D contentSize = this.content.calculateDimensions(g2); // transpose the dimensions, because the title is rotated if (this.expandToFitSpace) { return new Size2D(contentSize.getHeight(), maxWidth); } else { return new Size2D(contentSize.height, contentSize.width); } } else { throw new RuntimeException("Unrecognised exception."); } } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area allocated for the title. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null); } /** * Draws the block within the specified area. * * @param g2 the graphics device. * @param area the area. * @param params if this is an instance of {@link EntityBlockParams} it * is used to determine whether or not an * {@link EntityCollection} is returned by this method. * * @return An {@link EntityCollection} containing a chart entity for the * title, or null. */ public Object draw(Graphics2D g2, Rectangle2D area, Object params) { if (this.content == null) { return null; } area = trimMargin(area); drawBorder(g2, area); if (this.text.equals("")) { return null; } ChartEntity entity = null; if (params instanceof EntityBlockParams) { EntityBlockParams p = (EntityBlockParams) params; if (p.getGenerateEntities()) { entity = new TitleEntity(area, this, this.toolTipText, this.urlText); } } area = trimBorder(area); if (this.backgroundPaint != null) { g2.setPaint(this.backgroundPaint); g2.fill(area); } area = trimPadding(area); RectangleEdge position = getPosition(); if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { drawHorizontal(g2, area); } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) { drawVertical(g2, area); } BlockResult result = new BlockResult(); if (entity != null) { StandardEntityCollection sec = new StandardEntityCollection(); sec.add(entity); result.setEntityCollection(sec); } return result; } /** * Draws a the title horizontally within the specified area. This method * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw} * method. * * @param g2 the graphics device. * @param area the area for the title. */ protected void drawHorizontal(Graphics2D g2, Rectangle2D area) { Rectangle2D titleArea = (Rectangle2D) area.clone(); g2.setFont(this.font); g2.setPaint(this.paint); TextBlockAnchor anchor = null; float x = 0.0f; HorizontalAlignment horizontalAlignment = getHorizontalAlignment(); if (horizontalAlignment == HorizontalAlignment.LEFT) { x = (float) titleArea.getX(); anchor = TextBlockAnchor.TOP_LEFT; } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { x = (float) titleArea.getMaxX(); anchor = TextBlockAnchor.TOP_RIGHT; } else if (horizontalAlignment == HorizontalAlignment.CENTER) { x = (float) titleArea.getCenterX(); anchor = TextBlockAnchor.TOP_CENTER; } float y = 0.0f; RectangleEdge position = getPosition(); if (position == RectangleEdge.TOP) { y = (float) titleArea.getY(); } else if (position == RectangleEdge.BOTTOM) { y = (float) titleArea.getMaxY(); if (horizontalAlignment == HorizontalAlignment.LEFT) { anchor = TextBlockAnchor.BOTTOM_LEFT; } else if (horizontalAlignment == HorizontalAlignment.CENTER) { anchor = TextBlockAnchor.BOTTOM_CENTER; } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { anchor = TextBlockAnchor.BOTTOM_RIGHT; } } this.content.draw(g2, x, y, anchor); } /** * Draws a the title vertically within the specified area. This method * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw} * method. * * @param g2 the graphics device. * @param area the area for the title. */ protected void drawVertical(Graphics2D g2, Rectangle2D area) { Rectangle2D titleArea = (Rectangle2D) area.clone(); g2.setFont(this.font); g2.setPaint(this.paint); TextBlockAnchor anchor = null; float y = 0.0f; VerticalAlignment verticalAlignment = getVerticalAlignment(); if (verticalAlignment == VerticalAlignment.TOP) { y = (float) titleArea.getY(); anchor = TextBlockAnchor.TOP_RIGHT; } else if (verticalAlignment == VerticalAlignment.BOTTOM) { y = (float) titleArea.getMaxY(); anchor = TextBlockAnchor.TOP_LEFT; } else if (verticalAlignment == VerticalAlignment.CENTER) { y = (float) titleArea.getCenterY(); anchor = TextBlockAnchor.TOP_CENTER; } float x = 0.0f; RectangleEdge position = getPosition(); if (position == RectangleEdge.LEFT) { x = (float) titleArea.getX(); } else if (position == RectangleEdge.RIGHT) { x = (float) titleArea.getMaxX(); if (verticalAlignment == VerticalAlignment.TOP) { anchor = TextBlockAnchor.BOTTOM_RIGHT; } else if (verticalAlignment == VerticalAlignment.CENTER) { anchor = TextBlockAnchor.BOTTOM_CENTER; } else if (verticalAlignment == VerticalAlignment.BOTTOM) { anchor = TextBlockAnchor.BOTTOM_LEFT; } } this.content.draw(g2, x, y, anchor, x, y, -Math.PI / 2.0); } /** * Tests this title for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TextTitle)) { return false; } TextTitle that = (TextTitle) obj; if (!ObjectUtilities.equal(this.text, that.text)) { return false; } if (!ObjectUtilities.equal(this.font, that.font)) { return false; } if (!PaintUtilities.equal(this.paint, that.paint)) { return false; } if (this.textAlignment != that.textAlignment) { return false; } if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { return false; } if (this.maximumLinesToDisplay != that.maximumLinesToDisplay) { return false; } if (this.expandToFitSpace != that.expandToFitSpace) { return false; } if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { return false; } if (!ObjectUtilities.equal(this.urlText, that.urlText)) { return false; } return super.equals(obj); } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); result = 29 * result + (this.text != null ? this.text.hashCode() : 0); result = 29 * result + (this.font != null ? this.font.hashCode() : 0); result = 29 * result + (this.paint != null ? this.paint.hashCode() : 0); result = 29 * result + (this.backgroundPaint != null ? this.backgroundPaint.hashCode() : 0); return result; } /** * Returns a clone of this object. * * @return A clone. * * @throws CloneNotSupportedException never. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.paint, stream); SerialUtilities.writePaint(this.backgroundPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.paint = SerialUtilities.readPaint(stream); this.backgroundPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/Title.java0000644000175000017500000004016411173030414025503 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------- * Title.java * ---------- * (C) Copyright 2000-2008, by David Berry and Contributors. * * Original Author: David Berry; * Contributor(s): David Gilbert (for Object Refinery Limited); * Nicolas Brodu; * * Changes (from 21-Aug-2001) * -------------------------- * 21-Aug-2001 : Added standard header (DG); * 18-Sep-2001 : Updated header (DG); * 14-Nov-2001 : Package com.jrefinery.common.ui.* changed to * com.jrefinery.ui.* (DG); * 07-Feb-2002 : Changed blank space around title from Insets --> Spacer, to * allow for relative or absolute spacing (DG); * 25-Jun-2002 : Removed unnecessary imports (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 14-Oct-2002 : Changed the event listener storage structure (DG); * 11-Sep-2003 : Took care of listeners while cloning (NB); * 22-Sep-2003 : Spacer cannot be null. Added nullpointer checks for this (TM); * 08-Jan-2003 : Renamed AbstractTitle --> Title and moved to separate * package (DG); * 26-Oct-2004 : Refactored to implement Block interface, and removed redundant * constants (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 02-Feb-2005 : Changed Spacer --> RectangleInsets for padding (DG); * 03-May-2005 : Fixed problem in equals() method (DG); * 19-Sep-2008 : Added visibility flag (DG); * */ package org.jfree.chart.title; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.swing.event.EventListenerList; import org.jfree.chart.block.AbstractBlock; import org.jfree.chart.block.Block; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.chart.event.TitleChangeListener; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.VerticalAlignment; import org.jfree.util.ObjectUtilities; /** * The base class for all chart titles. A chart can have multiple titles, * appearing at the top, bottom, left or right of the chart. *

* Concrete implementations of this class will render text and images, and * hence do the actual work of drawing titles. */ public abstract class Title extends AbstractBlock implements Block, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6675162505277817221L; /** The default title position. */ public static final RectangleEdge DEFAULT_POSITION = RectangleEdge.TOP; /** The default horizontal alignment. */ public static final HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENT = HorizontalAlignment.CENTER; /** The default vertical alignment. */ public static final VerticalAlignment DEFAULT_VERTICAL_ALIGNMENT = VerticalAlignment.CENTER; /** Default title padding. */ public static final RectangleInsets DEFAULT_PADDING = new RectangleInsets( 1, 1, 1, 1); /** * A flag that controls whether or not the title is visible. * * @since 1.0.11 */ public boolean visible; /** The title position. */ private RectangleEdge position; /** The horizontal alignment of the title content. */ private HorizontalAlignment horizontalAlignment; /** The vertical alignment of the title content. */ private VerticalAlignment verticalAlignment; /** Storage for registered change listeners. */ private transient EventListenerList listenerList; /** * A flag that can be used to temporarily disable the listener mechanism. */ private boolean notify; /** * Creates a new title, using default attributes where necessary. */ protected Title() { this(Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); } /** * Creates a new title, using default attributes where necessary. * * @param position the position of the title (null not * permitted). * @param horizontalAlignment the horizontal alignment of the title * (null not permitted). * @param verticalAlignment the vertical alignment of the title * (null not permitted). */ protected Title(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { this(position, horizontalAlignment, verticalAlignment, Title.DEFAULT_PADDING); } /** * Creates a new title. * * @param position the position of the title (null not * permitted). * @param horizontalAlignment the horizontal alignment of the title (LEFT, * CENTER or RIGHT, null not * permitted). * @param verticalAlignment the vertical alignment of the title (TOP, * MIDDLE or BOTTOM, null not * permitted). * @param padding the amount of space to leave around the outside of the * title (null not permitted). */ protected Title(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding) { // check arguments... if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } if (horizontalAlignment == null) { throw new IllegalArgumentException( "Null 'horizontalAlignment' argument."); } if (verticalAlignment == null) { throw new IllegalArgumentException( "Null 'verticalAlignment' argument."); } if (padding == null) { throw new IllegalArgumentException("Null 'spacer' argument."); } this.visible = true; this.position = position; this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; setPadding(padding); this.listenerList = new EventListenerList(); this.notify = true; } /** * Returns a flag that controls whether or not the title should be * drawn. The default value is true. * * @return A boolean. * * @see #setVisible(boolean) * * @since 1.0.11 */ public boolean isVisible() { return this.visible; } /** * Sets a flag that controls whether or not the title should be drawn, and * sends a {@link TitleChangeEvent} to all registered listeners. * * @param visible the new flag value. * * @see #isVisible() * * @since 1.0.11 */ public void setVisible(boolean visible) { this.visible = visible; notifyListeners(new TitleChangeEvent(this)); } /** * Returns the position of the title. * * @return The title position (never null). */ public RectangleEdge getPosition() { return this.position; } /** * Sets the position for the title and sends a {@link TitleChangeEvent} to * all registered listeners. * * @param position the position (null not permitted). */ public void setPosition(RectangleEdge position) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } if (this.position != position) { this.position = position; notifyListeners(new TitleChangeEvent(this)); } } /** * Returns the horizontal alignment of the title. * * @return The horizontal alignment (never null). */ public HorizontalAlignment getHorizontalAlignment() { return this.horizontalAlignment; } /** * Sets the horizontal alignment for the title and sends a * {@link TitleChangeEvent} to all registered listeners. * * @param alignment the horizontal alignment (null not * permitted). */ public void setHorizontalAlignment(HorizontalAlignment alignment) { if (alignment == null) { throw new IllegalArgumentException("Null 'alignment' argument."); } if (this.horizontalAlignment != alignment) { this.horizontalAlignment = alignment; notifyListeners(new TitleChangeEvent(this)); } } /** * Returns the vertical alignment of the title. * * @return The vertical alignment (never null). */ public VerticalAlignment getVerticalAlignment() { return this.verticalAlignment; } /** * Sets the vertical alignment for the title, and notifies any registered * listeners of the change. * * @param alignment the new vertical alignment (TOP, MIDDLE or BOTTOM, * null not permitted). */ public void setVerticalAlignment(VerticalAlignment alignment) { if (alignment == null) { throw new IllegalArgumentException("Null 'alignment' argument."); } if (this.verticalAlignment != alignment) { this.verticalAlignment = alignment; notifyListeners(new TitleChangeEvent(this)); } } /** * Returns the flag that indicates whether or not the notification * mechanism is enabled. * * @return The flag. */ public boolean getNotify() { return this.notify; } /** * Sets the flag that indicates whether or not the notification mechanism * is enabled. There are certain situations (such as cloning) where you * want to turn notification off temporarily. * * @param flag the new value of the flag. */ public void setNotify(boolean flag) { this.notify = flag; if (flag) { notifyListeners(new TitleChangeEvent(this)); } } /** * Draws the title on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device. * @param area the area allocated for the title (subclasses should not * draw outside this area). */ public abstract void draw(Graphics2D g2, Rectangle2D area); /** * Returns a clone of the title. *

* One situation when this is useful is when editing the title properties - * you can edit a clone, and then it is easier to cancel the changes if * necessary. * * @return A clone of the title. * * @throws CloneNotSupportedException not thrown by this class, but it may * be thrown by subclasses. */ public Object clone() throws CloneNotSupportedException { Title duplicate = (Title) super.clone(); duplicate.listenerList = new EventListenerList(); // RectangleInsets is immutable => same reference in clone OK return duplicate; } /** * Registers an object for notification of changes to the title. * * @param listener the object that is being registered. */ public void addChangeListener(TitleChangeListener listener) { this.listenerList.add(TitleChangeListener.class, listener); } /** * Unregisters an object for notification of changes to the chart title. * * @param listener the object that is being unregistered. */ public void removeChangeListener(TitleChangeListener listener) { this.listenerList.remove(TitleChangeListener.class, listener); } /** * Notifies all registered listeners that the chart title has changed in * some way. * * @param event an object that contains information about the change to * the title. */ protected void notifyListeners(TitleChangeEvent event) { if (this.notify) { Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == TitleChangeListener.class) { ((TitleChangeListener) listeners[i + 1]).titleChanged( event); } } } } /** * Tests an object for equality with this title. * * @param obj the object (null not permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Title)) { return false; } Title that = (Title) obj; if (this.visible != that.visible) { return false; } if (this.position != that.position) { return false; } if (this.horizontalAlignment != that.horizontalAlignment) { return false; } if (this.verticalAlignment != that.verticalAlignment) { return false; } if (this.notify != that.notify) { return false; } return super.equals(obj); } /** * Returns a hashcode for the title. * * @return The hashcode. */ public int hashCode() { int result = 193; result = 37 * result + ObjectUtilities.hashCode(this.position); result = 37 * result + ObjectUtilities.hashCode(this.horizontalAlignment); result = 37 * result + ObjectUtilities.hashCode(this.verticalAlignment); return result; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.listenerList = new EventListenerList(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/title/package.html0000644000175000017500000000024011173030414026027 0ustar vincentvincent Classes used to display chart titles and subtitles. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/0000755000175000017500000000000011216245562023430 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/CategoryURLGenerator.java0000644000175000017500000000614011173030414030271 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CategoryURLGenerator.java * ------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Apr-2003 : Replaced reference to CategoryDataset with * KeyedValues2DDataset (DG); * 23-Apr-2003 : Switched around CategoryDataset and KeyedValues2DDataset * (again) (DG); * 13-Aug-2003 : Added clone() method (DG); * 14-Jun-2004 : Removed clone() method - classes that implement the interface * should implement the PublicCloneable interface instead, * wherever possible (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 13-Dec-2007 : Updated API docs (DG); * */ package org.jfree.chart.urls; import org.jfree.data.category.CategoryDataset; /** * A URL generator for items in a {@link CategoryDataset}. */ public interface CategoryURLGenerator { /** * Returns a URL for one item in a dataset. As a guideline, the URL * should be valid within the context of an XHTML 1.0 document. Classes * that implement this interface are responsible for correctly escaping * any text that is derived from the dataset, as this may be user-specified * and could pose a security risk. * * @param dataset the dataset. * @param series the series (zero-based index). * @param category the category. * * @return A string containing the URL. */ public String generateURL(CategoryDataset dataset, int series, int category); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/CustomCategoryURLGenerator.java0000644000175000017500000001362711173030414031474 0ustar vincentvincent/* ====================================== * JFreeChart : a free Java chart library * ====================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * CustomCategoryURLGenerator.java * ------------------------------- * (C) Copyright 2008, by Diego Pierangeli and Contributors. * * Original Author: Diego Pierangeli; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 23-Apr-2008 : Version 1, contributed by Diego Pierangeli based on * CustomXYURLGenerator by Richard Atkinson, with some * modifications by David Gilbert(DG); * */ package org.jfree.chart.urls; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.data.category.CategoryDataset; import org.jfree.util.PublicCloneable; /** * A custom URL generator. */ public class CustomCategoryURLGenerator implements CategoryURLGenerator, Cloneable, PublicCloneable, Serializable { /** Storage for the URLs. */ private ArrayList urlSeries = new ArrayList(); /** * Default constructor. */ public CustomCategoryURLGenerator() { super(); } /** * Returns the number of URL lists stored by the renderer. * * @return The list count. */ public int getListCount() { return this.urlSeries.size(); } /** * Returns the number of URLs in a given list. * * @param list the list index (zero based). * * @return The URL count. */ public int getURLCount(int list) { int result = 0; List urls = (List) this.urlSeries.get(list); if (urls != null) { result = urls.size(); } return result; } /** * Returns the URL for an item. * * @param series the series index. * @param item the item index. * * @return The URL (possibly null). */ public String getURL(int series, int item) { String result = null; if (series < getListCount()) { List urls = (List) this.urlSeries.get(series); if (urls != null) { if (item < urls.size()) { result = (String) urls.get(item); } } } return result; } /** * Generates a URL. * * @param dataset the dataset (ignored in this implementation). * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A string containing the URL (possibly null). */ public String generateURL(CategoryDataset dataset, int series, int item) { return getURL(series, item); } /** * Adds a list of URLs. * * @param urls the list of URLs (null permitted). */ public void addURLSeries(List urls) { List listToAdd = null; if (urls != null) { listToAdd = new java.util.ArrayList(urls); } this.urlSeries.add(listToAdd); } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CustomCategoryURLGenerator)) { return false; } CustomCategoryURLGenerator generator = (CustomCategoryURLGenerator) obj; int listCount = getListCount(); if (listCount != generator.getListCount()) { return false; } for (int series = 0; series < listCount; series++) { int urlCount = getURLCount(series); if (urlCount != generator.getURLCount(series)) { return false; } for (int item = 0; item < urlCount; item++) { String u1 = getURL(series, item); String u2 = generator.getURL(series, item); if (u1 != null) { if (!u1.equals(u2)) { return false; } } else { if (u2 != null) { return false; } } } } return true; } /** * Returns a new generator that is a copy of, and independent from, this * generator. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem with cloning. */ public Object clone() throws CloneNotSupportedException { CustomCategoryURLGenerator clone = (CustomCategoryURLGenerator) super.clone(); clone.urlSeries = new java.util.ArrayList(this.urlSeries); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/CustomPieURLGenerator.java0000644000175000017500000001533211173030414030427 0ustar vincentvincent/* ====================================== * JFreeChart : a free Java chart library * ====================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * CustomPieURLGenerator.java * -------------------------- * (C) Copyright 2004-2008, by David Basten and Contributors. * * Original Author: David Basten; * Contributors: -; * * Changes: * -------- * 04-Feb-2004 : Version 1, contributed by David Basten based on * CustomXYURLGenerator by Richard Atkinson (added to main source * tree on 25-May-2004); * */ package org.jfree.chart.urls; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.jfree.chart.plot.MultiplePiePlot; import org.jfree.data.general.PieDataset; import org.jfree.util.PublicCloneable; /** * A custom URL generator for pie charts. */ public class CustomPieURLGenerator implements PieURLGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7100607670144900503L; /** Storage for the URLs. */ private ArrayList urls; /** * Creates a new CustomPieURLGenerator instance, initially * empty. Call {@link #addURLs(Map)} to specify the URL fragments to be * used. */ public CustomPieURLGenerator() { this.urls = new ArrayList(); } /** * Generates a URL fragment. * * @param dataset the dataset (ignored). * @param key the item key. * @param pieIndex the pie index. * * @return A string containing the generated URL. * * @see #getURL(Comparable, int) */ public String generateURL(PieDataset dataset, Comparable key, int pieIndex) { return getURL(key, pieIndex); } /** * Returns the number of URL maps stored by the renderer. * * @return The list count. * * @see #addURLs(Map) */ public int getListCount() { return this.urls.size(); } /** * Returns the number of URLs in a given map (specified by its position * in the map list). * * @param list the list index (zero based). * * @return The URL count. * * @see #getListCount() */ public int getURLCount(int list) { int result = 0; Map urlMap = (Map) this.urls.get(list); if (urlMap != null) { result = urlMap.size(); } return result; } /** * Returns the URL for a section in the specified map. * * @param key the key. * @param mapIndex the map index. * * @return The URL. */ public String getURL(Comparable key, int mapIndex) { String result = null; if (mapIndex < getListCount()) { Map urlMap = (Map) this.urls.get(mapIndex); if (urlMap != null) { result = (String) urlMap.get(key); } } return result; } /** * Adds a map containing (key, URL) mappings where each * key is an instance of Comparable * (corresponding to the key for an item in a pie dataset) and each * URL is a String representing a URL fragment. *

* The map is appended to an internal list...you can add multiple maps * if you are working with, say, a {@link MultiplePiePlot}. * * @param urlMap the URLs (null permitted). */ public void addURLs(Map urlMap) { this.urls.add(urlMap); } /** * Tests if this object is equal to another. * * @param o the other object. * * @return A boolean. */ public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof CustomPieURLGenerator) { CustomPieURLGenerator generator = (CustomPieURLGenerator) o; if (getListCount() != generator.getListCount()) { return false; } Set keySet; for (int pieItem = 0; pieItem < getListCount(); pieItem++) { if (getURLCount(pieItem) != generator.getURLCount(pieItem)) { return false; } keySet = ((HashMap) this.urls.get(pieItem)).keySet(); String key; for (Iterator i = keySet.iterator(); i.hasNext();) { key = (String) i.next(); if (!getURL(key, pieItem).equals( generator.getURL(key, pieItem))) { return false; } } } return true; } return false; } /** * Returns a clone of the generator. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { CustomPieURLGenerator urlGen = new CustomPieURLGenerator(); Map map; Map newMap; String key; for (Iterator i = this.urls.iterator(); i.hasNext();) { map = (Map) i.next(); newMap = new HashMap(); for (Iterator j = map.keySet().iterator(); j.hasNext();) { key = (String) j.next(); newMap.put(key, map.get(key)); } urlGen.addURLs(newMap); newMap = null; } return urlGen; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/CustomXYURLGenerator.java0000644000175000017500000001447411173030414030260 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CustomXYURLGenerator.java * ------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Mar-2003 : Implemented Serializable (DG); * 20-Jan-2005 : Minor Javadoc update (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 11-Apr-2008 : Implemented Cloneable, otherwise charts using this URL * generator will fail to clone (DG); * */ package org.jfree.chart.urls; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * A custom URL generator. */ public class CustomXYURLGenerator implements XYURLGenerator, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8565933356596551832L; /** Storage for the URLs. */ private ArrayList urlSeries = new ArrayList(); /** * Default constructor. */ public CustomXYURLGenerator() { super(); } /** * Returns the number of URL lists stored by the renderer. * * @return The list count. */ public int getListCount() { return this.urlSeries.size(); } /** * Returns the number of URLs in a given list. * * @param list the list index (zero based). * * @return The URL count. */ public int getURLCount(int list) { int result = 0; List urls = (List) this.urlSeries.get(list); if (urls != null) { result = urls.size(); } return result; } /** * Returns the URL for an item. * * @param series the series index. * @param item the item index. * * @return The URL (possibly null). */ public String getURL(int series, int item) { String result = null; if (series < getListCount()) { List urls = (List) this.urlSeries.get(series); if (urls != null) { if (item < urls.size()) { result = (String) urls.get(item); } } } return result; } /** * Generates a URL. * * @param dataset the dataset. * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A string containing the URL (possibly null). */ public String generateURL(XYDataset dataset, int series, int item) { return getURL(series, item); } /** * Adds a list of URLs. * * @param urls the list of URLs (null permitted, the list * is copied). */ public void addURLSeries(List urls) { List listToAdd = null; if (urls != null) { listToAdd = new java.util.ArrayList(urls); } this.urlSeries.add(listToAdd); } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CustomXYURLGenerator)) { return false; } CustomXYURLGenerator that = (CustomXYURLGenerator) obj; int listCount = getListCount(); if (listCount != that.getListCount()) { return false; } for (int series = 0; series < listCount; series++) { int urlCount = getURLCount(series); if (urlCount != that.getURLCount(series)) { return false; } for (int item = 0; item < urlCount; item++) { String u1 = getURL(series, item); String u2 = that.getURL(series, item); if (u1 != null) { if (!u1.equals(u2)) { return false; } } else { if (u2 != null) { return false; } } } } return true; } /** * Returns a new generator that is a copy of, and independent from, this * generator. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem with cloning. */ public Object clone() throws CloneNotSupportedException { CustomXYURLGenerator clone = (CustomXYURLGenerator) super.clone(); clone.urlSeries = new java.util.ArrayList(this.urlSeries); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/PieURLGenerator.java0000644000175000017500000000631011173030414027230 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PieURLGenerator.java * -------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 07-Mar-2003 : Modified to use KeyedValuesDataset and added pieIndex * parameter (DG); * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Nov-2006 : Updated API docs (DG); * 13-Dec-2007 : Updated API docs (DG); * */ package org.jfree.chart.urls; import org.jfree.data.general.PieDataset; /** * Interface for a URL generator for plots that use data from a * {@link PieDataset}. Classes that implement this interface: *

    *
  • are responsible for correctly escaping any text that is derived from the * dataset, as this may be user-specified and could pose a security * risk;
  • *
  • should be either (a) immutable, or (b) cloneable via the * PublicCloneable interface (defined in the JCommon class * library). This provides a mechanism for the referring plot to clone * the generator if necessary.
  • *
*/ public interface PieURLGenerator { /** * Generates a URL for one item in a {@link PieDataset}. As a guideline, * the URL should be valid within the context of an XHTML 1.0 document. * * @param dataset the dataset (null not permitted). * @param key the item key (null not permitted). * @param pieIndex the pie index (differentiates between pies in a * 'multi' pie chart). * * @return A string containing the URL. */ public String generateURL(PieDataset dataset, Comparable key, int pieIndex); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/StandardCategoryURLGenerator.java0000644000175000017500000001750111173030414031755 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * StandardCategoryURLGenerator.java * --------------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * Cleland Early; * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 29-Aug-2002 : Reversed seriesParameterName and itemParameterName in * constructor. Never should have been the other way round. * Also updated JavaDoc (RA); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); * 23-Mar-2003 : Implemented Serializable (DG); * 13-Aug-2003 : Implemented Cloneable (DG); * 23-Dec-2003 : Added fix for bug 861282 (DG); * 21-May-2004 : Added URL encoding - see patch 947854 (DG); * 13-Jan-2004 : Fixed for compliance with XHTML 1.0 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 17-Apr-2007 : Use new URLUtilities class to encode URLs (DG); * */ package org.jfree.chart.urls; import java.io.Serializable; import org.jfree.data.category.CategoryDataset; import org.jfree.util.ObjectUtilities; /** * A URL generator that can be assigned to a * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. */ public class StandardCategoryURLGenerator implements CategoryURLGenerator, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2276668053074881909L; /** Prefix to the URL */ private String prefix = "index.html"; /** Series parameter name to go in each URL */ private String seriesParameterName = "series"; /** Category parameter name to go in each URL */ private String categoryParameterName = "category"; /** * Creates a new generator with default settings. */ public StandardCategoryURLGenerator() { super(); } /** * Constructor that overrides default prefix to the URL. * * @param prefix the prefix to the URL (null not permitted). */ public StandardCategoryURLGenerator(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } this.prefix = prefix; } /** * Constructor that overrides all the defaults. * * @param prefix the prefix to the URL (null not permitted). * @param seriesParameterName the name of the series parameter to go in * each URL (null not permitted). * @param categoryParameterName the name of the category parameter to go in * each URL (null not permitted). */ public StandardCategoryURLGenerator(String prefix, String seriesParameterName, String categoryParameterName) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } if (seriesParameterName == null) { throw new IllegalArgumentException( "Null 'seriesParameterName' argument."); } if (categoryParameterName == null) { throw new IllegalArgumentException( "Null 'categoryParameterName' argument."); } this.prefix = prefix; this.seriesParameterName = seriesParameterName; this.categoryParameterName = categoryParameterName; } /** * Generates a URL for a particular item within a series. * * @param dataset the dataset. * @param series the series index (zero-based). * @param category the category index (zero-based). * * @return The generated URL. */ public String generateURL(CategoryDataset dataset, int series, int category) { String url = this.prefix; Comparable seriesKey = dataset.getRowKey(series); Comparable categoryKey = dataset.getColumnKey(category); boolean firstParameter = url.indexOf("?") == -1; url += firstParameter ? "?" : "&"; url += this.seriesParameterName + "=" + URLUtilities.encode( seriesKey.toString(), "UTF-8"); url += "&" + this.categoryParameterName + "=" + URLUtilities.encode(categoryKey.toString(), "UTF-8"); return url; } /** * Returns an independent copy of the URL generator. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class, but * subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { // all attributes are immutable, so we can just return the super.clone() // FIXME: in fact, the generator itself is immutable, so cloning is // not necessary return super.clone(); } /** * Tests the generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardCategoryURLGenerator)) { return false; } StandardCategoryURLGenerator that = (StandardCategoryURLGenerator) obj; if (!ObjectUtilities.equal(this.prefix, that.prefix)) { return false; } if (!ObjectUtilities.equal(this.seriesParameterName, that.seriesParameterName)) { return false; } if (!ObjectUtilities.equal(this.categoryParameterName, that.categoryParameterName)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = (this.prefix != null ? this.prefix.hashCode() : 0); result = 29 * result + (this.seriesParameterName != null ? this.seriesParameterName.hashCode() : 0); result = 29 * result + (this.categoryParameterName != null ? this.categoryParameterName.hashCode() : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/StandardPieURLGenerator.java0000644000175000017500000001443411173030414030717 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * StandardPieURLGenerator.java * ---------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 07-Mar-2003 : Modified to use KeyedValuesDataset and added pieIndex * parameter (DG); * 21-Mar-2003 : Implemented Serializable (DG); * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); * 31-Mar-2004 : Added an optional 'pieIndex' parameter (DG); * 13-Jan-2005 : Fixed for compliance with XHTML 1.0 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-Nov-2006 : Fixed equals() method and added argument checks (DG); * 17-Apr-2007 : Encode section key in generateURL() (DG); * */ package org.jfree.chart.urls; import java.io.Serializable; import org.jfree.data.general.PieDataset; import org.jfree.util.ObjectUtilities; /** * A URL generator for pie charts. Instances of this class are immutable. */ public class StandardPieURLGenerator implements PieURLGenerator, Serializable { /** For serialization. */ private static final long serialVersionUID = 1626966402065883419L; /** The prefix. */ private String prefix = "index.html"; /** The category parameter name. */ private String categoryParameterName = "category"; /** The pie index parameter name. */ private String indexParameterName = "pieIndex"; /** * Default constructor. */ public StandardPieURLGenerator() { this("index.html"); } /** * Creates a new generator. * * @param prefix the prefix (null not permitted). */ public StandardPieURLGenerator(String prefix) { this(prefix, "category"); } /** * Creates a new generator. * * @param prefix the prefix (null not permitted). * @param categoryParameterName the category parameter name * (null not permitted). */ public StandardPieURLGenerator(String prefix, String categoryParameterName) { this(prefix, categoryParameterName, "pieIndex"); } /** * Creates a new generator. * * @param prefix the prefix (null not permitted). * @param categoryParameterName the category parameter name * (null not permitted). * @param indexParameterName the index parameter name (null * permitted). */ public StandardPieURLGenerator(String prefix, String categoryParameterName, String indexParameterName) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } if (categoryParameterName == null) { throw new IllegalArgumentException( "Null 'categoryParameterName' argument."); } this.prefix = prefix; this.categoryParameterName = categoryParameterName; this.indexParameterName = indexParameterName; } /** * Generates a URL. * * @param dataset the dataset (ignored). * @param key the item key (null not permitted). * @param pieIndex the pie index. * * @return A string containing the generated URL. */ public String generateURL(PieDataset dataset, Comparable key, int pieIndex) { String url = this.prefix; if (url.indexOf("?") > -1) { url += "&" + this.categoryParameterName + "=" + URLUtilities.encode(key.toString(), "UTF-8"); } else { url += "?" + this.categoryParameterName + "=" + URLUtilities.encode(key.toString(), "UTF-8"); } if (this.indexParameterName != null) { url += "&" + this.indexParameterName + "=" + String.valueOf(pieIndex); } return url; } /** * Tests if this object is equal to another. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardPieURLGenerator)) { return false; } StandardPieURLGenerator that = (StandardPieURLGenerator) obj; if (!this.prefix.equals(that.prefix)) { return false; } if (!this.categoryParameterName.equals(that.categoryParameterName)) { return false; } if (!ObjectUtilities.equal(this.indexParameterName, that.indexParameterName)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/StandardXYURLGenerator.java0000644000175000017500000001465611173030414030550 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StandardXYURLGenerator.java * --------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 29-Aug-2002 : New constructor and member variables to customise series and * item parameter names (RA); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Mar-2003 : Implemented Serializable (DG); * 01-Mar-2004 : Added equals() method (DG); * 13-Jan-2005 : Modified for XHTML 1.0 compliance (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.chart.urls; import java.io.Serializable; import org.jfree.data.xy.XYDataset; import org.jfree.util.ObjectUtilities; /** * A URL generator. */ public class StandardXYURLGenerator implements XYURLGenerator, Serializable { /** For serialization. */ private static final long serialVersionUID = -1771624523496595382L; /** The default prefix. */ public static final String DEFAULT_PREFIX = "index.html"; /** The default series parameter. */ public static final String DEFAULT_SERIES_PARAMETER = "series"; /** The default item parameter. */ public static final String DEFAULT_ITEM_PARAMETER = "item"; /** Prefix to the URL */ private String prefix; /** Series parameter name to go in each URL */ private String seriesParameterName; /** Item parameter name to go in each URL */ private String itemParameterName; /** * Creates a new default generator. This constructor is equivalent to * calling StandardXYURLGenerator("index.html", "series", "item"); * . */ public StandardXYURLGenerator() { this(DEFAULT_PREFIX, DEFAULT_SERIES_PARAMETER, DEFAULT_ITEM_PARAMETER); } /** * Creates a new generator with the specified prefix. This constructor * is equivalent to calling * StandardXYURLGenerator(prefix, "series", "item");. * * @param prefix the prefix to the URL (null not permitted). */ public StandardXYURLGenerator(String prefix) { this(prefix, DEFAULT_SERIES_PARAMETER, DEFAULT_ITEM_PARAMETER); } /** * Constructor that overrides all the defaults * * @param prefix the prefix to the URL (null not permitted). * @param seriesParameterName the name of the series parameter to go in * each URL (null not permitted). * @param itemParameterName the name of the item parameter to go in each * URL (null not permitted). */ public StandardXYURLGenerator(String prefix, String seriesParameterName, String itemParameterName) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } if (seriesParameterName == null) { throw new IllegalArgumentException( "Null 'seriesParameterName' argument."); } if (itemParameterName == null) { throw new IllegalArgumentException( "Null 'itemParameterName' argument."); } this.prefix = prefix; this.seriesParameterName = seriesParameterName; this.itemParameterName = itemParameterName; } /** * Generates a URL for a particular item within a series. * * @param dataset the dataset. * @param series the series number (zero-based index). * @param item the item number (zero-based index). * * @return The generated URL. */ public String generateURL(XYDataset dataset, int series, int item) { // TODO: URLEncode? String url = this.prefix; boolean firstParameter = url.indexOf("?") == -1; url += firstParameter ? "?" : "&"; url += this.seriesParameterName + "=" + series + "&" + this.itemParameterName + "=" + item; return url; } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardXYURLGenerator)) { return false; } StandardXYURLGenerator that = (StandardXYURLGenerator) obj; if (!ObjectUtilities.equal(that.prefix, this.prefix)) { return false; } if (!ObjectUtilities.equal(that.seriesParameterName, this.seriesParameterName)) { return false; } if (!ObjectUtilities.equal(that.itemParameterName, this.itemParameterName)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/StandardXYZURLGenerator.java0000644000175000017500000000425711173030414030676 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * StandardXYZURLGenerator.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributors: -; * * Changes: * -------- * 03-Feb-2003 : Version 1 (DG); * */ package org.jfree.chart.urls; import org.jfree.data.xy.XYZDataset; /** * A URL generator. */ public class StandardXYZURLGenerator extends StandardXYURLGenerator implements XYZURLGenerator { /** * Generates a URL for a particular item within a series. * * @param dataset the dataset. * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A string containing the generated URL. */ public String generateURL(XYZDataset dataset, int series, int item) { return super.generateURL(dataset, series, item); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/TimeSeriesURLGenerator.java0000644000175000017500000001671611173030414030577 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * TimeSeriesURLGenerator.java * --------------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 29-Aug-2002 : Initial version (RA); * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Mar-2003 : Implemented Serializable (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 13-Jan-2005 : Modified for XHTML 1.0 compliance (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Jul-2006 : Swap call to dataset's getX() --> getXValue() (DG); * 17-Apr-2007 : Added null argument checks to constructor, new accessor * methods, added equals() override and used new URLUtilities * class to encode series key and date (DG); * */ package org.jfree.chart.urls; import java.io.Serializable; import java.text.DateFormat; import java.util.Date; import org.jfree.data.xy.XYDataset; /** * A URL generator for time series charts. */ public class TimeSeriesURLGenerator implements XYURLGenerator, Serializable { /** For serialization. */ private static final long serialVersionUID = -9122773175671182445L; /** A formatter for the date. */ private DateFormat dateFormat = DateFormat.getInstance(); /** Prefix to the URL */ private String prefix = "index.html"; /** Name to use to identify the series */ private String seriesParameterName = "series"; /** Name to use to identify the item */ private String itemParameterName = "item"; /** * Default constructor. */ public TimeSeriesURLGenerator() { super(); } /** * Construct TimeSeriesURLGenerator overriding defaults. * * @param dateFormat a formatter for the date (null not * permitted). * @param prefix the prefix of the URL (null not permitted). * @param seriesParameterName the name of the series parameter in the URL * (null not permitted). * @param itemParameterName the name of the item parameter in the URL * (null not permitted). */ public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix, String seriesParameterName, String itemParameterName) { if (dateFormat == null) { throw new IllegalArgumentException("Null 'dateFormat' argument."); } if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } if (seriesParameterName == null) { throw new IllegalArgumentException( "Null 'seriesParameterName' argument."); } if (itemParameterName == null) { throw new IllegalArgumentException( "Null 'itemParameterName' argument."); } this.dateFormat = (DateFormat) dateFormat.clone(); this.prefix = prefix; this.seriesParameterName = seriesParameterName; this.itemParameterName = itemParameterName; } /** * Returns a clone of the date format assigned to this URL generator. * * @return The date format (never null). * * @since 1.0.6 */ public DateFormat getDateFormat() { return (DateFormat) this.dateFormat.clone(); } /** * Returns the prefix string. * * @return The prefix string (never null). * * @since 1.0.6 */ public String getPrefix() { return this.prefix; } /** * Returns the series parameter name. * * @return The series parameter name (never null). * * @since 1.0.6 */ public String getSeriesParameterName() { return this.seriesParameterName; } /** * Returns the item parameter name. * * @return The item parameter name (never null). * * @since 1.0.6 */ public String getItemParameterName() { return this.itemParameterName; } /** * Generates a URL for a particular item within a series. * * @param dataset the dataset (null not permitted). * @param series the series number (zero-based index). * @param item the item number (zero-based index). * * @return The generated URL. */ public String generateURL(XYDataset dataset, int series, int item) { String result = this.prefix; boolean firstParameter = result.indexOf("?") == -1; Comparable seriesKey = dataset.getSeriesKey(series); if (seriesKey != null) { result += firstParameter ? "?" : "&"; result += this.seriesParameterName + "=" + URLUtilities.encode( seriesKey.toString(), "UTF-8"); firstParameter = false; } long x = (long) dataset.getXValue(series, item); String xValue = this.dateFormat.format(new Date(x)); result += firstParameter ? "?" : "&"; result += this.itemParameterName + "=" + URLUtilities.encode(xValue, "UTF-8"); return result; } /** * Tests this generator for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimeSeriesURLGenerator)) { return false; } TimeSeriesURLGenerator that = (TimeSeriesURLGenerator) obj; if (!this.dateFormat.equals(that.dateFormat)) { return false; } if (!this.itemParameterName.equals(that.itemParameterName)) { return false; } if (!this.prefix.equals(that.prefix)) { return false; } if (!this.seriesParameterName.equals(that.seriesParameterName)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/URLUtilities.java0000644000175000017500000000603111173030414026617 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * URLUtilities.java * ----------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributors: -; * * Changes: * -------- * 17-Apr-2007 : Version 1 (DG); * */ package org.jfree.chart.urls; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLEncoder; /** * General utility methods for URLs. * * @since 1.0.6 */ public class URLUtilities { /** Constant used by {@link #encode(String, String)}. */ private static final Class[] STRING_ARGS_2 = new Class[] {String.class, String.class}; /** * Calls java.net.URLEncoder.encode(String, String) via * reflection, if we are running on JRE 1.4 or later, otherwise reverts to * the deprecated URLEncoder.encode(String) method. * * @param s the string to encode. * @param encoding the encoding. * * @return The encoded string. * * @since 1.0.6 */ public static String encode(String s, String encoding) { Class c = URLEncoder.class; String result = null; try { Method m = c.getDeclaredMethod("encode", STRING_ARGS_2); try { result = (String) m.invoke(null, new Object[] {s, encoding}); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } catch (NoSuchMethodException e) { // we're running on JRE 1.3.1 so this is the best we have... result = URLEncoder.encode(s); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/XYURLGenerator.java0000644000175000017500000000541411173030414027057 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * XYURLGenerator.java * ------------------- * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributors: David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 20-Jan-2005 : Minor Javadoc update (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 13-Dec-2007 : Updated API docs (DG); * */ package org.jfree.chart.urls; import org.jfree.data.xy.XYDataset; /** * Interface for a URL generator for plots that uses data from an * {@link XYDataset}. Classes that implement this interface are responsible * for correctly escaping any text that is derived from the dataset, as this * may be user-specified and could pose a security risk. */ public interface XYURLGenerator { /** * Generates a URL for a particular item within a series. As a guideline, * the URL should be valid within the context of an XHTML 1.0 document. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A string containing the generated URL (possibly * null). */ public String generateURL(XYDataset dataset, int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/XYZURLGenerator.java0000644000175000017500000000472211173030414027212 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYZURLGenerator.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributors: -; * * Changes: * -------- * 03-Feb-2003 : Version 1 (DG); * 13-Dec-2007 : Updated API docs (DG); * */ package org.jfree.chart.urls; import org.jfree.data.xy.XYZDataset; /** * Interface for a URL generator for plots that uses data from an * {@link XYZDataset}. Classes that implement this interface are responsible * for correctly escaping any text that is derived from the dataset, as this * may be user-specified and could pose a security risk. */ public interface XYZURLGenerator extends XYURLGenerator { /** * Generates a URL for a particular item within a series. As a guideline, * the URL should be valid within the context of an XHTML 1.0 document. * * @param dataset the dataset (null not permitted). * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return A string containing the generated URL. */ public String generateURL(XYZDataset dataset, int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/urls/package.html0000644000175000017500000000025511173030414025701 0ustar vincentvincent Classes for adding URLS to charts for HTML image map generation. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/0000755000175000017500000000000011216245562023420 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/HexNumberFormat.java0000644000175000017500000001144611173030414027325 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * HexNumberFormat.java * -------------------- * (C) Copyright 2007, 2008, by Richard West and Contributors. * * Original Author: Richard West, Advanced Micro Devices, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes: * -------- * 14-Jun-2007 : Version 1 (RW); * */ package org.jfree.chart.util; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; /** * A custom number formatter that formats numbers as hexadecimal strings. * There are some limitations, so be careful using this class. * * @since 1.0.6 */ public class HexNumberFormat extends NumberFormat { /** Number of hexadecimal digits for a byte. */ public static final int BYTE = 2; /** Number of hexadecimal digits for a word. */ public static final int WORD = 4; /** Number of hexadecimal digits for a double word. */ public static final int DWORD = 8; /** Number of hexadecimal digits for a quad word. */ public static final int QWORD = 16; /** The number of digits (shorter strings will be left padded). */ private int m_numDigits = DWORD; /** * Creates a new instance with 8 digits. */ public HexNumberFormat() { this(DWORD); } /** * Creates a new instance with the specified number of digits. * @param digits the digits. */ public HexNumberFormat(int digits) { super(); this.m_numDigits = digits; } /** * Returns the number of digits. * * @return The number of digits. */ public final int getNumberOfDigits() { return this.m_numDigits; } /** * Sets the number of digits. * * @param digits the number of digits. */ public void setNumberOfDigits(int digits) { this.m_numDigits = digits; } /** * Formats the specified number as a hexadecimal string. The decimal * fraction is ignored. * * @param number the number to format. * @param toAppendTo the buffer to append to (ignored here). * @param pos the field position (ignored here). * * @return The string buffer. */ public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { return format((long) number, toAppendTo, pos); } /** * Formats the specified number as a hexadecimal string. The decimal * fraction is ignored. * * @param number the number to format. * @param toAppendTo the buffer to append to (ignored here). * @param pos the field position (ignored here). * * @return The string buffer. */ public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { String l_hex = Long.toHexString(number).toUpperCase(); int l_pad = this.m_numDigits - l_hex.length(); l_pad = (0 < l_pad) ? l_pad : 0; StringBuffer l_extended = new StringBuffer("0x"); for (int i = 0; i < l_pad; i++) { l_extended.append(0); } l_extended.append(l_hex); return l_extended; } /** * Parsing is not implemented, so this method always returns * null. * * @param source ignored. * @param parsePosition ignored. * * @return Always null. */ public Number parse (String source, ParsePosition parsePosition) { return null; // don't bother with parsing } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/LineUtilities.java0000644000175000017500000001223011173030414027032 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * LineUtilities.java * ------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Nov-2008 : Version 1 (DG); * */ package org.jfree.chart.util; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; /** * Some utility methods for {@link Line2D} objects. * * @since 1.0.12 */ public class LineUtilities { /** * Clips the specified line to the given rectangle. * * @param line the line (null not permitted). * @param rect the clipping rectangle (null not permitted). * * @return true if the clipped line is visible, and * false otherwise. */ public static boolean clipLine(Line2D line, Rectangle2D rect) { double x1 = line.getX1(); double y1 = line.getY1(); double x2 = line.getX2(); double y2 = line.getY2(); double minX = rect.getMinX(); double maxX = rect.getMaxX(); double minY = rect.getMinY(); double maxY = rect.getMaxY(); int f1 = rect.outcode(x1, y1); int f2 = rect.outcode(x2, y2); while ((f1 | f2) != 0) { if ((f1 & f2) != 0) { return false; } double dx = (x2 - x1); double dy = (y2 - y1); // update (x1, y1), (x2, y2) and f1 and f2 using intersections // then recheck if (f1 != 0) { // first point is outside, so we update it against one of the // four sides then continue if ((f1 & Rectangle2D.OUT_LEFT) == Rectangle2D.OUT_LEFT && dx != 0.0) { y1 = y1 + (minX - x1) * dy / dx; x1 = minX; } else if ((f1 & Rectangle2D.OUT_RIGHT) == Rectangle2D.OUT_RIGHT && dx != 0.0) { y1 = y1 + (maxX - x1) * dy / dx; x1 = maxX; } else if ((f1 & Rectangle2D.OUT_BOTTOM) == Rectangle2D.OUT_BOTTOM && dy != 0.0) { x1 = x1 + (maxY - y1) * dx / dy; y1 = maxY; } else if ((f1 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP && dy != 0.0) { x1 = x1 + (minY - y1) * dx / dy; y1 = minY; } f1 = rect.outcode(x1, y1); } else if (f2 != 0) { // second point is outside, so we update it against one of the // four sides then continue if ((f2 & Rectangle2D.OUT_LEFT) == Rectangle2D.OUT_LEFT && dx != 0.0) { y2 = y2 + (minX - x2) * dy / dx; x2 = minX; } else if ((f2 & Rectangle2D.OUT_RIGHT) == Rectangle2D.OUT_RIGHT && dx != 0.0) { y2 = y2 + (maxX - x2) * dy / dx; x2 = maxX; } else if ((f2 & Rectangle2D.OUT_BOTTOM) == Rectangle2D.OUT_BOTTOM && dy != 0.0) { x2 = x2 + (maxY - y2) * dx / dy; y2 = maxY; } else if ((f2 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP && dy != 0.0) { x2 = x2 + (minY - y2) * dx / dy; y2 = minY; } f2 = rect.outcode(x2, y2); } } line.setLine(x1, y1, x2, y2); return true; // the line is visible - if it wasn't, we'd have // returned false from within the while loop above } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/LogFormat.java0000644000175000017500000001762311173030414026154 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * LogFormat.java * -------------- * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Aug-2007 : Version 1 (DG); * 19-Feb-2008 : Implemented equals() and clone(), and added new powerLabel * attribute as per Feature Request 1886036 (DG); * 14-Jan-2009 : Added default constructor, and accessor methods for * exponent formatter (DG); * */ package org.jfree.chart.util; import java.text.DecimalFormat; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; /** * A number formatter for logarithmic values. This formatter does not support * parsing. * * @since 1.0.7 */ public class LogFormat extends NumberFormat { /** The log base value. */ private double base; /** The natural logarithm of the base value. */ private double baseLog; /** The label for the log base (for example, "e"). */ private String baseLabel; /** * The label for the power symbol. * * @since 1.0.10 */ private String powerLabel; /** A flag that controls whether or not the base is shown. */ private boolean showBase; /** The number formatter for the exponent. */ private NumberFormat formatter = new DecimalFormat("0.0#"); /** * Creates a new instance using base 10. * * @since 1.0.13 */ public LogFormat() { this(10.0, "10", true); } /** * Creates a new instance. * * @param base the base. * @param baseLabel the base label (null not permitted). * @param showBase a flag that controls whether or not the base value is * shown. */ public LogFormat(double base, String baseLabel, boolean showBase) { this(base, baseLabel, "^", showBase); } /** * Creates a new instance. * * @param base the base. * @param baseLabel the base label (null not permitted). * @param powerLabel the power label (null not permitted). * @param showBase a flag that controls whether or not the base value is * shown. * * @since 1.0.10 */ public LogFormat(double base, String baseLabel, String powerLabel, boolean showBase) { if (baseLabel == null) { throw new IllegalArgumentException("Null 'baseLabel' argument."); } if (powerLabel == null) { throw new IllegalArgumentException("Null 'powerLabel' argument."); } this.base = base; this.baseLog = Math.log(this.base); this.baseLabel = baseLabel; this.showBase = showBase; this.powerLabel = powerLabel; } /** * Returns the number format used for the exponent. * * @return The number format (never null). * * @since 1.0.13. */ public NumberFormat getExponentFormat() { return (NumberFormat) this.formatter.clone(); } /** * Sets the number format used for the exponent. * * @param format the formatter (null not permitted). * * @since 1.0.13 */ public void setExponentFormat(NumberFormat format) { if (format == null) { throw new IllegalArgumentException("Null 'format' argument."); } this.formatter = format; } /** * Calculates the log of a given value. * * @param value the value. * * @return The log of the value. */ private double calculateLog(double value) { return Math.log(value) / this.baseLog; } /** * Returns a formatted representation of the specified number. * * @param number the number. * @param toAppendTo the string buffer to append to. * @param pos the position. * * @return A string buffer containing the formatted value. */ public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { StringBuffer result = new StringBuffer(); if (this.showBase) { result.append(this.baseLabel); result.append(this.powerLabel); } result.append(this.formatter.format(calculateLog(number))); return result; } /** * Formats the specified number as a hexadecimal string. The decimal * fraction is ignored. * * @param number the number to format. * @param toAppendTo the buffer to append to (ignored here). * @param pos the field position (ignored here). * * @return The string buffer. */ public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { StringBuffer result = new StringBuffer(); if (this.showBase) { result.append(this.baseLabel); result.append("^"); } result.append(this.formatter.format(calculateLog(number))); return result; } /** * Parsing is not implemented, so this method always returns * null. * * @param source ignored. * @param parsePosition ignored. * * @return Always null. */ public Number parse (String source, ParsePosition parsePosition) { return null; // don't bother with parsing } /** * Tests this formatter for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LogFormat)) { return false; } LogFormat that = (LogFormat) obj; if (this.base != that.base) { return false; } if (!this.baseLabel.equals(that.baseLabel)) { return false; } if (this.baseLog != that.baseLog) { return false; } if (this.showBase != that.showBase) { return false; } if (!this.formatter.equals(that.formatter)) { return false; } return super.equals(obj); } /** * Returns a clone of this instance. * * @return A clone. */ public Object clone() { LogFormat clone = (LogFormat) super.clone(); clone.formatter = (NumberFormat) this.formatter.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/RelativeDateFormat.java0000644000175000017500000004447611173030414030012 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * RelativeDateFormat.java * ----------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Michael Siemer; * * Changes: * -------- * 01-Nov-2006 : Version 1 (DG); * 23-Nov-2006 : Added argument checks, updated equals(), added clone() and * hashCode() (DG); * 15-Feb-2008 : Applied patch 1873328 by Michael Siemer, with minor * modifications (DG); * 01-Sep-2008 : Added new fields for hour and minute formatting, based on * patch 2033092 (DG); * */ package org.jfree.chart.util; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; /** * A formatter that formats dates to show the elapsed time relative to some * base date. * * @since 1.0.3 */ public class RelativeDateFormat extends DateFormat { /** The base milliseconds for the elapsed time calculation. */ private long baseMillis; /** * A flag that controls whether or not a zero day count is displayed. */ private boolean showZeroDays; /** * A flag that controls whether or not a zero hour count is displayed. * * @since 1.0.10 */ private boolean showZeroHours; /** * A formatter for the day count (most likely not critical until the * day count exceeds 999). */ private NumberFormat dayFormatter; /** * A prefix prepended to the start of the format if the relative date is * positive. * * @since 1.0.10 */ private String positivePrefix; /** * A string appended after the day count. */ private String daySuffix; /** * A formatter for the hours. * * @since 1.0.11 */ private NumberFormat hourFormatter; /** * A string appended after the hours. */ private String hourSuffix; /** * A formatter for the minutes. * * @since 1.0.11 */ private NumberFormat minuteFormatter; /** * A string appended after the minutes. */ private String minuteSuffix; /** * A formatter for the seconds (and milliseconds). */ private NumberFormat secondFormatter; /** * A string appended after the seconds. */ private String secondSuffix; /** * A constant for the number of milliseconds in one hour. */ private static long MILLISECONDS_IN_ONE_HOUR = 60 * 60 * 1000L; /** * A constant for the number of milliseconds in one day. */ private static long MILLISECONDS_IN_ONE_DAY = 24 * MILLISECONDS_IN_ONE_HOUR; /** * Creates a new instance with base milliseconds set to zero. */ public RelativeDateFormat() { this(0L); } /** * Creates a new instance. * * @param time the date/time (null not permitted). */ public RelativeDateFormat(Date time) { this(time.getTime()); } /** * Creates a new instance. * * @param baseMillis the time zone (null not permitted). */ public RelativeDateFormat(long baseMillis) { super(); this.baseMillis = baseMillis; this.showZeroDays = false; this.showZeroHours = true; this.positivePrefix = ""; this.dayFormatter = NumberFormat.getNumberInstance(); this.daySuffix = "d"; this.hourFormatter = NumberFormat.getNumberInstance(); this.hourSuffix = "h"; this.minuteFormatter = NumberFormat.getNumberInstance(); this.minuteSuffix = "m"; this.secondFormatter = NumberFormat.getNumberInstance(); this.secondFormatter.setMaximumFractionDigits(3); this.secondFormatter.setMinimumFractionDigits(3); this.secondSuffix = "s"; // we don't use the calendar or numberFormat fields, but equals(Object) // is failing without them being non-null this.calendar = new GregorianCalendar(); this.numberFormat = new DecimalFormat("0"); } /** * Returns the base date/time used to calculate the elapsed time for * display. * * @return The base date/time in milliseconds since 1-Jan-1970. * * @see #setBaseMillis(long) */ public long getBaseMillis() { return this.baseMillis; } /** * Sets the base date/time used to calculate the elapsed time for display. * This should be specified in milliseconds using the same encoding as * java.util.Date. * * @param baseMillis the base date/time in milliseconds. * * @see #getBaseMillis() */ public void setBaseMillis(long baseMillis) { this.baseMillis = baseMillis; } /** * Returns the flag that controls whether or not zero day counts are * shown in the formatted output. * * @return The flag. * * @see #setShowZeroDays(boolean) */ public boolean getShowZeroDays() { return this.showZeroDays; } /** * Sets the flag that controls whether or not zero day counts are shown * in the formatted output. * * @param show the flag. * * @see #getShowZeroDays() */ public void setShowZeroDays(boolean show) { this.showZeroDays = show; } /** * Returns the flag that controls whether or not zero hour counts are * shown in the formatted output. * * @return The flag. * * @see #setShowZeroHours(boolean) * * @since 1.0.10 */ public boolean getShowZeroHours() { return this.showZeroHours; } /** * Sets the flag that controls whether or not zero hour counts are shown * in the formatted output. * * @param show the flag. * * @see #getShowZeroHours() * * @since 1.0.10 */ public void setShowZeroHours(boolean show) { this.showZeroHours = show; } /** * Returns the string that is prepended to the format if the relative time * is positive. * * @return The string (never null). * * @see #setPositivePrefix(String) * * @since 1.0.10 */ public String getPositivePrefix() { return this.positivePrefix; } /** * Sets the string that is prepended to the format if the relative time is * positive. * * @param prefix the prefix (null not permitted). * * @see #getPositivePrefix() * * @since 1.0.10 */ public void setPositivePrefix(String prefix) { if (prefix == null) { throw new IllegalArgumentException("Null 'prefix' argument."); } this.positivePrefix = prefix; } /** * Sets the formatter for the days. * * @param formatter the formatter (null not permitted). * * @since 1.0.11 */ public void setDayFormatter(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.dayFormatter = formatter; } /** * Returns the string that is appended to the day count. * * @return The string. * * @see #setDaySuffix(String) */ public String getDaySuffix() { return this.daySuffix; } /** * Sets the string that is appended to the day count. * * @param suffix the suffix (null not permitted). * * @see #getDaySuffix() */ public void setDaySuffix(String suffix) { if (suffix == null) { throw new IllegalArgumentException("Null 'suffix' argument."); } this.daySuffix = suffix; } /** * Sets the formatter for the hours. * * @param formatter the formatter (null not permitted). * * @since 1.0.11 */ public void setHourFormatter(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.hourFormatter = formatter; } /** * Returns the string that is appended to the hour count. * * @return The string. * * @see #setHourSuffix(String) */ public String getHourSuffix() { return this.hourSuffix; } /** * Sets the string that is appended to the hour count. * * @param suffix the suffix (null not permitted). * * @see #getHourSuffix() */ public void setHourSuffix(String suffix) { if (suffix == null) { throw new IllegalArgumentException("Null 'suffix' argument."); } this.hourSuffix = suffix; } /** * Sets the formatter for the minutes. * * @param formatter the formatter (null not permitted). * * @since 1.0.11 */ public void setMinuteFormatter(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.minuteFormatter = formatter; } /** * Returns the string that is appended to the minute count. * * @return The string. * * @see #setMinuteSuffix(String) */ public String getMinuteSuffix() { return this.minuteSuffix; } /** * Sets the string that is appended to the minute count. * * @param suffix the suffix (null not permitted). * * @see #getMinuteSuffix() */ public void setMinuteSuffix(String suffix) { if (suffix == null) { throw new IllegalArgumentException("Null 'suffix' argument."); } this.minuteSuffix = suffix; } /** * Returns the string that is appended to the second count. * * @return The string. * * @see #setSecondSuffix(String) */ public String getSecondSuffix() { return this.secondSuffix; } /** * Sets the string that is appended to the second count. * * @param suffix the suffix (null not permitted). * * @see #getSecondSuffix() */ public void setSecondSuffix(String suffix) { if (suffix == null) { throw new IllegalArgumentException("Null 'suffix' argument."); } this.secondSuffix = suffix; } /** * Sets the formatter for the seconds and milliseconds. * * @param formatter the formatter (null not permitted). */ public void setSecondFormatter(NumberFormat formatter) { if (formatter == null) { throw new IllegalArgumentException("Null 'formatter' argument."); } this.secondFormatter = formatter; } /** * Formats the given date as the amount of elapsed time (relative to the * base date specified in the constructor). * * @param date the date. * @param toAppendTo the string buffer. * @param fieldPosition the field position. * * @return The formatted date. */ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { long currentMillis = date.getTime(); long elapsed = currentMillis - this.baseMillis; String signPrefix; if (elapsed < 0) { elapsed *= -1L; signPrefix = "-"; } else { signPrefix = this.positivePrefix; } long days = elapsed / MILLISECONDS_IN_ONE_DAY; elapsed = elapsed - (days * MILLISECONDS_IN_ONE_DAY); long hours = elapsed / MILLISECONDS_IN_ONE_HOUR; elapsed = elapsed - (hours * MILLISECONDS_IN_ONE_HOUR); long minutes = elapsed / 60000L; elapsed = elapsed - (minutes * 60000L); double seconds = elapsed / 1000.0; toAppendTo.append(signPrefix); if (days != 0 || this.showZeroDays) { toAppendTo.append(this.dayFormatter.format(days) + getDaySuffix()); } if (hours != 0 || this.showZeroHours) { toAppendTo.append(this.hourFormatter.format(hours) + getHourSuffix()); } toAppendTo.append(this.minuteFormatter.format(minutes) + getMinuteSuffix()); toAppendTo.append(this.secondFormatter.format(seconds) + getSecondSuffix()); return toAppendTo; } /** * Parses the given string (not implemented). * * @param source the date string. * @param pos the parse position. * * @return null, as this method has not been implemented. */ public Date parse(String source, ParsePosition pos) { return null; } /** * Tests this formatter for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof RelativeDateFormat)) { return false; } if (!super.equals(obj)) { return false; } RelativeDateFormat that = (RelativeDateFormat) obj; if (this.baseMillis != that.baseMillis) { return false; } if (this.showZeroDays != that.showZeroDays) { return false; } if (this.showZeroHours != that.showZeroHours) { return false; } if (!this.positivePrefix.equals(that.positivePrefix)) { return false; } if (!this.daySuffix.equals(that.daySuffix)) { return false; } if (!this.hourSuffix.equals(that.hourSuffix)) { return false; } if (!this.minuteSuffix.equals(that.minuteSuffix)) { return false; } if (!this.secondSuffix.equals(that.secondSuffix)) { return false; } if (!this.dayFormatter.equals(that.dayFormatter)) { return false; } if (!this.hourFormatter.equals(that.hourFormatter)) { return false; } if (!this.minuteFormatter.equals(that.minuteFormatter)) { return false; } if (!this.secondFormatter.equals(that.secondFormatter)) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; result = 37 * result + (int) (this.baseMillis ^ (this.baseMillis >>> 32)); result = 37 * result + this.positivePrefix.hashCode(); result = 37 * result + this.daySuffix.hashCode(); result = 37 * result + this.hourSuffix.hashCode(); result = 37 * result + this.minuteSuffix.hashCode(); result = 37 * result + this.secondSuffix.hashCode(); result = 37 * result + this.secondFormatter.hashCode(); return result; } /** * Returns a clone of this instance. * * @return A clone. */ public Object clone() { RelativeDateFormat clone = (RelativeDateFormat) super.clone(); clone.dayFormatter = (NumberFormat) this.dayFormatter.clone(); clone.secondFormatter = (NumberFormat) this.secondFormatter.clone(); return clone; } /** * Some test code. * * @param args ignored. */ public static void main(String[] args) { GregorianCalendar c0 = new GregorianCalendar(2006, 10, 1, 0, 0, 0); GregorianCalendar c1 = new GregorianCalendar(2006, 10, 1, 11, 37, 43); c1.set(Calendar.MILLISECOND, 123); System.out.println("Default: "); RelativeDateFormat rdf = new RelativeDateFormat(c0.getTime().getTime()); System.out.println(rdf.format(c1.getTime())); System.out.println(); System.out.println("Hide milliseconds: "); rdf.setSecondFormatter(new DecimalFormat("0")); System.out.println(rdf.format(c1.getTime())); System.out.println(); System.out.println("Show zero day output: "); rdf.setShowZeroDays(true); System.out.println(rdf.format(c1.getTime())); System.out.println(); System.out.println("Alternative suffixes: "); rdf.setShowZeroDays(false); rdf.setDaySuffix(":"); rdf.setHourSuffix(":"); rdf.setMinuteSuffix(":"); rdf.setSecondSuffix(""); System.out.println(rdf.format(c1.getTime())); System.out.println(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/ResourceBundleWrapper.java0000644000175000017500000001347411173030414030544 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * ResourceBundleWrapper.java * -------------------------- * (C)opyright 2008, by Jess Thrysoee and Contributors. * * Original Author: Jess Thrysoee; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 18-Dec-2008 : Version 1 (JT); * */ package org.jfree.chart.util; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.ResourceBundle; /** * Wrapper of ResourceBundle.getBundle() methods. This wrapper is introduced to * avoid a dramatic performance penalty by superfluous resource (and classes * loaded by Class.forName) lookups on web server in applets. * *
 * public class AppletC extends javax.swing.JApplet {
 *    public void init() {
 *       ResourceBundleWrapper.removeCodeBase(getCodeBase(),
 *               (URLClassLoader) getClass().getClassLoader());
 *    ...
 * 
* * @see * Bug ID: 4243379 * @see * Bug ID: 4668479 * * @since 1.0.12 */ public class ResourceBundleWrapper { /** * A special class loader with no code base lookup. This field may be * null (the field is only initialised if removeCodeBase() is * called from an applet. */ private static URLClassLoader noCodeBaseClassLoader; /** * Private constructor. */ private ResourceBundleWrapper() { // all methods are static, no need to instantiate } /** * Instantiate a {@link URLClassLoader} for resource lookups where the * codeBase URL is removed. This method is typically called from an * applet's init() method. If this method is never called, the * getBundle() methods map to the standard * {@link ResourceBundle} lookup methods. * * @param codeBase the codeBase URL. * @param urlClassLoader the class loader. */ public static void removeCodeBase(URL codeBase, URLClassLoader urlClassLoader) { List urlsNoBase = new ArrayList(); URL[] urls = urlClassLoader.getURLs(); for (int i = 0; i < urls.length; i++) { if (! urls[i].sameFile(codeBase)) { urlsNoBase.add(urls[i]); } } // substitute the filtered URL list URL[] urlsNoBaseArray = (URL[]) urlsNoBase.toArray(new URL[0]); noCodeBaseClassLoader = URLClassLoader.newInstance(urlsNoBaseArray); } /** * Finds and returns the specified resource bundle. * * @param baseName the base name. * * @return The resource bundle. */ public static final ResourceBundle getBundle(String baseName) { // the noCodeBaseClassLoader is configured by a call to the // removeCodeBase() method, typically in the init() method of an // applet... if (noCodeBaseClassLoader != null) { return ResourceBundle.getBundle(baseName, Locale.getDefault(), noCodeBaseClassLoader); } else { // standard ResourceBundle behaviour return ResourceBundle.getBundle(baseName); } } /** * Finds and returns the specified resource bundle. * * @param baseName the base name. * @param locale the locale. * * @return The resource bundle. */ public static final ResourceBundle getBundle(String baseName, Locale locale) { // the noCodeBaseClassLoader is configured by a call to the // removeCodeBase() method, typically in the init() method of an // applet... if (noCodeBaseClassLoader != null) { return ResourceBundle.getBundle(baseName, locale, noCodeBaseClassLoader); } else { // standard ResourceBundle behaviour return ResourceBundle.getBundle(baseName, locale); } } /** * Maps directly to ResourceBundle.getBundle(baseName, locale, * loader). * * @param baseName the base name. * @param locale the locale. * @param loader the class loader. * * @return The resource bundle. */ public static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader loader) { return ResourceBundle.getBundle(baseName, locale, loader); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/XYCoordinateType.java0000644000175000017500000001017711173030414027471 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYCoordinateType.java * --------------------- * (C) Copyright 2007, 2008 by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Feb-2007 : Version 1 (DG); * 03-Sep-2008 : Moved from experimental to main (DG); * */ package org.jfree.chart.util; import java.io.ObjectStreamException; import java.io.Serializable; /** * Represents several possible interpretations for an (x, y) coordinate. * * @since 1.0.11 */ public final class XYCoordinateType implements Serializable { /** The (x, y) coordinates represent a point in the data space. */ public static final XYCoordinateType DATA = new XYCoordinateType("XYCoordinateType.DATA"); /** * The (x, y) coordinates represent a relative position in the data space. * In this case, the values should be in the range (0.0 to 1.0). */ public static final XYCoordinateType RELATIVE = new XYCoordinateType("XYCoordinateType.RELATIVE"); /** * The (x, y) coordinates represent indices in a dataset. * In this case, the values should be in the range (0.0 to 1.0). */ public static final XYCoordinateType INDEX = new XYCoordinateType("XYCoordinateType.INDEX"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private XYCoordinateType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof XYCoordinateType)) { return false; } XYCoordinateType order = (XYCoordinateType) obj; if (!this.name.equals(order.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(XYCoordinateType.DATA)) { return XYCoordinateType.DATA; } else if (this.equals(XYCoordinateType.RELATIVE)) { return XYCoordinateType.RELATIVE; } else if (this.equals(XYCoordinateType.INDEX)) { return XYCoordinateType.INDEX; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/util/package.html0000644000175000017500000000043011173030414025664 0ustar vincentvincent Utility classes used by JFreeChart. Some of these will be candidates for addition to JCommon, but we keep them here so that our dependency is only JCommon 1.0.0 or later. libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartColor.java0000644000175000017500000001550411173030414025341 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ChartColor.java * --------------- * (C) Copyright 2003-2008, by Cameron Riley and Contributors. * * Original Author: Cameron Riley; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 23-Jan-2003 : Version 1, contributed by Cameron Riley (DG); * 25-Nov-2004 : Changed first 7 colors to softer shades (DG); * 03-Nov-2005 : Removed orange color, too close to yellow - see bug * report 1328408 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart; import java.awt.Color; import java.awt.Paint; /** * Class to extend the number of Colors available to the charts. This * extends the java.awt.Color object and extends the number of final * Colors publically accessible. */ public class ChartColor extends Color { /** A very dark red color. */ public static final Color VERY_DARK_RED = new Color(0x80, 0x00, 0x00); /** A dark red color. */ public static final Color DARK_RED = new Color(0xc0, 0x00, 0x00); /** A light red color. */ public static final Color LIGHT_RED = new Color(0xFF, 0x40, 0x40); /** A very light red color. */ public static final Color VERY_LIGHT_RED = new Color(0xFF, 0x80, 0x80); /** A very dark yellow color. */ public static final Color VERY_DARK_YELLOW = new Color(0x80, 0x80, 0x00); /** A dark yellow color. */ public static final Color DARK_YELLOW = new Color(0xC0, 0xC0, 0x00); /** A light yellow color. */ public static final Color LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x40); /** A very light yellow color. */ public static final Color VERY_LIGHT_YELLOW = new Color(0xFF, 0xFF, 0x80); /** A very dark green color. */ public static final Color VERY_DARK_GREEN = new Color(0x00, 0x80, 0x00); /** A dark green color. */ public static final Color DARK_GREEN = new Color(0x00, 0xC0, 0x00); /** A light green color. */ public static final Color LIGHT_GREEN = new Color(0x40, 0xFF, 0x40); /** A very light green color. */ public static final Color VERY_LIGHT_GREEN = new Color(0x80, 0xFF, 0x80); /** A very dark cyan color. */ public static final Color VERY_DARK_CYAN = new Color(0x00, 0x80, 0x80); /** A dark cyan color. */ public static final Color DARK_CYAN = new Color(0x00, 0xC0, 0xC0); /** A light cyan color. */ public static final Color LIGHT_CYAN = new Color(0x40, 0xFF, 0xFF); /** Aa very light cyan color. */ public static final Color VERY_LIGHT_CYAN = new Color(0x80, 0xFF, 0xFF); /** A very dark blue color. */ public static final Color VERY_DARK_BLUE = new Color(0x00, 0x00, 0x80); /** A dark blue color. */ public static final Color DARK_BLUE = new Color(0x00, 0x00, 0xC0); /** A light blue color. */ public static final Color LIGHT_BLUE = new Color(0x40, 0x40, 0xFF); /** A very light blue color. */ public static final Color VERY_LIGHT_BLUE = new Color(0x80, 0x80, 0xFF); /** A very dark magenta/purple color. */ public static final Color VERY_DARK_MAGENTA = new Color(0x80, 0x00, 0x80); /** A dark magenta color. */ public static final Color DARK_MAGENTA = new Color(0xC0, 0x00, 0xC0); /** A light magenta color. */ public static final Color LIGHT_MAGENTA = new Color(0xFF, 0x40, 0xFF); /** A very light magenta color. */ public static final Color VERY_LIGHT_MAGENTA = new Color(0xFF, 0x80, 0xFF); /** * Creates a Color with an opaque sRGB with red, green and blue values in * range 0-255. * * @param r the red component in range 0x00-0xFF. * @param g the green component in range 0x00-0xFF. * @param b the blue component in range 0x00-0xFF. */ public ChartColor(int r, int g, int b) { super(r, g, b); } /** * Convenience method to return an array of Paint objects that * represent the pre-defined colors in the Color and * ChartColor objects. * * @return An array of objects with the Paint interface. */ public static Paint[] createDefaultPaintArray() { return new Paint[] { new Color(0xFF, 0x55, 0x55), new Color(0x55, 0x55, 0xFF), new Color(0x55, 0xFF, 0x55), new Color(0xFF, 0xFF, 0x55), new Color(0xFF, 0x55, 0xFF), new Color(0x55, 0xFF, 0xFF), Color.pink, Color.gray, ChartColor.DARK_RED, ChartColor.DARK_BLUE, ChartColor.DARK_GREEN, ChartColor.DARK_YELLOW, ChartColor.DARK_MAGENTA, ChartColor.DARK_CYAN, Color.darkGray, ChartColor.LIGHT_RED, ChartColor.LIGHT_BLUE, ChartColor.LIGHT_GREEN, ChartColor.LIGHT_YELLOW, ChartColor.LIGHT_MAGENTA, ChartColor.LIGHT_CYAN, Color.lightGray, ChartColor.VERY_DARK_RED, ChartColor.VERY_DARK_BLUE, ChartColor.VERY_DARK_GREEN, ChartColor.VERY_DARK_YELLOW, ChartColor.VERY_DARK_MAGENTA, ChartColor.VERY_DARK_CYAN, ChartColor.VERY_LIGHT_RED, ChartColor.VERY_LIGHT_BLUE, ChartColor.VERY_LIGHT_GREEN, ChartColor.VERY_LIGHT_YELLOW, ChartColor.VERY_LIGHT_MAGENTA, ChartColor.VERY_LIGHT_CYAN }; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartFactory.java0000644000175000017500000031077711173030414025704 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ChartFactory.java * ----------------- * (C) Copyright 2001-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Serge V. Grachov; * Joao Guilherme Del Valle; * Bill Kelemen; * Jon Iles; * Jelai Wang; * Richard Atkinson; * David Browning (for Australian Institute of Marine * Science); * Benoit Xhenseval; * * Changes * ------- * 19-Oct-2001 : Version 1, most methods transferred from JFreeChart.java (DG); * 22-Oct-2001 : Added methods to create stacked bar charts (DG); * Renamed DataSource.java --> Dataset.java etc. (DG); * 31-Oct-2001 : Added 3D-effect vertical bar and stacked-bar charts, * contributed by Serge V. Grachov (DG); * 07-Nov-2001 : Added a flag to control whether or not a legend is added to * the chart (DG); * 17-Nov-2001 : For pie chart, changed dataset from CategoryDataset to * PieDataset (DG); * 30-Nov-2001 : Removed try/catch handlers from chart creation, as the * exception are now RuntimeExceptions, as suggested by Joao * Guilherme Del Valle (DG); * 06-Dec-2001 : Added createCombinableXXXXXCharts methods (BK); * 12-Dec-2001 : Added createCandlestickChart() method (DG); * 13-Dec-2001 : Updated methods for charts with new renderers (DG); * 08-Jan-2002 : Added import for * com.jrefinery.chart.combination.CombinedChart (DG); * 31-Jan-2002 : Changed the createCombinableVerticalXYBarChart() method to use * renderer (DG); * 06-Feb-2002 : Added new method createWindPlot() (DG); * 23-Apr-2002 : Updates to the chart and plot constructor API (DG); * 21-May-2002 : Added new method createAreaChart() (JI); * 06-Jun-2002 : Added new method createGanttChart() (DG); * 11-Jun-2002 : Renamed createHorizontalStackedBarChart() * --> createStackedHorizontalBarChart() for consistency (DG); * 06-Aug-2002 : Updated Javadoc comments (DG); * 21-Aug-2002 : Added createPieChart(CategoryDataset) method (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 09-Oct-2002 : Added methods including tooltips and URL flags (DG); * 06-Nov-2002 : Moved renderers into a separate package (DG); * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG); * 21-Mar-2003 : Incorporated HorizontalCategoryAxis3D, see bug id 685501 (DG); * 13-May-2003 : Merged some horizontal and vertical methods (DG); * 24-May-2003 : Added support for timeline in createHighLowChart (BK); * 07-Jul-2003 : Added createHistogram() method contributed by Jelai Wang (DG); * 27-Jul-2003 : Added createStackedAreaXYChart() method (RA); * 05-Aug-2003 : added new method createBoxAndWhiskerChart (DB); * 08-Sep-2003 : Changed ValueAxis API (DG); * 07-Oct-2003 : Added stepped area XY chart contributed by Matthias Rose (DG); * 06-Nov-2003 : Added createWaterfallChart() method (DG); * 20-Nov-2003 : Set rendering order for 3D bar charts to fix overlapping * problems (DG); * 25-Nov-2003 : Added createWaferMapChart() method (DG); * 23-Dec-2003 : Renamed createPie3DChart() --> createPieChart3D for * consistency (DG); * 20-Jan-2004 : Added createPolarChart() method (DG); * 28-Jan-2004 : Fixed bug (882890) with axis range in * createStackedXYAreaChart() method (DG); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 11-Mar-2004 : Updated for pie chart changes (DG); * 27-Apr-2004 : Added new createPieChart() method contributed by Benoit * Xhenseval (see RFE 942195) (DG); * 11-May-2004 : Split StandardCategoryItemLabelGenerator * --> StandardCategoryToolTipGenerator and * StandardCategoryLabelGenerator (DG); * 06-Jan-2005 : Removed deprecated methods (DG); * 27-Jan-2005 : Added new constructor to LineAndShapeRenderer (DG); * 28-Feb-2005 : Added docs to createBubbleChart() method (DG); * 17-Mar-2005 : Added createRingPlot() method (DG); * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); * 29-Nov-2005 : Removed signal chart (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 26-Jan-2006 : Corrected API docs for createScatterPlot() (DG); * 23-Aug-2006 : Modified createStackedXYAreaChart() to use * StackedXYAreaRenderer2, because StackedXYAreaRenderer doesn't * handle negative values (DG); * 27-Sep-2006 : Update createPieChart() method for deprecated code (DG); * 29-Nov-2006 : Update createXYBarChart() to use a time based tool tip * generator is a DateAxis is requested (DG); * 17-Jan-2007 : Added createBoxAndWhiskerChart() method from patch 1603937 * submitted by Darren Jung (DG); * 10-Jul-2007 : Added new methods to create pie charts with locale for * section label and tool tip formatting (DG); * 14-Aug-2008 : Added ChartTheme facility (DG); * 23-Oct-2008 : Check for legacy theme in setChartTheme() and reset default * bar painters (DG); * 20-Dec-2008 : In createStackedAreaChart(), set category margin to 0.0 (DG); * */ package org.jfree.chart; import java.awt.Color; import java.awt.Font; import java.text.DateFormat; import java.text.NumberFormat; import java.util.Iterator; import java.util.List; import java.util.Locale; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryAxis3D; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberAxis3D; import org.jfree.chart.axis.Timeline; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator; import org.jfree.chart.labels.HighLowItemLabelGenerator; import org.jfree.chart.labels.IntervalCategoryToolTipGenerator; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieToolTipGenerator; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.StandardXYZToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.MultiplePiePlot; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PiePlot3D; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PolarPlot; import org.jfree.chart.plot.RingPlot; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.WaferMapPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.DefaultPolarItemRenderer; import org.jfree.chart.renderer.WaferMapRenderer; import org.jfree.chart.renderer.category.AreaRenderer; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.BarRenderer3D; import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.GanttRenderer; import org.jfree.chart.renderer.category.GradientBarPainter; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.renderer.category.LineRenderer3D; import org.jfree.chart.renderer.category.StackedAreaRenderer; import org.jfree.chart.renderer.category.StackedBarRenderer; import org.jfree.chart.renderer.category.StackedBarRenderer3D; import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.chart.renderer.category.WaterfallBarRenderer; import org.jfree.chart.renderer.xy.CandlestickRenderer; import org.jfree.chart.renderer.xy.GradientXYBarPainter; import org.jfree.chart.renderer.xy.HighLowRenderer; import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; import org.jfree.chart.renderer.xy.StandardXYBarPainter; import org.jfree.chart.renderer.xy.WindItemRenderer; import org.jfree.chart.renderer.xy.XYAreaRenderer; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer; import org.jfree.chart.renderer.xy.XYBubbleRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.renderer.xy.XYStepAreaRenderer; import org.jfree.chart.renderer.xy.XYStepRenderer; import org.jfree.chart.title.TextTitle; import org.jfree.chart.urls.PieURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.chart.urls.StandardPieURLGenerator; import org.jfree.chart.urls.StandardXYURLGenerator; import org.jfree.chart.urls.StandardXYZURLGenerator; import org.jfree.chart.urls.XYURLGenerator; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.data.general.WaferMapDataset; import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; import org.jfree.data.statistics.BoxAndWhiskerXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.WindDataset; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; import org.jfree.ui.Layer; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import org.jfree.util.SortOrder; import org.jfree.util.TableOrder; /** * A collection of utility methods for creating some standard charts with * JFreeChart. */ public abstract class ChartFactory { /** The chart theme. */ private static ChartTheme currentTheme = new StandardChartTheme("JFree"); /** * Returns the current chart theme used by the factory. * * @return The chart theme. * * @see #setChartTheme(ChartTheme) * @see ChartUtilities#applyCurrentTheme(JFreeChart) * * @since 1.0.11 */ public static ChartTheme getChartTheme() { return currentTheme; } /** * Sets the current chart theme. This will be applied to all new charts * created via methods in this class. * * @param theme the theme (null not permitted). * * @see #getChartTheme() * @see ChartUtilities#applyCurrentTheme(JFreeChart) * * @since 1.0.11 */ public static void setChartTheme(ChartTheme theme) { if (theme == null) { throw new IllegalArgumentException("Null 'theme' argument."); } currentTheme = theme; // here we do a check to see if the user is installing the "Legacy" // theme, and reset the bar painters in that case... if (theme instanceof StandardChartTheme) { StandardChartTheme sct = (StandardChartTheme) theme; if (sct.getName().equals("Legacy")) { BarRenderer.setDefaultBarPainter(new StandardBarPainter()); XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter()); } else { BarRenderer.setDefaultBarPainter(new GradientBarPainter()); XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter()); } } } /** * Creates a pie chart with default settings. *

* The chart object returned by this method uses a {@link PiePlot} instance * as the plot. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale (null not permitted). * * @return A pie chart. * * @since 1.0.7 */ public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a pie chart with default settings. *

* The chart object returned by this method uses a {@link PiePlot} instance * as the plot. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A pie chart. */ public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a pie chart with default settings that compares 2 datasets. * The colour of each section will be determined by the move from the value * for the same key in previousDataset. ie if value1 > value2 * then the section will be in green (unless greenForIncrease * is false, in which case it would be red). * Each section can have a shade of red or green as the difference can be * tailored between 0% (black) and percentDiffForMaxScale% (bright * red/green). *

* For instance if percentDiffForMaxScale is 10 (10%), a * difference of 5% will have a half shade of red/green, a difference of * 10% or more will have a maximum shade/brightness of red/green. *

* The chart object returned by this method uses a {@link PiePlot} instance * as the plot. *

* Written by Benoit * Xhenseval. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param previousDataset the dataset for the last run, this will be used * to compare each key in the dataset * @param percentDiffForMaxScale scale goes from bright red/green to black, * percentDiffForMaxScale indicate the change * required to reach top scale. * @param greenForIncrease an increase since previousDataset will be * displayed in green (decrease red) if true. * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale (null not permitted). * @param subTitle displays a subtitle with colour scheme if true * @param showDifference create a new dataset that will show the % * difference between the two datasets. * * @return A pie chart. * * @since 1.0.7 */ public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset, int percentDiffForMaxScale, boolean greenForIncrease, boolean legend, boolean tooltips, Locale locale, boolean subTitle, boolean showDifference) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } List keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (Iterator it = keys.iterator(); it.hasNext();) { Comparable key = (Comparable) it.next(); Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format( percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } currentTheme.apply(chart); return chart; } /** * Creates a pie chart with default settings that compares 2 datasets. * The colour of each section will be determined by the move from the value * for the same key in previousDataset. ie if value1 > value2 * then the section will be in green (unless greenForIncrease * is false, in which case it would be red). * Each section can have a shade of red or green as the difference can be * tailored between 0% (black) and percentDiffForMaxScale% (bright * red/green). *

* For instance if percentDiffForMaxScale is 10 (10%), a * difference of 5% will have a half shade of red/green, a difference of * 10% or more will have a maximum shade/brightness of red/green. *

* The chart object returned by this method uses a {@link PiePlot} instance * as the plot. *

* Written by Benoit * Xhenseval. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param previousDataset the dataset for the last run, this will be used * to compare each key in the dataset * @param percentDiffForMaxScale scale goes from bright red/green to black, * percentDiffForMaxScale indicate the change * required to reach top scale. * @param greenForIncrease an increase since previousDataset will be * displayed in green (decrease red) if true. * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * @param subTitle displays a subtitle with colour scheme if true * @param showDifference create a new dataset that will show the % * difference between the two datasets. * * @return A pie chart. */ public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset, int percentDiffForMaxScale, boolean greenForIncrease, boolean legend, boolean tooltips, boolean urls, boolean subTitle, boolean showDifference) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } List keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (Iterator it = keys.iterator(); it.hasNext();) { Comparable key = (Comparable) it.next(); Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format( percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } currentTheme.apply(chart); return chart; } /** * Creates a ring chart with default settings. *

* The chart object returned by this method uses a {@link RingPlot} * instance as the plot. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale (null not permitted). * * @return A ring chart. * * @since 1.0.7 */ public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) { RingPlot plot = new RingPlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a ring chart with default settings. *

* The chart object returned by this method uses a {@link RingPlot} * instance as the plot. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A ring chart. */ public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls) { RingPlot plot = new RingPlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a chart that displays multiple pie plots. The chart object * returned by this method uses a {@link MultiplePiePlot} instance as the * plot. * * @param title the chart title (null permitted). * @param dataset the dataset (null permitted). * @param order the order that the data is extracted (by row or by column) * (null not permitted). * @param legend include a legend? * @param tooltips generate tooltips? * @param urls generate URLs? * * @return A chart. */ public static JFreeChart createMultiplePieChart(String title, CategoryDataset dataset, TableOrder order, boolean legend, boolean tooltips, boolean urls) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(order); plot.setBackgroundPaint(null); plot.setOutlineStroke(null); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a 3D pie chart using the specified dataset. The chart object * returned by this method uses a {@link PiePlot3D} instance as the * plot. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale (null not permitted). * * @return A pie chart. * * @since 1.0.7 */ public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) { PiePlot3D plot = new PiePlot3D(dataset); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a 3D pie chart using the specified dataset. The chart object * returned by this method uses a {@link PiePlot3D} instance as the * plot. * * @param title the chart title (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A pie chart. */ public static JFreeChart createPieChart3D(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls) { PiePlot3D plot = new PiePlot3D(dataset); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); } if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a chart that displays multiple pie plots. The chart object * returned by this method uses a {@link MultiplePiePlot} instance as the * plot. * * @param title the chart title (null permitted). * @param dataset the dataset (null permitted). * @param order the order that the data is extracted (by row or by column) * (null not permitted). * @param legend include a legend? * @param tooltips generate tooltips? * @param urls generate URLs? * * @return A chart. */ public static JFreeChart createMultiplePieChart3D(String title, CategoryDataset dataset, TableOrder order, boolean legend, boolean tooltips, boolean urls) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(order); plot.setBackgroundPaint(null); plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); if (tooltips) { PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); } if (urls) { PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a bar chart. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link NumberAxis} as the range axis, and a * {@link BarRenderer} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis * (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A bar chart. */ public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); BarRenderer renderer = new BarRenderer(); if (orientation == PlotOrientation.HORIZONTAL) { ItemLabelPosition position1 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setBaseNegativeItemLabelPosition(position2); } else if (orientation == PlotOrientation.VERTICAL) { ItemLabelPosition position1 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setBaseNegativeItemLabelPosition(position2); } if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a stacked bar chart with default settings. The chart object * returned by this method uses a {@link CategoryPlot} instance as the * plot, with a {@link CategoryAxis} for the domain axis, a * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer} * as the renderer. * * @param title the chart title (null permitted). * @param domainAxisLabel the label for the category axis * (null permitted). * @param rangeAxisLabel the label for the value axis * (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the orientation of the chart (horizontal or * vertical) (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A stacked bar chart. */ public static JFreeChart createStackedBarChart(String title, String domainAxisLabel, String rangeAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel); ValueAxis valueAxis = new NumberAxis(rangeAxisLabel); StackedBarRenderer renderer = new StackedBarRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a bar chart with a 3D effect. The chart object returned by this * method uses a {@link CategoryPlot} instance as the plot, with a * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as * the range axis, and a {@link BarRenderer3D} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A bar chart with a 3D effect. */ public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); BarRenderer3D renderer = new BarRenderer3D(); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); if (orientation == PlotOrientation.HORIZONTAL) { // change rendering order to ensure that bar overlapping is the // right way around plot.setRowRenderingOrder(SortOrder.DESCENDING); plot.setColumnRenderingOrder(SortOrder.DESCENDING); } plot.setForegroundAlpha(0.75f); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a stacked bar chart with a 3D effect and default settings. The * chart object returned by this method uses a {@link CategoryPlot} * instance as the plot, with a {@link CategoryAxis3D} for the domain axis, * a {@link NumberAxis3D} as the range axis, and a * {@link StackedBarRenderer3D} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the orientation (horizontal or vertical) * (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A stacked bar chart with a 3D effect. */ public static JFreeChart createStackedBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); // create the renderer... CategoryItemRenderer renderer = new StackedBarRenderer3D(); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } // create the plot... CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); if (orientation == PlotOrientation.HORIZONTAL) { // change rendering order to ensure that bar overlapping is the // right way around plot.setColumnRenderingOrder(SortOrder.DESCENDING); } // create the chart... JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates an area chart with default settings. The chart object returned * by this method uses a {@link CategoryPlot} instance as the plot, with a * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and an {@link AreaRenderer} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (null not * permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return An area chart. */ public static JFreeChart createAreaChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); categoryAxis.setCategoryMargin(0.0); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); AreaRenderer renderer = new AreaRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a stacked area chart with default settings. The chart object * returned by this method uses a {@link CategoryPlot} instance as the * plot, with a {@link CategoryAxis} for the domain axis, a * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer} * as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A stacked area chart. */ public static JFreeChart createStackedAreaChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); categoryAxis.setCategoryMargin(0.0); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); StackedAreaRenderer renderer = new StackedAreaRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a line chart with default settings. The chart object returned * by this method uses a {@link CategoryPlot} instance as the plot, with a * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link LineAndShapeRenderer} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the chart orientation (horizontal or vertical) * (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A line chart. */ public static JFreeChart createLineChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a line chart with default settings. The chart object returned by * this method uses a {@link CategoryPlot} instance as the plot, with a * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as * the range axis, and a {@link LineRenderer3D} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the chart orientation (horizontal or vertical) * (null not permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A line chart. */ public static JFreeChart createLineChart3D(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); LineRenderer3D renderer = new LineRenderer3D(); if (tooltips) { renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a Gantt chart using the supplied attributes plus default values * where required. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link DateAxis} as the range axis, and a * {@link GanttRenderer} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param dateAxisLabel the label for the date axis * (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A Gantt chart. */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator( "{3} - {4}", DateFormat.getDateInstance())); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a waterfall chart. The chart object returned by this method * uses a {@link CategoryPlot} instance as the plot, with a * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link WaterfallBarRenderer} as the renderer. * * @param title the chart title (null permitted). * @param categoryAxisLabel the label for the category axis * (null permitted). * @param valueAxisLabel the label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A waterfall chart. */ public static JFreeChart createWaterfallChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); categoryAxis.setCategoryMargin(0.0); ValueAxis valueAxis = new NumberAxis(valueAxisLabel); WaterfallBarRenderer renderer = new WaterfallBarRenderer(); if (orientation == PlotOrientation.HORIZONTAL) { ItemLabelPosition position = new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, Math.PI / 2.0); renderer.setBasePositiveItemLabelPosition(position); renderer.setBaseNegativeItemLabelPosition(position); } else if (orientation == PlotOrientation.VERTICAL) { ItemLabelPosition position = new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 0.0); renderer.setBasePositiveItemLabelPosition(position); renderer.setBaseNegativeItemLabelPosition(position); } if (tooltips) { StandardCategoryToolTipGenerator generator = new StandardCategoryToolTipGenerator(); renderer.setBaseToolTipGenerator(generator); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.clearRangeMarkers(); Marker baseline = new ValueMarker(0.0); baseline.setPaint(Color.black); plot.addRangeMarker(baseline, Layer.FOREGROUND); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a polar plot for the specified dataset (x-values interpreted as * angles in degrees). The chart object returned by this method uses a * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for * the radial axis. * * @param title the chart title (null permitted). * @param dataset the dataset (null permitted). * @param legend legend required? * @param tooltips tooltips required? * @param urls URLs required? * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a scatter plot with default settings. The chart object * returned by this method uses an {@link XYPlot} instance as the plot, * with a {@link NumberAxis} for the domain axis, a {@link NumberAxis} * as the range axis, and an {@link XYLineAndShapeRenderer} as the * renderer. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A scatter plot. */ public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a default instance of an XY bar chart. *

* The chart object returned by this method uses an {@link XYPlot} instance * as the plot, with a {@link DateAxis} for the domain axis, a * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the * renderer. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param dateAxis make the domain axis display dates? * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return An XY bar chart. */ public static JFreeChart createXYBarChart(String title, String xAxisLabel, boolean dateAxis, String yAxisLabel, IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } ValueAxis domainAxis = null; if (dateAxis) { domainAxis = new DateAxis(xAxisLabel); } else { NumberAxis axis = new NumberAxis(xAxisLabel); axis.setAutoRangeIncludesZero(false); domainAxis = axis; } ValueAxis valueAxis = new NumberAxis(yAxisLabel); XYBarRenderer renderer = new XYBarRenderer(); if (tooltips) { XYToolTipGenerator tt; if (dateAxis) { tt = StandardXYToolTipGenerator.getTimeSeriesInstance(); } else { tt = new StandardXYToolTipGenerator(); } renderer.setBaseToolTipGenerator(tt); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates an area chart using an {@link XYDataset}. *

* The chart object returned by this method uses an {@link XYPlot} instance * as the plot, with a {@link NumberAxis} for the domain axis, a * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as * the renderer. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return An XY area chart. */ public static JFreeChart createXYAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setOrientation(orientation); plot.setForegroundAlpha(0.5f); XYToolTipGenerator tipGenerator = null; if (tooltips) { tipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator)); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a stacked XY area plot. The chart object returned by this * method uses an {@link XYPlot} instance as the plot, with a * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A stacked XY area chart. */ public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2( toolTipGenerator, urlGenerator); renderer.setOutline(true); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setRangeAxis(yAxis); // forces recalculation of the axis range JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a line chart (based on an {@link XYDataset}) with default * settings. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return The chart. */ public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a stepped XY plot with default settings. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A chart. */ public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } DateAxis xAxis = new DateAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a filled stepped XY plot with default settings. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A chart. */ public static JFreeChart createXYStepAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYStepAreaRenderer( XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a time series chart. A time series chart is an * {@link XYPlot} with a {@link DateAxis} for the x-axis and a * {@link NumberAxis} for the y-axis. The default renderer is an * {@link XYLineAndShapeRenderer}. *

* A convenient dataset to use with this chart is a * {@link org.jfree.data.time.TimeSeriesCollection}. * * @param title the chart title (null permitted). * @param timeAxisLabel a label for the time axis (null * permitted). * @param valueAxisLabel a label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A time series chart. */ public static JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a default instance of a candlesticks chart. * * @param title the chart title (null permitted). * @param timeAxisLabel a label for the time axis (null * permitted). * @param valueAxisLabel a label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A candlestick chart. */ public static JFreeChart createCandlestickChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a default instance of a high-low-open-close chart. * * @param title the chart title (null permitted). * @param timeAxisLabel a label for the time axis (null * permitted). * @param valueAxisLabel a label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a default instance of a high-low-open-close chart * with a special timeline. This timeline can be a * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday * through Friday timeline that will remove Saturdays and Sundays from * the axis. * * @param title the chart title (null permitted). * @param timeAxisLabel a label for the time axis (null * permitted). * @param valueAxisLabel a label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param timeline the timeline. * @param legend a flag specifying whether or not a legend is required. * * @return A high-low-open-close chart. */ public static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, Timeline timeline, boolean legend) { DateAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setTimeline(timeline); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a bubble chart with default settings. The chart is composed of * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis, * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} * to draw the data items. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the X-axis (null permitted). * @param yAxisLabel a label for the Y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param orientation the orientation (horizontal or vertical) * (null NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A bubble chart. */ public static JFreeChart createBubbleChart(String title, String xAxisLabel, String yAxisLabel, XYZDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYBubbleRenderer( XYBubbleRenderer.SCALE_ON_RANGE_AXIS); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYZURLGenerator()); } plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a histogram chart. This chart is constructed with an * {@link XYPlot} using an {@link XYBarRenderer}. The domain and range * axes are {@link NumberAxis} instances. * * @param title the chart title (null permitted). * @param xAxisLabel the x axis label (null permitted). * @param yAxisLabel the y axis label (null permitted). * @param dataset the dataset (null permitted). * @param orientation the orientation (horizontal or vertical) * (null NOT permitted). * @param legend create a legend? * @param tooltips display tooltips? * @param urls generate URLs? * * @return The chart. */ public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); ValueAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYBarRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a default instance of a box and whisker chart * based on data from a {@link BoxAndWhiskerCategoryDataset}. * * @param title the chart title (null permitted). * @param categoryAxisLabel a label for the category axis * (null permitted). * @param valueAxisLabel a label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A box and whisker chart. * * @since 1.0.4 */ public static JFreeChart createBoxAndWhiskerChart(String title, String categoryAxisLabel, String valueAxisLabel, BoxAndWhiskerCategoryDataset dataset, boolean legend) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates and returns a default instance of a box and whisker chart. * * @param title the chart title (null permitted). * @param timeAxisLabel a label for the time axis (null * permitted). * @param valueAxisLabel a label for the value axis (null * permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A box and whisker chart. */ public static JFreeChart createBoxAndWhiskerChart(String title, String timeAxisLabel, String valueAxisLabel, BoxAndWhiskerXYDataset dataset, boolean legend) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a wind plot with default settings. * * @param title the chart title (null permitted). * @param xAxisLabel a label for the x-axis (null permitted). * @param yAxisLabel a label for the y-axis (null permitted). * @param dataset the dataset for the chart (null permitted). * @param legend a flag that controls whether or not a legend is created. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A wind plot. * */ public static JFreeChart createWindPlot(String title, String xAxisLabel, String yAxisLabel, WindDataset dataset, boolean legend, boolean tooltips, boolean urls) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setRange(-12.0, 12.0); WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } /** * Creates a wafer map chart. * * @param title the chart title (null permitted). * @param dataset the dataset (null permitted). * @param orientation the plot orientation (horizontal or vertical) * (null NOT permitted. * @param legend display a legend? * @param tooltips generate tooltips? * @param urls generate URLs? * * @return A wafer map chart. */ public static JFreeChart createWaferMapChart(String title, WaferMapDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } WaferMapPlot plot = new WaferMapPlot(dataset); WaferMapRenderer renderer = new WaferMapRenderer(); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartFrame.java0000644000175000017500000000571311173030414025316 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ChartFrame.java * --------------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Nov-2001 : Version 1 (DG); * 08-Jan-2001 : Added chartPanel attribute (DG); * 24-May-2002 : Renamed JFreeChartFrame --> ChartFrame (DG); * */ package org.jfree.chart; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.WindowConstants; /** * A frame for displaying a chart. */ public class ChartFrame extends JFrame { /** The chart panel. */ private ChartPanel chartPanel; /** * Constructs a frame for a chart. * * @param title the frame title. * @param chart the chart. */ public ChartFrame(String title, JFreeChart chart) { this(title, chart, false); } /** * Constructs a frame for a chart. * * @param title the frame title. * @param chart the chart. * @param scrollPane if true, put the Chart(Panel) into a * JScrollPane. */ public ChartFrame(String title, JFreeChart chart, boolean scrollPane) { super(title); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.chartPanel = new ChartPanel(chart); if (scrollPane) { setContentPane(new JScrollPane(this.chartPanel)); } else { setContentPane(this.chartPanel); } } /** * Returns the chart panel for the frame. * * @return The chart panel. */ public ChartPanel getChartPanel() { return this.chartPanel; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartMouseEvent.java0000644000175000017500000000760711173030414026362 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ChartMouseEvent.java * -------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Alex Weber; * * Changes * ------- * 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG); * 13-Jun-2002 : Added Javadoc comments (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 05-Nov-2002 : Added a reference to the source chart (DG); * 13-Jul-2004 : Now extends EventObject and implements Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-May-2007 : Updated API docs (DG); * */ package org.jfree.chart; import java.awt.event.MouseEvent; import java.io.Serializable; import java.util.EventObject; import org.jfree.chart.entity.ChartEntity; /** * A mouse event for a chart that is displayed in a {@link ChartPanel}. * * @see ChartMouseListener */ public class ChartMouseEvent extends EventObject implements Serializable { /** For serialization. */ private static final long serialVersionUID = -682393837314562149L; /** The chart that the mouse event relates to. */ private JFreeChart chart; /** The Java mouse event that triggered this event. */ private MouseEvent trigger; /** The chart entity (if any). */ private ChartEntity entity; /** * Constructs a new event. * * @param chart the source chart (null not permitted). * @param trigger the mouse event that triggered this event * (null not permitted). * @param entity the chart entity (if any) under the mouse point * (null permitted). */ public ChartMouseEvent(JFreeChart chart, MouseEvent trigger, ChartEntity entity) { super(chart); this.chart = chart; this.trigger = trigger; this.entity = entity; } /** * Returns the chart that the mouse event relates to. * * @return The chart (never null). */ public JFreeChart getChart() { return this.chart; } /** * Returns the mouse event that triggered this event. * * @return The event (never null). */ public MouseEvent getTrigger() { return this.trigger; } /** * Returns the chart entity (if any) under the mouse point. * * @return The chart entity (possibly null). */ public ChartEntity getEntity() { return this.entity; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartMouseListener.java0000644000175000017500000000514311173030414027057 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * ChartMouseListener.java * ----------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Alex Weber; * * Changes * ------- * 27-May-2002 : Version 1, incorporating code and ideas by Alex Weber (DG); * 13-Jun-2002 : Added Javadocs (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 23-Nov-2005 : Now extends EventListener (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-May-2007 : Updated API docs (DG); * */ package org.jfree.chart; import java.util.EventListener; /** * The interface that must be implemented by classes that wish to receive * {@link ChartMouseEvent} notifications from a {@link ChartPanel}. * * @see ChartPanel#addChartMouseListener(ChartMouseListener) */ public interface ChartMouseListener extends EventListener { /** * Callback method for receiving notification of a mouse click on a chart. * * @param event information about the event. */ void chartMouseClicked(ChartMouseEvent event); /** * Callback method for receiving notification of a mouse movement on a * chart. * * @param event information about the event. */ void chartMouseMoved(ChartMouseEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartPanel.java0000644000175000017500000033447411173030414025334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ChartPanel.java * --------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrzej Porebski; * Soren Caspersen; * Jonathan Nash; * Hans-Jurgen Greiner; * Andreas Schneider; * Daniel van Enckevort; * David M O'Donnell; * Arnaud Lelievre; * Matthias Rose; * Onno vd Akker; * Sergei Ivanov; * Ulrich Voigt - patch 2686040; * Alessandro Borges - patch 1460845; * * Changes (from 28-Jun-2001) * -------------------------- * 28-Jun-2001 : Integrated buffering code contributed by S???ren * Caspersen (DG); * 18-Sep-2001 : Updated header and fixed DOS encoding problem (DG); * 22-Nov-2001 : Added scaling to improve display of charts in small sizes (DG); * 26-Nov-2001 : Added property editing, saving and printing (DG); * 11-Dec-2001 : Transferred saveChartAsPNG method to new ChartUtilities * class (DG); * 13-Dec-2001 : Added tooltips (DG); * 16-Jan-2002 : Added an optional crosshair, based on the implementation by * Jonathan Nash. Renamed the tooltips class (DG); * 23-Jan-2002 : Implemented zooming based on code by Hans-Jurgen Greiner (DG); * 05-Feb-2002 : Improved tooltips setup. Renamed method attemptSaveAs() * --> doSaveAs() and made it public rather than private (DG); * 28-Mar-2002 : Added a new constructor (DG); * 09-Apr-2002 : Changed initialisation of tooltip generation, as suggested by * Hans-Jurgen Greiner (DG); * 27-May-2002 : New interactive zooming methods based on code by Hans-Jurgen * Greiner. Renamed JFreeChartPanel --> ChartPanel, moved * constants to ChartPanelConstants interface (DG); * 31-May-2002 : Fixed a bug with interactive zooming and added a way to * control if the zoom rectangle is filled in or drawn as an * outline. A mouse drag gesture towards the top left now causes * an autoRangeBoth() and is a way to undo zooms (AS); * 11-Jun-2002 : Reinstated handleClick method call in mouseClicked() to get * crosshairs working again (DG); * 13-Jun-2002 : Added check for null popup menu in mouseDragged method (DG); * 18-Jun-2002 : Added get/set methods for minimum and maximum chart * dimensions (DG); * 25-Jun-2002 : Removed redundant code (DG); * 27-Aug-2002 : Added get/set methods for popup menu (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 22-Oct-2002 : Added translation methods for screen <--> Java2D, contributed * by Daniel van Enckevort (DG); * 05-Nov-2002 : Added a chart reference to the ChartMouseEvent class (DG); * 22-Nov-2002 : Added test in zoom method for inverted axes, supplied by * David M O'Donnell (DG); * 14-Jan-2003 : Implemented ChartProgressListener interface (DG); * 14-Feb-2003 : Removed deprecated setGenerateTooltips method (DG); * 12-Mar-2003 : Added option to enforce filename extension (see bug id * 643173) (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 18-Sep-2003 : Added getScaleX() and getScaleY() methods (protected) as * requested by Irv Thomae (DG); * 12-Nov-2003 : Added zooming support for the FastScatterPlot class (DG); * 24-Nov-2003 : Minor Javadoc updates (DG); * 04-Dec-2003 : Added anchor point for crosshair calculation (DG); * 17-Jan-2004 : Added new methods to set tooltip delays to be used in this * chart panel. Refer to patch 877565 (MR); * 02-Feb-2004 : Fixed bug in zooming trigger and added zoomTriggerDistance * attribute (DG); * 08-Apr-2004 : Changed getScaleX() and getScaleY() from protected to * public (DG); * 15-Apr-2004 : Added zoomOutFactor and zoomInFactor (DG); * 21-Apr-2004 : Fixed zooming bug in mouseReleased() method (DG); * 13-Jul-2004 : Added check for null chart (DG); * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); * 11-Nov-2004 : Moved constants back in from ChartPanelConstants (DG); * 12-Nov-2004 : Modified zooming mechanism to support zooming within * subplots (DG); * 26-Jan-2005 : Fixed mouse zooming for horizontal category plots (DG); * 11-Apr-2005 : Added getFillZoomRectangle() method, renamed * setHorizontalZoom() --> setDomainZoomable(), * setVerticalZoom() --> setRangeZoomable(), added * isDomainZoomable() and isRangeZoomable(), added * getHorizontalAxisTrace() and getVerticalAxisTrace(), * renamed autoRangeBoth() --> restoreAutoBounds(), * autoRangeHorizontal() --> restoreAutoDomainBounds(), * autoRangeVertical() --> restoreAutoRangeBounds() (DG); * 12-Apr-2005 : Removed working areas, added getAnchorPoint() method, * added protected accessors for tracelines (DG); * 18-Apr-2005 : Made constants final (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 01-Jun-2005 : Fixed zooming for combined plots - see bug report * 1212039, fix thanks to Onno vd Akker (DG); * 25-Nov-2005 : Reworked event listener mechanism (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Aug-2006 : Fixed minor bug in restoreAutoRangeBounds() (DG); * 04-Sep-2006 : Renamed attemptEditChartProperties() --> * doEditChartProperties() and made public (DG); * 13-Sep-2006 : Don't generate ChartMouseEvents if the panel's chart is null * (fixes bug 1556951) (DG); * 05-Mar-2007 : Applied patch 1672561 by Sergei Ivanov, to fix zoom rectangle * drawing for dynamic charts (DG); * 17-Apr-2007 : Fix NullPointerExceptions in zooming for combined plots (DG); * 24-May-2007 : When the look-and-feel changes, update the popup menu if there * is one (DG); * 06-Jun-2007 : Fixed coordinates for drawing buffer image (DG); * 24-Sep-2007 : Added zoomAroundAnchor flag, and handle clearing of chart * buffer (DG); * 25-Oct-2007 : Added default directory attribute (DG); * 07-Nov-2007 : Fixed (rare) bug in refreshing off-screen image (DG); * 07-May-2008 : Fixed bug in zooming that triggered zoom for a rectangle * outside of the data area (DG); * 08-May-2008 : Fixed serialization bug (DG); * 15-Aug-2008 : Increased default maxDrawWidth/Height (DG); * 18-Sep-2008 : Modified creation of chart buffer (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 13-Jan-2009 : Fixed zooming methods to trigger only one plot * change event (DG); * 16-Jan-2009 : Use XOR for zoom rectangle only if useBuffer is false (DG); * 18-Mar-2009 : Added mouse wheel support (DG); * 19-Mar-2009 : Added panning on mouse drag support - based on Ulrich * Voigt's patch 2686040 (DG); * 26-Mar-2009 : Changed fillZoomRectangle default to true, and only change * cursor for CTRL-mouse-click if panning is enabled (DG); * 01-Apr-2009 : Fixed panning, and added different mouse event mask for * MacOSX (DG); * 08-Apr-2009 : Added copy to clipboard support, based on patch 1460845 * by Alessandro Borges (DG); * 09-Apr-2009 : Added overlay support (DG); * 10-Apr-2009 : Set chartBuffer background to match ChartPanel (DG); * */ package org.jfree.chart; import java.awt.AWTEvent; import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Insets; import java.awt.Paint; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Transparency; import java.awt.datatransfer.Clipboard; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.File; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.EventListener; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import javax.swing.JFileChooser; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; import javax.swing.event.EventListenerList; import org.jfree.chart.editor.ChartEditor; import org.jfree.chart.editor.ChartEditorManager; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.event.ChartProgressEvent; import org.jfree.chart.event.ChartProgressListener; import org.jfree.chart.panel.Overlay; import org.jfree.chart.event.OverlayChangeEvent; import org.jfree.chart.event.OverlayChangeListener; import org.jfree.chart.plot.Pannable; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.Zoomable; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.io.SerialUtilities; import org.jfree.ui.ExtensionFileFilter; /** * A Swing GUI component for displaying a {@link JFreeChart} object. *

* The panel registers with the chart to receive notification of changes to any * component of the chart. The chart is redrawn automatically whenever this * notification is received. */ public class ChartPanel extends JPanel implements ChartChangeListener, ChartProgressListener, ActionListener, MouseListener, MouseMotionListener, OverlayChangeListener, Printable, Serializable { /** For serialization. */ private static final long serialVersionUID = 6046366297214274674L; /** * Default setting for buffer usage. The default has been changed to * true from version 1.0.13 onwards, because of a severe * performance problem with drawing the zoom rectangle using XOR (which * now happens only when the buffer is NOT used). */ public static final boolean DEFAULT_BUFFER_USED = true; /** The default panel width. */ public static final int DEFAULT_WIDTH = 680; /** The default panel height. */ public static final int DEFAULT_HEIGHT = 420; /** The default limit below which chart scaling kicks in. */ public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300; /** The default limit below which chart scaling kicks in. */ public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; /** The default limit above which chart scaling kicks in. */ public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 1024; /** The default limit above which chart scaling kicks in. */ public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 768; /** The minimum size required to perform a zoom on a rectangle */ public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; /** Properties action command. */ public static final String PROPERTIES_COMMAND = "PROPERTIES"; /** * Copy action command. * * @since 1.0.13 */ public static final String COPY_COMMAND = "COPY"; /** Save action command. */ public static final String SAVE_COMMAND = "SAVE"; /** Print action command. */ public static final String PRINT_COMMAND = "PRINT"; /** Zoom in (both axes) action command. */ public static final String ZOOM_IN_BOTH_COMMAND = "ZOOM_IN_BOTH"; /** Zoom in (domain axis only) action command. */ public static final String ZOOM_IN_DOMAIN_COMMAND = "ZOOM_IN_DOMAIN"; /** Zoom in (range axis only) action command. */ public static final String ZOOM_IN_RANGE_COMMAND = "ZOOM_IN_RANGE"; /** Zoom out (both axes) action command. */ public static final String ZOOM_OUT_BOTH_COMMAND = "ZOOM_OUT_BOTH"; /** Zoom out (domain axis only) action command. */ public static final String ZOOM_OUT_DOMAIN_COMMAND = "ZOOM_DOMAIN_BOTH"; /** Zoom out (range axis only) action command. */ public static final String ZOOM_OUT_RANGE_COMMAND = "ZOOM_RANGE_BOTH"; /** Zoom reset (both axes) action command. */ public static final String ZOOM_RESET_BOTH_COMMAND = "ZOOM_RESET_BOTH"; /** Zoom reset (domain axis only) action command. */ public static final String ZOOM_RESET_DOMAIN_COMMAND = "ZOOM_RESET_DOMAIN"; /** Zoom reset (range axis only) action command. */ public static final String ZOOM_RESET_RANGE_COMMAND = "ZOOM_RESET_RANGE"; /** The chart that is displayed in the panel. */ private JFreeChart chart; /** Storage for registered (chart) mouse listeners. */ private transient EventListenerList chartMouseListeners; /** A flag that controls whether or not the off-screen buffer is used. */ private boolean useBuffer; /** A flag that indicates that the buffer should be refreshed. */ private boolean refreshBuffer; /** A buffer for the rendered chart. */ private transient Image chartBuffer; /** The height of the chart buffer. */ private int chartBufferHeight; /** The width of the chart buffer. */ private int chartBufferWidth; /** * The minimum width for drawing a chart (uses scaling for smaller widths). */ private int minimumDrawWidth; /** * The minimum height for drawing a chart (uses scaling for smaller * heights). */ private int minimumDrawHeight; /** * The maximum width for drawing a chart (uses scaling for bigger * widths). */ private int maximumDrawWidth; /** * The maximum height for drawing a chart (uses scaling for bigger * heights). */ private int maximumDrawHeight; /** The popup menu for the frame. */ private JPopupMenu popup; /** The drawing info collected the last time the chart was drawn. */ private ChartRenderingInfo info; /** The chart anchor point. */ private Point2D anchor; /** The scale factor used to draw the chart. */ private double scaleX; /** The scale factor used to draw the chart. */ private double scaleY; /** The plot orientation. */ private PlotOrientation orientation = PlotOrientation.VERTICAL; /** A flag that controls whether or not domain zooming is enabled. */ private boolean domainZoomable = false; /** A flag that controls whether or not range zooming is enabled. */ private boolean rangeZoomable = false; /** * The zoom rectangle starting point (selected by the user with a mouse * click). This is a point on the screen, not the chart (which may have * been scaled up or down to fit the panel). */ private Point2D zoomPoint = null; /** The zoom rectangle (selected by the user with the mouse). */ private transient Rectangle2D zoomRectangle = null; /** Controls if the zoom rectangle is drawn as an outline or filled. */ private boolean fillZoomRectangle = true; /** The minimum distance required to drag the mouse to trigger a zoom. */ private int zoomTriggerDistance; /** A flag that controls whether or not horizontal tracing is enabled. */ private boolean horizontalAxisTrace = false; /** A flag that controls whether or not vertical tracing is enabled. */ private boolean verticalAxisTrace = false; /** A vertical trace line. */ private transient Line2D verticalTraceLine; /** A horizontal trace line. */ private transient Line2D horizontalTraceLine; /** Menu item for zooming in on a chart (both axes). */ private JMenuItem zoomInBothMenuItem; /** Menu item for zooming in on a chart (domain axis). */ private JMenuItem zoomInDomainMenuItem; /** Menu item for zooming in on a chart (range axis). */ private JMenuItem zoomInRangeMenuItem; /** Menu item for zooming out on a chart. */ private JMenuItem zoomOutBothMenuItem; /** Menu item for zooming out on a chart (domain axis). */ private JMenuItem zoomOutDomainMenuItem; /** Menu item for zooming out on a chart (range axis). */ private JMenuItem zoomOutRangeMenuItem; /** Menu item for resetting the zoom (both axes). */ private JMenuItem zoomResetBothMenuItem; /** Menu item for resetting the zoom (domain axis only). */ private JMenuItem zoomResetDomainMenuItem; /** Menu item for resetting the zoom (range axis only). */ private JMenuItem zoomResetRangeMenuItem; /** * The default directory for saving charts to file. * * @since 1.0.7 */ private File defaultDirectoryForSaveAs; /** A flag that controls whether or not file extensions are enforced. */ private boolean enforceFileExtensions; /** A flag that indicates if original tooltip delays are changed. */ private boolean ownToolTipDelaysActive; /** Original initial tooltip delay of ToolTipManager.sharedInstance(). */ private int originalToolTipInitialDelay; /** Original reshow tooltip delay of ToolTipManager.sharedInstance(). */ private int originalToolTipReshowDelay; /** Original dismiss tooltip delay of ToolTipManager.sharedInstance(). */ private int originalToolTipDismissDelay; /** Own initial tooltip delay to be used in this chart panel. */ private int ownToolTipInitialDelay; /** Own reshow tooltip delay to be used in this chart panel. */ private int ownToolTipReshowDelay; /** Own dismiss tooltip delay to be used in this chart panel. */ private int ownToolTipDismissDelay; /** The factor used to zoom in on an axis range. */ private double zoomInFactor = 0.5; /** The factor used to zoom out on an axis range. */ private double zoomOutFactor = 2.0; /** * A flag that controls whether zoom operations are centred on the * current anchor point, or the centre point of the relevant axis. * * @since 1.0.7 */ private boolean zoomAroundAnchor; /** * The paint used to draw the zoom rectangle outline. * * @since 1.0.13 */ private transient Paint zoomOutlinePaint; /** * The zoom fill paint (should use transparency). * * @since 1.0.13 */ private transient Paint zoomFillPaint; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.LocalizationBundle"); /** * Temporary storage for the width and height of the chart * drawing area during panning. */ private double panW, panH; /** The last mouse position during panning. */ private Point panLast; /** * The mask for mouse events to trigger panning. * * @since 1.0.13 */ private int panMask = InputEvent.CTRL_MASK; /** * A list of overlays for the panel. * * @since 1.0.13 */ private List overlays; /** * Constructs a panel that displays the specified chart. * * @param chart the chart. */ public ChartPanel(JFreeChart chart) { this( chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_BUFFER_USED, true, // properties true, // save true, // print true, // zoom true // tooltips ); } /** * Constructs a panel containing a chart. The useBuffer flag * controls whether or not an offscreen BufferedImage is * maintained for the chart. If the buffer is used, more memory is * consumed, but panel repaints will be a lot quicker in cases where the * chart itself hasn't changed (for example, when another frame is moved * to reveal the panel). WARNING: If you set the useBuffer * flag to false, note that the mouse zooming rectangle will (in that case) * be drawn using XOR, and there is a SEVERE performance problem with that * on JRE6 on Windows. * * @param chart the chart. * @param useBuffer a flag controlling whether or not an off-screen buffer * is used (read the warning above before setting this * to false). */ public ChartPanel(JFreeChart chart, boolean useBuffer) { this(chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, useBuffer, true, // properties true, // save true, // print true, // zoom true // tooltips ); } /** * Constructs a JFreeChart panel. * * @param chart the chart. * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should * be added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. */ public ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) { this(chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_BUFFER_USED, properties, save, print, zoom, tooltips ); } /** * Constructs a JFreeChart panel. * * @param chart the chart. * @param width the preferred width of the panel. * @param height the preferred height of the panel. * @param minimumDrawWidth the minimum drawing width. * @param minimumDrawHeight the minimum drawing height. * @param maximumDrawWidth the maximum drawing width. * @param maximumDrawHeight the maximum drawing height. * @param useBuffer a flag that indicates whether to use the off-screen * buffer to improve performance (at the expense of * memory). * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should be * added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. */ public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) { this(chart, width, height, minimumDrawWidth, minimumDrawHeight, maximumDrawWidth, maximumDrawHeight, useBuffer, properties, true, save, print, zoom, tooltips); } /** * Constructs a JFreeChart panel. * * @param chart the chart. * @param width the preferred width of the panel. * @param height the preferred height of the panel. * @param minimumDrawWidth the minimum drawing width. * @param minimumDrawHeight the minimum drawing height. * @param maximumDrawWidth the maximum drawing width. * @param maximumDrawHeight the maximum drawing height. * @param useBuffer a flag that indicates whether to use the off-screen * buffer to improve performance (at the expense of * memory). * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param copy a flag indicating whether or not a copy option should be * available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should be * added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. * * @since 1.0.13 */ public ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean copy, boolean save, boolean print, boolean zoom, boolean tooltips) { setChart(chart); this.chartMouseListeners = new EventListenerList(); this.info = new ChartRenderingInfo(); setPreferredSize(new Dimension(width, height)); this.useBuffer = useBuffer; this.refreshBuffer = false; this.minimumDrawWidth = minimumDrawWidth; this.minimumDrawHeight = minimumDrawHeight; this.maximumDrawWidth = maximumDrawWidth; this.maximumDrawHeight = maximumDrawHeight; this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; // set up popup menu... this.popup = null; if (properties || copy || save || print || zoom) { this.popup = createPopupMenu(properties, copy, save, print, zoom); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); setDisplayToolTips(tooltips); addMouseListener(this); addMouseMotionListener(this); this.defaultDirectoryForSaveAs = null; this.enforceFileExtensions = true; // initialize ChartPanel-specific tool tip delays with // values the from ToolTipManager.sharedInstance() ToolTipManager ttm = ToolTipManager.sharedInstance(); this.ownToolTipInitialDelay = ttm.getInitialDelay(); this.ownToolTipDismissDelay = ttm.getDismissDelay(); this.ownToolTipReshowDelay = ttm.getReshowDelay(); this.zoomAroundAnchor = false; this.zoomOutlinePaint = Color.blue; this.zoomFillPaint = new Color(0, 0, 255, 63); this.panMask = InputEvent.CTRL_MASK; // for MacOSX we can't use the CTRL key for mouse drags, see: // http://developer.apple.com/qa/qa2004/qa1362.html String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("mac os x")) { this.panMask = InputEvent.ALT_MASK; } this.overlays = new java.util.ArrayList(); } /** * Returns the chart contained in the panel. * * @return The chart (possibly null). */ public JFreeChart getChart() { return this.chart; } /** * Sets the chart that is displayed in the panel. * * @param chart the chart (null permitted). */ public void setChart(JFreeChart chart) { // stop listening for changes to the existing chart if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } // add the new chart this.chart = chart; if (chart != null) { this.chart.addChangeListener(this); this.chart.addProgressListener(this); Plot plot = chart.getPlot(); this.domainZoomable = false; this.rangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = z.isDomainZoomable(); this.rangeZoomable = z.isRangeZoomable(); this.orientation = z.getOrientation(); } } else { this.domainZoomable = false; this.rangeZoomable = false; } if (this.useBuffer) { this.refreshBuffer = true; } repaint(); } /** * Returns the minimum drawing width for charts. *

* If the width available on the panel is less than this, then the chart is * drawn at the minimum width then scaled down to fit. * * @return The minimum drawing width. */ public int getMinimumDrawWidth() { return this.minimumDrawWidth; } /** * Sets the minimum drawing width for the chart on this panel. *

* At the time the chart is drawn on the panel, if the available width is * less than this amount, the chart will be drawn using the minimum width * then scaled down to fit the available space. * * @param width The width. */ public void setMinimumDrawWidth(int width) { this.minimumDrawWidth = width; } /** * Returns the maximum drawing width for charts. *

* If the width available on the panel is greater than this, then the chart * is drawn at the maximum width then scaled up to fit. * * @return The maximum drawing width. */ public int getMaximumDrawWidth() { return this.maximumDrawWidth; } /** * Sets the maximum drawing width for the chart on this panel. *

* At the time the chart is drawn on the panel, if the available width is * greater than this amount, the chart will be drawn using the maximum * width then scaled up to fit the available space. * * @param width The width. */ public void setMaximumDrawWidth(int width) { this.maximumDrawWidth = width; } /** * Returns the minimum drawing height for charts. *

* If the height available on the panel is less than this, then the chart * is drawn at the minimum height then scaled down to fit. * * @return The minimum drawing height. */ public int getMinimumDrawHeight() { return this.minimumDrawHeight; } /** * Sets the minimum drawing height for the chart on this panel. *

* At the time the chart is drawn on the panel, if the available height is * less than this amount, the chart will be drawn using the minimum height * then scaled down to fit the available space. * * @param height The height. */ public void setMinimumDrawHeight(int height) { this.minimumDrawHeight = height; } /** * Returns the maximum drawing height for charts. *

* If the height available on the panel is greater than this, then the * chart is drawn at the maximum height then scaled up to fit. * * @return The maximum drawing height. */ public int getMaximumDrawHeight() { return this.maximumDrawHeight; } /** * Sets the maximum drawing height for the chart on this panel. *

* At the time the chart is drawn on the panel, if the available height is * greater than this amount, the chart will be drawn using the maximum * height then scaled up to fit the available space. * * @param height The height. */ public void setMaximumDrawHeight(int height) { this.maximumDrawHeight = height; } /** * Returns the X scale factor for the chart. This will be 1.0 if no * scaling has been used. * * @return The scale factor. */ public double getScaleX() { return this.scaleX; } /** * Returns the Y scale factory for the chart. This will be 1.0 if no * scaling has been used. * * @return The scale factor. */ public double getScaleY() { return this.scaleY; } /** * Returns the anchor point. * * @return The anchor point (possibly null). */ public Point2D getAnchor() { return this.anchor; } /** * Sets the anchor point. This method is provided for the use of * subclasses, not end users. * * @param anchor the anchor point (null permitted). */ protected void setAnchor(Point2D anchor) { this.anchor = anchor; } /** * Returns the popup menu. * * @return The popup menu. */ public JPopupMenu getPopupMenu() { return this.popup; } /** * Sets the popup menu for the panel. * * @param popup the popup menu (null permitted). */ public void setPopupMenu(JPopupMenu popup) { this.popup = popup; } /** * Returns the chart rendering info from the most recent chart redraw. * * @return The chart rendering info. */ public ChartRenderingInfo getChartRenderingInfo() { return this.info; } /** * A convenience method that switches on mouse-based zooming. * * @param flag true enables zooming and rectangle fill on * zoom. */ public void setMouseZoomable(boolean flag) { setMouseZoomable(flag, true); } /** * A convenience method that switches on mouse-based zooming. * * @param flag true if zooming enabled * @param fillRectangle true if zoom rectangle is filled, * false if rectangle is shown as outline only. */ public void setMouseZoomable(boolean flag, boolean fillRectangle) { setDomainZoomable(flag); setRangeZoomable(flag); setFillZoomRectangle(fillRectangle); } /** * Returns the flag that determines whether or not zooming is enabled for * the domain axis. * * @return A boolean. */ public boolean isDomainZoomable() { return this.domainZoomable; } /** * Sets the flag that controls whether or not zooming is enable for the * domain axis. A check is made to ensure that the current plot supports * zooming for the domain values. * * @param flag true enables zooming if possible. */ public void setDomainZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = flag && (z.isDomainZoomable()); } } else { this.domainZoomable = false; } } /** * Returns the flag that determines whether or not zooming is enabled for * the range axis. * * @return A boolean. */ public boolean isRangeZoomable() { return this.rangeZoomable; } /** * A flag that controls mouse-based zooming on the vertical axis. * * @param flag true enables zooming. */ public void setRangeZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.rangeZoomable = flag && (z.isRangeZoomable()); } } else { this.rangeZoomable = false; } } /** * Returns the flag that controls whether or not the zoom rectangle is * filled when drawn. * * @return A boolean. */ public boolean getFillZoomRectangle() { return this.fillZoomRectangle; } /** * A flag that controls how the zoom rectangle is drawn. * * @param flag true instructs to fill the rectangle on * zoom, otherwise it will be outlined. */ public void setFillZoomRectangle(boolean flag) { this.fillZoomRectangle = flag; } /** * Returns the zoom trigger distance. This controls how far the mouse must * move before a zoom action is triggered. * * @return The distance (in Java2D units). */ public int getZoomTriggerDistance() { return this.zoomTriggerDistance; } /** * Sets the zoom trigger distance. This controls how far the mouse must * move before a zoom action is triggered. * * @param distance the distance (in Java2D units). */ public void setZoomTriggerDistance(int distance) { this.zoomTriggerDistance = distance; } /** * Returns the flag that controls whether or not a horizontal axis trace * line is drawn over the plot area at the current mouse location. * * @return A boolean. */ public boolean getHorizontalAxisTrace() { return this.horizontalAxisTrace; } /** * A flag that controls trace lines on the horizontal axis. * * @param flag true enables trace lines for the mouse * pointer on the horizontal axis. */ public void setHorizontalAxisTrace(boolean flag) { this.horizontalAxisTrace = flag; } /** * Returns the horizontal trace line. * * @return The horizontal trace line (possibly null). */ protected Line2D getHorizontalTraceLine() { return this.horizontalTraceLine; } /** * Sets the horizontal trace line. * * @param line the line (null permitted). */ protected void setHorizontalTraceLine(Line2D line) { this.horizontalTraceLine = line; } /** * Returns the flag that controls whether or not a vertical axis trace * line is drawn over the plot area at the current mouse location. * * @return A boolean. */ public boolean getVerticalAxisTrace() { return this.verticalAxisTrace; } /** * A flag that controls trace lines on the vertical axis. * * @param flag true enables trace lines for the mouse * pointer on the vertical axis. */ public void setVerticalAxisTrace(boolean flag) { this.verticalAxisTrace = flag; } /** * Returns the vertical trace line. * * @return The vertical trace line (possibly null). */ protected Line2D getVerticalTraceLine() { return this.verticalTraceLine; } /** * Sets the vertical trace line. * * @param line the line (null permitted). */ protected void setVerticalTraceLine(Line2D line) { this.verticalTraceLine = line; } /** * Returns the default directory for the "save as" option. * * @return The default directory (possibly null). * * @since 1.0.7 */ public File getDefaultDirectoryForSaveAs() { return this.defaultDirectoryForSaveAs; } /** * Sets the default directory for the "save as" option. If you set this * to null, the user's default directory will be used. * * @param directory the directory (null permitted). * * @since 1.0.7 */ public void setDefaultDirectoryForSaveAs(File directory) { if (directory != null) { if (!directory.isDirectory()) { throw new IllegalArgumentException( "The 'directory' argument is not a directory."); } } this.defaultDirectoryForSaveAs = directory; } /** * Returns true if file extensions should be enforced, and * false otherwise. * * @return The flag. * * @see #setEnforceFileExtensions(boolean) */ public boolean isEnforceFileExtensions() { return this.enforceFileExtensions; } /** * Sets a flag that controls whether or not file extensions are enforced. * * @param enforce the new flag value. * * @see #isEnforceFileExtensions() */ public void setEnforceFileExtensions(boolean enforce) { this.enforceFileExtensions = enforce; } /** * Returns the flag that controls whether or not zoom operations are * centered around the current anchor point. * * @return A boolean. * * @since 1.0.7 * * @see #setZoomAroundAnchor(boolean) */ public boolean getZoomAroundAnchor() { return this.zoomAroundAnchor; } /** * Sets the flag that controls whether or not zoom operations are * centered around the current anchor point. * * @param zoomAroundAnchor the new flag value. * * @since 1.0.7 * * @see #getZoomAroundAnchor() */ public void setZoomAroundAnchor(boolean zoomAroundAnchor) { this.zoomAroundAnchor = zoomAroundAnchor; } /** * Returns the zoom rectangle fill paint. * * @return The zoom rectangle fill paint (never null). * * @see #setZoomFillPaint(java.awt.Paint) * @see #setFillZoomRectangle(boolean) * * @since 1.0.13 */ public Paint getZoomFillPaint() { return this.zoomFillPaint; } /** * Sets the zoom rectangle fill paint. * * @param paint the paint (null not permitted). * * @see #getZoomFillPaint() * @see #getFillZoomRectangle() * * @since 1.0.13 */ public void setZoomFillPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.zoomFillPaint = paint; } /** * Returns the zoom rectangle outline paint. * * @return The zoom rectangle outline paint (never null). * * @see #setZoomOutlinePaint(java.awt.Paint) * @see #setFillZoomRectangle(boolean) * * @since 1.0.13 */ public Paint getZoomOutlinePaint() { return this.zoomOutlinePaint; } /** * Sets the zoom rectangle outline paint. * * @param paint the paint (null not permitted). * * @see #getZoomOutlinePaint() * @see #getFillZoomRectangle() * * @since 1.0.13 */ public void setZoomOutlinePaint(Paint paint) { this.zoomOutlinePaint = paint; } /** * The mouse wheel handler. This will be an instance of MouseWheelHandler * but we can't reference that class directly because it depends on JRE 1.4 * and we still want to support JRE 1.3.1. */ private Object mouseWheelHandler; /** * Returns true if the mouse wheel handler is enabled, and * false otherwise. * * @return A boolean. * * @since 1.0.13 */ public boolean isMouseWheelEnabled() { return this.mouseWheelHandler != null; } /** * Enables or disables mouse wheel support for the panel. * Note that this method does nothing when running JFreeChart on JRE 1.3.1, * because that older version of the Java runtime does not support * mouse wheel events. * * @param flag a boolean. * * @since 1.0.13 */ public void setMouseWheelEnabled(boolean flag) { if (flag && this.mouseWheelHandler == null) { // use reflection to instantiate a mouseWheelHandler because to // continue supporting JRE 1.3.1 we cannot depend on the // MouseWheelListener interface directly try { Class c = Class.forName("org.jfree.chart.MouseWheelHandler"); Constructor cc = c.getConstructor(new Class[] { ChartPanel.class}); Object mwh = cc.newInstance(new Object[] {this}); this.mouseWheelHandler = mwh; } catch (ClassNotFoundException e) { // the class isn't there, so we must have compiled JFreeChart // with JDK 1.3.1 - thus, we can't have mouse wheel support } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } else { if (this.mouseWheelHandler != null) { // use reflection to deregister the mouseWheelHandler try { Class mwl = Class.forName( "java.awt.event.MouseWheelListener"); Class c2 = ChartPanel.class; Method m = c2.getMethod("removeMouseWheelListener", new Class[] {mwl}); m.invoke(this, new Object[] {this.mouseWheelHandler}); } catch (ClassNotFoundException e) { // must be running on JRE 1.3.1, so just ignore this } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } /** * Add an overlay to the panel. * * @param overlay the overlay (null not permitted). * * @since 1.0.13 */ public void addOverlay(Overlay overlay) { if (overlay == null) { throw new IllegalArgumentException("Null 'overlay' argument."); } this.overlays.add(overlay); overlay.addChangeListener(this); repaint(); } /** * Removes an overlay from the panel. * * @param overlay the overlay to remove (null not permitted). * * @since 1.0.13 */ public void removeOverlay(Overlay overlay) { if (overlay == null) { throw new IllegalArgumentException("Null 'overlay' argument."); } boolean removed = this.overlays.remove(overlay); if (removed) { overlay.removeChangeListener(this); repaint(); } } /** * Handles a change to an overlay by repainting the panel. * * @param event the event. * * @since 1.0.13 */ public void overlayChanged(OverlayChangeEvent event) { repaint(); } /** * Switches the display of tooltips for the panel on or off. Note that * tooltips can only be displayed if the chart has been configured to * generate tooltip items. * * @param flag true to enable tooltips, false to * disable tooltips. */ public void setDisplayToolTips(boolean flag) { if (flag) { ToolTipManager.sharedInstance().registerComponent(this); } else { ToolTipManager.sharedInstance().unregisterComponent(this); } } /** * Returns a string for the tooltip. * * @param e the mouse event. * * @return A tool tip or null if no tooltip is available. */ public String getToolTipText(MouseEvent e) { String result = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { Insets insets = getInsets(); ChartEntity entity = entities.getEntity( (int) ((e.getX() - insets.left) / this.scaleX), (int) ((e.getY() - insets.top) / this.scaleY)); if (entity != null) { result = entity.getToolTipText(); } } } return result; } /** * Translates a Java2D point on the chart to a screen location. * * @param java2DPoint the Java2D point. * * @return The screen location. */ public Point translateJava2DToScreen(Point2D java2DPoint) { Insets insets = getInsets(); int x = (int) (java2DPoint.getX() * this.scaleX + insets.left); int y = (int) (java2DPoint.getY() * this.scaleY + insets.top); return new Point(x, y); } /** * Translates a panel (component) location to a Java2D point. * * @param screenPoint the screen location (null not * permitted). * * @return The Java2D coordinates. */ public Point2D translateScreenToJava2D(Point screenPoint) { Insets insets = getInsets(); double x = (screenPoint.getX() - insets.left) / this.scaleX; double y = (screenPoint.getY() - insets.top) / this.scaleY; return new Point2D.Double(x, y); } /** * Applies any scaling that is in effect for the chart drawing to the * given rectangle. * * @param rect the rectangle (null not permitted). * * @return A new scaled rectangle. */ public Rectangle2D scale(Rectangle2D rect) { Insets insets = getInsets(); double x = rect.getX() * getScaleX() + insets.left; double y = rect.getY() * getScaleY() + insets.top; double w = rect.getWidth() * getScaleX(); double h = rect.getHeight() * getScaleY(); return new Rectangle2D.Double(x, y, w, h); } /** * Returns the chart entity at a given point. *

* This method will return null if there is (a) no entity at the given * point, or (b) no entity collection has been generated. * * @param viewX the x-coordinate. * @param viewY the y-coordinate. * * @return The chart entity (possibly null). */ public ChartEntity getEntityForPoint(int viewX, int viewY) { ChartEntity result = null; if (this.info != null) { Insets insets = getInsets(); double x = (viewX - insets.left) / this.scaleX; double y = (viewY - insets.top) / this.scaleY; EntityCollection entities = this.info.getEntityCollection(); result = entities != null ? entities.getEntity(x, y) : null; } return result; } /** * Returns the flag that controls whether or not the offscreen buffer * needs to be refreshed. * * @return A boolean. */ public boolean getRefreshBuffer() { return this.refreshBuffer; } /** * Sets the refresh buffer flag. This flag is used to avoid unnecessary * redrawing of the chart when the offscreen image buffer is used. * * @param flag true indicates that the buffer should be * refreshed. */ public void setRefreshBuffer(boolean flag) { this.refreshBuffer = flag; } /** * Paints the component by drawing the chart to fill the entire component, * but allowing for the insets (which will be non-zero if a border has been * set for this component). To increase performance (at the expense of * memory), an off-screen buffer image can be used. * * @param g the graphics device for drawing on. */ public void paintComponent(Graphics g) { super.paintComponent(g); if (this.chart == null) { return; } Graphics2D g2 = (Graphics2D) g.create(); // first determine the size of the chart rendering area... Dimension size = getSize(); Insets insets = getInsets(); Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); // work out if scaling is required... boolean scale = false; double drawWidth = available.getWidth(); double drawHeight = available.getHeight(); this.scaleX = 1.0; this.scaleY = 1.0; if (drawWidth < this.minimumDrawWidth) { this.scaleX = drawWidth / this.minimumDrawWidth; drawWidth = this.minimumDrawWidth; scale = true; } else if (drawWidth > this.maximumDrawWidth) { this.scaleX = drawWidth / this.maximumDrawWidth; drawWidth = this.maximumDrawWidth; scale = true; } if (drawHeight < this.minimumDrawHeight) { this.scaleY = drawHeight / this.minimumDrawHeight; drawHeight = this.minimumDrawHeight; scale = true; } else if (drawHeight > this.maximumDrawHeight) { this.scaleY = drawHeight / this.maximumDrawHeight; drawHeight = this.maximumDrawHeight; scale = true; } Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, drawHeight); // are we using the chart buffer? if (this.useBuffer) { // do we need to resize the buffer? if ((this.chartBuffer == null) || (this.chartBufferWidth != available.getWidth()) || (this.chartBufferHeight != available.getHeight())) { this.chartBufferWidth = (int) available.getWidth(); this.chartBufferHeight = (int) available.getHeight(); GraphicsConfiguration gc = g2.getDeviceConfiguration(); this.chartBuffer = gc.createCompatibleImage( this.chartBufferWidth, this.chartBufferHeight, Transparency.TRANSLUCENT); this.refreshBuffer = true; } // do we need to redraw the buffer? if (this.refreshBuffer) { this.refreshBuffer = false; // clear the flag Rectangle2D bufferArea = new Rectangle2D.Double( 0, 0, this.chartBufferWidth, this.chartBufferHeight); Graphics2D bufferG2 = (Graphics2D) this.chartBuffer.getGraphics(); Rectangle r = new Rectangle(0, 0, this.chartBufferWidth, this.chartBufferHeight); bufferG2.setPaint(getBackground()); bufferG2.fill(r); if (scale) { AffineTransform saved = bufferG2.getTransform(); AffineTransform st = AffineTransform.getScaleInstance( this.scaleX, this.scaleY); bufferG2.transform(st); this.chart.draw(bufferG2, chartArea, this.anchor, this.info); bufferG2.setTransform(saved); } else { this.chart.draw(bufferG2, bufferArea, this.anchor, this.info); } } // zap the buffer onto the panel... g2.drawImage(this.chartBuffer, insets.left, insets.top, this); } // or redrawing the chart every time... else { AffineTransform saved = g2.getTransform(); g2.translate(insets.left, insets.top); if (scale) { AffineTransform st = AffineTransform.getScaleInstance( this.scaleX, this.scaleY); g2.transform(st); } this.chart.draw(g2, chartArea, this.anchor, this.info); g2.setTransform(saved); } Iterator iterator = this.overlays.iterator(); while (iterator.hasNext()) { Overlay overlay = (Overlay) iterator.next(); overlay.paintOverlay(g2, this); } // redraw the zoom rectangle (if present) - if useBuffer is false, // we use XOR so we can XOR the rectangle away again without redrawing // the chart drawZoomRectangle(g2, !this.useBuffer); g2.dispose(); this.anchor = null; this.verticalTraceLine = null; this.horizontalTraceLine = null; } /** * Receives notification of changes to the chart, and redraws the chart. * * @param event details of the chart change event. */ public void chartChanged(ChartChangeEvent event) { this.refreshBuffer = true; Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.orientation = z.getOrientation(); } repaint(); } /** * Receives notification of a chart progress event. * * @param event the event. */ public void chartProgress(ChartProgressEvent event) { // does nothing - override if necessary } /** * Handles action events generated by the popup menu. * * @param event the event. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); // many of the zoom methods need a screen location - all we have is // the zoomPoint, but it might be null. Here we grab the x and y // coordinates, or use defaults... double screenX = -1.0; double screenY = -1.0; if (this.zoomPoint != null) { screenX = this.zoomPoint.getX(); screenY = this.zoomPoint.getY(); } if (command.equals(PROPERTIES_COMMAND)) { doEditChartProperties(); } else if (command.equals(COPY_COMMAND)) { doCopy(); } else if (command.equals(SAVE_COMMAND)) { try { doSaveAs(); } catch (IOException e) { e.printStackTrace(); } } else if (command.equals(PRINT_COMMAND)) { createChartPrintJob(); } else if (command.equals(ZOOM_IN_BOTH_COMMAND)) { zoomInBoth(screenX, screenY); } else if (command.equals(ZOOM_IN_DOMAIN_COMMAND)) { zoomInDomain(screenX, screenY); } else if (command.equals(ZOOM_IN_RANGE_COMMAND)) { zoomInRange(screenX, screenY); } else if (command.equals(ZOOM_OUT_BOTH_COMMAND)) { zoomOutBoth(screenX, screenY); } else if (command.equals(ZOOM_OUT_DOMAIN_COMMAND)) { zoomOutDomain(screenX, screenY); } else if (command.equals(ZOOM_OUT_RANGE_COMMAND)) { zoomOutRange(screenX, screenY); } else if (command.equals(ZOOM_RESET_BOTH_COMMAND)) { restoreAutoBounds(); } else if (command.equals(ZOOM_RESET_DOMAIN_COMMAND)) { restoreAutoDomainBounds(); } else if (command.equals(ZOOM_RESET_RANGE_COMMAND)) { restoreAutoRangeBounds(); } } /** * Handles a 'mouse entered' event. This method changes the tooltip delays * of ToolTipManager.sharedInstance() to the possibly different values set * for this chart panel. * * @param e the mouse event. */ public void mouseEntered(MouseEvent e) { if (!this.ownToolTipDelaysActive) { ToolTipManager ttm = ToolTipManager.sharedInstance(); this.originalToolTipInitialDelay = ttm.getInitialDelay(); ttm.setInitialDelay(this.ownToolTipInitialDelay); this.originalToolTipReshowDelay = ttm.getReshowDelay(); ttm.setReshowDelay(this.ownToolTipReshowDelay); this.originalToolTipDismissDelay = ttm.getDismissDelay(); ttm.setDismissDelay(this.ownToolTipDismissDelay); this.ownToolTipDelaysActive = true; } } /** * Handles a 'mouse exited' event. This method resets the tooltip delays of * ToolTipManager.sharedInstance() to their * original values in effect before mouseEntered() * * @param e the mouse event. */ public void mouseExited(MouseEvent e) { if (this.ownToolTipDelaysActive) { // restore original tooltip dealys ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.setInitialDelay(this.originalToolTipInitialDelay); ttm.setReshowDelay(this.originalToolTipReshowDelay); ttm.setDismissDelay(this.originalToolTipDismissDelay); this.ownToolTipDelaysActive = false; } } /** * Handles a 'mouse pressed' event. *

* This event is the popup trigger on Unix/Linux. For Windows, the popup * trigger is the 'mouse released' event. * * @param e The mouse event. */ public void mousePressed(MouseEvent e) { Plot plot = this.chart.getPlot(); int mods = e.getModifiers(); if ((mods & this.panMask) == this.panMask) { // can we pan this plot? if (plot instanceof Pannable) { Pannable pannable = (Pannable) plot; if (pannable.isDomainPannable() || pannable.isRangePannable()) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null && screenDataArea.contains( e.getPoint())) { this.panW = screenDataArea.getWidth(); this.panH = screenDataArea.getHeight(); this.panLast = e.getPoint(); setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } } // the actual panning occurs later in the mouseDragged() // method } } else if (this.zoomRectangle == null) { Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); if (screenDataArea != null) { this.zoomPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea); } else { this.zoomPoint = null; } if (e.isPopupTrigger()) { if (this.popup != null) { displayPopupMenu(e.getX(), e.getY()); } } } } /** * Returns a point based on (x, y) but constrained to be within the bounds * of the given rectangle. This method could be moved to JCommon. * * @param x the x-coordinate. * @param y the y-coordinate. * @param area the rectangle (null not permitted). * * @return A point within the rectangle. */ private Point2D getPointInRectangle(int x, int y, Rectangle2D area) { double xx = Math.max(area.getMinX(), Math.min(x, area.getMaxX())); double yy = Math.max(area.getMinY(), Math.min(y, area.getMaxY())); return new Point2D.Double(xx, yy); } /** * Handles a 'mouse dragged' event. * * @param e the mouse event. */ public void mouseDragged(MouseEvent e) { // if the popup menu has already been triggered, then ignore dragging... if (this.popup != null && this.popup.isShowing()) { return; } // handle panning if we have a start point if (this.panLast != null) { double dx = e.getX() - this.panLast.getX(); double dy = e.getY() - this.panLast.getY(); if (dx == 0.0 && dy == 0.0) { return; } double wPercent = -dx / this.panW; double hPercent = dy / this.panH; boolean old = this.chart.getPlot().isNotify(); this.chart.getPlot().setNotify(false); Pannable p = (Pannable) this.chart.getPlot(); if (p.getOrientation() == PlotOrientation.VERTICAL) { p.panDomainAxes(wPercent, this.info.getPlotInfo(), this.panLast); p.panRangeAxes(hPercent, this.info.getPlotInfo(), this.panLast); } else { p.panDomainAxes(hPercent, this.info.getPlotInfo(), this.panLast); p.panRangeAxes(wPercent, this.info.getPlotInfo(), this.panLast); } this.panLast = e.getPoint(); this.chart.getPlot().setNotify(old); return; } // if no initial zoom point was set, ignore dragging... if (this.zoomPoint == null) { return; } Graphics2D g2 = (Graphics2D) getGraphics(); // erase the previous zoom rectangle (if any). We only need to do // this is we are using XOR mode, which we do when we're not using // the buffer (if there is a buffer, then at the end of this method we // just trigger a repaint) if (!this.useBuffer) { drawZoomRectangle(g2, true); } boolean hZoom = false; boolean vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } Rectangle2D scaledDataArea = getScreenDataArea( (int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); this.zoomRectangle = new Rectangle2D.Double( this.zoomPoint.getX(), this.zoomPoint.getY(), xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY()); } else if (hZoom) { double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); this.zoomRectangle = new Rectangle2D.Double( this.zoomPoint.getX(), scaledDataArea.getMinY(), xmax - this.zoomPoint.getX(), scaledDataArea.getHeight()); } else if (vZoom) { double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); this.zoomRectangle = new Rectangle2D.Double( scaledDataArea.getMinX(), this.zoomPoint.getY(), scaledDataArea.getWidth(), ymax - this.zoomPoint.getY()); } // Draw the new zoom rectangle... if (this.useBuffer) { repaint(); } else { // with no buffer, we use XOR to draw the rectangle "over" the // chart... drawZoomRectangle(g2, true); } g2.dispose(); } /** * Handles a 'mouse released' event. On Windows, we need to check if this * is a popup trigger, but only if we haven't already been tracking a zoom * rectangle. * * @param e information about the event. */ public void mouseReleased(MouseEvent e) { // if we've been panning, we need to reset now that the mouse is // released... if (this.panLast != null) { this.panLast = null; setCursor(Cursor.getDefaultCursor()); } else if (this.zoomRectangle != null) { boolean hZoom = false; boolean vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance; boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance; if (zoomTrigger1 || zoomTrigger2) { if ((hZoom && (e.getX() < this.zoomPoint.getX())) || (vZoom && (e.getY() < this.zoomPoint.getY()))) { restoreAutoBounds(); } else { double x, y, w, h; Rectangle2D screenDataArea = getScreenDataArea( (int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); double maxX = screenDataArea.getMaxX(); double maxY = screenDataArea.getMaxY(); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { x = this.zoomPoint.getX(); y = screenDataArea.getMinY(); w = Math.min(this.zoomRectangle.getWidth(), maxX - this.zoomPoint.getX()); h = screenDataArea.getHeight(); } else if (!hZoom) { x = screenDataArea.getMinX(); y = this.zoomPoint.getY(); w = screenDataArea.getWidth(); h = Math.min(this.zoomRectangle.getHeight(), maxY - this.zoomPoint.getY()); } else { x = this.zoomPoint.getX(); y = this.zoomPoint.getY(); w = Math.min(this.zoomRectangle.getWidth(), maxX - this.zoomPoint.getX()); h = Math.min(this.zoomRectangle.getHeight(), maxY - this.zoomPoint.getY()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); zoom(zoomArea); } this.zoomPoint = null; this.zoomRectangle = null; } else { // erase the zoom rectangle Graphics2D g2 = (Graphics2D) getGraphics(); if (this.useBuffer) { repaint(); } else { drawZoomRectangle(g2, true); } g2.dispose(); this.zoomPoint = null; this.zoomRectangle = null; } } else if (e.isPopupTrigger()) { if (this.popup != null) { displayPopupMenu(e.getX(), e.getY()); } } } /** * Receives notification of mouse clicks on the panel. These are * translated and passed on to any registered {@link ChartMouseListener}s. * * @param event Information about the mouse event. */ public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = (int) ((event.getX() - insets.left) / this.scaleX); int y = (int) ((event.getY() - insets.top) / this.scaleY); this.anchor = new Point2D.Double(x, y); if (this.chart == null) { return; } this.chart.setNotify(true); // force a redraw // new entity code... Object[] listeners = this.chartMouseListeners.getListeners( ChartMouseListener.class); if (listeners.length == 0) { return; } ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } } /** * Implementation of the MouseMotionListener's method. * * @param e the event. */ public void mouseMoved(MouseEvent e) { Graphics2D g2 = (Graphics2D) getGraphics(); if (this.horizontalAxisTrace) { drawHorizontalAxisTrace(g2, e.getX()); } if (this.verticalAxisTrace) { drawVerticalAxisTrace(g2, e.getY()); } g2.dispose(); Object[] listeners = this.chartMouseListeners.getListeners( ChartMouseListener.class); if (listeners.length == 0) { return; } Insets insets = getInsets(); int x = (int) ((e.getX() - insets.left) / this.scaleX); int y = (int) ((e.getY() - insets.top) / this.scaleY); ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } // we can only generate events if the panel's chart is not null // (see bug report 1556951) if (this.chart != null) { ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(event); } } } /** * Zooms in on an anchor point (specified in screen coordinate space). * * @param x the x value (in screen coordinates). * @param y the y value (in screen coordinates). */ public void zoomInBoth(double x, double y) { Plot plot = this.chart.getPlot(); if (plot == null) { return; } // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); zoomInDomain(x, y); zoomInRange(x, y); plot.setNotify(savedNotify); } /** * Decreases the length of the domain axis, centered about the given * coordinate on the screen. The length of the domain axis is reduced * by the value of {@link #getZoomInFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomInDomain(double x, double y) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); Zoomable z = (Zoomable) plot; z.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y)), this.zoomAroundAnchor); plot.setNotify(savedNotify); } } /** * Decreases the length of the range axis, centered about the given * coordinate on the screen. The length of the range axis is reduced by * the value of {@link #getZoomInFactor()}. * * @param x the x-coordinate (in screen coordinates). * @param y the y coordinate (in screen coordinates). */ public void zoomInRange(double x, double y) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); Zoomable z = (Zoomable) plot; z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y)), this.zoomAroundAnchor); plot.setNotify(savedNotify); } } /** * Zooms out on an anchor point (specified in screen coordinate space). * * @param x the x value (in screen coordinates). * @param y the y value (in screen coordinates). */ public void zoomOutBoth(double x, double y) { Plot plot = this.chart.getPlot(); if (plot == null) { return; } // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); zoomOutDomain(x, y); zoomOutRange(x, y); plot.setNotify(savedNotify); } /** * Increases the length of the domain axis, centered about the given * coordinate on the screen. The length of the domain axis is increased * by the value of {@link #getZoomOutFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomOutDomain(double x, double y) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); Zoomable z = (Zoomable) plot; z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y)), this.zoomAroundAnchor); plot.setNotify(savedNotify); } } /** * Increases the length the range axis, centered about the given * coordinate on the screen. The length of the range axis is increased * by the value of {@link #getZoomOutFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomOutRange(double x, double y) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); Zoomable z = (Zoomable) plot; z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y)), this.zoomAroundAnchor); plot.setNotify(savedNotify); } } /** * Zooms in on a selected region. * * @param selection the selected region. */ public void zoom(Rectangle2D selection) { // get the origin of the zoom selection in the Java2D space used for // drawing the chart (that is, before any scaling to fit the panel) Point2D selectOrigin = translateScreenToJava2D(new Point( (int) Math.ceil(selection.getX()), (int) Math.ceil(selection.getY()))); PlotRenderingInfo plotInfo = this.info.getPlotInfo(); Rectangle2D scaledDataArea = getScreenDataArea( (int) selection.getCenterX(), (int) selection.getCenterY()); if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) { double hLower = (selection.getMinX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) / scaledDataArea.getWidth(); double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) / scaledDataArea.getHeight(); double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) / scaledDataArea.getHeight(); Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = p.isNotify(); p.setNotify(false); Zoomable z = (Zoomable) p; if (z.getOrientation() == PlotOrientation.HORIZONTAL) { z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin); z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin); } else { z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin); z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin); } p.setNotify(savedNotify); } } } /** * Restores the auto-range calculation on both axes. */ public void restoreAutoBounds() { Plot plot = this.chart.getPlot(); if (plot == null) { return; } // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); restoreAutoDomainBounds(); restoreAutoRangeBounds(); plot.setNotify(savedNotify); } /** * Restores the auto-range calculation on the domain axis. */ public void restoreAutoDomainBounds() { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); // we need to guard against this.zoomPoint being null Point2D zp = (this.zoomPoint != null ? this.zoomPoint : new Point()); z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp); plot.setNotify(savedNotify); } } /** * Restores the auto-range calculation on the range axis. */ public void restoreAutoRangeBounds() { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; // here we tweak the notify flag on the plot so that only // one notification happens even though we update multiple // axes... boolean savedNotify = plot.isNotify(); plot.setNotify(false); // we need to guard against this.zoomPoint being null Point2D zp = (this.zoomPoint != null ? this.zoomPoint : new Point()); z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp); plot.setNotify(savedNotify); } } /** * Returns the data area for the chart (the area inside the axes) with the * current scaling applied (that is, the area as it appears on screen). * * @return The scaled data area. */ public Rectangle2D getScreenDataArea() { Rectangle2D dataArea = this.info.getPlotInfo().getDataArea(); Insets insets = getInsets(); double x = dataArea.getX() * this.scaleX + insets.left; double y = dataArea.getY() * this.scaleY + insets.top; double w = dataArea.getWidth() * this.scaleX; double h = dataArea.getHeight() * this.scaleY; return new Rectangle2D.Double(x, y, w, h); } /** * Returns the data area (the area inside the axes) for the plot or subplot, * with the current scaling applied. * * @param x the x-coordinate (for subplot selection). * @param y the y-coordinate (for subplot selection). * * @return The scaled data area. */ public Rectangle2D getScreenDataArea(int x, int y) { PlotRenderingInfo plotInfo = this.info.getPlotInfo(); Rectangle2D result; if (plotInfo.getSubplotCount() == 0) { result = getScreenDataArea(); } else { // get the origin of the zoom selection in the Java2D space used for // drawing the chart (that is, before any scaling to fit the panel) Point2D selectOrigin = translateScreenToJava2D(new Point(x, y)); int subplotIndex = plotInfo.getSubplotIndex(selectOrigin); if (subplotIndex == -1) { return null; } result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea()); } return result; } /** * Returns the initial tooltip delay value used inside this chart panel. * * @return An integer representing the initial delay value, in milliseconds. * * @see javax.swing.ToolTipManager#getInitialDelay() */ public int getInitialDelay() { return this.ownToolTipInitialDelay; } /** * Returns the reshow tooltip delay value used inside this chart panel. * * @return An integer representing the reshow delay value, in milliseconds. * * @see javax.swing.ToolTipManager#getReshowDelay() */ public int getReshowDelay() { return this.ownToolTipReshowDelay; } /** * Returns the dismissal tooltip delay value used inside this chart panel. * * @return An integer representing the dismissal delay value, in * milliseconds. * * @see javax.swing.ToolTipManager#getDismissDelay() */ public int getDismissDelay() { return this.ownToolTipDismissDelay; } /** * Specifies the initial delay value for this chart panel. * * @param delay the number of milliseconds to delay (after the cursor has * paused) before displaying. * * @see javax.swing.ToolTipManager#setInitialDelay(int) */ public void setInitialDelay(int delay) { this.ownToolTipInitialDelay = delay; } /** * Specifies the amount of time before the user has to wait initialDelay * milliseconds before a tooltip will be shown. * * @param delay time in milliseconds * * @see javax.swing.ToolTipManager#setReshowDelay(int) */ public void setReshowDelay(int delay) { this.ownToolTipReshowDelay = delay; } /** * Specifies the dismissal delay value for this chart panel. * * @param delay the number of milliseconds to delay before taking away the * tooltip * * @see javax.swing.ToolTipManager#setDismissDelay(int) */ public void setDismissDelay(int delay) { this.ownToolTipDismissDelay = delay; } /** * Returns the zoom in factor. * * @return The zoom in factor. * * @see #setZoomInFactor(double) */ public double getZoomInFactor() { return this.zoomInFactor; } /** * Sets the zoom in factor. * * @param factor the factor. * * @see #getZoomInFactor() */ public void setZoomInFactor(double factor) { this.zoomInFactor = factor; } /** * Returns the zoom out factor. * * @return The zoom out factor. * * @see #setZoomOutFactor(double) */ public double getZoomOutFactor() { return this.zoomOutFactor; } /** * Sets the zoom out factor. * * @param factor the factor. * * @see #getZoomOutFactor() */ public void setZoomOutFactor(double factor) { this.zoomOutFactor = factor; } /** * Draws zoom rectangle (if present). * The drawing is performed in XOR mode, therefore * when this method is called twice in a row, * the second call will completely restore the state * of the canvas. * * @param g2 the graphics device. * @param xor use XOR for drawing? */ private void drawZoomRectangle(Graphics2D g2, boolean xor) { if (this.zoomRectangle != null) { if (xor) { // Set XOR mode to draw the zoom rectangle g2.setXORMode(Color.gray); } if (this.fillZoomRectangle) { g2.setPaint(this.zoomFillPaint); g2.fill(this.zoomRectangle); } else { g2.setPaint(this.zoomOutlinePaint); g2.draw(this.zoomRectangle); } if (xor) { // Reset to the default 'overwrite' mode g2.setPaintMode(); } } } /** * Draws a vertical line used to trace the mouse position to the horizontal * axis. * * @param g2 the graphics device. * @param x the x-coordinate of the trace line. */ private void drawHorizontalAxisTrace(Graphics2D g2, int x) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { if (this.verticalTraceLine != null) { g2.draw(this.verticalTraceLine); this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } else { this.verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } g2.draw(this.verticalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); } /** * Draws a horizontal line used to trace the mouse position to the vertical * axis. * * @param g2 the graphics device. * @param y the y-coordinate of the trace line. */ private void drawVerticalAxisTrace(Graphics2D g2, int y) { Rectangle2D dataArea = getScreenDataArea(); g2.setXORMode(Color.orange); if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) { if (this.horizontalTraceLine != null) { g2.draw(this.horizontalTraceLine); this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } else { this.horizontalTraceLine = new Line2D.Float( (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y); } g2.draw(this.horizontalTraceLine); } // Reset to the default 'overwrite' mode g2.setPaintMode(); } /** * Displays a dialog that allows the user to edit the properties for the * current chart. * * @since 1.0.3 */ public void doEditChartProperties() { ChartEditor editor = ChartEditorManager.getChartEditor(this.chart); int result = JOptionPane.showConfirmDialog(this, editor, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { editor.updateChart(this.chart); } } /** * Copies the current chart to the system clipboard. * * @since 1.0.13 */ public void doCopy() { Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); ChartTransferable selection = new ChartTransferable(this.chart, getWidth(), getHeight()); systemClipboard.setContents(selection, null); } /** * Opens a file chooser and gives the user an opportunity to save the chart * in PNG format. * * @throws IOException if there is an I/O error. */ public void doSaveAs() throws IOException { JFileChooser fileChooser = new JFileChooser(); fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs); ExtensionFileFilter filter = new ExtensionFileFilter( localizationResources.getString("PNG_Image_Files"), ".png"); fileChooser.addChoosableFileFilter(filter); int option = fileChooser.showSaveDialog(this); if (option == JFileChooser.APPROVE_OPTION) { String filename = fileChooser.getSelectedFile().getPath(); if (isEnforceFileExtensions()) { if (!filename.endsWith(".png")) { filename = filename + ".png"; } } ChartUtilities.saveChartAsPNG(new File(filename), this.chart, getWidth(), getHeight()); } } /** * Creates a print job for the chart. */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } } /** * Prints the chart on a single page. * * @param g the graphics context. * @param pf the page format to use. * @param pageIndex the index of the page. If not 0, nothing * gets print. * * @return The result of printing. */ public int print(Graphics g, PageFormat pf, int pageIndex) { if (pageIndex != 0) { return NO_SUCH_PAGE; } Graphics2D g2 = (Graphics2D) g; double x = pf.getImageableX(); double y = pf.getImageableY(); double w = pf.getImageableWidth(); double h = pf.getImageableHeight(); this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor, null); return PAGE_EXISTS; } /** * Adds a listener to the list of objects listening for chart mouse events. * * @param listener the listener (null not permitted). */ public void addChartMouseListener(ChartMouseListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.chartMouseListeners.add(ChartMouseListener.class, listener); } /** * Removes a listener from the list of objects listening for chart mouse * events. * * @param listener the listener. */ public void removeChartMouseListener(ChartMouseListener listener) { this.chartMouseListeners.remove(ChartMouseListener.class, listener); } /** * Returns an array of the listeners of the given type registered with the * panel. * * @param listenerType the listener type. * * @return An array of listeners. */ public EventListener[] getListeners(Class listenerType) { if (listenerType == ChartMouseListener.class) { // fetch listeners from local storage return this.chartMouseListeners.getListeners(listenerType); } else { return super.getListeners(listenerType); } } /** * Creates a popup menu for the panel. * * @param properties include a menu item for the chart property editor. * @param save include a menu item for saving the chart. * @param print include a menu item for printing the chart. * @param zoom include menu items for zooming. * * @return The popup menu. */ protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { return createPopupMenu(properties, false, save, print, zoom); } /** * Creates a popup menu for the panel. * * @param properties include a menu item for the chart property editor. * @param copy include a menu item for copying to the clipboard. * @param save include a menu item for saving the chart. * @param print include a menu item for printing the chart. * @param zoom include menu items for zooming. * * @return The popup menu. * * @since 1.0.13 */ protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) { JPopupMenu result = new JPopupMenu("Chart:"); boolean separator = false; if (properties) { JMenuItem propertiesItem = new JMenuItem( localizationResources.getString("Properties...")); propertiesItem.setActionCommand(PROPERTIES_COMMAND); propertiesItem.addActionListener(this); result.add(propertiesItem); separator = true; } if (copy) { if (separator) { result.addSeparator(); separator = false; } JMenuItem copyItem = new JMenuItem( localizationResources.getString("Copy")); copyItem.setActionCommand(COPY_COMMAND); copyItem.addActionListener(this); result.add(copyItem); separator = !save; } if (save) { if (separator) { result.addSeparator(); separator = false; } JMenuItem saveItem = new JMenuItem( localizationResources.getString("Save_as...")); saveItem.setActionCommand(SAVE_COMMAND); saveItem.addActionListener(this); result.add(saveItem); separator = true; } if (print) { if (separator) { result.addSeparator(); separator = false; } JMenuItem printItem = new JMenuItem( localizationResources.getString("Print...")); printItem.setActionCommand(PRINT_COMMAND); printItem.addActionListener(this); result.add(printItem); separator = true; } if (zoom) { if (separator) { result.addSeparator(); separator = false; } JMenu zoomInMenu = new JMenu( localizationResources.getString("Zoom_In")); this.zoomInBothMenuItem = new JMenuItem( localizationResources.getString("All_Axes")); this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND); this.zoomInBothMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInBothMenuItem); zoomInMenu.addSeparator(); this.zoomInDomainMenuItem = new JMenuItem( localizationResources.getString("Domain_Axis")); this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND); this.zoomInDomainMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInDomainMenuItem); this.zoomInRangeMenuItem = new JMenuItem( localizationResources.getString("Range_Axis")); this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND); this.zoomInRangeMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInRangeMenuItem); result.add(zoomInMenu); JMenu zoomOutMenu = new JMenu( localizationResources.getString("Zoom_Out")); this.zoomOutBothMenuItem = new JMenuItem( localizationResources.getString("All_Axes")); this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND); this.zoomOutBothMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutBothMenuItem); zoomOutMenu.addSeparator(); this.zoomOutDomainMenuItem = new JMenuItem( localizationResources.getString("Domain_Axis")); this.zoomOutDomainMenuItem.setActionCommand( ZOOM_OUT_DOMAIN_COMMAND); this.zoomOutDomainMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutDomainMenuItem); this.zoomOutRangeMenuItem = new JMenuItem( localizationResources.getString("Range_Axis")); this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND); this.zoomOutRangeMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutRangeMenuItem); result.add(zoomOutMenu); JMenu autoRangeMenu = new JMenu( localizationResources.getString("Auto_Range")); this.zoomResetBothMenuItem = new JMenuItem( localizationResources.getString("All_Axes")); this.zoomResetBothMenuItem.setActionCommand( ZOOM_RESET_BOTH_COMMAND); this.zoomResetBothMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetBothMenuItem); autoRangeMenu.addSeparator(); this.zoomResetDomainMenuItem = new JMenuItem( localizationResources.getString("Domain_Axis")); this.zoomResetDomainMenuItem.setActionCommand( ZOOM_RESET_DOMAIN_COMMAND); this.zoomResetDomainMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetDomainMenuItem); this.zoomResetRangeMenuItem = new JMenuItem( localizationResources.getString("Range_Axis")); this.zoomResetRangeMenuItem.setActionCommand( ZOOM_RESET_RANGE_COMMAND); this.zoomResetRangeMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetRangeMenuItem); result.addSeparator(); result.add(autoRangeMenu); } return result; } /** * The idea is to modify the zooming options depending on the type of chart * being displayed by the panel. * * @param x horizontal position of the popup. * @param y vertical position of the popup. */ protected void displayPopupMenu(int x, int y) { if (this.popup != null) { // go through each zoom menu item and decide whether or not to // enable it... Plot plot = this.chart.getPlot(); boolean isDomainZoomable = false; boolean isRangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; isDomainZoomable = z.isDomainZoomable(); isRangeZoomable = z.isRangeZoomable(); } if (this.zoomInDomainMenuItem != null) { this.zoomInDomainMenuItem.setEnabled(isDomainZoomable); } if (this.zoomOutDomainMenuItem != null) { this.zoomOutDomainMenuItem.setEnabled(isDomainZoomable); } if (this.zoomResetDomainMenuItem != null) { this.zoomResetDomainMenuItem.setEnabled(isDomainZoomable); } if (this.zoomInRangeMenuItem != null) { this.zoomInRangeMenuItem.setEnabled(isRangeZoomable); } if (this.zoomOutRangeMenuItem != null) { this.zoomOutRangeMenuItem.setEnabled(isRangeZoomable); } if (this.zoomResetRangeMenuItem != null) { this.zoomResetRangeMenuItem.setEnabled(isRangeZoomable); } if (this.zoomInBothMenuItem != null) { this.zoomInBothMenuItem.setEnabled(isDomainZoomable && isRangeZoomable); } if (this.zoomOutBothMenuItem != null) { this.zoomOutBothMenuItem.setEnabled(isDomainZoomable && isRangeZoomable); } if (this.zoomResetBothMenuItem != null) { this.zoomResetBothMenuItem.setEnabled(isDomainZoomable && isRangeZoomable); } this.popup.show(this, x, y); } } /** * Updates the UI for a LookAndFeel change. */ public void updateUI() { // here we need to update the UI for the popup menu, if the panel // has one... if (this.popup != null) { SwingUtilities.updateComponentTreeUI(this.popup); } super.updateUI(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.zoomFillPaint, stream); SerialUtilities.writePaint(this.zoomOutlinePaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.zoomFillPaint = SerialUtilities.readPaint(stream); this.zoomOutlinePaint = SerialUtilities.readPaint(stream); // we create a new but empty chartMouseListeners list this.chartMouseListeners = new EventListenerList(); // register as a listener with sub-components... if (this.chart != null) { this.chart.addChangeListener(this); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartRenderingInfo.java0000644000175000017500000002100311173030414027003 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * ChartRenderingInfo.java * ----------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Jan-2002 : Version 1 (DG); * 05-Feb-2002 : Added a new constructor, completed Javadoc comments (DG); * 05-Mar-2002 : Added a clear() method (DG); * 23-May-2002 : Renamed DrawInfo --> ChartRenderingInfo (DG); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 17-Sep-2003 : Added PlotRenderingInfo (DG); * 01-Nov-2005 : Updated equals() method (DG); * 30-Nov-2005 : Removed get/setPlotArea() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 01-Dec-2006 : Fixed equals() and clone() (DG); * */ package org.jfree.chart; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A structure for storing rendering information from one call to the * JFreeChart.draw() method. *

* An instance of the {@link JFreeChart} class can draw itself within an * arbitrary rectangle on any Graphics2D. It is assumed that * client code will sometimes render the same chart in more than one view, so * the {@link JFreeChart} instance does not retain any information about its * rendered dimensions. This information can be useful sometimes, so you have * the option to collect the information at each call to * JFreeChart.draw(), by passing an instance of this * ChartRenderingInfo class. */ public class ChartRenderingInfo implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2751952018173406822L; /** The area in which the chart is drawn. */ private transient Rectangle2D chartArea; /** Rendering info for the chart's plot (and subplots, if any). */ private PlotRenderingInfo plotInfo; /** * Storage for the chart entities. Since retaining entity information for * charts with a large number of data points consumes a lot of memory, it * is intended that you can set this to null to prevent the * information being collected. */ private EntityCollection entities; /** * Constructs a new ChartRenderingInfo structure that can be used to * collect information about the dimensions of a rendered chart. */ public ChartRenderingInfo() { this(new StandardEntityCollection()); } /** * Constructs a new instance. If an entity collection is supplied, it will * be populated with information about the entities in a chart. If it is * null, no entity information (including tool tips) will * be collected. * * @param entities an entity collection (null permitted). */ public ChartRenderingInfo(EntityCollection entities) { this.chartArea = new Rectangle2D.Double(); this.plotInfo = new PlotRenderingInfo(this); this.entities = entities; } /** * Returns the area in which the chart was drawn. * * @return The area in which the chart was drawn. * * @see #setChartArea(Rectangle2D) */ public Rectangle2D getChartArea() { return this.chartArea; } /** * Sets the area in which the chart was drawn. * * @param area the chart area. * * @see #getChartArea() */ public void setChartArea(Rectangle2D area) { this.chartArea.setRect(area); } /** * Returns the collection of entities maintained by this instance. * * @return The entity collection (possibly null). * * @see #setEntityCollection(EntityCollection) */ public EntityCollection getEntityCollection() { return this.entities; } /** * Sets the entity collection. * * @param entities the entity collection (null permitted). * * @see #getEntityCollection() */ public void setEntityCollection(EntityCollection entities) { this.entities = entities; } /** * Clears the information recorded by this object. */ public void clear() { this.chartArea.setRect(0.0, 0.0, 0.0, 0.0); this.plotInfo = new PlotRenderingInfo(this); if (this.entities != null) { this.entities.clear(); } } /** * Returns the rendering info for the chart's plot. * * @return The rendering info for the plot. */ public PlotRenderingInfo getPlotInfo() { return this.plotInfo; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ChartRenderingInfo)) { return false; } ChartRenderingInfo that = (ChartRenderingInfo) obj; if (!ObjectUtilities.equal(this.chartArea, that.chartArea)) { return false; } if (!ObjectUtilities.equal(this.plotInfo, that.plotInfo)) { return false; } if (!ObjectUtilities.equal(this.entities, that.entities)) { return false; } return true; } /** * Returns a clone of this object. * * @return A clone. * * @throws CloneNotSupportedException if the object cannot be cloned. */ public Object clone() throws CloneNotSupportedException { ChartRenderingInfo clone = (ChartRenderingInfo) super.clone(); if (this.chartArea != null) { clone.chartArea = (Rectangle2D) this.chartArea.clone(); } if (this.entities instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.entities; clone.entities = (EntityCollection) pc.clone(); } return clone; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeShape(this.chartArea, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.chartArea = (Rectangle2D) SerialUtilities.readShape(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartTheme.java0000644000175000017500000000423411173030414025323 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * ChartTheme.java * --------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2008 : Version 1 (DG); * */ package org.jfree.chart; import org.jfree.chart.JFreeChart; /** * A {@link ChartTheme} a class that can apply a style or 'theme' to a chart. * It can be implemented in an arbitrary manner, with the styling applied to * the chart via the apply(JFreeChart) method. We provide one * implementation ({@link StandardChartTheme}) that just mimics the manual * process of calling methods to set various chart parameters. * * @since 1.0.11 */ public interface ChartTheme { /** * Applies this theme to the supplied chart. * * @param chart the chart (null not permitted). */ public void apply(JFreeChart chart); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartTransferable.java0000644000175000017500000001104011173030414026662 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * ChartSelection.java * ------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Apr-2009 : Version 1, with inspiration from patch 1460845 (DG); * */ package org.jfree.chart; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; /** * A class used to represent a chart on the clipboard. * * @since 1.0.13 */ public class ChartTransferable implements Transferable { /** The data flavor. */ final DataFlavor imageFlavor = new DataFlavor( "image/x-java-image; class=java.awt.Image", "Image"); /** The chart. */ private JFreeChart chart; /** The width of the chart on the clipboard. */ private int width; /** The height of the chart on the clipboard. */ private int height; /** * Creates a new chart selection. * * @param chart the chart. * @param width the chart width. * @param height the chart height. */ public ChartTransferable(JFreeChart chart, int width, int height) { this(chart, width, height, true); } /** * Creates a new chart selection. * * @param chart the chart. * @param width the chart width. * @param height the chart height. * @param cloneData clone the dataset(s)? */ public ChartTransferable(JFreeChart chart, int width, int height, boolean cloneData) { // we clone the chart because presumably there can be some delay // between putting this instance on the system clipboard and // actually having the getTransferData() method called... try { this.chart = (JFreeChart) chart.clone(); } catch (CloneNotSupportedException e) { this.chart = chart; } this.width = width; this.height = height; // FIXME: we've cloned the chart, but the dataset(s) aren't cloned // and we should do that } /** * Returns the data flavors supported. * * @return The data flavors supported. */ public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] {this.imageFlavor}; } /** * Returns true if the specified flavor is supported. * * @param flavor the flavor. * * @return A boolean. */ public boolean isDataFlavorSupported(DataFlavor flavor) { return this.imageFlavor.equals(flavor); } /** * Returns the content for the requested flavor, if it is supported. * * @param flavor the requested flavor. * * @return The content. * * @throws java.awt.datatransfer.UnsupportedFlavorException * @throws java.io.IOException */ public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { if (this.imageFlavor.equals(flavor)) { return this.chart.createBufferedImage(width, height); } else { throw new UnsupportedFlavorException(flavor); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ChartUtilities.java0000644000175000017500000007345411173030414026246 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * ChartUtilities.java * ------------------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Wolfgang Irler; * Richard Atkinson; * Xavier Poinsard; * * Changes * ------- * 11-Dec-2001 : Version 1. The JPEG method comes from Wolfgang Irler's * JFreeChartServletDemo class (DG); * 23-Jan-2002 : Changed saveChartAsXXX() methods to pass IOExceptions back to * caller (DG); * 26-Jun-2002 : Added image map methods (DG); * 05-Aug-2002 : Added writeBufferedImage methods * Modified writeImageMap method to support flexible image * maps (RA); * 26-Aug-2002 : Added saveChartAsJPEG and writeChartAsJPEG methods with info * objects (RA); * 05-Sep-2002 : Added writeImageMap() method to support OverLIB * - http://www.bosrup.com/web/overlib (RA); * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); * 17-Oct-2002 : Exposed JPEG quality setting and PNG compression level as * parameters (DG); * 25-Oct-2002 : Fixed writeChartAsJPEG() empty method bug (DG); * 13-Mar-2003 : Updated writeImageMap method as suggested by Xavier Poinsard * (see Feature Request 688079) (DG); * 12-Aug-2003 : Added support for custom image maps using * ToolTipTagFragmentGenerator and URLTagFragmentGenerator (RA); * 02-Sep-2003 : Separated PNG encoding from writing chart to an * OutputStream (RA); * 04-Dec-2003 : Chart draw() method modified to include anchor point (DG); * 20-Feb-2004 : Edited Javadocs and added argument checking (DG); * 05-Apr-2004 : Fixed problem with buffered image type (DG); * 01-Aug-2004 : Modified to use EncoderUtil for all image encoding (RA); * 02-Aug-2004 : Delegated image map related functionality to ImageMapUtil (RA); * 13-Jan-2005 : Renamed ImageMapUtil --> ImageMapUtilities, removed method * writeImageMap(PrintWriter, String, ChartRenderingInfo) which * exists in ImageMapUtilities (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Feb-2006 : API doc update (DG); * 19-Mar-2007 : Use try-finally to close output stream in saveChartAsXXX() * methods (DG); * 10-Jan-2008 : Fix bug 1868251 - don't create image with transparency when * saving to JPEG format (DG); * */ package org.jfree.chart; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import org.jfree.chart.encoders.EncoderUtil; import org.jfree.chart.encoders.ImageFormat; import org.jfree.chart.imagemap.ImageMapUtilities; import org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator; import org.jfree.chart.imagemap.StandardToolTipTagFragmentGenerator; import org.jfree.chart.imagemap.StandardURLTagFragmentGenerator; import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator; import org.jfree.chart.imagemap.URLTagFragmentGenerator; /** * A collection of utility methods for JFreeChart. Includes methods for * converting charts to image formats (PNG and JPEG) plus creating simple HTML * image maps. * * @see ImageMapUtilities */ public abstract class ChartUtilities { /** * Applies the current theme to the specified chart. This method is * provided for convenience, the theme itself is stored in the * {@link ChartFactory} class. * * @param chart the chart (null not permitted). * * @since 1.0.11 */ public static void applyCurrentTheme(JFreeChart chart) { ChartFactory.getChartTheme().apply(chart); } /** * Writes a chart to an output stream in PNG format. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... writeChartAsPNG(out, chart, width, height, null); } /** * Writes a chart to an output stream in PNG format. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param encodeAlpha encode alpha? * @param compression the compression level (0-9). * * @throws IOException if there are any I/O errors. */ public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, boolean encodeAlpha, int compression) throws IOException { // defer argument checking... ChartUtilities.writeChartAsPNG(out, chart, width, height, null, encodeAlpha, compression); } /** * Writes a chart to an output stream in PNG format. This method allows * you to pass in a {@link ChartRenderingInfo} object, to collect * information about the chart dimensions/entities. You will need this * info if you want to create an HTML image map. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * * @throws IOException if there are any I/O errors. */ public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } BufferedImage bufferedImage = chart.createBufferedImage(width, height, info); EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out); } /** * Writes a chart to an output stream in PNG format. This method allows * you to pass in a {@link ChartRenderingInfo} object, to collect * information about the chart dimensions/entities. You will need this * info if you want to create an HTML image map. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info carries back chart rendering info (null * permitted). * @param encodeAlpha encode alpha? * @param compression the PNG compression level (0-9). * * @throws IOException if there are any I/O errors. */ public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression) throws IOException { if (out == null) { throw new IllegalArgumentException("Null 'out' argument."); } if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } BufferedImage chartImage = chart.createBufferedImage(width, height, BufferedImage.TYPE_INT_ARGB, info); ChartUtilities.writeBufferedImageAsPNG(out, chartImage, encodeAlpha, compression); } /** * Writes a scaled version of a chart to an output stream in PNG format. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the unscaled chart width. * @param height the unscaled chart height. * @param widthScaleFactor the horizontal scale factor. * @param heightScaleFactor the vertical scale factor. * * @throws IOException if there are any I/O problems. */ public static void writeScaledChartAsPNG(OutputStream out, JFreeChart chart, int width, int height, int widthScaleFactor, int heightScaleFactor) throws IOException { if (out == null) { throw new IllegalArgumentException("Null 'out' argument."); } if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } double desiredWidth = width * widthScaleFactor; double desiredHeight = height * heightScaleFactor; double defaultWidth = width; double defaultHeight = height; boolean scale = false; // get desired width and height from somewhere then... if ((widthScaleFactor != 1) || (heightScaleFactor != 1)) { scale = true; } double scaleX = desiredWidth / defaultWidth; double scaleY = desiredHeight / defaultHeight; BufferedImage image = new BufferedImage((int) desiredWidth, (int) desiredHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); if (scale) { AffineTransform saved = g2.getTransform(); g2.transform(AffineTransform.getScaleInstance(scaleX, scaleY)); chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), null, null); g2.setTransform(saved); g2.dispose(); } else { chart.draw(g2, new Rectangle2D.Double(0, 0, defaultWidth, defaultHeight), null, null); } out.write(encodeAsPNG(image)); } /** * Saves a chart to the specified file in PNG format. * * @param file the file name (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsPNG(file, chart, width, height, null); } /** * Saves a chart to a file in PNG format. This method allows you to pass * in a {@link ChartRenderingInfo} object, to collect information about the * chart dimensions/entities. You will need this info if you want to * create an HTML image map. * * @param file the file (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * * @throws IOException if there are any I/O errors. */ public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (file == null) { throw new IllegalArgumentException("Null 'file' argument."); } OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { ChartUtilities.writeChartAsPNG(out, chart, width, height, info); } finally { out.close(); } } /** * Saves a chart to a file in PNG format. This method allows you to pass * in a {@link ChartRenderingInfo} object, to collect information about the * chart dimensions/entities. You will need this info if you want to * create an HTML image map. * * @param file the file (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * @param encodeAlpha encode alpha? * @param compression the PNG compression level (0-9). * * @throws IOException if there are any I/O errors. */ public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info, boolean encodeAlpha, int compression) throws IOException { if (file == null) { throw new IllegalArgumentException("Null 'file' argument."); } if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { writeChartAsPNG(out, chart, width, height, info, encodeAlpha, compression); } finally { out.close(); } } /** * Writes a chart to an output stream in JPEG format. Please note that * JPEG is a poor format for chart images, use PNG if possible. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... writeChartAsJPEG(out, chart, width, height, null); } /** * Writes a chart to an output stream in JPEG format. Please note that * JPEG is a poor format for chart images, use PNG if possible. * * @param out the output stream (null not permitted). * @param quality the quality setting. * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void writeChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... ChartUtilities.writeChartAsJPEG(out, quality, chart, width, height, null); } /** * Writes a chart to an output stream in JPEG format. This method allows * you to pass in a {@link ChartRenderingInfo} object, to collect * information about the chart dimensions/entities. You will need this * info if you want to create an HTML image map. * * @param out the output stream (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * * @throws IOException if there are any I/O errors. */ public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } BufferedImage image = chart.createBufferedImage(width, height, BufferedImage.TYPE_INT_RGB, info); EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out); } /** * Writes a chart to an output stream in JPEG format. This method allows * you to pass in a {@link ChartRenderingInfo} object, to collect * information about the chart dimensions/entities. You will need this * info if you want to create an HTML image map. * * @param out the output stream (null not permitted). * @param quality the output quality (0.0f to 1.0f). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * * @throws IOException if there are any I/O errors. */ public static void writeChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } BufferedImage image = chart.createBufferedImage(width, height, BufferedImage.TYPE_INT_RGB, info); EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality); } /** * Saves a chart to a file in JPEG format. * * @param file the file (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsJPEG(file, chart, width, height, null); } /** * Saves a chart to a file in JPEG format. * * @param file the file (null not permitted). * @param quality the JPEG quality setting. * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsJPEG(file, quality, chart, width, height, null); } /** * Saves a chart to a file in JPEG format. This method allows you to pass * in a {@link ChartRenderingInfo} object, to collect information about the * chart dimensions/entities. You will need this info if you want to * create an HTML image map. * * @param file the file name (null not permitted). * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (file == null) { throw new IllegalArgumentException("Null 'file' argument."); } if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { writeChartAsJPEG(out, chart, width, height, info); } finally { out.close(); } } /** * Saves a chart to a file in JPEG format. This method allows you to pass * in a {@link ChartRenderingInfo} object, to collect information about the * chart dimensions/entities. You will need this info if you want to * create an HTML image map. * * @param file the file name (null not permitted). * @param quality the quality setting. * @param chart the chart (null not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (null permitted). * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (file == null) { throw new IllegalArgumentException("Null 'file' argument."); } if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } OutputStream out = new BufferedOutputStream(new FileOutputStream( file)); try { writeChartAsJPEG(out, quality, chart, width, height, info); } finally { out.close(); } } /** * Writes a {@link BufferedImage} to an output stream in JPEG format. * * @param out the output stream (null not permitted). * @param image the image (null not permitted). * * @throws IOException if there are any I/O errors. */ public static void writeBufferedImageAsJPEG(OutputStream out, BufferedImage image) throws IOException { // defer argument checking... writeBufferedImageAsJPEG(out, 0.75f, image); } /** * Writes a {@link BufferedImage} to an output stream in JPEG format. * * @param out the output stream (null not permitted). * @param quality the image quality (0.0f to 1.0f). * @param image the image (null not permitted). * * @throws IOException if there are any I/O errors. */ public static void writeBufferedImageAsJPEG(OutputStream out, float quality, BufferedImage image) throws IOException { EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality); } /** * Writes a {@link BufferedImage} to an output stream in PNG format. * * @param out the output stream (null not permitted). * @param image the image (null not permitted). * * @throws IOException if there are any I/O errors. */ public static void writeBufferedImageAsPNG(OutputStream out, BufferedImage image) throws IOException { EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out); } /** * Writes a {@link BufferedImage} to an output stream in PNG format. * * @param out the output stream (null not permitted). * @param image the image (null not permitted). * @param encodeAlpha encode alpha? * @param compression the compression level (0-9). * * @throws IOException if there are any I/O errors. */ public static void writeBufferedImageAsPNG(OutputStream out, BufferedImage image, boolean encodeAlpha, int compression) throws IOException { EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out, compression, encodeAlpha); } /** * Encodes a {@link BufferedImage} to PNG format. * * @param image the image (null not permitted). * * @return A byte array in PNG format. * * @throws IOException if there is an I/O problem. */ public static byte[] encodeAsPNG(BufferedImage image) throws IOException { return EncoderUtil.encode(image, ImageFormat.PNG); } /** * Encodes a {@link BufferedImage} to PNG format. * * @param image the image (null not permitted). * @param encodeAlpha encode alpha? * @param compression the PNG compression level (0-9). * * @return The byte array in PNG format. * * @throws IOException if there is an I/O problem. */ public static byte[] encodeAsPNG(BufferedImage image, boolean encodeAlpha, int compression) throws IOException { return EncoderUtil.encode(image, ImageFormat.PNG, compression, encodeAlpha); } /** * Writes an image map to an output stream. * * @param writer the writer (null not permitted). * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * @param useOverLibForToolTips whether to use OverLIB for tooltips * (http://www.bosrup.com/web/overlib/). * * @throws IOException if there are any I/O errors. */ public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info, boolean useOverLibForToolTips) throws IOException { ToolTipTagFragmentGenerator toolTipTagFragmentGenerator = null; if (useOverLibForToolTips) { toolTipTagFragmentGenerator = new OverLIBToolTipTagFragmentGenerator(); } else { toolTipTagFragmentGenerator = new StandardToolTipTagFragmentGenerator(); } ImageMapUtilities.writeImageMap(writer, name, info, toolTipTagFragmentGenerator, new StandardURLTagFragmentGenerator()); } /** * Writes an image map to the specified writer. * * @param writer the writer (null not permitted). * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (null not permitted * if info contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (null not permitted if * info contains URLs). * * @throws IOException if there are any I/O errors. */ public static void writeImageMap(PrintWriter writer, String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) throws IOException { writer.println(ImageMapUtilities.getImageMap(name, info, toolTipTagFragmentGenerator, urlTagFragmentGenerator)); } /** * Creates an HTML image map. This method maps to * {@link ImageMapUtilities#getImageMap(String, ChartRenderingInfo, * ToolTipTagFragmentGenerator, URLTagFragmentGenerator)}, using default * generators. * * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * * @return The map tag. */ public static String getImageMap(String name, ChartRenderingInfo info) { return ImageMapUtilities.getImageMap(name, info, new StandardToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator()); } /** * Creates an HTML image map. This method maps directly to * {@link ImageMapUtilities#getImageMap(String, ChartRenderingInfo, * ToolTipTagFragmentGenerator, URLTagFragmentGenerator)}. * * @param name the map name (null not permitted). * @param info the chart rendering info (null not permitted). * @param toolTipTagFragmentGenerator a generator for the HTML fragment * that will contain the tooltip text (null not permitted * if info contains tooltip information). * @param urlTagFragmentGenerator a generator for the HTML fragment that * will contain the URL reference (null not permitted if * info contains URLs). * * @return The map tag. */ public static String getImageMap(String name, ChartRenderingInfo info, ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, URLTagFragmentGenerator urlTagFragmentGenerator) { return ImageMapUtilities.getImageMap(name, info, toolTipTagFragmentGenerator, urlTagFragmentGenerator); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/ClipPath.java0000644000175000017500000003050111173030414024777 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * ClipPath.java * ------------- * (C) Copyright 2003-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * Nicolas Brodu; * * Changes * ------- * 22-Apr-2003 : Added standard header (DG); * 09-May-2003 : Added AxisLocation (DG); * 11-Sep-2003 : Implemented Cloneable (NB); * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.chart; import java.awt.BasicStroke; import java.awt.Composite; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Stroke; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.ui.RectangleEdge; /** * This class would typically be used with a * {@link org.jfree.chart.plot.ContourPlot}. It allows the user to define a * GeneralPath curve in plot coordinates. This curve can then be * used mask off or define regions within the contour plot. The data must be * sorted. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class ClipPath implements Cloneable { /** The x values. */ private double[] xValue = null; /** The y values. */ private double[] yValue = null; /** Controls whether drawing will be clipped ( * false would still allow the drawing or filling of path */ private boolean clip = true; /** Controls whether the path is drawn as an outline. */ private boolean drawPath = false; /** Controls whether the path is filled. */ private boolean fillPath = false; /** The fill paint. */ private Paint fillPaint = null; /** The draw paint. */ private Paint drawPaint = null; /** The draw stroke. */ private Stroke drawStroke = null; /** The composite. */ private Composite composite = null; /** * Constructor for ClipPath. */ public ClipPath() { super(); } /** * Constructor for ClipPath. * Default values are assumed for the fillPath and drawPath options as * false and true respectively. The fillPaint is set to Color.GRAY, the * drawColor is Color.BLUE, the stroke is BasicStroke(1) * and the composite is AlphaComposite.Src. * * @param xValue x coordinates of curved to be created * @param yValue y coordinates of curved to be created */ public ClipPath(double[] xValue, double[] yValue) { this(xValue, yValue, true, false, true); } /** * Constructor for ClipPath. * The fillPaint is set to Color.GRAY, the drawColor is Color.BLUE, the * stroke is BasicStroke(1) and the composite is AlphaComposite.Src. * * @param xValue x coordinates of curved to be created * @param yValue y coordinates of curved to be created * @param clip clip? * @param fillPath whether the path is to filled * @param drawPath whether the path is to drawn as an outline */ public ClipPath(double[] xValue, double[] yValue, boolean clip, boolean fillPath, boolean drawPath) { this.xValue = xValue; this.yValue = yValue; this.clip = clip; this.fillPath = fillPath; this.drawPath = drawPath; this.fillPaint = java.awt.Color.gray; this.drawPaint = java.awt.Color.blue; this.drawStroke = new BasicStroke(1); this.composite = java.awt.AlphaComposite.Src; } /** * Constructor for ClipPath. * * @param xValue x coordinates of curved to be created * @param yValue y coordinates of curved to be created * @param fillPath whether the path is to filled * @param drawPath whether the path is to drawn as an outline * @param fillPaint the fill paint * @param drawPaint the outline stroke color * @param drawStroke the stroke style * @param composite the composite rule */ public ClipPath(double[] xValue, double[] yValue, boolean fillPath, boolean drawPath, Paint fillPaint, Paint drawPaint, Stroke drawStroke, Composite composite) { this.xValue = xValue; this.yValue = yValue; this.fillPath = fillPath; this.drawPath = drawPath; this.fillPaint = fillPaint; this.drawPaint = drawPaint; this.drawStroke = drawStroke; this.composite = composite; } /** * Draws the clip path. * * @param g2 current graphics2D. * @param dataArea the dataArea that the plot is being draw in. * @param horizontalAxis the horizontal axis. * @param verticalAxis the vertical axis. * * @return The GeneralPath defining the outline */ public GeneralPath draw(Graphics2D g2, Rectangle2D dataArea, ValueAxis horizontalAxis, ValueAxis verticalAxis) { GeneralPath generalPath = generateClipPath( dataArea, horizontalAxis, verticalAxis ); if (this.fillPath || this.drawPath) { Composite saveComposite = g2.getComposite(); Paint savePaint = g2.getPaint(); Stroke saveStroke = g2.getStroke(); if (this.fillPaint != null) { g2.setPaint(this.fillPaint); } if (this.composite != null) { g2.setComposite(this.composite); } if (this.fillPath) { g2.fill(generalPath); } if (this.drawStroke != null) { g2.setStroke(this.drawStroke); } if (this.drawPath) { g2.draw(generalPath); } g2.setPaint(savePaint); g2.setComposite(saveComposite); g2.setStroke(saveStroke); } return generalPath; } /** * Generates the clip path. * * @param dataArea the dataArea that the plot is being draw in. * @param horizontalAxis the horizontal axis. * @param verticalAxis the vertical axis. * * @return The GeneralPath defining the outline */ public GeneralPath generateClipPath(Rectangle2D dataArea, ValueAxis horizontalAxis, ValueAxis verticalAxis) { GeneralPath generalPath = new GeneralPath(); double transX = horizontalAxis.valueToJava2D( this.xValue[0], dataArea, RectangleEdge.BOTTOM ); double transY = verticalAxis.valueToJava2D( this.yValue[0], dataArea, RectangleEdge.LEFT ); generalPath.moveTo((float) transX, (float) transY); for (int k = 0; k < this.yValue.length; k++) { transX = horizontalAxis.valueToJava2D( this.xValue[k], dataArea, RectangleEdge.BOTTOM ); transY = verticalAxis.valueToJava2D( this.yValue[k], dataArea, RectangleEdge.LEFT ); generalPath.lineTo((float) transX, (float) transY); } generalPath.closePath(); return generalPath; } /** * Returns the composite. * * @return Composite */ public Composite getComposite() { return this.composite; } /** * Returns the drawPaint. * * @return Paint */ public Paint getDrawPaint() { return this.drawPaint; } /** * Returns the drawPath. * * @return boolean */ public boolean isDrawPath() { return this.drawPath; } /** * Returns the drawStroke. * * @return Stroke */ public Stroke getDrawStroke() { return this.drawStroke; } /** * Returns the fillPaint. * * @return Paint */ public Paint getFillPaint() { return this.fillPaint; } /** * Returns the fillPath. * * @return boolean */ public boolean isFillPath() { return this.fillPath; } /** * Returns the xValue. * * @return double[] */ public double[] getXValue() { return this.xValue; } /** * Returns the yValue. * * @return double[] */ public double[] getYValue() { return this.yValue; } /** * Sets the composite. * * @param composite The composite to set */ public void setComposite(Composite composite) { this.composite = composite; } /** * Sets the drawPaint. * * @param drawPaint The drawPaint to set */ public void setDrawPaint(Paint drawPaint) { this.drawPaint = drawPaint; } /** * Sets the drawPath. * * @param drawPath The drawPath to set */ public void setDrawPath(boolean drawPath) { this.drawPath = drawPath; } /** * Sets the drawStroke. * * @param drawStroke The drawStroke to set */ public void setDrawStroke(Stroke drawStroke) { this.drawStroke = drawStroke; } /** * Sets the fillPaint. * * @param fillPaint The fillPaint to set */ public void setFillPaint(Paint fillPaint) { this.fillPaint = fillPaint; } /** * Sets the fillPath. * * @param fillPath The fillPath to set */ public void setFillPath(boolean fillPath) { this.fillPath = fillPath; } /** * Sets the xValue. * * @param xValue The xValue to set */ public void setXValue(double[] xValue) { this.xValue = xValue; } /** * Sets the yValue. * * @param yValue The yValue to set */ public void setYValue(double[] yValue) { this.yValue = yValue; } /** * Returns the clip. * * @return boolean */ public boolean isClip() { return this.clip; } /** * Sets the clip. * * @param clip The clip to set */ public void setClip(boolean clip) { this.clip = clip; } /** * Returns a clone of the object (a deeper clone than default to avoid bugs * when setting values in cloned object). * * @return The clone. * * @throws CloneNotSupportedException if cloning is not supported. */ public Object clone() throws CloneNotSupportedException { ClipPath clone = (ClipPath) super.clone(); clone.xValue = (double[]) this.xValue.clone(); clone.yValue = (double[]) this.yValue.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/DrawableLegendItem.java0000644000175000017500000001502711173030414026760 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DrawableLegendItem.java * ----------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Luke Quinane; * Barak Naveh; * * Changes * ------- * 07-Feb-2002 : Version 1 (DG); * 23-Sep-2002 : Renamed LegendItem --> DrawableLegendItem (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Oct-2003 : Applied patch for displaying series line style, contributed by * Luke Quinane (DG); * 27-Mar-2004 : Added getMaxX() and getMaxY() methods (BN); * 27-Jan-2005 : Cleared out code that belongs in the LegendItem class (DG); * */ package org.jfree.chart; import java.awt.Shape; import java.awt.geom.Line2D; import java.awt.geom.Point2D; /** * This class contains a single legend item along with position details for * drawing the item on a particular chart. * * @deprecated This class is not used by JFreeChart. */ public class DrawableLegendItem { /** * The legend item (encapsulates information about the label, color and * shape). */ private LegendItem item; /** The x-coordinate for the item's location. */ private double x; /** The y-coordinate for the item's location. */ private double y; /** The width of the item. */ private double width; /** The height of the item. */ private double height; /** A shape used to indicate color on the legend. */ private Shape marker; /** A line used to indicate the series stroke on the legend */ private Line2D line; /** The label position within the item. */ private Point2D labelPosition; /** * Create a legend item. * * @param item the legend item for display. */ public DrawableLegendItem(LegendItem item) { this.item = item; } /** * Returns the legend item. * * @return The legend item. */ public LegendItem getItem() { return this.item; } /** * Get the x-coordinate for the item's location. * * @return The x-coordinate for the item's location. */ public double getX() { return this.x; } /** * Set the x-coordinate for the item's location. * * @param x the x-coordinate. */ public void setX(double x) { this.x = x; } /** * Get the y-coordinate for the item's location. * * @return The y-coordinate for the item's location. */ public double getY() { return this.y; } /** * Set the y-coordinate for the item's location. * * @param y the y-coordinate. */ public void setY(double y) { this.y = y; } /** * Get the width of this item. * * @return The width. */ public double getWidth() { return this.width; } /** * Get the height of this item. * * @return The height. */ public double getHeight() { return this.height; } /** * Returns the largest X coordinate of the framing rectangle of this legend * item. * * @return The largest x coordinate of the framing rectangle of this legend * item. */ public double getMaxX() { return getX() + getWidth(); } /** * Returns the largest Y coordinate of the framing rectangle of this legend * item. * * @return The largest Y coordinate of the framing rectangle of this legend * item. */ public double getMaxY() { return getY() + getHeight(); } /** * Get the marker. * * @return The shape used to indicate color on the legend for this item. */ public Shape getMarker() { return this.marker; } /** * Set the marker. * * @param marker a shape used to indicate color on the legend for this * item. */ public void setMarker(Shape marker) { this.marker = marker; } /** * Sets the line used to label this series. * * @param l the new line to use. */ public void setLine(Line2D l) { this.line = l; } /** * Returns the list. * * @return The line. */ public Line2D getLine() { return this.line; } /** * Returns the label position. * * @return The label position. */ public Point2D getLabelPosition() { return this.labelPosition; } /** * Sets the label position. * * @param position the label position. */ public void setLabelPosition(Point2D position) { this.labelPosition = position; } /** * Set the bounds of this item. * * @param x x-coordinate for the item's location. * @param y y-coordinate for the item's location. * @param width the width of this item. * @param height the height of this item. */ public void setBounds(double x, double y, double width, double height) { this.x = x; this.y = y; this.width = width; this.height = height; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/Effect3D.java0000644000175000017500000000410111173030414024653 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * Effect3D.java * ------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Nov-2002 : Version 1 (DG); * 14-Nov-2002 : Modified to have independent x and y offsets (DG); * */ package org.jfree.chart; /** * An interface that should be implemented by renderers that use a 3D effect. * This allows the axes to mirror the same effect by querying the renderer. */ public interface Effect3D { /** * Returns the x-offset (in Java2D units) for the 3D effect. * * @return The offset. */ public double getXOffset(); /** * Returns the y-offset (in Java2D units) for the 3D effect. * * @return The offset. */ public double getYOffset(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/HashUtilities.java0000644000175000017500000002555211173030414026064 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * HashUtilities.java * ------------------ * (C) Copyright 2006, 2007, by Object Refinery Limited; * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Oct-2006 : Version 1 (DG); * 06-Mar-2007 : Fix for hashCodeForDoubleArray() method (DG); * 13-Nov-2007 : Added new utility methods (DG); * 22-Nov-2007 : Added hashCode() method for 'int' (DG); * 05-Dec-2007 : Added special methods to handle BooleanList, PaintList, * and StrokeList (DG); * */ package org.jfree.chart; import java.awt.GradientPaint; import java.awt.Paint; import java.awt.Stroke; import org.jfree.util.BooleanList; import org.jfree.util.PaintList; import org.jfree.util.StrokeList; /** * Some utility methods for calculating hash codes. * * @since 1.0.3 */ public class HashUtilities { /** * Returns a hash code for a Paint instance. If * p is null, this method returns zero. * * @param p the paint (null permitted). * * @return The hash code. */ public static int hashCodeForPaint(Paint p) { if (p == null) { return 0; } int result = 0; // handle GradientPaint as a special case if (p instanceof GradientPaint) { GradientPaint gp = (GradientPaint) p; result = 193; result = 37 * result + gp.getColor1().hashCode(); result = 37 * result + gp.getPoint1().hashCode(); result = 37 * result + gp.getColor2().hashCode(); result = 37 * result + gp.getPoint2().hashCode(); } else { // we assume that all other Paint instances implement equals() and // hashCode()...of course that might not be true, but what can we // do about it? result = p.hashCode(); } return result; } /** * Returns a hash code for a double[] instance. If the array * is null, this method returns zero. * * @param a the array (null permitted). * * @return The hash code. */ public static int hashCodeForDoubleArray(double[] a) { if (a == null) { return 0; } int result = 193; long temp; for (int i = 0; i < a.length; i++) { temp = Double.doubleToLongBits(a[i]); result = 29 * result + (int) (temp ^ (temp >>> 32)); } return result; } /** * Returns a hash value based on a seed value and the value of a boolean * primitive. * * @param pre the seed value. * @param b the boolean value. * * @return A hash value. * * @since 1.0.7 */ public static int hashCode(int pre, boolean b) { return 37 * pre + (b ? 0 : 1); } /** * Returns a hash value based on a seed value and the value of an int * primitive. * * @param pre the seed value. * @param i the int value. * * @return A hash value. * * @since 1.0.8 */ public static int hashCode(int pre, int i) { return 37 * pre + i; } /** * Returns a hash value based on a seed value and the value of a double * primitive. * * @param pre the seed value. * @param d the double value. * * @return A hash value. * * @since 1.0.7 */ public static int hashCode(int pre, double d) { long l = Double.doubleToLongBits(d); return 37 * pre + (int) (l ^ (l >>> 32)); } /** * Returns a hash value based on a seed value and a paint instance. * * @param pre the seed value. * @param p the paint (null permitted). * * @return A hash value. * * @since 1.0.7 */ public static int hashCode(int pre, Paint p) { return 37 * pre + hashCodeForPaint(p); } /** * Returns a hash value based on a seed value and a stroke instance. * * @param pre the seed value. * @param s the stroke (null permitted). * * @return A hash value. * * @since 1.0.7 */ public static int hashCode(int pre, Stroke s) { int h = (s != null ? s.hashCode() : 0); return 37 * pre + h; } /** * Returns a hash value based on a seed value and a string instance. * * @param pre the seed value. * @param s the string (null permitted). * * @return A hash value. * * @since 1.0.7 */ public static int hashCode(int pre, String s) { int h = (s != null ? s.hashCode() : 0); return 37 * pre + h; } /** * Returns a hash value based on a seed value and a Comparable * instance. * * @param pre the seed value. * @param c the comparable (null permitted). * * @return A hash value. * * @since 1.0.7 */ public static int hashCode(int pre, Comparable c) { int h = (c != null ? c.hashCode() : 0); return 37 * pre + h; } /** * Returns a hash value based on a seed value and an Object * instance. * * @param pre the seed value. * @param obj the object (null permitted). * * @return A hash value. * * @since 1.0.8 */ public static int hashCode(int pre, Object obj) { int h = (obj != null ? obj.hashCode() : 0); return 37 * pre + h; } /** * Computes a hash code for a {@link BooleanList}. In the latest version * of JCommon, the {@link BooleanList} class should implement the hashCode() * method correctly, but we compute it here anyway so that we can work with * older versions of JCommon (back to 1.0.0). * * @param pre the seed value. * @param list the list (null permitted). * * @return The hash code. * * @since 1.0.9 */ public static int hashCode(int pre, BooleanList list) { if (list == null) { return pre; } int result = 127; int size = list.size(); result = HashUtilities.hashCode(result, size); // for efficiency, we just use the first, last and middle items to // compute a hashCode... if (size > 0) { result = HashUtilities.hashCode(result, list.getBoolean(0)); if (size > 1) { result = HashUtilities.hashCode(result, list.getBoolean(size - 1)); if (size > 2) { result = HashUtilities.hashCode(result, list.getBoolean(size / 2)); } } } return 37 * pre + result; } /** * Computes a hash code for a {@link PaintList}. In the latest version * of JCommon, the {@link PaintList} class should implement the hashCode() * method correctly, but we compute it here anyway so that we can work with * older versions of JCommon (back to 1.0.0). * * @param pre the seed value. * @param list the list (null permitted). * * @return The hash code. * * @since 1.0.9 */ public static int hashCode(int pre, PaintList list) { if (list == null) { return pre; } int result = 127; int size = list.size(); result = HashUtilities.hashCode(result, size); // for efficiency, we just use the first, last and middle items to // compute a hashCode... if (size > 0) { result = HashUtilities.hashCode(result, list.getPaint(0)); if (size > 1) { result = HashUtilities.hashCode(result, list.getPaint(size - 1)); if (size > 2) { result = HashUtilities.hashCode(result, list.getPaint(size / 2)); } } } return 37 * pre + result; } /** * Computes a hash code for a {@link StrokeList}. In the latest version * of JCommon, the {@link StrokeList} class should implement the hashCode() * method correctly, but we compute it here anyway so that we can work with * older versions of JCommon (back to 1.0.0). * * @param pre the seed value. * @param list the list (null permitted). * * @return The hash code. * * @since 1.0.9 */ public static int hashCode(int pre, StrokeList list) { if (list == null) { return pre; } int result = 127; int size = list.size(); result = HashUtilities.hashCode(result, size); // for efficiency, we just use the first, last and middle items to // compute a hashCode... if (size > 0) { result = HashUtilities.hashCode(result, list.getStroke(0)); if (size > 1) { result = HashUtilities.hashCode(result, list.getStroke(size - 1)); if (size > 2) { result = HashUtilities.hashCode(result, list.getStroke(size / 2)); } } } return 37 * pre + result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/JFreeChart.java0000644000175000017500000020731011173030414025254 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * JFreeChart.java * --------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrzej Porebski; * David Li; * Wolfgang Irler; * Christian W. Zuckschwerdt; * Klaus Rheinwald; * Nicolas Brodu; * Peter Kolb (patch 2603321); * * NOTE: The above list of contributors lists only the people that have * contributed to this source file (JFreeChart.java) - for a list of ALL * contributors to the project, please see the README.txt file. * * Changes (from 20-Jun-2001) * -------------------------- * 20-Jun-2001 : Modifications submitted by Andrzej Porebski for legend * placement; * 21-Jun-2001 : Removed JFreeChart parameter from Plot constructors (DG); * 22-Jun-2001 : Multiple titles added (original code by David Berry, with * reworkings by DG); * 18-Sep-2001 : Updated header (DG); * 15-Oct-2001 : Moved data source classes into new package * com.jrefinery.data.* (DG); * 18-Oct-2001 : New factory method for creating VerticalXYBarChart (DG); * 19-Oct-2001 : Moved series paint and stroke methods to the Plot class (DG); * Moved static chart creation methods to new ChartFactory * class (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * Fixed bug where chart isn't registered with the dataset (DG); * 07-Nov-2001 : Fixed bug where null title in constructor causes * exception (DG); * Tidied up event notification code (DG); * 17-Nov-2001 : Added getLegendItemCount() method (DG); * 21-Nov-2001 : Set clipping in draw method to ensure that nothing gets drawn * outside the chart area (DG); * 11-Dec-2001 : Added the createBufferedImage() method, taken from the * JFreeChartServletDemo class (DG); * 13-Dec-2001 : Added tooltips (DG); * 16-Jan-2002 : Added handleClick() method (DG); * 22-Jan-2002 : Fixed bug correlating legend labels with pie data (DG); * 05-Feb-2002 : Removed redundant tooltips code (DG); * 19-Feb-2002 : Added accessor methods for the backgroundImage and * backgroundImageAlpha attributes (DG); * 21-Feb-2002 : Added static fields for INFO, COPYRIGHT, LICENCE, CONTRIBUTORS * and LIBRARIES. These can be used to display information about * JFreeChart (DG); * 06-Mar-2002 : Moved constants to JFreeChartConstants interface (DG); * 18-Apr-2002 : PieDataset is no longer sorted (oldman); * 23-Apr-2002 : Moved dataset to the Plot class (DG); * 13-Jun-2002 : Added an extra draw() method (DG); * 25-Jun-2002 : Implemented the Drawable interface and removed redundant * imports (DG); * 26-Jun-2002 : Added another createBufferedImage() method (DG); * 18-Sep-2002 : Fixed issues reported by Checkstyle (DG); * 23-Sep-2002 : Added new contributor (DG); * 28-Oct-2002 : Created main title and subtitle list to replace existing title * list (DG); * 08-Jan-2003 : Added contributor (DG); * 17-Jan-2003 : Added new constructor (DG); * 22-Jan-2003 : Added ChartColor class by Cameron Riley, and background image * alignment code by Christian W. Zuckschwerdt (DG); * 11-Feb-2003 : Added flag to allow suppression of chart change events, based * on a suggestion by Klaus Rheinwald (DG); * 04-Mar-2003 : Added small fix for suppressed chart change events (see bug id * 690865) (DG); * 10-Mar-2003 : Added Benoit Xhenseval to contributors (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 15-Jul-2003 : Added an optional border for the chart (DG); * 11-Sep-2003 : Took care of listeners while cloning (NB); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 22-Sep-2003 : Added nullpointer checks. * 25-Sep-2003 : Added nullpointer checks too (NB). * 03-Dec-2003 : Legends are now registered by this class instead of using the * old constructor way (TM); * 03-Dec-2003 : Added anchorPoint to draw() method (DG); * 08-Jan-2004 : Reworked title code, introducing line wrapping (DG); * 09-Feb-2004 : Created additional createBufferedImage() method (DG); * 05-Apr-2004 : Added new createBufferedImage() method (DG); * 27-May-2004 : Moved constants from JFreeChartConstants.java back to this * class (DG); * 25-Nov-2004 : Updates for changes to Title class (DG); * 06-Jan-2005 : Change lookup for default background color (DG); * 31-Jan-2005 : Added Don Elliott to contributors (DG); * 02-Feb-2005 : Added clearSubtitles() method (DG); * 03-Feb-2005 : Added Mofeed Shahin to contributors (DG); * 08-Feb-2005 : Updated for RectangleConstraint changes (DG); * 28-Mar-2005 : Renamed Legend --> OldLegend (DG); * 12-Apr-2005 : Added methods to access legend(s) in subtitle list (DG); * 13-Apr-2005 : Added removeLegend() and removeSubtitle() methods (DG); * 20-Apr-2005 : Modified to collect chart entities from titles and * subtitles (DG); * 26-Apr-2005 : Removed LOGGER (DG); * 06-Jun-2005 : Added addLegend() method and padding attribute, fixed equals() * method (DG); * 24-Nov-2005 : Removed OldLegend and related code - don't want to support * this in 1.0.0 final (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 27-Jan-2006 : Updated version number (DG); * 07-Dec-2006 : Added some missing credits (DG); * 17-Jan-2007 : Added Darren Jung to contributor list (DG); * 05-Mar-2007 : Added Sergei Ivanov to the contributor list (DG); * 16-Mar-2007 : Modified initial legend border (DG); * 22-Mar-2007 : New methods for text anti-aliasing (DG); * 16-May-2007 : Fixed argument check in getSubtitle(), copy list in * get/setSubtitles(), and added new addSubtitle(int, Title) * method (DG); * 05-Jun-2007 : Add change listener to default legend (DG); * 04-Dec-2007 : In createBufferedImage() methods, make the default image type * BufferedImage.TYPE_INT_ARGB (thanks to Klaus Rheinwald) (DG); * 05-Dec-2007 : Fixed bug 1749124 (not registering as listener with * TextTitle) (DG); * 23-Apr-2008 : Added new contributor (Diego Pierangeli) (DG); * 16-May-2008 : Added new contributor (Michael Siemer) (DG); * 19-Sep-2008 : Check for title visibility (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); * */ package org.jfree.chart; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Paint; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; import javax.swing.ImageIcon; import javax.swing.UIManager; import javax.swing.event.EventListenerList; import org.jfree.JCommon; import org.jfree.chart.block.BlockParams; import org.jfree.chart.block.EntityBlockResult; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.LineBorder; import org.jfree.chart.block.RectangleConstraint; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.JFreeChartEntity; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.event.ChartProgressEvent; import org.jfree.chart.event.ChartProgressListener; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.chart.event.TitleChangeEvent; import org.jfree.chart.event.TitleChangeListener; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.title.LegendTitle; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; import org.jfree.ui.Align; import org.jfree.ui.Drawable; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.Size2D; import org.jfree.ui.VerticalAlignment; import org.jfree.ui.about.Contributor; import org.jfree.ui.about.Licences; import org.jfree.ui.about.ProjectInfo; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; /** * A chart class implemented using the Java 2D APIs. The current version * supports bar charts, line charts, pie charts and xy plots (including time * series data). *

* JFreeChart coordinates several objects to achieve its aim of being able to * draw a chart on a Java 2D graphics device: a list of {@link Title} objects * (which often includes the chart's legend), a {@link Plot} and a * {@link org.jfree.data.general.Dataset} (the plot in turn manages a * domain axis and a range axis). *

* You should use a {@link ChartPanel} to display a chart in a GUI. *

* The {@link ChartFactory} class contains static methods for creating * 'ready-made' charts. * * @see ChartPanel * @see ChartFactory * @see Title * @see Plot */ public class JFreeChart implements Drawable, TitleChangeListener, PlotChangeListener, Serializable, Cloneable { /** For serialization. */ private static final long serialVersionUID = -3470703747817429120L; /** Information about the project. */ public static final ProjectInfo INFO = new JFreeChartInfo(); /** The default font for titles. */ public static final Font DEFAULT_TITLE_FONT = new Font("SansSerif", Font.BOLD, 18); /** The default background color. */ public static final Paint DEFAULT_BACKGROUND_PAINT = UIManager.getColor("Panel.background"); /** The default background image. */ public static final Image DEFAULT_BACKGROUND_IMAGE = null; /** The default background image alignment. */ public static final int DEFAULT_BACKGROUND_IMAGE_ALIGNMENT = Align.FIT; /** The default background image alpha. */ public static final float DEFAULT_BACKGROUND_IMAGE_ALPHA = 0.5f; /** * Rendering hints that will be used for chart drawing. This should never * be null. */ private transient RenderingHints renderingHints; /** A flag that controls whether or not the chart border is drawn. */ private boolean borderVisible; /** The stroke used to draw the chart border (if visible). */ private transient Stroke borderStroke; /** The paint used to draw the chart border (if visible). */ private transient Paint borderPaint; /** The padding between the chart border and the chart drawing area. */ private RectangleInsets padding; /** The chart title (optional). */ private TextTitle title; /** * The chart subtitles (zero, one or many). This field should never be * null. */ private List subtitles; /** Draws the visual representation of the data. */ private Plot plot; /** Paint used to draw the background of the chart. */ private transient Paint backgroundPaint; /** An optional background image for the chart. */ private transient Image backgroundImage; // todo: not serialized yet /** The alignment for the background image. */ private int backgroundImageAlignment = Align.FIT; /** The alpha transparency for the background image. */ private float backgroundImageAlpha = 0.5f; /** Storage for registered change listeners. */ private transient EventListenerList changeListeners; /** Storage for registered progress listeners. */ private transient EventListenerList progressListeners; /** * A flag that can be used to enable/disable notification of chart change * events. */ private boolean notify; /** * Creates a new chart based on the supplied plot. The chart will have * a legend added automatically, but no title (although you can easily add * one later). *

* Note that the {@link ChartFactory} class contains a range * of static methods that will return ready-made charts, and often this * is a more convenient way to create charts than using this constructor. * * @param plot the plot (null not permitted). */ public JFreeChart(Plot plot) { this(null, null, plot, true); } /** * Creates a new chart with the given title and plot. A default font * ({@link #DEFAULT_TITLE_FONT}) is used for the title, and the chart will * have a legend added automatically. *

* Note that the {@link ChartFactory} class contains a range * of static methods that will return ready-made charts, and often this * is a more convenient way to create charts than using this constructor. * * @param title the chart title (null permitted). * @param plot the plot (null not permitted). */ public JFreeChart(String title, Plot plot) { this(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); } /** * Creates a new chart with the given title and plot. The * createLegend argument specifies whether or not a legend * should be added to the chart. *

* Note that the {@link ChartFactory} class contains a range * of static methods that will return ready-made charts, and often this * is a more convenient way to create charts than using this constructor. * * @param title the chart title (null permitted). * @param titleFont the font for displaying the chart title * (null permitted). * @param plot controller of the visual representation of the data * (null not permitted). * @param createLegend a flag indicating whether or not a legend should * be created for the chart. */ public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend) { if (plot == null) { throw new NullPointerException("Null 'plot' argument."); } // create storage for listeners... this.progressListeners = new EventListenerList(); this.changeListeners = new EventListenerList(); this.notify = true; // default is to notify listeners when the // chart changes this.renderingHints = new RenderingHints( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); this.borderVisible = false; this.borderStroke = new BasicStroke(1.0f); this.borderPaint = Color.black; this.padding = RectangleInsets.ZERO_INSETS; this.plot = plot; plot.addChangeListener(this); this.subtitles = new ArrayList(); // create a legend, if requested... if (createLegend) { LegendTitle legend = new LegendTitle(this.plot); legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); legend.setFrame(new LineBorder()); legend.setBackgroundPaint(Color.white); legend.setPosition(RectangleEdge.BOTTOM); this.subtitles.add(legend); legend.addChangeListener(this); } // add the chart title, if one has been specified... if (title != null) { if (titleFont == null) { titleFont = DEFAULT_TITLE_FONT; } this.title = new TextTitle(title, titleFont); this.title.addChangeListener(this); } this.backgroundPaint = DEFAULT_BACKGROUND_PAINT; this.backgroundImage = DEFAULT_BACKGROUND_IMAGE; this.backgroundImageAlignment = DEFAULT_BACKGROUND_IMAGE_ALIGNMENT; this.backgroundImageAlpha = DEFAULT_BACKGROUND_IMAGE_ALPHA; } /** * Returns the collection of rendering hints for the chart. * * @return The rendering hints for the chart (never null). * * @see #setRenderingHints(RenderingHints) */ public RenderingHints getRenderingHints() { return this.renderingHints; } /** * Sets the rendering hints for the chart. These will be added (using the * Graphics2D.addRenderingHints() method) near the start of the * JFreeChart.draw() method. * * @param renderingHints the rendering hints (null not * permitted). * * @see #getRenderingHints() */ public void setRenderingHints(RenderingHints renderingHints) { if (renderingHints == null) { throw new NullPointerException("RenderingHints given are null"); } this.renderingHints = renderingHints; fireChartChanged(); } /** * Returns a flag that controls whether or not a border is drawn around the * outside of the chart. * * @return A boolean. * * @see #setBorderVisible(boolean) */ public boolean isBorderVisible() { return this.borderVisible; } /** * Sets a flag that controls whether or not a border is drawn around the * outside of the chart. * * @param visible the flag. * * @see #isBorderVisible() */ public void setBorderVisible(boolean visible) { this.borderVisible = visible; fireChartChanged(); } /** * Returns the stroke used to draw the chart border (if visible). * * @return The border stroke. * * @see #setBorderStroke(Stroke) */ public Stroke getBorderStroke() { return this.borderStroke; } /** * Sets the stroke used to draw the chart border (if visible). * * @param stroke the stroke. * * @see #getBorderStroke() */ public void setBorderStroke(Stroke stroke) { this.borderStroke = stroke; fireChartChanged(); } /** * Returns the paint used to draw the chart border (if visible). * * @return The border paint. * * @see #setBorderPaint(Paint) */ public Paint getBorderPaint() { return this.borderPaint; } /** * Sets the paint used to draw the chart border (if visible). * * @param paint the paint. * * @see #getBorderPaint() */ public void setBorderPaint(Paint paint) { this.borderPaint = paint; fireChartChanged(); } /** * Returns the padding between the chart border and the chart drawing area. * * @return The padding (never null). * * @see #setPadding(RectangleInsets) */ public RectangleInsets getPadding() { return this.padding; } /** * Sets the padding between the chart border and the chart drawing area, * and sends a {@link ChartChangeEvent} to all registered listeners. * * @param padding the padding (null not permitted). * * @see #getPadding() */ public void setPadding(RectangleInsets padding) { if (padding == null) { throw new IllegalArgumentException("Null 'padding' argument."); } this.padding = padding; notifyListeners(new ChartChangeEvent(this)); } /** * Returns the main chart title. Very often a chart will have just one * title, so we make this case simple by providing accessor methods for * the main title. However, multiple titles are supported - see the * {@link #addSubtitle(Title)} method. * * @return The chart title (possibly null). * * @see #setTitle(TextTitle) */ public TextTitle getTitle() { return this.title; } /** * Sets the main title for the chart and sends a {@link ChartChangeEvent} * to all registered listeners. If you do not want a title for the * chart, set it to null. If you want more than one title on * a chart, use the {@link #addSubtitle(Title)} method. * * @param title the title (null permitted). * * @see #getTitle() */ public void setTitle(TextTitle title) { if (this.title != null) { this.title.removeChangeListener(this); } this.title = title; if (title != null) { title.addChangeListener(this); } fireChartChanged(); } /** * Sets the chart title and sends a {@link ChartChangeEvent} to all * registered listeners. This is a convenience method that ends up calling * the {@link #setTitle(TextTitle)} method. If there is an existing title, * its text is updated, otherwise a new title using the default font is * added to the chart. If text is null the chart * title is set to null. * * @param text the title text (null permitted). * * @see #getTitle() */ public void setTitle(String text) { if (text != null) { if (this.title == null) { setTitle(new TextTitle(text, JFreeChart.DEFAULT_TITLE_FONT)); } else { this.title.setText(text); } } else { setTitle((TextTitle) null); } } /** * Adds a legend to the plot and sends a {@link ChartChangeEvent} to all * registered listeners. * * @param legend the legend (null not permitted). * * @see #removeLegend() */ public void addLegend(LegendTitle legend) { addSubtitle(legend); } /** * Returns the legend for the chart, if there is one. Note that a chart * can have more than one legend - this method returns the first. * * @return The legend (possibly null). * * @see #getLegend(int) */ public LegendTitle getLegend() { return getLegend(0); } /** * Returns the nth legend for a chart, or null. * * @param index the legend index (zero-based). * * @return The legend (possibly null). * * @see #addLegend(LegendTitle) */ public LegendTitle getLegend(int index) { int seen = 0; Iterator iterator = this.subtitles.iterator(); while (iterator.hasNext()) { Title subtitle = (Title) iterator.next(); if (subtitle instanceof LegendTitle) { if (seen == index) { return (LegendTitle) subtitle; } else { seen++; } } } return null; } /** * Removes the first legend in the chart and sends a * {@link ChartChangeEvent} to all registered listeners. * * @see #getLegend() */ public void removeLegend() { removeSubtitle(getLegend()); } /** * Returns the list of subtitles for the chart. * * @return The subtitle list (possibly empty, but never null). * * @see #setSubtitles(List) */ public List getSubtitles() { return new ArrayList(this.subtitles); } /** * Sets the title list for the chart (completely replaces any existing * titles) and sends a {@link ChartChangeEvent} to all registered * listeners. * * @param subtitles the new list of subtitles (null not * permitted). * * @see #getSubtitles() */ public void setSubtitles(List subtitles) { if (subtitles == null) { throw new NullPointerException("Null 'subtitles' argument."); } setNotify(false); clearSubtitles(); Iterator iterator = subtitles.iterator(); while (iterator.hasNext()) { Title t = (Title) iterator.next(); if (t != null) { addSubtitle(t); } } setNotify(true); // this fires a ChartChangeEvent } /** * Returns the number of titles for the chart. * * @return The number of titles for the chart. * * @see #getSubtitles() */ public int getSubtitleCount() { return this.subtitles.size(); } /** * Returns a chart subtitle. * * @param index the index of the chart subtitle (zero based). * * @return A chart subtitle. * * @see #addSubtitle(Title) */ public Title getSubtitle(int index) { if ((index < 0) || (index >= getSubtitleCount())) { throw new IllegalArgumentException("Index out of range."); } return (Title) this.subtitles.get(index); } /** * Adds a chart subtitle, and notifies registered listeners that the chart * has been modified. * * @param subtitle the subtitle (null not permitted). * * @see #getSubtitle(int) */ public void addSubtitle(Title subtitle) { if (subtitle == null) { throw new IllegalArgumentException("Null 'subtitle' argument."); } this.subtitles.add(subtitle); subtitle.addChangeListener(this); fireChartChanged(); } /** * Adds a subtitle at a particular position in the subtitle list, and sends * a {@link ChartChangeEvent} to all registered listeners. * * @param index the index (in the range 0 to {@link #getSubtitleCount()}). * @param subtitle the subtitle to add (null not permitted). * * @since 1.0.6 */ public void addSubtitle(int index, Title subtitle) { if (index < 0 || index > getSubtitleCount()) { throw new IllegalArgumentException( "The 'index' argument is out of range."); } if (subtitle == null) { throw new IllegalArgumentException("Null 'subtitle' argument."); } this.subtitles.add(index, subtitle); subtitle.addChangeListener(this); fireChartChanged(); } /** * Clears all subtitles from the chart and sends a {@link ChartChangeEvent} * to all registered listeners. * * @see #addSubtitle(Title) */ public void clearSubtitles() { Iterator iterator = this.subtitles.iterator(); while (iterator.hasNext()) { Title t = (Title) iterator.next(); t.removeChangeListener(this); } this.subtitles.clear(); fireChartChanged(); } /** * Removes the specified subtitle and sends a {@link ChartChangeEvent} to * all registered listeners. * * @param title the title. * * @see #addSubtitle(Title) */ public void removeSubtitle(Title title) { this.subtitles.remove(title); fireChartChanged(); } /** * Returns the plot for the chart. The plot is a class responsible for * coordinating the visual representation of the data, including the axes * (if any). * * @return The plot. */ public Plot getPlot() { return this.plot; } /** * Returns the plot cast as a {@link CategoryPlot}. *

* NOTE: if the plot is not an instance of {@link CategoryPlot}, then a * ClassCastException is thrown. * * @return The plot. * * @see #getPlot() */ public CategoryPlot getCategoryPlot() { return (CategoryPlot) this.plot; } /** * Returns the plot cast as an {@link XYPlot}. *

* NOTE: if the plot is not an instance of {@link XYPlot}, then a * ClassCastException is thrown. * * @return The plot. * * @see #getPlot() */ public XYPlot getXYPlot() { return (XYPlot) this.plot; } /** * Returns a flag that indicates whether or not anti-aliasing is used when * the chart is drawn. * * @return The flag. * * @see #setAntiAlias(boolean) */ public boolean getAntiAlias() { Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING); return RenderingHints.VALUE_ANTIALIAS_ON.equals(val); } /** * Sets a flag that indicates whether or not anti-aliasing is used when the * chart is drawn. *

* Anti-aliasing usually improves the appearance of charts, but is slower. * * @param flag the new value of the flag. * * @see #getAntiAlias() */ public void setAntiAlias(boolean flag) { Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING); if (val == null) { val = RenderingHints.VALUE_ANTIALIAS_DEFAULT; } if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(val) || flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(val)) { // no change, do nothing return; } if (flag) { this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else { this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } fireChartChanged(); } /** * Returns the current value stored in the rendering hints table for * {@link RenderingHints#KEY_TEXT_ANTIALIASING}. * * @return The hint value (possibly null). * * @since 1.0.5 * * @see #setTextAntiAlias(Object) */ public Object getTextAntiAlias() { return this.renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); } /** * Sets the value in the rendering hints table for * {@link RenderingHints#KEY_TEXT_ANTIALIASING} to either * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_ON} or * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_OFF}, then sends a * {@link ChartChangeEvent} to all registered listeners. * * @param flag the new value of the flag. * * @since 1.0.5 * * @see #getTextAntiAlias() * @see #setTextAntiAlias(Object) */ public void setTextAntiAlias(boolean flag) { if (flag) { setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } } /** * Sets the value in the rendering hints table for * {@link RenderingHints#KEY_TEXT_ANTIALIASING} and sends a * {@link ChartChangeEvent} to all registered listeners. * * @param val the new value (null permitted). * * @since 1.0.5 * * @see #getTextAntiAlias() * @see #setTextAntiAlias(boolean) */ public void setTextAntiAlias(Object val) { this.renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, val); notifyListeners(new ChartChangeEvent(this)); } /** * Returns the paint used for the chart background. * * @return The paint (possibly null). * * @see #setBackgroundPaint(Paint) */ public Paint getBackgroundPaint() { return this.backgroundPaint; } /** * Sets the paint used to fill the chart background and sends a * {@link ChartChangeEvent} to all registered listeners. * * @param paint the paint (null permitted). * * @see #getBackgroundPaint() */ public void setBackgroundPaint(Paint paint) { if (this.backgroundPaint != null) { if (!this.backgroundPaint.equals(paint)) { this.backgroundPaint = paint; fireChartChanged(); } } else { if (paint != null) { this.backgroundPaint = paint; fireChartChanged(); } } } /** * Returns the background image for the chart, or null if * there is no image. * * @return The image (possibly null). * * @see #setBackgroundImage(Image) */ public Image getBackgroundImage() { return this.backgroundImage; } /** * Sets the background image for the chart and sends a * {@link ChartChangeEvent} to all registered listeners. * * @param image the image (null permitted). * * @see #getBackgroundImage() */ public void setBackgroundImage(Image image) { if (this.backgroundImage != null) { if (!this.backgroundImage.equals(image)) { this.backgroundImage = image; fireChartChanged(); } } else { if (image != null) { this.backgroundImage = image; fireChartChanged(); } } } /** * Returns the background image alignment. Alignment constants are defined * in the org.jfree.ui.Align class in the JCommon class * library. * * @return The alignment. * * @see #setBackgroundImageAlignment(int) */ public int getBackgroundImageAlignment() { return this.backgroundImageAlignment; } /** * Sets the background alignment. Alignment options are defined by the * {@link org.jfree.ui.Align} class. * * @param alignment the alignment. * * @see #getBackgroundImageAlignment() */ public void setBackgroundImageAlignment(int alignment) { if (this.backgroundImageAlignment != alignment) { this.backgroundImageAlignment = alignment; fireChartChanged(); } } /** * Returns the alpha-transparency for the chart's background image. * * @return The alpha-transparency. * * @see #setBackgroundImageAlpha(float) */ public float getBackgroundImageAlpha() { return this.backgroundImageAlpha; } /** * Sets the alpha-transparency for the chart's background image. * Registered listeners are notified that the chart has been changed. * * @param alpha the alpha value. * * @see #getBackgroundImageAlpha() */ public void setBackgroundImageAlpha(float alpha) { if (this.backgroundImageAlpha != alpha) { this.backgroundImageAlpha = alpha; fireChartChanged(); } } /** * Returns a flag that controls whether or not change events are sent to * registered listeners. * * @return A boolean. * * @see #setNotify(boolean) */ public boolean isNotify() { return this.notify; } /** * Sets a flag that controls whether or not listeners receive * {@link ChartChangeEvent} notifications. * * @param notify a boolean. * * @see #isNotify() */ public void setNotify(boolean notify) { this.notify = notify; // if the flag is being set to true, there may be queued up changes... if (notify) { notifyListeners(new ChartChangeEvent(this)); } } /** * Draws the chart on a Java 2D graphics device (such as the screen or a * printer). *

* This method is the focus of the entire JFreeChart library. * * @param g2 the graphics device. * @param area the area within which the chart should be drawn. */ public void draw(Graphics2D g2, Rectangle2D area) { draw(g2, area, null, null); } /** * Draws the chart on a Java 2D graphics device (such as the screen or a * printer). This method is the focus of the entire JFreeChart library. * * @param g2 the graphics device. * @param area the area within which the chart should be drawn. * @param info records info about the drawing (null means collect no info). */ public void draw(Graphics2D g2, Rectangle2D area, ChartRenderingInfo info) { draw(g2, area, null, info); } /** * Draws the chart on a Java 2D graphics device (such as the screen or a * printer). *

* This method is the focus of the entire JFreeChart library. * * @param g2 the graphics device. * @param chartArea the area within which the chart should be drawn. * @param anchor the anchor point (in Java2D space) for the chart * (null permitted). * @param info records info about the drawing (null means collect no info). */ public void draw(Graphics2D g2, Rectangle2D chartArea, Point2D anchor, ChartRenderingInfo info) { notifyListeners(new ChartProgressEvent(this, this, ChartProgressEvent.DRAWING_STARTED, 0)); EntityCollection entities = null; // record the chart area, if info is requested... if (info != null) { info.clear(); info.setChartArea(chartArea); entities = info.getEntityCollection(); } if (entities != null) { entities.add(new JFreeChartEntity((Rectangle2D) chartArea.clone(), this)); } // ensure no drawing occurs outside chart area... Shape savedClip = g2.getClip(); g2.clip(chartArea); g2.addRenderingHints(this.renderingHints); // draw the chart background... if (this.backgroundPaint != null) { g2.setPaint(this.backgroundPaint); g2.fill(chartArea); } if (this.backgroundImage != null) { Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.backgroundImageAlpha)); Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, this.backgroundImage.getWidth(null), this.backgroundImage.getHeight(null)); Align.align(dest, chartArea, this.backgroundImageAlignment); g2.drawImage(this.backgroundImage, (int) dest.getX(), (int) dest.getY(), (int) dest.getWidth(), (int) dest.getHeight(), null); g2.setComposite(originalComposite); } if (isBorderVisible()) { Paint paint = getBorderPaint(); Stroke stroke = getBorderStroke(); if (paint != null && stroke != null) { Rectangle2D borderArea = new Rectangle2D.Double( chartArea.getX(), chartArea.getY(), chartArea.getWidth() - 1.0, chartArea.getHeight() - 1.0); g2.setPaint(paint); g2.setStroke(stroke); g2.draw(borderArea); } } // draw the title and subtitles... Rectangle2D nonTitleArea = new Rectangle2D.Double(); nonTitleArea.setRect(chartArea); this.padding.trim(nonTitleArea); if (this.title != null) { EntityCollection e = drawTitle(this.title, g2, nonTitleArea, (entities != null)); if (e != null) { entities.addAll(e); } } Iterator iterator = this.subtitles.iterator(); while (iterator.hasNext()) { Title currentTitle = (Title) iterator.next(); if (currentTitle.isVisible()) { EntityCollection e = drawTitle(currentTitle, g2, nonTitleArea, (entities != null)); if (e != null) { entities.addAll(e); } } } Rectangle2D plotArea = nonTitleArea; // draw the plot (axes and data visualisation) PlotRenderingInfo plotInfo = null; if (info != null) { plotInfo = info.getPlotInfo(); } this.plot.draw(g2, plotArea, anchor, null, plotInfo); g2.setClip(savedClip); notifyListeners(new ChartProgressEvent(this, this, ChartProgressEvent.DRAWING_FINISHED, 100)); } /** * Creates a rectangle that is aligned to the frame. * * @param dimensions the dimensions for the rectangle. * @param frame the frame to align to. * @param hAlign the horizontal alignment. * @param vAlign the vertical alignment. * * @return A rectangle. */ private Rectangle2D createAlignedRectangle2D(Size2D dimensions, Rectangle2D frame, HorizontalAlignment hAlign, VerticalAlignment vAlign) { double x = Double.NaN; double y = Double.NaN; if (hAlign == HorizontalAlignment.LEFT) { x = frame.getX(); } else if (hAlign == HorizontalAlignment.CENTER) { x = frame.getCenterX() - (dimensions.width / 2.0); } else if (hAlign == HorizontalAlignment.RIGHT) { x = frame.getMaxX() - dimensions.width; } if (vAlign == VerticalAlignment.TOP) { y = frame.getY(); } else if (vAlign == VerticalAlignment.CENTER) { y = frame.getCenterY() - (dimensions.height / 2.0); } else if (vAlign == VerticalAlignment.BOTTOM) { y = frame.getMaxY() - dimensions.height; } return new Rectangle2D.Double(x, y, dimensions.width, dimensions.height); } /** * Draws a title. The title should be drawn at the top, bottom, left or * right of the specified area, and the area should be updated to reflect * the amount of space used by the title. * * @param t the title (null not permitted). * @param g2 the graphics device (null not permitted). * @param area the chart area, excluding any existing titles * (null not permitted). * @param entities a flag that controls whether or not an entity * collection is returned for the title. * * @return An entity collection for the title (possibly null). */ protected EntityCollection drawTitle(Title t, Graphics2D g2, Rectangle2D area, boolean entities) { if (t == null) { throw new IllegalArgumentException("Null 't' argument."); } if (area == null) { throw new IllegalArgumentException("Null 'area' argument."); } Rectangle2D titleArea = new Rectangle2D.Double(); RectangleEdge position = t.getPosition(); double ww = area.getWidth(); if (ww <= 0.0) { return null; } double hh = area.getHeight(); if (hh <= 0.0) { return null; } RectangleConstraint constraint = new RectangleConstraint(ww, new Range(0.0, ww), LengthConstraintType.RANGE, hh, new Range(0.0, hh), LengthConstraintType.RANGE); Object retValue = null; BlockParams p = new BlockParams(); p.setGenerateEntities(entities); if (position == RectangleEdge.TOP) { Size2D size = t.arrange(g2, constraint); titleArea = createAlignedRectangle2D(size, area, t.getHorizontalAlignment(), VerticalAlignment.TOP); retValue = t.draw(g2, titleArea, p); area.setRect(area.getX(), Math.min(area.getY() + size.height, area.getMaxY()), area.getWidth(), Math.max(area.getHeight() - size.height, 0)); } else if (position == RectangleEdge.BOTTOM) { Size2D size = t.arrange(g2, constraint); titleArea = createAlignedRectangle2D(size, area, t.getHorizontalAlignment(), VerticalAlignment.BOTTOM); retValue = t.draw(g2, titleArea, p); area.setRect(area.getX(), area.getY(), area.getWidth(), area.getHeight() - size.height); } else if (position == RectangleEdge.RIGHT) { Size2D size = t.arrange(g2, constraint); titleArea = createAlignedRectangle2D(size, area, HorizontalAlignment.RIGHT, t.getVerticalAlignment()); retValue = t.draw(g2, titleArea, p); area.setRect(area.getX(), area.getY(), area.getWidth() - size.width, area.getHeight()); } else if (position == RectangleEdge.LEFT) { Size2D size = t.arrange(g2, constraint); titleArea = createAlignedRectangle2D(size, area, HorizontalAlignment.LEFT, t.getVerticalAlignment()); retValue = t.draw(g2, titleArea, p); area.setRect(area.getX() + size.width, area.getY(), area.getWidth() - size.width, area.getHeight()); } else { throw new RuntimeException("Unrecognised title position."); } EntityCollection result = null; if (retValue instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) retValue; result = ebr.getEntityCollection(); } return result; } /** * Creates and returns a buffered image into which the chart has been drawn. * * @param width the width. * @param height the height. * * @return A buffered image. */ public BufferedImage createBufferedImage(int width, int height) { return createBufferedImage(width, height, null); } /** * Creates and returns a buffered image into which the chart has been drawn. * * @param width the width. * @param height the height. * @param info carries back chart state information (null * permitted). * * @return A buffered image. */ public BufferedImage createBufferedImage(int width, int height, ChartRenderingInfo info) { return createBufferedImage(width, height, BufferedImage.TYPE_INT_ARGB, info); } /** * Creates and returns a buffered image into which the chart has been drawn. * * @param width the width. * @param height the height. * @param imageType the image type. * @param info carries back chart state information (null * permitted). * * @return A buffered image. */ public BufferedImage createBufferedImage(int width, int height, int imageType, ChartRenderingInfo info) { BufferedImage image = new BufferedImage(width, height, imageType); Graphics2D g2 = image.createGraphics(); draw(g2, new Rectangle2D.Double(0, 0, width, height), null, info); g2.dispose(); return image; } /** * Creates and returns a buffered image into which the chart has been drawn. * * @param imageWidth the image width. * @param imageHeight the image height. * @param drawWidth the width for drawing the chart (will be scaled to * fit image). * @param drawHeight the height for drawing the chart (will be scaled to * fit image). * @param info optional object for collection chart dimension and entity * information. * * @return A buffered image. */ public BufferedImage createBufferedImage(int imageWidth, int imageHeight, double drawWidth, double drawHeight, ChartRenderingInfo info) { BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); double scaleX = imageWidth / drawWidth; double scaleY = imageHeight / drawHeight; AffineTransform st = AffineTransform.getScaleInstance(scaleX, scaleY); g2.transform(st); draw(g2, new Rectangle2D.Double(0, 0, drawWidth, drawHeight), null, info); g2.dispose(); return image; } /** * Handles a 'click' on the chart. JFreeChart is not a UI component, so * some other object (for example, {@link ChartPanel}) needs to capture * the click event and pass it onto the JFreeChart object. * If you are not using JFreeChart in a client application, then this * method is not required. * * @param x x-coordinate of the click (in Java2D space). * @param y y-coordinate of the click (in Java2D space). * @param info contains chart dimension and entity information * (null not permitted). */ public void handleClick(int x, int y, ChartRenderingInfo info) { // pass the click on to the plot... // rely on the plot to post a plot change event and redraw the chart... this.plot.handleClick(x, y, info.getPlotInfo()); } /** * Registers an object for notification of changes to the chart. * * @param listener the listener (null not permitted). * * @see #removeChangeListener(ChartChangeListener) */ public void addChangeListener(ChartChangeListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.changeListeners.add(ChartChangeListener.class, listener); } /** * Deregisters an object for notification of changes to the chart. * * @param listener the listener (null not permitted) * * @see #addChangeListener(ChartChangeListener) */ public void removeChangeListener(ChartChangeListener listener) { if (listener == null) { throw new IllegalArgumentException("Null 'listener' argument."); } this.changeListeners.remove(ChartChangeListener.class, listener); } /** * Sends a default {@link ChartChangeEvent} to all registered listeners. *

* This method is for convenience only. */ public void fireChartChanged() { ChartChangeEvent event = new ChartChangeEvent(this); notifyListeners(event); } /** * Sends a {@link ChartChangeEvent} to all registered listeners. * * @param event information about the event that triggered the * notification. */ protected void notifyListeners(ChartChangeEvent event) { if (this.notify) { Object[] listeners = this.changeListeners.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ChartChangeListener.class) { ((ChartChangeListener) listeners[i + 1]).chartChanged( event); } } } } /** * Registers an object for notification of progress events relating to the * chart. * * @param listener the object being registered. * * @see #removeProgressListener(ChartProgressListener) */ public void addProgressListener(ChartProgressListener listener) { this.progressListeners.add(ChartProgressListener.class, listener); } /** * Deregisters an object for notification of changes to the chart. * * @param listener the object being deregistered. * * @see #addProgressListener(ChartProgressListener) */ public void removeProgressListener(ChartProgressListener listener) { this.progressListeners.remove(ChartProgressListener.class, listener); } /** * Sends a {@link ChartProgressEvent} to all registered listeners. * * @param event information about the event that triggered the * notification. */ protected void notifyListeners(ChartProgressEvent event) { Object[] listeners = this.progressListeners.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ChartProgressListener.class) { ((ChartProgressListener) listeners[i + 1]).chartProgress(event); } } } /** * Receives notification that a chart title has changed, and passes this * on to registered listeners. * * @param event information about the chart title change. */ public void titleChanged(TitleChangeEvent event) { event.setChart(this); notifyListeners(event); } /** * Receives notification that the plot has changed, and passes this on to * registered listeners. * * @param event information about the plot change. */ public void plotChanged(PlotChangeEvent event) { event.setChart(this); notifyListeners(event); } /** * Tests this chart for equality with another object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof JFreeChart)) { return false; } JFreeChart that = (JFreeChart) obj; if (!this.renderingHints.equals(that.renderingHints)) { return false; } if (this.borderVisible != that.borderVisible) { return false; } if (!ObjectUtilities.equal(this.borderStroke, that.borderStroke)) { return false; } if (!PaintUtilities.equal(this.borderPaint, that.borderPaint)) { return false; } if (!this.padding.equals(that.padding)) { return false; } if (!ObjectUtilities.equal(this.title, that.title)) { return false; } if (!ObjectUtilities.equal(this.subtitles, that.subtitles)) { return false; } if (!ObjectUtilities.equal(this.plot, that.plot)) { return false; } if (!PaintUtilities.equal( this.backgroundPaint, that.backgroundPaint )) { return false; } if (!ObjectUtilities.equal(this.backgroundImage, that.backgroundImage)) { return false; } if (this.backgroundImageAlignment != that.backgroundImageAlignment) { return false; } if (this.backgroundImageAlpha != that.backgroundImageAlpha) { return false; } if (this.notify != that.notify) { return false; } return true; } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeStroke(this.borderStroke, stream); SerialUtilities.writePaint(this.borderPaint, stream); SerialUtilities.writePaint(this.backgroundPaint, stream); } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.borderStroke = SerialUtilities.readStroke(stream); this.borderPaint = SerialUtilities.readPaint(stream); this.backgroundPaint = SerialUtilities.readPaint(stream); this.progressListeners = new EventListenerList(); this.changeListeners = new EventListenerList(); this.renderingHints = new RenderingHints( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // register as a listener with sub-components... if (this.title != null) { this.title.addChangeListener(this); } for (int i = 0; i < getSubtitleCount(); i++) { getSubtitle(i).addChangeListener(this); } this.plot.addChangeListener(this); } /** * Prints information about JFreeChart to standard output. * * @param args no arguments are honored. */ public static void main(String[] args) { System.out.println(JFreeChart.INFO.toString()); } /** * Clones the object, and takes care of listeners. * Note: caller shall register its own listeners on cloned graph. * * @return A clone. * * @throws CloneNotSupportedException if the chart is not cloneable. */ public Object clone() throws CloneNotSupportedException { JFreeChart chart = (JFreeChart) super.clone(); chart.renderingHints = (RenderingHints) this.renderingHints.clone(); // private boolean borderVisible; // private transient Stroke borderStroke; // private transient Paint borderPaint; if (this.title != null) { chart.title = (TextTitle) this.title.clone(); chart.title.addChangeListener(chart); } chart.subtitles = new ArrayList(); for (int i = 0; i < getSubtitleCount(); i++) { Title subtitle = (Title) getSubtitle(i).clone(); chart.subtitles.add(subtitle); subtitle.addChangeListener(chart); } if (this.plot != null) { chart.plot = (Plot) this.plot.clone(); chart.plot.addChangeListener(chart); } chart.progressListeners = new EventListenerList(); chart.changeListeners = new EventListenerList(); return chart; } } /** * Information about the JFreeChart project. One instance of this class is * assigned to JFreeChart.INFO. */ class JFreeChartInfo extends ProjectInfo { /** * Default constructor. */ public JFreeChartInfo() { // get a locale-specific resource bundle... String baseResourceClass = "org.jfree.chart.resources.JFreeChartResources"; ResourceBundle resources = ResourceBundleWrapper.getBundle( baseResourceClass); setName(resources.getString("project.name")); setVersion(resources.getString("project.version")); setInfo(resources.getString("project.info")); setCopyright(resources.getString("project.copyright")); setLogo(null); // load only when required setLicenceName("LGPL"); setLicenceText(Licences.getInstance().getLGPL()); setContributors(Arrays.asList( new Contributor[]{ new Contributor("Eric Alexander", "-"), new Contributor("Richard Atkinson", "richard_c_atkinson@ntlworld.com"), new Contributor("David Basten", "-"), new Contributor("David Berry", "-"), new Contributor("Chris Boek", "-"), new Contributor("Zoheb Borbora", "-"), new Contributor("Anthony Boulestreau", "-"), new Contributor("Jeremy Bowman", "-"), new Contributor("Nicolas Brodu", "-"), new Contributor("Jody Brownell", "-"), new Contributor("David Browning", "-"), new Contributor("Soren Caspersen", "-"), new Contributor("Chuanhao Chiu", "-"), new Contributor("Brian Cole", "-"), new Contributor("Pascal Collet", "-"), new Contributor("Martin Cordova", "-"), new Contributor("Paolo Cova", "-"), new Contributor("Greg Darke", "-"), new Contributor("Mike Duffy", "-"), new Contributor("Don Elliott", "-"), new Contributor("David Forslund", "-"), new Contributor("Jonathan Gabbai", "-"), new Contributor("David Gilbert", "david.gilbert@object-refinery.com"), new Contributor("Serge V. Grachov", "-"), new Contributor("Daniel Gredler", "-"), new Contributor("Hans-Jurgen Greiner", "-"), new Contributor("Joao Guilherme Del Valle", "-"), new Contributor("Aiman Han", "-"), new Contributor("Cameron Hayne", "-"), new Contributor("Martin Hoeller", "-"), new Contributor("Jon Iles", "-"), new Contributor("Wolfgang Irler", "-"), new Contributor("Sergei Ivanov", "-"), new Contributor("Adriaan Joubert", "-"), new Contributor("Darren Jung", "-"), new Contributor("Xun Kang", "-"), new Contributor("Bill Kelemen", "-"), new Contributor("Norbert Kiesel", "-"), new Contributor("Peter Kolb", "-"), new Contributor("Gideon Krause", "-"), new Contributor("Pierre-Marie Le Biot", "-"), new Contributor("Arnaud Lelievre", "-"), new Contributor("Wolfgang Lenhard", "-"), new Contributor("David Li", "-"), new Contributor("Yan Liu", "-"), new Contributor("Tin Luu", "-"), new Contributor("Craig MacFarlane", "-"), new Contributor("Achilleus Mantzios", "-"), new Contributor("Thomas Meier", "-"), new Contributor("Jim Moore", "-"), new Contributor("Jonathan Nash", "-"), new Contributor("Barak Naveh", "-"), new Contributor("David M. O'Donnell", "-"), new Contributor("Krzysztof Paz", "-"), new Contributor("Eric Penfold", "-"), new Contributor("Tomer Peretz", "-"), new Contributor("Diego Pierangeli", "-"), new Contributor("Xavier Poinsard", "-"), new Contributor("Andrzej Porebski", "-"), new Contributor("Viktor Rajewski", "-"), new Contributor("Eduardo Ramalho", "-"), new Contributor("Michael Rauch", "-"), new Contributor("Cameron Riley", "-"), new Contributor("Klaus Rheinwald", "-"), new Contributor("Dan Rivett", "d.rivett@ukonline.co.uk"), new Contributor("Scott Sams", "-"), new Contributor("Michel Santos", "-"), new Contributor("Thierry Saura", "-"), new Contributor("Andreas Schneider", "-"), new Contributor("Jean-Luc SCHWAB", "-"), new Contributor("Bryan Scott", "-"), new Contributor("Tobias Selb", "-"), new Contributor("Darshan Shah", "-"), new Contributor("Mofeed Shahin", "-"), new Contributor("Michael Siemer", "-"), new Contributor("Pady Srinivasan", "-"), new Contributor("Greg Steckman", "-"), new Contributor("Gerald Struck", "-"), new Contributor("Roger Studner", "-"), new Contributor("Irv Thomae", "-"), new Contributor("Eric Thomas", "-"), new Contributor("Rich Unger", "-"), new Contributor("Daniel van Enckevort", "-"), new Contributor("Laurence Vanhelsuwe", "-"), new Contributor("Sylvain Vieujot", "-"), new Contributor("Ulrich Voigt", "-"), new Contributor("Jelai Wang", "-"), new Contributor("Mark Watson", "www.markwatson.com"), new Contributor("Alex Weber", "-"), new Contributor("Matthew Wright", "-"), new Contributor("Benoit Xhenseval", "-"), new Contributor("Christian W. Zuckschwerdt", "Christian.Zuckschwerdt@Informatik.Uni-Oldenburg.de"), new Contributor("Hari", "-"), new Contributor("Sam (oldman)", "-"), } )); addLibrary(JCommon.INFO); } /** * Returns the JFreeChart logo (a picture of a gorilla). * * @return The JFreeChart logo. */ public Image getLogo() { Image logo = super.getLogo(); if (logo == null) { URL imageURL = this.getClass().getClassLoader().getResource( "org/jfree/chart/gorilla.jpg"); if (imageURL != null) { ImageIcon temp = new ImageIcon(imageURL); // use ImageIcon because it waits for the image to load... logo = temp.getImage(); setLogo(logo); } } return logo; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LegendItem.java0000644000175000017500000010563011173030414025316 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * LegendItem.java * --------------- * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrzej Porebski; * David Li; * Wolfgang Irler; * Luke Quinane; * * Changes (from 2-Oct-2002) * ------------------------- * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 17-Jan-2003 : Dropped outlineStroke attribute (DG); * 08-Oct-2003 : Applied patch for displaying series line style, contributed by * Luke Quinane (DG); * 21-Jan-2004 : Added the shapeFilled flag (DG); * 04-Jun-2004 : Added equals() method, implemented Serializable (DG); * 25-Nov-2004 : Changes required by new LegendTitle implementation (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 20-Apr-2005 : Added tooltip and URL text (DG); * 28-Nov-2005 : Separated constructors for AttributedString labels (DG); * 10-Dec-2005 : Fixed serialization bug (1377239) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 20-Jul-2006 : Added dataset and series index fields (DG); * 13-Dec-2006 : Added fillPaintTransformer attribute (DG); * 18-May-2007 : Added dataset and seriesKey fields (DG); * 03-Aug-2007 : Fixed null pointer exception (DG); * 23-Apr-2008 : Added new constructor and implemented Cloneable (DG); * 17-Jun-2008 : Added optional labelFont and labelPaint attributes (DG); * 15-Oct-2008 : Added new constructor (DG); * */ package org.jfree.chart; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.text.AttributedString; import java.text.CharacterIterator; import org.jfree.data.general.Dataset; import org.jfree.io.SerialUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.AttributedStringUtilities; import org.jfree.util.ObjectUtilities; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; import org.jfree.util.ShapeUtilities; /** * A temporary storage object for recording the properties of a legend item, * without any consideration for layout issues. */ public class LegendItem implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -797214582948827144L; /** * The dataset. * * @since 1.0.6 */ private Dataset dataset; /** * The series key. * * @since 1.0.6 */ private Comparable seriesKey; /** The dataset index. */ private int datasetIndex; /** The series index. */ private int series; /** The label. */ private String label; /** * The label font (null is permitted). * * @since 1.0.11 */ private Font labelFont; /** * The label paint (null is permitted). * * @since 1.0.11 */ private transient Paint labelPaint; /** The attributed label (if null, fall back to the regular label). */ private transient AttributedString attributedLabel; /** * The description (not currently used - could be displayed as a tool tip). */ private String description; /** The tool tip text. */ private String toolTipText; /** The url text. */ private String urlText; /** A flag that controls whether or not the shape is visible. */ private boolean shapeVisible; /** The shape. */ private transient Shape shape; /** A flag that controls whether or not the shape is filled. */ private boolean shapeFilled; /** The paint. */ private transient Paint fillPaint; /** * A gradient paint transformer. * * @since 1.0.4 */ private GradientPaintTransformer fillPaintTransformer; /** A flag that controls whether or not the shape outline is visible. */ private boolean shapeOutlineVisible; /** The outline paint. */ private transient Paint outlinePaint; /** The outline stroke. */ private transient Stroke outlineStroke; /** A flag that controls whether or not the line is visible. */ private boolean lineVisible; /** The line. */ private transient Shape line; /** The stroke. */ private transient Stroke lineStroke; /** The line paint. */ private transient Paint linePaint; /** * The shape must be non-null for a LegendItem - if no shape is required, * use this. */ private static final Shape UNUSED_SHAPE = new Line2D.Float(); /** * The stroke must be non-null for a LegendItem - if no stroke is required, * use this. */ private static final Stroke UNUSED_STROKE = new BasicStroke(0.0f); /** * Creates a legend item with the specified label. The remaining * attributes take default values. * * @param label the label (null not permitted). * * @since 1.0.10 */ public LegendItem(String label) { this(label, Color.black); } /** * Creates a legend item with the specified label and fill paint. The * remaining attributes take default values. * * @param label the label (null not permitted). * @param paint the paint (null not permitted). * * @since 1.0.12 */ public LegendItem(String label, Paint paint) { this(label, null, null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0), paint); } /** * Creates a legend item with a filled shape. The shape is not outlined, * and no line is visible. * * @param label the label (null not permitted). * @param description the description (null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param shape the shape (null not permitted). * @param fillPaint the paint used to fill the shape (null * not permitted). */ public LegendItem(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint) { this(label, description, toolTipText, urlText, /* shape visible = */ true, shape, /* shape filled = */ true, fillPaint, /* shape outlined */ false, Color.black, UNUSED_STROKE, /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE, Color.black); } /** * Creates a legend item with a filled and outlined shape. * * @param label the label (null not permitted). * @param description the description (null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param shape the shape (null not permitted). * @param fillPaint the paint used to fill the shape (null * not permitted). * @param outlineStroke the outline stroke (null not * permitted). * @param outlinePaint the outline paint (null not * permitted). */ public LegendItem(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) { this(label, description, toolTipText, urlText, /* shape visible = */ true, shape, /* shape filled = */ true, fillPaint, /* shape outlined = */ true, outlinePaint, outlineStroke, /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE, Color.black); } /** * Creates a legend item using a line. * * @param label the label (null not permitted). * @param description the description (null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param line the line (null not permitted). * @param lineStroke the line stroke (null not permitted). * @param linePaint the line paint (null not permitted). */ public LegendItem(String label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) { this(label, description, toolTipText, urlText, /* shape visible = */ false, UNUSED_SHAPE, /* shape filled = */ false, Color.black, /* shape outlined = */ false, Color.black, UNUSED_STROKE, /* line visible = */ true, line, lineStroke, linePaint); } /** * Creates a new legend item. * * @param label the label (null not permitted). * @param description the description (not currently used, * null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param shapeVisible a flag that controls whether or not the shape is * displayed. * @param shape the shape (null permitted). * @param shapeFilled a flag that controls whether or not the shape is * filled. * @param fillPaint the fill paint (null not permitted). * @param shapeOutlineVisible a flag that controls whether or not the * shape is outlined. * @param outlinePaint the outline paint (null not permitted). * @param outlineStroke the outline stroke (null not * permitted). * @param lineVisible a flag that controls whether or not the line is * visible. * @param line the line. * @param lineStroke the stroke (null not permitted). * @param linePaint the line paint (null not permitted). */ public LegendItem(String label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) { if (label == null) { throw new IllegalArgumentException("Null 'label' argument."); } if (fillPaint == null) { throw new IllegalArgumentException("Null 'fillPaint' argument."); } if (lineStroke == null) { throw new IllegalArgumentException("Null 'lineStroke' argument."); } if (outlinePaint == null) { throw new IllegalArgumentException("Null 'outlinePaint' argument."); } if (outlineStroke == null) { throw new IllegalArgumentException( "Null 'outlineStroke' argument."); } this.label = label; this.labelPaint = null; this.attributedLabel = null; this.description = description; this.shapeVisible = shapeVisible; this.shape = shape; this.shapeFilled = shapeFilled; this.fillPaint = fillPaint; this.fillPaintTransformer = new StandardGradientPaintTransformer(); this.shapeOutlineVisible = shapeOutlineVisible; this.outlinePaint = outlinePaint; this.outlineStroke = outlineStroke; this.lineVisible = lineVisible; this.line = line; this.lineStroke = lineStroke; this.linePaint = linePaint; this.toolTipText = toolTipText; this.urlText = urlText; } /** * Creates a legend item with a filled shape. The shape is not outlined, * and no line is visible. * * @param label the label (null not permitted). * @param description the description (null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param shape the shape (null not permitted). * @param fillPaint the paint used to fill the shape (null * not permitted). */ public LegendItem(AttributedString label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint) { this(label, description, toolTipText, urlText, /* shape visible = */ true, shape, /* shape filled = */ true, fillPaint, /* shape outlined = */ false, Color.black, UNUSED_STROKE, /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE, Color.black); } /** * Creates a legend item with a filled and outlined shape. * * @param label the label (null not permitted). * @param description the description (null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param shape the shape (null not permitted). * @param fillPaint the paint used to fill the shape (null * not permitted). * @param outlineStroke the outline stroke (null not * permitted). * @param outlinePaint the outline paint (null not * permitted). */ public LegendItem(AttributedString label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) { this(label, description, toolTipText, urlText, /* shape visible = */ true, shape, /* shape filled = */ true, fillPaint, /* shape outlined = */ true, outlinePaint, outlineStroke, /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE, Color.black); } /** * Creates a legend item using a line. * * @param label the label (null not permitted). * @param description the description (null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param line the line (null not permitted). * @param lineStroke the line stroke (null not permitted). * @param linePaint the line paint (null not permitted). */ public LegendItem(AttributedString label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) { this(label, description, toolTipText, urlText, /* shape visible = */ false, UNUSED_SHAPE, /* shape filled = */ false, Color.black, /* shape outlined = */ false, Color.black, UNUSED_STROKE, /* line visible = */ true, line, lineStroke, linePaint); } /** * Creates a new legend item. * * @param label the label (null not permitted). * @param description the description (not currently used, * null permitted). * @param toolTipText the tool tip text (null permitted). * @param urlText the URL text (null permitted). * @param shapeVisible a flag that controls whether or not the shape is * displayed. * @param shape the shape (null permitted). * @param shapeFilled a flag that controls whether or not the shape is * filled. * @param fillPaint the fill paint (null not permitted). * @param shapeOutlineVisible a flag that controls whether or not the * shape is outlined. * @param outlinePaint the outline paint (null not permitted). * @param outlineStroke the outline stroke (null not * permitted). * @param lineVisible a flag that controls whether or not the line is * visible. * @param line the line (null not permitted). * @param lineStroke the stroke (null not permitted). * @param linePaint the line paint (null not permitted). */ public LegendItem(AttributedString label, String description, String toolTipText, String urlText, boolean shapeVisible, Shape shape, boolean shapeFilled, Paint fillPaint, boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) { if (label == null) { throw new IllegalArgumentException("Null 'label' argument."); } if (fillPaint == null) { throw new IllegalArgumentException("Null 'fillPaint' argument."); } if (lineStroke == null) { throw new IllegalArgumentException("Null 'lineStroke' argument."); } if (line == null) { throw new IllegalArgumentException("Null 'line' argument."); } if (linePaint == null) { throw new IllegalArgumentException("Null 'linePaint' argument."); } if (outlinePaint == null) { throw new IllegalArgumentException("Null 'outlinePaint' argument."); } if (outlineStroke == null) { throw new IllegalArgumentException( "Null 'outlineStroke' argument."); } this.label = characterIteratorToString(label.getIterator()); this.attributedLabel = label; this.description = description; this.shapeVisible = shapeVisible; this.shape = shape; this.shapeFilled = shapeFilled; this.fillPaint = fillPaint; this.fillPaintTransformer = new StandardGradientPaintTransformer(); this.shapeOutlineVisible = shapeOutlineVisible; this.outlinePaint = outlinePaint; this.outlineStroke = outlineStroke; this.lineVisible = lineVisible; this.line = line; this.lineStroke = lineStroke; this.linePaint = linePaint; this.toolTipText = toolTipText; this.urlText = urlText; } /** * Returns a string containing the characters from the given iterator. * * @param iterator the iterator (null not permitted). * * @return A string. */ private String characterIteratorToString(CharacterIterator iterator) { int endIndex = iterator.getEndIndex(); int beginIndex = iterator.getBeginIndex(); int count = endIndex - beginIndex; if (count <= 0) { return ""; } char[] chars = new char[count]; int i = 0; char c = iterator.first(); while (c != CharacterIterator.DONE) { chars[i] = c; i++; c = iterator.next(); } return new String(chars); } /** * Returns the dataset. * * @return The dataset. * * @since 1.0.6 * * @see #setDatasetIndex(int) */ public Dataset getDataset() { return this.dataset; } /** * Sets the dataset. * * @param dataset the dataset. * * @since 1.0.6 */ public void setDataset(Dataset dataset) { this.dataset = dataset; } /** * Returns the dataset index for this legend item. * * @return The dataset index. * * @since 1.0.2 * * @see #setDatasetIndex(int) * @see #getDataset() */ public int getDatasetIndex() { return this.datasetIndex; } /** * Sets the dataset index for this legend item. * * @param index the index. * * @since 1.0.2 * * @see #getDatasetIndex() */ public void setDatasetIndex(int index) { this.datasetIndex = index; } /** * Returns the series key. * * @return The series key. * * @since 1.0.6 * * @see #setSeriesKey(Comparable) */ public Comparable getSeriesKey() { return this.seriesKey; } /** * Sets the series key. * * @param key the series key. * * @since 1.0.6 */ public void setSeriesKey(Comparable key) { this.seriesKey = key; } /** * Returns the series index for this legend item. * * @return The series index. * * @since 1.0.2 */ public int getSeriesIndex() { return this.series; } /** * Sets the series index for this legend item. * * @param index the index. * * @since 1.0.2 */ public void setSeriesIndex(int index) { this.series = index; } /** * Returns the label. * * @return The label (never null). */ public String getLabel() { return this.label; } /** * Returns the label font. * * @return The label font (possibly null). * * @since 1.0.11 */ public Font getLabelFont() { return this.labelFont; } /** * Sets the label font. * * @param font the font (null permitted). * * @since 1.0.11 */ public void setLabelFont(Font font) { this.labelFont = font; } /** * Returns the paint used to draw the label. * * @return The paint (possibly null). * * @since 1.0.11 */ public Paint getLabelPaint() { return this.labelPaint; } /** * Sets the paint used to draw the label. * * @param paint the paint (null permitted). * * @since 1.0.11 */ public void setLabelPaint(Paint paint) { this.labelPaint = paint; } /** * Returns the attributed label. * * @return The attributed label (possibly null). */ public AttributedString getAttributedLabel() { return this.attributedLabel; } /** * Returns the description for the legend item. * * @return The description. */ public String getDescription() { return this.description; } /** * Returns the tool tip text. * * @return The tool tip text (possibly null). */ public String getToolTipText() { return this.toolTipText; } /** * Returns the URL text. * * @return The URL text (possibly null). */ public String getURLText() { return this.urlText; } /** * Returns a flag that indicates whether or not the shape is visible. * * @return A boolean. */ public boolean isShapeVisible() { return this.shapeVisible; } /** * Returns the shape used to label the series represented by this legend * item. * * @return The shape (never null). */ public Shape getShape() { return this.shape; } /** * Returns a flag that controls whether or not the shape is filled. * * @return A boolean. */ public boolean isShapeFilled() { return this.shapeFilled; } /** * Returns the fill paint. * * @return The fill paint (never null). */ public Paint getFillPaint() { return this.fillPaint; } /** * Sets the fill paint. * * @param paint the paint (null not permitted). * * @since 1.0.11 */ public void setFillPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.fillPaint = paint; } /** * Returns the flag that controls whether or not the shape outline * is visible. * * @return A boolean. */ public boolean isShapeOutlineVisible() { return this.shapeOutlineVisible; } /** * Returns the line stroke for the series. * * @return The stroke (never null). */ public Stroke getLineStroke() { return this.lineStroke; } /** * Returns the paint used for lines. * * @return The paint (never null). */ public Paint getLinePaint() { return this.linePaint; } /** * Sets the line paint. * * @param paint the paint (null not permitted). * * @since 1.0.11 */ public void setLinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.linePaint = paint; } /** * Returns the outline paint. * * @return The outline paint (never null). */ public Paint getOutlinePaint() { return this.outlinePaint; } /** * Sets the outline paint. * * @param paint the paint (null not permitted). * * @since 1.0.11 */ public void setOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.outlinePaint = paint; } /** * Returns the outline stroke. * * @return The outline stroke (never null). */ public Stroke getOutlineStroke() { return this.outlineStroke; } /** * Returns a flag that indicates whether or not the line is visible. * * @return A boolean. */ public boolean isLineVisible() { return this.lineVisible; } /** * Returns the line. * * @return The line (never null). */ public Shape getLine() { return this.line; } /** * Returns the transformer used when the fill paint is an instance of * GradientPaint. * * @return The transformer (never null). * * @since 1.0.4 * * @see #setFillPaintTransformer(GradientPaintTransformer) */ public GradientPaintTransformer getFillPaintTransformer() { return this.fillPaintTransformer; } /** * Sets the transformer used when the fill paint is an instance of * GradientPaint. * * @param transformer the transformer (null not permitted). * * @since 1.0.4 * * @see #getFillPaintTransformer() */ public void setFillPaintTransformer(GradientPaintTransformer transformer) { if (transformer == null) { throw new IllegalArgumentException("Null 'transformer' attribute."); } this.fillPaintTransformer = transformer; } /** * Tests this item for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LegendItem)) { return false; } LegendItem that = (LegendItem) obj; if (this.datasetIndex != that.datasetIndex) { return false; } if (this.series != that.series) { return false; } if (!this.label.equals(that.label)) { return false; } if (!AttributedStringUtilities.equal(this.attributedLabel, that.attributedLabel)) { return false; } if (!ObjectUtilities.equal(this.description, that.description)) { return false; } if (this.shapeVisible != that.shapeVisible) { return false; } if (!ShapeUtilities.equal(this.shape, that.shape)) { return false; } if (this.shapeFilled != that.shapeFilled) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { return false; } if (!ObjectUtilities.equal(this.fillPaintTransformer, that.fillPaintTransformer)) { return false; } if (this.shapeOutlineVisible != that.shapeOutlineVisible) { return false; } if (!this.outlineStroke.equals(that.outlineStroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!this.lineVisible == that.lineVisible) { return false; } if (!ShapeUtilities.equal(this.line, that.line)) { return false; } if (!this.lineStroke.equals(that.lineStroke)) { return false; } if (!PaintUtilities.equal(this.linePaint, that.linePaint)) { return false; } if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { return false; } if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { return false; } return true; } /** * Returns an independent copy of this object (except that the clone will * still reference the same dataset as the original * LegendItem). * * @return A clone. * * @throws CloneNotSupportedException if the legend item cannot be cloned. * * @since 1.0.10 */ public Object clone() throws CloneNotSupportedException { LegendItem clone = (LegendItem) super.clone(); if (this.seriesKey instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.seriesKey; clone.seriesKey = (Comparable) pc.clone(); } // FIXME: Clone the attributed string if it is not null clone.shape = ShapeUtilities.clone(this.shape); if (this.fillPaintTransformer instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.fillPaintTransformer; clone.fillPaintTransformer = (GradientPaintTransformer) pc.clone(); } clone.line = ShapeUtilities.clone(this.line); return clone; } /** * Provides serialization support. * * @param stream the output stream (null not permitted). * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writeAttributedString(this.attributedLabel, stream); SerialUtilities.writeShape(this.shape, stream); SerialUtilities.writePaint(this.fillPaint, stream); SerialUtilities.writeStroke(this.outlineStroke, stream); SerialUtilities.writePaint(this.outlinePaint, stream); SerialUtilities.writeShape(this.line, stream); SerialUtilities.writeStroke(this.lineStroke, stream); SerialUtilities.writePaint(this.linePaint, stream); SerialUtilities.writePaint(this.labelPaint, stream); } /** * Provides serialization support. * * @param stream the input stream (null not permitted). * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.attributedLabel = SerialUtilities.readAttributedString(stream); this.shape = SerialUtilities.readShape(stream); this.fillPaint = SerialUtilities.readPaint(stream); this.outlineStroke = SerialUtilities.readStroke(stream); this.outlinePaint = SerialUtilities.readPaint(stream); this.line = SerialUtilities.readShape(stream); this.lineStroke = SerialUtilities.readStroke(stream); this.linePaint = SerialUtilities.readPaint(stream); this.labelPaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LegendItemCollection.java0000644000175000017500000001100011173030414027315 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * LegendItemCollection.java * ------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Feb-2002 : Version 1 (DG); * 24-Sep-2002 : Added get(int) and getItemCount() methods (DG); * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 18-Apr-2005 : Added equals() method and implemented Cloneable and * Serializable (DG); * 23-Apr-2008 : Fixed clone() method (DG); * */ package org.jfree.chart; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.util.ObjectUtilities; /** * A collection of legend items. */ public class LegendItemCollection implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1365215565589815953L; /** Storage for the legend items. */ private List items; /** * Constructs a new legend item collection, initially empty. */ public LegendItemCollection() { this.items = new java.util.ArrayList(); } /** * Adds a legend item to the collection. * * @param item the item to add. */ public void add(LegendItem item) { this.items.add(item); } /** * Adds the legend items from another collection to this collection. * * @param collection the other collection. */ public void addAll(LegendItemCollection collection) { this.items.addAll(collection.items); } /** * Returns a legend item from the collection. * * @param index the legend item index (zero-based). * * @return The legend item. */ public LegendItem get(int index) { return (LegendItem) this.items.get(index); } /** * Returns the number of legend items in the collection. * * @return The item count. */ public int getItemCount() { return this.items.size(); } /** * Returns an iterator that provides access to all the legend items. * * @return An iterator. */ public Iterator iterator() { return this.items.iterator(); } /** * Tests this collection for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof LegendItemCollection)) { return false; } LegendItemCollection that = (LegendItemCollection) obj; if (!this.items.equals(that.items)) { return false; } return true; } /** * Returns a clone of the collection. * * @return A clone. * * @throws CloneNotSupportedException if an item in the collection is not * cloneable. */ public Object clone() throws CloneNotSupportedException { LegendItemCollection clone = (LegendItemCollection) super.clone(); clone.items = (List) ObjectUtilities.deepClone(this.items); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LegendItemSource.java0000644000175000017500000000373111173030414026476 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * LegendItemSource.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart; /** * A source of legend items. A {@link org.jfree.chart.title.LegendTitle} will * maintain a list of sources (often just one) from which it obtains legend * items. */ public interface LegendItemSource { /** * Returns a (possibly empty) collection of legend items. * * @return The legend item collection (never null). */ public LegendItemCollection getLegendItems(); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LegendRenderingOrder.java0000644000175000017500000000717311173030414027334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * LegendRenderingOrder.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: Angel; * Contributor(s): -; * * Changes * ------- * 26-Mar-2004 : Version 1 (DG); * */ package org.jfree.chart; import java.io.ObjectStreamException; import java.io.Serializable; /** * Represents the order for rendering legend items. */ public final class LegendRenderingOrder implements Serializable { /** For serialization. */ private static final long serialVersionUID = -3832486612685808616L; /** In order. */ public static final LegendRenderingOrder STANDARD = new LegendRenderingOrder("LegendRenderingOrder.STANDARD"); /** In reverse order. */ public static final LegendRenderingOrder REVERSE = new LegendRenderingOrder("LegendRenderingOrder.REVERSE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private LegendRenderingOrder(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof LegendRenderingOrder)) { return false; } LegendRenderingOrder order = (LegendRenderingOrder) obj; if (!this.name.equals(order.toString())) { return false; } return true; } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(LegendRenderingOrder.STANDARD)) { return LegendRenderingOrder.STANDARD; } else if (this.equals(LegendRenderingOrder.REVERSE)) { return LegendRenderingOrder.REVERSE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle.properties0000644000175000017500000000067611173030414030342 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # Auto_Range=Auto Range All_Axes=Both Axes Chart_Properties=Chart Properties Copy=Copy Domain_Axis=Domain Axis PNG_Image_Files=PNG Image Files Print...=Print... Properties...=Properties... Save_as...=Save as... Range_Axis=Range Axis Zoom_In=Zoom In Zoom_Out=Zoom Out libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_de.properties0000644000175000017500000000113211173030414030776 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - german version # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt); # Auto_Range=Autojustage All_Axes=Beide Achsen Chart_Properties=Diagramm-Eigenschaften Copy=Kopieren Domain_Axis=Horizontale Achse PNG_Image_Files=PNG Datei (Portable Network Graphics) (*.png) Print...=Drucken... Properties...=Eigenschaften... Save_as...=Speichern unter... Range_Axis=Vertikale Achse Zoom_In=Hineinzoomen Zoom_Out=Herauszoomen libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_es.properties0000644000175000017500000000110611173030414031016 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - spanish version # # Changes (from 16-Dec-2003) # -------------------------- # 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo # Auto_Range=Escala autom\u00E1tica All_Axes=Todos los ejes Chart_Properties=Propiedades del gr\u00E1fico Copy=Copiar Domain_Axis=Eje horizontal PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png) Print...=Imprimir... Properties...=Propiedades... Save_as...=Grabar como... Range_Axis=Eje vertical Zoom_In=Acercar Zoom_Out=Alejar libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_fr.properties0000644000175000017500000000106511173030414031022 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - french version # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # Auto_Range=Echelle automatique All_Axes=Les deux axes Chart_Properties=Propri\u00E9t\u00E9s du graphique Copy=Copier Domain_Axis=Axe horizontal PNG_Image_Files=Format PNG (Portable Network Graphics) (*.png) Print...=Imprimer... Properties...=Propri\u00E9t\u00E9s... Save_as...=Enregistrer sous... Range_Axis=Axe vertical Zoom_In=Zoom avant Zoom_Out=Zoom arri\u00E8re libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_it.properties0000644000175000017500000000063711173030414031033 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - italian version Auto_Range=Dimensiona Automaticamente All_Axes=Entrambi gli Assi Chart_Properties=Propriet\u00E0 del Grafico Copy=Copia Domain_Axis=Asse Orizzontale PNG_Image_Files=Immagine PNG Print...=Stampa... Properties...=Propriet\u00E0... Save_as...=Salva Come... Range_Axis=Asse Verticale Zoom_In=Ingrandisci Zoom_Out=Rimpicciolisci libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_nl.properties0000644000175000017500000000100711173030414031020 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 24-Mar-2003 : Translated into Dutch # 31-Aug-2003 : Initial version (AL); # Auto_Range=Automatisch bereik All_Axes=Beide assen Chart_Properties=Eigenschappen Copy=Kopie\u00EBren Domain_Axis=Horizontale As PNG_Image_Files=PNG afbeelding Print...=Afdrukken... Properties...=Eigenschappen... Save_as...=Opslaan als... Range_Axis=Verticale As Zoom_In=Inzoomen Zoom_Out=Uitzoomen libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_pl.properties0000644000175000017500000000101411173030414031020 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file # # Changes (from 15-Mar-2004) # -------------------------- # 15-Mar-2004 : Initial version (Kuba Duda); # Auto_Range=Automatyczny zakres All_Axes=Obie osie Chart_Properties=W\u0142a\u015bciwo\u015bci wykresu Copy=Kopiuj Domain_Axis=O\u015b pozioma PNG_Image_Files=Pliki graficzne PNG Print...=Drukuj... Properties...=W\u0142a\u015bciwo\u015bci... Save_as...=Zapisz jako... Range_Axis=O\u015b pionowa Zoom_In=Powi\u0119ksz Zoom_Out=Pomniejsz libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_pt_BR.properties0000644000175000017500000000106411173030414031420 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version # # Changes (from 24-May-2007) # -------------------------- # 24-May-2007 : Initial version (Leonardo Alves Machado); # Auto_Range=Escala autom\u00E1tica All_Axes=Todos os eixos Chart_Properties=Propriedades do gr\u00E1fico Copy=Copiar Domain_Axis=Eixo horizontal PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png) Print...=Imprimir... Properties...=Propriedades... Save_as...=Salvar como... Range_Axis=Eixo vertical Zoom_In=Ampliar Zoom_Out=Reduzir libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_pt_PT.properties0000644000175000017500000000104311173030414031435 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version # # Changes (from 09-Set-2003) # -------------------------- # 09-Set-2003 : Initial version (ER); # Auto_Range=Escala autom\u00E1tica All_Axes=Todos os eixos Chart_Properties=Propriedades do gr\u00E1fico Copy=Copiar Domain_Axis=Eixo horizontal PNG_Image_Files=Formato PNG (Portable Network Graphics) (*.png) Print...=Imprimir... Properties...=Propriedades... Save_as...=Gravar como... Range_Axis=Eixo vertical Zoom_In=Aproximar Zoom_Out=Afastar libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_ru.properties0000644000175000017500000000224211173030414031037 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file # # Changes (from 10-Nov-2003) # -------------------------- # 10-Nov-2003 : Initial version (AL); # Auto_Range=\u0410\u0432\u0442\u043e\u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 All_Axes=\u041f\u043e \u0432\u0441\u0435\u043c \u043e\u0441\u044f\u043c Chart_Properties=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 Copy=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c Domain_Axis=\u041f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438 PNG_Image_Files=PNG \u0444\u0430\u0439\u043b Print...=\u041f\u0435\u0447\u0430\u0442\u044c... Properties...=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438... Save_as...=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a... Range_Axis=\u041f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u0438 Zoom_In=\u041f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c Zoom_Out=\u041e\u0442\u0434\u0430\u043b\u0438\u0442\u044c libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_zh_CN.properties0000644000175000017500000000105011173030414031406 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file # # Changes # ------- # 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495; # Auto_Range=\u81ea\u52a8\u8c03\u6574 All_Axes=\u6240\u6709\u8f74 Chart_Properties=\u56fe\u8868\u5c5e\u6027 Copy=\u590d\u5236 Domain_Axis=\u6c34\u5e73\u8f74 PNG_Image_Files=PNG \u683c\u5f0f\u7684\u56fe\u50cf Print...=\u6253\u5370 Properties...=\u5c5e\u6027 Save_as...=\u53e6\u5b58\u4e3a Range_Axis=\u5782\u76f4\u8f74 Zoom_In=\u653e\u5927 Zoom_Out=\u7f29\u5c0f libjfreechart-java-1.0.13.orig/source/org/jfree/chart/LocalizationBundle_zh_TW.properties0000644000175000017500000000100211173030414031435 0ustar vincentvincent# org.jfree.chart.ChartPanel ResourceBundle properties file # # Changes (from 31-Aug-2003) # -------------------------- # 31-Aug-2003 : Initial version (AL); # Auto_Range=\u81ea\u52d5\u8abf\u6574 All_Axes=\u6240\u6709\u8ef8 Chart_Properties=\u5716\u8868\u5167\u5bb9 Copy=\u8907\u88fd Domain_Axis=\u6a6b\u8ef8 PNG_Image_Files=PNG\u5716\u6a94 Print...=\u5217\u5370 Properties...=\u5167\u5bb9 Save_as...=\u53e6\u5b58\u65b0\u6a94 Range_Axis=\u7e31\u8ef8 Zoom_In=\u653e\u5927 Zoom_Out=\u7e2e\u5c0f libjfreechart-java-1.0.13.orig/source/org/jfree/chart/MouseWheelHandler.java0000644000175000017500000001231611173030414026652 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * MouseWheelHandler.java * ---------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Ulrich Voigt - patch 2686040; * * Changes * ------- * 18-Mar-2009 : Version 1, based on ideas by UV in patch 2686040 (DG); * 26-Mar-2009 : Implemented Serializable (DG); * */ package org.jfree.chart; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.geom.Point2D; import java.io.Serializable; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.Zoomable; /** * A class that handles mouse wheel events for the {@link ChartPanel} class. * Mouse wheel event support was added in JDK 1.4, so this class will be omitted * from JFreeChart if you build it using JDK 1.3. * * @since 1.0.13 */ class MouseWheelHandler implements MouseWheelListener, Serializable { /** The chart panel. */ private ChartPanel chartPanel; /** The zoom factor. */ double zoomFactor; /** * Creates a new instance. * * @param chartPanel the chart panel (null not permitted). */ public MouseWheelHandler(ChartPanel chartPanel) { this.chartPanel = chartPanel; this.zoomFactor = 0.10; this.chartPanel.addMouseWheelListener(this); } /** * Returns the current zoom factor. The default value is 0.10 (ten * percent). * * @return The zoom factor. * * @see #setZoomFactor(double) */ public double getZoomFactor() { return this.zoomFactor; } /** * Sets the zoom factor. * * @param zoomFactor the zoom factor. * * @see #getZoomFactor() */ public void setZoomFactor(double zoomFactor) { this.zoomFactor = zoomFactor; } /** * Handles a mouse wheel event from the underlying chart panel. * * @param e the event. */ public void mouseWheelMoved(MouseWheelEvent e) { JFreeChart chart = this.chartPanel.getChart(); if (chart == null) { return; } Plot plot = chart.getPlot(); if (plot instanceof Zoomable) { Zoomable zoomable = (Zoomable) plot; handleZoomable(zoomable, e); } // TODO: here we could handle non-zoomable plots in interesting // ways (for example, the wheel could rotate a PiePlot or just zoom // in on the whole panel). } /** * Handle the case where a plot implements the {@link Zoomable} interface. * * @param zoomable the zoomable plot. * @param e the mouse wheel event. */ private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) { Plot plot = (Plot) zoomable; ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); PlotRenderingInfo pinfo = info.getPlotInfo(); Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint()); if (!pinfo.getDataArea().contains(p)) { return; } int clicks = e.getWheelRotation(); int direction = 0; if (clicks < 0) { direction = -1; } else if (clicks > 0) { direction = 1; } boolean old = plot.isNotify(); // do not notify while zooming each axis plot.setNotify(false); double increment = 1.0 + this.zoomFactor; if (direction > 0) { zoomable.zoomDomainAxes(increment, pinfo, p, true); zoomable.zoomRangeAxes(increment, pinfo, p, true); } else if (direction < 0) { zoomable.zoomDomainAxes(1.0 / increment, pinfo, p, true); zoomable.zoomRangeAxes(1.0 / increment, pinfo, p, true); } // set the old notify status plot.setNotify(old); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/PaintMap.java0000644000175000017500000001564511173030414025020 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * PaintMap.java * ------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 27-Sep-2006 : Version 1 (DG); * 17-Jan-2007 : Changed TreeMap to HashMap, so that different classes that * implement Comparable can be used as keys (DG); * */ package org.jfree.chart; import java.awt.Paint; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.jfree.io.SerialUtilities; import org.jfree.util.PaintUtilities; /** * A storage structure that maps Comparable instances with * Paint instances. *

* To support cloning and serialization, you should only use keys that are * cloneable and serializable. Special handling for the Paint * instances is included in this class. * * @since 1.0.3 */ public class PaintMap implements Cloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -4639833772123069274L; /** Storage for the keys and values. */ private transient Map store; /** * Creates a new (empty) map. */ public PaintMap() { this.store = new HashMap(); } /** * Returns the paint associated with the specified key, or * null. * * @param key the key (null not permitted). * * @return The paint, or null. * * @throws IllegalArgumentException if key is * null. */ public Paint getPaint(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } return (Paint) this.store.get(key); } /** * Returns true if the map contains the specified key, and * false otherwise. * * @param key the key. * * @return true if the map contains the specified key, and * false otherwise. */ public boolean containsKey(Comparable key) { return this.store.containsKey(key); } /** * Adds a mapping between the specified key and * paint values. * * @param key the key (null not permitted). * @param paint the paint. * * @throws IllegalArgumentException if key is * null. */ public void put(Comparable key, Paint paint) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.store.put(key, paint); } /** * Resets the map to empty. */ public void clear() { this.store.clear(); } /** * Tests this map for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set keys = this.store.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true; } /** * Returns a clone of this PaintMap. * * @return A clone of this instance. * * @throws CloneNotSupportedException if any key is not cloneable. */ public Object clone() throws CloneNotSupportedException { // TODO: I think we need to make sure the keys are actually cloned, // whereas the paint instances are always immutable so they're OK return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(this.store.size()); Set keys = this.store.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); stream.writeObject(key); Paint paint = getPaint(key); SerialUtilities.writePaint(paint, stream); } } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.store = new HashMap(); int keyCount = stream.readInt(); for (int i = 0; i < keyCount; i++) { Comparable key = (Comparable) stream.readObject(); Paint paint = SerialUtilities.readPaint(stream); this.store.put(key, paint); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/PolarChartPanel.java0000644000175000017500000002036211173030414026316 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PolarChartPanel.java * -------------------- * (C) Copyright 2004-2008, by Solution Engineering, Inc. and Contributors. * * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart; import java.awt.Component; import java.awt.event.ActionEvent; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PolarPlot; /** * PolarChartPanel is the top level object for using the * {@link PolarPlot}. Since this class has a JPanel in the * inheritance hierarchy, one uses this class to integrate the Polar plot into * their application. *

* The main modification to ChartPanel is the popup menu. It * removes ChartPanel's versions of: *

    *
  • Zoom In
  • *
  • Zoom Out
  • *
  • Auto Range
  • *
* and replaces them with versions more appropriate for {@link PolarPlot}. */ public class PolarChartPanel extends ChartPanel { // ----------------- // --- Constants --- // ----------------- /** Zoom in command string. */ private static final String POLAR_ZOOM_IN_ACTION_COMMAND = "Polar Zoom In"; /** Zoom out command string. */ private static final String POLAR_ZOOM_OUT_ACTION_COMMAND = "Polar Zoom Out"; /** Auto range command string. */ private static final String POLAR_AUTO_RANGE_ACTION_COMMAND = "Polar Auto Range"; // ------------------------ // --- Member Variables --- // ------------------------ // -------------------- // --- Constructors --- // -------------------- /** * Constructs a JFreeChart panel. * * @param chart the chart. */ public PolarChartPanel(JFreeChart chart) { this(chart, true); } /** * Creates a new panel. * * @param chart the chart. * @param useBuffer buffered? */ public PolarChartPanel(JFreeChart chart, boolean useBuffer) { super(chart, useBuffer); checkChart(chart); setMinimumDrawWidth(200); setMinimumDrawHeight(200); setMaximumDrawWidth(2000); setMaximumDrawHeight(2000); } // -------------------------- // --- ChartPanel Methods --- // -------------------------- /** * Sets the chart that is displayed in the panel. * * @param chart The chart. */ public void setChart(JFreeChart chart) { checkChart(chart); super.setChart(chart); } /** * Creates a popup menu for the panel. * * @param properties include a menu item for the chart property editor. * @param save include a menu item for saving the chart. * @param print include a menu item for printing the chart. * @param zoom include menu items for zooming. * * @return The popup menu. */ protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { JPopupMenu result = super.createPopupMenu(properties, save, print, zoom); int zoomInIndex = getPopupMenuItem(result, "Zoom In"); int zoomOutIndex = getPopupMenuItem(result, "Zoom Out"); int autoIndex = getPopupMenuItem(result, "Auto Range"); if (zoom) { JMenuItem zoomIn = new JMenuItem("Zoom In"); zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND); zoomIn.addActionListener(this); JMenuItem zoomOut = new JMenuItem("Zoom Out"); zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND); zoomOut.addActionListener(this); JMenuItem auto = new JMenuItem("Auto Range"); auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND); auto.addActionListener(this); if (zoomInIndex != -1) { result.remove(zoomInIndex); } else { zoomInIndex = result.getComponentCount() - 1; } result.add(zoomIn, zoomInIndex); if (zoomOutIndex != -1) { result.remove(zoomOutIndex); } else { zoomOutIndex = zoomInIndex + 1; } result.add(zoomOut, zoomOutIndex); if (autoIndex != -1) { result.remove(autoIndex); } else { autoIndex = zoomOutIndex + 1; } result.add(auto, autoIndex); } return result; } /** * Handles action events generated by the popup menu. * * @param event the event. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals(POLAR_ZOOM_IN_ACTION_COMMAND)) { PolarPlot plot = (PolarPlot) getChart().getPlot(); plot.zoom(0.5); } else if (command.equals(POLAR_ZOOM_OUT_ACTION_COMMAND)) { PolarPlot plot = (PolarPlot) getChart().getPlot(); plot.zoom(2.0); } else if (command.equals(POLAR_AUTO_RANGE_ACTION_COMMAND)) { PolarPlot plot = (PolarPlot) getChart().getPlot(); plot.getAxis().setAutoRange(true); } else { super.actionPerformed(event); } } // ---------------------- // --- Public Methods --- // ---------------------- // ----------------------- // --- Private Methods --- // ----------------------- /** * Test that the chart is using an xy plot with time as the domain axis. * * @param chart the chart. */ private void checkChart(JFreeChart chart) { Plot plot = chart.getPlot(); if (!(plot instanceof PolarPlot)) { throw new IllegalArgumentException("plot is not a PolarPlot"); } } /** * Returns the index of an item in a popup menu. * * @param menu the menu. * @param text the label. * * @return The item index. */ private int getPopupMenuItem(JPopupMenu menu, String text) { int index = -1; for (int i = 0; (index == -1) && (i < menu.getComponentCount()); i++) { Component comp = menu.getComponent(i); if (comp instanceof JMenuItem) { JMenuItem item = (JMenuItem) comp; if (text.equals(item.getText())) { index = i; } } } return index; } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/StandardChartTheme.java0000644000175000017500000017010511173030414027005 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * StandardChartTheme.java * ----------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2008 : Version 1 (DG); * 10-Apr-2009 : Added getter/setter for smallFont (DG); * */ package org.jfree.chart; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Stroke; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.chart.annotations.XYAnnotation; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.PeriodAxis; import org.jfree.chart.axis.PeriodAxisLabelInfo; import org.jfree.chart.axis.SubCategoryAxis; import org.jfree.chart.axis.SymbolAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.block.Block; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.LabelBlock; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.CombinedDomainCategoryPlot; import org.jfree.chart.plot.CombinedDomainXYPlot; import org.jfree.chart.plot.CombinedRangeCategoryPlot; import org.jfree.chart.plot.CombinedRangeXYPlot; import org.jfree.chart.plot.DefaultDrawingSupplier; import org.jfree.chart.plot.DrawingSupplier; import org.jfree.chart.plot.FastScatterPlot; import org.jfree.chart.plot.MeterPlot; import org.jfree.chart.plot.MultiplePiePlot; import org.jfree.chart.plot.PieLabelLinkStyle; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PolarPlot; import org.jfree.chart.plot.SpiderWebPlot; import org.jfree.chart.plot.ThermometerPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.AbstractRenderer; import org.jfree.chart.renderer.category.BarPainter; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.BarRenderer3D; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.GradientBarPainter; import org.jfree.chart.renderer.category.LineRenderer3D; import org.jfree.chart.renderer.category.MinMaxCategoryRenderer; import org.jfree.chart.renderer.category.StatisticalBarRenderer; import org.jfree.chart.renderer.xy.GradientXYBarPainter; import org.jfree.chart.renderer.xy.XYBarPainter; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.title.CompositeTitle; import org.jfree.chart.title.LegendTitle; import org.jfree.chart.title.PaintScaleLegend; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleInsets; import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** * A default implementation of the {@link ChartTheme} interface. This * implementation just collects a whole bunch of chart attributes and mimics * the manual process of applying each attribute to the right sub-object * within the JFreeChart instance. It's not elegant code, but it works. * * @since 1.0.11 */ public class StandardChartTheme implements ChartTheme, Cloneable, PublicCloneable, Serializable { /** The name of this theme. */ private String name; /** * The largest font size. Use for the main chart title. */ private Font extraLargeFont; /** * A large font. Used for subtitles. */ private Font largeFont; /** * The regular font size. Used for axis tick labels, legend items etc. */ private Font regularFont; /** * The small font size. */ private Font smallFont; /** The paint used to display the main chart title. */ private transient Paint titlePaint; /** The paint used to display subtitles. */ private transient Paint subtitlePaint; /** The background paint for the chart. */ private transient Paint chartBackgroundPaint; /** The legend background paint. */ private transient Paint legendBackgroundPaint; /** The legend item paint. */ private transient Paint legendItemPaint; /** The drawing supplier. */ private DrawingSupplier drawingSupplier; /** The background paint for the plot. */ private transient Paint plotBackgroundPaint; /** The plot outline paint. */ private transient Paint plotOutlinePaint; /** The label link style for pie charts. */ private PieLabelLinkStyle labelLinkStyle; /** The label link paint for pie charts. */ private transient Paint labelLinkPaint; /** The domain grid line paint. */ private transient Paint domainGridlinePaint; /** The range grid line paint. */ private transient Paint rangeGridlinePaint; /** * The baseline paint (used for domain and range zero baselines) * * @since 1.0.13 */ private transient Paint baselinePaint; /** The crosshair paint. */ private transient Paint crosshairPaint; /** The axis offsets. */ private RectangleInsets axisOffset; /** The axis label paint. */ private transient Paint axisLabelPaint; /** The tick label paint. */ private transient Paint tickLabelPaint; /** The item label paint. */ private transient Paint itemLabelPaint; /** * A flag that controls whether or not shadows are visible (for example, * in a bar renderer). */ private boolean shadowVisible; /** The shadow paint. */ private transient Paint shadowPaint; /** The bar painter. */ private BarPainter barPainter; /** The XY bar painter. */ private XYBarPainter xyBarPainter; /** The thermometer paint. */ private transient Paint thermometerPaint; /** * The paint used to fill the interior of the 'walls' in the background * of a plot with a 3D effect. Applied to BarRenderer3D. */ private transient Paint wallPaint; /** The error indicator paint for the {@link StatisticalBarRenderer}. */ private transient Paint errorIndicatorPaint; /** The grid band paint for a {@link SymbolAxis}. */ private transient Paint gridBandPaint = SymbolAxis.DEFAULT_GRID_BAND_PAINT; /** The grid band alternate paint for a {@link SymbolAxis}. */ private transient Paint gridBandAlternatePaint = SymbolAxis.DEFAULT_GRID_BAND_ALTERNATE_PAINT; /** * Creates and returns the default 'JFree' chart theme. * * @return A chart theme. */ public static ChartTheme createJFreeTheme() { return new StandardChartTheme("JFree"); } /** * Creates and returns a theme called "Darkness". In this theme, the * charts have a black background. * * @return The "Darkness" theme. */ public static ChartTheme createDarknessTheme() { StandardChartTheme theme = new StandardChartTheme("Darkness"); theme.titlePaint = Color.white; theme.subtitlePaint = Color.white; theme.legendBackgroundPaint = Color.black; theme.legendItemPaint = Color.white; theme.chartBackgroundPaint = Color.black; theme.plotBackgroundPaint = Color.black; theme.plotOutlinePaint = Color.yellow; theme.baselinePaint = Color.white; theme.crosshairPaint = Color.red; theme.labelLinkPaint = Color.lightGray; theme.tickLabelPaint = Color.white; theme.axisLabelPaint = Color.white; theme.shadowPaint = Color.darkGray; theme.itemLabelPaint = Color.white; theme.drawingSupplier = new DefaultDrawingSupplier( new Paint[] {Color.decode("0xFFFF00"), Color.decode("0x0036CC"), Color.decode("0xFF0000"), Color.decode("0xFFFF7F"), Color.decode("0x6681CC"), Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), Color.decode("0x99A6CC"), Color.decode("0xFFBFBF"), Color.decode("0xA9A938"), Color.decode("0x2D4587")}, new Paint[] {Color.decode("0xFFFF00"), Color.decode("0x0036CC")}, new Stroke[] {new BasicStroke(2.0f)}, new Stroke[] {new BasicStroke(0.5f)}, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); theme.wallPaint = Color.darkGray; theme.errorIndicatorPaint = Color.lightGray; theme.gridBandPaint = new Color(255, 255, 255, 20); theme.gridBandAlternatePaint = new Color(255, 255, 255, 40); return theme; } /** * Creates and returns a {@link ChartTheme} that doesn't apply any changes * to the JFreeChart defaults. This produces the "legacy" look for * JFreeChart. * * @return A legacy theme. */ public static ChartTheme createLegacyTheme() { StandardChartTheme theme = new StandardChartTheme("Legacy") { public void apply(JFreeChart chart) { // do nothing at all } }; return theme; } /** * Creates a new default instance. * * @param name the name of the theme (null not permitted). */ public StandardChartTheme(String name) { if (name == null) { throw new IllegalArgumentException("Null 'name' argument."); } this.name = name; this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20); this.largeFont = new Font("Tahoma", Font.BOLD, 14); this.regularFont = new Font("Tahoma", Font.PLAIN, 12); this.smallFont = new Font("Tahoma", Font.PLAIN, 10); this.titlePaint = Color.black; this.subtitlePaint = Color.black; this.legendBackgroundPaint = Color.white; this.legendItemPaint = Color.darkGray; this.chartBackgroundPaint = Color.white; this.drawingSupplier = new DefaultDrawingSupplier(); this.plotBackgroundPaint = Color.lightGray; this.plotOutlinePaint = Color.black; this.labelLinkPaint = Color.black; this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE; this.axisOffset = new RectangleInsets(4, 4, 4, 4); this.domainGridlinePaint = Color.white; this.rangeGridlinePaint = Color.white; this.baselinePaint = Color.black; this.crosshairPaint = Color.blue; this.axisLabelPaint = Color.darkGray; this.tickLabelPaint = Color.darkGray; this.barPainter = new GradientBarPainter(); this.xyBarPainter = new GradientXYBarPainter(); this.shadowVisible = true; this.shadowPaint = Color.gray; this.itemLabelPaint = Color.black; this.thermometerPaint = Color.white; this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT; this.errorIndicatorPaint = Color.black; } /** * Returns the largest font for this theme. * * @return The largest font for this theme. * * @see #setExtraLargeFont(Font) */ public Font getExtraLargeFont() { return this.extraLargeFont; } /** * Sets the largest font for this theme. * * @param font the font (null not permitted). * * @see #getExtraLargeFont() */ public void setExtraLargeFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.extraLargeFont = font; } /** * Returns the large font for this theme. * * @return The large font (never null). * * @see #setLargeFont(Font) */ public Font getLargeFont() { return this.largeFont; } /** * Sets the large font for this theme. * * @param font the font (null not permitted). * * @see #getLargeFont() */ public void setLargeFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.largeFont = font; } /** * Returns the regular font. * * @return The regular font (never null). * * @see #setRegularFont(Font) */ public Font getRegularFont() { return this.regularFont; } /** * Sets the regular font for this theme. * * @param font the font (null not permitted). * * @see #getRegularFont() */ public void setRegularFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.regularFont = font; } /** * Returns the small font. * * @return The small font (never null). * * @see #setSmallFont(Font) * * @since 1.0.13 */ public Font getSmallFont() { return this.smallFont; } /** * Sets the small font for this theme. * * @param font the font (null not permitted). * * @see #getSmallFont() * * @since 1.0.13 */ public void setSmallFont(Font font) { if (font == null) { throw new IllegalArgumentException("Null 'font' argument."); } this.smallFont = font; } /** * Returns the title paint. * * @return The title paint (never null). * * @see #setTitlePaint(Paint) */ public Paint getTitlePaint() { return this.titlePaint; } /** * Sets the title paint. * * @param paint the paint (null not permitted). * * @see #getTitlePaint() */ public void setTitlePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.titlePaint = paint; } /** * Returns the subtitle paint. * * @return The subtitle paint (never null). * * @see #setSubtitlePaint(Paint) */ public Paint getSubtitlePaint() { return this.subtitlePaint; } /** * Sets the subtitle paint. * * @param paint the paint (null not permitted). * * @see #getSubtitlePaint() */ public void setSubtitlePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.subtitlePaint = paint; } /** * Returns the chart background paint. * * @return The chart background paint (never null). * * @see #setChartBackgroundPaint(Paint) */ public Paint getChartBackgroundPaint() { return this.chartBackgroundPaint; } /** * Sets the chart background paint. * * @param paint the paint (null not permitted). * * @see #getChartBackgroundPaint() */ public void setChartBackgroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.chartBackgroundPaint = paint; } /** * Returns the legend background paint. * * @return The legend background paint (never null). * * @see #setLegendBackgroundPaint(Paint) */ public Paint getLegendBackgroundPaint() { return this.legendBackgroundPaint; } /** * Sets the legend background paint. * * @param paint the paint (null not permitted). * * @see #getLegendBackgroundPaint() */ public void setLegendBackgroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.legendBackgroundPaint = paint; } /** * Returns the legend item paint. * * @return The legend item paint (never null). * * @see #setLegendItemPaint(Paint) */ public Paint getLegendItemPaint() { return this.legendItemPaint; } /** * Sets the legend item paint. * * @param paint the paint (null not permitted). * * @see #getLegendItemPaint() */ public void setLegendItemPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.legendItemPaint = paint; } /** * Returns the plot background paint. * * @return The plot background paint (never null). * * @see #setPlotBackgroundPaint(Paint) */ public Paint getPlotBackgroundPaint() { return this.plotBackgroundPaint; } /** * Sets the plot background paint. * * @param paint the paint (null not permitted). * * @see #getPlotBackgroundPaint() */ public void setPlotBackgroundPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.plotBackgroundPaint = paint; } /** * Returns the plot outline paint. * * @return The plot outline paint (never null). * * @see #setPlotOutlinePaint(Paint) */ public Paint getPlotOutlinePaint() { return this.plotOutlinePaint; } /** * Sets the plot outline paint. * * @param paint the paint (null not permitted). * * @see #getPlotOutlinePaint() */ public void setPlotOutlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.plotOutlinePaint = paint; } /** * Returns the label link style for pie charts. * * @return The label link style (never null). * * @see #setLabelLinkStyle(PieLabelLinkStyle) */ public PieLabelLinkStyle getLabelLinkStyle() { return this.labelLinkStyle; } /** * Sets the label link style for pie charts. * * @param style the style (null not permitted). * * @see #getLabelLinkStyle() */ public void setLabelLinkStyle(PieLabelLinkStyle style) { if (style == null) { throw new IllegalArgumentException("Null 'style' argument."); } this.labelLinkStyle = style; } /** * Returns the label link paint for pie charts. * * @return The label link paint (never null). * * @see #setLabelLinkPaint(Paint) */ public Paint getLabelLinkPaint() { return this.labelLinkPaint; } /** * Sets the label link paint for pie charts. * * @param paint the paint (null not permitted). * * @see #getLabelLinkPaint() */ public void setLabelLinkPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.labelLinkPaint = paint; } /** * Returns the domain grid line paint. * * @return The domain grid line paint (never null). * * @see #setDomainGridlinePaint(Paint) */ public Paint getDomainGridlinePaint() { return this.domainGridlinePaint; } /** * Sets the domain grid line paint. * * @param paint the paint (null not permitted). * * @see #getDomainGridlinePaint() */ public void setDomainGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.domainGridlinePaint = paint; } /** * Returns the range grid line paint. * * @return The range grid line paint (never null). * * @see #setRangeGridlinePaint(Paint) */ public Paint getRangeGridlinePaint() { return this.rangeGridlinePaint; } /** * Sets the range grid line paint. * * @param paint the paint (null not permitted). * * @see #getRangeGridlinePaint() */ public void setRangeGridlinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.rangeGridlinePaint = paint; } /** * Returns the baseline paint. * * @return The baseline paint. * * @since 1.0.13 */ public Paint getBaselinePaint() { return this.baselinePaint; } /** * Sets the baseline paint. * * @param paint the paint (null not permitted). * * @since 1.0.13 */ public void setBaselinePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.baselinePaint = paint; } /** * Returns the crosshair paint. * * @return The crosshair paint. */ public Paint getCrosshairPaint() { return this.crosshairPaint; } /** * Sets the crosshair paint. * * @param paint the paint (null not permitted). */ public void setCrosshairPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.crosshairPaint = paint; } /** * Returns the axis offsets. * * @return The axis offsets (never null). * * @see #setAxisOffset(RectangleInsets) */ public RectangleInsets getAxisOffset() { return this.axisOffset; } /** * Sets the axis offset. * * @param offset the offset (null not permitted). * * @see #getAxisOffset() */ public void setAxisOffset(RectangleInsets offset) { if (offset == null) { throw new IllegalArgumentException("Null 'offset' argument."); } this.axisOffset = offset; } /** * Returns the axis label paint. * * @return The axis label paint (never null). * * @see #setAxisLabelPaint(Paint) */ public Paint getAxisLabelPaint() { return this.axisLabelPaint; } /** * Sets the axis label paint. * * @param paint the paint (null not permitted). * * @see #getAxisLabelPaint() */ public void setAxisLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.axisLabelPaint = paint; } /** * Returns the tick label paint. * * @return The tick label paint (never null). * * @see #setTickLabelPaint(Paint) */ public Paint getTickLabelPaint() { return this.tickLabelPaint; } /** * Sets the tick label paint. * * @param paint the paint (null not permitted). * * @see #getTickLabelPaint() */ public void setTickLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.tickLabelPaint = paint; } /** * Returns the item label paint. * * @return The item label paint (never null). * * @see #setItemLabelPaint(Paint) */ public Paint getItemLabelPaint() { return this.itemLabelPaint; } /** * Sets the item label paint. * * @param paint the paint (null not permitted). * * @see #getItemLabelPaint() */ public void setItemLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.itemLabelPaint = paint; } /** * Returns the shadow visibility flag. * * @return The shadow visibility flag. * * @see #setShadowVisible(boolean) */ public boolean isShadowVisible() { return this.shadowVisible; } /** * Sets the shadow visibility flag. * * @param visible the flag. * * @see #isShadowVisible() */ public void setShadowVisible(boolean visible) { this.shadowVisible = visible; } /** * Returns the shadow paint. * * @return The shadow paint (never null). * * @see #setShadowPaint(Paint) */ public Paint getShadowPaint() { return this.shadowPaint; } /** * Sets the shadow paint. * * @param paint the paint (null not permitted). * * @see #getShadowPaint() */ public void setShadowPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.shadowPaint = paint; } /** * Returns the bar painter. * * @return The bar painter (never null). * * @see #setBarPainter(BarPainter) */ public BarPainter getBarPainter() { return this.barPainter; } /** * Sets the bar painter. * * @param painter the painter (null not permitted). * * @see #getBarPainter() */ public void setBarPainter(BarPainter painter) { if (painter == null) { throw new IllegalArgumentException("Null 'painter' argument."); } this.barPainter = painter; } /** * Returns the XY bar painter. * * @return The XY bar painter (never null). * * @see #setXYBarPainter(XYBarPainter) */ public XYBarPainter getXYBarPainter() { return this.xyBarPainter; } /** * Sets the XY bar painter. * * @param painter the painter (null not permitted). * * @see #getXYBarPainter() */ public void setXYBarPainter(XYBarPainter painter) { if (painter == null) { throw new IllegalArgumentException("Null 'painter' argument."); } this.xyBarPainter = painter; } /** * Returns the thermometer paint. * * @return The thermometer paint (never null). * * @see #setThermometerPaint(Paint) */ public Paint getThermometerPaint() { return this.thermometerPaint; } /** * Sets the thermometer paint. * * @param paint the paint (null not permitted). * * @see #getThermometerPaint() */ public void setThermometerPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.thermometerPaint = paint; } /** * Returns the wall paint for charts with a 3D effect. * * @return The wall paint (never null). * * @see #setWallPaint(Paint) */ public Paint getWallPaint() { return this.wallPaint; } /** * Sets the wall paint for charts with a 3D effect. * * @param paint the paint (null not permitted). * * @see #getWallPaint() */ public void setWallPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.wallPaint = paint; } /** * Returns the error indicator paint. * * @return The error indicator paint (never null). * * @see #setErrorIndicatorPaint(Paint) */ public Paint getErrorIndicatorPaint() { return this.errorIndicatorPaint; } /** * Sets the error indicator paint. * * @param paint the paint (null not permitted). * * @see #getErrorIndicatorPaint() */ public void setErrorIndicatorPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.errorIndicatorPaint = paint; } /** * Returns the grid band paint. * * @return The grid band paint (never null). * * @see #setGridBandPaint(Paint) */ public Paint getGridBandPaint() { return this.gridBandPaint; } /** * Sets the grid band paint. * * @param paint the paint (null not permitted). * * @see #getGridBandPaint() */ public void setGridBandPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.gridBandPaint = paint; } /** * Returns the grid band alternate paint (used for a {@link SymbolAxis}). * * @return The paint (never null). * * @see #setGridBandAlternatePaint(Paint) */ public Paint getGridBandAlternatePaint() { return this.gridBandAlternatePaint; } /** * Sets the grid band alternate paint (used for a {@link SymbolAxis}). * * @param paint the paint (null not permitted). * * @see #getGridBandAlternatePaint() */ public void setGridBandAlternatePaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.gridBandAlternatePaint = paint; } /** * Returns the name of this theme. * * @return The name of this theme. */ public String getName() { return this.name; } /** * Returns a clone of the drawing supplier for this theme. * * @return A clone of the drawing supplier. */ public DrawingSupplier getDrawingSupplier() { DrawingSupplier result = null; if (this.drawingSupplier instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.drawingSupplier; try { result = (DrawingSupplier) pc.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } return result; } /** * Sets the drawing supplier for this theme. * * @param supplier the supplier (null not permitted). * * @see #getDrawingSupplier() */ public void setDrawingSupplier(DrawingSupplier supplier) { if (supplier == null) { throw new IllegalArgumentException("Null 'supplier' argument."); } this.drawingSupplier = supplier; } /** * Applies this theme to the supplied chart. * * @param chart the chart (null not permitted). */ public void apply(JFreeChart chart) { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } TextTitle title = chart.getTitle(); if (title != null) { title.setFont(this.extraLargeFont); title.setPaint(this.titlePaint); } int subtitleCount = chart.getSubtitleCount(); for (int i = 0; i < subtitleCount; i++) { applyToTitle(chart.getSubtitle(i)); } chart.setBackgroundPaint(this.chartBackgroundPaint); // now process the plot if there is one Plot plot = chart.getPlot(); if (plot != null) { applyToPlot(plot); } } /** * Applies the attributes of this theme to the specified title. * * @param title the title. */ protected void applyToTitle(Title title) { if (title instanceof TextTitle) { TextTitle tt = (TextTitle) title; tt.setFont(this.largeFont); tt.setPaint(this.subtitlePaint); } else if (title instanceof LegendTitle) { LegendTitle lt = (LegendTitle) title; if (lt.getBackgroundPaint() != null) { lt.setBackgroundPaint(this.legendBackgroundPaint); } lt.setItemFont(this.regularFont); lt.setItemPaint(this.legendItemPaint); if (lt.getWrapper() != null) { applyToBlockContainer(lt.getWrapper()); } } else if (title instanceof PaintScaleLegend) { PaintScaleLegend psl = (PaintScaleLegend) title; psl.setBackgroundPaint(this.legendBackgroundPaint); ValueAxis axis = psl.getAxis(); if (axis != null) { applyToValueAxis(axis); } } else if (title instanceof CompositeTitle) { CompositeTitle ct = (CompositeTitle) title; BlockContainer bc = ct.getContainer(); List blocks = bc.getBlocks(); Iterator iterator = blocks.iterator(); while (iterator.hasNext()) { Block b = (Block) iterator.next(); if (b instanceof Title) { applyToTitle((Title) b); } } } } /** * Applies the attributes of this theme to the specified container. * * @param bc a block container (null not permitted). */ protected void applyToBlockContainer(BlockContainer bc) { Iterator iterator = bc.getBlocks().iterator(); while (iterator.hasNext()) { Block b = (Block) iterator.next(); applyToBlock(b); } } /** * Applies the attributes of this theme to the specified block. * * @param b the block. */ protected void applyToBlock(Block b) { if (b instanceof Title) { applyToTitle((Title) b); } else if (b instanceof LabelBlock) { LabelBlock lb = (LabelBlock) b; lb.setFont(this.regularFont); lb.setPaint(this.legendItemPaint); } } /** * Applies the attributes of this theme to a plot. * * @param plot the plot (null). */ protected void applyToPlot(Plot plot) { if (plot == null) { throw new IllegalArgumentException("Null 'plot' argument."); } if (plot.getDrawingSupplier() != null) { plot.setDrawingSupplier(getDrawingSupplier()); } if (plot.getBackgroundPaint() != null) { plot.setBackgroundPaint(this.plotBackgroundPaint); } plot.setOutlinePaint(this.plotOutlinePaint); // now handle specific plot types (and yes, I know this is some // really ugly code that has to be manually updated any time a new // plot type is added - I should have written something much cooler, // but I didn't and neither did anyone else). if (plot instanceof PiePlot) { applyToPiePlot((PiePlot) plot); } else if (plot instanceof MultiplePiePlot) { applyToMultiplePiePlot((MultiplePiePlot) plot); } else if (plot instanceof CategoryPlot) { applyToCategoryPlot((CategoryPlot) plot); } else if (plot instanceof XYPlot) { applyToXYPlot((XYPlot) plot); } else if (plot instanceof FastScatterPlot) { applyToFastScatterPlot((FastScatterPlot) plot); } else if (plot instanceof MeterPlot) { applyToMeterPlot((MeterPlot) plot); } else if (plot instanceof ThermometerPlot) { applyToThermometerPlot((ThermometerPlot) plot); } else if (plot instanceof SpiderWebPlot) { applyToSpiderWebPlot((SpiderWebPlot) plot); } else if (plot instanceof PolarPlot) { applyToPolarPlot((PolarPlot) plot); } } /** * Applies the attributes of this theme to a {@link PiePlot} instance. * This method also clears any set values for the section paint, outline * etc, so that the theme's {@link DrawingSupplier} will be used. * * @param plot the plot (null not permitted). */ protected void applyToPiePlot(PiePlot plot) { plot.setLabelLinkPaint(this.labelLinkPaint); plot.setLabelLinkStyle(this.labelLinkStyle); plot.setLabelFont(this.regularFont); // clear the section attributes so that the theme's DrawingSupplier // will be used if (plot.getAutoPopulateSectionPaint()) { plot.clearSectionPaints(false); } if (plot.getAutoPopulateSectionOutlinePaint()) { plot.clearSectionOutlinePaints(false); } if (plot.getAutoPopulateSectionOutlineStroke()) { plot.clearSectionOutlineStrokes(false); } } /** * Applies the attributes of this theme to a {@link MultiplePiePlot}. * * @param plot the plot (null not permitted). */ protected void applyToMultiplePiePlot(MultiplePiePlot plot) { apply(plot.getPieChart()); } /** * Applies the attributes of this theme to a {@link CategoryPlot}. * * @param plot the plot (null not permitted). */ protected void applyToCategoryPlot(CategoryPlot plot) { plot.setAxisOffset(this.axisOffset); plot.setDomainGridlinePaint(this.domainGridlinePaint); plot.setRangeGridlinePaint(this.rangeGridlinePaint); plot.setRangeZeroBaselinePaint(this.baselinePaint); // process all domain axes int domainAxisCount = plot.getDomainAxisCount(); for (int i = 0; i < domainAxisCount; i++) { CategoryAxis axis = plot.getDomainAxis(i); if (axis != null) { applyToCategoryAxis(axis); } } // process all range axes int rangeAxisCount = plot.getRangeAxisCount(); for (int i = 0; i < rangeAxisCount; i++) { ValueAxis axis = (ValueAxis) plot.getRangeAxis(i); if (axis != null) { applyToValueAxis(axis); } } // process all renderers int rendererCount = plot.getRendererCount(); for (int i = 0; i < rendererCount; i++) { CategoryItemRenderer r = plot.getRenderer(i); if (r != null) { applyToCategoryItemRenderer(r); } } if (plot instanceof CombinedDomainCategoryPlot) { CombinedDomainCategoryPlot cp = (CombinedDomainCategoryPlot) plot; Iterator iterator = cp.getSubplots().iterator(); while (iterator.hasNext()) { CategoryPlot subplot = (CategoryPlot) iterator.next(); if (subplot != null) { applyToPlot(subplot); } } } if (plot instanceof CombinedRangeCategoryPlot) { CombinedRangeCategoryPlot cp = (CombinedRangeCategoryPlot) plot; Iterator iterator = cp.getSubplots().iterator(); while (iterator.hasNext()) { CategoryPlot subplot = (CategoryPlot) iterator.next(); if (subplot != null) { applyToPlot(subplot); } } } } /** * Applies the attributes of this theme to a {@link XYPlot}. * * @param plot the plot (null not permitted). */ protected void applyToXYPlot(XYPlot plot) { plot.setAxisOffset(this.axisOffset); plot.setDomainZeroBaselinePaint(this.baselinePaint); plot.setRangeZeroBaselinePaint(this.baselinePaint); plot.setDomainGridlinePaint(this.domainGridlinePaint); plot.setRangeGridlinePaint(this.rangeGridlinePaint); plot.setDomainCrosshairPaint(this.crosshairPaint); plot.setRangeCrosshairPaint(this.crosshairPaint); // process all domain axes int domainAxisCount = plot.getDomainAxisCount(); for (int i = 0; i < domainAxisCount; i++) { ValueAxis axis = plot.getDomainAxis(i); if (axis != null) { applyToValueAxis(axis); } } // process all range axes int rangeAxisCount = plot.getRangeAxisCount(); for (int i = 0; i < rangeAxisCount; i++) { ValueAxis axis = (ValueAxis) plot.getRangeAxis(i); if (axis != null) { applyToValueAxis(axis); } } // process all renderers int rendererCount = plot.getRendererCount(); for (int i = 0; i < rendererCount; i++) { XYItemRenderer r = plot.getRenderer(i); if (r != null) { applyToXYItemRenderer(r); } } // process all annotations Iterator iter = plot.getAnnotations().iterator(); while (iter.hasNext()) { XYAnnotation a = (XYAnnotation) iter.next(); applyToXYAnnotation(a); } if (plot instanceof CombinedDomainXYPlot) { CombinedDomainXYPlot cp = (CombinedDomainXYPlot) plot; Iterator iterator = cp.getSubplots().iterator(); while (iterator.hasNext()) { XYPlot subplot = (XYPlot) iterator.next(); if (subplot != null) { applyToPlot(subplot); } } } if (plot instanceof CombinedRangeXYPlot) { CombinedRangeXYPlot cp = (CombinedRangeXYPlot) plot; Iterator iterator = cp.getSubplots().iterator(); while (iterator.hasNext()) { XYPlot subplot = (XYPlot) iterator.next(); if (subplot != null) { applyToPlot(subplot); } } } } /** * Applies the attributes of this theme to a {@link FastScatterPlot}. * @param plot */ protected void applyToFastScatterPlot(FastScatterPlot plot) { plot.setDomainGridlinePaint(this.domainGridlinePaint); plot.setRangeGridlinePaint(this.rangeGridlinePaint); ValueAxis xAxis = plot.getDomainAxis(); if (xAxis != null) { applyToValueAxis(xAxis); } ValueAxis yAxis = plot.getRangeAxis(); if (yAxis != null) { applyToValueAxis(yAxis); } } /** * Applies the attributes of this theme to a {@link PolarPlot}. This * method is called from the {@link #applyToPlot(Plot)} method. * * @param plot the plot (null not permitted). */ protected void applyToPolarPlot(PolarPlot plot) { plot.setAngleLabelFont(this.regularFont); plot.setAngleLabelPaint(this.tickLabelPaint); plot.setAngleGridlinePaint(this.domainGridlinePaint); plot.setRadiusGridlinePaint(this.rangeGridlinePaint); ValueAxis axis = plot.getAxis(); if (axis != null) { applyToValueAxis(axis); } } /** * Applies the attributes of this theme to a {@link SpiderWebPlot}. * * @param plot the plot (null not permitted). */ protected void applyToSpiderWebPlot(SpiderWebPlot plot) { plot.setLabelFont(this.regularFont); plot.setLabelPaint(this.axisLabelPaint); plot.setAxisLinePaint(this.axisLabelPaint); } /** * Applies the attributes of this theme to a {@link MeterPlot}. * * @param plot the plot (null not permitted). */ protected void applyToMeterPlot(MeterPlot plot) { plot.setDialBackgroundPaint(this.plotBackgroundPaint); plot.setValueFont(this.largeFont); plot.setValuePaint(this.axisLabelPaint); plot.setDialOutlinePaint(this.plotOutlinePaint); plot.setNeedlePaint(this.thermometerPaint); plot.setTickLabelFont(this.regularFont); plot.setTickLabelPaint(this.tickLabelPaint); } /** * Applies the attributes for this theme to a {@link ThermometerPlot}. * This method is called from the {@link #applyToPlot(Plot)} method. * * @param plot the plot. */ protected void applyToThermometerPlot(ThermometerPlot plot) { plot.setValueFont(this.largeFont); plot.setThermometerPaint(this.thermometerPaint); ValueAxis axis = plot.getRangeAxis(); if (axis != null) { applyToValueAxis(axis); } } /** * Applies the attributes for this theme to a {@link CategoryAxis}. * * @param axis the axis (null not permitted). */ protected void applyToCategoryAxis(CategoryAxis axis) { axis.setLabelFont(this.largeFont); axis.setLabelPaint(this.axisLabelPaint); axis.setTickLabelFont(this.regularFont); axis.setTickLabelPaint(this.tickLabelPaint); if (axis instanceof SubCategoryAxis) { SubCategoryAxis sca = (SubCategoryAxis) axis; sca.setSubLabelFont(this.regularFont); sca.setSubLabelPaint(this.tickLabelPaint); } } /** * Applies the attributes for this theme to a {@link ValueAxis}. * * @param axis the axis (null not permitted). */ protected void applyToValueAxis(ValueAxis axis) { axis.setLabelFont(this.largeFont); axis.setLabelPaint(this.axisLabelPaint); axis.setTickLabelFont(this.regularFont); axis.setTickLabelPaint(this.tickLabelPaint); if (axis instanceof SymbolAxis) { applyToSymbolAxis((SymbolAxis) axis); } if (axis instanceof PeriodAxis) { applyToPeriodAxis((PeriodAxis) axis); } } /** * Applies the attributes for this theme to a {@link SymbolAxis}. * * @param axis the axis (null not permitted). */ protected void applyToSymbolAxis(SymbolAxis axis) { axis.setGridBandPaint(this.gridBandPaint); axis.setGridBandAlternatePaint(this.gridBandAlternatePaint); } /** * Applies the attributes for this theme to a {@link PeriodAxis}. * * @param axis the axis (null not permitted). */ protected void applyToPeriodAxis(PeriodAxis axis) { PeriodAxisLabelInfo[] info = axis.getLabelInfo(); for (int i = 0; i < info.length; i++) { PeriodAxisLabelInfo e = info[i]; PeriodAxisLabelInfo n = new PeriodAxisLabelInfo(e.getPeriodClass(), e.getDateFormat(), e.getPadding(), this.regularFont, this.tickLabelPaint, e.getDrawDividers(), e.getDividerStroke(), e.getDividerPaint()); info[i] = n; } axis.setLabelInfo(info); } /** * Applies the attributes for this theme to an {@link AbstractRenderer}. * * @param renderer the renderer (null not permitted). */ protected void applyToAbstractRenderer(AbstractRenderer renderer) { if (renderer.getAutoPopulateSeriesPaint()) { renderer.clearSeriesPaints(false); } if (renderer.getAutoPopulateSeriesStroke()) { renderer.clearSeriesStrokes(false); } } /** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (null not permitted). */ protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) { if (renderer == null) { throw new IllegalArgumentException("Null 'renderer' argument."); } if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); // now we handle some special cases - yes, UGLY code alert! // BarRenderer if (renderer instanceof BarRenderer) { BarRenderer br = (BarRenderer) renderer; br.setBarPainter(this.barPainter); br.setShadowVisible(this.shadowVisible); br.setShadowPaint(this.shadowPaint); } // BarRenderer3D if (renderer instanceof BarRenderer3D) { BarRenderer3D br3d = (BarRenderer3D) renderer; br3d.setWallPaint(this.wallPaint); } // LineRenderer3D if (renderer instanceof LineRenderer3D) { LineRenderer3D lr3d = (LineRenderer3D) renderer; lr3d.setWallPaint(this.wallPaint); } // StatisticalBarRenderer if (renderer instanceof StatisticalBarRenderer) { StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer; sbr.setErrorIndicatorPaint(this.errorIndicatorPaint); } // MinMaxCategoryRenderer if (renderer instanceof MinMaxCategoryRenderer) { MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer; mmcr.setGroupPaint(this.errorIndicatorPaint); } } /** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (null not permitted). */ protected void applyToXYItemRenderer(XYItemRenderer renderer) { if (renderer == null) { throw new IllegalArgumentException("Null 'renderer' argument."); } if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); if (renderer instanceof XYBarRenderer) { XYBarRenderer br = (XYBarRenderer) renderer; br.setBarPainter(this.xyBarPainter); br.setShadowVisible(this.shadowVisible); } } /** * Applies the settings of this theme to the specified annotation. * * @param annotation the annotation. */ protected void applyToXYAnnotation(XYAnnotation annotation) { if (annotation == null) { throw new IllegalArgumentException("Null 'annotation' argument."); } if (annotation instanceof XYTextAnnotation) { XYTextAnnotation xyta = (XYTextAnnotation) annotation; xyta.setFont(this.smallFont); xyta.setPaint(this.itemLabelPaint); } } /** * Tests this theme for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StandardChartTheme)) { return false; } StandardChartTheme that = (StandardChartTheme) obj; if (!this.name.equals(that.name)) { return false; } if (!this.extraLargeFont.equals(that.extraLargeFont)) { return false; } if (!this.largeFont.equals(that.largeFont)) { return false; } if (!this.regularFont.equals(that.regularFont)) { return false; } if (!this.smallFont.equals(that.smallFont)) { return false; } if (!PaintUtilities.equal(this.titlePaint, that.titlePaint)) { return false; } if (!PaintUtilities.equal(this.subtitlePaint, that.subtitlePaint)) { return false; } if (!PaintUtilities.equal(this.chartBackgroundPaint, that.chartBackgroundPaint)) { return false; } if (!PaintUtilities.equal(this.legendBackgroundPaint, that.legendBackgroundPaint)) { return false; } if (!PaintUtilities.equal(this.legendItemPaint, that.legendItemPaint)) { return false; } if (!this.drawingSupplier.equals(that.drawingSupplier)) { return false; } if (!PaintUtilities.equal(this.plotBackgroundPaint, that.plotBackgroundPaint)) { return false; } if (!PaintUtilities.equal(this.plotOutlinePaint, that.plotOutlinePaint)) { return false; } if (!this.labelLinkStyle.equals(that.labelLinkStyle)) { return false; } if (!PaintUtilities.equal(this.labelLinkPaint, that.labelLinkPaint)) { return false; } if (!PaintUtilities.equal(this.domainGridlinePaint, that.domainGridlinePaint)) { return false; } if (!PaintUtilities.equal(this.rangeGridlinePaint, that.rangeGridlinePaint)) { return false; } if (!PaintUtilities.equal(this.crosshairPaint, that.crosshairPaint)) { return false; } if (!this.axisOffset.equals(that.axisOffset)) { return false; } if (!PaintUtilities.equal(this.axisLabelPaint, that.axisLabelPaint)) { return false; } if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { return false; } if (!PaintUtilities.equal(this.itemLabelPaint, that.itemLabelPaint)) { return false; } if (this.shadowVisible != that.shadowVisible) { return false; } if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { return false; } if (!this.barPainter.equals(that.barPainter)) { return false; } if (!this.xyBarPainter.equals(that.xyBarPainter)) { return false; } if (!PaintUtilities.equal(this.thermometerPaint, that.thermometerPaint)) { return false; } if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { return false; } if (!PaintUtilities.equal(this.errorIndicatorPaint, that.errorIndicatorPaint)) { return false; } if (!PaintUtilities.equal(this.gridBandPaint, that.gridBandPaint)) { return false; } if (!PaintUtilities.equal(this.gridBandAlternatePaint, that.gridBandAlternatePaint)) { return false; } return true; } /** * Returns a clone of this theme. * * @return A clone. * * @throws CloneNotSupportedException if the theme cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Provides serialization support. * * @param stream the output stream (null not permitted). * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); SerialUtilities.writePaint(this.titlePaint, stream); SerialUtilities.writePaint(this.subtitlePaint, stream); SerialUtilities.writePaint(this.chartBackgroundPaint, stream); SerialUtilities.writePaint(this.legendBackgroundPaint, stream); SerialUtilities.writePaint(this.legendItemPaint, stream); SerialUtilities.writePaint(this.plotBackgroundPaint, stream); SerialUtilities.writePaint(this.plotOutlinePaint, stream); SerialUtilities.writePaint(this.labelLinkPaint, stream); SerialUtilities.writePaint(this.baselinePaint, stream); SerialUtilities.writePaint(this.domainGridlinePaint, stream); SerialUtilities.writePaint(this.rangeGridlinePaint, stream); SerialUtilities.writePaint(this.crosshairPaint, stream); SerialUtilities.writePaint(this.axisLabelPaint, stream); SerialUtilities.writePaint(this.tickLabelPaint, stream); SerialUtilities.writePaint(this.itemLabelPaint, stream); SerialUtilities.writePaint(this.shadowPaint, stream); SerialUtilities.writePaint(this.thermometerPaint, stream); SerialUtilities.writePaint(this.wallPaint, stream); SerialUtilities.writePaint(this.errorIndicatorPaint, stream); SerialUtilities.writePaint(this.gridBandPaint, stream); SerialUtilities.writePaint(this.gridBandAlternatePaint, stream); } /** * Provides serialization support. * * @param stream the input stream (null not permitted). * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.titlePaint = SerialUtilities.readPaint(stream); this.subtitlePaint = SerialUtilities.readPaint(stream); this.chartBackgroundPaint = SerialUtilities.readPaint(stream); this.legendBackgroundPaint = SerialUtilities.readPaint(stream); this.legendItemPaint = SerialUtilities.readPaint(stream); this.plotBackgroundPaint = SerialUtilities.readPaint(stream); this.plotOutlinePaint = SerialUtilities.readPaint(stream); this.labelLinkPaint = SerialUtilities.readPaint(stream); this.baselinePaint = SerialUtilities.readPaint(stream); this.domainGridlinePaint = SerialUtilities.readPaint(stream); this.rangeGridlinePaint = SerialUtilities.readPaint(stream); this.crosshairPaint = SerialUtilities.readPaint(stream); this.axisLabelPaint = SerialUtilities.readPaint(stream); this.tickLabelPaint = SerialUtilities.readPaint(stream); this.itemLabelPaint = SerialUtilities.readPaint(stream); this.shadowPaint = SerialUtilities.readPaint(stream); this.thermometerPaint = SerialUtilities.readPaint(stream); this.wallPaint = SerialUtilities.readPaint(stream); this.errorIndicatorPaint = SerialUtilities.readPaint(stream); this.gridBandPaint = SerialUtilities.readPaint(stream); this.gridBandAlternatePaint = SerialUtilities.readPaint(stream); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/StrokeMap.java0000644000175000017500000001532711173030414025211 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * StrokeMap.java * -------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 27-Sep-2006 : Version 1 (DG); * */ package org.jfree.chart; import java.awt.Stroke; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TreeMap; import org.jfree.io.SerialUtilities; import org.jfree.util.ObjectUtilities; /** * A storage structure that maps Comparable instances with * Stroke instances. *

* To support cloning and serialization, you should only use keys that are * cloneable and serializable. Special handling for the Stroke * instances is included in this class. * * @since 1.0.3 */ public class StrokeMap implements Cloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -8148916785963525169L; /** Storage for the keys and values. */ private transient Map store; /** * Creates a new (empty) map. */ public StrokeMap() { this.store = new TreeMap(); } /** * Returns the stroke associated with the specified key, or * null. * * @param key the key (null not permitted). * * @return The stroke, or null. * * @throws IllegalArgumentException if key is * null. */ public Stroke getStroke(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } return (Stroke) this.store.get(key); } /** * Returns true if the map contains the specified key, and * false otherwise. * * @param key the key. * * @return true if the map contains the specified key, and * false otherwise. */ public boolean containsKey(Comparable key) { return this.store.containsKey(key); } /** * Adds a mapping between the specified key and * stroke values. * * @param key the key (null not permitted). * @param stroke the stroke. */ public void put(Comparable key, Stroke stroke) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.store.put(key, stroke); } /** * Resets the map to empty. */ public void clear() { this.store.clear(); } /** * Tests this map for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof StrokeMap)) { return false; } StrokeMap that = (StrokeMap) obj; if (this.store.size() != that.store.size()) { return false; } Set keys = this.store.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Stroke s1 = getStroke(key); Stroke s2 = that.getStroke(key); if (!ObjectUtilities.equal(s1, s2)) { return false; } } return true; } /** * Returns a clone of this StrokeMap. * * @return A clone of this instance. * * @throws CloneNotSupportedException if any key is not cloneable. */ public Object clone() throws CloneNotSupportedException { // TODO: I think we need to make sure the keys are actually cloned, // whereas the stroke instances are always immutable so they're OK return super.clone(); } /** * Provides serialization support. * * @param stream the output stream. * * @throws IOException if there is an I/O error. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(this.store.size()); Set keys = this.store.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); stream.writeObject(key); Stroke stroke = getStroke(key); SerialUtilities.writeStroke(stroke, stream); } } /** * Provides serialization support. * * @param stream the input stream. * * @throws IOException if there is an I/O error. * @throws ClassNotFoundException if there is a classpath problem. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.store = new TreeMap(); int keyCount = stream.readInt(); for (int i = 0; i < keyCount; i++) { Comparable key = (Comparable) stream.readObject(); Stroke stroke = SerialUtilities.readStroke(stream); this.store.put(key, stroke); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/gorilla.jpg0000644000175000017500000001306511173030414024571 0ustar vincentvincentJFIFHHC     C  dd"  j@͆)@gau|LMc2d5n#&2%i&d׻:4RC+ }) y/K/) &inMG mB[wu7z6FtJ?ydoV3q4%[oEBѭ*r_QX1 eesJh7Qѱ011c::u[Dz}c $>#Թ+Kİv2+ӛOr3ϸ bSO5!E_]jl371 iƨ6mb"/)1&!"Q 1A23R?]悄1F_XYO.ܙxXm$Afш!ȕ%5x{Wp=iΠ0e][8`c:kS)v5}k?%!1AQ"R?ຌ&\wfT{H{3S3bHXQf$KEGw.^:NN#3z%It\/w+jzl`j~2$<7sL, 0i: !1A"2Qaq #3BR$%br?铹% O*E6ߔMb\2?A8k-u-aRNbnGBѕJoptuk=I\ĸiYKύ9Ѽcbq$ ;/#bh\-)͵Rn+/%V5(rIWD1qЮծO+,6>c.d4C*<ʈMliS){ЗM'Bn#_axpMȑ(,lK}FiBxSIC9>z9o̼X֯{kiR1F)~ [Bz~BcvLИWny;ƊJ2-j`lBtG.AJ ("rUQlҫo{W*"JrՓZRYu~SĆTf旁¥ 4ҐtD)S: U]UaT0Ykx'eÞqYG1Y]otHTuZE3eҰo DtGPDf8qOC]flp 0v0l É*:=o'%Y&ʱ5y:JnƦ[ud O Jm>)Rx'JJӗ;`p})]3jGq^VR#"d<ڙp>:|jeJpnG$ Mwdv76s7g}}7֟~4d},>zCo(xEM2Dƶ9EnEL㏛=[}'Z^@\ K !ġM_siN4dgVU xskW;r4^EWi?-#e^mzӛCCηo)EkVMYy/fӸ-ye YmmPR{˚yR~\w31J83rULA2j:GjJzڱ9cO)o*4Գu Av‡T25]R~D)#lZ꼴y*r'8+zZי['!#۝ww{3Zq,7l%,ZsHw-B: ƮlA̶}0;U,MF92 ˇME&h BT۸Lbb@/-+%ʶtjZFW+a_^*H:RT~Tǘ58Bxg,W@Jw؀h-u$ iWkMgey}NC[Eƴ4UVV}n_1Qu@ϺQqާ\teb~00_P 8e|Yjp9d7 򇵱t-INKZ|9j^O0] #!1AaQq?E*֧0Yy+ ]^1z&R|˺ eiIr&q^g{LQbp.֫RU:XqPkfD0u, ۱gWCN4&E;[: }M)D$!1AaQq? A^n0-5_3tĩpkUnD?2)8=#D.3^(]#_i4ڊ2+JD&yVp{|HWyh77藙xȝhi27g$!1AQaq?wN)atdžasei%uˎCCt(죊rlnP] Sߛ ]*@b9kBoҖ..-)qeV.Fؖց JPJĀE|Ņ0 \1n&i{48m O @ (ޒkҚYvuVqqRGQ&4NqZ'cNo">bstߜ5 h]hmPTj:a(Wn gZ܊kQ= mz.Pc)|aGdA~pvBJ|X^!z..>~3A|*6V?t D|j4 Jjq8_I͂Q&BG",qs\*8(%] Hawbmm6 7!9!wb˧P1HͅWnG>H%DqkQ":l8ZF,F@SV6p]*tkRXQI}*7*8=bܿ\a~9Suwak-#νAд3@(zd,tDӋIBF |[|H\8Avl8cOC^q#FOX&7ÁH:LeOx2ॉh5cn \(! DCH(d m/IA8ZAtEq.^6+yH I!)N=@I<cVJD@pc4@؏) Qyd_x5Yl(_!,QOq*CY 1@|`!_,}{'+N8G2KyEHx@)T[AkFNPj%v!I9nOIlȼ `qxBzk$*6ߌ6tY1ùM0ÏͻzZωjZ"wJyWw?libjfreechart-java-1.0.13.orig/source/org/jfree/chart/package.html0000644000175000017500000000032011173030414024705 0ustar vincentvincent Core classes, including {@link org.jfree.chart.JFreeChart} and {@link org.jfree.chart.ChartPanel}. libjfreechart-java-1.0.13.orig/source/org/jfree/data/0000755000175000017500000000000011216245562022253 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/category/0000755000175000017500000000000011216245562024070 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/category/CategoryDataset.java0000644000175000017500000000542411173030414030011 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * CategoryDataset.java * -------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 21-Aug-2001) * -------------------------- * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); * 18-Sep-2001 : Updated e-mail address in header (DG); * 15-Oct-2001 : Moved to new package (com.jrefinery.data.*) (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 17-Nov-2001 : Updated Javadoc comments (DG); * 04-Mar-2002 : Updated import statement (DG); * 23-Oct-2002 : Reorganised code (DG); * 10-Jan-2003 : Updated Javadocs (DG); * 21-Jan-2003 : Merged with TableDataset (which only existed in CVS) (DG); * 13-Mar-2003 : Added KeyedValues2DDataset interface (DG); * 23-Apr-2003 : Switched CategoryDataset and KeyedValues2DDataset so that * CategoryDataset is the super interface (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.category (DG); * */ package org.jfree.data.category; import org.jfree.data.KeyedValues2D; import org.jfree.data.general.Dataset; /** * The interface for a dataset with one or more series, and values associated * with categories. *

* The categories are represented by Comparable instance, with the * category label being provided by the toString method. */ public interface CategoryDataset extends KeyedValues2D, Dataset { // no additional methods required } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/CategoryRangeInfo.java0000644000175000017500000000442611173030414030275 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * CategoryRangeInfo.java * ---------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2009 : Version 1 (DG); * */ package org.jfree.data.category; import java.util.List; import org.jfree.data.Range; /** * An interface that can (optionally) be implemented by a dataset to assist in * determining the minimum and maximum y-values. * * @since 1.0.13 */ public interface CategoryRangeInfo { /** * Returns the range of the values in this dataset's range. * * @param visibleSeriesKeys the keys of the visible series. * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (or null if the dataset contains no * values). */ public Range getRangeBounds(List visibleSeriesKeys, boolean includeInterval); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/CategoryToPieDataset.java0000644000175000017500000002527211173030414030755 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * CategoryToPieDataset.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Christian W. Zuckschwerdt; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * 30-Jul-2003 : Pass through DatasetChangeEvent (CZ); * 29-Jan-2004 : Replaced 'extract' int with TableOrder (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * ------------- JFREECHART 1.0.0 RELEASED ------------------------------------ * 26-Jul-2006 : Added serialVersionUID, changed constructor to allow null * for source, and added getSource(), getExtractType() and * getExtractIndex() methods - see feature request 1477915 (DG); * */ package org.jfree.data.category; import java.util.Collections; import java.util.List; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.general.PieDataset; import org.jfree.util.TableOrder; /** * A {@link PieDataset} implementation that obtains its data from one row or * column of a {@link CategoryDataset}. */ public class CategoryToPieDataset extends AbstractDataset implements PieDataset, DatasetChangeListener { /** For serialization. */ static final long serialVersionUID = 5516396319762189617L; /** The source. */ private CategoryDataset source; /** The extract type. */ private TableOrder extract; /** The row or column index. */ private int index; /** * An adaptor class that converts any {@link CategoryDataset} into a * {@link PieDataset}, by taking the values from a single row or column. *

* If source is null, the created dataset will * be empty. * * @param source the source dataset (null permitted). * @param extract extract data from rows or columns? (null * not permitted). * @param index the row or column index. */ public CategoryToPieDataset(CategoryDataset source, TableOrder extract, int index) { if (extract == null) { throw new IllegalArgumentException("Null 'extract' argument."); } this.source = source; if (this.source != null) { this.source.addChangeListener(this); } this.extract = extract; this.index = index; } /** * Returns the underlying dataset. * * @return The underlying dataset (possibly null). * * @since 1.0.2 */ public CategoryDataset getUnderlyingDataset() { return this.source; } /** * Returns the extract type, which determines whether data is read from * one row or one column of the underlying dataset. * * @return The extract type. * * @since 1.0.2 */ public TableOrder getExtractType() { return this.extract; } /** * Returns the index of the row or column from which to extract the data. * * @return The extract index. * * @since 1.0.2 */ public int getExtractIndex() { return this.index; } /** * Returns the number of items (values) in the collection. If the * underlying dataset is null, this method returns zero. * * @return The item count. */ public int getItemCount() { int result = 0; if (this.source != null) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnCount(); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowCount(); } } return result; } /** * Returns a value from the dataset. * * @param item the item index (zero-based). * * @return The value (possibly null). * * @throws IndexOutOfBoundsException if item is not in the * range 0 to getItemCount() - 1. */ public Number getValue(int item) { Number result = null; if (item < 0 || item >= getItemCount()) { // this will include the case where the underlying dataset is null throw new IndexOutOfBoundsException( "The 'item' index is out of bounds."); } if (this.extract == TableOrder.BY_ROW) { result = this.source.getValue(this.index, item); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getValue(item, this.index); } return result; } /** * Returns the key at the specified index. * * @param index the item index (in the range 0 to * getItemCount() - 1). * * @return The key. * * @throws IndexOutOfBoundsException if index is not in the * specified range. */ public Comparable getKey(int index) { Comparable result = null; if (index < 0 || index >= getItemCount()) { // this includes the case where the underlying dataset is null throw new IndexOutOfBoundsException("Invalid 'index': " + index); } if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnKey(index); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowKey(index); } return result; } /** * Returns the index for a given key, or -1 if there is no * such key. * * @param key the key. * * @return The index for the key, or -1. */ public int getIndex(Comparable key) { int result = -1; if (this.source != null) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnIndex(key); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowIndex(key); } } return result; } /** * Returns the keys for the dataset. *

* If the underlying dataset is null, this method returns an * empty list. * * @return The keys. */ public List getKeys() { List result = Collections.EMPTY_LIST; if (this.source != null) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnKeys(); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowKeys(); } } return result; } /** * Returns the value for a given key. If the key is not recognised, the * method should return null (but note that null * can be associated with a valid key also). * * @param key the key. * * @return The value (possibly null). */ public Number getValue(Comparable key) { Number result = null; int keyIndex = getIndex(key); if (keyIndex != -1) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getValue(this.index, keyIndex); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getValue(keyIndex, this.index); } } return result; } /** * Sends a {@link DatasetChangeEvent} to all registered listeners, with * this (not the underlying) dataset as the source. * * @param event the event (ignored, a new event with this dataset as the * source is sent to the listeners). */ public void datasetChanged(DatasetChangeEvent event) { fireDatasetChanged(); } /** * Tests this dataset for equality with an arbitrary object, returning * true if obj is a dataset containing the same * keys and values in the same order as this dataset. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/DefaultCategoryDataset.java0000644000175000017500000003170511173030414031317 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * DefaultCategoryDataset.java * --------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Jan-2003 : Added standard header, and renamed DefaultCategoryDataset (DG); * 13-Mar-2003 : Inserted DefaultKeyedValues2DDataset into class hierarchy (DG); * 06-Oct-2003 : Added incrementValue() method (DG); * 05-Apr-2004 : Added clear() method (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.category (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 26-Feb-2007 : Updated API docs (DG); * 08-Mar-2007 : Implemented clone() (DG); * 09-May-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.category; import java.io.Serializable; import java.util.List; import org.jfree.data.DefaultKeyedValues2D; import org.jfree.data.UnknownKeyException; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A default implementation of the {@link CategoryDataset} interface. */ public class DefaultCategoryDataset extends AbstractDataset implements CategoryDataset, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -8168173757291644622L; /** A storage structure for the data. */ private DefaultKeyedValues2D data; /** * Creates a new (empty) dataset. */ public DefaultCategoryDataset() { this.data = new DefaultKeyedValues2D(); } /** * Returns the number of rows in the table. * * @return The row count. * * @see #getColumnCount() */ public int getRowCount() { return this.data.getRowCount(); } /** * Returns the number of columns in the table. * * @return The column count. * * @see #getRowCount() */ public int getColumnCount() { return this.data.getColumnCount(); } /** * Returns a value from the table. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The value (possibly null). * * @see #addValue(Number, Comparable, Comparable) * @see #removeValue(Comparable, Comparable) */ public Number getValue(int row, int column) { return this.data.getValue(row, column); } /** * Returns the key for the specified row. * * @param row the row index (zero-based). * * @return The row key. * * @see #getRowIndex(Comparable) * @see #getRowKeys() * @see #getColumnKey(int) */ public Comparable getRowKey(int row) { return this.data.getRowKey(row); } /** * Returns the row index for a given key. * * @param key the row key (null not permitted). * * @return The row index. * * @see #getRowKey(int) */ public int getRowIndex(Comparable key) { // defer null argument check return this.data.getRowIndex(key); } /** * Returns the row keys. * * @return The keys. * * @see #getRowKey(int) */ public List getRowKeys() { return this.data.getRowKeys(); } /** * Returns a column key. * * @param column the column index (zero-based). * * @return The column key. * * @see #getColumnIndex(Comparable) */ public Comparable getColumnKey(int column) { return this.data.getColumnKey(column); } /** * Returns the column index for a given key. * * @param key the column key (null not permitted). * * @return The column index. * * @see #getColumnKey(int) */ public int getColumnIndex(Comparable key) { // defer null argument check return this.data.getColumnIndex(key); } /** * Returns the column keys. * * @return The keys. * * @see #getColumnKey(int) */ public List getColumnKeys() { return this.data.getColumnKeys(); } /** * Returns the value for a pair of keys. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The value (possibly null). * * @throws UnknownKeyException if either key is not defined in the dataset. * * @see #addValue(Number, Comparable, Comparable) */ public Number getValue(Comparable rowKey, Comparable columnKey) { return this.data.getValue(rowKey, columnKey); } /** * Adds a value to the table. Performs the same function as setValue(). * * @param value the value. * @param rowKey the row key. * @param columnKey the column key. * * @see #getValue(Comparable, Comparable) * @see #removeValue(Comparable, Comparable) */ public void addValue(Number value, Comparable rowKey, Comparable columnKey) { this.data.addValue(value, rowKey, columnKey); fireDatasetChanged(); } /** * Adds a value to the table. * * @param value the value. * @param rowKey the row key. * @param columnKey the column key. * * @see #getValue(Comparable, Comparable) */ public void addValue(double value, Comparable rowKey, Comparable columnKey) { addValue(new Double(value), rowKey, columnKey); } /** * Adds or updates a value in the table and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param value the value (null permitted). * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #getValue(Comparable, Comparable) */ public void setValue(Number value, Comparable rowKey, Comparable columnKey) { this.data.setValue(value, rowKey, columnKey); fireDatasetChanged(); } /** * Adds or updates a value in the table and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param value the value. * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #getValue(Comparable, Comparable) */ public void setValue(double value, Comparable rowKey, Comparable columnKey) { setValue(new Double(value), rowKey, columnKey); } /** * Adds the specified value to an existing value in the dataset (if the * existing value is null, it is treated as if it were 0.0). * * @param value the value. * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @throws UnknownKeyException if either key is not defined in the dataset. */ public void incrementValue(double value, Comparable rowKey, Comparable columnKey) { double existing = 0.0; Number n = getValue(rowKey, columnKey); if (n != null) { existing = n.doubleValue(); } setValue(existing + value, rowKey, columnKey); } /** * Removes a value from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key. * @param columnKey the column key. * * @see #addValue(Number, Comparable, Comparable) */ public void removeValue(Comparable rowKey, Comparable columnKey) { this.data.removeValue(rowKey, columnKey); fireDatasetChanged(); } /** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowIndex the row index. * * @see #removeColumn(int) */ public void removeRow(int rowIndex) { this.data.removeRow(rowIndex); fireDatasetChanged(); } /** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key. * * @see #removeColumn(Comparable) */ public void removeRow(Comparable rowKey) { this.data.removeRow(rowKey); fireDatasetChanged(); } /** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnIndex the column index. * * @see #removeRow(int) */ public void removeColumn(int columnIndex) { this.data.removeColumn(columnIndex); fireDatasetChanged(); } /** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnKey the column key (null not permitted). * * @see #removeRow(Comparable) * * @throws UnknownKeyException if columnKey is not defined * in the dataset. */ public void removeColumn(Comparable columnKey) { this.data.removeColumn(columnKey); fireDatasetChanged(); } /** * Clears all data from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. */ public void clear() { this.data.clear(); fireDatasetChanged(); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof CategoryDataset)) { return false; } CategoryDataset that = (CategoryDataset) obj; if (!getRowKeys().equals(that.getRowKeys())) { return false; } if (!getColumnKeys().equals(that.getColumnKeys())) { return false; } int rowCount = getRowCount(); int colCount = getColumnCount(); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < colCount; c++) { Number v1 = getValue(r, c); Number v2 = that.getValue(r, c); if (v1 == null) { if (v2 != null) { return false; } } else if (!v1.equals(v2)) { return false; } } } return true; } /** * Returns a hash code for the dataset. * * @return A hash code. */ public int hashCode() { return this.data.hashCode(); } /** * Returns a clone of the dataset. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * dataset. */ public Object clone() throws CloneNotSupportedException { DefaultCategoryDataset clone = (DefaultCategoryDataset) super.clone(); clone.data = (DefaultKeyedValues2D) this.data.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/DefaultIntervalCategoryDataset.java0000644000175000017500000006752311173030414033033 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * DefaultIntervalCategoryDataset.java * ----------------------------------- * (C) Copyright 2002-2008, by Jeremy Bowman and Contributors. * * Original Author: Jeremy Bowman; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 29-Apr-2002 : Version 1, contributed by Jeremy Bowman (DG); * 24-Oct-2002 : Amendments for changes made to the dataset interface (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 08-Mar-2007 : Added equals() and clone() overrides (DG); * 25-Feb-2008 : Fix for the special case where the dataset is empty, see bug * 1897580 (DG) * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.data.category; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.ResourceBundle; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.data.DataUtilities; import org.jfree.data.UnknownKeyException; import org.jfree.data.general.AbstractSeriesDataset; /** * A convenience class that provides a default implementation of the * {@link IntervalCategoryDataset} interface. *

* The standard constructor accepts data in a two dimensional array where the * first dimension is the series, and the second dimension is the category. */ public class DefaultIntervalCategoryDataset extends AbstractSeriesDataset implements IntervalCategoryDataset { /** The series keys. */ private Comparable[] seriesKeys; /** The category keys. */ private Comparable[] categoryKeys; /** Storage for the start value data. */ private Number[][] startData; /** Storage for the end value data. */ private Number[][] endData; /** * Creates a new dataset using the specified data values and automatically * generated series and category keys. * * @param starts the starting values for the intervals (null * not permitted). * @param ends the ending values for the intervals (null not * permitted). */ public DefaultIntervalCategoryDataset(double[][] starts, double[][] ends) { this(DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); } /** * Constructs a dataset and populates it with data from the array. *

* The arrays are indexed as data[series][category]. Series and category * names are automatically generated - you can change them using the * {@link #setSeriesKeys(Comparable[])} and * {@link #setCategoryKeys(Comparable[])} methods. * * @param starts the start values data. * @param ends the end values data. */ public DefaultIntervalCategoryDataset(Number[][] starts, Number[][] ends) { this(null, null, starts, ends); } /** * Constructs a DefaultIntervalCategoryDataset, populates it with data * from the arrays, and uses the supplied names for the series. *

* Category names are generated automatically ("Category 1", "Category 2", * etc). * * @param seriesNames the series names (if null, series names * will be generated automatically). * @param starts the start values data, indexed as data[series][category]. * @param ends the end values data, indexed as data[series][category]. */ public DefaultIntervalCategoryDataset(String[] seriesNames, Number[][] starts, Number[][] ends) { this(seriesNames, null, starts, ends); } /** * Constructs a DefaultIntervalCategoryDataset, populates it with data * from the arrays, and uses the supplied names for the series and the * supplied objects for the categories. * * @param seriesKeys the series keys (if null, series keys * will be generated automatically). * @param categoryKeys the category keys (if null, category * keys will be generated automatically). * @param starts the start values data, indexed as data[series][category]. * @param ends the end values data, indexed as data[series][category]. */ public DefaultIntervalCategoryDataset(Comparable[] seriesKeys, Comparable[] categoryKeys, Number[][] starts, Number[][] ends) { this.startData = starts; this.endData = ends; if (starts != null && ends != null) { String baseName = "org.jfree.data.resources.DataPackageResources"; ResourceBundle resources = ResourceBundleWrapper.getBundle( baseName); int seriesCount = starts.length; if (seriesCount != ends.length) { String errMsg = "DefaultIntervalCategoryDataset: the number " + "of series in the start value dataset does " + "not match the number of series in the end " + "value dataset."; throw new IllegalArgumentException(errMsg); } if (seriesCount > 0) { // set up the series names... if (seriesKeys != null) { if (seriesKeys.length != seriesCount) { throw new IllegalArgumentException( "The number of series keys does not " + "match the number of series in the data."); } this.seriesKeys = seriesKeys; } else { String prefix = resources.getString( "series.default-prefix") + " "; this.seriesKeys = generateKeys(seriesCount, prefix); } // set up the category names... int categoryCount = starts[0].length; if (categoryCount != ends[0].length) { String errMsg = "DefaultIntervalCategoryDataset: the " + "number of categories in the start value " + "dataset does not match the number of " + "categories in the end value dataset."; throw new IllegalArgumentException(errMsg); } if (categoryKeys != null) { if (categoryKeys.length != categoryCount) { throw new IllegalArgumentException( "The number of category keys does not match " + "the number of categories in the data."); } this.categoryKeys = categoryKeys; } else { String prefix = resources.getString( "categories.default-prefix") + " "; this.categoryKeys = generateKeys(categoryCount, prefix); } } else { this.seriesKeys = new Comparable[0]; this.categoryKeys = new Comparable[0]; } } } /** * Returns the number of series in the dataset (possibly zero). * * @return The number of series in the dataset. * * @see #getRowCount() * @see #getCategoryCount() */ public int getSeriesCount() { int result = 0; if (this.startData != null) { result = this.startData.length; } return result; } /** * Returns a series index. * * @param seriesKey the series key. * * @return The series index. * * @see #getRowIndex(Comparable) * @see #getSeriesKey(int) */ public int getSeriesIndex(Comparable seriesKey) { int result = -1; for (int i = 0; i < this.seriesKeys.length; i++) { if (seriesKey.equals(this.seriesKeys[i])) { result = i; break; } } return result; } /** * Returns the name of the specified series. * * @param series the index of the required series (zero-based). * * @return The name of the specified series. * * @see #getSeriesIndex(Comparable) */ public Comparable getSeriesKey(int series) { if ((series >= getSeriesCount()) || (series < 0)) { throw new IllegalArgumentException("No such series : " + series); } return this.seriesKeys[series]; } /** * Sets the names of the series in the dataset. * * @param seriesKeys the new keys (null not permitted, the * length of the array must match the number of series in the * dataset). * * @see #setCategoryKeys(Comparable[]) */ public void setSeriesKeys(Comparable[] seriesKeys) { if (seriesKeys == null) { throw new IllegalArgumentException("Null 'seriesKeys' argument."); } if (seriesKeys.length != getSeriesCount()) { throw new IllegalArgumentException( "The number of series keys does not match the data."); } this.seriesKeys = seriesKeys; fireDatasetChanged(); } /** * Returns the number of categories in the dataset. * * @return The number of categories in the dataset. * * @see #getColumnCount() */ public int getCategoryCount() { int result = 0; if (this.startData != null) { if (getSeriesCount() > 0) { result = this.startData[0].length; } } return result; } /** * Returns a list of the categories in the dataset. This method supports * the {@link CategoryDataset} interface. * * @return A list of the categories in the dataset. * * @see #getRowKeys() */ public List getColumnKeys() { // the CategoryDataset interface expects a list of categories, but // we've stored them in an array... if (this.categoryKeys == null) { return new ArrayList(); } else { return Collections.unmodifiableList(Arrays.asList( this.categoryKeys)); } } /** * Sets the categories for the dataset. * * @param categoryKeys an array of objects representing the categories in * the dataset. * * @see #getRowKeys() * @see #setSeriesKeys(Comparable[]) */ public void setCategoryKeys(Comparable[] categoryKeys) { if (categoryKeys == null) { throw new IllegalArgumentException("Null 'categoryKeys' argument."); } if (categoryKeys.length != getCategoryCount()) { throw new IllegalArgumentException( "The number of categories does not match the data."); } for (int i = 0; i < categoryKeys.length; i++) { if (categoryKeys[i] == null) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.setCategoryKeys(): " + "null category not permitted."); } } this.categoryKeys = categoryKeys; fireDatasetChanged(); } /** * Returns the data value for one category in a series. *

* This method is part of the CategoryDataset interface. Not particularly * meaningful for this class...returns the end value. * * @param series The required series (zero based index). * @param category The required category. * * @return The data value for one category in a series (null possible). * * @see #getEndValue(Comparable, Comparable) */ public Number getValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getValue(seriesIndex, itemIndex); } /** * Returns the data value for one category in a series. *

* This method is part of the CategoryDataset interface. Not particularly * meaningful for this class...returns the end value. * * @param series the required series (zero based index). * @param category the required category. * * @return The data value for one category in a series (null possible). * * @see #getEndValue(int, int) */ public Number getValue(int series, int category) { return getEndValue(series, category); } /** * Returns the start data value for one category in a series. * * @param series the required series. * @param category the required category. * * @return The start data value for one category in a series * (possibly null). * * @see #getStartValue(int, int) */ public Number getStartValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getStartValue(seriesIndex, itemIndex); } /** * Returns the start data value for one category in a series. * * @param series the required series (zero based index). * @param category the required category. * * @return The start data value for one category in a series * (possibly null). * * @see #getStartValue(Comparable, Comparable) */ public Number getStartValue(int series, int category) { // check arguments... if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.getValue(): " + "series index out of range."); } if ((category < 0) || (category >= getCategoryCount())) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.getValue(): " + "category index out of range."); } // fetch the value... return this.startData[series][category]; } /** * Returns the end data value for one category in a series. * * @param series the required series. * @param category the required category. * * @return The end data value for one category in a series (null possible). * * @see #getEndValue(int, int) */ public Number getEndValue(Comparable series, Comparable category) { int seriesIndex = getSeriesIndex(series); if (seriesIndex < 0) { throw new UnknownKeyException("Unknown 'series' key."); } int itemIndex = getColumnIndex(category); if (itemIndex < 0) { throw new UnknownKeyException("Unknown 'category' key."); } return getEndValue(seriesIndex, itemIndex); } /** * Returns the end data value for one category in a series. * * @param series the required series (zero based index). * @param category the required category. * * @return The end data value for one category in a series (null possible). * * @see #getEndValue(Comparable, Comparable) */ public Number getEndValue(int series, int category) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.getValue(): " + "series index out of range."); } if ((category < 0) || (category >= getCategoryCount())) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.getValue(): " + "category index out of range."); } return this.endData[series][category]; } /** * Sets the start data value for one category in a series. * * @param series the series (zero-based index). * @param category the category. * * @param value The value. * * @see #setEndValue(int, Comparable, Number) */ public void setStartValue(int series, Comparable category, Number value) { // does the series exist? if ((series < 0) || (series > getSeriesCount() - 1)) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.setValue: " + "series outside valid range."); } // is the category valid? int categoryIndex = getCategoryIndex(category); if (categoryIndex < 0) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.setValue: " + "unrecognised category."); } // update the data... this.startData[series][categoryIndex] = value; fireDatasetChanged(); } /** * Sets the end data value for one category in a series. * * @param series the series (zero-based index). * @param category the category. * * @param value the value. * * @see #setStartValue(int, Comparable, Number) */ public void setEndValue(int series, Comparable category, Number value) { // does the series exist? if ((series < 0) || (series > getSeriesCount() - 1)) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.setValue: " + "series outside valid range."); } // is the category valid? int categoryIndex = getCategoryIndex(category); if (categoryIndex < 0) { throw new IllegalArgumentException( "DefaultIntervalCategoryDataset.setValue: " + "unrecognised category."); } // update the data... this.endData[series][categoryIndex] = value; fireDatasetChanged(); } /** * Returns the index for the given category. * * @param category the category (null not permitted). * * @return The index. * * @see #getColumnIndex(Comparable) */ public int getCategoryIndex(Comparable category) { int result = -1; for (int i = 0; i < this.categoryKeys.length; i++) { if (category.equals(this.categoryKeys[i])) { result = i; break; } } return result; } /** * Generates an array of keys, by appending a space plus an integer * (starting with 1) to the supplied prefix string. * * @param count the number of keys required. * @param prefix the name prefix. * * @return An array of prefixN with N = { 1 .. count}. */ private Comparable[] generateKeys(int count, String prefix) { Comparable[] result = new Comparable[count]; String name; for (int i = 0; i < count; i++) { name = prefix + (i + 1); result[i] = name; } return result; } /** * Returns a column key. * * @param column the column index. * * @return The column key. * * @see #getRowKey(int) */ public Comparable getColumnKey(int column) { return this.categoryKeys[column]; } /** * Returns a column index. * * @param columnKey the column key (null not permitted). * * @return The column index. * * @see #getCategoryIndex(Comparable) */ public int getColumnIndex(Comparable columnKey) { if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } return getCategoryIndex(columnKey); } /** * Returns a row index. * * @param rowKey the row key. * * @return The row index. * * @see #getSeriesIndex(Comparable) */ public int getRowIndex(Comparable rowKey) { return getSeriesIndex(rowKey); } /** * Returns a list of the series in the dataset. This method supports the * {@link CategoryDataset} interface. * * @return A list of the series in the dataset. * * @see #getColumnKeys() */ public List getRowKeys() { // the CategoryDataset interface expects a list of series, but // we've stored them in an array... if (this.seriesKeys == null) { return new java.util.ArrayList(); } else { return Collections.unmodifiableList(Arrays.asList(this.seriesKeys)); } } /** * Returns the name of the specified series. * * @param row the index of the required row/series (zero-based). * * @return The name of the specified series. * * @see #getColumnKey(int) */ public Comparable getRowKey(int row) { if ((row >= getRowCount()) || (row < 0)) { throw new IllegalArgumentException( "The 'row' argument is out of bounds."); } return this.seriesKeys[row]; } /** * Returns the number of categories in the dataset. This method is part of * the {@link CategoryDataset} interface. * * @return The number of categories in the dataset. * * @see #getCategoryCount() * @see #getRowCount() */ public int getColumnCount() { return this.categoryKeys.length; } /** * Returns the number of series in the dataset (possibly zero). * * @return The number of series in the dataset. * * @see #getSeriesCount() * @see #getColumnCount() */ public int getRowCount() { return this.seriesKeys.length; } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultIntervalCategoryDataset)) { return false; } DefaultIntervalCategoryDataset that = (DefaultIntervalCategoryDataset) obj; if (!Arrays.equals(this.seriesKeys, that.seriesKeys)) { return false; } if (!Arrays.equals(this.categoryKeys, that.categoryKeys)) { return false; } if (!equal(this.startData, that.startData)) { return false; } if (!equal(this.endData, that.endData)) { return false; } // seem to be the same... return true; } /** * Returns a clone of this dataset. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * dataset. */ public Object clone() throws CloneNotSupportedException { DefaultIntervalCategoryDataset clone = (DefaultIntervalCategoryDataset) super.clone(); clone.categoryKeys = (Comparable[]) this.categoryKeys.clone(); clone.seriesKeys = (Comparable[]) this.seriesKeys.clone(); clone.startData = clone(this.startData); clone.endData = clone(this.endData); return clone; } /** * Tests two double[][] arrays for equality. * * @param array1 the first array (null permitted). * @param array2 the second arrray (null permitted). * * @return A boolean. */ private static boolean equal(Number[][] array1, Number[][] array2) { if (array1 == null) { return (array2 == null); } if (array2 == null) { return false; } if (array1.length != array2.length) { return false; } for (int i = 0; i < array1.length; i++) { if (!Arrays.equals(array1[i], array2[i])) { return false; } } return true; } /** * Clones a two dimensional array of Number objects. * * @param array the array (null not permitted). * * @return A clone of the array. */ private static Number[][] clone(Number[][] array) { if (array == null) { throw new IllegalArgumentException("Null 'array' argument."); } Number[][] result = new Number[array.length][]; for (int i = 0; i < array.length; i++) { Number[] child = array[i]; Number[] copychild = new Number[child.length]; System.arraycopy(child, 0, copychild, 0, child.length); result[i] = copychild; } return result; } /** * Returns a list of the series in the dataset. * * @return A list of the series in the dataset. * * @deprecated Use {@link #getRowKeys()} instead. */ public List getSeries() { if (this.seriesKeys == null) { return new java.util.ArrayList(); } else { return Collections.unmodifiableList(Arrays.asList(this.seriesKeys)); } } /** * Returns a list of the categories in the dataset. * * @return A list of the categories in the dataset. * * @deprecated Use {@link #getColumnKeys()} instead. */ public List getCategories() { return getColumnKeys(); } /** * Returns the item count. * * @return The item count. * * @deprecated Use {@link #getCategoryCount()} instead. */ public int getItemCount() { return this.categoryKeys.length; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/IntervalCategoryDataset.java0000644000175000017500000000730211173030414031513 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * IntervalCategoryDataset.java * ---------------------------- * (C) Copyright 2002-2008, by Eduard Martinescu and Contributors. * * Original Author: Eduard Martinescu; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 19-Mar-2002 : Version 1 contributed by Eduard Martinescu. The interface * name and method names have been renamed to be consistent with * existing interfaces (DG); * 06-Jun-2002 : Updated Javadoc comments (DG); * 24-Oct-2002 : Categories and series are now indexed by int or Comparable, * following changes made to the CategoryDataset interface (DG); * 12-May-2008 : Updated API docs (DG); * */ package org.jfree.data.category; /** * A category dataset that defines a value range for each series/category * combination. */ public interface IntervalCategoryDataset extends CategoryDataset { /** * Returns the start value for the interval for a given series and category. * * @param series the series (zero-based index). * @param category the category (zero-based index). * * @return The start value (possibly null). * * @see #getEndValue(int, int) */ public Number getStartValue(int series, int category); /** * Returns the start value for the interval for a given series and category. * * @param series the series key. * @param category the category key. * * @return The start value (possibly null). * * @see #getEndValue(Comparable, Comparable) */ public Number getStartValue(Comparable series, Comparable category); /** * Returns the end value for the interval for a given series and category. * * @param series the series (zero-based index). * @param category the category (zero-based index). * * @return The end value (possibly null). * * @see #getStartValue(int, int) */ public Number getEndValue(int series, int category); /** * Returns the end value for the interval for a given series and category. * * @param series the series key. * @param category the category key. * * @return The end value (possibly null). * * @see #getStartValue(Comparable, Comparable) */ public Number getEndValue(Comparable series, Comparable category); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/SlidingCategoryDataset.java0000644000175000017500000002520411173030414031321 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * SlidingCategoryDataset.java * --------------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-May-2008 : Version 1 (DG); * 15-Mar-2009 : Fixed bug in getColumnKeys() method (DG); * */ package org.jfree.data.category; import java.util.Collections; import java.util.List; import org.jfree.data.UnknownKeyException; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A {@link CategoryDataset} implementation that presents a subset of the * categories in an underlying dataset. The index of the first "visible" * category can be modified, which provides a means of "sliding" through * the categories in the underlying dataset. * * @since 1.0.10 */ public class SlidingCategoryDataset extends AbstractDataset implements CategoryDataset { /** The underlying dataset. */ private CategoryDataset underlying; /** The index of the first category to present. */ private int firstCategoryIndex; /** The maximum number of categories to present. */ private int maximumCategoryCount; /** * Creates a new instance. * * @param underlying the underlying dataset (null not * permitted). * @param firstColumn the index of the first visible column from the * underlying dataset. * @param maxColumns the maximumColumnCount. */ public SlidingCategoryDataset(CategoryDataset underlying, int firstColumn, int maxColumns) { this.underlying = underlying; this.firstCategoryIndex = firstColumn; this.maximumCategoryCount = maxColumns; } /** * Returns the underlying dataset that was supplied to the constructor. * * @return The underlying dataset (never null). */ public CategoryDataset getUnderlyingDataset() { return this.underlying; } /** * Returns the index of the first visible category. * * @return The index. * * @see #setFirstCategoryIndex(int) */ public int getFirstCategoryIndex() { return this.firstCategoryIndex; } /** * Sets the index of the first category that should be used from the * underlying dataset, and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param first the index. * * @see #getFirstCategoryIndex() */ public void setFirstCategoryIndex(int first) { if (first < 0 || first >= this.underlying.getColumnCount()) { throw new IllegalArgumentException("Invalid index."); } this.firstCategoryIndex = first; fireDatasetChanged(); } /** * Returns the maximum category count. * * @return The maximum category count. * * @see #setMaximumCategoryCount(int) */ public int getMaximumCategoryCount() { return this.maximumCategoryCount; } /** * Sets the maximum category count and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param max the maximum. * * @see #getMaximumCategoryCount() */ public void setMaximumCategoryCount(int max) { if (max < 0) { throw new IllegalArgumentException("Requires 'max' >= 0."); } this.maximumCategoryCount = max; fireDatasetChanged(); } /** * Returns the index of the last column for this dataset, or -1. * * @return The index. */ private int lastCategoryIndex() { if (this.maximumCategoryCount == 0) { return -1; } return Math.min(this.firstCategoryIndex + this.maximumCategoryCount, this.underlying.getColumnCount()) - 1; } /** * Returns the index for the specified column key. * * @param key the key. * * @return The column index, or -1 if the key is not recognised. */ public int getColumnIndex(Comparable key) { int index = this.underlying.getColumnIndex(key); if (index >= this.firstCategoryIndex && index <= lastCategoryIndex()) { return index - this.firstCategoryIndex; } return -1; // we didn't find the key } /** * Returns the column key for a given index. * * @param column the column index (zero-based). * * @return The column key. * * @throws IndexOutOfBoundsException if row is out of bounds. */ public Comparable getColumnKey(int column) { return this.underlying.getColumnKey(column + this.firstCategoryIndex); } /** * Returns the column keys. * * @return The keys. * * @see #getColumnKey(int) */ public List getColumnKeys() { List result = new java.util.ArrayList(); int last = lastCategoryIndex(); for (int i = this.firstCategoryIndex; i <= last; i++) { result.add(this.underlying.getColumnKey(i)); } return Collections.unmodifiableList(result); } /** * Returns the row index for a given key. * * @param key the row key. * * @return The row index, or -1 if the key is unrecognised. */ public int getRowIndex(Comparable key) { return this.underlying.getRowIndex(key); } /** * Returns the row key for a given index. * * @param row the row index (zero-based). * * @return The row key. * * @throws IndexOutOfBoundsException if row is out of bounds. */ public Comparable getRowKey(int row) { return this.underlying.getRowKey(row); } /** * Returns the row keys. * * @return The keys. */ public List getRowKeys() { return this.underlying.getRowKeys(); } /** * Returns the value for a pair of keys. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The value (possibly null). * * @throws UnknownKeyException if either key is not defined in the dataset. */ public Number getValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getValue(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the number of columns in the table. * * @return The column count. */ public int getColumnCount() { int last = lastCategoryIndex(); if (last == -1) { return 0; } else { return Math.max(last - this.firstCategoryIndex + 1, 0); } } /** * Returns the number of rows in the table. * * @return The row count. */ public int getRowCount() { return this.underlying.getRowCount(); } /** * Returns a value from the table. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The value (possibly null). */ public Number getValue(int row, int column) { return this.underlying.getValue(row, column + this.firstCategoryIndex); } /** * Tests this SlidingCategoryDataset for equality with an * arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SlidingCategoryDataset)) { return false; } SlidingCategoryDataset that = (SlidingCategoryDataset) obj; if (this.firstCategoryIndex != that.firstCategoryIndex) { return false; } if (this.maximumCategoryCount != that.maximumCategoryCount) { return false; } if (!this.underlying.equals(that.underlying)) { return false; } return true; } /** * Returns an independent copy of the dataset. Note that: *

    *
  • the underlying dataset is only cloned if it implements the * {@link PublicCloneable} interface;
  • *
  • the listeners registered with this dataset are not carried over to * the cloned dataset.
  • *
* * @return An independent copy of the dataset. * * @throws CloneNotSupportedException if the dataset cannot be cloned for * any reason. */ public Object clone() throws CloneNotSupportedException { SlidingCategoryDataset clone = (SlidingCategoryDataset) super.clone(); if (this.underlying instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.underlying; clone.underlying = (CategoryDataset) pc.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/category/package.html0000644000175000017500000000032411173030414026336 0ustar vincentvincent A package containing the {@link org.jfree.data.category.CategoryDataset} interface and related classes. libjfreechart-java-1.0.13.orig/source/org/jfree/data/contour/0000755000175000017500000000000011216245562023744 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/contour/ContourDataset.java0000644000175000017500000000765511173030414027551 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * ContourDataset.java * ------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 23-Jan-2003) * -------------------------- * 23-Jan-2003 : Added standard header (DG); * 17-Jan-2004 : Added methods from DefaultContourDataset that are referenced * by ContourPlot. See bug 741048 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.data.contour; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYZDataset; /** * The interface through which JFreeChart obtains data in the form of (x, y, z) * items - used for XY and XYZ plots. * * @deprecated This interface is no longer supported (as of version 1.0.4). * If you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public interface ContourDataset extends XYZDataset { /** * Returns the smallest Z data value. * * @return The minimum Z value. */ public double getMinZValue(); /** * Returns the largest Z data value. * * @return The maximum Z value. */ public double getMaxZValue(); /** * Returns the array of Numbers representing the x data values. * * @return The array of x values. */ public Number[] getXValues(); /** * Returns the array of Numbers representing the y data values. * * @return The array of y values. */ public Number[] getYValues(); /** * Returns the array of Numbers representing the z data values. * * @return The array of z values. */ public Number[] getZValues(); /** * Returns an int array contain the index into the x values. * * @return The X values. */ public int[] indexX(); /** * Returns the index of the xvalues. * * @return The x values. */ public int[] getXIndices(); /** * Returns the maximum z-value within visible region of plot. * * @param x the x-value. * @param y the y-value. * * @return The maximum z-value. */ public Range getZValueRange(Range x, Range y); /** * Returns true if axis are dates. * * @param axisNumber the axis where 0-x, 1-y, and 2-z. * * @return true or false. */ public boolean isDateAxis(int axisNumber); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/contour/DefaultContourDataset.java0000644000175000017500000003734211173030414031052 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultContourDataset.java * -------------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 23-Jan-2003) * -------------------------- * 23-Jan-2003 : Added standard header (DG); * 20-May-2003 : removed member vars numX and numY, which were never used (TM); * 06-May-2004 : Now extends AbstractXYZDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue(), getY() with getYValue() and * getZ() with getZValue() methods (DG); * ------------- JFREECHART 1.0.x -------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.data.contour; import java.util.Arrays; import java.util.Date; import java.util.Vector; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.Range; import org.jfree.data.xy.AbstractXYZDataset; import org.jfree.data.xy.XYDataset; /** * A convenience class that provides a default implementation of the * {@link ContourDataset} interface. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class DefaultContourDataset extends AbstractXYZDataset implements ContourDataset { /** The series name (this dataset supports only one series). */ protected Comparable seriesKey = null; /** Storage for the x values. */ protected Number[] xValues = null; /** Storage for the y values. */ protected Number[] yValues = null; /** Storage for the z values. */ protected Number[] zValues = null; /** The index for the start of each column in the data. */ protected int[] xIndex = null; /** Flags that track whether x, y and z are dates. */ boolean[] dateAxis = new boolean[3]; /** * Creates a new dataset, initially empty. */ public DefaultContourDataset() { super(); } /** * Constructs a new dataset with the given data. * * @param seriesKey the series key. * @param xData the x values. * @param yData the y values. * @param zData the z values. */ public DefaultContourDataset(Comparable seriesKey, Object[] xData, Object[] yData, Object[] zData) { this.seriesKey = seriesKey; initialize(xData, yData, zData); } /** * Initialises the dataset. * * @param xData the x values. * @param yData the y values. * @param zData the z values. */ public void initialize(Object[] xData, Object[] yData, Object[] zData) { this.xValues = new Double[xData.length]; this.yValues = new Double[yData.length]; this.zValues = new Double[zData.length]; // We organise the data with the following assumption: // 1) the data are sorted by x then y // 2) that the data will be represented by a rectangle formed by // using x[i+1], x, y[j+1], and y. // 3) we march along the y-axis at the same value of x until a new // value x is found at which point we will flag the index // where x[i+1]<>x[i] Vector tmpVector = new Vector(); //create a temporary vector double x = 1.123452e31; // set x to some arbitary value (used below) for (int k = 0; k < this.xValues.length; k++) { if (xData[k] != null) { Number xNumber; if (xData[k] instanceof Number) { xNumber = (Number) xData[k]; } else if (xData[k] instanceof Date) { this.dateAxis[0] = true; Date xDate = (Date) xData[k]; xNumber = new Long(xDate.getTime()); //store data as Long } else { xNumber = new Integer(0); } this.xValues[k] = new Double(xNumber.doubleValue()); // store Number as Double // check if starting new column if (x != this.xValues[k].doubleValue()) { tmpVector.add(new Integer(k)); //store index where new //column starts x = this.xValues[k].doubleValue(); // set x to most recent value } } } Object[] inttmp = tmpVector.toArray(); this.xIndex = new int[inttmp.length]; // create array xIndex to hold // new column indices for (int i = 0; i < inttmp.length; i++) { this.xIndex[i] = ((Integer) inttmp[i]).intValue(); } for (int k = 0; k < this.yValues.length; k++) { // store y and z axes // as Doubles this.yValues[k] = (Double) yData[k]; if (zData[k] != null) { this.zValues[k] = (Double) zData[k]; } } } /** * Creates an object array from an array of doubles. * * @param data the data. * * @return An array of Double objects. */ public static Object[][] formObjectArray(double[][] data) { Object[][] object = new Double[data.length][data[0].length]; for (int i = 0; i < object.length; i++) { for (int j = 0; j < object[i].length; j++) { object[i][j] = new Double(data[i][j]); } } return object; } /** * Creates an object array from an array of doubles. * * @param data the data. * * @return An array of Double objects. */ public static Object[] formObjectArray(double[] data) { Object[] object = new Double[data.length]; for (int i = 0; i < object.length; i++) { object[i] = new Double(data[i]); } return object; } /** * Returns the number of items in the specified series. This method * is provided to satisfy the {@link XYDataset} interface implementation. * * @param series must be zero, as this dataset only supports one series. * * @return The item count. */ public int getItemCount(int series) { if (series > 0) { throw new IllegalArgumentException("Only one series for contour"); } return this.zValues.length; } /** * Returns the maximum z-value. * * @return The maximum z-value. */ public double getMaxZValue() { double zMax = -1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.zValues[k] != null) { zMax = Math.max(zMax, this.zValues[k].doubleValue()); } } return zMax; } /** * Returns the minimum z-value. * * @return The minimum z-value. */ public double getMinZValue() { double zMin = 1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.zValues[k] != null) { zMin = Math.min(zMin, this.zValues[k].doubleValue()); } } return zMin; } /** * Returns the maximum z-value within visible region of plot. * * @param x the x range. * @param y the y range. * * @return The z range. */ public Range getZValueRange(Range x, Range y) { double minX = x.getLowerBound(); double minY = y.getLowerBound(); double maxX = x.getUpperBound(); double maxY = y.getUpperBound(); double zMin = 1.e20; double zMax = -1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.xValues[k].doubleValue() >= minX && this.xValues[k].doubleValue() <= maxX && this.yValues[k].doubleValue() >= minY && this.yValues[k].doubleValue() <= maxY) { if (this.zValues[k] != null) { zMin = Math.min(zMin, this.zValues[k].doubleValue()); zMax = Math.max(zMax, this.zValues[k].doubleValue()); } } } return new Range(zMin, zMax); } /** * Returns the minimum z-value. * * @param minX the minimum x value. * @param minY the minimum y value. * @param maxX the maximum x value. * @param maxY the maximum y value. * * @return The minimum z-value. */ public double getMinZValue(double minX, double minY, double maxX, double maxY) { double zMin = 1.e20; for (int k = 0; k < this.zValues.length; k++) { if (this.zValues[k] != null) { zMin = Math.min(zMin, this.zValues[k].doubleValue()); } } return zMin; } /** * Returns the number of series. *

* Required by XYDataset interface (this will always return 1) * * @return 1. */ public int getSeriesCount() { return 1; } /** * Returns the name of the specified series. * * Method provided to satisfy the XYDataset interface implementation * * @param series must be zero. * * @return The series name. */ public Comparable getSeriesKey(int series) { if (series > 0) { throw new IllegalArgumentException("Only one series for contour"); } return this.seriesKey; } /** * Returns the index of the xvalues. * * @return The x values. */ public int[] getXIndices() { return this.xIndex; } /** * Returns the x values. * * @return The x values. */ public Number[] getXValues() { return this.xValues; } /** * Returns the x value for the specified series and index (zero-based * indices). Required by the {@link XYDataset}. * * @param series must be zero; * @param item the item index (zero-based). * * @return The x value. */ public Number getX(int series, int item) { if (series > 0) { throw new IllegalArgumentException("Only one series for contour"); } return this.xValues[item]; } /** * Returns an x value. * * @param item the item index (zero-based). * * @return The X value. */ public Number getXValue(int item) { return this.xValues[item]; } /** * Returns a Number array containing all y values. * * @return The Y values. */ public Number[] getYValues() { return this.yValues; } /** * Returns the y value for the specified series and index (zero-based * indices). Required by the {@link XYDataset}. * * @param series the series index (must be zero for this dataset). * @param item the item index (zero-based). * * @return The Y value. */ public Number getY(int series, int item) { if (series > 0) { throw new IllegalArgumentException("Only one series for contour"); } return this.yValues[item]; } /** * Returns a Number array containing all z values. * * @return The Z values. */ public Number[] getZValues() { return this.zValues; } /** * Returns the z value for the specified series and index (zero-based * indices). Required by the {@link XYDataset} * * @param series the series index (must be zero for this dataset). * @param item the item index (zero-based). * * @return The Z value. */ public Number getZ(int series, int item) { if (series > 0) { throw new IllegalArgumentException("Only one series for contour"); } return this.zValues[item]; } /** * Returns an int array contain the index into the x values. * * @return The X values. */ public int[] indexX() { int[] index = new int[this.xValues.length]; for (int k = 0; k < index.length; k++) { index[k] = indexX(k); } return index; } /** * Given index k, returns the column index containing k. * * @param k index of interest. * * @return The column index. */ public int indexX(int k) { int i = Arrays.binarySearch(this.xIndex, k); if (i >= 0) { return i; } else { return -1 * i - 2; } } /** * Given index k, return the row index containing k. * * @param k index of interest. * * @return The row index. */ public int indexY(int k) { // this may be obsolete (not used anywhere) return (k / this.xValues.length); } /** * Given column and row indices, returns the k index. * * @param i index of along x-axis. * @param j index of along y-axis. * * @return The Z index. */ public int indexZ(int i, int j) { return this.xValues.length * j + i; } /** * Returns true if axis are dates. * * @param axisNumber The axis where 0-x, 1-y, and 2-z. * * @return A boolean. */ public boolean isDateAxis(int axisNumber) { if (axisNumber < 0 || axisNumber > 2) { return false; // bad axisNumber } return this.dateAxis[axisNumber]; } /** * Sets the names of the series in the data source. * * @param seriesKeys the keys of the series in the data source. */ public void setSeriesKeys(Comparable[] seriesKeys) { if (seriesKeys.length > 1) { throw new IllegalArgumentException( "Contours only support one series"); } this.seriesKey = seriesKeys[0]; fireDatasetChanged(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/contour/NonGridContourDataset.java0000644000175000017500000002024311173030414031016 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * NonGridContourDataset.java * -------------------------- * (C) Copyright 2002-2008, by David M. O'Donnell. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 24-Jul-2003) * -------------------------- * 24-Jul-2003 : Added standard header (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jan-2007 : Deprecated (DG); * */ package org.jfree.data.contour; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.Range; /** * A convenience class that extends the {@link DefaultContourDataset} to * accommodate non-grid data. * * @deprecated This class is no longer supported (as of version 1.0.4). If * you are creating contour plots, please try to use {@link XYPlot} and * {@link XYBlockRenderer}. */ public class NonGridContourDataset extends DefaultContourDataset { /** Default number of x values. */ static final int DEFAULT_NUM_X = 50; /** Default number of y values. */ static final int DEFAULT_NUM_Y = 50; /** Default power. */ static final int DEFAULT_POWER = 4; /** * Default constructor. */ public NonGridContourDataset() { super(); } /** * Constructor for NonGridContourDataset. Uses default values for grid * dimensions and weighting. * * @param seriesName the series name. * @param xData the x values. * @param yData the y values. * @param zData the z values. */ public NonGridContourDataset(String seriesName, Object[] xData, Object[] yData, Object[] zData) { super(seriesName, xData, yData, zData); buildGrid(DEFAULT_NUM_X, DEFAULT_NUM_Y, DEFAULT_POWER); } /** * Constructor for NonGridContourDataset. * * @param seriesName the series name. * @param xData the x values. * @param yData the y values. * @param zData the z values. * @param numX number grid cells in along the x-axis * @param numY number grid cells in along the y-axis * @param power exponent for inverse distance weighting */ public NonGridContourDataset(String seriesName, Object[] xData, Object[] yData, Object[] zData, int numX, int numY, int power) { super(seriesName, xData, yData, zData); buildGrid(numX, numY, power); } /** * Builds a regular grid. Maps the non-grid data into the regular grid * using an inverse distance between grid and non-grid points. Weighting * of distance can be controlled by setting through the power parameter * that controls the exponent used on the distance weighting * (e.g., distance^power). * * @param numX number grid points in along the x-axis * @param numY number grid points in along the y-axis * @param power exponent for inverse distance weighting */ protected void buildGrid(int numX, int numY, int power) { int numValues = numX * numY; double[] xGrid = new double[numValues]; double[] yGrid = new double [numValues]; double[] zGrid = new double [numValues]; // Find min, max for the x and y axes double xMin = 1.e20; for (int k = 0; k < this.xValues.length; k++) { xMin = Math.min(xMin, this.xValues[k].doubleValue()); } double xMax = -1.e20; for (int k = 0; k < this.xValues.length; k++) { xMax = Math.max(xMax, this.xValues[k].doubleValue()); } double yMin = 1.e20; for (int k = 0; k < this.yValues.length; k++) { yMin = Math.min(yMin, this.yValues[k].doubleValue()); } double yMax = -1.e20; for (int k = 0; k < this.yValues.length; k++) { yMax = Math.max(yMax, this.yValues[k].doubleValue()); } Range xRange = new Range(xMin, xMax); Range yRange = new Range(yMin, yMax); xRange.getLength(); yRange.getLength(); // Determine the cell size double dxGrid = xRange.getLength() / (numX - 1); double dyGrid = yRange.getLength() / (numY - 1); // Generate the grid double x = 0.0; for (int i = 0; i < numX; i++) { if (i == 0) { x = xMin; } else { x += dxGrid; } double y = 0.0; for (int j = 0; j < numY; j++) { int k = numY * i + j; xGrid[k] = x; if (j == 0) { y = yMin; } else { y += dyGrid; } yGrid[k] = y; } } // Map the nongrid data into the new regular grid for (int kGrid = 0; kGrid < xGrid.length; kGrid++) { double dTotal = 0.0; zGrid[kGrid] = 0.0; for (int k = 0; k < this.xValues.length; k++) { double xPt = this.xValues[k].doubleValue(); double yPt = this.yValues[k].doubleValue(); double d = distance(xPt, yPt, xGrid[kGrid], yGrid[kGrid]); if (power != 1) { d = Math.pow(d, power); } d = Math.sqrt(d); if (d > 0.0) { d = 1.0 / d; } else { // if d is real small set the inverse to a large number // to avoid INF d = 1.e20; } if (this.zValues[k] != null) { // scale by the inverse of distance^power zGrid[kGrid] += this.zValues[k].doubleValue() * d; } dTotal += d; } zGrid[kGrid] = zGrid[kGrid] / dTotal; //remove distance of the sum } //initalize xValues, yValues, and zValues arrays. initialize( formObjectArray(xGrid), formObjectArray(yGrid), formObjectArray(zGrid) ); } /** * Calculates the distance between two points. * * @param xDataPt the x coordinate. * @param yDataPt the y coordinate. * @param xGrdPt the x grid coordinate. * @param yGrdPt the y grid coordinate. * * @return The distance between two points. */ protected double distance(double xDataPt, double yDataPt, double xGrdPt, double yGrdPt) { double dx = xDataPt - xGrdPt; double dy = yDataPt - yGrdPt; return Math.sqrt(dx * dx + dy * dy); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/contour/package.html0000644000175000017500000000036611173030414026220 0ustar vincentvincent Datasets used by the {@link org.jfree.chart.plot.ContourPlot} class. All classes/interfaces in this package are now deprecated. libjfreechart-java-1.0.13.orig/source/org/jfree/data/function/0000755000175000017500000000000011216245562024100 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/function/Function2D.java0000644000175000017500000000356411173030414026714 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * Function2D.java * --------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 01-Oct-2002 : Version 1 (DG); * 20-Jan-2005 : Minor Javadoc update (DG); * */ package org.jfree.data.function; /** * A function of the form y = f(x). */ public interface Function2D { /** * Returns the value of the function ('y') for a given input ('x'). * * @param x the x-value. * * @return The function value. */ public double getValue(double x); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/function/LineFunction2D.java0000644000175000017500000000426111173030414027517 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * LineFunction2D.java * ------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 01-Oct-2002 : Version 1 (DG); * */ package org.jfree.data.function; /** * A function in the form y = a + bx. */ public class LineFunction2D implements Function2D { /** The intercept. */ private double a; /** The slope of the line. */ private double b; /** * Constructs a new line function. * * @param a the intercept. * @param b the slope. */ public LineFunction2D(double a, double b) { this.a = a; this.b = b; } /** * Returns the function value. * * @param x the x-value. * * @return The value. */ public double getValue(double x) { return this.a + this.b * x; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/function/NormalDistributionFunction2D.java0000644000175000017500000000655611173030414032471 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * NormalDistributionFunction2D.java * --------------------------------- * (C)opyright 2004-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-May-2004 : Version 1 (DG); * 21-Nov-2005 : Added getters for the mean and standard deviation (DG); * 12-Feb-2009 : Precompute some constants from the function - see bug * 2572016 (DG); * */ package org.jfree.data.function; /** * A normal distribution function. See * http://en.wikipedia.org/wiki/Normal_distribution. */ public class NormalDistributionFunction2D implements Function2D { /** The mean. */ private double mean; /** The standard deviation. */ private double std; /** Precomputed factor for the function value. */ private double factor; /** Precomputed denominator for the function value. */ private double denominator; /** * Constructs a new normal distribution function. * * @param mean the mean. * @param std the standard deviation (> 0). */ public NormalDistributionFunction2D(double mean, double std) { if (std <= 0) { throw new IllegalArgumentException("Requires 'std' > 0."); } this.mean = mean; this.std = std; // calculate constant values this.factor = 1 / (std * Math.sqrt(2.0 * Math.PI)); this.denominator = 2 * std * std; } /** * Returns the mean for the function. * * @return The mean. */ public double getMean() { return this.mean; } /** * Returns the standard deviation for the function. * * @return The standard deviation. */ public double getStandardDeviation() { return this.std; } /** * Returns the function value. * * @param x the x-value. * * @return The value. */ public double getValue(double x) { double z = x - this.mean; return this.factor * Math.exp(-z * z / this.denominator); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/function/PowerFunction2D.java0000644000175000017500000000436311173030414027727 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PowerFunction2D.java * -------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 01-Oct-2002 : Version 1 (DG); * */ package org.jfree.data.function; /** * A function of the form y = a * x ^ b. */ public class PowerFunction2D implements Function2D { /** The 'a' coefficient. */ private double a; /** The 'b' coefficient. */ private double b; /** * Creates a new power function. * * @param a the 'a' coefficient. * @param b the 'b' coefficient. */ public PowerFunction2D(double a, double b) { this.a = a; this.b = b; } /** * Returns the value of the function for a given input ('x'). * * @param x the x-value. * * @return The value. */ public double getValue(double x) { return this.a * Math.pow(x, this.b); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/function/package.html0000644000175000017500000000022111173030414026342 0ustar vincentvincent Representation for simple functions. libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/0000755000175000017500000000000011216245562023370 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/GanttCategoryDataset.java0000644000175000017500000001407011173030414030304 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * GanttCategoryDataset.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Sep-2003 : Version 1, based on MultiIntervalCategoryDataset (DG); * 23-Sep-2003 : Fixed Checkstyle issues (DG); * 12-May-2008 : Updated API docs (DG); * */ package org.jfree.data.gantt; import org.jfree.data.category.IntervalCategoryDataset; /** * An extension of the {@link IntervalCategoryDataset} interface that adds * support for multiple sub-intervals. */ public interface GanttCategoryDataset extends IntervalCategoryDataset { /** * Returns the percent complete for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The percent complete. * * @see #getPercentComplete(Comparable, Comparable) */ public Number getPercentComplete(int row, int column); /** * Returns the percent complete for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The percent complete. * * @see #getPercentComplete(int, int) */ public Number getPercentComplete(Comparable rowKey, Comparable columnKey); /** * Returns the number of sub-intervals for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The sub-interval count. * * @see #getSubIntervalCount(Comparable, Comparable) */ public int getSubIntervalCount(int row, int column); /** * Returns the number of sub-intervals for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The sub-interval count. * * @see #getSubIntervalCount(int, int) */ public int getSubIntervalCount(Comparable rowKey, Comparable columnKey); /** * Returns the start value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval index (zero-based). * * @return The start value (possibly null). * * @see #getEndValue(int, int, int) */ public Number getStartValue(int row, int column, int subinterval); /** * Returns the start value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The start value (possibly null). * * @see #getEndValue(Comparable, Comparable, int) */ public Number getStartValue(Comparable rowKey, Comparable columnKey, int subinterval); /** * Returns the end value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval. * * @return The end value (possibly null). * * @see #getStartValue(int, int, int) */ public Number getEndValue(int row, int column, int subinterval); /** * Returns the end value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The end value (possibly null). * * @see #getStartValue(Comparable, Comparable, int) */ public Number getEndValue(Comparable rowKey, Comparable columnKey, int subinterval); /** * Returns the percentage complete value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval. * * @return The percent complete value (possibly null). * * @see #getPercentComplete(Comparable, Comparable, int) */ public Number getPercentComplete(int row, int column, int subinterval); /** * Returns the percentage complete value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The percent complete value (possibly null). * * @see #getPercentComplete(int, int, int) */ public Number getPercentComplete(Comparable rowKey, Comparable columnKey, int subinterval); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/SlidingGanttCategoryDataset.java0000644000175000017500000004634511173030414031630 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * SlidingGanttCategoryDataset.java * -------------------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-May-2008 : Version 1 (DG); * */ package org.jfree.data.gantt; import java.util.Collections; import java.util.List; import org.jfree.data.UnknownKeyException; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A {@link GanttCategoryDataset} implementation that presents a subset of the * categories in an underlying dataset. The index of the first "visible" * category can be modified, which provides a means of "sliding" through * the categories in the underlying dataset. * * @since 1.0.10 */ public class SlidingGanttCategoryDataset extends AbstractDataset implements GanttCategoryDataset { /** The underlying dataset. */ private GanttCategoryDataset underlying; /** The index of the first category to present. */ private int firstCategoryIndex; /** The maximum number of categories to present. */ private int maximumCategoryCount; /** * Creates a new instance. * * @param underlying the underlying dataset (null not * permitted). * @param firstColumn the index of the first visible column from the * underlying dataset. * @param maxColumns the maximumColumnCount. */ public SlidingGanttCategoryDataset(GanttCategoryDataset underlying, int firstColumn, int maxColumns) { this.underlying = underlying; this.firstCategoryIndex = firstColumn; this.maximumCategoryCount = maxColumns; } /** * Returns the underlying dataset that was supplied to the constructor. * * @return The underlying dataset (never null). */ public GanttCategoryDataset getUnderlyingDataset() { return this.underlying; } /** * Returns the index of the first visible category. * * @return The index. * * @see #setFirstCategoryIndex(int) */ public int getFirstCategoryIndex() { return this.firstCategoryIndex; } /** * Sets the index of the first category that should be used from the * underlying dataset, and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param first the index. * * @see #getFirstCategoryIndex() */ public void setFirstCategoryIndex(int first) { if (first < 0 || first >= this.underlying.getColumnCount()) { throw new IllegalArgumentException("Invalid index."); } this.firstCategoryIndex = first; fireDatasetChanged(); } /** * Returns the maximum category count. * * @return The maximum category count. * * @see #setMaximumCategoryCount(int) */ public int getMaximumCategoryCount() { return this.maximumCategoryCount; } /** * Sets the maximum category count and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param max the maximum. * * @see #getMaximumCategoryCount() */ public void setMaximumCategoryCount(int max) { if (max < 0) { throw new IllegalArgumentException("Requires 'max' >= 0."); } this.maximumCategoryCount = max; fireDatasetChanged(); } /** * Returns the index of the last column for this dataset, or -1. * * @return The index. */ private int lastCategoryIndex() { if (this.maximumCategoryCount == 0) { return -1; } return Math.min(this.firstCategoryIndex + this.maximumCategoryCount, this.underlying.getColumnCount()) - 1; } /** * Returns the index for the specified column key. * * @param key the key. * * @return The column index, or -1 if the key is not recognised. */ public int getColumnIndex(Comparable key) { int index = this.underlying.getColumnIndex(key); if (index >= this.firstCategoryIndex && index <= lastCategoryIndex()) { return index - this.firstCategoryIndex; } return -1; // we didn't find the key } /** * Returns the column key for a given index. * * @param column the column index (zero-based). * * @return The column key. * * @throws IndexOutOfBoundsException if row is out of bounds. */ public Comparable getColumnKey(int column) { return this.underlying.getColumnKey(column + this.firstCategoryIndex); } /** * Returns the column keys. * * @return The keys. * * @see #getColumnKey(int) */ public List getColumnKeys() { List result = new java.util.ArrayList(); int last = lastCategoryIndex(); for (int i = this.firstCategoryIndex; i < last; i++) { result.add(this.underlying.getColumnKey(i)); } return Collections.unmodifiableList(result); } /** * Returns the row index for a given key. * * @param key the row key. * * @return The row index, or -1 if the key is unrecognised. */ public int getRowIndex(Comparable key) { return this.underlying.getRowIndex(key); } /** * Returns the row key for a given index. * * @param row the row index (zero-based). * * @return The row key. * * @throws IndexOutOfBoundsException if row is out of bounds. */ public Comparable getRowKey(int row) { return this.underlying.getRowKey(row); } /** * Returns the row keys. * * @return The keys. */ public List getRowKeys() { return this.underlying.getRowKeys(); } /** * Returns the value for a pair of keys. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The value (possibly null). * * @throws UnknownKeyException if either key is not defined in the dataset. */ public Number getValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getValue(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the number of columns in the table. * * @return The column count. */ public int getColumnCount() { int last = lastCategoryIndex(); if (last == -1) { return 0; } else { return Math.max(last - this.firstCategoryIndex + 1, 0); } } /** * Returns the number of rows in the table. * * @return The row count. */ public int getRowCount() { return this.underlying.getRowCount(); } /** * Returns a value from the table. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The value (possibly null). */ public Number getValue(int row, int column) { return this.underlying.getValue(row, column + this.firstCategoryIndex); } /** * Returns the percent complete for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The percent complete. */ public Number getPercentComplete(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getPercentComplete(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the percentage complete value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The percent complete value (possibly null). * * @see #getPercentComplete(int, int, int) */ public Number getPercentComplete(Comparable rowKey, Comparable columnKey, int subinterval) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getPercentComplete(r, c + this.firstCategoryIndex, subinterval); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the end value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The end value (possibly null). * * @see #getStartValue(Comparable, Comparable, int) */ public Number getEndValue(Comparable rowKey, Comparable columnKey, int subinterval) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getEndValue(r, c + this.firstCategoryIndex, subinterval); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the end value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval. * * @return The end value (possibly null). * * @see #getStartValue(int, int, int) */ public Number getEndValue(int row, int column, int subinterval) { return this.underlying.getEndValue(row, column + this.firstCategoryIndex, subinterval); } /** * Returns the percent complete for a given item. * * @param series the row index (zero-based). * @param category the column index (zero-based). * * @return The percent complete. */ public Number getPercentComplete(int series, int category) { return this.underlying.getPercentComplete(series, category + this.firstCategoryIndex); } /** * Returns the percentage complete value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval. * * @return The percent complete value (possibly null). * * @see #getPercentComplete(Comparable, Comparable, int) */ public Number getPercentComplete(int row, int column, int subinterval) { return this.underlying.getPercentComplete(row, column + this.firstCategoryIndex, subinterval); } /** * Returns the start value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The start value (possibly null). * * @see #getEndValue(Comparable, Comparable, int) */ public Number getStartValue(Comparable rowKey, Comparable columnKey, int subinterval) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getStartValue(r, c + this.firstCategoryIndex, subinterval); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the start value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval index (zero-based). * * @return The start value (possibly null). * * @see #getEndValue(int, int, int) */ public Number getStartValue(int row, int column, int subinterval) { return this.underlying.getStartValue(row, column + this.firstCategoryIndex, subinterval); } /** * Returns the number of sub-intervals for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The sub-interval count. * * @see #getSubIntervalCount(int, int) */ public int getSubIntervalCount(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getSubIntervalCount(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the number of sub-intervals for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The sub-interval count. * * @see #getSubIntervalCount(Comparable, Comparable) */ public int getSubIntervalCount(int row, int column) { return this.underlying.getSubIntervalCount(row, column + this.firstCategoryIndex); } /** * Returns the start value for the interval for a given series and category. * * @param rowKey the series key. * @param columnKey the category key. * * @return The start value (possibly null). * * @see #getEndValue(Comparable, Comparable) */ public Number getStartValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getStartValue(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the start value for the interval for a given series and category. * * @param row the series (zero-based index). * @param column the category (zero-based index). * * @return The start value (possibly null). * * @see #getEndValue(int, int) */ public Number getStartValue(int row, int column) { return this.underlying.getStartValue(row, column + this.firstCategoryIndex); } /** * Returns the end value for the interval for a given series and category. * * @param rowKey the series key. * @param columnKey the category key. * * @return The end value (possibly null). * * @see #getStartValue(Comparable, Comparable) */ public Number getEndValue(Comparable rowKey, Comparable columnKey) { int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); if (c != -1) { return this.underlying.getEndValue(r, c + this.firstCategoryIndex); } else { throw new UnknownKeyException("Unknown columnKey: " + columnKey); } } /** * Returns the end value for the interval for a given series and category. * * @param series the series (zero-based index). * @param category the category (zero-based index). * * @return The end value (possibly null). */ public Number getEndValue(int series, int category) { return this.underlying.getEndValue(series, category + this.firstCategoryIndex); } /** * Tests this SlidingCategoryDataset for equality with an * arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SlidingGanttCategoryDataset)) { return false; } SlidingGanttCategoryDataset that = (SlidingGanttCategoryDataset) obj; if (this.firstCategoryIndex != that.firstCategoryIndex) { return false; } if (this.maximumCategoryCount != that.maximumCategoryCount) { return false; } if (!this.underlying.equals(that.underlying)) { return false; } return true; } /** * Returns an independent copy of the dataset. Note that: *

    *
  • the underlying dataset is only cloned if it implements the * {@link PublicCloneable} interface;
  • *
  • the listeners registered with this dataset are not carried over to * the cloned dataset.
  • *
* * @return An independent copy of the dataset. * * @throws CloneNotSupportedException if the dataset cannot be cloned for * any reason. */ public Object clone() throws CloneNotSupportedException { SlidingGanttCategoryDataset clone = (SlidingGanttCategoryDataset) super.clone(); if (this.underlying instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.underlying; clone.underlying = (GanttCategoryDataset) pc.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/Task.java0000644000175000017500000001675111173030414025135 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Task.java * --------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jan-2003 : Version 1 (DG); * 16-Sep-2003 : Added percentage complete (DG); * 30-Jul-2004 : Added clone() and equals() methods and implemented * Serializable (DG); * */ package org.jfree.data.gantt; import java.io.Serializable; import java.util.Date; import java.util.List; import org.jfree.data.time.SimpleTimePeriod; import org.jfree.data.time.TimePeriod; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A simple representation of a task. The task has a description and a * duration. You can add sub-tasks to the task. */ public class Task implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1094303785346988894L; /** The task description. */ private String description; /** The time period for the task (estimated or actual). */ private TimePeriod duration; /** The percent complete (null is permitted). */ private Double percentComplete; /** Storage for the sub-tasks (if any). */ private List subtasks; /** * Creates a new task. * * @param description the task description (null not * permitted). * @param duration the task duration (null permitted). */ public Task(String description, TimePeriod duration) { if (description == null) { throw new IllegalArgumentException("Null 'description' argument."); } this.description = description; this.duration = duration; this.percentComplete = null; this.subtasks = new java.util.ArrayList(); } /** * Creates a new task. * * @param description the task description (null not * permitted). * @param start the start date (null not permitted). * @param end the end date (null not permitted). */ public Task(String description, Date start, Date end) { this(description, new SimpleTimePeriod(start, end)); } /** * Returns the task description. * * @return The task description (never null). */ public String getDescription() { return this.description; } /** * Sets the task description. * * @param description the description (null not permitted). */ public void setDescription(String description) { if (description == null) { throw new IllegalArgumentException("Null 'description' argument."); } this.description = description; } /** * Returns the duration (actual or estimated) of the task. * * @return The task duration (possibly null). */ public TimePeriod getDuration() { return this.duration; } /** * Sets the task duration (actual or estimated). * * @param duration the duration (null permitted). */ public void setDuration(TimePeriod duration) { this.duration = duration; } /** * Returns the percentage complete for this task. * * @return The percentage complete (possibly null). */ public Double getPercentComplete() { return this.percentComplete; } /** * Sets the percentage complete for the task. * * @param percent the percentage (null permitted). */ public void setPercentComplete(Double percent) { this.percentComplete = percent; } /** * Sets the percentage complete for the task. * * @param percent the percentage. */ public void setPercentComplete(double percent) { setPercentComplete(new Double(percent)); } /** * Adds a sub-task to the task. * * @param subtask the subtask (null not permitted). */ public void addSubtask(Task subtask) { if (subtask == null) { throw new IllegalArgumentException("Null 'subtask' argument."); } this.subtasks.add(subtask); } /** * Removes a sub-task from the task. * * @param subtask the subtask. */ public void removeSubtask(Task subtask) { this.subtasks.remove(subtask); } /** * Returns the sub-task count. * * @return The sub-task count. */ public int getSubtaskCount() { return this.subtasks.size(); } /** * Returns a sub-task. * * @param index the index. * * @return The sub-task. */ public Task getSubtask(int index) { return (Task) this.subtasks.get(index); } /** * Tests this object for equality with an arbitrary object. * * @param object the other object (null permitted). * * @return A boolean. */ public boolean equals(Object object) { if (object == this) { return true; } if (!(object instanceof Task)) { return false; } Task that = (Task) object; if (!ObjectUtilities.equal(this.description, that.description)) { return false; } if (!ObjectUtilities.equal(this.duration, that.duration)) { return false; } if (!ObjectUtilities.equal(this.percentComplete, that.percentComplete)) { return false; } if (!ObjectUtilities.equal(this.subtasks, that.subtasks)) { return false; } return true; } /** * Returns a clone of the task. * * @return A clone. * * @throws CloneNotSupportedException never thrown by this class, but * subclasses may not support cloning. */ public Object clone() throws CloneNotSupportedException { Task clone = (Task) super.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/TaskSeries.java0000644000175000017500000001346211173030414026304 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * TaskSeries.java * --------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jun-2002 : Version 1 (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Added methods to get TimeAllocation by task index (DG); * 10-Jan-2003 : Renamed GanttSeries --> TaskSeries (DG); * 30-Jul-2004 : Added equals() method (DG); * 09-May-2008 : Fixed cloning bug (DG); * */ package org.jfree.data.gantt; import java.util.Collections; import java.util.List; import org.jfree.data.general.Series; import org.jfree.util.ObjectUtilities; /** * A series that contains zero, one or many {@link Task} objects. *

* This class is used as a building block for the {@link TaskSeriesCollection} * class that can be used to construct basic Gantt charts. */ public class TaskSeries extends Series { /** Storage for the tasks in the series. */ private List tasks; /** * Constructs a new series with the specified name. * * @param name the series name (null not permitted). */ public TaskSeries(String name) { super(name); this.tasks = new java.util.ArrayList(); } /** * Adds a task to the series and sends a * {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners. * * @param task the task (null not permitted). */ public void add(Task task) { if (task == null) { throw new IllegalArgumentException("Null 'task' argument."); } this.tasks.add(task); fireSeriesChanged(); } /** * Removes a task from the series and sends * a {@link org.jfree.data.general.SeriesChangeEvent} * to all registered listeners. * * @param task the task. */ public void remove(Task task) { this.tasks.remove(task); fireSeriesChanged(); } /** * Removes all tasks from the series and sends * a {@link org.jfree.data.general.SeriesChangeEvent} * to all registered listeners. */ public void removeAll() { this.tasks.clear(); fireSeriesChanged(); } /** * Returns the number of items in the series. * * @return The item count. */ public int getItemCount() { return this.tasks.size(); } /** * Returns a task from the series. * * @param index the task index (zero-based). * * @return The task. */ public Task get(int index) { return (Task) this.tasks.get(index); } /** * Returns the task in the series that has the specified description. * * @param description the name (null not permitted). * * @return The task (possibly null). */ public Task get(String description) { Task result = null; int count = this.tasks.size(); for (int i = 0; i < count; i++) { Task t = (Task) this.tasks.get(i); if (t.getDescription().equals(description)) { result = t; break; } } return result; } /** * Returns an unmodifialble list of the tasks in the series. * * @return The tasks. */ public List getTasks() { return Collections.unmodifiableList(this.tasks); } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TaskSeries)) { return false; } if (!super.equals(obj)) { return false; } TaskSeries that = (TaskSeries) obj; if (!this.tasks.equals(that.tasks)) { return false; } return true; } /** * Returns an independent copy of this series. * * @return A clone of the series. * * @throws CloneNotSupportedException if there is some problem cloning * the dataset. */ public Object clone() throws CloneNotSupportedException { TaskSeries clone = (TaskSeries) super.clone(); clone.tasks = (List) ObjectUtilities.deepClone(this.tasks); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/TaskSeriesCollection.java0000644000175000017500000005206711173030414030324 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TaskSeriesCollection.java * ------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Thomas Schuster; * * Changes * ------- * 06-Jun-2002 : Version 1 (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and * CategoryToolTipGenerator interface (DG); * 10-Jan-2003 : Renamed GanttSeriesCollection --> TaskSeriesCollection (DG); * 04-Sep-2003 : Fixed bug 800324 (DG); * 16-Sep-2003 : Implemented GanttCategoryDataset (DG); * 12-Jan-2005 : Fixed bug 1099331 (DG); * 18-Jan-2006 : Added new methods getSeries(int) and * getSeries(Comparable) (DG); * 09-May-2008 : Fixed cloning bug (DG); * */ package org.jfree.data.gantt; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.data.general.AbstractSeriesDataset; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.time.TimePeriod; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A collection of {@link TaskSeries} objects. This class provides one * implementation of the {@link GanttCategoryDataset} interface. */ public class TaskSeriesCollection extends AbstractSeriesDataset implements GanttCategoryDataset, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2065799050738449903L; /** * Storage for aggregate task keys (the task description is used as the * key). */ private List keys; /** Storage for the series. */ private List data; /** * Default constructor. */ public TaskSeriesCollection() { this.keys = new java.util.ArrayList(); this.data = new java.util.ArrayList(); } /** * Returns a series from the collection. * * @param key the series key (null not permitted). * * @return The series. * * @since 1.0.1 */ public TaskSeries getSeries(Comparable key) { if (key == null) { throw new NullPointerException("Null 'key' argument."); } TaskSeries result = null; int index = getRowIndex(key); if (index >= 0) { result = getSeries(index); } return result; } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @since 1.0.1 */ public TaskSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (TaskSeries) this.data.get(series); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return getRowCount(); } /** * Returns the name of a series. * * @param series the series index (zero-based). * * @return The name of a series. */ public Comparable getSeriesKey(int series) { TaskSeries ts = (TaskSeries) this.data.get(series); return ts.getKey(); } /** * Returns the number of rows (series) in the collection. * * @return The series count. */ public int getRowCount() { return this.data.size(); } /** * Returns the row keys. In this case, each series is a key. * * @return The row keys. */ public List getRowKeys() { return this.data; } /** * Returns the number of column in the dataset. * * @return The column count. */ public int getColumnCount() { return this.keys.size(); } /** * Returns a list of the column keys in the dataset. * * @return The category list. */ public List getColumnKeys() { return this.keys; } /** * Returns a column key. * * @param index the column index. * * @return The column key. */ public Comparable getColumnKey(int index) { return (Comparable) this.keys.get(index); } /** * Returns the column index for a column key. * * @param columnKey the column key (null not permitted). * * @return The column index. */ public int getColumnIndex(Comparable columnKey) { if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } return this.keys.indexOf(columnKey); } /** * Returns the row index for the given row key. * * @param rowKey the row key. * * @return The index. */ public int getRowIndex(Comparable rowKey) { int result = -1; int count = this.data.size(); for (int i = 0; i < count; i++) { TaskSeries s = (TaskSeries) this.data.get(i); if (s.getKey().equals(rowKey)) { result = i; break; } } return result; } /** * Returns the key for a row. * * @param index the row index (zero-based). * * @return The key. */ public Comparable getRowKey(int index) { TaskSeries series = (TaskSeries) this.data.get(index); return series.getKey(); } /** * Adds a series to the dataset and sends a * {@link org.jfree.data.general.DatasetChangeEvent} to all registered * listeners. * * @param series the series (null not permitted). */ public void add(TaskSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); // look for any keys that we don't already know about... Iterator iterator = series.getTasks().iterator(); while (iterator.hasNext()) { Task task = (Task) iterator.next(); String key = task.getDescription(); int index = this.keys.indexOf(key); if (index < 0) { this.keys.add(key); } } fireDatasetChanged(); } /** * Removes a series from the collection and sends * a {@link org.jfree.data.general.DatasetChangeEvent} * to all registered listeners. * * @param series the series. */ public void remove(TaskSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } } /** * Removes a series from the collection and sends * a {@link org.jfree.data.general.DatasetChangeEvent} * to all registered listeners. * * @param series the series (zero based index). */ public void remove(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException( "TaskSeriesCollection.remove(): index outside valid range."); } // fetch the series, remove the change listener, then remove the series. TaskSeries ts = (TaskSeries) this.data.get(series); ts.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } /** * Removes all the series from the collection and sends * a {@link org.jfree.data.general.DatasetChangeEvent} * to all registered listeners. */ public void removeAll() { // deregister the collection as a change listener to each series in // the collection. Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TaskSeries series = (TaskSeries) iterator.next(); series.removeChangeListener(this); } // remove all the series from the collection and notify listeners. this.data.clear(); fireDatasetChanged(); } /** * Returns the value for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The item value. */ public Number getValue(Comparable rowKey, Comparable columnKey) { return getStartValue(rowKey, columnKey); } /** * Returns the value for a task. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The start value. */ public Number getValue(int row, int column) { return getStartValue(row, column); } /** * Returns the start value for a task. This is a date/time value, measured * in milliseconds since 1-Jan-1970. * * @param rowKey the series. * @param columnKey the category. * * @return The start value (possibly null). */ public Number getStartValue(Comparable rowKey, Comparable columnKey) { Number result = null; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { TimePeriod duration = task.getDuration(); if (duration != null) { result = new Long(duration.getStart().getTime()); } } return result; } /** * Returns the start value for a task. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The start value. */ public Number getStartValue(int row, int column) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getStartValue(rowKey, columnKey); } /** * Returns the end value for a task. This is a date/time value, measured * in milliseconds since 1-Jan-1970. * * @param rowKey the series. * @param columnKey the category. * * @return The end value (possibly null). */ public Number getEndValue(Comparable rowKey, Comparable columnKey) { Number result = null; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { TimePeriod duration = task.getDuration(); if (duration != null) { result = new Long(duration.getEnd().getTime()); } } return result; } /** * Returns the end value for a task. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The end value. */ public Number getEndValue(int row, int column) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getEndValue(rowKey, columnKey); } /** * Returns the percent complete for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The percent complete (possibly null). */ public Number getPercentComplete(int row, int column) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getPercentComplete(rowKey, columnKey); } /** * Returns the percent complete for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The percent complete. */ public Number getPercentComplete(Comparable rowKey, Comparable columnKey) { Number result = null; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { result = task.getPercentComplete(); } return result; } /** * Returns the number of sub-intervals for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The sub-interval count. */ public int getSubIntervalCount(int row, int column) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getSubIntervalCount(rowKey, columnKey); } /** * Returns the number of sub-intervals for a given item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The sub-interval count. */ public int getSubIntervalCount(Comparable rowKey, Comparable columnKey) { int result = 0; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { result = task.getSubtaskCount(); } return result; } /** * Returns the start value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval index (zero-based). * * @return The start value (possibly null). */ public Number getStartValue(int row, int column, int subinterval) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getStartValue(rowKey, columnKey, subinterval); } /** * Returns the start value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the subinterval. * * @return The start value (possibly null). */ public Number getStartValue(Comparable rowKey, Comparable columnKey, int subinterval) { Number result = null; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { Task sub = task.getSubtask(subinterval); if (sub != null) { TimePeriod duration = sub.getDuration(); result = new Long(duration.getStart().getTime()); } } return result; } /** * Returns the end value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the subinterval. * * @return The end value (possibly null). */ public Number getEndValue(int row, int column, int subinterval) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getEndValue(rowKey, columnKey, subinterval); } /** * Returns the end value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the subinterval. * * @return The end value (possibly null). */ public Number getEndValue(Comparable rowKey, Comparable columnKey, int subinterval) { Number result = null; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { Task sub = task.getSubtask(subinterval); if (sub != null) { TimePeriod duration = sub.getDuration(); result = new Long(duration.getEnd().getTime()); } } return result; } /** * Returns the percentage complete value of a sub-interval for a given item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * @param subinterval the sub-interval. * * @return The percent complete value (possibly null). */ public Number getPercentComplete(int row, int column, int subinterval) { Comparable rowKey = getRowKey(row); Comparable columnKey = getColumnKey(column); return getPercentComplete(rowKey, columnKey, subinterval); } /** * Returns the percentage complete value of a sub-interval for a given item. * * @param rowKey the row key. * @param columnKey the column key. * @param subinterval the sub-interval. * * @return The percent complete value (possibly null). */ public Number getPercentComplete(Comparable rowKey, Comparable columnKey, int subinterval) { Number result = null; int row = getRowIndex(rowKey); TaskSeries series = (TaskSeries) this.data.get(row); Task task = series.get(columnKey.toString()); if (task != null) { Task sub = task.getSubtask(subinterval); if (sub != null) { result = sub.getPercentComplete(); } } return result; } /** * Called when a series belonging to the dataset changes. * * @param event information about the change. */ public void seriesChanged(SeriesChangeEvent event) { refreshKeys(); fireDatasetChanged(); } /** * Refreshes the keys. */ private void refreshKeys() { this.keys.clear(); for (int i = 0; i < getSeriesCount(); i++) { TaskSeries series = (TaskSeries) this.data.get(i); // look for any keys that we don't already know about... Iterator iterator = series.getTasks().iterator(); while (iterator.hasNext()) { Task task = (Task) iterator.next(); String key = task.getDescription(); int index = this.keys.indexOf(key); if (index < 0) { this.keys.add(key); } } } } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TaskSeriesCollection)) { return false; } TaskSeriesCollection that = (TaskSeriesCollection) obj; if (!ObjectUtilities.equal(this.data, that.data)) { return false; } return true; } /** * Returns an independent copy of this dataset. * * @return A clone of the dataset. * * @throws CloneNotSupportedException if there is some problem cloning * the dataset. */ public Object clone() throws CloneNotSupportedException { TaskSeriesCollection clone = (TaskSeriesCollection) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); clone.keys = new java.util.ArrayList(this.keys); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/XYTaskDataset.java0000644000175000017500000003342011173030414026714 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * XYTaskDataset.java * ------------------ * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Sep-2008 : Version 1 (DG); * */ package org.jfree.data.gantt; import java.util.Date; import org.jfree.chart.axis.SymbolAxis; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.time.TimePeriod; import org.jfree.data.xy.AbstractXYDataset; import org.jfree.data.xy.IntervalXYDataset; /** * A dataset implementation that wraps a {@link TaskSeriesCollection} and * presents it as an {@link IntervalXYDataset}, allowing a set of tasks to * be displayed using an {@link XYBarRenderer} (and usually a * {@link SymbolAxis}). This is a very specialised dataset implementation * ---before using it, you should take some time to understand the use-cases * that it is designed for. * * @since 1.0.11 */ public class XYTaskDataset extends AbstractXYDataset implements IntervalXYDataset, DatasetChangeListener { /** The underlying tasks. */ private TaskSeriesCollection underlying; /** The series interval width (typically 0.0 < w <= 1.0). */ private double seriesWidth; /** A flag that controls whether or not the data values are transposed. */ private boolean transposed; /** * Creates a new dataset based on the supplied collection of tasks. * * @param tasks the underlying dataset (null not permitted). */ public XYTaskDataset(TaskSeriesCollection tasks) { if (tasks == null) { throw new IllegalArgumentException("Null 'tasks' argument."); } this.underlying = tasks; this.seriesWidth = 0.8; this.underlying.addChangeListener(this); } /** * Returns the underlying task series collection that was supplied to the * constructor. * * @return The underlying collection (never null). */ public TaskSeriesCollection getTasks() { return this.underlying; } /** * Returns the width of the interval for each series this dataset. * * @return The width of the series interval. * * @see #setSeriesWidth(double) */ public double getSeriesWidth() { return this.seriesWidth; } /** * Sets the series interval width and sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param w the width. * * @see #getSeriesWidth() */ public void setSeriesWidth(double w) { if (w <= 0.0) { throw new IllegalArgumentException("Requires 'w' > 0.0."); } this.seriesWidth = w; fireDatasetChanged(); } /** * Returns a flag that indicates whether or not the dataset is transposed. * The default is false which means the x-values are integers * corresponding to the series indices, and the y-values are millisecond * values corresponding to the task date/time intervals. If the flag * is set to true, the x and y-values are reversed. * * @return The flag. * * @see #setTransposed(boolean) */ public boolean isTransposed() { return this.transposed; } /** * Sets the flag that controls whether or not the dataset is transposed * and sends a {@link DatasetChangeEvent} to all registered listeners. * * @param transposed the new flag value. * * @see #isTransposed() */ public void setTransposed(boolean transposed) { this.transposed = transposed; fireDatasetChanged(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.underlying.getSeriesCount(); } /** * Returns the name of a series. * * @param series the series index (zero-based). * * @return The name of a series. */ public Comparable getSeriesKey(int series) { return this.underlying.getSeriesKey(series); } /** * Returns the number of items (tasks) in the specified series. * * @param series the series index (zero-based). * * @return The item count. */ public int getItemCount(int series) { return this.underlying.getSeries(series).getItemCount(); } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getXValue(int series, int item) { if (!this.transposed) { return getSeriesValue(series); } else { return getItemValue(series, item); } } /** * Returns the starting date/time for the specified item (task) in the * given series, measured in milliseconds since 1-Jan-1970 (as in * java.util.Date). * * @param series the series index. * @param item the item (or task) index. * * @return The start date/time. */ public double getStartXValue(int series, int item) { if (!this.transposed) { return getSeriesStartValue(series); } else { return getItemStartValue(series, item); } } /** * Returns the ending date/time for the specified item (task) in the * given series, measured in milliseconds since 1-Jan-1970 (as in * java.util.Date). * * @param series the series index. * @param item the item (or task) index. * * @return The end date/time. */ public double getEndXValue(int series, int item) { if (!this.transposed) { return getSeriesEndValue(series); } else { return getItemEndValue(series, item); } } /** * Returns the x-value for the specified series. * * @param series the series index. * @param item the item index. * * @return The x-value (in milliseconds). */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the starting date/time for the specified item (task) in the * given series, measured in milliseconds since 1-Jan-1970 (as in * java.util.Date). * * @param series the series index. * @param item the item (or task) index. * * @return The start date/time. */ public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); } /** * Returns the ending date/time for the specified item (task) in the * given series, measured in milliseconds since 1-Jan-1970 (as in * java.util.Date). * * @param series the series index. * @param item the item (or task) index. * * @return The end date/time. */ public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); } /** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getYValue(int series, int item) { if (!this.transposed) { return getItemValue(series, item); } else { return getSeriesValue(series); } } /** * Returns the starting value of the y-interval for an item in the * given series. * * @param series the series index. * @param item the item (or task) index. * * @return The y-interval start. */ public double getStartYValue(int series, int item) { if (!this.transposed) { return getItemStartValue(series, item); } else { return getSeriesStartValue(series); } } /** * Returns the ending value of the y-interval for an item in the * given series. * * @param series the series index. * @param item the item (or task) index. * * @return The y-interval end. */ public double getEndYValue(int series, int item) { if (!this.transposed) { return getItemEndValue(series, item); } else { return getSeriesEndValue(series); } } /** * Returns the y-value for the specified series/item. In this * implementation, we return the series index as the y-value (this means * that every item in the series has a constant integer value). * * @param series the series index. * @param item the item index. * * @return The y-value. */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Returns the starting value of the y-interval for an item in the * given series. * * @param series the series index. * @param item the item (or task) index. * * @return The y-interval start. */ public Number getStartY(int series, int item) { return new Double(getStartYValue(series, item)); } /** * Returns the ending value of the y-interval for an item in the * given series. * * @param series the series index. * @param item the item (or task) index. * * @return The y-interval end. */ public Number getEndY(int series, int item) { return new Double(getEndYValue(series, item)); } private double getSeriesValue(int series) { return series; } private double getSeriesStartValue(int series) { return series - this.seriesWidth / 2.0; } private double getSeriesEndValue(int series) { return series + this.seriesWidth / 2.0; } private double getItemValue(int series, int item) { TaskSeries s = this.underlying.getSeries(series); Task t = s.get(item); TimePeriod duration = t.getDuration(); Date start = duration.getStart(); Date end = duration.getEnd(); return (start.getTime() + end.getTime()) / 2.0; } private double getItemStartValue(int series, int item) { TaskSeries s = this.underlying.getSeries(series); Task t = s.get(item); TimePeriod duration = t.getDuration(); Date start = duration.getStart(); return start.getTime(); } private double getItemEndValue(int series, int item) { TaskSeries s = this.underlying.getSeries(series); Task t = s.get(item); TimePeriod duration = t.getDuration(); Date end = duration.getEnd(); return end.getTime(); } /** * Receives a change event from the underlying dataset and responds by * firing a change event for this dataset. * * @param event the event. */ public void datasetChanged(DatasetChangeEvent event) { fireDatasetChanged(); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYTaskDataset)) { return false; } XYTaskDataset that = (XYTaskDataset) obj; if (this.seriesWidth != that.seriesWidth) { return false; } if (this.transposed != that.transposed) { return false; } if (!this.underlying.equals(that.underlying)) { return false; } return true; } /** * Returns a clone of this dataset. * * @return A clone of this dataset. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { XYTaskDataset clone = (XYTaskDataset) super.clone(); clone.underlying = (TaskSeriesCollection) this.underlying.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/gantt/package.html0000644000175000017500000000023211173030414025634 0ustar vincentvincent Data interfaces and classes for Gantt charts. libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/0000755000175000017500000000000011216245562023670 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/general/AbstractDataset.java0000644000175000017500000002205311173030414027574 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * AbstractDataset.java * -------------------- * (C)opyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu (for Astrium and EADS Corporate Research * Center); * * Changes (from 21-Aug-2001) * -------------------------- * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); * 18-Sep-2001 : Updated e-mail address in header (DG); * 15-Oct-2001 : Moved to new package (com.jrefinery.data.*) (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 17-Nov-2001 : Changed constructor from public to protected, created new * AbstractSeriesDataset class and transferred series-related * methods, updated Javadoc comments (DG); * 04-Mar-2002 : Updated import statements (DG); * 11-Jun-2002 : Updated for change in the event constructor (DG); * 07-Aug-2002 : Changed listener list to use * javax.swing.event.EventListenerList (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 27-Mar-2003 : Implemented Serializable (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * 08-Sep-2003 : Serialization fixes (NB); * 11-Sep-2003 : Cloning Fixes (NB); * 01-Jun-2005 : Added hasListener() method for unit testing (DG); * */ package org.jfree.data.general; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectInputValidation; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Arrays; import java.util.EventListener; import java.util.List; import javax.swing.event.EventListenerList; /** * An abstract implementation of the {@link Dataset} interface, containing a * mechanism for registering change listeners. */ public abstract class AbstractDataset implements Dataset, Cloneable, Serializable, ObjectInputValidation { /** For serialization. */ private static final long serialVersionUID = 1918768939869230744L; /** The group that the dataset belongs to. */ private DatasetGroup group; /** Storage for registered change listeners. */ private transient EventListenerList listenerList; /** * Constructs a dataset. By default, the dataset is assigned to its own * group. */ protected AbstractDataset() { this.group = new DatasetGroup(); this.listenerList = new EventListenerList(); } /** * Returns the dataset group for the dataset. * * @return The group (never null). * * @see #setGroup(DatasetGroup) */ public DatasetGroup getGroup() { return this.group; } /** * Sets the dataset group for the dataset. * * @param group the group (null not permitted). * * @see #getGroup() */ public void setGroup(DatasetGroup group) { if (group == null) { throw new IllegalArgumentException("Null 'group' argument."); } this.group = group; } /** * Registers an object to receive notification of changes to the dataset. * * @param listener the object to register. * * @see #removeChangeListener(DatasetChangeListener) */ public void addChangeListener(DatasetChangeListener listener) { this.listenerList.add(DatasetChangeListener.class, listener); } /** * Deregisters an object so that it no longer receives notification of * changes to the dataset. * * @param listener the object to deregister. * * @see #addChangeListener(DatasetChangeListener) */ public void removeChangeListener(DatasetChangeListener listener) { this.listenerList.remove(DatasetChangeListener.class, listener); } /** * Returns true if the specified object is registered with * the dataset as a listener. Most applications won't need to call this * method, it exists mainly for use by unit testing code. * * @param listener the listener. * * @return A boolean. * * @see #addChangeListener(DatasetChangeListener) * @see #removeChangeListener(DatasetChangeListener) */ public boolean hasListener(EventListener listener) { List list = Arrays.asList(this.listenerList.getListenerList()); return list.contains(listener); } /** * Notifies all registered listeners that the dataset has changed. * * @see #addChangeListener(DatasetChangeListener) */ protected void fireDatasetChanged() { notifyListeners(new DatasetChangeEvent(this, this)); } /** * Notifies all registered listeners that the dataset has changed. * * @param event contains information about the event that triggered the * notification. * * @see #addChangeListener(DatasetChangeListener) * @see #removeChangeListener(DatasetChangeListener) */ protected void notifyListeners(DatasetChangeEvent event) { Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == DatasetChangeListener.class) { ((DatasetChangeListener) listeners[i + 1]).datasetChanged( event); } } } /** * Returns a clone of the dataset. The cloned dataset will NOT include the * {@link DatasetChangeListener} references that have been registered with * this dataset. * * @return A clone. * * @throws CloneNotSupportedException if the dataset does not support * cloning. */ public Object clone() throws CloneNotSupportedException { AbstractDataset clone = (AbstractDataset) super.clone(); clone.listenerList = new EventListenerList(); return clone; } /** * Handles serialization. * * @param stream the output stream. * * @throws IOException if there is an I/O problem. */ private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); } /** * Restores a serialized object. * * @param stream the input stream. * * @throws IOException if there is an I/O problem. * @throws ClassNotFoundException if there is a problem loading a class. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.listenerList = new EventListenerList(); stream.registerValidation(this, 10); // see comments about priority of // 10 in validateObject() } /** * Validates the object. We use this opportunity to call listeners who have * registered during the deserialization process, as listeners are not * serialized. This method is called by the serialization system after the * entire graph is read. * * This object has registered itself to the system with a priority of 10. * Other callbacks may register with a higher priority number to be called * before this object, or with a lower priority number to be called after * the listeners were notified. * * All listeners are supposed to have register by now, either in their * readObject or validateObject methods. Notify them that this dataset has * changed. * * @exception InvalidObjectException If the object cannot validate itself. */ public void validateObject() throws InvalidObjectException { fireDatasetChanged(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/AbstractSeriesDataset.java0000644000175000017500000000720211173030414030746 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * AbstractSeriesDataset.java * -------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Nov-2001 : Version 1 (DG); * 28-Mar-2002 : Implemented SeriesChangeListener interface (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 04-Feb-2003 : Removed redundant methods (DG); * 27-Mar-2003 : Implemented Serializable (DG); * */ package org.jfree.data.general; import java.io.Serializable; /** * An abstract implementation of the {@link SeriesDataset} interface, * containing a mechanism for registering change listeners. */ public abstract class AbstractSeriesDataset extends AbstractDataset implements SeriesDataset, SeriesChangeListener, Serializable { /** For serialization. */ private static final long serialVersionUID = -6074996219705033171L; /** * Creates a new dataset. */ protected AbstractSeriesDataset() { super(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public abstract int getSeriesCount(); /** * Returns the key for a series. *

* If series is not within the specified range, the * implementing method should throw an {@link IndexOutOfBoundsException} * (preferred) or an {@link IllegalArgumentException}. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The series key. */ public abstract Comparable getSeriesKey(int series); /** * Returns the index of the named series, or -1. * * @param seriesKey the series key (null permitted). * * @return The index. */ public int indexOf(Comparable seriesKey) { int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { if (getSeriesKey(s).equals(seriesKey)) { return s; } } return -1; } /** * Called when a series belonging to the dataset changes. * * @param event information about the change. */ public void seriesChanged(SeriesChangeEvent event) { fireDatasetChanged(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/CombinationDataset.java0000644000175000017500000000523711173030414030300 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * CombinationDataset.java * ----------------------- * (C) Copyright 2001-2009, by Bill Kelemen. * * Original Author: Bill Kelemen; * Contributor(s): -; * * Changes * ------- * 06-Dec-2001 : Version 1 (BK); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.data.general; /** * Interface that describes the new methods that any combined dataset needs to * implement. A combined dataset object will combine one or more datasets and * expose a sub-set or union of the combined datasets. * * @deprecated 1.0.13 */ public interface CombinationDataset { /////////////////////////////////////////////////////////////////////////// // New methods from CombinationDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the parent Dataset of this combination. If there is more than * one parent, or a child is found that is not a combination, then returns * null. * * @return The parent Dataset of this combination. */ public SeriesDataset getParent(); /** * Returns a map or indirect indexing form our series into parent's series. * * @return A map or indirect indexing form our series into parent's series. */ public int[] getMap(); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/CombinedDataset.java0000644000175000017500000005140511173030414027554 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * CombinedDataset.java * -------------------- * (C) Copyright 2001-2009, by Bill Kelemen and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 06-Dec-2001 : Version 1 (BK); * 27-Dec-2001 : Fixed bug in getChildPosition method (BK); * 29-Dec-2001 : Fixed bug in getChildPosition method with complex * CombinePlot (BK); * 05-Feb-2002 : Small addition to the interface HighLowDataset, as requested * by Sylvain Vieujot (DG); * 14-Feb-2002 : Added bug fix for IntervalXYDataset methods, submitted by * Gyula Kun-Szabo (DG); * 11-Jun-2002 : Updated for change in event constructor (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 06-May-2004 : Now extends AbstractIntervalXYDataset and added other methods * that return double primitives (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 04-Feb-2009 : Deprecated the class (DG); * */ package org.jfree.data.general; import java.util.List; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; /** * This class can combine instances of {@link XYDataset}, {@link OHLCDataset} * and {@link IntervalXYDataset} together exposing the union of all the series * under one dataset. * * @deprecated As of version 1.0.13. This class will be removed from * JFreeChart 1.2.0 onwards. Anyone needing this facility will need to * maintain it outside of JFreeChart. */ public class CombinedDataset extends AbstractIntervalXYDataset implements XYDataset, OHLCDataset, IntervalXYDataset, CombinationDataset { /** Storage for the datasets we combine. */ private List datasetInfo = new java.util.ArrayList(); /** * Default constructor for an empty combination. */ public CombinedDataset() { super(); } /** * Creates a CombinedDataset initialized with an array of SeriesDatasets. * * @param data array of SeriesDataset that contains the SeriesDatasets to * combine. */ public CombinedDataset(SeriesDataset[] data) { add(data); } /** * Adds one SeriesDataset to the combination. Listeners are notified of the * change. * * @param data the SeriesDataset to add. */ public void add(SeriesDataset data) { fastAdd(data); DatasetChangeEvent event = new DatasetChangeEvent(this, this); notifyListeners(event); } /** * Adds an array of SeriesDataset's to the combination. Listeners are * notified of the change. * * @param data array of SeriesDataset to add */ public void add(SeriesDataset[] data) { for (int i = 0; i < data.length; i++) { fastAdd(data[i]); } DatasetChangeEvent event = new DatasetChangeEvent(this, this); notifyListeners(event); } /** * Adds one series from a SeriesDataset to the combination. Listeners are * notified of the change. * * @param data the SeriesDataset where series is contained * @param series series to add */ public void add(SeriesDataset data, int series) { add(new SubSeriesDataset(data, series)); } /** * Fast add of a SeriesDataset. Does not notify listeners of the change. * * @param data SeriesDataset to add */ private void fastAdd(SeriesDataset data) { for (int i = 0; i < data.getSeriesCount(); i++) { this.datasetInfo.add(new DatasetInfo(data, i)); } } /////////////////////////////////////////////////////////////////////////// // From SeriesDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the number of series in the dataset. * * @return The number of series in the dataset. */ public int getSeriesCount() { return this.datasetInfo.size(); } /** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { DatasetInfo di = getDatasetInfo(series); return di.data.getSeriesKey(di.series); } /////////////////////////////////////////////////////////////////////////// // From XYDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the X-value for the specified series and item. *

* Note: throws ClassCastException if the series is not from * a {@link XYDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The X-value for the specified series and item. */ public Number getX(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((XYDataset) di.data).getX(di.series, item); } /** * Returns the Y-value for the specified series and item. *

* Note: throws ClassCastException if the series is not from * a {@link XYDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The Y-value for the specified series and item. */ public Number getY(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((XYDataset) di.data).getY(di.series, item); } /** * Returns the number of items in a series. *

* Note: throws ClassCastException if the series is not from * a {@link XYDataset}. * * @param series the index of the series of interest (zero-based). * * @return The number of items in a series. */ public int getItemCount(int series) { DatasetInfo di = getDatasetInfo(series); return ((XYDataset) di.data).getItemCount(di.series); } /////////////////////////////////////////////////////////////////////////// // From HighLowDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the high-value for the specified series and item. *

* Note: throws ClassCastException if the series is not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The high-value for the specified series and item. */ public Number getHigh(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((OHLCDataset) di.data).getHigh(di.series, item); } /** * Returns the high-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. */ public double getHighValue(int series, int item) { double result = Double.NaN; Number high = getHigh(series, item); if (high != null) { result = high.doubleValue(); } return result; } /** * Returns the low-value for the specified series and item. *

* Note: throws ClassCastException if the series is not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The low-value for the specified series and item. */ public Number getLow(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((OHLCDataset) di.data).getLow(di.series, item); } /** * Returns the low-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. */ public double getLowValue(int series, int item) { double result = Double.NaN; Number low = getLow(series, item); if (low != null) { result = low.doubleValue(); } return result; } /** * Returns the open-value for the specified series and item. *

* Note: throws ClassCastException if the series is not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The open-value for the specified series and item. */ public Number getOpen(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((OHLCDataset) di.data).getOpen(di.series, item); } /** * Returns the open-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The open-value. */ public double getOpenValue(int series, int item) { double result = Double.NaN; Number open = getOpen(series, item); if (open != null) { result = open.doubleValue(); } return result; } /** * Returns the close-value for the specified series and item. *

* Note: throws ClassCastException if the series is not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The close-value for the specified series and item. */ public Number getClose(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((OHLCDataset) di.data).getClose(di.series, item); } /** * Returns the close-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. */ public double getCloseValue(int series, int item) { double result = Double.NaN; Number close = getClose(series, item); if (close != null) { result = close.doubleValue(); } return result; } /** * Returns the volume value for the specified series and item. *

* Note: throws ClassCastException if the series is not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The volume value for the specified series and item. */ public Number getVolume(int series, int item) { DatasetInfo di = getDatasetInfo(series); return ((OHLCDataset) di.data).getVolume(di.series, item); } /** * Returns the volume-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The volume-value. */ public double getVolumeValue(int series, int item) { double result = Double.NaN; Number volume = getVolume(series, item); if (volume != null) { result = volume.doubleValue(); } return result; } /////////////////////////////////////////////////////////////////////////// // From IntervalXYDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the starting X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The value. */ public Number getStartX(int series, int item) { DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getStartX(di.series, item); } else { return getX(series, item); } } /** * Returns the ending X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The value. */ public Number getEndX(int series, int item) { DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getEndX(di.series, item); } else { return getX(series, item); } } /** * Returns the starting Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The starting Y value for the specified series and item. */ public Number getStartY(int series, int item) { DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getStartY(di.series, item); } else { return getY(series, item); } } /** * Returns the ending Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The ending Y value for the specified series and item. */ public Number getEndY(int series, int item) { DatasetInfo di = getDatasetInfo(series); if (di.data instanceof IntervalXYDataset) { return ((IntervalXYDataset) di.data).getEndY(di.series, item); } else { return getY(series, item); } } /////////////////////////////////////////////////////////////////////////// // New methods from CombinationDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the parent Dataset of this combination. If there is more than * one parent, or a child is found that is not a CombinationDataset, then * returns null. * * @return The parent Dataset of this combination or null. */ public SeriesDataset getParent() { SeriesDataset parent = null; for (int i = 0; i < this.datasetInfo.size(); i++) { SeriesDataset child = getDatasetInfo(i).data; if (child instanceof CombinationDataset) { SeriesDataset childParent = ((CombinationDataset) child).getParent(); if (parent == null) { parent = childParent; } else if (parent != childParent) { return null; } } else { return null; } } return parent; } /** * Returns a map or indirect indexing form our series into parent's series. * Prior to calling this method, the client should check getParent() to make * sure the CombinationDataset uses the same parent. If not, the map * returned by this method will be invalid or null. * * @return A map or indirect indexing form our series into parent's series. * * @see #getParent() */ public int[] getMap() { int[] map = null; for (int i = 0; i < this.datasetInfo.size(); i++) { SeriesDataset child = getDatasetInfo(i).data; if (child instanceof CombinationDataset) { int[] childMap = ((CombinationDataset) child).getMap(); if (childMap == null) { return null; } map = joinMap(map, childMap); } else { return null; } } return map; } /////////////////////////////////////////////////////////////////////////// // New Methods /////////////////////////////////////////////////////////////////////////// /** * Returns the child position. * * @param child the child dataset. * * @return The position. */ public int getChildPosition(Dataset child) { int n = 0; for (int i = 0; i < this.datasetInfo.size(); i++) { SeriesDataset childDataset = getDatasetInfo(i).data; if (childDataset instanceof CombinedDataset) { int m = ((CombinedDataset) childDataset) .getChildPosition(child); if (m >= 0) { return n + m; } n++; } else { if (child == childDataset) { return n; } n++; } } return -1; } /////////////////////////////////////////////////////////////////////////// // Private /////////////////////////////////////////////////////////////////////////// /** * Returns the DatasetInfo object associated with the series. * * @param series the index of the series. * * @return The DatasetInfo object associated with the series. */ private DatasetInfo getDatasetInfo(int series) { return (DatasetInfo) this.datasetInfo.get(series); } /** * Joins two map arrays (int[]) together. * * @param a the first array. * @param b the second array. * * @return A copy of { a[], b[] }. */ private int[] joinMap(int[] a, int[] b) { if (a == null) { return b; } if (b == null) { return a; } int[] result = new int[a.length + b.length]; System.arraycopy(a, 0, result, 0, a.length); System.arraycopy(b, 0, result, a.length, b.length); return result; } /** * Private class to store as pairs (SeriesDataset, series) for all combined * series. */ private class DatasetInfo { /** The dataset. */ private SeriesDataset data; /** The series. */ private int series; /** * Creates a new dataset info record. * * @param data the dataset. * @param series the series. */ DatasetInfo(SeriesDataset data, int series) { this.data = data; this.series = series; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/Dataset.java0000644000175000017500000000653111173030414026113 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * Dataset.java * ------------ * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 15-Oct-2001 : Moved to a new package (com.jrefinery.data.*) (DG); * 22-Oct-2001 : Changed name to Dataset.java (DG); * 17-Nov-2001 : Added getLegendItemCount() and getLegendItemLabels() methods, * created SeriesDataset interface and transferred series related * methods out (DG); * 22-Jan-2002 : Reconsidered (and removed) the getLegendItemCount() and * getLegendItemLabels() methods...leave this to client code (DG); * 27-Sep-2002 : Added get/setDatasetGroup() methods (DG); * 10-Jan-2003 : Updated Javadocs (DG); * */ package org.jfree.data.general; /** * The base interface for data sets. *

* All datasets are required to support the {@link DatasetChangeEvent} * mechanism by allowing listeners to register and receive notification of any * changes to the dataset. *

* In addition, all datasets must belong to one (and only one) * {@link DatasetGroup}. The group object maintains a reader-writer lock * which provides synchronised access to the datasets in multi-threaded code. */ public interface Dataset { /** * Registers an object for notification of changes to the dataset. * * @param listener the object to register. */ public void addChangeListener(DatasetChangeListener listener); /** * Deregisters an object for notification of changes to the dataset. * * @param listener the object to deregister. */ public void removeChangeListener(DatasetChangeListener listener); /** * Returns the dataset group. * * @return The dataset group. */ public DatasetGroup getGroup(); /** * Sets the dataset group. * * @param group the dataset group. */ public void setGroup(DatasetGroup group); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DatasetChangeEvent.java0000644000175000017500000000633311173030414030223 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DatasetChangeEvent.java * ----------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 15-Oct-2001 : Move to new package (com.jrefinery.data.*) (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 11-Jun-2002 : Separated the event source from the dataset to cover the case * where the dataset is changed to null in the Plot class. * Updated Javadocs (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 05-Oct-2004 : Minor Javadoc updates (DG); * */ package org.jfree.data.general; /** * A change event that encapsulates information about a change to a dataset. */ public class DatasetChangeEvent extends java.util.EventObject { /** * The dataset that generated the change event. */ private Dataset dataset; /** * Constructs a new event. The source is either the dataset or the * {@link org.jfree.chart.plot.Plot} class. The dataset can be * null (in this case the source will be the * {@link org.jfree.chart.plot.Plot} class). * * @param source the source of the event. * @param dataset the dataset that generated the event (null * permitted). */ public DatasetChangeEvent(Object source, Dataset dataset) { super(source); this.dataset = dataset; } /** * Returns the dataset that generated the event. Note that the dataset * may be null since adding a null dataset to a * plot will generated a change event. * * @return The dataset (possibly null). */ public Dataset getDataset() { return this.dataset; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DatasetChangeListener.java0000644000175000017500000000444411173030414030730 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DatasetChangeListener.java * -------------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 15-Oct-2001 : Moved to new package (com.jrefinery.data.*) (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 07-Aug-2002 : Now extends EventListener (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.data.general; import java.util.EventListener; /** * The interface that must be supported by classes that wish to receive * notification of changes to a dataset. */ public interface DatasetChangeListener extends EventListener { /** * Receives notification of an dataset change event. * * @param event information about the event. */ public void datasetChanged(DatasetChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DatasetGroup.java0000644000175000017500000000655411173030414027135 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * DatasetGroup.java * ----------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Oct-2002 : Version 1 (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 20-Aug-2003 : Implemented Cloneable (DG); * */ package org.jfree.data.general; import java.io.Serializable; /** * A class that is used to group datasets (currently not used for any specific * purpose). */ public class DatasetGroup implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3640642179674185688L; /** The group id. */ private String id; /** * Constructs a new group. */ public DatasetGroup() { super(); this.id = "NOID"; } /** * Creates a new group with the specified id. * * @param id the identification for the group. */ public DatasetGroup(String id) { if (id == null) { throw new IllegalArgumentException("Null 'id' argument."); } this.id = id; } /** * Returns the identification string for this group. * * @return The identification string. */ public String getID() { return this.id; } /** * Clones the group. * * @return A clone. * * @throws CloneNotSupportedException not by this class. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DatasetGroup)) { return false; } DatasetGroup that = (DatasetGroup) obj; if (!this.id.equals(that.id)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DatasetUtilities.java0000644000175000017500000024612311173030414030012 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DatasetUtilities.java * --------------------- * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrzej Porebski (bug fix); * Jonathan Nash (bug fix); * Richard Atkinson; * Andreas Schroeder; * Rafal Skalny (patch 1925366); * Jerome David (patch 2131001); * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 15-Nov-2001 : Moved to package com.jrefinery.data.* in the JCommon class * library (DG); * Changed to handle null values from datasets (DG); * Bug fix (thanks to Andrzej Porebski) - initial value now set * to positive or negative infinity when iterating (DG); * 22-Nov-2001 : Datasets with containing no data now return null for min and * max calculations (DG); * 13-Dec-2001 : Extended to handle HighLowDataset and IntervalXYDataset (DG); * 15-Feb-2002 : Added getMinimumStackedRangeValue() and * getMaximumStackedRangeValue() (DG); * 28-Feb-2002 : Renamed Datasets.java --> DatasetUtilities.java (DG); * 18-Mar-2002 : Fixed bug in min/max domain calculation for datasets that * implement the CategoryDataset interface AND the XYDataset * interface at the same time. Thanks to Jonathan Nash for the * fix (DG); * 23-Apr-2002 : Added getDomainExtent() and getRangeExtent() methods (DG); * 13-Jun-2002 : Modified range measurements to handle * IntervalCategoryDataset (DG); * 12-Jul-2002 : Method name change in DomainInfo interface (DG); * 30-Jul-2002 : Added pie dataset summation method (DG); * 01-Oct-2002 : Added a method for constructing an XYDataset from a Function2D * instance (DG); * 24-Oct-2002 : Amendments required following changes to the CategoryDataset * interface (DG); * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG); * 04-Mar-2003 : Added isEmpty(XYDataset) method (DG); * 05-Mar-2003 : Added a method for creating a CategoryDataset from a * KeyedValues instance (DG); * 15-May-2003 : Renamed isEmpty --> isEmptyOrNull (DG); * 25-Jun-2003 : Added limitPieDataset methods (RA); * 26-Jun-2003 : Modified getDomainExtent() method to accept null datasets (DG); * 27-Jul-2003 : Added getStackedRangeExtent(TableXYDataset data) (RA); * 18-Aug-2003 : getStackedRangeExtent(TableXYDataset data) now handles null * values (RA); * 02-Sep-2003 : Added method to check for null or empty PieDataset (DG); * 18-Sep-2003 : Fix for bug 803660 (getMaximumRangeValue for * CategoryDataset) (DG); * 20-Oct-2003 : Added getCumulativeRangeExtent() method (DG); * 09-Jan-2003 : Added argument checking code to the createCategoryDataset() * method (DG); * 23-Mar-2004 : Fixed bug in getMaximumStackedRangeValue() method (DG); * 31-Mar-2004 : Exposed the extent iteration algorithms to use one of them and * applied noninstantiation pattern (AS); * 11-May-2004 : Renamed getPieDatasetTotal --> calculatePieDatasetTotal (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with getYValue(); * 24-Aug-2004 : Added argument checks to createCategoryDataset() method (DG); * 04-Oct-2004 : Renamed ArrayUtils --> ArrayUtilities (DG); * 06-Oct-2004 : Renamed findDomainExtent() --> findDomainBounds(), * findRangeExtent() --> findRangeBounds() (DG); * 07-Jan-2005 : Renamed findStackedRangeExtent() --> findStackedRangeBounds(), * findCumulativeRangeExtent() --> findCumulativeRangeBounds(), * iterateXYRangeExtent() --> iterateXYRangeBounds(), * removed deprecated methods (DG); * 03-Feb-2005 : The findStackedRangeBounds() methods now return null for * empty datasets (DG); * 03-Mar-2005 : Moved createNumberArray() and createNumberArray2D() methods * from DatasetUtilities --> DataUtilities (DG); * 22-Sep-2005 : Added new findStackedRangeBounds() method that takes base * argument (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 15-Mar-2007 : Added calculateStackTotal() method (DG); * 27-Mar-2008 : Fixed bug in findCumulativeRangeBounds() method (DG); * 28-Mar-2008 : Fixed sample count in sampleFunction2D() method, renamed * iterateXYRangeBounds() --> iterateRangeBounds(XYDataset), and * fixed a bug in findRangeBounds(XYDataset, false) (DG); * 28-Mar-2008 : Applied a variation of patch 1925366 (from Rafal Skalny) for * slightly more efficient iterateRangeBounds() methods (DG); * 08-Apr-2008 : Fixed typo in iterateRangeBounds() (DG); * 08-Oct-2008 : Applied patch 2131001 by Jerome David, with some modifications * and additions and some new unit tests (DG); * 12-Feb-2009 : Added sampleFunction2DToSeries() method (DG); * 27-Mar-2009 : Added new methods to find domain and range bounds taking into * account hidden series (DG); * 01-Apr-2009 : Handle a StatisticalCategoryDataset in * iterateToFindRangeBounds() (DG); * */ package org.jfree.data.general; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.jfree.data.DomainInfo; import org.jfree.data.KeyToGroupMap; import org.jfree.data.KeyedValues; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.CategoryRangeInfo; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.data.function.Function2D; import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; import org.jfree.data.statistics.BoxAndWhiskerXYDataset; import org.jfree.data.statistics.StatisticalCategoryDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYDomainInfo; import org.jfree.data.xy.XYRangeInfo; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.ArrayUtilities; /** * A collection of useful static methods relating to datasets. */ public final class DatasetUtilities { /** * Private constructor for non-instanceability. */ private DatasetUtilities() { // now try to instantiate this ;-) } /** * Calculates the total of all the values in a {@link PieDataset}. If * the dataset contains negative or null values, they are * ignored. * * @param dataset the dataset (null not permitted). * * @return The total. */ public static double calculatePieDatasetTotal(PieDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } List keys = dataset.getKeys(); double totalValue = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable current = (Comparable) iterator.next(); if (current != null) { Number value = dataset.getValue(current); double v = 0.0; if (value != null) { v = value.doubleValue(); } if (v > 0) { totalValue = totalValue + v; } } } return totalValue; } /** * Creates a pie dataset from a table dataset by taking all the values * for a single row. * * @param dataset the dataset (null not permitted). * @param rowKey the row key. * * @return A pie dataset. */ public static PieDataset createPieDatasetForRow(CategoryDataset dataset, Comparable rowKey) { int row = dataset.getRowIndex(rowKey); return createPieDatasetForRow(dataset, row); } /** * Creates a pie dataset from a table dataset by taking all the values * for a single row. * * @param dataset the dataset (null not permitted). * @param row the row (zero-based index). * * @return A pie dataset. */ public static PieDataset createPieDatasetForRow(CategoryDataset dataset, int row) { DefaultPieDataset result = new DefaultPieDataset(); int columnCount = dataset.getColumnCount(); for (int current = 0; current < columnCount; current++) { Comparable columnKey = dataset.getColumnKey(current); result.setValue(columnKey, dataset.getValue(row, current)); } return result; } /** * Creates a pie dataset from a table dataset by taking all the values * for a single column. * * @param dataset the dataset (null not permitted). * @param columnKey the column key. * * @return A pie dataset. */ public static PieDataset createPieDatasetForColumn(CategoryDataset dataset, Comparable columnKey) { int column = dataset.getColumnIndex(columnKey); return createPieDatasetForColumn(dataset, column); } /** * Creates a pie dataset from a {@link CategoryDataset} by taking all the * values for a single column. * * @param dataset the dataset (null not permitted). * @param column the column (zero-based index). * * @return A pie dataset. */ public static PieDataset createPieDatasetForColumn(CategoryDataset dataset, int column) { DefaultPieDataset result = new DefaultPieDataset(); int rowCount = dataset.getRowCount(); for (int i = 0; i < rowCount; i++) { Comparable rowKey = dataset.getRowKey(i); result.setValue(rowKey, dataset.getValue(i, column)); } return result; } /** * Creates a new pie dataset based on the supplied dataset, but modified * by aggregating all the low value items (those whose value is lower * than the percentThreshold) into a single item with the * key "Other". * * @param source the source dataset (null not permitted). * @param key a new key for the aggregated items (null not * permitted). * @param minimumPercent the percent threshold. * * @return The pie dataset with (possibly) aggregated items. */ public static PieDataset createConsolidatedPieDataset(PieDataset source, Comparable key, double minimumPercent) { return DatasetUtilities.createConsolidatedPieDataset(source, key, minimumPercent, 2); } /** * Creates a new pie dataset based on the supplied dataset, but modified * by aggregating all the low value items (those whose value is lower * than the percentThreshold) into a single item. The * aggregated items are assigned the specified key. Aggregation only * occurs if there are at least minItems items to aggregate. * * @param source the source dataset (null not permitted). * @param key the key to represent the aggregated items. * @param minimumPercent the percent threshold (ten percent is 0.10). * @param minItems only aggregate low values if there are at least this * many. * * @return The pie dataset with (possibly) aggregated items. */ public static PieDataset createConsolidatedPieDataset(PieDataset source, Comparable key, double minimumPercent, int minItems) { DefaultPieDataset result = new DefaultPieDataset(); double total = DatasetUtilities.calculatePieDatasetTotal(source); // Iterate and find all keys below threshold percentThreshold List keys = source.getKeys(); ArrayList otherKeys = new ArrayList(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable currentKey = (Comparable) iterator.next(); Number dataValue = source.getValue(currentKey); if (dataValue != null) { double value = dataValue.doubleValue(); if (value / total < minimumPercent) { otherKeys.add(currentKey); } } } // Create new dataset with keys above threshold percentThreshold iterator = keys.iterator(); double otherValue = 0; while (iterator.hasNext()) { Comparable currentKey = (Comparable) iterator.next(); Number dataValue = source.getValue(currentKey); if (dataValue != null) { if (otherKeys.contains(currentKey) && otherKeys.size() >= minItems) { // Do not add key to dataset otherValue += dataValue.doubleValue(); } else { // Add key to dataset result.setValue(currentKey, dataValue); } } } // Add other category if applicable if (otherKeys.size() >= minItems) { result.setValue(key, otherValue); } return result; } /** * Creates a {@link CategoryDataset} that contains a copy of the data in an * array (instances of Double are created to represent the * data items). *

* Row and column keys are created by appending 0, 1, 2, ... to the * supplied prefixes. * * @param rowKeyPrefix the row key prefix. * @param columnKeyPrefix the column key prefix. * @param data the data. * * @return The dataset. */ public static CategoryDataset createCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, double[][] data) { DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int r = 0; r < data.length; r++) { String rowKey = rowKeyPrefix + (r + 1); for (int c = 0; c < data[r].length; c++) { String columnKey = columnKeyPrefix + (c + 1); result.addValue(new Double(data[r][c]), rowKey, columnKey); } } return result; } /** * Creates a {@link CategoryDataset} that contains a copy of the data in * an array. *

* Row and column keys are created by appending 0, 1, 2, ... to the * supplied prefixes. * * @param rowKeyPrefix the row key prefix. * @param columnKeyPrefix the column key prefix. * @param data the data. * * @return The dataset. */ public static CategoryDataset createCategoryDataset(String rowKeyPrefix, String columnKeyPrefix, Number[][] data) { DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int r = 0; r < data.length; r++) { String rowKey = rowKeyPrefix + (r + 1); for (int c = 0; c < data[r].length; c++) { String columnKey = columnKeyPrefix + (c + 1); result.addValue(data[r][c], rowKey, columnKey); } } return result; } /** * Creates a {@link CategoryDataset} that contains a copy of the data in * an array (instances of Double are created to represent the * data items). *

* Row and column keys are taken from the supplied arrays. * * @param rowKeys the row keys (null not permitted). * @param columnKeys the column keys (null not permitted). * @param data the data. * * @return The dataset. */ public static CategoryDataset createCategoryDataset(Comparable[] rowKeys, Comparable[] columnKeys, double[][] data) { // check arguments... if (rowKeys == null) { throw new IllegalArgumentException("Null 'rowKeys' argument."); } if (columnKeys == null) { throw new IllegalArgumentException("Null 'columnKeys' argument."); } if (ArrayUtilities.hasDuplicateItems(rowKeys)) { throw new IllegalArgumentException("Duplicate items in 'rowKeys'."); } if (ArrayUtilities.hasDuplicateItems(columnKeys)) { throw new IllegalArgumentException( "Duplicate items in 'columnKeys'."); } if (rowKeys.length != data.length) { throw new IllegalArgumentException( "The number of row keys does not match the number of rows in " + "the data array."); } int columnCount = 0; for (int r = 0; r < data.length; r++) { columnCount = Math.max(columnCount, data[r].length); } if (columnKeys.length != columnCount) { throw new IllegalArgumentException( "The number of column keys does not match the number of " + "columns in the data array."); } // now do the work... DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int r = 0; r < data.length; r++) { Comparable rowKey = rowKeys[r]; for (int c = 0; c < data[r].length; c++) { Comparable columnKey = columnKeys[c]; result.addValue(new Double(data[r][c]), rowKey, columnKey); } } return result; } /** * Creates a {@link CategoryDataset} by copying the data from the supplied * {@link KeyedValues} instance. * * @param rowKey the row key (null not permitted). * @param rowData the row data (null not permitted). * * @return A dataset. */ public static CategoryDataset createCategoryDataset(Comparable rowKey, KeyedValues rowData) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (rowData == null) { throw new IllegalArgumentException("Null 'rowData' argument."); } DefaultCategoryDataset result = new DefaultCategoryDataset(); for (int i = 0; i < rowData.getItemCount(); i++) { result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); } return result; } /** * Creates an {@link XYDataset} by sampling the specified function over a * fixed range. * * @param f the function (null not permitted). * @param start the start value for the range. * @param end the end value for the range. * @param samples the number of sample points (must be > 1). * @param seriesKey the key to give the resulting series * (null not permitted). * * @return A dataset. */ public static XYDataset sampleFunction2D(Function2D f, double start, double end, int samples, Comparable seriesKey) { // defer argument checking XYSeries series = sampleFunction2DToSeries(f, start, end, samples, seriesKey); XYSeriesCollection collection = new XYSeriesCollection(series); return collection; } /** * Creates an {@link XYSeries} by sampling the specified function over a * fixed range. * * @param f the function (null not permitted). * @param start the start value for the range. * @param end the end value for the range. * @param samples the number of sample points (must be > 1). * @param seriesKey the key to give the resulting series * (null not permitted). * * @return A series. * * @since 1.0.13 */ public static XYSeries sampleFunction2DToSeries(Function2D f, double start, double end, int samples, Comparable seriesKey) { if (f == null) { throw new IllegalArgumentException("Null 'f' argument."); } if (seriesKey == null) { throw new IllegalArgumentException("Null 'seriesKey' argument."); } if (start >= end) { throw new IllegalArgumentException("Requires 'start' < 'end'."); } if (samples < 2) { throw new IllegalArgumentException("Requires 'samples' > 1"); } XYSeries series = new XYSeries(seriesKey); double step = (end - start) / (samples - 1); for (int i = 0; i < samples; i++) { double x = start + (step * i); series.add(x, f.getValue(x)); } return series; } /** * Returns true if the dataset is empty (or null), * and false otherwise. * * @param dataset the dataset (null permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(PieDataset dataset) { if (dataset == null) { return true; } int itemCount = dataset.getItemCount(); if (itemCount == 0) { return true; } for (int item = 0; item < itemCount; item++) { Number y = dataset.getValue(item); if (y != null) { double yy = y.doubleValue(); if (yy > 0.0) { return false; } } } return true; } /** * Returns true if the dataset is empty (or null), * and false otherwise. * * @param dataset the dataset (null permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(CategoryDataset dataset) { if (dataset == null) { return true; } int rowCount = dataset.getRowCount(); int columnCount = dataset.getColumnCount(); if (rowCount == 0 || columnCount == 0) { return true; } for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { if (dataset.getValue(r, c) != null) { return false; } } } return true; } /** * Returns true if the dataset is empty (or null), * and false otherwise. * * @param dataset the dataset (null permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(XYDataset dataset) { if (dataset != null) { for (int s = 0; s < dataset.getSeriesCount(); s++) { if (dataset.getItemCount(s) > 0) { return false; } } } return true; } /** * Returns the range of values in the domain (x-values) of a dataset. * * @param dataset the dataset (null not permitted). * * @return The range of values (possibly null). */ public static Range findDomainBounds(XYDataset dataset) { return findDomainBounds(dataset, true); } /** * Returns the range of values in the domain (x-values) of a dataset. * * @param dataset the dataset (null not permitted). * @param includeInterval determines whether or not the x-interval is taken * into account (only applies if the dataset is an * {@link IntervalXYDataset}). * * @return The range of values (possibly null). */ public static Range findDomainBounds(XYDataset dataset, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; // if the dataset implements DomainInfo, life is easier if (dataset instanceof DomainInfo) { DomainInfo info = (DomainInfo) dataset; result = info.getDomainBounds(includeInterval); } else { result = iterateDomainBounds(dataset, includeInterval); } return result; } /** * Returns the bounds of the x-values in the specified dataset * taking into account only the visible series and including any x-interval * if requested. * * @param dataset the dataset (null not permitted). * @param visibleSeriesKeys the visible series keys (null * not permitted). * @param includeInterval include the x-interval (if any)? * * @return The bounds (or null if the dataset contains no * values. * * @since 1.0.13 */ public static Range findDomainBounds(XYDataset dataset, List visibleSeriesKeys, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; if (dataset instanceof XYDomainInfo) { XYDomainInfo info = (XYDomainInfo) dataset; result = info.getDomainBounds(visibleSeriesKeys, includeInterval); } else { result = iterateToFindDomainBounds(dataset, visibleSeriesKeys, includeInterval); } return result; } /** * Iterates over the items in an {@link XYDataset} to find * the range of x-values. If the dataset is an instance of * {@link IntervalXYDataset}, the starting and ending x-values * will be used for the bounds calculation. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). */ public static Range iterateDomainBounds(XYDataset dataset) { return iterateDomainBounds(dataset, true); } /** * Iterates over the items in an {@link XYDataset} to find * the range of x-values. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines, for an * {@link IntervalXYDataset}, whether the x-interval or just the * x-value is used to determine the overall range. * * @return The range (possibly null). */ public static Range iterateDomainBounds(XYDataset dataset, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); double lvalue; double uvalue; if (includeInterval && dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = intervalXYData.getStartXValue(series, item); uvalue = intervalXYData.getEndXValue(series, item); if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); } if (!Double.isNaN(uvalue)) { maximum = Math.max(maximum, uvalue); } } } } else { for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { lvalue = dataset.getXValue(series, item); uvalue = lvalue; if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); maximum = Math.max(maximum, uvalue); } } } } if (minimum > maximum) { return null; } else { return new Range(minimum, maximum); } } /** * Returns the range of values in the range for the dataset. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). */ public static Range findRangeBounds(CategoryDataset dataset) { return findRangeBounds(dataset, true); } /** * Returns the range of values in the range for the dataset. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly null). */ public static Range findRangeBounds(CategoryDataset dataset, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; result = info.getRangeBounds(includeInterval); } else { result = iterateRangeBounds(dataset, includeInterval); } return result; } /** * Finds the bounds of the y-values in the specified dataset, including * only those series that are listed in visibleSeriesKeys. * * @param dataset the dataset (null not permitted). * @param visibleSeriesKeys the keys for the visible series * (null not permitted). * @param includeInterval include the y-interval (if the dataset has a * y-interval). * * @return The data bounds. * * @since 1.0.13 */ public static Range findRangeBounds(CategoryDataset dataset, List visibleSeriesKeys, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; if (dataset instanceof CategoryRangeInfo) { CategoryRangeInfo info = (CategoryRangeInfo) dataset; result = info.getRangeBounds(visibleSeriesKeys, includeInterval); } else { result = iterateToFindRangeBounds(dataset, visibleSeriesKeys, includeInterval); } return result; } /** * Returns the range of values in the range for the dataset. This method * is the partner for the {@link #findDomainBounds(XYDataset)} method. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). */ public static Range findRangeBounds(XYDataset dataset) { return findRangeBounds(dataset, true); } /** * Returns the range of values in the range for the dataset. This method * is the partner for the {@link #findDomainBounds(XYDataset, boolean)} * method. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly null). */ public static Range findRangeBounds(XYDataset dataset, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; result = info.getRangeBounds(includeInterval); } else { result = iterateRangeBounds(dataset, includeInterval); } return result; } /** * Finds the bounds of the y-values in the specified dataset, including * only those series that are listed in visibleSeriesKeys, and those items * whose x-values fall within the specified range. * * @param dataset the dataset (null not permitted). * @param visibleSeriesKeys the keys for the visible series * (null not permitted). * @param xRange the x-range (null not permitted). * @param includeInterval include the y-interval (if the dataset has a * y-interval). * * @return The data bounds. * * @since 1.0.13 */ public static Range findRangeBounds(XYDataset dataset, List visibleSeriesKeys, Range xRange, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; if (dataset instanceof XYRangeInfo) { XYRangeInfo info = (XYRangeInfo) dataset; result = info.getRangeBounds(visibleSeriesKeys, xRange, includeInterval); } else { result = iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, includeInterval); } return result; } /** * Iterates over the data item of the category dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly null). * * @deprecated As of 1.0.10, use * {@link #iterateRangeBounds(CategoryDataset, boolean)}. */ public static Range iterateCategoryRangeBounds(CategoryDataset dataset, boolean includeInterval) { return iterateRangeBounds(dataset, includeInterval); } /** * Iterates over the data item of the category dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). * * @since 1.0.10 */ public static Range iterateRangeBounds(CategoryDataset dataset) { return iterateRangeBounds(dataset, true); } /** * Iterates over the data item of the category dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (possibly null). * * @since 1.0.10 */ public static Range iterateRangeBounds(CategoryDataset dataset, boolean includeInterval) { double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int rowCount = dataset.getRowCount(); int columnCount = dataset.getColumnCount(); if (includeInterval && dataset instanceof IntervalCategoryDataset) { // handle the special case where the dataset has y-intervals that // we want to measure IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; Number lvalue, uvalue; for (int row = 0; row < rowCount; row++) { for (int column = 0; column < columnCount; column++) { lvalue = icd.getStartValue(row, column); uvalue = icd.getEndValue(row, column); if (lvalue != null && !Double.isNaN(lvalue.doubleValue())) { minimum = Math.min(minimum, lvalue.doubleValue()); } if (uvalue != null && !Double.isNaN(uvalue.doubleValue())) { maximum = Math.max(maximum, uvalue.doubleValue()); } } } } else { // handle the standard case (plain CategoryDataset) for (int row = 0; row < rowCount; row++) { for (int column = 0; column < columnCount; column++) { Number value = dataset.getValue(row, column); if (value != null) { double v = value.doubleValue(); if (!Double.isNaN(v)) { minimum = Math.min(minimum, v); maximum = Math.max(maximum, v); } } } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } } /** * Iterates over the data item of the category dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * @param visibleSeriesKeys the visible series keys. * * @return The range (possibly null). * * @since 1.0.13 */ public static Range iterateToFindRangeBounds(CategoryDataset dataset, List visibleSeriesKeys, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (visibleSeriesKeys == null) { throw new IllegalArgumentException( "Null 'visibleSeriesKeys' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int columnCount = dataset.getColumnCount(); if (includeInterval && dataset instanceof BoxAndWhiskerCategoryDataset) { // handle special case of BoxAndWhiskerDataset BoxAndWhiskerCategoryDataset bx = (BoxAndWhiskerCategoryDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); int itemCount = dataset.getColumnCount(); for (int item = 0; item < itemCount; item++) { Number lvalue = bx.getMinRegularValue(series, item); if (lvalue == null) { lvalue = bx.getValue(series, item); } Number uvalue = bx.getMaxRegularValue(series, item); if (uvalue == null) { uvalue = bx.getValue(series, item); } if (lvalue != null) { minimum = Math.min(minimum, lvalue.doubleValue()); } if (uvalue != null) { maximum = Math.max(maximum, uvalue.doubleValue()); } } } } else if (includeInterval && dataset instanceof IntervalCategoryDataset) { // handle the special case where the dataset has y-intervals that // we want to measure IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; Number lvalue, uvalue; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { lvalue = icd.getStartValue(series, column); uvalue = icd.getEndValue(series, column); if (lvalue != null && !Double.isNaN(lvalue.doubleValue())) { minimum = Math.min(minimum, lvalue.doubleValue()); } if (uvalue != null && !Double.isNaN(uvalue.doubleValue())) { maximum = Math.max(maximum, uvalue.doubleValue()); } } } } else if (includeInterval && dataset instanceof StatisticalCategoryDataset) { // handle the special case where the dataset has y-intervals that // we want to measure StatisticalCategoryDataset scd = (StatisticalCategoryDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { Number meanN = scd.getMeanValue(series, column); if (meanN != null) { double std = 0.0; Number stdN = scd.getStdDevValue(series, column); if (stdN != null) { std = stdN.doubleValue(); if (Double.isNaN(std)) { std = 0.0; } } double mean = meanN.doubleValue(); if (!Double.isNaN(mean)) { minimum = Math.min(minimum, mean - std); maximum = Math.max(maximum, mean + std); } } } } } else { // handle the standard case (plain CategoryDataset) Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.getRowIndex(seriesKey); for (int column = 0; column < columnCount; column++) { Number value = dataset.getValue(series, column); if (value != null) { double v = value.doubleValue(); if (!Double.isNaN(v)) { minimum = Math.min(minimum, v); maximum = Math.max(maximum, v); } } } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } } /** * Iterates over the data item of the xy dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). * * @deprecated As of 1.0.10, use {@link #iterateRangeBounds(XYDataset)}. */ public static Range iterateXYRangeBounds(XYDataset dataset) { return iterateRangeBounds(dataset); } /** * Iterates over the data item of the xy dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * * @return The range (possibly null). * * @since 1.0.10 */ public static Range iterateRangeBounds(XYDataset dataset) { return iterateRangeBounds(dataset, true); } /** * Iterates over the data items of the xy dataset to find * the range bounds. * * @param dataset the dataset (null not permitted). * @param includeInterval a flag that determines, for an * {@link IntervalXYDataset}, whether the y-interval or just the * y-value is used to determine the overall range. * * @return The range (possibly null). * * @since 1.0.10 */ public static Range iterateRangeBounds(XYDataset dataset, boolean includeInterval) { double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); // handle three cases by dataset type if (includeInterval && dataset instanceof IntervalXYDataset) { // handle special case of IntervalXYDataset IntervalXYDataset ixyd = (IntervalXYDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double lvalue = ixyd.getStartYValue(series, item); double uvalue = ixyd.getEndYValue(series, item); if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); } if (!Double.isNaN(uvalue)) { maximum = Math.max(maximum, uvalue); } } } } else if (includeInterval && dataset instanceof OHLCDataset) { // handle special case of OHLCDataset OHLCDataset ohlc = (OHLCDataset) dataset; for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double lvalue = ohlc.getLowValue(series, item); double uvalue = ohlc.getHighValue(series, item); if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); } if (!Double.isNaN(uvalue)) { maximum = Math.max(maximum, uvalue); } } } } else { // standard case - plain XYDataset for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value = dataset.getYValue(series, item); if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); maximum = Math.max(maximum, value); } } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } } /** * Returns the range of x-values in the specified dataset for the * data items belonging to the visible series. * * @param dataset the dataset (null not permitted). * @param visibleSeriesKeys the visible series keys (null not * permitted). * @param includeInterval a flag that determines whether or not the * y-interval for the dataset is included (this only applies if the * dataset is an instance of IntervalXYDataset). * * @return The x-range (possibly null). * * @since 1.0.13 */ public static Range iterateToFindDomainBounds(XYDataset dataset, List visibleSeriesKeys, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (visibleSeriesKeys == null) { throw new IllegalArgumentException( "Null 'visibleSeriesKeys' argument."); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; if (includeInterval && dataset instanceof IntervalXYDataset) { // handle special case of IntervalXYDataset IntervalXYDataset ixyd = (IntervalXYDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.indexOf(seriesKey); int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double lvalue = ixyd.getStartXValue(series, item); double uvalue = ixyd.getEndXValue(series, item); if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); } if (!Double.isNaN(uvalue)) { maximum = Math.max(maximum, uvalue); } } } } else { // standard case - plain XYDataset Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.indexOf(seriesKey); int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double x = dataset.getXValue(series, item); if (!Double.isNaN(x)) { minimum = Math.min(minimum, x); maximum = Math.max(maximum, x); } } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } } /** * Returns the range of y-values in the specified dataset for the * data items belonging to the visible series and with x-values in the * given range. * * @param dataset the dataset (null not permitted). * @param visibleSeriesKeys the visible series keys (null not * permitted). * @param xRange the x-range (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval for the dataset is included (this only applies if the * dataset is an instance of IntervalXYDataset). * * @return The y-range (possibly null). * * @since 1.0.13 */ public static Range iterateToFindRangeBounds(XYDataset dataset, List visibleSeriesKeys, Range xRange, boolean includeInterval) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (visibleSeriesKeys == null) { throw new IllegalArgumentException( "Null 'visibleSeriesKeys' argument."); } if (xRange == null) { throw new IllegalArgumentException("Null 'xRange' argument"); } double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; // handle three cases by dataset type if (includeInterval && dataset instanceof OHLCDataset) { // handle special case of OHLCDataset OHLCDataset ohlc = (OHLCDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.indexOf(seriesKey); int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double x = ohlc.getXValue(series, item); if (xRange.contains(x)) { double lvalue = ohlc.getLowValue(series, item); double uvalue = ohlc.getHighValue(series, item); if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); } if (!Double.isNaN(uvalue)) { maximum = Math.max(maximum, uvalue); } } } } } else if (includeInterval && dataset instanceof BoxAndWhiskerXYDataset) { // handle special case of BoxAndWhiskerXYDataset BoxAndWhiskerXYDataset bx = (BoxAndWhiskerXYDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.indexOf(seriesKey); int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double x = bx.getXValue(series, item); if (xRange.contains(x)) { Number lvalue = bx.getMinRegularValue(series, item); Number uvalue = bx.getMaxRegularValue(series, item); if (lvalue != null) { minimum = Math.min(minimum, lvalue.doubleValue()); } if (uvalue != null) { maximum = Math.max(maximum, uvalue.doubleValue()); } } } } } else if (includeInterval && dataset instanceof IntervalXYDataset) { // handle special case of IntervalXYDataset IntervalXYDataset ixyd = (IntervalXYDataset) dataset; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.indexOf(seriesKey); int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double x = ixyd.getXValue(series, item); if (xRange.contains(x)) { double lvalue = ixyd.getStartYValue(series, item); double uvalue = ixyd.getEndYValue(series, item); if (!Double.isNaN(lvalue)) { minimum = Math.min(minimum, lvalue); } if (!Double.isNaN(uvalue)) { maximum = Math.max(maximum, uvalue); } } } } } else { // standard case - plain XYDataset Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); int series = dataset.indexOf(seriesKey); int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); if (xRange.contains(x)) { if (!Double.isNaN(y)) { minimum = Math.min(minimum, y); maximum = Math.max(maximum, y); } } } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Range(minimum, maximum); } } /** * Finds the minimum domain (or X) value for the specified dataset. This * is easy if the dataset implements the {@link DomainInfo} interface (a * good idea if there is an efficient way to determine the minimum value). * Otherwise, it involves iterating over the entire data-set. *

* Returns null if all the data values in the dataset are * null. * * @param dataset the dataset (null not permitted). * * @return The minimum value (possibly null). */ public static Number findMinimumDomainValue(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; // if the dataset implements DomainInfo, life is easy if (dataset instanceof DomainInfo) { DomainInfo info = (DomainInfo) dataset; return new Double(info.getDomainLowerBound(true)); } else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getStartXValue(series, item); } else { value = dataset.getXValue(series, item); } if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); } } } if (minimum == Double.POSITIVE_INFINITY) { result = null; } else { result = new Double(minimum); } } return result; } /** * Returns the maximum domain value for the specified dataset. This is * easy if the dataset implements the {@link DomainInfo} interface (a good * idea if there is an efficient way to determine the maximum value). * Otherwise, it involves iterating over the entire data-set. Returns * null if all the data values in the dataset are * null. * * @param dataset the dataset (null not permitted). * * @return The maximum value (possibly null). */ public static Number findMaximumDomainValue(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; // if the dataset implements DomainInfo, life is easy if (dataset instanceof DomainInfo) { DomainInfo info = (DomainInfo) dataset; return new Double(info.getDomainUpperBound(true)); } // hasn't implemented DomainInfo, so iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getEndXValue(series, item); } else { value = dataset.getXValue(series, item); } if (!Double.isNaN(value)) { maximum = Math.max(maximum, value); } } } if (maximum == Double.NEGATIVE_INFINITY) { result = null; } else { result = new Double(maximum); } } return result; } /** * Returns the minimum range value for the specified dataset. This is * easy if the dataset implements the {@link RangeInfo} interface (a good * idea if there is an efficient way to determine the minimum value). * Otherwise, it involves iterating over the entire data-set. Returns * null if all the data values in the dataset are * null. * * @param dataset the dataset (null not permitted). * * @return The minimum value (possibly null). */ public static Number findMinimumRangeValue(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeLowerBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getStartValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { minimum = Math.min(minimum, value.doubleValue()); } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Double(minimum); } } } /** * Returns the minimum range value for the specified dataset. This is * easy if the dataset implements the {@link RangeInfo} interface (a good * idea if there is an efficient way to determine the minimum value). * Otherwise, it involves iterating over the entire data-set. Returns * null if all the data values in the dataset are * null. * * @param dataset the dataset (null not permitted). * * @return The minimum value (possibly null). */ public static Number findMinimumRangeValue(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeLowerBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double minimum = Double.POSITIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getStartYValue(series, item); } else if (dataset instanceof OHLCDataset) { OHLCDataset highLowData = (OHLCDataset) dataset; value = highLowData.getLowValue(series, item); } else { value = dataset.getYValue(series, item); } if (!Double.isNaN(value)) { minimum = Math.min(minimum, value); } } } if (minimum == Double.POSITIVE_INFINITY) { return null; } else { return new Double(minimum); } } } /** * Returns the maximum range value for the specified dataset. This is easy * if the dataset implements the {@link RangeInfo} interface (a good idea * if there is an efficient way to determine the maximum value). * Otherwise, it involves iterating over the entire data-set. Returns * null if all the data values are null. * * @param dataset the dataset (null not permitted). * * @return The maximum value (possibly null). */ public static Number findMaximumRangeValue(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeUpperBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getRowCount(); int itemCount = dataset.getColumnCount(); for (int series = 0; series < seriesCount; series++) { for (int item = 0; item < itemCount; item++) { Number value; if (dataset instanceof IntervalCategoryDataset) { IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; value = icd.getEndValue(series, item); } else { value = dataset.getValue(series, item); } if (value != null) { maximum = Math.max(maximum, value.doubleValue()); } } } if (maximum == Double.NEGATIVE_INFINITY) { return null; } else { return new Double(maximum); } } } /** * Returns the maximum range value for the specified dataset. This is * easy if the dataset implements the {@link RangeInfo} interface (a good * idea if there is an efficient way to determine the maximum value). * Otherwise, it involves iterating over the entire data-set. Returns * null if all the data values are null. * * @param dataset the dataset (null not permitted). * * @return The maximum value (possibly null). */ public static Number findMaximumRangeValue(XYDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } // work out the minimum value... if (dataset instanceof RangeInfo) { RangeInfo info = (RangeInfo) dataset; return new Double(info.getRangeUpperBound(true)); } // hasn't implemented RangeInfo, so we'll have to iterate... else { double maximum = Double.NEGATIVE_INFINITY; int seriesCount = dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { int itemCount = dataset.getItemCount(series); for (int item = 0; item < itemCount; item++) { double value; if (dataset instanceof IntervalXYDataset) { IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; value = intervalXYData.getEndYValue(series, item); } else if (dataset instanceof OHLCDataset) { OHLCDataset highLowData = (OHLCDataset) dataset; value = highLowData.getHighValue(series, item); } else { value = dataset.getYValue(series, item); } if (!Double.isNaN(value)) { maximum = Math.max(maximum, value); } } } if (maximum == Double.NEGATIVE_INFINITY) { return null; } else { return new Double(maximum); } } } /** * Returns the minimum and maximum values for the dataset's range * (y-values), assuming that the series in one category are stacked. * * @param dataset the dataset (null not permitted). * * @return The range (null if the dataset contains no values). */ public static Range findStackedRangeBounds(CategoryDataset dataset) { return findStackedRangeBounds(dataset, 0.0); } /** * Returns the minimum and maximum values for the dataset's range * (y-values), assuming that the series in one category are stacked. * * @param dataset the dataset (null not permitted). * @param base the base value for the bars. * * @return The range (null if the dataset contains no values). */ public static Range findStackedRangeBounds(CategoryDataset dataset, double base) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Range result = null; double minimum = Double.POSITIVE_INFINITY; double maximum = Double.NEGATIVE_INFINITY; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double positive = base; double negative = base; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { double value = number.doubleValue(); if (value > 0.0) { positive = positive + value; } if (value < 0.0) { negative = negative + value; // '+', remember value is negative } } } minimum = Math.min(minimum, negative); maximum = Math.max(maximum, positive); } if (minimum <= maximum) { result = new Range(minimum, maximum); } return result; } /** * Returns the minimum and maximum values for the dataset's range * (y-values), assuming that the series in one category are stacked. * * @param dataset the dataset. * @param map a structure that maps series to groups. * * @return The value range (null if the dataset contains no * values). */ public static Range findStackedRangeBounds(CategoryDataset dataset, KeyToGroupMap map) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } boolean hasValidData = false; Range result = null; // create an array holding the group indices for each series... int[] groupIndex = new int[dataset.getRowCount()]; for (int i = 0; i < dataset.getRowCount(); i++) { groupIndex[i] = map.getGroupIndex(map.getGroup( dataset.getRowKey(i))); } // minimum and maximum for each group... int groupCount = map.getGroupCount(); double[] minimum = new double[groupCount]; double[] maximum = new double[groupCount]; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double[] positive = new double[groupCount]; double[] negative = new double[groupCount]; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { hasValidData = true; double value = number.doubleValue(); if (value > 0.0) { positive[groupIndex[series]] = positive[groupIndex[series]] + value; } if (value < 0.0) { negative[groupIndex[series]] = negative[groupIndex[series]] + value; // '+', remember value is negative } } } for (int g = 0; g < groupCount; g++) { minimum[g] = Math.min(minimum[g], negative[g]); maximum[g] = Math.max(maximum[g], positive[g]); } } if (hasValidData) { for (int j = 0; j < groupCount; j++) { result = Range.combine(result, new Range(minimum[j], maximum[j])); } } return result; } /** * Returns the minimum value in the dataset range, assuming that values in * each category are "stacked". * * @param dataset the dataset (null not permitted). * * @return The minimum value. * * @see #findMaximumStackedRangeValue(CategoryDataset) */ public static Number findMinimumStackedRangeValue(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; boolean hasValidData = false; double minimum = 0.0; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double total = 0.0; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { hasValidData = true; double value = number.doubleValue(); if (value < 0.0) { total = total + value; // '+', remember value is negative } } } minimum = Math.min(minimum, total); } if (hasValidData) { result = new Double(minimum); } return result; } /** * Returns the maximum value in the dataset range, assuming that values in * each category are "stacked". * * @param dataset the dataset (null not permitted). * * @return The maximum value (possibly null). * * @see #findMinimumStackedRangeValue(CategoryDataset) */ public static Number findMaximumStackedRangeValue(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } Number result = null; boolean hasValidData = false; double maximum = 0.0; int categoryCount = dataset.getColumnCount(); for (int item = 0; item < categoryCount; item++) { double total = 0.0; int seriesCount = dataset.getRowCount(); for (int series = 0; series < seriesCount; series++) { Number number = dataset.getValue(series, item); if (number != null) { hasValidData = true; double value = number.doubleValue(); if (value > 0.0) { total = total + value; } } } maximum = Math.max(maximum, total); } if (hasValidData) { result = new Double(maximum); } return result; } /** * Returns the minimum and maximum values for the dataset's range, * assuming that the series are stacked. * * @param dataset the dataset (null not permitted). * * @return The range ([0.0, 0.0] if the dataset contains no values). */ public static Range findStackedRangeBounds(TableXYDataset dataset) { return findStackedRangeBounds(dataset, 0.0); } /** * Returns the minimum and maximum values for the dataset's range, * assuming that the series are stacked, using the specified base value. * * @param dataset the dataset (null not permitted). * @param base the base value. * * @return The range (null if the dataset contains no values). */ public static Range findStackedRangeBounds(TableXYDataset dataset, double base) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } double minimum = base; double maximum = base; for (int itemNo = 0; itemNo < dataset.getItemCount(); itemNo++) { double positive = base; double negative = base; int seriesCount = dataset.getSeriesCount(); for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) { double y = dataset.getYValue(seriesNo, itemNo); if (!Double.isNaN(y)) { if (y > 0.0) { positive += y; } else { negative += y; } } } if (positive > maximum) { maximum = positive; } if (negative < minimum) { minimum = negative; } } if (minimum <= maximum) { return new Range(minimum, maximum); } else { return null; } } /** * Calculates the total for the y-values in all series for a given item * index. * * @param dataset the dataset. * @param item the item index. * * @return The total. * * @since 1.0.5 */ public static double calculateStackTotal(TableXYDataset dataset, int item) { double total = 0.0; int seriesCount = dataset.getSeriesCount(); for (int s = 0; s < seriesCount; s++) { double value = dataset.getYValue(s, item); if (!Double.isNaN(value)) { total = total + value; } } return total; } /** * Calculates the range of values for a dataset where each item is the * running total of the items for the current series. * * @param dataset the dataset (null not permitted). * * @return The range. * * @see #findRangeBounds(CategoryDataset) */ public static Range findCumulativeRangeBounds(CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... double minimum = 0.0; double maximum = 0.0; for (int row = 0; row < dataset.getRowCount(); row++) { double runningTotal = 0.0; for (int column = 0; column <= dataset.getColumnCount() - 1; column++) { Number n = dataset.getValue(row, column); if (n != null) { allItemsNull = false; double value = n.doubleValue(); if (!Double.isNaN(value)) { runningTotal = runningTotal + value; minimum = Math.min(minimum, runningTotal); maximum = Math.max(maximum, runningTotal); } } } } if (!allItemsNull) { return new Range(minimum, maximum); } else { return null; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DefaultHeatMapDataset.java0000644000175000017500000002443711173030414030665 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultHeatMapDataset.java * -------------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Jan-2009 : Version 1 (DG); * */ package org.jfree.data.general; import java.io.Serializable; import org.jfree.data.DataUtilities; import org.jfree.util.PublicCloneable; /** * A default implementation of the {@link HeatMapDataset} interface. * * @since 1.0.13 */ public class DefaultHeatMapDataset extends AbstractDataset implements HeatMapDataset, Cloneable, PublicCloneable, Serializable { /** The number of samples in this dataset for the x-dimension. */ private int xSamples; /** The number of samples in this dataset for the y-dimension. */ private int ySamples; /** The minimum x-value in the dataset. */ private double minX; /** The maximum x-value in the dataset. */ private double maxX; /** The minimum y-value in the dataset. */ private double minY; /** The maximum y-value in the dataset. */ private double maxY; /** Storage for the z-values. */ private double[][] zValues; /** * Creates a new dataset where all the z-values are initially 0. This is * a fixed size array of z-values. * * @param xSamples the number of x-values. * @param ySamples the number of y-values * @param minX the minimum x-value in the dataset. * @param maxX the maximum x-value in the dataset. * @param minY the minimum y-value in the dataset. * @param maxY the maximum y-value in the dataset. */ public DefaultHeatMapDataset(int xSamples, int ySamples, double minX, double maxX, double minY, double maxY) { if (xSamples < 1) { throw new IllegalArgumentException("Requires 'xSamples' > 0"); } if (ySamples < 1) { throw new IllegalArgumentException("Requires 'ySamples' > 0"); } if (Double.isInfinite(minX) || Double.isNaN(minX)) { throw new IllegalArgumentException("'minX' cannot be INF or NaN."); } if (Double.isInfinite(maxX) || Double.isNaN(maxX)) { throw new IllegalArgumentException("'maxX' cannot be INF or NaN."); } if (Double.isInfinite(minY) || Double.isNaN(minY)) { throw new IllegalArgumentException("'minY' cannot be INF or NaN."); } if (Double.isInfinite(maxY) || Double.isNaN(maxY)) { throw new IllegalArgumentException("'maxY' cannot be INF or NaN."); } this.xSamples = xSamples; this.ySamples = ySamples; this.minX = minX; this.maxX = maxX; this.minY = minY; this.maxY = maxY; this.zValues = new double[xSamples][]; for (int x = 0; x < xSamples; x++) { this.zValues[x] = new double[ySamples]; } } /** * Returns the number of x values across the width of the dataset. The * values are evenly spaced between {@link #getMinimumXValue()} and * {@link #getMaximumXValue()}. * * @return The number of x-values (always > 0). */ public int getXSampleCount() { return this.xSamples; } /** * Returns the number of y values (or samples) for the dataset. The * values are evenly spaced between {@link #getMinimumYValue()} and * {@link #getMaximumYValue()}. * * @return The number of y-values (always > 0). */ public int getYSampleCount() { return this.ySamples; } /** * Returns the lowest x-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The lowest x-value represented in this dataset. */ public double getMinimumXValue() { return this.minX; } /** * Returns the highest x-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The highest x-value represented in this dataset. */ public double getMaximumXValue() { return this.maxX; } /** * Returns the lowest y-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The lowest y-value represented in this dataset. */ public double getMinimumYValue() { return this.minY; } /** * Returns the highest y-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The highest y-value represented in this dataset. */ public double getMaximumYValue() { return this.maxY; } /** * A convenience method that returns the x-value for the given index. * * @param xIndex the xIndex. * * @return The x-value. */ public double getXValue(int xIndex) { double x = this.minX + (this.maxX - this.minX) * (xIndex / (double) this.xSamples); return x; } /** * A convenience method that returns the y-value for the given index. * * @param yIndex the yIndex. * * @return The y-value. */ public double getYValue(int yIndex) { double y = this.minY + (this.maxY - this.minY) * (yIndex / (double) this.ySamples); return y; } /** * Returns the z-value at the specified sample position in the dataset. * For a missing or unknown value, this method should return Double.NAN. * * @param xIndex the position of the x sample in the dataset. * @param yIndex the position of the y sample in the dataset. * * @return The z-value. */ public double getZValue(int xIndex, int yIndex) { return this.zValues[xIndex][yIndex]; } /** * Returns the z-value at the specified sample position in the dataset. * In this implementation, where the underlying values are stored in an * array of double primitives, you should avoid using this method and * use {@link #getZValue(int, int)} instead. * * @param xIndex the position of the x sample in the dataset. * @param yIndex the position of the y sample in the dataset. * * @return The z-value. */ public Number getZ(int xIndex, int yIndex) { return new Double(getZValue(xIndex, yIndex)); } /** * Updates a z-value in the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param xIndex the x-index. * @param yIndex the y-index. * @param z the new z-value. */ public void setZValue(int xIndex, int yIndex, double z) { setZValue(xIndex, yIndex, z, true); } /** * Updates a z-value in the dataset and, if requested, sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param xIndex the x-index. * @param yIndex the y-index. * @param z the new z-value. * @param notify notify listeners? */ public void setZValue(int xIndex, int yIndex, double z, boolean notify) { this.zValues[xIndex][yIndex] = z; if (notify) { fireDatasetChanged(); } } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultHeatMapDataset)) { return false; } DefaultHeatMapDataset that = (DefaultHeatMapDataset) obj; if (this.xSamples != that.xSamples) { return false; } if (this.ySamples != that.ySamples) { return false; } if (this.minX != that.minX) { return false; } if (this.maxX != that.maxX) { return false; } if (this.minY != that.minY) { return false; } if (this.maxY != that.maxY) { return false; } if (!DataUtilities.equal(this.zValues, that.zValues)) { return false; } // can't find any differences return true; } /** * Returns an independent copy of this dataset. * * @return A clone. * * @throws java.lang.CloneNotSupportedException */ public Object clone() throws CloneNotSupportedException { DefaultHeatMapDataset clone = (DefaultHeatMapDataset) super.clone(); clone.zValues = DataUtilities.clone(this.zValues); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DefaultKeyedValueDataset.java0000644000175000017500000001324311173030414031375 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * DefaultKeyedValueDataset.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * */ package org.jfree.data.general; import java.io.Serializable; import org.jfree.data.DefaultKeyedValue; import org.jfree.data.KeyedValue; import org.jfree.util.ObjectUtilities; /** * A default implementation of the {@link KeyedValueDataset} interface. */ public class DefaultKeyedValueDataset extends AbstractDataset implements KeyedValueDataset, Serializable { /** For serialization. */ private static final long serialVersionUID = -8149484339560406750L; /** Storage for the data. */ private KeyedValue data; /** * Constructs a new dataset, initially empty. */ public DefaultKeyedValueDataset() { this(null); } /** * Creates a new dataset with the specified initial value. * * @param key the key. * @param value the value (null permitted). */ public DefaultKeyedValueDataset(Comparable key, Number value) { this(new DefaultKeyedValue(key, value)); } /** * Creates a new dataset that uses the data from a {@link KeyedValue} * instance. * * @param data the data (null permitted). */ public DefaultKeyedValueDataset(KeyedValue data) { this.data = data; } /** * Returns the key associated with the value, or null if the * dataset has no data item. * * @return The key. */ public Comparable getKey() { Comparable result = null; if (this.data != null) { result = this.data.getKey(); } return result; } /** * Returns the value. * * @return The value (possibly null). */ public Number getValue() { Number result = null; if (this.data != null) { result = this.data.getValue(); } return result; } /** * Updates the value. * * @param value the new value (null permitted). */ public void updateValue(Number value) { if (this.data == null) { throw new RuntimeException("updateValue: can't update null."); } setValue(this.data.getKey(), value); } /** * Sets the value for the dataset and sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param key the key. * @param value the value (null permitted). */ public void setValue(Comparable key, Number value) { this.data = new DefaultKeyedValue(key, value); notifyListeners(new DatasetChangeEvent(this, this)); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof KeyedValueDataset)) { return false; } KeyedValueDataset that = (KeyedValueDataset) obj; if (this.data == null) { if (that.getKey() != null || that.getValue() != null) { return false; } return true; } if (!ObjectUtilities.equal(this.data.getKey(), that.getKey())) { return false; } if (!ObjectUtilities.equal(this.data.getValue(), that.getValue())) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return (this.data != null ? this.data.hashCode() : 0); } /** * Creates a clone of the dataset. * * @return A clone. * * @throws CloneNotSupportedException This class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { DefaultKeyedValueDataset clone = (DefaultKeyedValueDataset) super.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DefaultKeyedValues2DDataset.java0000644000175000017500000000420711173030414031746 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * DefaultKeyedValues2DDataset.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (copied from DefaultCategoryDataset) (DG); * 23-Apr-2003 : Moved implementation into the DefaultCategoryDataset * class (DG); * */ package org.jfree.data.general; import java.io.Serializable; import org.jfree.data.category.DefaultCategoryDataset; /** * A default implementation of the {@link KeyedValues2DDataset} interface. * */ public class DefaultKeyedValues2DDataset extends DefaultCategoryDataset implements KeyedValues2DDataset, Serializable { /** For serialization. */ private static final long serialVersionUID = 4288210771905990424L; // no new methods } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DefaultKeyedValuesDataset.java0000644000175000017500000000374411173030414031565 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * DefaultKeyedValuesDataset.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Mar-2003 : Version 1 (DG); * 13-Mar-2003 : Implemented Serializable (DG); * */ package org.jfree.data.general; /** * A default implementation of the {@link KeyedValuesDataset} interface. * This is an alias for {@link DefaultPieDataset}. */ public class DefaultKeyedValuesDataset extends DefaultPieDataset implements KeyedValuesDataset { /** For serialization. */ private static final long serialVersionUID = 306264413152815781L; // no new methods } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DefaultPieDataset.java0000644000175000017500000002715511173030414030063 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DefaultPieDataset.java * ---------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Sam (oldman); * * Changes * ------- * 17-Nov-2001 : Version 1 (DG); * 22-Jan-2002 : Removed legend methods from dataset implementations (DG); * 07-Apr-2002 : Modified implementation to guarantee data sequence to remain * in the order categories are added (oldman); * 23-Oct-2002 : Added getCategory(int) method and getItemCount() method, in * line with changes to the PieDataset interface (DG); * 04-Feb-2003 : Changed underlying data storage to DefaultKeyedValues (DG); * 04-Mar-2003 : Inserted DefaultKeyedValuesDataset class into hierarchy (DG); * 24-Apr-2003 : Switched places with DefaultKeyedValuesDataset (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * 03-Mar-2005 : Implemented PublicCloneable (DG); * 29-Jun-2005 : Added remove() method (DG); * ------------- JFREECHART 1.0.0 --------------------------------------------- * 31-Jul-2006 : Added a clear() method to clear all values from the * dataset (DG); * 28-Sep-2006 : Added sortByKeys() and sortByValues() methods (DG); * 30-Apr-2007 : Added new insertValues() methods (DG); * */ package org.jfree.data.general; import java.io.Serializable; import java.util.Collections; import java.util.List; import org.jfree.data.DefaultKeyedValues; import org.jfree.data.KeyedValues; import org.jfree.data.UnknownKeyException; import org.jfree.util.PublicCloneable; import org.jfree.util.SortOrder; /** * A default implementation of the {@link PieDataset} interface. */ public class DefaultPieDataset extends AbstractDataset implements PieDataset, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2904745139106540618L; /** Storage for the data. */ private DefaultKeyedValues data; /** * Constructs a new dataset, initially empty. */ public DefaultPieDataset() { this.data = new DefaultKeyedValues(); } /** * Creates a new dataset by copying data from a {@link KeyedValues} * instance. * * @param data the data (null not permitted). */ public DefaultPieDataset(KeyedValues data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } this.data = new DefaultKeyedValues(); for (int i = 0; i < data.getItemCount(); i++) { this.data.addValue(data.getKey(i), data.getValue(i)); } } /** * Returns the number of items in the dataset. * * @return The item count. */ public int getItemCount() { return this.data.getItemCount(); } /** * Returns the categories in the dataset. The returned list is * unmodifiable. * * @return The categories in the dataset. */ public List getKeys() { return Collections.unmodifiableList(this.data.getKeys()); } /** * Returns the key for the specified item, or null. * * @param item the item index (in the range 0 to * getItemCount() - 1). * * @return The key, or null. * * @throws IndexOutOfBoundsException if item is not in the * specified range. */ public Comparable getKey(int item) { return this.data.getKey(item); } /** * Returns the index for a key, or -1 if the key is not recognised. * * @param key the key (null not permitted). * * @return The index, or -1 if the key is unrecognised. * * @throws IllegalArgumentException if key is * null. */ public int getIndex(Comparable key) { return this.data.getIndex(key); } /** * Returns a value. * * @param item the value index. * * @return The value (possibly null). */ public Number getValue(int item) { Number result = null; if (getItemCount() > item) { result = this.data.getValue(item); } return result; } /** * Returns the data value associated with a key. * * @param key the key (null not permitted). * * @return The value (possibly null). * * @throws UnknownKeyException if the key is not recognised. */ public Number getValue(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } return this.data.getValue(key); } /** * Sets the data value for a key and sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param key the key (null not permitted). * @param value the value. * * @throws IllegalArgumentException if key is * null. */ public void setValue(Comparable key, Number value) { this.data.setValue(key, value); fireDatasetChanged(); } /** * Sets the data value for a key and sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param key the key (null not permitted). * @param value the value. * * @throws IllegalArgumentException if key is * null. */ public void setValue(Comparable key, double value) { setValue(key, new Double(value)); } /** * Inserts a new value at the specified position in the dataset or, if * there is an existing item with the specified key, updates the value * for that item and moves it to the specified position. After the change * is made, this methods sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param position the position (in the range 0 to getItemCount()). * @param key the key (null not permitted). * @param value the value (null permitted). * * @since 1.0.6 */ public void insertValue(int position, Comparable key, double value) { insertValue(position, key, new Double(value)); } /** * Inserts a new value at the specified position in the dataset or, if * there is an existing item with the specified key, updates the value * for that item and moves it to the specified position. After the change * is made, this methods sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param position the position (in the range 0 to getItemCount()). * @param key the key (null not permitted). * @param value the value (null permitted). * * @since 1.0.6 */ public void insertValue(int position, Comparable key, Number value) { this.data.insertValue(position, key, value); fireDatasetChanged(); } /** * Removes an item from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param key the key (null not permitted). * * @throws IllegalArgumentException if key is * null. */ public void remove(Comparable key) { this.data.removeValue(key); fireDatasetChanged(); } /** * Clears all data from this dataset and sends a {@link DatasetChangeEvent} * to all registered listeners (unless the dataset was already empty). * * @since 1.0.2 */ public void clear() { if (getItemCount() > 0) { this.data.clear(); fireDatasetChanged(); } } /** * Sorts the dataset's items by key and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param order the sort order (null not permitted). * * @since 1.0.3 */ public void sortByKeys(SortOrder order) { this.data.sortByKeys(order); fireDatasetChanged(); } /** * Sorts the dataset's items by value and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param order the sort order (null not permitted). * * @since 1.0.3 */ public void sortByValues(SortOrder order) { this.data.sortByValues(order); fireDatasetChanged(); } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return this.data.hashCode(); } /** * Returns a clone of the dataset. * * @return A clone. * * @throws CloneNotSupportedException This class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { DefaultPieDataset clone = (DefaultPieDataset) super.clone(); clone.data = (DefaultKeyedValues) this.data.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/DefaultValueDataset.java0000644000175000017500000001020511173030414030406 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * DefaultValueDataset.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * 03-Mar-2005 : Implemented PublicCloneable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 30-Jan-2007 : Added explicit super() call in constructor (for clarity) (DG); * */ package org.jfree.data.general; import java.io.Serializable; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A dataset that stores a single value (that is possibly null). * This class provides a default implementation of the {@link ValueDataset} * interface. */ public class DefaultValueDataset extends AbstractDataset implements ValueDataset, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8137521217249294891L; /** The value. */ private Number value; /** * Constructs a new dataset, initially empty. */ public DefaultValueDataset() { this(null); } /** * Creates a new dataset with the specified value. * * @param value the value. */ public DefaultValueDataset(double value) { this(new Double(value)); } /** * Creates a new dataset with the specified value. * * @param value the initial value (null permitted). */ public DefaultValueDataset(Number value) { super(); this.value = value; } /** * Returns the value. * * @return The value (possibly null). */ public Number getValue() { return this.value; } /** * Sets the value and sends a {@link DatasetChangeEvent} to all registered * listeners. * * @param value the new value (null permitted). */ public void setValue(Number value) { this.value = value; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof ValueDataset) { ValueDataset vd = (ValueDataset) obj; return ObjectUtilities.equal(this.value, vd.getValue()); } return false; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return (this.value != null ? this.value.hashCode() : 0); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/HeatMapDataset.java0000644000175000017500000001252311173030414027351 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * HeatMapDataset.java * ------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Jan-2009 : Version 1 (DG); * */ package org.jfree.data.general; /** * A dataset that represents a rectangular grid of (x, y, z) values. The x * and y values appear at regular intervals in the dataset, while the z-values * can take any value (including null for unknown values). * * @since 1.0.13 */ public interface HeatMapDataset { /** * Returns the number of x values across the width of the dataset. The * values are evenly spaced between {@link #getMinimumXValue()} and * {@link #getMaximumXValue()}. * * @return The number of x-values (always > 0). */ public int getXSampleCount(); /** * Returns the number of y values (or samples) for the dataset. The * values are evenly spaced between {@link #getMinimumYValue()} and * {@link #getMaximumYValue()}. * * @return The number of y-values (always > 0). */ public int getYSampleCount(); /** * Returns the lowest x-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The lowest x-value represented in this dataset. */ public double getMinimumXValue(); /** * Returns the highest x-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The highest x-value represented in this dataset. */ public double getMaximumXValue(); /** * Returns the lowest y-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The lowest y-value represented in this dataset. */ public double getMinimumYValue(); /** * Returns the highest y-value represented in this dataset. A requirement * of this interface is that this method must never return infinite or * Double.NAN values. * * @return The highest y-value represented in this dataset. */ public double getMaximumYValue(); /** * A convenience method that returns the x-value for the given index. * * @param xIndex the xIndex. * * @return The x-value. */ public double getXValue(int xIndex); /** * A convenience method that returns the y-value for the given index. * * @param yIndex the yIndex. * * @return The y-value. */ public double getYValue(int yIndex); /** * Returns the z-value at the specified sample position in the dataset. * For a missing or unknown value, this method should return Double.NAN. * * @param xIndex the position of the x sample in the dataset. * @param yIndex the position of the y sample in the dataset. * * @return The z-value. */ public double getZValue(int xIndex, int yIndex); /** * Returns the z-value at the specified sample position in the dataset. * This method can return null to indicate a missing/unknown * value. *

* Bear in mind that the class implementing this interface may * store its data using primitives rather than objects, so calling this * method may require a new Number object to be allocated... * for this reason, it is generally preferable to use the * {@link #getZValue(int, int)} method unless you *know* that the dataset * implementation stores the z-values using objects. * * @param xIndex the position of the x sample in the dataset. * @param yIndex the position of the y sample in the dataset. * * @return The z-value (possibly null). */ public Number getZ(int xIndex, int yIndex); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/HeatMapUtilities.java0000644000175000017500000001163211173030414027737 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * HeatMapUtilities.java * --------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Jan-2009 : Version 1 (DG); * */ package org.jfree.data.general; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.image.BufferedImage; import org.jfree.chart.renderer.PaintScale; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * A utility class for the {@link HeatMapDataset}. * * @since 1.0.13 */ public abstract class HeatMapUtilities { /** * Returns a dataset containing one series that holds a copy of the (x, z) * data from one row (y-index) of the specified dataset. * * @param dataset the dataset (null not permitted). * @param row the row (y) index. * @param seriesName the series name/key (null not permitted). * * @return The dataset. */ public static XYDataset extractRowFromHeatMapDataset(HeatMapDataset dataset, int row, Comparable seriesName) { XYSeries series = new XYSeries(seriesName); int cols = dataset.getXSampleCount(); for (int c = 0; c < cols; c++) { series.add(dataset.getXValue(c), dataset.getZValue(c, row)); } XYSeriesCollection result = new XYSeriesCollection(series); return result; } /** * Returns a dataset containing one series that holds a copy of the (y, z) * data from one column (x-index) of the specified dataset. * * @param dataset the dataset (null not permitted). * @param column the column (x) index. * @param seriesName the series name (null not permitted). * * @return The dataset. */ public static XYDataset extractColumnFromHeatMapDataset( HeatMapDataset dataset, int column, Comparable seriesName) { XYSeries series = new XYSeries(seriesName); int rows = dataset.getYSampleCount(); for (int r = 0; r < rows; r++) { series.add(dataset.getYValue(r), dataset.getZValue(column, r)); } XYSeriesCollection result = new XYSeriesCollection(series); return result; } /** * Creates an image that displays the values from the specified dataset. * * @param dataset the dataset (null not permitted). * @param paintScale the paint scale for the z-values (null * not permitted). * * @return A buffered image. */ public static BufferedImage createHeatMapImage(HeatMapDataset dataset, PaintScale paintScale) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } if (paintScale == null) { throw new IllegalArgumentException("Null 'paintScale' argument."); } int xCount = dataset.getXSampleCount(); int yCount = dataset.getYSampleCount(); BufferedImage image = new BufferedImage(xCount, yCount, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); for (int xIndex = 0; xIndex < xCount; xIndex++) { for (int yIndex = 0; yIndex < yCount; yIndex++) { double z = dataset.getZValue(xIndex, yIndex); Paint p = paintScale.getPaint(z); g2.setPaint(p); g2.fillRect(xIndex, yCount - yIndex - 1, 1, 1); } } return image; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/KeyedValueDataset.java0000644000175000017500000000334511173030414030072 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * KeyedValueDataset.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 13-Mar-2003 : Version 1 (DG); * */ package org.jfree.data.general; import org.jfree.data.KeyedValue; /** * A dataset containing a single value. */ public interface KeyedValueDataset extends KeyedValue, Dataset { // no new methods required } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/KeyedValues2DDataset.java0000644000175000017500000000375711173030414030452 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * KeyedValues2DDataset.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 13-Mar-2003 : Version 1 (DG); * 23-Apr-2003 : Switched CategoryDataset and KeyedValues2DDataset so that * CategoryDataset is the super interface (DG); * */ package org.jfree.data.general; import org.jfree.data.category.CategoryDataset; /** * A dataset containing (key, value) data items. This dataset is equivalent * to a {@link CategoryDataset} and is included for completeness only. */ public interface KeyedValues2DDataset extends CategoryDataset { // no new methods required } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/KeyedValuesDataset.java0000644000175000017500000000337411173030414030257 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * KeyedValuesDataset.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Mar-2003 : Version 1 (DG); * 24-Apr-2003 : Switched places with PieDataset (DG); * */ package org.jfree.data.general; /** * A dataset containing (key, value) data items. */ public interface KeyedValuesDataset extends PieDataset { // no new methods required } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/PieDataset.java0000644000175000017500000000435711173030414026555 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * PieDataset.java * --------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Sam (oldman); * * Changes * ------- * 17-Nov-2001 : Version 1 (DG); * 22-Jan-2002 : Removed the getCategoryCount() method, updated Javadoc * comments (DG); * 18-Apr-2002 : getCategories() now returns List instead of Set (oldman); * 23-Oct-2002 : Reorganised the code: PieDataset now extends KeyedValues * interface (DG); * 04-Mar-2003 : Now just replicates the KeyedValuesDataset interface (DG); * */ package org.jfree.data.general; import org.jfree.data.KeyedValues; /** * A general purpose dataset where values are associated with keys. As the * name suggests, you can use this dataset to supply data for pie charts (refer * to the {@link org.jfree.chart.plot.PiePlot} class). */ public interface PieDataset extends KeyedValues, Dataset { // no new methods added. } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/Series.java0000644000175000017500000002647711173030414025773 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * Series.java * ----------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 29-Nov-2001 : Added cloning and property change support (DG); * 30-Jan-2002 : Added a description attribute and changed the constructors to * protected (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Implemented Serializable (DG); * 01-May-2003 : Added equals() method (DG); * 26-Jun-2003 : Changed listener list to use EventListenerList - see bug * 757027 (DG); * 15-Oct-2003 : Added a flag to control whether or not change events are sent * to registered listeners (DG); * 19-May-2005 : Made abstract (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 04-May-2006 : Updated API docs (DG); * 26-Sep-2007 : Added isEmpty() and getItemCount() methods (DG); * */ package org.jfree.data.general; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.io.Serializable; import javax.swing.event.EventListenerList; import org.jfree.util.ObjectUtilities; /** * Base class representing a data series. Subclasses are left to implement the * actual data structures. *

* The series has two properties ("Key" and "Description") for which you can * register a PropertyChangeListener. *

* You can also register a {@link SeriesChangeListener} to receive notification * of changes to the series data. */ public abstract class Series implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6906561437538683581L; /** The key for the series. */ private Comparable key; /** A description of the series. */ private String description; /** Storage for registered change listeners. */ private EventListenerList listeners; /** Object to support property change notification. */ private PropertyChangeSupport propertyChangeSupport; /** A flag that controls whether or not changes are notified. */ private boolean notify; /** * Creates a new series with the specified key. * * @param key the series key (null not permitted). */ protected Series(Comparable key) { this(key, null); } /** * Creates a new series with the specified key and description. * * @param key the series key (null NOT permitted). * @param description the series description (null permitted). */ protected Series(Comparable key, String description) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.key = key; this.description = description; this.listeners = new EventListenerList(); this.propertyChangeSupport = new PropertyChangeSupport(this); this.notify = true; } /** * Returns the key for the series. * * @return The series key (never null). * * @see #setKey(Comparable) */ public Comparable getKey() { return this.key; } /** * Sets the key for the series and sends a PropertyChangeEvent * (with the property name "Key") to all registered listeners. * * @param key the key (null not permitted). * * @see #getKey() */ public void setKey(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable old = this.key; this.key = key; this.propertyChangeSupport.firePropertyChange("Key", old, key); } /** * Returns a description of the series. * * @return The series description (possibly null). * * @see #setDescription(String) */ public String getDescription() { return this.description; } /** * Sets the description of the series and sends a * PropertyChangeEvent to all registered listeners. * * @param description the description (null permitted). * * @see #getDescription() */ public void setDescription(String description) { String old = this.description; this.description = description; this.propertyChangeSupport.firePropertyChange("Description", old, description); } /** * Returns the flag that controls whether or not change events are sent to * registered listeners. * * @return A boolean. * * @see #setNotify(boolean) */ public boolean getNotify() { return this.notify; } /** * Sets the flag that controls whether or not change events are sent to * registered listeners. * * @param notify the new value of the flag. * * @see #getNotify() */ public void setNotify(boolean notify) { if (this.notify != notify) { this.notify = notify; fireSeriesChanged(); } } /** * Returns true if the series contains no data items, and * false otherwise. * * @return A boolean. * * @since 1.0.7 */ public boolean isEmpty() { return (getItemCount() == 0); } /** * Returns the number of data items in the series. * * @return The number of data items in the series. */ public abstract int getItemCount(); /** * Returns a clone of the series. *

* Notes: *

    *
  • No need to clone the name or description, since String object is * immutable.
  • *
  • We set the listener list to empty, since the listeners did not * register with the clone.
  • *
  • Same applies to the PropertyChangeSupport instance.
  • *
* * @return A clone of the series. * * @throws CloneNotSupportedException not thrown by this class, but * subclasses may differ. */ public Object clone() throws CloneNotSupportedException { Series clone = (Series) super.clone(); clone.listeners = new EventListenerList(); clone.propertyChangeSupport = new PropertyChangeSupport(clone); return clone; } /** * Tests the series for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Series)) { return false; } Series that = (Series) obj; if (!getKey().equals(that.getKey())) { return false; } if (!ObjectUtilities.equal(getDescription(), that.getDescription())) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = this.key.hashCode(); result = 29 * result + (this.description != null ? this.description.hashCode() : 0); return result; } /** * Registers an object with this series, to receive notification whenever * the series changes. *

* Objects being registered must implement the {@link SeriesChangeListener} * interface. * * @param listener the listener to register. */ public void addChangeListener(SeriesChangeListener listener) { this.listeners.add(SeriesChangeListener.class, listener); } /** * Deregisters an object, so that it not longer receives notification * whenever the series changes. * * @param listener the listener to deregister. */ public void removeChangeListener(SeriesChangeListener listener) { this.listeners.remove(SeriesChangeListener.class, listener); } /** * General method for signalling to registered listeners that the series * has been changed. */ public void fireSeriesChanged() { if (this.notify) { notifyListeners(new SeriesChangeEvent(this)); } } /** * Sends a change event to all registered listeners. * * @param event contains information about the event that triggered the * notification. */ protected void notifyListeners(SeriesChangeEvent event) { Object[] listenerList = this.listeners.getListenerList(); for (int i = listenerList.length - 2; i >= 0; i -= 2) { if (listenerList[i] == SeriesChangeListener.class) { ((SeriesChangeListener) listenerList[i + 1]).seriesChanged( event); } } } /** * Adds a property change listener to the series. * * @param listener the listener. */ public void addPropertyChangeListener(PropertyChangeListener listener) { this.propertyChangeSupport.addPropertyChangeListener(listener); } /** * Removes a property change listener from the series. * * @param listener The listener. */ public void removePropertyChangeListener(PropertyChangeListener listener) { this.propertyChangeSupport.removePropertyChangeListener(listener); } /** * Fires a property change event. * * @param property the property key. * @param oldValue the old value. * @param newValue the new value. */ protected void firePropertyChange(String property, Object oldValue, Object newValue) { this.propertyChangeSupport.firePropertyChange(property, oldValue, newValue); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/SeriesChangeEvent.java0000644000175000017500000000411411173030414030063 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * SeriesChangeEvent.java * ---------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 18-Aug-2003 : Implemented Serializable (DG); * */ package org.jfree.data.general; import java.io.Serializable; import java.util.EventObject; /** * An event with details of a change to a series. */ public class SeriesChangeEvent extends EventObject implements Serializable { /** For serialization. */ private static final long serialVersionUID = 1593866085210089052L; /** * Constructs a new event. * * @param source the source of the change event. */ public SeriesChangeEvent(Object source) { super(source); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/SeriesChangeListener.java0000644000175000017500000000402711173030414030572 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * SeriesChangeListener.java * ------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 26-Jun-2003 : Now extends EventListener so we can use the EventListenerList * mechanism (DG); * */ package org.jfree.data.general; import java.util.EventListener; /** * Methods for receiving notification of changes to a data series. */ public interface SeriesChangeListener extends EventListener { /** * Called when an observed series changes in some way. * * @param event information about the change. */ public void seriesChanged(SeriesChangeEvent event); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/SeriesDataset.java0000644000175000017500000000560711173030414027271 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * SeriesDataset.java * ------------------ * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Nov-2001 : Version 1 (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 19-May-2005 : Changed getSeriesName() --> getSeriesKey() and added indexOf() * method (DG); * */ package org.jfree.data.general; import org.jfree.data.category.CategoryDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.IntervalXYZDataset; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYZDataset; /** * The interface for a dataset consisting of one or many series of data. * * @see CategoryDataset * @see IntervalXYDataset * @see IntervalXYZDataset * @see XYDataset * @see XYZDataset */ public interface SeriesDataset extends Dataset { /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount(); /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for the series. */ public Comparable getSeriesKey(int series); /** * Returns the index of the series with the specified key, or -1 if there * is no such series in the dataset. * * @param seriesKey the series key (null permitted). * * @return The index, or -1. */ public int indexOf(Comparable seriesKey); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/SeriesException.java0000644000175000017500000000422111173030414027631 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * SeriesException.java * -------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 26-Mar-2002 : Modified to extend RuntimeException rather than Exception (DG); * 18-Aug-2003 : Implemented Serializable (DG); * */ package org.jfree.data.general; import java.io.Serializable; /** * A general purpose exception class for data series. */ public class SeriesException extends RuntimeException implements Serializable { /** For serialization. */ private static final long serialVersionUID = -3667048387550852940L; /** * Constructs a new series exception. * * @param message a message describing the exception. */ public SeriesException(String message) { super(message); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/SubSeriesDataset.java0000644000175000017500000003600011173030414027732 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * SubseriesDataset.java * --------------------- * (C) Copyright 2001-2009, by Bill Kelemen and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): Sylvain Vieujot; * David Gilbert (for Object Refinery Limited); * * Changes * ------- * 06-Dec-2001 : Version 1 (BK); * 05-Feb-2002 : Added SignalsDataset (and small change to HighLowDataset * interface) as requested by Sylvain Vieujot (DG); * 28-Feb-2002 : Fixed bug: missing map[series] in IntervalXYDataset and * SignalsDataset methods (BK); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 06-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 29-Nov-2005 : Removed SignalsDataset (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 04-Feb-2009 : Deprecated, this class won't be supported in version * 1.2.0 (DG); * */ package org.jfree.data.general; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; /** * This class will create a dataset with one or more series from another * {@link SeriesDataset}. * * @deprecated As of version 1.0.13. This class will be removed from * JFreeChart 1.2.0 onwards. Anyone needing this facility will need to * maintain it outside of JFreeChart. */ public class SubSeriesDataset extends AbstractIntervalXYDataset implements OHLCDataset, IntervalXYDataset, CombinationDataset { /** The parent dataset. */ private SeriesDataset parent = null; /** Storage for map. */ private int[] map; // maps our series into our parent's /** * Creates a SubSeriesDataset using one or more series from * parent. The series to use are passed as an array of int. * * @param parent underlying dataset * @param map int[] of series from parent to include in this Dataset */ public SubSeriesDataset(SeriesDataset parent, int[] map) { this.parent = parent; this.map = map; } /** * Creates a SubSeriesDataset using one series from parent. * The series to is passed as an int. * * @param parent underlying dataset * @param series series from parent to include in this Dataset */ public SubSeriesDataset(SeriesDataset parent, int series) { this(parent, new int[] {series}); } /////////////////////////////////////////////////////////////////////////// // From HighLowDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the high-value for the specified series and item. *

* Note: throws ClassCastException if the series if not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The high-value for the specified series and item. */ public Number getHigh(int series, int item) { return ((OHLCDataset) this.parent).getHigh(this.map[series], item); } /** * Returns the high-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. */ public double getHighValue(int series, int item) { double result = Double.NaN; Number high = getHigh(series, item); if (high != null) { result = high.doubleValue(); } return result; } /** * Returns the low-value for the specified series and item. *

* Note: throws ClassCastException if the series if not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The low-value for the specified series and item. */ public Number getLow(int series, int item) { return ((OHLCDataset) this.parent).getLow(this.map[series], item); } /** * Returns the low-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. */ public double getLowValue(int series, int item) { double result = Double.NaN; Number low = getLow(series, item); if (low != null) { result = low.doubleValue(); } return result; } /** * Returns the open-value for the specified series and item. *

* Note: throws ClassCastException if the series if not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The open-value for the specified series and item. */ public Number getOpen(int series, int item) { return ((OHLCDataset) this.parent).getOpen(this.map[series], item); } /** * Returns the open-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The open-value. */ public double getOpenValue(int series, int item) { double result = Double.NaN; Number open = getOpen(series, item); if (open != null) { result = open.doubleValue(); } return result; } /** * Returns the close-value for the specified series and item. *

* Note: throws ClassCastException if the series if not from a * {@link OHLCDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The close-value for the specified series and item. */ public Number getClose(int series, int item) { return ((OHLCDataset) this.parent).getClose(this.map[series], item); } /** * Returns the close-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. */ public double getCloseValue(int series, int item) { double result = Double.NaN; Number close = getClose(series, item); if (close != null) { result = close.doubleValue(); } return result; } /** * Returns the volume. *

* Note: throws ClassCastException if the series if not from a * {@link OHLCDataset}. * * @param series the series (zero based index). * @param item the item (zero based index). * * @return The volume. */ public Number getVolume(int series, int item) { return ((OHLCDataset) this.parent).getVolume(this.map[series], item); } /** * Returns the volume-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The volume-value. */ public double getVolumeValue(int series, int item) { double result = Double.NaN; Number volume = getVolume(series, item); if (volume != null) { result = volume.doubleValue(); } return result; } /////////////////////////////////////////////////////////////////////////// // From XYDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the X-value for the specified series and item. *

* Note: throws ClassCastException if the series if not from a * {@link XYDataset}. * * @param series the index of the series of interest (zero-based); * @param item the index of the item of interest (zero-based). * * @return The X-value for the specified series and item. */ public Number getX(int series, int item) { return ((XYDataset) this.parent).getX(this.map[series], item); } /** * Returns the Y-value for the specified series and item. *

* Note: throws ClassCastException if the series if not from a * {@link XYDataset}. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The Y-value for the specified series and item. */ public Number getY(int series, int item) { return ((XYDataset) this.parent).getY(this.map[series], item); } /** * Returns the number of items in a series. *

* Note: throws ClassCastException if the series if not from a * {@link XYDataset}. * * @param series the index of the series of interest (zero-based). * * @return The number of items in a series. */ public int getItemCount(int series) { return ((XYDataset) this.parent).getItemCount(this.map[series]); } /////////////////////////////////////////////////////////////////////////// // From SeriesDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the number of series in the dataset. * * @return The number of series in the dataset. */ public int getSeriesCount() { return this.map.length; } /** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The name of a series. */ public Comparable getSeriesKey(int series) { return this.parent.getSeriesKey(this.map[series]); } /////////////////////////////////////////////////////////////////////////// // From IntervalXYDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the starting X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The starting X value for the specified series and item. */ public Number getStartX(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getStartX( this.map[series], item ); } else { return getX(series, item); } } /** * Returns the ending X value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The ending X value for the specified series and item. */ public Number getEndX(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getEndX( this.map[series], item ); } else { return getX(series, item); } } /** * Returns the starting Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The starting Y value for the specified series and item. */ public Number getStartY(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getStartY( this.map[series], item ); } else { return getY(series, item); } } /** * Returns the ending Y value for the specified series and item. * * @param series the index of the series of interest (zero-based). * @param item the index of the item of interest (zero-based). * * @return The ending Y value for the specified series and item. */ public Number getEndY(int series, int item) { if (this.parent instanceof IntervalXYDataset) { return ((IntervalXYDataset) this.parent).getEndY( this.map[series], item ); } else { return getY(series, item); } } /////////////////////////////////////////////////////////////////////////// // New methods from CombinationDataset /////////////////////////////////////////////////////////////////////////// /** * Returns the parent Dataset of this combination. * * @return The parent Dataset of this combination. */ public SeriesDataset getParent() { return this.parent; } /** * Returns a map or indirect indexing form our series into parent's series. * * @return A map or indirect indexing form our series into parent's series. */ public int[] getMap() { return (int[]) this.map.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/ValueDataset.java0000644000175000017500000000334111173030414027104 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ValueDataset.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 27-Mar-2003 : Version 1 (DG); * */ package org.jfree.data.general; import org.jfree.data.Value; /** * An interface for a dataset that returns a single value. */ public interface ValueDataset extends Value, Dataset { // no additional methods required } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/WaferMapDataset.java0000644000175000017500000002112711173030414027534 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * WaferMapDataset.java * -------------------- * (C)opyright 2003-2008, by Robert Redburn and Contributors. * * Original Author: Robert Redburn; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 25-Nov-2003 : Version 1 contributed by Robert Redburn (with some * modifications to match style conventions) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.data.general; import java.util.Set; import java.util.TreeSet; import org.jfree.data.DefaultKeyedValues2D; /** * A dataset that can be used with the {@link org.jfree.chart.plot.WaferMapPlot} * class. */ public class WaferMapDataset extends AbstractDataset { /** * Storage structure for the data values (row key is chipx, column is * chipy) */ private DefaultKeyedValues2D data; /** wafer x dimension */ private int maxChipX; /** wafer y dimension */ private int maxChipY; /** space to draw between chips */ private double chipSpace; /** maximum value in this dataset */ private Double maxValue; /** minimum value in this dataset */ private Double minValue; /** default chip spacing */ private static final double DEFAULT_CHIP_SPACE = 1d; /** * Creates a new dataset using the default chipspace. * * @param maxChipX the wafer x-dimension. * @param maxChipY the wafer y-dimension. */ public WaferMapDataset(int maxChipX, int maxChipY) { this(maxChipX, maxChipY, null); } /** * Creates a new dataset. * * @param maxChipX the wafer x-dimension. * @param maxChipY the wafer y-dimension. * @param chipSpace the space between chips. */ public WaferMapDataset(int maxChipX, int maxChipY, Number chipSpace) { this.maxValue = new Double(Double.NEGATIVE_INFINITY); this.minValue = new Double(Double.POSITIVE_INFINITY); this.data = new DefaultKeyedValues2D(); this.maxChipX = maxChipX; this.maxChipY = maxChipY; if (chipSpace == null) { this.chipSpace = DEFAULT_CHIP_SPACE; } else { this.chipSpace = chipSpace.doubleValue(); } } /** * Sets a value in the dataset. * * @param value the value. * @param chipx the x-index for the chip. * @param chipy the y-index for the chip. */ public void addValue(Number value, Comparable chipx, Comparable chipy) { setValue(value, chipx, chipy); } /** * Adds a value to the dataset. * * @param v the value. * @param x the x-index. * @param y the y-index. */ public void addValue(int v, int x, int y) { setValue(new Double(v), new Integer(x), new Integer(y)); } /** * Sets a value in the dataset and updates min and max value entries. * * @param value the value. * @param chipx the x-index. * @param chipy the y-index. */ public void setValue(Number value, Comparable chipx, Comparable chipy) { this.data.setValue(value, chipx, chipy); if (isMaxValue(value)) { this.maxValue = (Double) value; } if (isMinValue(value)) { this.minValue = (Double) value; } } /** * Returns the number of unique values. * * @return The number of unique values. */ public int getUniqueValueCount() { return getUniqueValues().size(); } /** * Returns the set of unique values. * * @return The set of unique values. */ public Set getUniqueValues() { Set unique = new TreeSet(); //step through all the values and add them to the hash for (int r = 0; r < this.data.getRowCount(); r++) { for (int c = 0; c < this.data.getColumnCount(); c++) { Number value = this.data.getValue(r, c); if (value != null) { unique.add(value); } } } return unique; } /** * Returns the data value for a chip. * * @param chipx the x-index. * @param chipy the y-index. * * @return The data value. */ public Number getChipValue(int chipx, int chipy) { return getChipValue(new Integer(chipx), new Integer(chipy)); } /** * Returns the value for a given chip x and y or null. * * @param chipx the x-index. * @param chipy the y-index. * * @return The data value. */ public Number getChipValue(Comparable chipx, Comparable chipy) { int rowIndex = this.data.getRowIndex(chipx); if (rowIndex < 0) { return null; } int colIndex = this.data.getColumnIndex(chipy); if (colIndex < 0) { return null; } return this.data.getValue(rowIndex, colIndex); } /** * Tests to see if the passed value is larger than the stored maxvalue. * * @param check the number to check. * * @return A boolean. */ public boolean isMaxValue(Number check) { if (check.doubleValue() > this.maxValue.doubleValue()) { return true; } return false; } /** * Tests to see if the passed value is smaller than the stored minvalue. * * @param check the number to check. * * @return A boolean. */ public boolean isMinValue(Number check) { if (check.doubleValue() < this.minValue.doubleValue()) { return true; } return false; } /** * Returns the maximum value stored in the dataset. * * @return The maximum value. */ public Number getMaxValue() { return this.maxValue; } /** * Returns the minimum value stored in the dataset. * * @return The minimum value. */ public Number getMinValue() { return this.minValue; } /** * Returns the wafer x-dimension. * * @return The number of chips in the x-dimension. */ public int getMaxChipX() { return this.maxChipX; } /** * Sets wafer x dimension. * * @param maxChipX the number of chips in the x-dimension. */ public void setMaxChipX(int maxChipX) { this.maxChipX = maxChipX; } /** * Returns the number of chips in the y-dimension. * * @return The number of chips. */ public int getMaxChipY() { return this.maxChipY; } /** * Sets the number of chips in the y-dimension. * * @param maxChipY the number of chips. */ public void setMaxChipY(int maxChipY) { this.maxChipY = maxChipY; } /** * Returns the space to draw between chips. * * @return The space. */ public double getChipSpace() { return this.chipSpace; } /** * Sets the space to draw between chips. * * @param space the space. */ public void setChipSpace(double space) { this.chipSpace = space; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/general/package.html0000644000175000017500000000021111173030414026131 0ustar vincentvincent Data interfaces and classes. libjfreechart-java-1.0.13.orig/source/org/jfree/data/io/0000755000175000017500000000000011216245562022662 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/io/CSV.java0000644000175000017500000001535211173030414024154 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------- * CSV.java * -------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 24-Nov-2003 : Version 1 (DG); * */ package org.jfree.data.io; import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; import java.util.List; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; /** * A utility class for reading {@link CategoryDataset} data from a CSV file. * This initial version is very basic, and won't handle errors in the data * file very gracefully. */ public class CSV { /** The field delimiter. */ private char fieldDelimiter; /** The text delimiter. */ private char textDelimiter; /** * Creates a new CSV reader where the field delimiter is a comma, and the * text delimiter is a double-quote. */ public CSV() { this(',', '"'); } /** * Creates a new reader with the specified field and text delimiters. * * @param fieldDelimiter the field delimiter (usually a comma, semi-colon, * colon, tab or space). * @param textDelimiter the text delimiter (usually a single or double * quote). */ public CSV(char fieldDelimiter, char textDelimiter) { this.fieldDelimiter = fieldDelimiter; this.textDelimiter = textDelimiter; } /** * Reads a {@link CategoryDataset} from a CSV file or input source. * * @param in the input source. * * @return A category dataset. * * @throws IOException if there is an I/O problem. */ public CategoryDataset readCategoryDataset(Reader in) throws IOException { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); BufferedReader reader = new BufferedReader(in); List columnKeys = null; int lineIndex = 0; String line = reader.readLine(); while (line != null) { if (lineIndex == 0) { // first line contains column keys columnKeys = extractColumnKeys(line); } else { // remaining lines contain a row key and data values extractRowKeyAndData(line, dataset, columnKeys); } line = reader.readLine(); lineIndex++; } return dataset; } /** * Extracts the column keys from a string. * * @param line a line from the input file. * * @return A list of column keys. */ private List extractColumnKeys(String line) { List keys = new java.util.ArrayList(); int fieldIndex = 0; int start = 0; for (int i = 0; i < line.length(); i++) { if (line.charAt(i) == this.fieldDelimiter) { if (fieldIndex > 0) { // first field is ignored, since // column 0 is for row keys String key = line.substring(start, i); keys.add(removeStringDelimiters(key)); } start = i + 1; fieldIndex++; } } String key = line.substring(start, line.length()); keys.add(removeStringDelimiters(key)); return keys; } /** * Extracts the row key and data for a single line from the input source. * * @param line the line from the input source. * @param dataset the dataset to be populated. * @param columnKeys the column keys. */ private void extractRowKeyAndData(String line, DefaultCategoryDataset dataset, List columnKeys) { Comparable rowKey = null; int fieldIndex = 0; int start = 0; for (int i = 0; i < line.length(); i++) { if (line.charAt(i) == this.fieldDelimiter) { if (fieldIndex == 0) { // first field contains the row key String key = line.substring(start, i); rowKey = removeStringDelimiters(key); } else { // remaining fields contain values Double value = Double.valueOf( removeStringDelimiters(line.substring(start, i)) ); dataset.addValue( value, rowKey, (Comparable) columnKeys.get(fieldIndex - 1) ); } start = i + 1; fieldIndex++; } } Double value = Double.valueOf( removeStringDelimiters(line.substring(start, line.length())) ); dataset.addValue( value, rowKey, (Comparable) columnKeys.get(fieldIndex - 1) ); } /** * Removes the string delimiters from a key (as well as any white space * outside the delimiters). * * @param key the key (including delimiters). * * @return The key without delimiters. */ private String removeStringDelimiters(String key) { String k = key.trim(); if (k.charAt(0) == this.textDelimiter) { k = k.substring(1); } if (k.charAt(k.length() - 1) == this.textDelimiter) { k = k.substring(0, k.length() - 1); } return k; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/io/package.html0000644000175000017500000000023411173030414025130 0ustar vincentvincent Miscellaneous support for input/output of data. libjfreechart-java-1.0.13.orig/source/org/jfree/data/jdbc/0000755000175000017500000000000011216245562023155 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/jdbc/JDBCCategoryDataset.java0000644000175000017500000003004111173030414027512 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * JDBCCategoryDataset.java * ------------------------ * (C) Copyright 2002-2008, by Bryan Scott and Contributors. * * Original Author: Bryan Scott; Andy; * Contributor(s): David Gilbert (for Object Refinery Limited); * Thomas Morgner; * * Changes * ------- * 26-Apr-2002 : Creation based on JdbcXYDataSet, using code contributed from * Andy; * 13-Aug-2002 : Updated Javadocs, import statements and formatting (DG); * 03-Sep-2002 : Added fix for bug 591385 (DG); * 18-Sep-2002 : Updated to support BIGINT (BS); * 16-Oct-2002 : Added fix for bug 586667 (DG); * 03-Feb-2003 : Added Types.DECIMAL (see bug report 677814) (DG); * 13-Jun-2003 : Added Types.TIME as suggest by Bryan Scott in the forum (DG); * 30-Jun-2003 : CVS Write test (BS); * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) * method (BS); * 29-Aug-2003 : Added a 'transpose' flag, so that data can be easily * transposed if required (DG); * 10-Sep-2003 : Added support for additional JDBC types (DG); * 24-Sep-2003 : Added clearing results from previous queries to executeQuery * following being highlighted on online forum (BS); * 02-Dec-2003 : Throwing exceptions allows to handle errors, removed default * constructor, as without a connection, a query can never be * executed (TM); * 04-Dec-2003 : Added missing Javadocs (DG); * ------------- JFREECHART 1.0.0 --------------------------------------------- * 08-Mar-2006 : Fixed bug 1445748 where an exception is thrown if * executeQuery() is called more than once (DG); * */ package org.jfree.data.jdbc; import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; /** * A {@link CategoryDataset} implementation over a database JDBC result set. * The dataset is populated via a call to {@link #executeQuery(String)} with * the string SQL query. The SQL query must return at least two columns. The * first column will be the category name and remaining columns values (each * column represents a series). Subsequent calls to * {@link #executeQuery(String)} will refresh the dataset. *

* The database connection is read-only and no write back facility exists. *

* NOTE: Many people have found this class too restrictive in general use. * For the greatest flexibility, please consider writing your own code to read * data from a ResultSet and populate a * {@link DefaultCategoryDataset} directly. */ public class JDBCCategoryDataset extends DefaultCategoryDataset { /** For serialization. */ static final long serialVersionUID = -3080395327918844965L; /** The database connection. */ private transient Connection connection; /** * A flag the controls whether or not the table is transposed. The default * is 'true' because this provides the behaviour described in the * documentation. */ private boolean transpose = true; /** * Creates a new dataset with a database connection. * * @param url the URL of the database connection. * @param driverName the database driver class name. * @param user the database user. * @param passwd the database user's password. * * @throws ClassNotFoundException if the driver cannot be found. * @throws SQLException if there is an error obtaining a connection to the * database. */ public JDBCCategoryDataset(String url, String driverName, String user, String passwd) throws ClassNotFoundException, SQLException { Class.forName(driverName); this.connection = DriverManager.getConnection(url, user, passwd); } /** * Create a new dataset with the given database connection. * * @param connection the database connection. */ public JDBCCategoryDataset(Connection connection) { if (connection == null) { throw new NullPointerException("A connection must be supplied."); } this.connection = connection; } /** * Creates a new dataset with the given database connection, and executes * the supplied query to populate the dataset. * * @param connection the connection. * @param query the query. * * @throws SQLException if there is a problem executing the query. */ public JDBCCategoryDataset(Connection connection, String query) throws SQLException { this(connection); executeQuery(query); } /** * Returns a flag that controls whether or not the table values are * transposed when added to the dataset. * * @return A boolean. */ public boolean getTranspose() { return this.transpose; } /** * Sets a flag that controls whether or not the table values are transposed * when added to the dataset. * * @param transpose the flag. */ public void setTranspose(boolean transpose) { this.transpose = transpose; } /** * Populates the dataset by executing the supplied query against the * existing database connection. If no connection exists then no action * is taken. *

* The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query. * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(String query) throws SQLException { executeQuery(this.connection, query); } /** * Populates the dataset by executing the supplied query against the * existing database connection. If no connection exists then no action * is taken. *

* The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param con the connection. * @param query the query. * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(Connection con, String query) throws SQLException { Statement statement = null; ResultSet resultSet = null; try { statement = con.createStatement(); resultSet = statement.executeQuery(query); ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); if (columnCount < 2) { throw new SQLException( "JDBCCategoryDataset.executeQuery() : insufficient columns " + "returned from the database."); } // Remove any previous old data int i = getRowCount(); while (--i >= 0) { removeRow(i); } while (resultSet.next()) { // first column contains the row key... Comparable rowKey = resultSet.getString(1); for (int column = 2; column <= columnCount; column++) { Comparable columnKey = metaData.getColumnName(column); int columnType = metaData.getColumnType(column); switch (columnType) { case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.FLOAT: case Types.DOUBLE: case Types.DECIMAL: case Types.NUMERIC: case Types.REAL: { Number value = (Number) resultSet.getObject(column); if (this.transpose) { setValue(value, columnKey, rowKey); } else { setValue(value, rowKey, columnKey); } break; } case Types.DATE: case Types.TIME: case Types.TIMESTAMP: { Date date = (Date) resultSet.getObject(column); Number value = new Long(date.getTime()); if (this.transpose) { setValue(value, columnKey, rowKey); } else { setValue(value, rowKey, columnKey); } break; } case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: { String string = (String) resultSet.getObject(column); try { Number value = Double.valueOf(string); if (this.transpose) { setValue(value, columnKey, rowKey); } else { setValue(value, rowKey, columnKey); } } catch (NumberFormatException e) { // suppress (value defaults to null) } break; } default: // not a value, can't use it (defaults to null) break; } } } fireDatasetChanged(); } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { // report this? } } if (statement != null) { try { statement.close(); } catch (Exception e) { // report this? } } } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/jdbc/JDBCPieDataset.java0000644000175000017500000002172611173030414026464 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * JDBCPieDataset.java * ------------------- * (C) Copyright 2002-2008, by Bryan Scott and Contributors. * * Original Author: Bryan Scott; Andy * Contributor(s): David Gilbert (for Object Refinery Limited); * Thomas Morgner; * * Changes * ------- * 26-Apr-2002 : Creation based on JdbcXYDataSet, but extending * DefaultPieDataset (BS); * 24-Jun-2002 : Removed unnecessary import and local variable (DG); * 13-Aug-2002 : Updated Javadoc comments and imports, removed default * constructor (DG); * 18-Sep-2002 : Updated to support BIGINT (BS); * 21-Jan-2003 : Renamed JdbcPieDataset --> JDBCPieDataset (DG); * 03-Feb-2003 : Added Types.DECIMAL (see bug report 677814) (DG); * 05-Jun-2003 : Updated to support TIME, optimised executeQuery method (BS); * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) * method (BS); * 02-Dec-2003 : Throwing exceptions allows to handle errors, removed default * constructor, as without a connection, a query can never be * executed (TM); * 04-Dec-2003 : Added missing Javadocs (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; import java.sql.Types; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; /** * A {@link PieDataset} that reads data from a database via JDBC. *

* A query should be supplied that returns data in two columns, the first * containing VARCHAR data, and the second containing numerical data. The * data is cached in-memory and can be refreshed at any time. */ public class JDBCPieDataset extends DefaultPieDataset { /** For serialization. */ static final long serialVersionUID = -8753216855496746108L; /** The database connection. */ private transient Connection connection; /** * Creates a new JDBCPieDataset and establishes a new database connection. * * @param url the URL of the database connection. * @param driverName the database driver class name. * @param user the database user. * @param password the database users password. * * @throws ClassNotFoundException if the driver cannot be found. * @throws SQLException if there is a problem obtaining a database * connection. */ public JDBCPieDataset(String url, String driverName, String user, String password) throws SQLException, ClassNotFoundException { Class.forName(driverName); this.connection = DriverManager.getConnection(url, user, password); } /** * Creates a new JDBCPieDataset using a pre-existing database connection. *

* The dataset is initially empty, since no query has been supplied yet. * * @param con the database connection. */ public JDBCPieDataset(Connection con) { if (con == null) { throw new NullPointerException("A connection must be supplied."); } this.connection = con; } /** * Creates a new JDBCPieDataset using a pre-existing database connection. *

* The dataset is initialised with the supplied query. * * @param con the database connection. * @param query the database connection. * * @throws SQLException if there is a problem executing the query. */ public JDBCPieDataset(Connection con, String query) throws SQLException { this(con); executeQuery(query); } /** * ExecuteQuery will attempt execute the query passed to it against the * existing database connection. If no connection exists then no action * is taken. * The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query to be executed. * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(String query) throws SQLException { executeQuery(this.connection, query); } /** * ExecuteQuery will attempt execute the query passed to it against the * existing database connection. If no connection exists then no action * is taken. * The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query to be executed * @param con the connection the query is to be executed against * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(Connection con, String query) throws SQLException { Statement statement = null; ResultSet resultSet = null; try { statement = con.createStatement(); resultSet = statement.executeQuery(query); ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); if (columnCount != 2) { throw new SQLException( "Invalid sql generated. PieDataSet requires 2 columns only" ); } int columnType = metaData.getColumnType(2); double value = Double.NaN; while (resultSet.next()) { Comparable key = resultSet.getString(1); switch (columnType) { case Types.NUMERIC: case Types.REAL: case Types.INTEGER: case Types.DOUBLE: case Types.FLOAT: case Types.DECIMAL: case Types.BIGINT: value = resultSet.getDouble(2); setValue(key, value); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: Timestamp date = resultSet.getTimestamp(2); value = date.getTime(); setValue(key, value); break; default: System.err.println( "JDBCPieDataset - unknown data type" ); break; } } fireDatasetChanged(); } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { System.err.println("JDBCPieDataset: swallowing exception."); } } if (statement != null) { try { statement.close(); } catch (Exception e) { System.err.println("JDBCPieDataset: swallowing exception."); } } } } /** * Close the database connection */ public void close() { try { this.connection.close(); } catch (Exception e) { System.err.println("JdbcXYDataset: swallowing exception."); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/jdbc/JDBCXYDataset.java0000644000175000017500000004771411173030414026314 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * JDBCXYDataset.java * ------------------ * (C) Copyright 2002-2008, by Bryan Scott and Contributors. * * Original Author: Bryan Scott; * Contributor(s): David Gilbert (for Object Refinery Limited); * Eric Alexander; * * * Changes * ------- * 14-Mar-2002 : Version 1 contributed by Bryan Scott (DG); * 19-Apr-2002 : Updated executeQuery, to close cursors and to improve support * for types. * 26-Apr-2002 : Renamed JdbcXYDataset to better fit in with the existing data * source conventions. * 26-Apr-2002 : Changed to extend AbstractDataset. * 13-Aug-2002 : Updated Javadoc comments and imports (DG); * 18-Sep-2002 : Updated to support BIGINT (BS); * 21-Jan-2003 : Renamed JdbcXYDataset --> JDBCXYDataset (DG); * 01-Jul-2003 : Added support to query whether a timeseries (BS); * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) * method (BS); * 24-Sep-2003 : Added a check to ensure at least two valid columns are * returned by the query in executeQuery as suggest in online * forum by anonymous (BS); * 02-Dec-2003 : Throwing exceptions allows to handle errors, removed default * constructor, as without a connection, a query can never be * executed. * 16-Mar-2004 : Added check for null values (EA); * 05-May-2004 : Now extends AbstractXYDataset (DG); * 21-May-2004 : Implemented TableXYDataset, added support for SMALLINT and * fixed bug in code that determines the min and max values (see * bug id 938138) (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 18-Nov-2004 : Updated for changes in RangeInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 17-Oct-2006 : Deprecated unused methods - see bug 1578293 (DG); * */ package org.jfree.data.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import java.util.ArrayList; import java.util.Date; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.Dataset; import org.jfree.data.xy.AbstractXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.Log; /** * This class provides an {@link XYDataset} implementation over a database * JDBC result set. The dataset is populated via a call to executeQuery with * the string sql query. The sql query must return at least two columns. * The first column will be the x-axis and remaining columns y-axis values. * executeQuery can be called a number of times. * * The database connection is read-only and no write back facility exists. */ public class JDBCXYDataset extends AbstractXYDataset implements XYDataset, TableXYDataset, RangeInfo { /** The database connection. */ private transient Connection connection; /** Column names. */ private String[] columnNames = {}; /** Rows. */ private ArrayList rows; /** The maximum y value of the returned result set */ private double maxValue = 0.0; /** The minimum y value of the returned result set */ private double minValue = 0.0; /** Is this dataset a timeseries ? */ private boolean isTimeSeries = false; /** * Creates a new JDBCXYDataset (initially empty) with no database * connection. */ private JDBCXYDataset() { this.rows = new ArrayList(); } /** * Creates a new dataset (initially empty) and establishes a new database * connection. * * @param url URL of the database connection. * @param driverName the database driver class name. * @param user the database user. * @param password the database user's password. * * @throws ClassNotFoundException if the driver cannot be found. * @throws SQLException if there is a problem connecting to the database. */ public JDBCXYDataset(String url, String driverName, String user, String password) throws SQLException, ClassNotFoundException { this(); Class.forName(driverName); this.connection = DriverManager.getConnection(url, user, password); } /** * Creates a new dataset (initially empty) using the specified database * connection. * * @param con the database connection. * * @throws SQLException if there is a problem connecting to the database. */ public JDBCXYDataset(Connection con) throws SQLException { this(); this.connection = con; } /** * Creates a new dataset using the specified database connection, and * populates it using data obtained with the supplied query. * * @param con the connection. * @param query the SQL query. * * @throws SQLException if there is a problem executing the query. */ public JDBCXYDataset(Connection con, String query) throws SQLException { this(con); executeQuery(query); } /** * Returns true if the dataset represents time series data, * and false otherwise. * * @return A boolean. */ public boolean isTimeSeries() { return this.isTimeSeries; } /** * Sets a flag that indicates whether or not the data represents a time * series. * * @param timeSeries the new value of the flag. */ public void setTimeSeries(boolean timeSeries) { this.isTimeSeries = timeSeries; } /** * ExecuteQuery will attempt execute the query passed to it against the * existing database connection. If no connection exists then no action * is taken. * * The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query to be executed. * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(String query) throws SQLException { executeQuery(this.connection, query); } /** * ExecuteQuery will attempt execute the query passed to it against the * provided database connection. If connection is null then no action is * taken. * * The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query to be executed. * @param con the connection the query is to be executed against. * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(Connection con, String query) throws SQLException { if (con == null) { throw new SQLException( "There is no database to execute the query." ); } ResultSet resultSet = null; Statement statement = null; try { statement = con.createStatement(); resultSet = statement.executeQuery(query); ResultSetMetaData metaData = resultSet.getMetaData(); int numberOfColumns = metaData.getColumnCount(); int numberOfValidColumns = 0; int [] columnTypes = new int[numberOfColumns]; for (int column = 0; column < numberOfColumns; column++) { try { int type = metaData.getColumnType(column + 1); switch (type) { case Types.NUMERIC: case Types.REAL: case Types.INTEGER: case Types.DOUBLE: case Types.FLOAT: case Types.DECIMAL: case Types.BIT: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: case Types.BIGINT: case Types.SMALLINT: ++numberOfValidColumns; columnTypes[column] = type; break; default: Log.warn( "Unable to load column " + column + " (" + type + "," + metaData.getColumnClassName(column + 1) + ")" ); columnTypes[column] = Types.NULL; break; } } catch (SQLException e) { columnTypes[column] = Types.NULL; throw e; } } if (numberOfValidColumns <= 1) { throw new SQLException( "Not enough valid columns where generated by query." ); } /// First column is X data this.columnNames = new String[numberOfValidColumns - 1]; /// Get the column names and cache them. int currentColumn = 0; for (int column = 1; column < numberOfColumns; column++) { if (columnTypes[column] != Types.NULL) { this.columnNames[currentColumn] = metaData.getColumnLabel(column + 1); ++currentColumn; } } // Might need to add, to free memory from any previous result sets if (this.rows != null) { for (int column = 0; column < this.rows.size(); column++) { ArrayList row = (ArrayList) this.rows.get(column); row.clear(); } this.rows.clear(); } // Are we working with a time series. switch (columnTypes[0]) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: this.isTimeSeries = true; break; default : this.isTimeSeries = false; break; } // Get all rows. // rows = new ArrayList(); while (resultSet.next()) { ArrayList newRow = new ArrayList(); for (int column = 0; column < numberOfColumns; column++) { Object xObject = resultSet.getObject(column + 1); switch (columnTypes[column]) { case Types.NUMERIC: case Types.REAL: case Types.INTEGER: case Types.DOUBLE: case Types.FLOAT: case Types.DECIMAL: case Types.BIGINT: case Types.SMALLINT: newRow.add(xObject); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: newRow.add(new Long(((Date) xObject).getTime())); break; case Types.NULL: break; default: System.err.println("Unknown data"); columnTypes[column] = Types.NULL; break; } } this.rows.add(newRow); } /// a kludge to make everything work when no rows returned if (this.rows.size() == 0) { ArrayList newRow = new ArrayList(); for (int column = 0; column < numberOfColumns; column++) { if (columnTypes[column] != Types.NULL) { newRow.add(new Integer(0)); } } this.rows.add(newRow); } /// Determine max and min values. if (this.rows.size() < 1) { this.maxValue = 0.0; this.minValue = 0.0; } else { ArrayList row = (ArrayList) this.rows.get(0); this.maxValue = Double.NEGATIVE_INFINITY; this.minValue = Double.POSITIVE_INFINITY; for (int rowNum = 0; rowNum < this.rows.size(); ++rowNum) { row = (ArrayList) this.rows.get(rowNum); for (int column = 1; column < numberOfColumns; column++) { Object testValue = row.get(column); if (testValue != null) { double test = ((Number) testValue).doubleValue(); if (test < this.minValue) { this.minValue = test; } if (test > this.maxValue) { this.maxValue = test; } } } } } fireDatasetChanged(); // Tell the listeners a new table has arrived. } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { // TODO: is this a good idea? } } if (statement != null) { try { statement.close(); } catch (Exception e) { // TODO: is this a good idea? } } } } /** * Returns the x-value for the specified series and item. The * implementation is responsible for ensuring that the x-values are * presented in ascending order. * * @param seriesIndex the series (zero-based index). * @param itemIndex the item (zero-based index). * * @return The x-value * * @see XYDataset */ public Number getX(int seriesIndex, int itemIndex) { ArrayList row = (ArrayList) this.rows.get(itemIndex); return (Number) row.get(0); } /** * Returns the y-value for the specified series and item. * * @param seriesIndex the series (zero-based index). * @param itemIndex the item (zero-based index). * * @return The yValue value * * @see XYDataset */ public Number getY(int seriesIndex, int itemIndex) { ArrayList row = (ArrayList) this.rows.get(itemIndex); return (Number) row.get(seriesIndex + 1); } /** * Returns the number of items in the specified series. * * @param seriesIndex the series (zero-based index). * * @return The itemCount value * * @see XYDataset */ public int getItemCount(int seriesIndex) { return this.rows.size(); } /** * Returns the number of items in all series. This method is defined by * the {@link TableXYDataset} interface. * * @return The item count. */ public int getItemCount() { return getItemCount(0); } /** * Returns the number of series in the dataset. * * @return The seriesCount value * * @see XYDataset * @see Dataset */ public int getSeriesCount() { return this.columnNames.length; } /** * Returns the key for the specified series. * * @param seriesIndex the series (zero-based index). * * @return The seriesName value * * @see XYDataset * @see Dataset */ public Comparable getSeriesKey(int seriesIndex) { if ((seriesIndex < this.columnNames.length) && (this.columnNames[seriesIndex] != null)) { return this.columnNames[seriesIndex]; } else { return ""; } } /** * Returns the number of items that should be displayed in the legend. * * @return The legendItemCount value * * @deprecated This method is not used in JFreeChart 1.0.x (it was left in * the API by mistake and is officially deprecated from version 1.0.3 * onwards). */ public int getLegendItemCount() { return getSeriesCount(); } /** * Returns the legend item labels. * * @return The legend item labels. * * @deprecated This method is not used in JFreeChart 1.0.x (it was left in * the API by mistake and is officially deprecated from version 1.0.3 * onwards). */ public String[] getLegendItemLabels() { return this.columnNames; } /** * Close the database connection */ public void close() { try { this.connection.close(); } catch (Exception e) { System.err.println("JdbcXYDataset: swallowing exception."); } } /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. */ public double getRangeLowerBound(boolean includeInterval) { return this.minValue; } /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ public double getRangeUpperBound(boolean includeInterval) { return this.maxValue; } /** * Returns the range of the values in this dataset's range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range. */ public Range getRangeBounds(boolean includeInterval) { return new Range(this.minValue, this.maxValue); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/jdbc/package.html0000644000175000017500000000024611173030414025426 0ustar vincentvincent Dataset classes that fetch data from a database via JDBC. libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/0000755000175000017500000000000011216245562024265 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/DataPackageResources.java0000644000175000017500000000431511173030414031141 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * DataPackageResources.java * ------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.data.resources; import java.util.ListResourceBundle; /** * A resource bundle that stores all the items that might need localisation. * */ public class DataPackageResources extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The localised resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"series.default-prefix", "Series"}, {"categories.default-prefix", "Category"}, }; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/DataPackageResources_de.java0000644000175000017500000000453011173030414031610 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DataPackageResources_de.java * ---------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: Thomas Meier; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 04-Apr-2002 : Version 1, translation by Thomas Meier (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.resources; import java.util.ListResourceBundle; /** * A resource bundle that stores all the items that might need localisation. */ public class DataPackageResources_de extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The localised resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"series.default-prefix", "Reihen"}, {"categories.default-prefix", "Kategorien"}, }; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/DataPackageResources_es.java0000644000175000017500000000454711173030414031637 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DataPackageResources_es.java * ---------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Hans-Jurgen Greiner; * * Changes * ------- * 26-Mar-2002 : Version 1, translation by Hans-Jurgen Greiner (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.resources; import java.util.ListResourceBundle; /** * A resource bundle that stores all the items that might need localisation. */ public class DataPackageResources_es extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The localised resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"series.default-prefix", "Series"}, {"categories.default-prefix", "Categor?a"}, }; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/DataPackageResources_fr.java0000644000175000017500000000430611173030414031630 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DataPackageResources_fr.java * ---------------------------- * * Original Author: Anthony Boulestreau; * Contributor(s): -; * * Changes * ------- * 26-Mar-2002 : Version 1 (AB); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.resources; import java.util.ListResourceBundle; /** * A resource bundle that stores all the items that might need localisation. */ public class DataPackageResources_fr extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The localised resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"series.default-prefix", "S?ries"}, {"categories.default-prefix", "Cat?gorie"}, }; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/DataPackageResources_pl.java0000644000175000017500000000453511173030414031640 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DataPackageResources_pl.java * ---------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * Polish translation: Krzysztof Pa? (kpaz@samorzad.pw.edu.pl) * * Changes * ------- * 21-Mar-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.resources; import java.util.ListResourceBundle; /** * A resource bundle that stores all the items that might need localisation. */ public class DataPackageResources_pl extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The localised resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"series.default-prefix", "Serie"}, {"categories.default-prefix", "Kategorie"}, }; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/DataPackageResources_ru.java0000644000175000017500000000414511173030414031650 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DataPackageResources_ru.java * ---------------------------- * * Original Author: Sergey Bondarenko; * Contributor(s): -; * * Changes * ------- * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.resources; import java.util.ListResourceBundle; /** * A resource bundle that stores all the items that might need localisation. */ public class DataPackageResources_ru extends ListResourceBundle { /** * Returns the array of strings in the resource bundle. * * @return The localised resources. */ public Object[][] getContents() { return CONTENTS; } /** The resources to be localised. */ private static final Object[][] CONTENTS = { {"series.default-prefix", "?????"}, {"categories.default-prefix", "?????????"}, }; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/resources/package.html0000644000175000017500000000024211173030414026532 0ustar vincentvincent Resource bundles for items that require localisation. libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/0000755000175000017500000000000011216245562024445 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/BoxAndWhiskerCalculator.java0000644000175000017500000002172511173030414032027 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * BoxAndWhiskerCalculator.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Aug-2003 : Version 1 (DG); * 17-Nov-2003 : Fixed bug in calculations of outliers and median (DG); * 10-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 * release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 15-Nov-2006 : Cleaned up handling of null arguments, and null or NaN items * in the list (DG); * */ package org.jfree.data.statistics; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; /** * A utility class that calculates the mean, median, quartiles Q1 and Q3, plus * a list of outlier values...all from an arbitrary list of * Number objects. */ public abstract class BoxAndWhiskerCalculator { /** * Calculates the statistics required for a {@link BoxAndWhiskerItem} * from a list of Number objects. Any items in the list * that are null, not an instance of Number, or * equivalent to Double.NaN, will be ignored. * * @param values a list of numbers (a null list is not * permitted). * * @return A box-and-whisker item. */ public static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics( List values) { return calculateBoxAndWhiskerStatistics(values, true); } /** * Calculates the statistics required for a {@link BoxAndWhiskerItem} * from a list of Number objects. Any items in the list * that are null, not an instance of Number, or * equivalent to Double.NaN, will be ignored. * * @param values a list of numbers (a null list is not * permitted). * @param stripNullAndNaNItems a flag that controls the handling of null * and NaN items. * * @return A box-and-whisker item. * * @since 1.0.3 */ public static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics( List values, boolean stripNullAndNaNItems) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } List vlist; if (stripNullAndNaNItems) { vlist = new ArrayList(values.size()); Iterator iterator = values.listIterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof Number) { Number n = (Number) obj; double v = n.doubleValue(); if (!Double.isNaN(v)) { vlist.add(n); } } } } else { vlist = values; } Collections.sort(vlist); double mean = Statistics.calculateMean(vlist, false); double median = Statistics.calculateMedian(vlist, false); double q1 = calculateQ1(vlist); double q3 = calculateQ3(vlist); double interQuartileRange = q3 - q1; double upperOutlierThreshold = q3 + (interQuartileRange * 1.5); double lowerOutlierThreshold = q1 - (interQuartileRange * 1.5); double upperFaroutThreshold = q3 + (interQuartileRange * 2.0); double lowerFaroutThreshold = q1 - (interQuartileRange * 2.0); double minRegularValue = Double.POSITIVE_INFINITY; double maxRegularValue = Double.NEGATIVE_INFINITY; double minOutlier = Double.POSITIVE_INFINITY; double maxOutlier = Double.NEGATIVE_INFINITY; List outliers = new ArrayList(); Iterator iterator = vlist.iterator(); while (iterator.hasNext()) { Number number = (Number) iterator.next(); double value = number.doubleValue(); if (value > upperOutlierThreshold) { outliers.add(number); if (value > maxOutlier && value <= upperFaroutThreshold) { maxOutlier = value; } } else if (value < lowerOutlierThreshold) { outliers.add(number); if (value < minOutlier && value >= lowerFaroutThreshold) { minOutlier = value; } } else { minRegularValue = Math.min(minRegularValue, value); maxRegularValue = Math.max(maxRegularValue, value); } minOutlier = Math.min(minOutlier, minRegularValue); maxOutlier = Math.max(maxOutlier, maxRegularValue); } return new BoxAndWhiskerItem(new Double(mean), new Double(median), new Double(q1), new Double(q3), new Double(minRegularValue), new Double(maxRegularValue), new Double(minOutlier), new Double(maxOutlier), outliers); } /** * Calculates the first quartile for a list of numbers in ascending order. * If the items in the list are not in ascending order, the result is * unspecified. If the list contains items that are null, not * an instance of Number, or equivalent to * Double.NaN, the result is unspecified. * * @param values the numbers in ascending order (null not * permitted). * * @return The first quartile. */ public static double calculateQ1(List values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, 0, count / 2); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, 0, count / 2 - 1); } } return result; } /** * Calculates the third quartile for a list of numbers in ascending order. * If the items in the list are not in ascending order, the result is * unspecified. If the list contains items that are null, not * an instance of Number, or equivalent to * Double.NaN, the result is unspecified. * * @param values the list of values (null not permitted). * * @return The third quartile. */ public static double calculateQ3(List values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/BoxAndWhiskerCategoryDataset.java0000644000175000017500000001655411173030414033025 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * BoxAndWhiskerCategoryDataset.java * --------------------------------- * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): -; * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 27-Aug-2003 : Renamed getAverageValue --> getMeanValue, changed * getAllOutliers to return a List rather than an array (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.data.statistics; import java.util.List; import org.jfree.data.category.CategoryDataset; /** * A category dataset that defines various medians, outliers and an average * value for each item. */ public interface BoxAndWhiskerCategoryDataset extends CategoryDataset { /** * Returns the mean value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The mean value. */ public Number getMeanValue(int row, int column); /** * Returns the average value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The average value. */ public Number getMeanValue(Comparable rowKey, Comparable columnKey); /** * Returns the median value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The median value. */ public Number getMedianValue(int row, int column); /** * Returns the median value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The median value. */ public Number getMedianValue(Comparable rowKey, Comparable columnKey); /** * Returns the q1median value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The q1median value. */ public Number getQ1Value(int row, int column); /** * Returns the q1median value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The q1median value. */ public Number getQ1Value(Comparable rowKey, Comparable columnKey); /** * Returns the q3median value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The q3median value. */ public Number getQ3Value(int row, int column); /** * Returns the q3median value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The q3median value. */ public Number getQ3Value(Comparable rowKey, Comparable columnKey); /** * Returns the minimum regular (non-outlier) value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The minimum regular value. */ public Number getMinRegularValue(int row, int column); /** * Returns the minimum regular (non-outlier) value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The minimum regular value. */ public Number getMinRegularValue(Comparable rowKey, Comparable columnKey); /** * Returns the maximum regular (non-outlier) value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The maximum regular value. */ public Number getMaxRegularValue(int row, int column); /** * Returns the maximum regular (non-outlier) value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The maximum regular value. */ public Number getMaxRegularValue(Comparable rowKey, Comparable columnKey); /** * Returns the minimum outlier (non-farout) for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The minimum outlier. */ public Number getMinOutlier(int row, int column); /** * Returns the minimum outlier (non-farout) for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The minimum outlier. */ public Number getMinOutlier(Comparable rowKey, Comparable columnKey); /** * Returns the maximum outlier (non-farout) for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The maximum outlier. */ public Number getMaxOutlier(int row, int column); /** * Returns the maximum outlier (non-farout) for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The maximum outlier. */ public Number getMaxOutlier(Comparable rowKey, Comparable columnKey); /** * Returns a list of outlier values for an item. The list may be empty, * but should never be null. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return A list of outliers for an item. */ public List getOutliers(int row, int column); /** * Returns a list of outlier values for an item. The list may be empty, * but should never be null. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return A list of outlier values for an item. */ public List getOutliers(Comparable rowKey, Comparable columnKey); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/BoxAndWhiskerItem.java0000644000175000017500000002177111173030414030635 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * BoxAndWhiskerItem.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Aug-2003 : Version 1 (DG); * 01-Mar-2004 : Added equals() method and implemented Serializable (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 15-Nov-2006 : Added toString() method override (DG); * 02-Oct-2007 : Added new constructor (for convenience) (DG); * */ package org.jfree.data.statistics; import java.io.Serializable; import java.util.Collections; import java.util.List; import org.jfree.util.ObjectUtilities; /** * Represents one data item within a box-and-whisker dataset. Instances of * this class are immutable. */ public class BoxAndWhiskerItem implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7329649623148167423L; /** The mean. */ private Number mean; /** The median. */ private Number median; /** The first quarter. */ private Number q1; /** The third quarter. */ private Number q3; /** The minimum regular value. */ private Number minRegularValue; /** The maximum regular value. */ private Number maxRegularValue; /** The minimum outlier. */ private Number minOutlier; /** The maximum outlier. */ private Number maxOutlier; /** The outliers. */ private List outliers; /** * Creates a new box-and-whisker item. * * @param mean the mean (null permitted). * @param median the median (null permitted). * @param q1 the first quartile (null permitted). * @param q3 the third quartile (null permitted). * @param minRegularValue the minimum regular value (null * permitted). * @param maxRegularValue the maximum regular value (null * permitted). * @param minOutlier the minimum outlier (null permitted). * @param maxOutlier the maximum outlier (null permitted). * @param outliers the outliers (null permitted). */ public BoxAndWhiskerItem(Number mean, Number median, Number q1, Number q3, Number minRegularValue, Number maxRegularValue, Number minOutlier, Number maxOutlier, List outliers) { this.mean = mean; this.median = median; this.q1 = q1; this.q3 = q3; this.minRegularValue = minRegularValue; this.maxRegularValue = maxRegularValue; this.minOutlier = minOutlier; this.maxOutlier = maxOutlier; this.outliers = outliers; } /** * Creates a new box-and-whisker item. * * @param mean the mean. * @param median the median * @param q1 the first quartile. * @param q3 the third quartile. * @param minRegularValue the minimum regular value. * @param maxRegularValue the maximum regular value. * @param minOutlier the minimum outlier value. * @param maxOutlier the maximum outlier value. * @param outliers a list of the outliers. * * @since 1.0.7 */ public BoxAndWhiskerItem(double mean, double median, double q1, double q3, double minRegularValue, double maxRegularValue, double minOutlier, double maxOutlier, List outliers) { // pass values to other constructor this(new Double(mean), new Double(median), new Double(q1), new Double(q3), new Double(minRegularValue), new Double(maxRegularValue), new Double(minOutlier), new Double(maxOutlier), outliers); } /** * Returns the mean. * * @return The mean (possibly null). */ public Number getMean() { return this.mean; } /** * Returns the median. * * @return The median (possibly null). */ public Number getMedian() { return this.median; } /** * Returns the first quartile. * * @return The first quartile (possibly null). */ public Number getQ1() { return this.q1; } /** * Returns the third quartile. * * @return The third quartile (possibly null). */ public Number getQ3() { return this.q3; } /** * Returns the minimum regular value. * * @return The minimum regular value (possibly null). */ public Number getMinRegularValue() { return this.minRegularValue; } /** * Returns the maximum regular value. * * @return The maximum regular value (possibly null). */ public Number getMaxRegularValue() { return this.maxRegularValue; } /** * Returns the minimum outlier. * * @return The minimum outlier (possibly null). */ public Number getMinOutlier() { return this.minOutlier; } /** * Returns the maximum outlier. * * @return The maximum outlier (possibly null). */ public Number getMaxOutlier() { return this.maxOutlier; } /** * Returns a list of outliers. * * @return A list of outliers (possibly null). */ public List getOutliers() { if (this.outliers == null) { return null; } return Collections.unmodifiableList(this.outliers); } /** * Returns a string representation of this instance, primarily for * debugging purposes. * * @return A string representation of this instance. */ public String toString() { return super.toString() + "[mean=" + this.mean + ",median=" + this.median + ",q1=" + this.q1 + ",q3=" + this.q3 + "]"; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof BoxAndWhiskerItem)) { return false; } BoxAndWhiskerItem that = (BoxAndWhiskerItem) obj; if (!ObjectUtilities.equal(this.mean, that.mean)) { return false; } if (!ObjectUtilities.equal(this.median, that.median)) { return false; } if (!ObjectUtilities.equal(this.q1, that.q1)) { return false; } if (!ObjectUtilities.equal(this.q3, that.q3)) { return false; } if (!ObjectUtilities.equal(this.minRegularValue, that.minRegularValue)) { return false; } if (!ObjectUtilities.equal(this.maxRegularValue, that.maxRegularValue)) { return false; } if (!ObjectUtilities.equal(this.minOutlier, that.minOutlier)) { return false; } if (!ObjectUtilities.equal(this.maxOutlier, that.maxOutlier)) { return false; } if (!ObjectUtilities.equal(this.outliers, that.outliers)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/BoxAndWhiskerXYDataset.java0000644000175000017500000001475011173030414031604 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * BoxAndWhiskerXYDataset.java * --------------------------- * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 12-Aug-2003 : Added new methods: getMaxNonOutlierValue * getMaxNonFaroutValue * getOutlierCoefficient * setOutlierCoefficient * getFaroutCoefficient * setFaroutCoefficient * getInterquartileRange (DB) * 27-Aug-2003 : Renamed BoxAndWhiskerDataset --> BoxAndWhiskerXYDataset, and * cut down methods (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.data.statistics; import java.util.List; import org.jfree.data.xy.XYDataset; /** * An interface that defines data in the form of (x, max, min, average, median) * tuples. *

* Example: JFreeChart uses this interface to obtain data for AIMS * max-min-average-median plots. */ public interface BoxAndWhiskerXYDataset extends XYDataset { /** * Returns the mean for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The mean for the specified series and item. */ public Number getMeanValue(int series, int item); /** * Returns the median-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The median-value for the specified series and item. */ public Number getMedianValue(int series, int item); /** * Returns the Q1 median-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The Q1 median-value for the specified series and item. */ public Number getQ1Value(int series, int item); /** * Returns the Q3 median-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The Q3 median-value for the specified series and item. */ public Number getQ3Value(int series, int item); /** * Returns the min-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The min-value for the specified series and item. */ public Number getMinRegularValue(int series, int item); /** * Returns the max-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The max-value for the specified series and item. */ public Number getMaxRegularValue(int series, int item); /** * Returns the minimum value which is not a farout. * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A Number representing the maximum non-farout value. */ public Number getMinOutlier(int series, int item); /** * Returns the maximum value which is not a farout, ie Q3 + (interquartile * range * farout coefficient). * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A Number representing the maximum non-farout value. */ public Number getMaxOutlier(int series, int item); /** * Returns an array of outliers for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The array of outliers for the specified series and item. */ public List getOutliers(int series, int item); /** * Returns the value used as the outlier coefficient. The outlier * coefficient gives an indication of the degree of certainty in an * unskewed distribution. Increasing the coefficient increases the number * of values included. Currently only used to ensure farout coefficient * is greater than the outlier coefficient * * @return A double representing the value used to calculate * outliers */ public double getOutlierCoefficient(); /** * Returns the value used as the farout coefficient. The farout coefficient * allows the calculation of which values will be off the graph. * * @return A double representing the value used to calculate * farouts */ public double getFaroutCoefficient(); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.javalibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.0000644000175000017500000006734711173030414033476 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------- * DefaultBoxAndWhiskerCategoryDataset.java * ---------------------------------------- * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 27-Aug-2003 : Moved from org.jfree.data --> org.jfree.data.statistics (DG); * 12-Nov-2003 : Changed 'data' from private to protected and added a new 'add' * method as proposed by Tim Bardzil. Also removed old code (DG); * 01-Mar-2004 : Added equals() method (DG); * 18-Nov-2004 : Updates for changes in RangeInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 17-Apr-2007 : Fixed bug 1701822 (DG); * 13-Jun-2007 : Fixed error in previous patch (DG); * 28-Sep-2007 : Fixed cloning bug (DG); * 02-Oct-2007 : Fixed bug in updating cached bounds (DG); * 03-Oct-2007 : Fixed another bug in updating cached bounds, added removal * methods (DG); * */ package org.jfree.data.statistics; import java.util.List; import org.jfree.data.KeyedObjects2D; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A convenience class that provides a default implementation of the * {@link BoxAndWhiskerCategoryDataset} interface. */ public class DefaultBoxAndWhiskerCategoryDataset extends AbstractDataset implements BoxAndWhiskerCategoryDataset, RangeInfo, PublicCloneable { /** Storage for the data. */ protected KeyedObjects2D data; /** The minimum range value. */ private double minimumRangeValue; /** The row index for the cell that the minimum range value comes from. */ private int minimumRangeValueRow; /** * The column index for the cell that the minimum range value comes from. */ private int minimumRangeValueColumn; /** The maximum range value. */ private double maximumRangeValue; /** The row index for the cell that the maximum range value comes from. */ private int maximumRangeValueRow; /** * The column index for the cell that the maximum range value comes from. */ private int maximumRangeValueColumn; /** * Creates a new dataset. */ public DefaultBoxAndWhiskerCategoryDataset() { this.data = new KeyedObjects2D(); this.minimumRangeValue = Double.NaN; this.minimumRangeValueRow = -1; this.minimumRangeValueColumn = -1; this.maximumRangeValue = Double.NaN; this.maximumRangeValueRow = -1; this.maximumRangeValueColumn = -1; } /** * Adds a list of values relating to one box-and-whisker entity to the * table. The various median values are calculated. * * @param list a collection of values from which the various medians will * be calculated. * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #add(BoxAndWhiskerItem, Comparable, Comparable) */ public void add(List list, Comparable rowKey, Comparable columnKey) { BoxAndWhiskerItem item = BoxAndWhiskerCalculator .calculateBoxAndWhiskerStatistics(list); add(item, rowKey, columnKey); } /** * Adds a list of values relating to one Box and Whisker entity to the * table. The various median values are calculated. * * @param item a box and whisker item (null not permitted). * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #add(List, Comparable, Comparable) */ public void add(BoxAndWhiskerItem item, Comparable rowKey, Comparable columnKey) { this.data.addObject(item, rowKey, columnKey); // update cached min and max values int r = this.data.getRowIndex(rowKey); int c = this.data.getColumnIndex(columnKey); if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn == c) || (this.minimumRangeValueRow == r && this.minimumRangeValueColumn == c)) { updateBounds(); } else { double minval = Double.NaN; if (item.getMinOutlier() != null) { minval = item.getMinOutlier().doubleValue(); } double maxval = Double.NaN; if (item.getMaxOutlier() != null) { maxval = item.getMaxOutlier().doubleValue(); } if (Double.isNaN(this.maximumRangeValue)) { this.maximumRangeValue = maxval; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } else if (maxval > this.maximumRangeValue) { this.maximumRangeValue = maxval; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } if (Double.isNaN(this.minimumRangeValue)) { this.minimumRangeValue = minval; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } else if (minval < this.minimumRangeValue) { this.minimumRangeValue = minval; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } } fireDatasetChanged(); } /** * Removes an item from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #add(BoxAndWhiskerItem, Comparable, Comparable) * * @since 1.0.7 */ public void remove(Comparable rowKey, Comparable columnKey) { // defer null argument checks int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); this.data.removeObject(rowKey, columnKey); // if this cell held a maximum and/or minimum value, we'll need to // update the cached bounds... if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn == c) || (this.minimumRangeValueRow == r && this.minimumRangeValueColumn == c)) { updateBounds(); } fireDatasetChanged(); } /** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowIndex the row index. * * @see #removeColumn(int) * * @since 1.0.7 */ public void removeRow(int rowIndex) { this.data.removeRow(rowIndex); updateBounds(); fireDatasetChanged(); } /** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key. * * @see #removeColumn(Comparable) * * @since 1.0.7 */ public void removeRow(Comparable rowKey) { this.data.removeRow(rowKey); updateBounds(); fireDatasetChanged(); } /** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnIndex the column index. * * @see #removeRow(int) * * @since 1.0.7 */ public void removeColumn(int columnIndex) { this.data.removeColumn(columnIndex); updateBounds(); fireDatasetChanged(); } /** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnKey the column key. * * @see #removeRow(Comparable) * * @since 1.0.7 */ public void removeColumn(Comparable columnKey) { this.data.removeColumn(columnKey); updateBounds(); fireDatasetChanged(); } /** * Clears all data from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @since 1.0.7 */ public void clear() { this.data.clear(); updateBounds(); fireDatasetChanged(); } /** * Return an item from within the dataset. * * @param row the row index. * @param column the column index. * * @return The item. */ public BoxAndWhiskerItem getItem(int row, int column) { return (BoxAndWhiskerItem) this.data.getObject(row, column); } /** * Returns the value for an item. * * @param row the row index. * @param column the column index. * * @return The value. * * @see #getMedianValue(int, int) * @see #getValue(Comparable, Comparable) */ public Number getValue(int row, int column) { return getMedianValue(row, column); } /** * Returns the value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The value. * * @see #getMedianValue(Comparable, Comparable) * @see #getValue(int, int) */ public Number getValue(Comparable rowKey, Comparable columnKey) { return getMedianValue(rowKey, columnKey); } /** * Returns the mean value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The mean value. * * @see #getItem(int, int) */ public Number getMeanValue(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject(row, column); if (item != null) { result = item.getMean(); } return result; } /** * Returns the mean value for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The mean value. * * @see #getItem(int, int) */ public Number getMeanValue(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getMean(); } return result; } /** * Returns the median value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The median value. * * @see #getItem(int, int) */ public Number getMedianValue(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject(row, column); if (item != null) { result = item.getMedian(); } return result; } /** * Returns the median value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The median value. * * @see #getItem(int, int) */ public Number getMedianValue(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getMedian(); } return result; } /** * Returns the first quartile value. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The first quartile value. * * @see #getItem(int, int) */ public Number getQ1Value(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getQ1(); } return result; } /** * Returns the first quartile value. * * @param rowKey the row key. * @param columnKey the column key. * * @return The first quartile value. * * @see #getItem(int, int) */ public Number getQ1Value(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getQ1(); } return result; } /** * Returns the third quartile value. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The third quartile value. * * @see #getItem(int, int) */ public Number getQ3Value(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getQ3(); } return result; } /** * Returns the third quartile value. * * @param rowKey the row key. * @param columnKey the column key. * * @return The third quartile value. * * @see #getItem(int, int) */ public Number getQ3Value(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getQ3(); } return result; } /** * Returns the column index for a given key. * * @param key the column key (null not permitted). * * @return The column index. * * @see #getColumnKey(int) */ public int getColumnIndex(Comparable key) { return this.data.getColumnIndex(key); } /** * Returns a column key. * * @param column the column index (zero-based). * * @return The column key. * * @see #getColumnIndex(Comparable) */ public Comparable getColumnKey(int column) { return this.data.getColumnKey(column); } /** * Returns the column keys. * * @return The keys. * * @see #getRowKeys() */ public List getColumnKeys() { return this.data.getColumnKeys(); } /** * Returns the row index for a given key. * * @param key the row key (null not permitted). * * @return The row index. * * @see #getRowKey(int) */ public int getRowIndex(Comparable key) { // defer null argument check return this.data.getRowIndex(key); } /** * Returns a row key. * * @param row the row index (zero-based). * * @return The row key. * * @see #getRowIndex(Comparable) */ public Comparable getRowKey(int row) { return this.data.getRowKey(row); } /** * Returns the row keys. * * @return The keys. * * @see #getColumnKeys() */ public List getRowKeys() { return this.data.getRowKeys(); } /** * Returns the number of rows in the table. * * @return The row count. * * @see #getColumnCount() */ public int getRowCount() { return this.data.getRowCount(); } /** * Returns the number of columns in the table. * * @return The column count. * * @see #getRowCount() */ public int getColumnCount() { return this.data.getColumnCount(); } /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. * * @see #getRangeUpperBound(boolean) */ public double getRangeLowerBound(boolean includeInterval) { return this.minimumRangeValue; } /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. * * @see #getRangeLowerBound(boolean) */ public double getRangeUpperBound(boolean includeInterval) { return this.maximumRangeValue; } /** * Returns the range of the values in this dataset's range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range. */ public Range getRangeBounds(boolean includeInterval) { return new Range(this.minimumRangeValue, this.maximumRangeValue); } /** * Returns the minimum regular (non outlier) value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The minimum regular value. * * @see #getItem(int, int) */ public Number getMinRegularValue(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getMinRegularValue(); } return result; } /** * Returns the minimum regular (non outlier) value for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The minimum regular value. * * @see #getItem(int, int) */ public Number getMinRegularValue(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getMinRegularValue(); } return result; } /** * Returns the maximum regular (non outlier) value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The maximum regular value. * * @see #getItem(int, int) */ public Number getMaxRegularValue(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getMaxRegularValue(); } return result; } /** * Returns the maximum regular (non outlier) value for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The maximum regular value. * * @see #getItem(int, int) */ public Number getMaxRegularValue(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getMaxRegularValue(); } return result; } /** * Returns the minimum outlier (non farout) value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The minimum outlier. * * @see #getItem(int, int) */ public Number getMinOutlier(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getMinOutlier(); } return result; } /** * Returns the minimum outlier (non farout) value for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The minimum outlier. * * @see #getItem(int, int) */ public Number getMinOutlier(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getMinOutlier(); } return result; } /** * Returns the maximum outlier (non farout) value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The maximum outlier. * * @see #getItem(int, int) */ public Number getMaxOutlier(int row, int column) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getMaxOutlier(); } return result; } /** * Returns the maximum outlier (non farout) value for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return The maximum outlier. * * @see #getItem(int, int) */ public Number getMaxOutlier(Comparable rowKey, Comparable columnKey) { Number result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getMaxOutlier(); } return result; } /** * Returns a list of outlier values for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return A list of outlier values. * * @see #getItem(int, int) */ public List getOutliers(int row, int column) { List result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( row, column); if (item != null) { result = item.getOutliers(); } return result; } /** * Returns a list of outlier values for an item. * * @param rowKey the row key. * @param columnKey the column key. * * @return A list of outlier values. * * @see #getItem(int, int) */ public List getOutliers(Comparable rowKey, Comparable columnKey) { List result = null; BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( rowKey, columnKey); if (item != null) { result = item.getOutliers(); } return result; } /** * Resets the cached bounds, by iterating over the entire dataset to find * the current bounds. */ private void updateBounds() { this.minimumRangeValue = Double.NaN; this.minimumRangeValueRow = -1; this.minimumRangeValueColumn = -1; this.maximumRangeValue = Double.NaN; this.maximumRangeValueRow = -1; this.maximumRangeValueColumn = -1; int rowCount = getRowCount(); int columnCount = getColumnCount(); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { BoxAndWhiskerItem item = getItem(r, c); if (item != null) { Number min = item.getMinOutlier(); if (min != null) { double minv = min.doubleValue(); if (!Double.isNaN(minv)) { if (minv < this.minimumRangeValue || Double.isNaN( this.minimumRangeValue)) { this.minimumRangeValue = minv; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } } } Number max = item.getMaxOutlier(); if (max != null) { double maxv = max.doubleValue(); if (!Double.isNaN(maxv)) { if (maxv > this.maximumRangeValue || Double.isNaN( this.maximumRangeValue)) { this.maximumRangeValue = maxv; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } } } } } } } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset dataset = (DefaultBoxAndWhiskerCategoryDataset) obj; return ObjectUtilities.equal(this.data, dataset.data); } return false; } /** * Returns a clone of this dataset. * * @return A clone. * * @throws CloneNotSupportedException if cloning is not possible. */ public Object clone() throws CloneNotSupportedException { DefaultBoxAndWhiskerCategoryDataset clone = (DefaultBoxAndWhiskerCategoryDataset) super.clone(); clone.data = (KeyedObjects2D) this.data.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDataset.java0000644000175000017500000004504211173030414033107 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * DefaultBoxAndWhiskerXYDataset.java * ---------------------------------- * (C) Copyright 2003-2008, by David Browning and Contributors. * * Original Author: David Browning (for Australian Institute of Marine * Science); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 05-Aug-2003 : Version 1, contributed by David Browning (DG); * 08-Aug-2003 : Minor changes to comments (DB) * Allow average to be null - average is a perculiar AIMS * requirement which probably should be stripped out and overlaid * if required... * Added a number of methods to allow the max and min non-outlier * and non-farout values to be calculated * 12-Aug-2003 Changed the getYValue to return the highest outlier value * Added getters and setters for outlier and farout coefficients * 27-Aug-2003 : Renamed DefaultBoxAndWhiskerDataset * --> DefaultBoxAndWhiskerXYDataset (DG); * 06-May-2004 : Now extends AbstractXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 18-Nov-2004 : Updated for changes in RangeInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 12-Nov-2007 : Implemented equals() and clone() (DG); * */ package org.jfree.data.statistics; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.xy.AbstractXYDataset; import org.jfree.util.ObjectUtilities; /** * A simple implementation of the {@link BoxAndWhiskerXYDataset} interface. * This dataset implementation can hold only one series. */ public class DefaultBoxAndWhiskerXYDataset extends AbstractXYDataset implements BoxAndWhiskerXYDataset, RangeInfo { /** The series key. */ private Comparable seriesKey; /** Storage for the dates. */ private List dates; /** Storage for the box and whisker statistics. */ private List items; /** The minimum range value. */ private Number minimumRangeValue; /** The maximum range value. */ private Number maximumRangeValue; /** The range of values. */ private Range rangeBounds; /** * The coefficient used to calculate outliers. Tukey's default value is * 1.5 (see EDA) Any value which is greater than Q3 + (interquartile range * * outlier coefficient) is considered to be an outlier. Can be altered * if the data is particularly skewed. */ private double outlierCoefficient = 1.5; /** * The coefficient used to calculate farouts. Tukey's default value is 2 * (see EDA) Any value which is greater than Q3 + (interquartile range * * farout coefficient) is considered to be a farout. Can be altered if the * data is particularly skewed. */ private double faroutCoefficient = 2.0; /** * Constructs a new box and whisker dataset. *

* The current implementation allows only one series in the dataset. * This may be extended in a future version. * * @param seriesKey the key for the series. */ public DefaultBoxAndWhiskerXYDataset(Comparable seriesKey) { this.seriesKey = seriesKey; this.dates = new ArrayList(); this.items = new ArrayList(); this.minimumRangeValue = null; this.maximumRangeValue = null; this.rangeBounds = null; } /** * Returns the value used as the outlier coefficient. The outlier * coefficient gives an indication of the degree of certainty in an * unskewed distribution. Increasing the coefficient increases the number * of values included. Currently only used to ensure farout coefficient is * greater than the outlier coefficient * * @return A double representing the value used to calculate * outliers. * * @see #setOutlierCoefficient(double) */ public double getOutlierCoefficient() { return this.outlierCoefficient; } /** * Sets the value used as the outlier coefficient * * @param outlierCoefficient being a double representing the * value used to calculate outliers. * * @see #getOutlierCoefficient() */ public void setOutlierCoefficient(double outlierCoefficient) { this.outlierCoefficient = outlierCoefficient; } /** * Returns the value used as the farout coefficient. The farout coefficient * allows the calculation of which values will be off the graph. * * @return A double representing the value used to calculate * farouts. * * @see #setFaroutCoefficient(double) */ public double getFaroutCoefficient() { return this.faroutCoefficient; } /** * Sets the value used as the farouts coefficient. The farout coefficient * must b greater than the outlier coefficient. * * @param faroutCoefficient being a double representing the * value used to calculate farouts. * * @see #getFaroutCoefficient() */ public void setFaroutCoefficient(double faroutCoefficient) { if (faroutCoefficient > getOutlierCoefficient()) { this.faroutCoefficient = faroutCoefficient; } else { throw new IllegalArgumentException("Farout value must be greater " + "than the outlier value, which is currently set at: (" + getOutlierCoefficient() + ")"); } } /** * Returns the number of series in the dataset. *

* This implementation only allows one series. * * @return The number of series. */ public int getSeriesCount() { return 1; } /** * Returns the number of items in the specified series. * * @param series the index (zero-based) of the series. * * @return The number of items in the specified series. */ public int getItemCount(int series) { return this.dates.size(); } /** * Adds an item to the dataset and sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param date the date (null not permitted). * @param item the item (null not permitted). */ public void add(Date date, BoxAndWhiskerItem item) { this.dates.add(date); this.items.add(item); if (this.minimumRangeValue == null) { this.minimumRangeValue = item.getMinRegularValue(); } else { if (item.getMinRegularValue().doubleValue() < this.minimumRangeValue.doubleValue()) { this.minimumRangeValue = item.getMinRegularValue(); } } if (this.maximumRangeValue == null) { this.maximumRangeValue = item.getMaxRegularValue(); } else { if (item.getMaxRegularValue().doubleValue() > this.maximumRangeValue.doubleValue()) { this.maximumRangeValue = item.getMaxRegularValue(); } } this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(), this.maximumRangeValue.doubleValue()); fireDatasetChanged(); } /** * Returns the name of the series stored in this dataset. * * @param i the index of the series. Currently ignored. * * @return The name of this series. */ public Comparable getSeriesKey(int i) { return this.seriesKey; } /** * Return an item from within the dataset. * * @param series the series index (ignored, since this dataset contains * only one series). * @param item the item within the series (zero-based index) * * @return The item. */ public BoxAndWhiskerItem getItem(int series, int item) { return (BoxAndWhiskerItem) this.items.get(item); } /** * Returns the x-value for one item in a series. *

* The value returned is a Long object generated from the underlying Date * object. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ public Number getX(int series, int item) { return new Long(((Date) this.dates.get(item)).getTime()); } /** * Returns the x-value for one item in a series, as a Date. *

* This method is provided for convenience only. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value as a Date. */ public Date getXDate(int series, int item) { return (Date) this.dates.get(item); } /** * Returns the y-value for one item in a series. *

* This method (from the XYDataset interface) is mapped to the * getMeanValue() method. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value. */ public Number getY(int series, int item) { return getMeanValue(series, item); } /** * Returns the mean for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The mean for the specified series and item. */ public Number getMeanValue(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getMean(); } return result; } /** * Returns the median-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The median-value for the specified series and item. */ public Number getMedianValue(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getMedian(); } return result; } /** * Returns the Q1 median-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The Q1 median-value for the specified series and item. */ public Number getQ1Value(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getQ1(); } return result; } /** * Returns the Q3 median-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The Q3 median-value for the specified series and item. */ public Number getQ3Value(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getQ3(); } return result; } /** * Returns the min-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The min-value for the specified series and item. */ public Number getMinRegularValue(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getMinRegularValue(); } return result; } /** * Returns the max-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The max-value for the specified series and item. */ public Number getMaxRegularValue(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getMaxRegularValue(); } return result; } /** * Returns the minimum value which is not a farout. * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A Number representing the maximum non-farout value. */ public Number getMinOutlier(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getMinOutlier(); } return result; } /** * Returns the maximum value which is not a farout, ie Q3 + (interquartile * range * farout coefficient). * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return A Number representing the maximum non-farout value. */ public Number getMaxOutlier(int series, int item) { Number result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getMaxOutlier(); } return result; } /** * Returns an array of outliers for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The array of outliers for the specified series and item. */ public List getOutliers(int series, int item) { List result = null; BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); if (stats != null) { result = stats.getOutliers(); } return result; } /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. */ public double getRangeLowerBound(boolean includeInterval) { double result = Double.NaN; if (this.minimumRangeValue != null) { result = this.minimumRangeValue.doubleValue(); } return result; } /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ public double getRangeUpperBound(boolean includeInterval) { double result = Double.NaN; if (this.maximumRangeValue != null) { result = this.maximumRangeValue.doubleValue(); } return result; } /** * Returns the range of the values in this dataset's range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range. */ public Range getRangeBounds(boolean includeInterval) { return this.rangeBounds; } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultBoxAndWhiskerXYDataset)) { return false; } DefaultBoxAndWhiskerXYDataset that = (DefaultBoxAndWhiskerXYDataset) obj; if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey)) { return false; } if (!this.dates.equals(that.dates)) { return false; } if (!this.items.equals(that.items)) { return false; } return true; } /** * Returns a clone of the plot. * * @return A clone. * * @throws CloneNotSupportedException if the cloning is not supported. */ public Object clone() throws CloneNotSupportedException { DefaultBoxAndWhiskerXYDataset clone = (DefaultBoxAndWhiskerXYDataset) super.clone(); clone.dates = new java.util.ArrayList(this.dates); clone.items = new java.util.ArrayList(this.items); return clone; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.javalibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.jav0000644000175000017500000003021011173030414033531 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * DefaultMultiValueCategoryDataset.java * ------------------------------------- * (C) Copyright 2007, 2008, by David Forslund and Contributors. * * Original Author: David Forslund; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 08-Oct-2007 : Version 1, see patch 1780779 (DG); * 06-Nov-2007 : Return EMPTY_LIST not null from getValues() (DG); */ package org.jfree.data.statistics; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.data.KeyedObjects2D; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A category dataset that defines multiple values for each item. * * @since 1.0.7 */ public class DefaultMultiValueCategoryDataset extends AbstractDataset implements MultiValueCategoryDataset, RangeInfo, PublicCloneable { /** * Storage for the data. */ protected KeyedObjects2D data; /** * The minimum range value. */ private Number minimumRangeValue; /** * The maximum range value. */ private Number maximumRangeValue; /** * The range of values. */ private Range rangeBounds; /** * Creates a new dataset. */ public DefaultMultiValueCategoryDataset() { this.data = new KeyedObjects2D(); this.minimumRangeValue = null; this.maximumRangeValue = null; this.rangeBounds = new Range(0.0, 0.0); } /** * Adds a list of values to the dataset (null and Double.NaN * items are automatically removed) and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param values a list of values (null not permitted). * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). */ public void add(List values, Comparable rowKey, Comparable columnKey) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } List vlist = new ArrayList(values.size()); Iterator iterator = values.listIterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj instanceof Number) { Number n = (Number) obj; double v = n.doubleValue(); if (!Double.isNaN(v)) { vlist.add(n); } } } Collections.sort(vlist); this.data.addObject(vlist, rowKey, columnKey); if (vlist.size() > 0) { double maxval = Double.NEGATIVE_INFINITY; double minval = Double.POSITIVE_INFINITY; for (int i = 0; i < vlist.size(); i++) { Number n = (Number) vlist.get(i); double v = n.doubleValue(); minval = Math.min(minval, v); maxval = Math.max(maxval, v); } // update the cached range values... if (this.maximumRangeValue == null) { this.maximumRangeValue = new Double(maxval); } else if (maxval > this.maximumRangeValue.doubleValue()) { this.maximumRangeValue = new Double(maxval); } if (this.minimumRangeValue == null) { this.minimumRangeValue = new Double(minval); } else if (minval < this.minimumRangeValue.doubleValue()) { this.minimumRangeValue = new Double(minval); } this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(), this.maximumRangeValue.doubleValue()); } fireDatasetChanged(); } /** * Returns a list (possibly empty) of the values for the specified item. * The returned list should be unmodifiable. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The list of values. */ public List getValues(int row, int column) { List values = (List) this.data.getObject(row, column); if (values != null) { return Collections.unmodifiableList(values); } else { return Collections.EMPTY_LIST; } } /** * Returns a list (possibly empty) of the values for the specified item. * The returned list should be unmodifiable. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The list of values. */ public List getValues(Comparable rowKey, Comparable columnKey) { return Collections.unmodifiableList((List) this.data.getObject(rowKey, columnKey)); } /** * Returns the average value for the specified item. * * @param row the row key. * @param column the column key. * * @return The average value. */ public Number getValue(Comparable row, Comparable column) { List l = (List) this.data.getObject(row, column); double average = 0.0d; int count = 0; if (l != null && l.size() > 0) { for (int i = 0; i < l.size(); i++) { Number n = (Number) l.get(i); average += n.doubleValue(); count += 1; } if (count > 0) { average = average / count; } } if (count == 0) { return null; } return new Double(average); } /** * Returns the average value for the specified item. * * @param row the row index. * @param column the column index. * * @return The average value. */ public Number getValue(int row, int column) { List l = (List) this.data.getObject(row, column); double average = 0.0d; int count = 0; if (l != null && l.size() > 0) { for (int i = 0; i < l.size(); i++) { Number n = (Number) l.get(i); average += n.doubleValue(); count += 1; } if (count > 0) { average = average / count; } } if (count == 0) { return null; } return new Double(average); } /** * Returns the column index for a given key. * * @param key the column key. * * @return The column index. */ public int getColumnIndex(Comparable key) { return this.data.getColumnIndex(key); } /** * Returns a column key. * * @param column the column index (zero-based). * * @return The column key. */ public Comparable getColumnKey(int column) { return this.data.getColumnKey(column); } /** * Returns the column keys. * * @return The keys. */ public List getColumnKeys() { return this.data.getColumnKeys(); } /** * Returns the row index for a given key. * * @param key the row key. * * @return The row index. */ public int getRowIndex(Comparable key) { return this.data.getRowIndex(key); } /** * Returns a row key. * * @param row the row index (zero-based). * * @return The row key. */ public Comparable getRowKey(int row) { return this.data.getRowKey(row); } /** * Returns the row keys. * * @return The keys. */ public List getRowKeys() { return this.data.getRowKeys(); } /** * Returns the number of rows in the table. * * @return The row count. */ public int getRowCount() { return this.data.getRowCount(); } /** * Returns the number of columns in the table. * * @return The column count. */ public int getColumnCount() { return this.data.getColumnCount(); } /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. */ public double getRangeLowerBound(boolean includeInterval) { double result = Double.NaN; if (this.minimumRangeValue != null) { result = this.minimumRangeValue.doubleValue(); } return result; } /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ public double getRangeUpperBound(boolean includeInterval) { double result = Double.NaN; if (this.maximumRangeValue != null) { result = this.maximumRangeValue.doubleValue(); } return result; } /** * Returns the range of the values in this dataset's range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * @return The range. */ public Range getRangeBounds(boolean includeInterval) { return this.rangeBounds; } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultMultiValueCategoryDataset)) { return false; } DefaultMultiValueCategoryDataset that = (DefaultMultiValueCategoryDataset) obj; return this.data.equals(that.data); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if the dataset cannot be cloned. */ public Object clone() throws CloneNotSupportedException { DefaultMultiValueCategoryDataset clone = (DefaultMultiValueCategoryDataset) super.clone(); clone.data = (KeyedObjects2D) this.data.clone(); return clone; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.javalibjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.ja0000644000175000017500000006016311173030414033552 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------- * DefaultStatisticalCategoryDataset.java * -------------------------------------- * (C) Copyright 2002-2008, by Pascal Collet and Contributors. * * Original Author: Pascal Collet; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 21-Aug-2002 : Version 1, contributed by Pascal Collet (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 05-Feb-2003 : Revised implementation to use KeyedObjects2D (DG); * 28-Aug-2003 : Moved from org.jfree.data --> org.jfree.data.statistics (DG); * 06-Oct-2003 : Removed incorrect Javadoc text (DG); * 18-Nov-2004 : Updated for changes in RangeInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 01-Feb-2005 : Changed minimumRangeValue and maximumRangeValue from Double * to double (DG); * 05-Feb-2005 : Implemented equals() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 08-Aug-2006 : Reworked implementation of RangeInfo methods (DG); * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * 28-Sep-2007 : Fixed cloning bug (DG); * 02-Oct-2007 : Fixed bug updating cached range values (DG); * */ package org.jfree.data.statistics; import java.util.List; import org.jfree.data.KeyedObjects2D; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.AbstractDataset; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A convenience class that provides a default implementation of the * {@link StatisticalCategoryDataset} interface. */ public class DefaultStatisticalCategoryDataset extends AbstractDataset implements StatisticalCategoryDataset, RangeInfo, PublicCloneable { /** Storage for the data. */ private KeyedObjects2D data; /** The minimum range value. */ private double minimumRangeValue; /** The row index for the minimum range value. */ private int minimumRangeValueRow; /** The column index for the minimum range value. */ private int minimumRangeValueColumn; /** The minimum range value including the standard deviation. */ private double minimumRangeValueIncStdDev; /** * The row index for the minimum range value (including the standard * deviation). */ private int minimumRangeValueIncStdDevRow; /** * The column index for the minimum range value (including the standard * deviation). */ private int minimumRangeValueIncStdDevColumn; /** The maximum range value. */ private double maximumRangeValue; /** The row index for the maximum range value. */ private int maximumRangeValueRow; /** The column index for the maximum range value. */ private int maximumRangeValueColumn; /** The maximum range value including the standard deviation. */ private double maximumRangeValueIncStdDev; /** * The row index for the maximum range value (including the standard * deviation). */ private int maximumRangeValueIncStdDevRow; /** * The column index for the maximum range value (including the standard * deviation). */ private int maximumRangeValueIncStdDevColumn; /** * Creates a new dataset. */ public DefaultStatisticalCategoryDataset() { this.data = new KeyedObjects2D(); this.minimumRangeValue = Double.NaN; this.minimumRangeValueRow = -1; this.minimumRangeValueColumn = -1; this.maximumRangeValue = Double.NaN; this.maximumRangeValueRow = -1; this.maximumRangeValueColumn = -1; this.minimumRangeValueIncStdDev = Double.NaN; this.minimumRangeValueIncStdDevRow = -1; this.minimumRangeValueIncStdDevColumn = -1; this.maximumRangeValueIncStdDev = Double.NaN; this.maximumRangeValueIncStdDevRow = -1; this.maximumRangeValueIncStdDevColumn = -1; } /** * Returns the mean value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The mean value (possibly null). */ public Number getMeanValue(int row, int column) { Number result = null; MeanAndStandardDeviation masd = (MeanAndStandardDeviation) this.data.getObject(row, column); if (masd != null) { result = masd.getMean(); } return result; } /** * Returns the value for an item (for this dataset, the mean value is * returned). * * @param row the row index. * @param column the column index. * * @return The value (possibly null). */ public Number getValue(int row, int column) { return getMeanValue(row, column); } /** * Returns the value for an item (for this dataset, the mean value is * returned). * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The value (possibly null). */ public Number getValue(Comparable rowKey, Comparable columnKey) { return getMeanValue(rowKey, columnKey); } /** * Returns the mean value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The mean value (possibly null). */ public Number getMeanValue(Comparable rowKey, Comparable columnKey) { Number result = null; MeanAndStandardDeviation masd = (MeanAndStandardDeviation) this.data.getObject(rowKey, columnKey); if (masd != null) { result = masd.getMean(); } return result; } /** * Returns the standard deviation value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The standard deviation (possibly null). */ public Number getStdDevValue(int row, int column) { Number result = null; MeanAndStandardDeviation masd = (MeanAndStandardDeviation) this.data.getObject(row, column); if (masd != null) { result = masd.getStandardDeviation(); } return result; } /** * Returns the standard deviation value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The standard deviation (possibly null). */ public Number getStdDevValue(Comparable rowKey, Comparable columnKey) { Number result = null; MeanAndStandardDeviation masd = (MeanAndStandardDeviation) this.data.getObject(rowKey, columnKey); if (masd != null) { result = masd.getStandardDeviation(); } return result; } /** * Returns the column index for a given key. * * @param key the column key (null not permitted). * * @return The column index. */ public int getColumnIndex(Comparable key) { // defer null argument check return this.data.getColumnIndex(key); } /** * Returns a column key. * * @param column the column index (zero-based). * * @return The column key. */ public Comparable getColumnKey(int column) { return this.data.getColumnKey(column); } /** * Returns the column keys. * * @return The keys. */ public List getColumnKeys() { return this.data.getColumnKeys(); } /** * Returns the row index for a given key. * * @param key the row key (null not permitted). * * @return The row index. */ public int getRowIndex(Comparable key) { // defer null argument check return this.data.getRowIndex(key); } /** * Returns a row key. * * @param row the row index (zero-based). * * @return The row key. */ public Comparable getRowKey(int row) { return this.data.getRowKey(row); } /** * Returns the row keys. * * @return The keys. */ public List getRowKeys() { return this.data.getRowKeys(); } /** * Returns the number of rows in the table. * * @return The row count. * * @see #getColumnCount() */ public int getRowCount() { return this.data.getRowCount(); } /** * Returns the number of columns in the table. * * @return The column count. * * @see #getRowCount() */ public int getColumnCount() { return this.data.getColumnCount(); } /** * Adds a mean and standard deviation to the table. * * @param mean the mean. * @param standardDeviation the standard deviation. * @param rowKey the row key. * @param columnKey the column key. */ public void add(double mean, double standardDeviation, Comparable rowKey, Comparable columnKey) { add(new Double(mean), new Double(standardDeviation), rowKey, columnKey); } /** * Adds a mean and standard deviation to the table. * * @param mean the mean. * @param standardDeviation the standard deviation. * @param rowKey the row key. * @param columnKey the column key. */ public void add(Number mean, Number standardDeviation, Comparable rowKey, Comparable columnKey) { MeanAndStandardDeviation item = new MeanAndStandardDeviation( mean, standardDeviation); this.data.addObject(item, rowKey, columnKey); double m = Double.NaN; double sd = Double.NaN; if (mean != null) { m = mean.doubleValue(); } if (standardDeviation != null) { sd = standardDeviation.doubleValue(); } // update cached range values int r = this.data.getColumnIndex(columnKey); int c = this.data.getRowIndex(rowKey); if ((r == this.maximumRangeValueRow && c == this.maximumRangeValueColumn) || (r == this.maximumRangeValueIncStdDevRow && c == this.maximumRangeValueIncStdDevColumn) || (r == this.minimumRangeValueRow && c == this.minimumRangeValueColumn) || (r == this.minimumRangeValueIncStdDevRow && c == this.minimumRangeValueIncStdDevColumn)) { // iterate over all data items and update mins and maxes updateBounds(); } else { if (!Double.isNaN(m)) { if (Double.isNaN(this.maximumRangeValue) || m > this.maximumRangeValue) { this.maximumRangeValue = m; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } } if (!Double.isNaN(m + sd)) { if (Double.isNaN(this.maximumRangeValueIncStdDev) || (m + sd) > this.maximumRangeValueIncStdDev) { this.maximumRangeValueIncStdDev = m + sd; this.maximumRangeValueIncStdDevRow = r; this.maximumRangeValueIncStdDevColumn = c; } } if (!Double.isNaN(m)) { if (Double.isNaN(this.minimumRangeValue) || m < this.minimumRangeValue) { this.minimumRangeValue = m; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } } if (!Double.isNaN(m - sd)) { if (Double.isNaN(this.minimumRangeValueIncStdDev) || (m - sd) < this.minimumRangeValueIncStdDev) { this.minimumRangeValueIncStdDev = m - sd; this.minimumRangeValueIncStdDevRow = r; this.minimumRangeValueIncStdDevColumn = c; } } } fireDatasetChanged(); } /** * Removes an item from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #add(double, double, Comparable, Comparable) * * @since 1.0.7 */ public void remove(Comparable rowKey, Comparable columnKey) { // defer null argument checks int r = getRowIndex(rowKey); int c = getColumnIndex(columnKey); this.data.removeObject(rowKey, columnKey); // if this cell held a maximum and/or minimum value, we'll need to // update the cached bounds... if ((r == this.maximumRangeValueRow && c == this.maximumRangeValueColumn) || (r == this.maximumRangeValueIncStdDevRow && c == this.maximumRangeValueIncStdDevColumn) || (r == this.minimumRangeValueRow && c == this.minimumRangeValueColumn) || (r == this.minimumRangeValueIncStdDevRow && c == this.minimumRangeValueIncStdDevColumn)) { // iterate over all data items and update mins and maxes updateBounds(); } fireDatasetChanged(); } /** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowIndex the row index. * * @see #removeColumn(int) * * @since 1.0.7 */ public void removeRow(int rowIndex) { this.data.removeRow(rowIndex); updateBounds(); fireDatasetChanged(); } /** * Removes a row from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param rowKey the row key (null not permitted). * * @see #removeColumn(Comparable) * * @since 1.0.7 */ public void removeRow(Comparable rowKey) { this.data.removeRow(rowKey); updateBounds(); fireDatasetChanged(); } /** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnIndex the column index. * * @see #removeRow(int) * * @since 1.0.7 */ public void removeColumn(int columnIndex) { this.data.removeColumn(columnIndex); updateBounds(); fireDatasetChanged(); } /** * Removes a column from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param columnKey the column key (null not permitted). * * @see #removeRow(Comparable) * * @since 1.0.7 */ public void removeColumn(Comparable columnKey) { this.data.removeColumn(columnKey); updateBounds(); fireDatasetChanged(); } /** * Clears all data from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @since 1.0.7 */ public void clear() { this.data.clear(); updateBounds(); fireDatasetChanged(); } /** * Iterate over all the data items and update the cached bound values. */ private void updateBounds() { this.maximumRangeValue = Double.NaN; this.maximumRangeValueRow = -1; this.maximumRangeValueColumn = -1; this.minimumRangeValue = Double.NaN; this.minimumRangeValueRow = -1; this.minimumRangeValueColumn = -1; this.maximumRangeValueIncStdDev = Double.NaN; this.maximumRangeValueIncStdDevRow = -1; this.maximumRangeValueIncStdDevColumn = -1; this.minimumRangeValueIncStdDev = Double.NaN; this.minimumRangeValueIncStdDevRow = -1; this.minimumRangeValueIncStdDevColumn = -1; int rowCount = this.data.getRowCount(); int columnCount = this.data.getColumnCount(); for (int r = 0; r < rowCount; r++) { for (int c = 0; c < columnCount; c++) { double m = Double.NaN; double sd = Double.NaN; MeanAndStandardDeviation masd = (MeanAndStandardDeviation) this.data.getObject(r, c); if (masd == null) { continue; } m = masd.getMeanValue(); sd = masd.getStandardDeviationValue(); if (!Double.isNaN(m)) { // update the max value if (Double.isNaN(this.maximumRangeValue)) { this.maximumRangeValue = m; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } else { if (m > this.maximumRangeValue) { this.maximumRangeValue = m; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } } // update the min value if (Double.isNaN(this.minimumRangeValue)) { this.minimumRangeValue = m; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } else { if (m < this.minimumRangeValue) { this.minimumRangeValue = m; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } } if (!Double.isNaN(sd)) { // update the max value if (Double.isNaN(this.maximumRangeValueIncStdDev)) { this.maximumRangeValueIncStdDev = m + sd; this.maximumRangeValueIncStdDevRow = r; this.maximumRangeValueIncStdDevColumn = c; } else { if (m + sd > this.maximumRangeValueIncStdDev) { this.maximumRangeValueIncStdDev = m + sd; this.maximumRangeValueIncStdDevRow = r; this.maximumRangeValueIncStdDevColumn = c; } } // update the min value if (Double.isNaN(this.minimumRangeValueIncStdDev)) { this.minimumRangeValueIncStdDev = m - sd; this.minimumRangeValueIncStdDevRow = r; this.minimumRangeValueIncStdDevColumn = c; } else { if (m - sd < this.minimumRangeValueIncStdDev) { this.minimumRangeValueIncStdDev = m - sd; this.minimumRangeValueIncStdDevRow = r; this.minimumRangeValueIncStdDevColumn = c; } } } } } } } /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. * * @see #getRangeUpperBound(boolean) */ public double getRangeLowerBound(boolean includeInterval) { if (includeInterval) { return this.minimumRangeValueIncStdDev; } else { return this.minimumRangeValue; } } /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. * * @see #getRangeLowerBound(boolean) */ public double getRangeUpperBound(boolean includeInterval) { if (includeInterval) { return this.maximumRangeValueIncStdDev; } else { return this.maximumRangeValue; } } /** * Returns the range of the values in this dataset's range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range. */ public Range getRangeBounds(boolean includeInterval) { Range result = null; if (includeInterval) { if (!Double.isNaN(this.minimumRangeValueIncStdDev) && !Double.isNaN(this.maximumRangeValueIncStdDev)) { result = new Range(this.minimumRangeValueIncStdDev, this.maximumRangeValueIncStdDev); } } else { if (!Double.isNaN(this.minimumRangeValue) && !Double.isNaN(this.maximumRangeValue)) { result = new Range(this.minimumRangeValue, this.maximumRangeValue); } } return result; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultStatisticalCategoryDataset)) { return false; } DefaultStatisticalCategoryDataset that = (DefaultStatisticalCategoryDataset) obj; if (!this.data.equals(that.data)) { return false; } return true; } /** * Returns a clone of this dataset. * * @return A clone of this dataset. * * @throws CloneNotSupportedException if cloning cannot be completed. */ public Object clone() throws CloneNotSupportedException { DefaultStatisticalCategoryDataset clone = (DefaultStatisticalCategoryDataset) super.clone(); clone.data = (KeyedObjects2D) this.data.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/HistogramBin.java0000644000175000017500000001115011173030414027662 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * HistogramBin.java * ----------------- * (C) Copyright 2003-2008, by Jelai Wang and Contributors. * * Original Author: Jelai Wang (jelaiw AT mindspring.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 06-Jul-2003 : Version 1, contributed by Jelai Wang (DG); * 07-Jul-2003 : Changed package and added Javadocs (DG); * 01-Mar-2004 : Moved from org.jfree.data --> org.jfree.data.statistics (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.data.statistics; import java.io.Serializable; /** * A bin for the {@link HistogramDataset} class. */ public class HistogramBin implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7614685080015589931L; /** The number of items in the bin. */ private int count; /** The start boundary. */ private double startBoundary; /** The end boundary. */ private double endBoundary; /** * Creates a new bin. * * @param startBoundary the start boundary. * @param endBoundary the end boundary. */ public HistogramBin(double startBoundary, double endBoundary) { if (startBoundary > endBoundary) { throw new IllegalArgumentException( "HistogramBin(): startBoundary > endBoundary."); } this.count = 0; this.startBoundary = startBoundary; this.endBoundary = endBoundary; } /** * Returns the number of items in the bin. * * @return The item count. */ public int getCount() { return this.count; } /** * Increments the item count. */ public void incrementCount() { this.count++; } /** * Returns the start boundary. * * @return The start boundary. */ public double getStartBoundary() { return this.startBoundary; } /** * Returns the end boundary. * * @return The end boundary. */ public double getEndBoundary() { return this.endBoundary; } /** * Returns the bin width. * * @return The bin width. */ public double getBinWidth() { return this.endBoundary - this.startBoundary; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj instanceof HistogramBin) { HistogramBin bin = (HistogramBin) obj; boolean b0 = bin.startBoundary == this.startBoundary; boolean b1 = bin.endBoundary == this.endBoundary; boolean b2 = bin.count == this.count; return b0 && b1 && b2; } return false; } /** * Returns a clone of the bin. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/HistogramDataset.java0000644000175000017500000004224711173030414030552 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * HistogramDataset.java * --------------------- * (C) Copyright 2003-2008, by Jelai Wang and Contributors. * * Original Author: Jelai Wang (jelaiw AT mindspring.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * Cameron Hayne; * Rikard Bj?rklind; * * Changes * ------- * 06-Jul-2003 : Version 1, contributed by Jelai Wang (DG); * 07-Jul-2003 : Changed package and added Javadocs (DG); * 15-Oct-2003 : Updated Javadocs and removed array sorting (JW); * 09-Jan-2004 : Added fix by "Z." posted in the JFreeChart forum (DG); * 01-Mar-2004 : Added equals() and clone() methods and implemented * Serializable. Also added new addSeries() method (DG); * 06-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 20-May-2005 : Speed up binning - see patch 1026151 contributed by Cameron * Hayne (DG); * 08-Jun-2005 : Fixed bug in getSeriesKey() method (DG); * 22-Nov-2005 : Fixed cast in getSeriesKey() method - see patch 1329287 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-Aug-2006 : Improved precision of bin boundary calculation (DG); * 07-Sep-2006 : Fixed bug 1553088 (DG); * 22-May-2008 : Implemented clone() method override (DG); * */ package org.jfree.data.statistics; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A dataset that can be used for creating histograms. * * @see SimpleHistogramDataset */ public class HistogramDataset extends AbstractIntervalXYDataset implements IntervalXYDataset, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -6341668077370231153L; /** A list of maps. */ private List list; /** The histogram type. */ private HistogramType type; /** * Creates a new (empty) dataset with a default type of * {@link HistogramType}.FREQUENCY. */ public HistogramDataset() { this.list = new ArrayList(); this.type = HistogramType.FREQUENCY; } /** * Returns the histogram type. * * @return The type (never null). */ public HistogramType getType() { return this.type; } /** * Sets the histogram type and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param type the type (null not permitted). */ public void setType(HistogramType type) { if (type == null) { throw new IllegalArgumentException("Null 'type' argument"); } this.type = type; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Adds a series to the dataset, using the specified number of bins. * * @param key the series key (null not permitted). * @param values the values (null not permitted). * @param bins the number of bins (must be at least 1). */ public void addSeries(Comparable key, double[] values, int bins) { // defer argument checking... double minimum = getMinimum(values); double maximum = getMaximum(values); addSeries(key, values, bins, minimum, maximum); } /** * Adds a series to the dataset. Any data value less than minimum will be * assigned to the first bin, and any data value greater than maximum will * be assigned to the last bin. Values falling on the boundary of * adjacent bins will be assigned to the higher indexed bin. * * @param key the series key (null not permitted). * @param values the raw observations. * @param bins the number of bins (must be at least 1). * @param minimum the lower bound of the bin range. * @param maximum the upper bound of the bin range. */ public void addSeries(Comparable key, double[] values, int bins, double minimum, double maximum) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } else if (bins < 1) { throw new IllegalArgumentException( "The 'bins' value must be at least 1."); } double binWidth = (maximum - minimum) / bins; double lower = minimum; double upper; List binList = new ArrayList(bins); for (int i = 0; i < bins; i++) { HistogramBin bin; // make sure bins[bins.length]'s upper boundary ends at maximum // to avoid the rounding issue. the bins[0] lower boundary is // guaranteed start from min if (i == bins - 1) { bin = new HistogramBin(lower, maximum); } else { upper = minimum + (i + 1) * binWidth; bin = new HistogramBin(lower, upper); lower = upper; } binList.add(bin); } // fill the bins for (int i = 0; i < values.length; i++) { int binIndex = bins - 1; if (values[i] < maximum) { double fraction = (values[i] - minimum) / (maximum - minimum); if (fraction < 0.0) { fraction = 0.0; } binIndex = (int) (fraction * bins); // rounding could result in binIndex being equal to bins // which will cause an IndexOutOfBoundsException - see bug // report 1553088 if (binIndex >= bins) { binIndex = bins - 1; } } HistogramBin bin = (HistogramBin) binList.get(binIndex); bin.incrementCount(); } // generic map for each series Map map = new HashMap(); map.put("key", key); map.put("bins", binList); map.put("values.length", new Integer(values.length)); map.put("bin width", new Double(binWidth)); this.list.add(map); } /** * Returns the minimum value in an array of values. * * @param values the values (null not permitted and * zero-length array not permitted). * * @return The minimum value. */ private double getMinimum(double[] values) { if (values == null || values.length < 1) { throw new IllegalArgumentException( "Null or zero length 'values' argument."); } double min = Double.MAX_VALUE; for (int i = 0; i < values.length; i++) { if (values[i] < min) { min = values[i]; } } return min; } /** * Returns the maximum value in an array of values. * * @param values the values (null not permitted and * zero-length array not permitted). * * @return The maximum value. */ private double getMaximum(double[] values) { if (values == null || values.length < 1) { throw new IllegalArgumentException( "Null or zero length 'values' argument."); } double max = -Double.MAX_VALUE; for (int i = 0; i < values.length; i++) { if (values[i] > max) { max = values[i]; } } return max; } /** * Returns the bins for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return A list of bins. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ List getBins(int series) { Map map = (Map) this.list.get(series); return (List) map.get("bins"); } /** * Returns the total number of observations for a series. * * @param series the series index. * * @return The total. */ private int getTotal(int series) { Map map = (Map) this.list.get(series); return ((Integer) map.get("values.length")).intValue(); } /** * Returns the bin width for a series. * * @param series the series index (zero based). * * @return The bin width. */ private double getBinWidth(int series) { Map map = (Map) this.list.get(series); return ((Double) map.get("bin width")).doubleValue(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.list.size(); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The series key. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Comparable getSeriesKey(int series) { Map map = (Map) this.list.get(series); return (Comparable) map.get("key"); } /** * Returns the number of data items for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The item count. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public int getItemCount(int series) { return getBins(series).size(); } /** * Returns the X value for a bin. This value won't be used for plotting * histograms, since the renderer will ignore it. But other renderers can * use it (for example, you could use the dataset to create a line * chart). * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (zero based). * * @return The start value. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Number getX(int series, int item) { List bins = getBins(series); HistogramBin bin = (HistogramBin) bins.get(item); double x = (bin.getStartBoundary() + bin.getEndBoundary()) / 2.; return new Double(x); } /** * Returns the y-value for a bin (calculated to take into account the * histogram type). * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (zero based). * * @return The y-value. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Number getY(int series, int item) { List bins = getBins(series); HistogramBin bin = (HistogramBin) bins.get(item); double total = getTotal(series); double binWidth = getBinWidth(series); if (this.type == HistogramType.FREQUENCY) { return new Double(bin.getCount()); } else if (this.type == HistogramType.RELATIVE_FREQUENCY) { return new Double(bin.getCount() / total); } else if (this.type == HistogramType.SCALE_AREA_TO_1) { return new Double(bin.getCount() / (binWidth * total)); } else { // pretty sure this shouldn't ever happen throw new IllegalStateException(); } } /** * Returns the start value for a bin. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (zero based). * * @return The start value. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Number getStartX(int series, int item) { List bins = getBins(series); HistogramBin bin = (HistogramBin) bins.get(item); return new Double(bin.getStartBoundary()); } /** * Returns the end value for a bin. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (zero based). * * @return The end value. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Number getEndX(int series, int item) { List bins = getBins(series); HistogramBin bin = (HistogramBin) bins.get(item); return new Double(bin.getEndBoundary()); } /** * Returns the start y-value for a bin (which is the same as the y-value, * this method exists only to support the general form of the * {@link IntervalXYDataset} interface). * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (zero based). * * @return The y-value. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the end y-value for a bin (which is the same as the y-value, * this method exists only to support the general form of the * {@link IntervalXYDataset} interface). * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (zero based). * * @return The Y value. * * @throws IndexOutOfBoundsException if series is outside the * specified range. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof HistogramDataset)) { return false; } HistogramDataset that = (HistogramDataset) obj; if (!ObjectUtilities.equal(this.type, that.type)) { return false; } if (!ObjectUtilities.equal(this.list, that.list)) { return false; } return true; } /** * Returns a clone of the dataset. * * @return A clone of the dataset. * * @throws CloneNotSupportedException if the object cannot be cloned. */ public Object clone() throws CloneNotSupportedException { HistogramDataset clone = (HistogramDataset) super.clone(); int seriesCount = getSeriesCount(); clone.list = new java.util.ArrayList(seriesCount); for (int i = 0; i < seriesCount; i++) { clone.list.add(new HashMap((Map) this.list.get(i))); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/HistogramType.java0000644000175000017500000001011311173030414030071 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * HistogramType.java * ------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Mar-2004 : Version 1 (DG); * */ package org.jfree.data.statistics; import java.io.ObjectStreamException; import java.io.Serializable; /** * A class for creating constants to represent the histogram type. See Bloch's * enum tip in 'Effective Java'. */ public class HistogramType implements Serializable { /** For serialization. */ private static final long serialVersionUID = 2618927186251997727L; /** Frequency histogram. */ public static final HistogramType FREQUENCY = new HistogramType("FREQUENCY"); /** Relative frequency. */ public static final HistogramType RELATIVE_FREQUENCY = new HistogramType("RELATIVE_FREQUENCY"); /** Scale area to one. */ public static final HistogramType SCALE_AREA_TO_1 = new HistogramType("SCALE_AREA_TO_1"); /** The type name. */ private String name; /** * Creates a new type. * * @param name the name. */ private HistogramType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Tests this type for equality with an arbitrary object. * * @param obj the object to test against. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof HistogramType)) { return false; } HistogramType t = (HistogramType) obj; if (!this.name.equals(t.name)) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(HistogramType.FREQUENCY)) { return HistogramType.FREQUENCY; } else if (this.equals(HistogramType.RELATIVE_FREQUENCY)) { return HistogramType.RELATIVE_FREQUENCY; } else if (this.equals(HistogramType.SCALE_AREA_TO_1)) { return HistogramType.SCALE_AREA_TO_1; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/MeanAndStandardDeviation.java0000644000175000017500000001254211173030414032131 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * MeanAndStandardDeviation.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Feb-2002 : Version 1 (DG); * 05-Feb-2005 : Added equals() method and implemented Serializable (DG); * 02-Oct-2007 : Added getMeanValue() and getStandardDeviationValue() methods * for convenience, and toString() method for debugging (DG); * */ package org.jfree.data.statistics; import java.io.Serializable; import org.jfree.util.ObjectUtilities; /** * A simple data structure that holds a mean value and a standard deviation * value. This is used in the * {@link org.jfree.data.statistics.DefaultStatisticalCategoryDataset} class. */ public class MeanAndStandardDeviation implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7413468697315721515L; /** The mean. */ private Number mean; /** The standard deviation. */ private Number standardDeviation; /** * Creates a new mean and standard deviation record. * * @param mean the mean. * @param standardDeviation the standard deviation. */ public MeanAndStandardDeviation(double mean, double standardDeviation) { this(new Double(mean), new Double(standardDeviation)); } /** * Creates a new mean and standard deviation record. * * @param mean the mean (null permitted). * @param standardDeviation the standard deviation (null * permitted. */ public MeanAndStandardDeviation(Number mean, Number standardDeviation) { this.mean = mean; this.standardDeviation = standardDeviation; } /** * Returns the mean. * * @return The mean. */ public Number getMean() { return this.mean; } /** * Returns the mean as a double primitive. If the underlying mean is * null, this method will return Double.NaN. * * @return The mean. * * @see #getMean() * * @since 1.0.7 */ public double getMeanValue() { double result = Double.NaN; if (this.mean != null) { result = this.mean.doubleValue(); } return result; } /** * Returns the standard deviation. * * @return The standard deviation. */ public Number getStandardDeviation() { return this.standardDeviation; } /** * Returns the standard deviation as a double primitive. If the underlying * standard deviation is null, this method will return * Double.NaN. * * @return The standard deviation. * * @since 1.0.7 */ public double getStandardDeviationValue() { double result = Double.NaN; if (this.standardDeviation != null) { result = this.standardDeviation.doubleValue(); } return result; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MeanAndStandardDeviation)) { return false; } MeanAndStandardDeviation that = (MeanAndStandardDeviation) obj; if (!ObjectUtilities.equal(this.mean, that.mean)) { return false; } if (!ObjectUtilities.equal( this.standardDeviation, that.standardDeviation) ) { return false; } return true; } /** * Returns a string representing this instance. * * @return A string. * * @since 1.0.7 */ public String toString() { return "[" + this.mean + ", " + this.standardDeviation + "]"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/MultiValueCategoryDataset.java0000644000175000017500000000513711173030414032377 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * MultiValueCategoryDataset.java * ------------------------------ * (C) Copyright 2007, 2008, by David Forslund and Contributors. * * Original Author: David Forslund; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 08-Oct-2007 : Version 1, see patch 1780779 (DG); * */ package org.jfree.data.statistics; import java.util.List; import org.jfree.data.category.CategoryDataset; /** * A category dataset that defines multiple values for each item. * * @since 1.0.7 */ public interface MultiValueCategoryDataset extends CategoryDataset { /** * Returns a list (possibly empty) of the values for the specified item. * The returned list should be unmodifiable. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The list of values. */ public List getValues(int row, int column); /** * Returns a list (possibly empty) of the values for the specified item. * The returned list should be unmodifiable. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The list of values. */ public List getValues(Comparable rowKey, Comparable columnKey); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/Regression.java0000644000175000017500000001572011173030414027423 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * Regression.java * --------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Sep-2002 : Version 1 (DG); * 18-Aug-2003 : Added 'abstract' (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * */ package org.jfree.data.statistics; import org.jfree.data.xy.XYDataset; /** * A utility class for fitting regression curves to data. */ public abstract class Regression { /** * Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to * the data using ordinary least squares regression. The result is * returned as a double[], where result[0] --> a, and result[1] --> b. * * @param data the data. * * @return The parameters. */ public static double[] getOLSRegression(double[][] data) { int n = data.length; if (n < 2) { throw new IllegalArgumentException("Not enough data."); } double sumX = 0; double sumY = 0; double sumXX = 0; double sumXY = 0; for (int i = 0; i < n; i++) { double x = data[i][0]; double y = data[i][1]; sumX += x; sumY += y; double xx = x * x; sumXX += xx; double xy = x * y; sumXY += xy; } double sxx = sumXX - (sumX * sumX) / n; double sxy = sumXY - (sumX * sumY) / n; double xbar = sumX / n; double ybar = sumY / n; double[] result = new double[2]; result[1] = sxy / sxx; result[0] = ybar - result[1] * xbar; return result; } /** * Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to * the data using ordinary least squares regression. The result is returned * as a double[], where result[0] --> a, and result[1] --> b. * * @param data the data. * @param series the series (zero-based index). * * @return The parameters. */ public static double[] getOLSRegression(XYDataset data, int series) { int n = data.getItemCount(series); if (n < 2) { throw new IllegalArgumentException("Not enough data."); } double sumX = 0; double sumY = 0; double sumXX = 0; double sumXY = 0; for (int i = 0; i < n; i++) { double x = data.getXValue(series, i); double y = data.getYValue(series, i); sumX += x; sumY += y; double xx = x * x; sumXX += xx; double xy = x * y; sumXY += xy; } double sxx = sumXX - (sumX * sumX) / n; double sxy = sumXY - (sumX * sumY) / n; double xbar = sumX / n; double ybar = sumY / n; double[] result = new double[2]; result[1] = sxy / sxx; result[0] = ybar - result[1] * xbar; return result; } /** * Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to * the data using a power regression equation. The result is returned as * an array, where double[0] --> a, and double[1] --> b. * * @param data the data. * * @return The parameters. */ public static double[] getPowerRegression(double[][] data) { int n = data.length; if (n < 2) { throw new IllegalArgumentException("Not enough data."); } double sumX = 0; double sumY = 0; double sumXX = 0; double sumXY = 0; for (int i = 0; i < n; i++) { double x = Math.log(data[i][0]); double y = Math.log(data[i][1]); sumX += x; sumY += y; double xx = x * x; sumXX += xx; double xy = x * y; sumXY += xy; } double sxx = sumXX - (sumX * sumX) / n; double sxy = sumXY - (sumX * sumY) / n; double xbar = sumX / n; double ybar = sumY / n; double[] result = new double[2]; result[1] = sxy / sxx; result[0] = Math.pow(Math.exp(1.0), ybar - result[1] * xbar); return result; } /** * Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to * the data using a power regression equation. The result is returned as * an array, where double[0] --> a, and double[1] --> b. * * @param data the data. * @param series the series to fit the regression line against. * * @return The parameters. */ public static double[] getPowerRegression(XYDataset data, int series) { int n = data.getItemCount(series); if (n < 2) { throw new IllegalArgumentException("Not enough data."); } double sumX = 0; double sumY = 0; double sumXX = 0; double sumXY = 0; for (int i = 0; i < n; i++) { double x = Math.log(data.getXValue(series, i)); double y = Math.log(data.getYValue(series, i)); sumX += x; sumY += y; double xx = x * x; sumXX += xx; double xy = x * y; sumXY += xy; } double sxx = sumXX - (sumX * sumX) / n; double sxy = sumXY - (sumX * sumY) / n; double xbar = sumX / n; double ybar = sumY / n; double[] result = new double[2]; result[1] = sxy / sxx; result[0] = Math.pow(Math.exp(1.0), ybar - result[1] * xbar); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/SimpleHistogramBin.java0000644000175000017500000001703711173030414031046 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * SimpleHistogramBin.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jan-2005 : Version 1 (DG); * */ package org.jfree.data.statistics; import java.io.Serializable; import org.jfree.util.PublicCloneable; /** * A bin for the {@link SimpleHistogramDataset}. */ public class SimpleHistogramBin implements Comparable, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3480862537505941742L; /** The lower bound for the bin. */ private double lowerBound; /** The upper bound for the bin. */ private double upperBound; /** * A flag that controls whether the lower bound is included in the bin * range. */ private boolean includeLowerBound; /** * A flag that controls whether the upper bound is included in the bin * range. */ private boolean includeUpperBound; /** The item count. */ private int itemCount; /** * Creates a new bin. * * @param lowerBound the lower bound (inclusive). * @param upperBound the upper bound (inclusive); */ public SimpleHistogramBin(double lowerBound, double upperBound) { this(lowerBound, upperBound, true, true); } /** * Creates a new bin. * * @param lowerBound the lower bound. * @param upperBound the upper bound. * @param includeLowerBound include the lower bound? * @param includeUpperBound include the upper bound? */ public SimpleHistogramBin(double lowerBound, double upperBound, boolean includeLowerBound, boolean includeUpperBound) { if (lowerBound >= upperBound) { throw new IllegalArgumentException("Invalid bounds"); } this.lowerBound = lowerBound; this.upperBound = upperBound; this.includeLowerBound = includeLowerBound; this.includeUpperBound = includeUpperBound; this.itemCount = 0; } /** * Returns the lower bound. * * @return The lower bound. */ public double getLowerBound() { return this.lowerBound; } /** * Return the upper bound. * * @return The upper bound. */ public double getUpperBound() { return this.upperBound; } /** * Returns the item count. * * @return The item count. */ public int getItemCount() { return this.itemCount; } /** * Sets the item count. * * @param count the item count. */ public void setItemCount(int count) { this.itemCount = count; } /** * Returns true if the specified value belongs in the bin, * and false otherwise. * * @param value the value. * * @return A boolean. */ public boolean accepts(double value) { if (Double.isNaN(value)) { return false; } if (value < this.lowerBound) { return false; } if (value > this.upperBound) { return false; } if (value == this.lowerBound) { return this.includeLowerBound; } if (value == this.upperBound) { return this.includeUpperBound; } return true; } /** * Returns true if this bin overlaps with the specified bin, * and false otherwise. * * @param bin the other bin (null not permitted). * * @return A boolean. */ public boolean overlapsWith(SimpleHistogramBin bin) { if (this.upperBound < bin.lowerBound) { return false; } if (this.lowerBound > bin.upperBound) { return false; } if (this.upperBound == bin.lowerBound) { return this.includeUpperBound && bin.includeLowerBound; } if (this.lowerBound == bin.upperBound) { return this.includeLowerBound && bin.includeUpperBound; } return true; } /** * Compares the bin to an arbitrary object and returns the relative * ordering. * * @param obj the object. * * @return An integer indicating the relative ordering of the this bin and * the given object. */ public int compareTo(Object obj) { if (!(obj instanceof SimpleHistogramBin)) { return 0; } SimpleHistogramBin bin = (SimpleHistogramBin) obj; if (this.lowerBound < bin.lowerBound) { return -1; } if (this.lowerBound > bin.lowerBound) { return 1; } // lower bounds are the same if (this.upperBound < bin.upperBound) { return -1; } if (this.upperBound > bin.upperBound) { return 1; } return 0; } /** * Tests this bin for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (!(obj instanceof SimpleHistogramBin)) { return false; } SimpleHistogramBin that = (SimpleHistogramBin) obj; if (this.lowerBound != that.lowerBound) { return false; } if (this.upperBound != that.upperBound) { return false; } if (this.includeLowerBound != that.includeLowerBound) { return false; } if (this.includeUpperBound != that.includeUpperBound) { return false; } if (this.itemCount != that.itemCount) { return false; } return true; } /** * Returns a clone of the bin. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/SimpleHistogramDataset.java0000644000175000017500000003524111173030414031720 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * SimpleHistogramDataset.java * --------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Sergei Ivanov; * * Changes * ------- * 10-Jan-2005 : Version 1 (DG); * 21-May-2007 : Added clearObservations() and removeAllBins() (SI); * 10-Jul-2007 : Added null argument check to constructor (DG); * */ package org.jfree.data.statistics; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.data.DomainOrder; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A dataset used for creating simple histograms with custom defined bins. * * @see HistogramDataset */ public class SimpleHistogramDataset extends AbstractIntervalXYDataset implements IntervalXYDataset, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7997996479768018443L; /** The series key. */ private Comparable key; /** The bins. */ private List bins; /** * A flag that controls whether or not the bin count is divided by the * bin size. */ private boolean adjustForBinSize; /** * Creates a new histogram dataset. Note that the * adjustForBinSize flag defaults to true. * * @param key the series key (null not permitted). */ public SimpleHistogramDataset(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.key = key; this.bins = new ArrayList(); this.adjustForBinSize = true; } /** * Returns a flag that controls whether or not the bin count is divided by * the bin size in the {@link #getXValue(int, int)} method. * * @return A boolean. * * @see #setAdjustForBinSize(boolean) */ public boolean getAdjustForBinSize() { return this.adjustForBinSize; } /** * Sets the flag that controls whether or not the bin count is divided by * the bin size in the {@link #getYValue(int, int)} method, and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param adjust the flag. * * @see #getAdjustForBinSize() */ public void setAdjustForBinSize(boolean adjust) { this.adjustForBinSize = adjust; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Returns the number of series in the dataset (always 1 for this dataset). * * @return The series count. */ public int getSeriesCount() { return 1; } /** * Returns the key for a series. Since this dataset only stores a single * series, the series argument is ignored. * * @param series the series (zero-based index, ignored in this dataset). * * @return The key for the series. */ public Comparable getSeriesKey(int series) { return this.key; } /** * Returns the order of the domain (or X) values returned by the dataset. * * @return The order (never null). */ public DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; } /** * Returns the number of items in a series. Since this dataset only stores * a single series, the series argument is ignored. * * @param series the series index (zero-based, ignored in this dataset). * * @return The item count. */ public int getItemCount(int series) { return this.bins.size(); } /** * Adds a bin to the dataset. An exception is thrown if the bin overlaps * with any existing bin in the dataset. * * @param bin the bin (null not permitted). * * @see #removeAllBins() */ public void addBin(SimpleHistogramBin bin) { // check that the new bin doesn't overlap with any existing bin Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin existingBin = (SimpleHistogramBin) iterator.next(); if (bin.overlapsWith(existingBin)) { throw new RuntimeException("Overlapping bin"); } } this.bins.add(bin); Collections.sort(this.bins); } /** * Adds an observation to the dataset (by incrementing the item count for * the appropriate bin). A runtime exception is thrown if the value does * not fit into any bin. * * @param value the value. */ public void addObservation(double value) { addObservation(value, true); } /** * Adds an observation to the dataset (by incrementing the item count for * the appropriate bin). A runtime exception is thrown if the value does * not fit into any bin. * * @param value the value. * @param notify send {@link DatasetChangeEvent} to listeners? */ public void addObservation(double value, boolean notify) { boolean placed = false; Iterator iterator = this.bins.iterator(); while (iterator.hasNext() && !placed) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); if (bin.accepts(value)) { bin.setItemCount(bin.getItemCount() + 1); placed = true; } } if (!placed) { throw new RuntimeException("No bin."); } if (notify) { notifyListeners(new DatasetChangeEvent(this, this)); } } /** * Adds a set of values to the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param values the values (null not permitted). * * @see #clearObservations() */ public void addObservations(double[] values) { for (int i = 0; i < values.length; i++) { addObservation(values[i], false); } notifyListeners(new DatasetChangeEvent(this, this)); } /** * Removes all current observation data and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.6 * * @see #addObservations(double[]) * @see #removeAllBins() */ public void clearObservations() { Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); bin.setItemCount(0); } notifyListeners(new DatasetChangeEvent(this, this)); } /** * Removes all bins and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @since 1.0.6 * * @see #addBin(SimpleHistogramBin) */ public void removeAllBins() { this.bins = new ArrayList(); notifyListeners(new DatasetChangeEvent(this, this)); } /** * Returns the x-value for an item within a series. The x-values may or * may not be returned in ascending order, that is up to the class * implementing the interface. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value (never null). */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value. */ public double getXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return (bin.getLowerBound() + bin.getUpperBound()) / 2.0; } /** * Returns the y-value for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value (possibly null). */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value. * * @see #getAdjustForBinSize() */ public double getYValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); if (this.adjustForBinSize) { return bin.getItemCount() / (bin.getUpperBound() - bin.getLowerBound()); } else { return bin.getItemCount(); } } /** * Returns the starting X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); } /** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The start x-value. */ public double getStartXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return bin.getLowerBound(); } /** * Returns the ending X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); } /** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The end x-value. */ public double getEndXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return bin.getUpperBound(); } /** * Returns the starting Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the start y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The start y-value. */ public double getStartYValue(int series, int item) { return getYValue(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Returns the end y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The end y-value. */ public double getEndYValue(int series, int item) { return getYValue(series, item); } /** * Compares the dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SimpleHistogramDataset)) { return false; } SimpleHistogramDataset that = (SimpleHistogramDataset) obj; if (!this.key.equals(that.key)) { return false; } if (this.adjustForBinSize != that.adjustForBinSize) { return false; } if (!this.bins.equals(that.bins)) { return false; } return true; } /** * Returns a clone of the dataset. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class, but maybe * by subclasses (if any). */ public Object clone() throws CloneNotSupportedException { SimpleHistogramDataset clone = (SimpleHistogramDataset) super.clone(); clone.bins = (List) ObjectUtilities.deepClone(this.bins); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/StatisticalCategoryDataset.java0000644000175000017500000000654611173030414032601 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * StatisticalCategoryDataset.java * ------------------------------- * (C) Copyright 2002-2009, by Pascal Collet and Contributors. * * Original Author: Pascal Collet; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 21-Aug-2002 : Version 1, contributed by Pascal Collet (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 24-Oct-2002 : Amendments in line with changes to the CategoryDataset * interface (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); * */ package org.jfree.data.statistics; import org.jfree.data.category.CategoryDataset; /** * A category dataset that defines a mean and standard deviation value for * each item. */ public interface StatisticalCategoryDataset extends CategoryDataset { /** * Returns the mean value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The mean value (possibly null). */ public Number getMeanValue(int row, int column); /** * Returns the mean value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The mean value (possibly null). */ public Number getMeanValue(Comparable rowKey, Comparable columnKey); /** * Returns the standard deviation value for an item. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The standard deviation (possibly null). */ public Number getStdDevValue(int row, int column); /** * Returns the standard deviation value for an item. * * @param rowKey the row key. * @param columnKey the columnKey. * * @return The standard deviation (possibly null). */ public Number getStdDevValue(Comparable rowKey, Comparable columnKey); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/Statistics.java0000644000175000017500000004225511173030414027440 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * Statistics.java * --------------- * (C) Copyright 2000-2008, by Matthew Wright and Contributors. * * Original Author: Matthew Wright; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 08-Nov-2001) * -------------------------- * 08-Nov-2001 : Added standard header and tidied Javadoc comments (DG); * Moved from JFreeChart to package com.jrefinery.data.* in * JCommon class library (DG); * 24-Jun-2002 : Removed unnecessary local variable (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 26-May-2004 : Moved calculateMean() method from BoxAndWhiskerCalculator (DG); * 02-Jun-2004 : Fixed bug in calculateMedian() method (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * */ package org.jfree.data.statistics; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; /** * A utility class that provides some common statistical functions. */ public abstract class Statistics { /** * Returns the mean of an array of numbers. This is equivalent to calling * calculateMean(values, true). * * @param values the values (null not permitted). * * @return The mean. */ public static double calculateMean(Number[] values) { return calculateMean(values, true); } /** * Returns the mean of an array of numbers. * * @param values the values (null not permitted). * @param includeNullAndNaN a flag that controls whether or not * null and Double.NaN values are included * in the calculation (if either is present in the array, the result is * {@link Double#NaN}). * * @return The mean. * * @since 1.0.3 */ public static double calculateMean(Number[] values, boolean includeNullAndNaN) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double sum = 0.0; double current; int counter = 0; for (int i = 0; i < values.length; i++) { // treat nulls the same as NaNs if (values[i] != null) { current = values[i].doubleValue(); } else { current = Double.NaN; } // calculate the sum and count if (includeNullAndNaN || !Double.isNaN(current)) { sum = sum + current; counter++; } } double result = (sum / counter); return result; } /** * Returns the mean of a collection of Number objects. * * @param values the values (null not permitted). * * @return The mean. */ public static double calculateMean(Collection values) { return calculateMean(values, true); } /** * Returns the mean of a collection of Number objects. * * @param values the values (null not permitted). * @param includeNullAndNaN a flag that controls whether or not * null and Double.NaN values are included * in the calculation (if either is present in the array, the result is * {@link Double#NaN}). * * @return The mean. * * @since 1.0.3 */ public static double calculateMean(Collection values, boolean includeNullAndNaN) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } int count = 0; double total = 0.0; Iterator iterator = values.iterator(); while (iterator.hasNext()) { Object object = iterator.next(); if (object == null) { if (includeNullAndNaN) { return Double.NaN; } } else { if (object instanceof Number) { Number number = (Number) object; double value = number.doubleValue(); if (Double.isNaN(value)) { if (includeNullAndNaN) { return Double.NaN; } } else { total = total + number.doubleValue(); count = count + 1; } } } } return total / count; } /** * Calculates the median for a list of values (Number objects). * The list of values will be copied, and the copy sorted, before * calculating the median. To avoid this step (if your list of values * is already sorted), use the {@link #calculateMedian(List, boolean)} * method. * * @param values the values (null permitted). * * @return The median. */ public static double calculateMedian(List values) { return calculateMedian(values, true); } /** * Calculates the median for a list of values (Number objects). * If copyAndSort is false, the list is assumed * to be presorted in ascending order by value. * * @param values the values (null permitted). * @param copyAndSort a flag that controls whether the list of values is * copied and sorted. * * @return The median. */ public static double calculateMedian(List values, boolean copyAndSort) { double result = Double.NaN; if (values != null) { if (copyAndSort) { int itemCount = values.size(); List copy = new ArrayList(itemCount); for (int i = 0; i < itemCount; i++) { copy.add(i, values.get(i)); } Collections.sort(copy); values = copy; } int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { Number value = (Number) values.get((count - 1) / 2); result = value.doubleValue(); } else { Number value = (Number) values.get(0); result = value.doubleValue(); } } else { Number value1 = (Number) values.get(count / 2 - 1); Number value2 = (Number) values.get(count / 2); result = (value1.doubleValue() + value2.doubleValue()) / 2.0; } } } return result; } /** * Calculates the median for a sublist within a list of values * (Number objects). * * @param values the values, in any order (null not * permitted). * @param start the start index. * @param end the end index. * * @return The median. */ public static double calculateMedian(List values, int start, int end) { return calculateMedian(values, start, end, true); } /** * Calculates the median for a sublist within a list of values * (Number objects). The entire list will be sorted if the * ascendingfalse. * * @param values the values (null not permitted). * @param start the start index. * @param end the end index. * @param copyAndSort a flag that that controls whether the list of values * is copied and sorted. * * @return The median. */ public static double calculateMedian(List values, int start, int end, boolean copyAndSort) { double result = Double.NaN; if (copyAndSort) { List working = new ArrayList(end - start + 1); for (int i = start; i <= end; i++) { working.add(values.get(i)); } Collections.sort(working); result = calculateMedian(working, false); } else { int count = end - start + 1; if (count > 0) { if (count % 2 == 1) { if (count > 1) { Number value = (Number) values.get(start + (count - 1) / 2); result = value.doubleValue(); } else { Number value = (Number) values.get(start); result = value.doubleValue(); } } else { Number value1 = (Number) values.get(start + count / 2 - 1); Number value2 = (Number) values.get(start + count / 2); result = (value1.doubleValue() + value2.doubleValue()) / 2.0; } } } return result; } /** * Returns the standard deviation of a set of numbers. * * @param data the data (null or zero length array not * permitted). * * @return The standard deviation of a set of numbers. */ public static double getStdDev(Number[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' array."); } if (data.length == 0) { throw new IllegalArgumentException("Zero length 'data' array."); } double avg = calculateMean(data); double sum = 0.0; for (int counter = 0; counter < data.length; counter++) { double diff = data[counter].doubleValue() - avg; sum = sum + diff * diff; } return Math.sqrt(sum / (data.length - 1)); } /** * Fits a straight line to a set of (x, y) data, returning the slope and * intercept. * * @param xData the x-data (null not permitted). * @param yData the y-data (null not permitted). * * @return A double array with the intercept in [0] and the slope in [1]. */ public static double[] getLinearFit(Number[] xData, Number[] yData) { if (xData == null) { throw new IllegalArgumentException("Null 'xData' argument."); } if (yData == null) { throw new IllegalArgumentException("Null 'yData' argument."); } if (xData.length != yData.length) { throw new IllegalArgumentException( "Statistics.getLinearFit(): array lengths must be equal."); } double[] result = new double[2]; // slope result[1] = getSlope(xData, yData); // intercept result[0] = calculateMean(yData) - result[1] * calculateMean(xData); return result; } /** * Finds the slope of a regression line using least squares. * * @param xData the x-values (null not permitted). * @param yData the y-values (null not permitted). * * @return The slope. */ public static double getSlope(Number[] xData, Number[] yData) { if (xData == null) { throw new IllegalArgumentException("Null 'xData' argument."); } if (yData == null) { throw new IllegalArgumentException("Null 'yData' argument."); } if (xData.length != yData.length) { throw new IllegalArgumentException("Array lengths must be equal."); } // ********* stat function for linear slope ******** // y = a + bx // a = ybar - b * xbar // sum(x * y) - (sum (x) * sum(y)) / n // b = ------------------------------------ // sum (x^2) - (sum(x)^2 / n // ************************************************* // sum of x, x^2, x * y, y double sx = 0.0, sxx = 0.0, sxy = 0.0, sy = 0.0; int counter; for (counter = 0; counter < xData.length; counter++) { sx = sx + xData[counter].doubleValue(); sxx = sxx + Math.pow(xData[counter].doubleValue(), 2); sxy = sxy + yData[counter].doubleValue() * xData[counter].doubleValue(); sy = sy + yData[counter].doubleValue(); } return (sxy - (sx * sy) / counter) / (sxx - (sx * sx) / counter); } /** * Calculates the correlation between two datasets. Both arrays should * contain the same number of items. Null values are treated as zero. *

* Information about the correlation calculation was obtained from: * * http://trochim.human.cornell.edu/kb/statcorr.htm * * @param data1 the first dataset. * @param data2 the second dataset. * * @return The correlation. */ public static double getCorrelation(Number[] data1, Number[] data2) { if (data1 == null) { throw new IllegalArgumentException("Null 'data1' argument."); } if (data2 == null) { throw new IllegalArgumentException("Null 'data2' argument."); } if (data1.length != data2.length) { throw new IllegalArgumentException( "'data1' and 'data2' arrays must have same length." ); } int n = data1.length; double sumX = 0.0; double sumY = 0.0; double sumX2 = 0.0; double sumY2 = 0.0; double sumXY = 0.0; for (int i = 0; i < n; i++) { double x = 0.0; if (data1[i] != null) { x = data1[i].doubleValue(); } double y = 0.0; if (data2[i] != null) { y = data2[i].doubleValue(); } sumX = sumX + x; sumY = sumY + y; sumXY = sumXY + (x * y); sumX2 = sumX2 + (x * x); sumY2 = sumY2 + (y * y); } return (n * sumXY - sumX * sumY) / Math.pow((n * sumX2 - sumX * sumX) * (n * sumY2 - sumY * sumY), 0.5); } /** * Returns a data set for a moving average on the data set passed in. * * @param xData an array of the x data. * @param yData an array of the y data. * @param period the number of data points to average * * @return A double[][] the length of the data set in the first dimension, * with two doubles for x and y in the second dimension */ public static double[][] getMovingAverage(Number[] xData, Number[] yData, int period) { // check arguments... if (xData.length != yData.length) { throw new IllegalArgumentException("Array lengths must be equal."); } if (period > xData.length) { throw new IllegalArgumentException( "Period can't be longer than dataset." ); } double[][] result = new double[xData.length - period][2]; for (int i = 0; i < result.length; i++) { result[i][0] = xData[i + period].doubleValue(); // holds the moving average sum double sum = 0.0; for (int j = 0; j < period; j++) { sum += yData[i + j].doubleValue(); } sum = sum / period; result[i][1] = sum; } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/statistics/package.html0000644000175000017500000000022711173030414026715 0ustar vincentvincent Classes for representing statistical data. libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/0000755000175000017500000000000011216245562023211 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/time/ohlc/0000755000175000017500000000000011216245562024136 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/time/ohlc/OHLC.java0000644000175000017500000000725711173030414025527 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * OHLC.java * --------- * (C) Copyright 2006, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * */ package org.jfree.data.time.ohlc; import java.io.Serializable; /** * A high low data record (immutable). This class is used internally by the * {@link OHLCItem} class. * * @since 1.0.4 */ public class OHLC implements Serializable { /** The open value. */ private double open; /** The close value. */ private double close; /** The high value. */ private double high; /** The low value. */ private double low; /** * Creates a new instance of OHLC. * * @param open the open value. * @param close the close value. * @param high the high value. * @param low the low value. */ public OHLC(double open, double high, double low, double close) { this.open = open; this.close = close; this.high = high; this.low = low; } /** * Returns the open value. * * @return The open value. */ public double getOpen() { return this.open; } /** * Returns the close value. * * @return The close value. */ public double getClose() { return this.close; } /** * Returns the high value. * * @return The high value. */ public double getHigh() { return this.high; } /** * Returns the low value. * * @return The low value. */ public double getLow() { return this.low; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof OHLC)) { return false; } OHLC that = (OHLC) obj; if (this.open != that.open) { return false; } if (this.close != that.close) { return false; } if (this.high != that.high) { return false; } if (this.low != that.low) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/ohlc/OHLCItem.java0000644000175000017500000000744311173030414026343 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * OHLCItem.java * ------------- * (C) Copyright 2006, 2007, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * */ package org.jfree.data.time.ohlc; import org.jfree.data.ComparableObjectItem; import org.jfree.data.time.RegularTimePeriod; /** * An item representing data in the form (period, open, high, low, close). * * @since 1.0.4 */ public class OHLCItem extends ComparableObjectItem { /** * Creates a new instance of OHLCItem. * * @param period the time period. * @param open the open-value. * @param high the high-value. * @param low the low-value. * @param close the close-value. */ public OHLCItem(RegularTimePeriod period, double open, double high, double low, double close) { super(period, new OHLC(open, high, low, close)); } /** * Returns the period. * * @return The period (never null). */ public RegularTimePeriod getPeriod() { return (RegularTimePeriod) getComparable(); } /** * Returns the y-value. * * @return The y-value. */ public double getYValue() { return getCloseValue(); } /** * Returns the open value. * * @return The open value. */ public double getOpenValue() { OHLC ohlc = (OHLC) getObject(); if (ohlc != null) { return ohlc.getOpen(); } else { return Double.NaN; } } /** * Returns the high value. * * @return The high value. */ public double getHighValue() { OHLC ohlc = (OHLC) getObject(); if (ohlc != null) { return ohlc.getHigh(); } else { return Double.NaN; } } /** * Returns the low value. * * @return The low value. */ public double getLowValue() { OHLC ohlc = (OHLC) getObject(); if (ohlc != null) { return ohlc.getLow(); } else { return Double.NaN; } } /** * Returns the close value. * * @return The close value. */ public double getCloseValue() { OHLC ohlc = (OHLC) getObject(); if (ohlc != null) { return ohlc.getClose(); } else { return Double.NaN; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/ohlc/OHLCSeries.java0000644000175000017500000000702311173030414026671 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * OHLCSeries.java * --------------- * (C) Copyright 2006, 2007, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * */ package org.jfree.data.time.ohlc; import org.jfree.data.ComparableObjectItem; import org.jfree.data.ComparableObjectSeries; import org.jfree.data.time.RegularTimePeriod; /** * A list of (RegularTimePeriod, open, high, low, close) data items. * * @since 1.0.4 * * @see OHLCSeriesCollection */ public class OHLCSeries extends ComparableObjectSeries { /** * Creates a new empty series. By default, items added to the series will * be sorted into ascending order by period, and duplicate periods will * not be allowed. * * @param key the series key (null not permitted). */ public OHLCSeries(Comparable key) { super(key, true, false); } /** * Returns the time period for the specified item. * * @param index the item index. * * @return The time period. */ public RegularTimePeriod getPeriod(int index) { final OHLCItem item = (OHLCItem) getDataItem(index); return item.getPeriod(); } /** * Returns the data item at the specified index. * * @param index the item index. * * @return The data item. */ public ComparableObjectItem getDataItem(int index) { return super.getDataItem(index); } /** * Adds a data item to the series. * * @param period the period. * @param open the open-value. * @param high the high-value. * @param low the low-value. * @param close the close-value. */ public void add(RegularTimePeriod period, double open, double high, double low, double close) { if (getItemCount() > 0) { OHLCItem item0 = (OHLCItem) this.getDataItem(0); if (!period.getClass().equals(item0.getPeriod().getClass())) { throw new IllegalArgumentException( "Can't mix RegularTimePeriod class types."); } } super.add(new OHLCItem(period, open, high, low, close), true); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java0000644000175000017500000003011511173030414030703 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * OHLCSeriesCollection.java * ------------------------- * (C) Copyright 2006, 2007, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * 10-Jul-2008 : Added accessor methods for xPosition attribute (DG); */ package org.jfree.data.time.ohlc; import java.io.Serializable; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimePeriodAnchor; import org.jfree.data.xy.AbstractXYDataset; import org.jfree.data.xy.OHLCDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.ObjectUtilities; /** * A collection of {@link OHLCSeries} objects. * * @since 1.0.4 * * @see OHLCSeries */ public class OHLCSeriesCollection extends AbstractXYDataset implements OHLCDataset, Serializable { /** Storage for the data series. */ private List data; private TimePeriodAnchor xPosition = TimePeriodAnchor.MIDDLE; /** * Creates a new instance of OHLCSeriesCollection. */ public OHLCSeriesCollection() { this.data = new java.util.ArrayList(); } /** * Returns the position within each time period that is used for the X * value when the collection is used as an {@link XYDataset}. * * @return The anchor position (never null). * * @since 1.0.11 */ public TimePeriodAnchor getXPosition() { return this.xPosition; } /** * Sets the position within each time period that is used for the X values * when the collection is used as an {@link XYDataset}, then sends a * {@link DatasetChangeEvent} is sent to all registered listeners. * * @param anchor the anchor position (null not permitted). * * @since 1.0.11 */ public void setXPosition(TimePeriodAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.xPosition = anchor; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(OHLCSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public OHLCSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (OHLCSeries) this.data.get(series); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for a series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public int getItemCount(int series) { // defer argument checking return getSeries(series).getItemCount(); } /** * Returns the x-value for a time period. * * @param period the time period (null not permitted). * * @return The x-value. */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(); } return result; } /** * Returns the x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public double getXValue(int series, int item) { OHLCSeries s = (OHLCSeries) this.data.get(series); OHLCItem di = (OHLCItem) s.getDataItem(item); RegularTimePeriod period = di.getPeriod(); return getX(period); } /** * Returns the x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The y-value. */ public Number getY(int series, int item) { OHLCSeries s = (OHLCSeries) this.data.get(series); OHLCItem di = (OHLCItem) s.getDataItem(item); return new Double(di.getYValue()); } /** * Returns the open-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The open-value. */ public double getOpenValue(int series, int item) { OHLCSeries s = (OHLCSeries) this.data.get(series); OHLCItem di = (OHLCItem) s.getDataItem(item); return di.getOpenValue(); } /** * Returns the open-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The open-value. */ public Number getOpen(int series, int item) { return new Double(getOpenValue(series, item)); } /** * Returns the close-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The close-value. */ public double getCloseValue(int series, int item) { OHLCSeries s = (OHLCSeries) this.data.get(series); OHLCItem di = (OHLCItem) s.getDataItem(item); return di.getCloseValue(); } /** * Returns the close-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The close-value. */ public Number getClose(int series, int item) { return new Double(getCloseValue(series, item)); } /** * Returns the high-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The high-value. */ public double getHighValue(int series, int item) { OHLCSeries s = (OHLCSeries) this.data.get(series); OHLCItem di = (OHLCItem) s.getDataItem(item); return di.getHighValue(); } /** * Returns the high-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The high-value. */ public Number getHigh(int series, int item) { return new Double(getHighValue(series, item)); } /** * Returns the low-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The low-value. */ public double getLowValue(int series, int item) { OHLCSeries s = (OHLCSeries) this.data.get(series); OHLCItem di = (OHLCItem) s.getDataItem(item); return di.getLowValue(); } /** * Returns the low-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The low-value. */ public Number getLow(int series, int item) { return new Double(getLowValue(series, item)); } /** * Returns null always, because this dataset doesn't record * any volume data. * * @param series the series index (ignored). * @param item the item index (ignored). * * @return null. */ public Number getVolume(int series, int item) { return null; } /** * Returns Double.NaN always, because this dataset doesn't * record any volume data. * * @param series the series index (ignored). * @param item the item index (ignored). * * @return Double.NaN. */ public double getVolumeValue(int series, int item) { return Double.NaN; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof OHLCSeriesCollection)) { return false; } OHLCSeriesCollection that = (OHLCSeriesCollection) obj; if (!this.xPosition.equals(that.xPosition)) { return false; } return ObjectUtilities.equal(this.data, that.data); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem. */ public Object clone() throws CloneNotSupportedException { OHLCSeriesCollection clone = (OHLCSeriesCollection) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/ohlc/package.html0000644000175000017500000000026111173030414026404 0ustar vincentvincent Classes for representing financial data in open-high-low-close form. libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/DateRange.java0000644000175000017500000001213011173030414025671 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * DateRange.java * -------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Bill Kelemen; * * Changes * ------- * 22-Apr-2002 : Version 1 based on code by Bill Kelemen (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Sep-2003 : Minor Javadoc update (DG); * 28-May-2008 : Fixed problem with immutability (DG); * 01-Sep-2008 : Added getLowerMillis() and getUpperMillis() (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.text.DateFormat; import java.util.Date; import org.jfree.data.Range; /** * A range specified in terms of two java.util.Date objects. * Instances of this class are immutable. */ public class DateRange extends Range implements Serializable { /** For serialization. */ private static final long serialVersionUID = -4705682568375418157L; /** The lower bound for the range. */ private long lowerDate; /** The upper bound for the range. */ private long upperDate; /** * Default constructor. */ public DateRange() { this(new Date(0), new Date(1)); } /** * Constructs a new range. * * @param lower the lower bound (null not permitted). * @param upper the upper bound (null not permitted). */ public DateRange(Date lower, Date upper) { super(lower.getTime(), upper.getTime()); this.lowerDate = lower.getTime(); this.upperDate = upper.getTime(); } /** * Constructs a new range using two values that will be interpreted as * "milliseconds since midnight GMT, 1-Jan-1970". * * @param lower the lower (oldest) date. * @param upper the upper (most recent) date. */ public DateRange(double lower, double upper) { super(lower, upper); this.lowerDate = (long) lower; this.upperDate = (long) upper; } /** * Constructs a new range that is based on another {@link Range}. The * other range does not have to be a {@link DateRange}. If it is not, the * upper and lower bounds are evaluated as milliseconds since midnight * GMT, 1-Jan-1970. * * @param other the other range (null not permitted). */ public DateRange(Range other) { this(other.getLowerBound(), other.getUpperBound()); } /** * Returns the lower (earlier) date for the range. * * @return The lower date for the range. * * @see #getLowerMillis() */ public Date getLowerDate() { return new Date(this.lowerDate); } /** * Returns the lower bound of the range in milliseconds. * * @return The lower bound. * * @see #getLowerDate() * * @since 1.0.11 */ public long getLowerMillis() { return this.lowerDate; } /** * Returns the upper (later) date for the range. * * @return The upper date for the range. * * @see #getUpperMillis() */ public Date getUpperDate() { return new Date(this.upperDate); } /** * Returns the upper bound of the range in milliseconds. * * @return The upper bound. * * @see #getUpperDate() * * @since 1.0.11 */ public long getUpperMillis() { return this.upperDate; } /** * Returns a string representing the date range (useful for debugging). * * @return A string representing the date range. */ public String toString() { DateFormat df = DateFormat.getDateTimeInstance(); return "[" + df.format(getLowerDate()) + " --> " + df.format(getUpperDate()) + "]"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Day.java0000644000175000017500000003722711173030414024572 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------- * Day.java * -------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 15-Nov-2001 : Updated Javadoc comments (DG); * 04-Dec-2001 : Added static method to parse a string into a Day object (DG); * 19-Dec-2001 : Added new constructor as suggested by Paul English (DG); * 29-Jan-2002 : Changed getDay() method to getSerialDate() (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 19-Mar-2002 : Changed the API for the TimePeriod classes (DG); * 29-May-2002 : Fixed bug in equals method (DG); * 24-Jun-2002 : Removed unnecessary imports (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for * JDK 1.3 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * 02-Mar-2009 : Added new constructor with Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import org.jfree.date.SerialDate; /** * Represents a single day in the range 1-Jan-1900 to 31-Dec-9999. This class * is immutable, which is a requirement for all {@link RegularTimePeriod} * subclasses. */ public class Day extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = -7082667380758962755L; /** A standard date formatter. */ protected static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); /** A date formatter for the default locale. */ protected static final DateFormat DATE_FORMAT_SHORT = DateFormat.getDateInstance(DateFormat.SHORT); /** A date formatter for the default locale. */ protected static final DateFormat DATE_FORMAT_MEDIUM = DateFormat.getDateInstance(DateFormat.MEDIUM); /** A date formatter for the default locale. */ protected static final DateFormat DATE_FORMAT_LONG = DateFormat.getDateInstance(DateFormat.LONG); /** The day (uses SerialDate for convenience). */ private SerialDate serialDate; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Creates a new instance, derived from the system date/time (and assuming * the default timezone). */ public Day() { this(new Date()); } /** * Constructs a new one day time period. * * @param day the day-of-the-month. * @param month the month (1 to 12). * @param year the year (1900 <= year <= 9999). */ public Day(int day, int month, int year) { this.serialDate = SerialDate.createInstance(day, month, year); peg(Calendar.getInstance()); } /** * Constructs a new one day time period. * * @param serialDate the day (null not permitted). */ public Day(SerialDate serialDate) { if (serialDate == null) { throw new IllegalArgumentException("Null 'serialDate' argument."); } this.serialDate = serialDate; peg(Calendar.getInstance()); } /** * Constructs a new instance, based on a particular date/time and the * default time zone. * * @param time the time (null not permitted). * * @see #Day(Date, TimeZone) */ public Day(Date time) { // defer argument checking... this(time, TimeZone.getDefault(), Locale.getDefault()); } /** * Constructs a new instance, based on a particular date/time and time zone. * * @param time the date/time. * @param zone the time zone. * * @deprecated As of 1.0.13, use the constructor that specifies the locale * also. */ public Day(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Constructs a new instance, based on a particular date/time and time zone. * * @param time the date/time (null not permitted). * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). */ public Day(Date time, TimeZone zone, Locale locale) { if (time == null) { throw new IllegalArgumentException("Null 'time' argument."); } if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); int d = calendar.get(Calendar.DAY_OF_MONTH); int m = calendar.get(Calendar.MONTH) + 1; int y = calendar.get(Calendar.YEAR); this.serialDate = SerialDate.createInstance(d, m, y); peg(calendar); } /** * Returns the day as a {@link SerialDate}. Note: the reference that is * returned should be an instance of an immutable {@link SerialDate} * (otherwise the caller could use the reference to alter the state of * this Day instance, and Day is supposed * to be immutable). * * @return The day as a {@link SerialDate}. */ public SerialDate getSerialDate() { return this.serialDate; } /** * Returns the year. * * @return The year. */ public int getYear() { return this.serialDate.getYYYY(); } /** * Returns the month. * * @return The month. */ public int getMonth() { return this.serialDate.getMonth(); } /** * Returns the day of the month. * * @return The day of the month. */ public int getDayOfMonth() { return this.serialDate.getDayOfMonth(); } /** * Returns the first millisecond of the day. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the day. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the day. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the day. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the day preceding this one. * * @return The day preceding this one. */ public RegularTimePeriod previous() { Day result; int serial = this.serialDate.toSerial(); if (serial > SerialDate.SERIAL_LOWER_BOUND) { SerialDate yesterday = SerialDate.createInstance(serial - 1); return new Day(yesterday); } else { result = null; } return result; } /** * Returns the day following this one, or null if some limit * has been reached. * * @return The day following this one, or null if some limit * has been reached. */ public RegularTimePeriod next() { Day result; int serial = this.serialDate.toSerial(); if (serial < SerialDate.SERIAL_UPPER_BOUND) { SerialDate tomorrow = SerialDate.createInstance(serial + 1); return new Day(tomorrow); } else { result = null; } return result; } /** * Returns a serial index number for the day. * * @return The serial index number. */ public long getSerialIndex() { return this.serialDate.toSerial(); } /** * Returns the first millisecond of the day, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar calendar to use (null not permitted). * * @return The start of the day as milliseconds since 01-01-1970. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { int year = this.serialDate.getYYYY(); int month = this.serialDate.getMonth(); int day = this.serialDate.getDayOfMonth(); calendar.clear(); calendar.set(year, month - 1, day, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the day, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar calendar to use (null not permitted). * * @return The end of the day as milliseconds since 01-01-1970. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { int year = this.serialDate.getYYYY(); int month = this.serialDate.getMonth(); int day = this.serialDate.getDayOfMonth(); calendar.clear(); calendar.set(year, month - 1, day, 23, 59, 59); calendar.set(Calendar.MILLISECOND, 999); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Tests the equality of this Day object to an arbitrary object. Returns * true if the target is a Day instance or a SerialDate instance * representing the same day as this object. In all other cases, * returns false. * * @param obj the object (null permitted). * * @return A flag indicating whether or not an object is equal to this day. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Day)) { return false; } Day that = (Day) obj; if (!this.serialDate.equals(that.getSerialDate())) { return false; } return true; } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { return this.serialDate.hashCode(); } /** * Returns an integer indicating the order of this Day object relative to * the specified object: * * negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Day object // ---------------------------------------- if (o1 instanceof Day) { Day d = (Day) o1; result = -d.getSerialDate().compare(this.serialDate); } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns a string representing the day. * * @return A string representing the day. */ public String toString() { return this.serialDate.toString(); } /** * Parses the string argument as a day. *

* This method is required to recognise YYYY-MM-DD as a valid format. * Anything else, for now, is a bonus. * * @param s the date string to parse. * * @return null if the string does not contain any parseable * string, the day otherwise. */ public static Day parseDay(String s) { try { return new Day (Day.DATE_FORMAT.parse(s)); } catch (ParseException e1) { try { return new Day (Day.DATE_FORMAT_SHORT.parse(s)); } catch (ParseException e2) { // ignore } } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/DynamicTimeSeriesCollection.java0000644000175000017500000007641611173030414031452 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * DynamicTimeSeriesCollection.java * -------------------------------- * (C) Copyright 2002-2008, by I. H. Thomae and Contributors. * * Original Author: I. H. Thomae (ithomae@ists.dartmouth.edu); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 22-Nov-2002 : Initial version completed * Jan 2003 : Optimized advanceTime(), added implemnt'n of RangeInfo intfc * (using cached values for min, max, and range); also added * getOldestIndex() and getNewestIndex() ftns so client classes * can use this class as the master "index authority". * 22-Jan-2003 : Made this class stand on its own, rather than extending * class FastTimeSeriesCollection * 31-Jan-2003 : Changed TimePeriod --> RegularTimePeriod (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); * 29-Apr-2003 : Added small change to appendData method, from Irv Thomae (DG); * 19-Sep-2003 : Added new appendData method, from Irv Thomae (DG); * 05-May-2004 : Now extends AbstractIntervalXYDataset. This also required a * change to the return type of the getY() method - I'm slightly * unsure of the implications of this, so it might require some * further amendment (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 11-Jan-2004 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.time; import java.util.Calendar; import java.util.TimeZone; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; /** * A dynamic dataset. *

* Like FastTimeSeriesCollection, this class is a functional replacement * for JFreeChart's TimeSeriesCollection _and_ TimeSeries classes. * FastTimeSeriesCollection is appropriate for a fixed time range; for * real-time applications this subclass adds the ability to append new * data and discard the oldest. * In this class, the arrays used in FastTimeSeriesCollection become FIFO's. * NOTE:As presented here, all data is assumed >= 0, an assumption which is * embodied only in methods associated with interface RangeInfo. */ public class DynamicTimeSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, RangeInfo { /** * Useful constant for controlling the x-value returned for a time * period. */ public static final int START = 0; /** * Useful constant for controlling the x-value returned for a time period. */ public static final int MIDDLE = 1; /** * Useful constant for controlling the x-value returned for a time period. */ public static final int END = 2; /** The maximum number of items for each series (can be overridden). */ private int maximumItemCount = 2000; // an arbitrary safe default value /** The history count. */ protected int historyCount; /** Storage for the series keys. */ private Comparable[] seriesKeys; /** The time period class - barely used, and could be removed (DG). */ private Class timePeriodClass = Minute.class; // default value; /** Storage for the x-values. */ protected RegularTimePeriod[] pointsInTime; /** The number of series. */ private int seriesCount; /** * A wrapper for a fixed array of float values. */ protected class ValueSequence { /** Storage for the float values. */ float[] dataPoints; /** * Default constructor: */ public ValueSequence() { this(DynamicTimeSeriesCollection.this.maximumItemCount); } /** * Creates a sequence with the specified length. * * @param length the length. */ public ValueSequence(int length) { this.dataPoints = new float[length]; for (int i = 0; i < length; i++) { this.dataPoints[i] = 0.0f; } } /** * Enters data into the storage array. * * @param index the index. * @param value the value. */ public void enterData(int index, float value) { this.dataPoints[index] = value; } /** * Returns a value from the storage array. * * @param index the index. * * @return The value. */ public float getData(int index) { return this.dataPoints[index]; } } /** An array for storing the objects that represent each series. */ protected ValueSequence[] valueHistory; /** A working calendar (to recycle) */ protected Calendar workingCalendar; /** * The position within a time period to return as the x-value (START, * MIDDLE or END). */ private int position; /** * A flag that indicates that the domain is 'points in time'. If this flag * is true, only the x-value is used to determine the range of values in * the domain, the start and end x-values are ignored. */ private boolean domainIsPointsInTime; /** index for mapping: points to the oldest valid time & data. */ private int oldestAt; // as a class variable, initializes == 0 /** Index of the newest data item. */ private int newestAt; // cached values used for interface DomainInfo: /** the # of msec by which time advances. */ private long deltaTime; /** Cached domain start (for use by DomainInfo). */ private Long domainStart; /** Cached domain end (for use by DomainInfo). */ private Long domainEnd; /** Cached domain range (for use by DomainInfo). */ private Range domainRange; // Cached values used for interface RangeInfo: (note minValue pinned at 0) // A single set of extrema covers the entire SeriesCollection /** The minimum value. */ private Float minValue = new Float(0.0f); /** The maximum value. */ private Float maxValue = null; /** The value range. */ private Range valueRange; // autoinit's to null. /** * Constructs a dataset with capacity for N series, tied to default * timezone. * * @param nSeries the number of series to be accommodated. * @param nMoments the number of TimePeriods to be spanned. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments) { this(nSeries, nMoments, new Millisecond(), TimeZone.getDefault()); this.newestAt = nMoments - 1; } /** * Constructs an empty dataset, tied to a specific timezone. * * @param nSeries the number of series to be accommodated * @param nMoments the number of TimePeriods to be spanned * @param zone the timezone. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments, TimeZone zone) { this(nSeries, nMoments, new Millisecond(), zone); this.newestAt = nMoments - 1; } /** * Creates a new dataset. * * @param nSeries the number of series. * @param nMoments the number of items per series. * @param timeSample a time period sample. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample) { this(nSeries, nMoments, timeSample, TimeZone.getDefault()); } /** * Creates a new dataset. * * @param nSeries the number of series. * @param nMoments the number of items per series. * @param timeSample a time period sample. * @param zone the time zone. */ public DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample, TimeZone zone) { // the first initialization must precede creation of the ValueSet array: this.maximumItemCount = nMoments; // establishes length of each array this.historyCount = nMoments; this.seriesKeys = new Comparable[nSeries]; // initialize the members of "seriesNames" array so they won't be null: for (int i = 0; i < nSeries; i++) { this.seriesKeys[i] = ""; } this.newestAt = nMoments - 1; this.valueHistory = new ValueSequence[nSeries]; this.timePeriodClass = timeSample.getClass(); /// Expand the following for all defined TimePeriods: if (this.timePeriodClass == Second.class) { this.pointsInTime = new Second[nMoments]; } else if (this.timePeriodClass == Minute.class) { this.pointsInTime = new Minute[nMoments]; } else if (this.timePeriodClass == Hour.class) { this.pointsInTime = new Hour[nMoments]; } /// .. etc.... this.workingCalendar = Calendar.getInstance(zone); this.position = START; this.domainIsPointsInTime = true; } /** * Fill the pointsInTime with times using TimePeriod.next(): * Will silently return if the time array was already populated. * * Also computes the data cached for later use by * methods implementing the DomainInfo interface: * * @param start the start. * * @return ??. */ public synchronized long setTimeBase(RegularTimePeriod start) { if (this.pointsInTime[0] == null) { this.pointsInTime[0] = start; for (int i = 1; i < this.historyCount; i++) { this.pointsInTime[i] = this.pointsInTime[i - 1].next(); } } long oldestL = this.pointsInTime[0].getFirstMillisecond( this.workingCalendar ); long nextL = this.pointsInTime[1].getFirstMillisecond( this.workingCalendar ); this.deltaTime = nextL - oldestL; this.oldestAt = 0; this.newestAt = this.historyCount - 1; findDomainLimits(); return this.deltaTime; } /** * Finds the domain limits. Note: this doesn't need to be synchronized * because it's called from within another method that already is. */ protected void findDomainLimits() { long startL = getOldestTime().getFirstMillisecond(this.workingCalendar); long endL; if (this.domainIsPointsInTime) { endL = getNewestTime().getFirstMillisecond(this.workingCalendar); } else { endL = getNewestTime().getLastMillisecond(this.workingCalendar); } this.domainStart = new Long(startL); this.domainEnd = new Long(endL); this.domainRange = new Range(startL, endL); } /** * Returns the x position type (START, MIDDLE or END). * * @return The x position type. */ public int getPosition() { return this.position; } /** * Sets the x position type (START, MIDDLE or END). * * @param position The x position type. */ public void setPosition(int position) { this.position = position; } /** * Adds a series to the dataset. Only the y-values are supplied, the * x-values are specified elsewhere. * * @param values the y-values. * @param seriesNumber the series index (zero-based). * @param seriesKey the series key. * * Use this as-is during setup only, or add the synchronized keyword around * the copy loop. */ public void addSeries(float[] values, int seriesNumber, Comparable seriesKey) { invalidateRangeInfo(); int i; if (values == null) { throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): " + "cannot add null array of values."); } if (seriesNumber >= this.valueHistory.length) { throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): " + "cannot add more series than specified in c'tor"); } if (this.valueHistory[seriesNumber] == null) { this.valueHistory[seriesNumber] = new ValueSequence(this.historyCount); this.seriesCount++; } // But if that series array already exists, just overwrite its contents // Avoid IndexOutOfBoundsException: int srcLength = values.length; int copyLength = this.historyCount; boolean fillNeeded = false; if (srcLength < this.historyCount) { fillNeeded = true; copyLength = srcLength; } //{ for (i = 0; i < copyLength; i++) { // deep copy from values[], caller // can safely discard that array this.valueHistory[seriesNumber].enterData(i, values[i]); } if (fillNeeded) { for (i = copyLength; i < this.historyCount; i++) { this.valueHistory[seriesNumber].enterData(i, 0.0f); } } //} if (seriesKey != null) { this.seriesKeys[seriesNumber] = seriesKey; } fireSeriesChanged(); } /** * Sets the name of a series. If planning to add values individually. * * @param seriesNumber the series. * @param key the new key. */ public void setSeriesKey(int seriesNumber, Comparable key) { this.seriesKeys[seriesNumber] = key; } /** * Adds a value to a series. * * @param seriesNumber the series index. * @param index ??. * @param value the value. */ public void addValue(int seriesNumber, int index, float value) { invalidateRangeInfo(); if (seriesNumber >= this.valueHistory.length) { throw new IllegalArgumentException( "TimeSeriesDataset.addValue(): series #" + seriesNumber + "unspecified in c'tor" ); } if (this.valueHistory[seriesNumber] == null) { this.valueHistory[seriesNumber] = new ValueSequence(this.historyCount); this.seriesCount++; } // But if that series array already exists, just overwrite its contents //synchronized(this) //{ this.valueHistory[seriesNumber].enterData(index, value); //} fireSeriesChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.seriesCount; } /** * Returns the number of items in a series. *

* For this implementation, all series have the same number of items. * * @param series the series index (zero-based). * * @return The item count. */ public int getItemCount(int series) { // all arrays equal length, // so ignore argument: return this.historyCount; } // Methods for managing the FIFO's: /** * Re-map an index, for use in retrieving data. * * @param toFetch the index. * * @return The translated index. */ protected int translateGet(int toFetch) { if (this.oldestAt == 0) { return toFetch; // no translation needed } // else [implicit here] int newIndex = toFetch + this.oldestAt; if (newIndex >= this.historyCount) { newIndex -= this.historyCount; } return newIndex; } /** * Returns the actual index to a time offset by "delta" from newestAt. * * @param delta the delta. * * @return The offset. */ public int offsetFromNewest(int delta) { return wrapOffset(this.newestAt + delta); } /** * ?? * * @param delta ?? * * @return The offset. */ public int offsetFromOldest(int delta) { return wrapOffset(this.oldestAt + delta); } /** * ?? * * @param protoIndex the index. * * @return The offset. */ protected int wrapOffset(int protoIndex) { int tmp = protoIndex; if (tmp >= this.historyCount) { tmp -= this.historyCount; } else if (tmp < 0) { tmp += this.historyCount; } return tmp; } /** * Adjust the array offset as needed when a new time-period is added: * Increments the indices "oldestAt" and "newestAt", mod(array length), * zeroes the series values at newestAt, returns the new TimePeriod. * * @return The new time period. */ public synchronized RegularTimePeriod advanceTime() { RegularTimePeriod nextInstant = this.pointsInTime[this.newestAt].next(); this.newestAt = this.oldestAt; // newestAt takes value previously held // by oldestAT /*** * The next 10 lines or so should be expanded if data can be negative ***/ // if the oldest data contained a maximum Y-value, invalidate the stored // Y-max and Y-range data: boolean extremaChanged = false; float oldMax = 0.0f; if (this.maxValue != null) { oldMax = this.maxValue.floatValue(); } for (int s = 0; s < getSeriesCount(); s++) { if (this.valueHistory[s].getData(this.oldestAt) == oldMax) { extremaChanged = true; } if (extremaChanged) { break; } } /*** If data can be < 0, add code here to check the minimum **/ if (extremaChanged) { invalidateRangeInfo(); } // wipe the next (about to be used) set of data slots float wiper = (float) 0.0; for (int s = 0; s < getSeriesCount(); s++) { this.valueHistory[s].enterData(this.newestAt, wiper); } // Update the array of TimePeriods: this.pointsInTime[this.newestAt] = nextInstant; // Now advance "oldestAt", wrapping at end of the array this.oldestAt++; if (this.oldestAt >= this.historyCount) { this.oldestAt = 0; } // Update the domain limits: long startL = this.domainStart.longValue(); //(time is kept in msec) this.domainStart = new Long(startL + this.deltaTime); long endL = this.domainEnd.longValue(); this.domainEnd = new Long(endL + this.deltaTime); this.domainRange = new Range(startL, endL); fireSeriesChanged(); return nextInstant; } // If data can be < 0, the next 2 methods should be modified /** * Invalidates the range info. */ public void invalidateRangeInfo() { this.maxValue = null; this.valueRange = null; } /** * Returns the maximum value. * * @return The maximum value. */ protected double findMaxValue() { double max = 0.0f; for (int s = 0; s < getSeriesCount(); s++) { for (int i = 0; i < this.historyCount; i++) { double tmp = getYValue(s, i); if (tmp > max) { max = tmp; } } } return max; } /** End, positive-data-only code **/ /** * Returns the index of the oldest data item. * * @return The index. */ public int getOldestIndex() { return this.oldestAt; } /** * Returns the index of the newest data item. * * @return The index. */ public int getNewestIndex() { return this.newestAt; } // appendData() writes new data at the index position given by newestAt/ // When adding new data dynamically, use advanceTime(), followed by this: /** * Appends new data. * * @param newData the data. */ public void appendData(float[] newData) { int nDataPoints = newData.length; if (nDataPoints > this.valueHistory.length) { throw new IllegalArgumentException( "More data than series to put them in" ); } int s; // index to select the "series" for (s = 0; s < nDataPoints; s++) { // check whether the "valueHistory" array member exists; if not, // create them: if (this.valueHistory[s] == null) { this.valueHistory[s] = new ValueSequence(this.historyCount); } this.valueHistory[s].enterData(this.newestAt, newData[s]); } fireSeriesChanged(); } /** * Appends data at specified index, for loading up with data from file(s). * * @param newData the data * @param insertionIndex the index value at which to put it * @param refresh value of n in "refresh the display on every nth call" * (ignored if <= 0 ) */ public void appendData(float[] newData, int insertionIndex, int refresh) { int nDataPoints = newData.length; if (nDataPoints > this.valueHistory.length) { throw new IllegalArgumentException( "More data than series to put them " + "in" ); } for (int s = 0; s < nDataPoints; s++) { if (this.valueHistory[s] == null) { this.valueHistory[s] = new ValueSequence(this.historyCount); } this.valueHistory[s].enterData(insertionIndex, newData[s]); } if (refresh > 0) { insertionIndex++; if (insertionIndex % refresh == 0) { fireSeriesChanged(); } } } /** * Returns the newest time. * * @return The newest time. */ public RegularTimePeriod getNewestTime() { return this.pointsInTime[this.newestAt]; } /** * Returns the oldest time. * * @return The oldest time. */ public RegularTimePeriod getOldestTime() { return this.pointsInTime[this.oldestAt]; } /** * Returns the x-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ // getXxx() ftns can ignore the "series" argument: // Don't synchronize this!! Instead, synchronize the loop that calls it. public Number getX(int series, int item) { RegularTimePeriod tp = this.pointsInTime[translateGet(item)]; return new Long(getX(tp)); } /** * Returns the y-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getYValue(int series, int item) { // Don't synchronize this!! // Instead, synchronize the loop that calls it. ValueSequence values = this.valueHistory[series]; return values.getData(translateGet(item)); } /** * Returns the y-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getY(int series, int item) { return new Float(getYValue(series, item)); } /** * Returns the start x-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartX(int series, int item) { RegularTimePeriod tp = this.pointsInTime[translateGet(item)]; return new Long(tp.getFirstMillisecond(this.workingCalendar)); } /** * Returns the end x-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndX(int series, int item) { RegularTimePeriod tp = this.pointsInTime[translateGet(item)]; return new Long(tp.getLastMillisecond(this.workingCalendar)); } /** * Returns the start y-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the end y-value. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndY(int series, int item) { return getY(series, item); } /* // "Extras" found useful when analyzing/verifying class behavior: public Number getUntranslatedXValue(int series, int item) { return super.getXValue(series, item); } public float getUntranslatedY(int series, int item) { return super.getY(series, item); } */ /** * Returns the key for a series. * * @param series the series index (zero-based). * * @return The key. */ public Comparable getSeriesKey(int series) { return this.seriesKeys[series]; } /** * Sends a {@link SeriesChangeEvent} to all registered listeners. */ protected void fireSeriesChanged() { seriesChanged(new SeriesChangeEvent(this)); } // The next 3 functions override the base-class implementation of // the DomainInfo interface. Using saved limits (updated by // each updateTime() call), improves performance. // /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { return this.domainStart.doubleValue(); // a Long kept updated by advanceTime() } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { return this.domainEnd.doubleValue(); // a Long kept updated by advanceTime() } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { if (this.domainRange == null) { findDomainLimits(); } return this.domainRange; } /** * Returns the x-value for a time period. * * @param period the period. * * @return The x-value. */ private long getX(RegularTimePeriod period) { switch (this.position) { case (START) : return period.getFirstMillisecond(this.workingCalendar); case (MIDDLE) : return period.getMiddleMillisecond(this.workingCalendar); case (END) : return period.getLastMillisecond(this.workingCalendar); default: return period.getMiddleMillisecond(this.workingCalendar); } } // The next 3 functions implement the RangeInfo interface. // Using saved limits (updated by each updateTime() call) significantly // improves performance. WARNING: this code makes the simplifying // assumption that data is never negative. Expand as needed for the // general case. /** * Returns the minimum range value. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum range value. */ public double getRangeLowerBound(boolean includeInterval) { double result = Double.NaN; if (this.minValue != null) { result = this.minValue.doubleValue(); } return result; } /** * Returns the maximum range value. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum range value. */ public double getRangeUpperBound(boolean includeInterval) { double result = Double.NaN; if (this.maxValue != null) { result = this.maxValue.doubleValue(); } return result; } /** * Returns the value range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range. */ public Range getRangeBounds(boolean includeInterval) { if (this.valueRange == null) { double max = getRangeUpperBound(includeInterval); this.valueRange = new Range(0.0, max); } return this.valueRange; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/FixedMillisecond.java0000644000175000017500000002015311173030414027265 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * FixedMillisecond.java * --------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Mar-2002 : Version 1, based on original Millisecond implementation (DG); * 24-Jun-2002 : Removed unnecessary imports (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Oct-2006 : Added peg() method (DG); * 28-May-2008 : Fixed immutability problem (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; /** * Wrapper for a java.util.Date object that allows it to be used * as a {@link RegularTimePeriod}. This class is immutable, which is a * requirement for all {@link RegularTimePeriod} subclasses. */ public class FixedMillisecond extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7867521484545646931L; /** The millisecond. */ private long time; /** * Constructs a millisecond based on the current system time. */ public FixedMillisecond() { this(new Date()); } /** * Constructs a millisecond. * * @param millisecond the millisecond (same encoding as java.util.Date). */ public FixedMillisecond(long millisecond) { this(new Date(millisecond)); } /** * Constructs a millisecond. * * @param time the time. */ public FixedMillisecond(Date time) { this.time = time.getTime(); } /** * Returns the date/time. * * @return The date/time. */ public Date getTime() { return new Date(this.time); } /** * This method is overridden to do nothing. * * @param calendar ignored * * @since 1.0.3 */ public void peg(Calendar calendar) { // nothing to do } /** * Returns the millisecond preceding this one. * * @return The millisecond preceding this one. */ public RegularTimePeriod previous() { RegularTimePeriod result = null; long t = this.time; if (t != Long.MIN_VALUE) { result = new FixedMillisecond(t - 1); } return result; } /** * Returns the millisecond following this one. * * @return The millisecond following this one. */ public RegularTimePeriod next() { RegularTimePeriod result = null; long t = this.time; if (t != Long.MAX_VALUE) { result = new FixedMillisecond(t + 1); } return result; } /** * Tests the equality of this object against an arbitrary Object. * * @param object the object to compare * * @return A boolean. */ public boolean equals(Object object) { if (object instanceof FixedMillisecond) { FixedMillisecond m = (FixedMillisecond) object; return this.time == m.getFirstMillisecond(); } else { return false; } } /** * Returns a hash code for this object instance. * * @return A hash code. */ public int hashCode() { return (int) this.time; } /** * Returns an integer indicating the order of this Millisecond object * relative to the specified * object: negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; long difference; // CASE 1 : Comparing to another Second object // ------------------------------------------- if (o1 instanceof FixedMillisecond) { FixedMillisecond t1 = (FixedMillisecond) o1; difference = this.time - t1.time; if (difference > 0) { result = 1; } else { if (difference < 0) { result = -1; } else { result = 0; } } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns the first millisecond of the time period. * * @return The first millisecond of the time period. */ public long getFirstMillisecond() { return this.time; } /** * Returns the first millisecond of the time period. * * @param calendar the calendar. * * @return The first millisecond of the time period. */ public long getFirstMillisecond(Calendar calendar) { return this.time; } /** * Returns the last millisecond of the time period. * * @return The last millisecond of the time period. */ public long getLastMillisecond() { return this.time; } /** * Returns the last millisecond of the time period. * * @param calendar the calendar. * * @return The last millisecond of the time period. */ public long getLastMillisecond(Calendar calendar) { return this.time; } /** * Returns the millisecond closest to the middle of the time period. * * @return The millisecond closest to the middle of the time period. */ public long getMiddleMillisecond() { return this.time; } /** * Returns the millisecond closest to the middle of the time period. * * @param calendar the calendar. * * @return The millisecond closest to the middle of the time period. */ public long getMiddleMillisecond(Calendar calendar) { return this.time; } /** * Returns a serial index number for the millisecond. * * @return The serial index number. */ public long getSerialIndex() { return this.time; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Hour.java0000644000175000017500000003701011173030414024760 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Hour.java * --------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 18-Dec-2001 : Changed order of parameters in constructor (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 14-Feb-2002 : Fixed bug in Hour(Date) constructor (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 15-Mar-2002 : Changed API (DG); * 16-Apr-2002 : Fixed small time zone bug in constructor (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method, and new constructor for * convenience (DG); * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for * JDK 1.3 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 04-Apr-2007 : In Hour(Date, TimeZone), peg milliseconds using specified * time zone (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * 02-Mar-2009 : Added new constructor with Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * Represents an hour in a specific day. This class is immutable, which is a * requirement for all {@link RegularTimePeriod} subclasses. */ public class Hour extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = -835471579831937652L; /** Useful constant for the first hour in the day. */ public static final int FIRST_HOUR_IN_DAY = 0; /** Useful constant for the last hour in the day. */ public static final int LAST_HOUR_IN_DAY = 23; /** The day. */ private Day day; /** The hour. */ private byte hour; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Constructs a new Hour, based on the system date/time. */ public Hour() { this(new Date()); } /** * Constructs a new Hour. * * @param hour the hour (in the range 0 to 23). * @param day the day (null not permitted). */ public Hour(int hour, Day day) { if (day == null) { throw new IllegalArgumentException("Null 'day' argument."); } this.hour = (byte) hour; this.day = day; peg(Calendar.getInstance()); } /** * Creates a new hour. * * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Hour(int hour, int day, int month, int year) { this(hour, new Day(day, month, year)); } /** * Constructs a new instance, based on the supplied date/time and * the default time zone. * * @param time the date-time (null not permitted). * * @see #Hour(Date, TimeZone) */ public Hour(Date time) { // defer argument checking... this(time, TimeZone.getDefault(), Locale.getDefault()); } /** * Constructs a new instance, based on the supplied date/time evaluated * in the specified time zone. * * @param time the date-time (null not permitted). * @param zone the time zone (null not permitted). * * @deprecated As of 1.0.13, use the constructor that specifies the locale * also. */ public Hour(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Constructs a new instance, based on the supplied date/time evaluated * in the specified time zone. * * @param time the date-time (null not permitted). * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.13 */ public Hour(Date time, TimeZone zone, Locale locale) { if (time == null) { throw new IllegalArgumentException("Null 'time' argument."); } if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); this.day = new Day(time, zone, locale); peg(calendar); } /** * Returns the hour. * * @return The hour (0 <= hour <= 23). */ public int getHour() { return this.hour; } /** * Returns the day in which this hour falls. * * @return The day. */ public Day getDay() { return this.day; } /** * Returns the year in which this hour falls. * * @return The year. */ public int getYear() { return this.day.getYear(); } /** * Returns the month in which this hour falls. * * @return The month. */ public int getMonth() { return this.day.getMonth(); } /** * Returns the day-of-the-month in which this hour falls. * * @return The day-of-the-month. */ public int getDayOfMonth() { return this.day.getDayOfMonth(); } /** * Returns the first millisecond of the hour. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the hour. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the hour. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the hour. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the hour preceding this one. * * @return The hour preceding this one. */ public RegularTimePeriod previous() { Hour result; if (this.hour != FIRST_HOUR_IN_DAY) { result = new Hour(this.hour - 1, this.day); } else { // we are at the first hour in the day... Day prevDay = (Day) this.day.previous(); if (prevDay != null) { result = new Hour(LAST_HOUR_IN_DAY, prevDay); } else { result = null; } } return result; } /** * Returns the hour following this one. * * @return The hour following this one. */ public RegularTimePeriod next() { Hour result; if (this.hour != LAST_HOUR_IN_DAY) { result = new Hour(this.hour + 1, this.day); } else { // we are at the last hour in the day... Day nextDay = (Day) this.day.next(); if (nextDay != null) { result = new Hour(FIRST_HOUR_IN_DAY, nextDay); } else { result = null; } } return result; } /** * Returns a serial index number for the hour. * * @return The serial index number. */ public long getSerialIndex() { return this.day.getSerialIndex() * 24L + this.hour; } /** * Returns the first millisecond of the hour. * * @param calendar the calendar/timezone (null not permitted). * * @return The first millisecond. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int dom = this.day.getDayOfMonth(); calendar.set(year, month, dom, this.hour, 0, 0); calendar.set(Calendar.MILLISECOND, 0); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the hour. * * @param calendar the calendar/timezone (null not permitted). * * @return The last millisecond. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int dom = this.day.getDayOfMonth(); calendar.set(year, month, dom, this.hour, 59, 59); calendar.set(Calendar.MILLISECOND, 999); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Tests the equality of this object against an arbitrary Object. *

* This method will return true ONLY if the object is an Hour object * representing the same hour as this instance. * * @param obj the object to compare (null permitted). * * @return true if the hour and day value of the object * is the same as this. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Hour)) { return false; } Hour that = (Hour) obj; if (this.hour != that.hour) { return false; } if (!this.day.equals(that.day)) { return false; } return true; } /** * Returns a string representation of this instance, for debugging * purposes. * * @return A string. */ public String toString() { return "[" + this.hour + "," + getDayOfMonth() + "/" + getMonth() + "/" + getYear() + "]"; } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + this.hour; result = 37 * result + this.day.hashCode(); return result; } /** * Returns an integer indicating the order of this Hour object relative to * the specified object: * * negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Hour object // ----------------------------------------- if (o1 instanceof Hour) { Hour h = (Hour) o1; result = getDay().compareTo(h.getDay()); if (result == 0) { result = this.hour - h.getHour(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Creates an Hour instance by parsing a string. The string is assumed to * be in the format "YYYY-MM-DD HH", perhaps with leading or trailing * whitespace. * * @param s the hour string to parse. * * @return null if the string is not parseable, the hour * otherwise. */ public static Hour parseHour(String s) { Hour result = null; s = s.trim(); String daystr = s.substring(0, Math.min(10, s.length())); Day day = Day.parseDay(daystr); if (day != null) { String hourstr = s.substring( Math.min(daystr.length() + 1, s.length()), s.length() ); hourstr = hourstr.trim(); int hour = Integer.parseInt(hourstr); // if the hour is 0 - 23 then create an hour if ((hour >= FIRST_HOUR_IN_DAY) && (hour <= LAST_HOUR_IN_DAY)) { result = new Hour(hour, day); } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Millisecond.java0000644000175000017500000003422211173030414026307 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * Millisecond.java * ---------------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 19-Dec-2001 : Added new constructors as suggested by Paul English (DG); * 26-Feb-2002 : Added new getStart() and getEnd() methods (DG); * 29-Mar-2002 : Fixed bug in getStart(), getEnd() and compareTo() methods (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 04-Apr-2007 : In Millisecond(Date, TimeZone), peg milliseconds to the * specified zone (DG); * 06-Jun-2008 : Added handling for general RegularTimePeriod in compareTo() * method: * see http://www.jfree.org/phpBB2/viewtopic.php?t=24805 (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * 02-Mar-2009 : Added new constructor with Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * Represents a millisecond. This class is immutable, which is a requirement * for all {@link RegularTimePeriod} subclasses. */ public class Millisecond extends RegularTimePeriod implements Serializable { /** For serialization. */ static final long serialVersionUID = -5316836467277638485L; /** A constant for the first millisecond in a second. */ public static final int FIRST_MILLISECOND_IN_SECOND = 0; /** A constant for the last millisecond in a second. */ public static final int LAST_MILLISECOND_IN_SECOND = 999; /** The day. */ private Day day; /** The hour in the day. */ private byte hour; /** The minute. */ private byte minute; /** The second. */ private byte second; /** The millisecond. */ private int millisecond; /** * The pegged millisecond. */ private long firstMillisecond; /** * Constructs a millisecond based on the current system time. */ public Millisecond() { this(new Date()); } /** * Constructs a millisecond. * * @param millisecond the millisecond (0-999). * @param second the second. */ public Millisecond(int millisecond, Second second) { this.millisecond = millisecond; this.second = (byte) second.getSecond(); this.minute = (byte) second.getMinute().getMinute(); this.hour = (byte) second.getMinute().getHourValue(); this.day = second.getMinute().getDay(); peg(Calendar.getInstance()); } /** * Creates a new millisecond. * * @param millisecond the millisecond (0-999). * @param second the second (0-59). * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Millisecond(int millisecond, int second, int minute, int hour, int day, int month, int year) { this(millisecond, new Second(second, minute, hour, day, month, year)); } /** * Constructs a new millisecond using the default time zone. * * @param time the time. * * @see #Millisecond(Date, TimeZone) */ public Millisecond(Date time) { this(time, TimeZone.getDefault(), Locale.getDefault()); } /** * Creates a millisecond. * * @param time the instant in time. * @param zone the time zone. * * @deprecated As of 1.0.13, use the constructor that specifies the locale * also. */ public Millisecond(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Creates a millisecond. * * @param time the date-time (null not permitted). * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.13 */ public Millisecond(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.millisecond = calendar.get(Calendar.MILLISECOND); this.second = (byte) calendar.get(Calendar.SECOND); this.minute = (byte) calendar.get(Calendar.MINUTE); this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); this.day = new Day(time, zone, locale); peg(calendar); } /** * Returns the second. * * @return The second. */ public Second getSecond() { return new Second(this.second, this.minute, this.hour, this.day.getDayOfMonth(), this.day.getMonth(), this.day.getYear()); } /** * Returns the millisecond. * * @return The millisecond. */ public long getMillisecond() { return this.millisecond; } /** * Returns the first millisecond of the second. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the second. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the second. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the second. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.firstMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); } /** * Returns the millisecond preceding this one. * * @return The millisecond preceding this one. */ public RegularTimePeriod previous() { RegularTimePeriod result = null; if (this.millisecond != FIRST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond - 1, getSecond()); } else { Second previous = (Second) getSecond().previous(); if (previous != null) { result = new Millisecond(LAST_MILLISECOND_IN_SECOND, previous); } } return result; } /** * Returns the millisecond following this one. * * @return The millisecond following this one. */ public RegularTimePeriod next() { RegularTimePeriod result = null; if (this.millisecond != LAST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond + 1, getSecond()); } else { Second next = (Second) getSecond().next(); if (next != null) { result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next); } } return result; } /** * Returns a serial index number for the millisecond. * * @return The serial index number. */ public long getSerialIndex() { long hourIndex = this.day.getSerialIndex() * 24L + this.hour; long minuteIndex = hourIndex * 60L + this.minute; long secondIndex = minuteIndex * 60L + this.second; return secondIndex * 1000L + this.millisecond; } /** * Tests the equality of this object against an arbitrary Object. *

* This method will return true ONLY if the object is a Millisecond object * representing the same millisecond as this instance. * * @param obj the object to compare * * @return true if milliseconds and seconds of this and object * are the same. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Millisecond)) { return false; } Millisecond that = (Millisecond) obj; if (this.millisecond != that.millisecond) { return false; } if (this.second != that.second) { return false; } if (this.minute != that.minute) { return false; } if (this.hour != that.hour) { return false; } if (!this.day.equals(that.day)) { return false; } return true; } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hashcode. */ public int hashCode() { int result = 17; result = 37 * result + this.millisecond; result = 37 * result + getSecond().hashCode(); return result; } /** * Returns an integer indicating the order of this Millisecond object * relative to the specified object: * * negative == before, zero == same, positive == after. * * @param obj the object to compare * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object obj) { int result; long difference; // CASE 1 : Comparing to another Second object // ------------------------------------------- if (obj instanceof Millisecond) { Millisecond ms = (Millisecond) obj; difference = getFirstMillisecond() - ms.getFirstMillisecond(); if (difference > 0) { result = 1; } else { if (difference < 0) { result = -1; } else { result = 0; } } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (obj instanceof RegularTimePeriod) { RegularTimePeriod rtp = (RegularTimePeriod) obj; final long thisVal = this.getFirstMillisecond(); final long anotherVal = rtp.getFirstMillisecond(); result = (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1)); } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns the first millisecond of the time period. * * @param calendar the calendar (null not permitted). * * @return The first millisecond of the time period. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int day = this.day.getDayOfMonth(); calendar.clear(); calendar.set(year, month, day, this.hour, this.minute, this.second); calendar.set(Calendar.MILLISECOND, this.millisecond); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the time period. * * @param calendar the calendar (null not permitted). * * @return The last millisecond of the time period. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { return getFirstMillisecond(calendar); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Minute.java0000644000175000017500000003762611173030414025321 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * Minute.java * ----------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 18-Dec-2001 : Changed order of parameters in constructor (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 14-Feb-2002 : Fixed bug in Minute(Date) constructor, and changed the range * to start from zero instead of one (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 13-Mar-2002 : Added parseMinute() method (DG); * 19-Mar-2002 : Changed API, the minute is now defined in relation to an * Hour (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method, and new constructor for * convenience (DG); * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for * JDK 1.3 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 11-Dec-2006 : Fix for previous() - bug 1611872 (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * 02-Mar-2009 : Added new constructor that specifies Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * Represents a minute. This class is immutable, which is a requirement for * all {@link RegularTimePeriod} subclasses. */ public class Minute extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = 2144572840034842871L; /** Useful constant for the first minute in a day. */ public static final int FIRST_MINUTE_IN_HOUR = 0; /** Useful constant for the last minute in a day. */ public static final int LAST_MINUTE_IN_HOUR = 59; /** The day. */ private Day day; /** The hour in which the minute falls. */ private byte hour; /** The minute. */ private byte minute; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Constructs a new Minute, based on the system date/time. */ public Minute() { this(new Date()); } /** * Constructs a new Minute. * * @param minute the minute (0 to 59). * @param hour the hour (null not permitted). */ public Minute(int minute, Hour hour) { if (hour == null) { throw new IllegalArgumentException("Null 'hour' argument."); } this.minute = (byte) minute; this.hour = (byte) hour.getHour(); this.day = hour.getDay(); peg(Calendar.getInstance()); } /** * Constructs a new instance, based on the supplied date/time and * the default time zone. * * @param time the time (null not permitted). * * @see #Minute(Date, TimeZone) */ public Minute(Date time) { // defer argument checking this(time, TimeZone.getDefault(), Locale.getDefault()); } /** * Constructs a new Minute, based on the supplied date/time and timezone. * * @param time the time (null not permitted). * @param zone the time zone (null not permitted). * * @deprecated As of 1.0.13, use the constructor that specifies the locale * also. */ public Minute(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Constructs a new Minute, based on the supplied date/time and timezone. * * @param time the time (null not permitted). * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.13 */ public Minute(Date time, TimeZone zone, Locale locale) { if (time == null) { throw new IllegalArgumentException("Null 'time' argument."); } if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); int min = calendar.get(Calendar.MINUTE); this.minute = (byte) min; this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); this.day = new Day(time, zone, locale); peg(calendar); } /** * Creates a new minute. * * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Minute(int minute, int hour, int day, int month, int year) { this(minute, new Hour(hour, new Day(day, month, year))); } /** * Returns the day. * * @return The day. * * @since 1.0.3 */ public Day getDay() { return this.day; } /** * Returns the hour. * * @return The hour (never null). */ public Hour getHour() { return new Hour(this.hour, this.day); } /** * Returns the hour. * * @return The hour. * * @since 1.0.3 */ public int getHourValue() { return this.hour; } /** * Returns the minute. * * @return The minute. */ public int getMinute() { return this.minute; } /** * Returns the first millisecond of the minute. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the minute. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the minute. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the minute. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the minute preceding this one. * * @return The minute preceding this one. */ public RegularTimePeriod previous() { Minute result; if (this.minute != FIRST_MINUTE_IN_HOUR) { result = new Minute(this.minute - 1, getHour()); } else { Hour h = (Hour) getHour().previous(); if (h != null) { result = new Minute(LAST_MINUTE_IN_HOUR, h); } else { result = null; } } return result; } /** * Returns the minute following this one. * * @return The minute following this one. */ public RegularTimePeriod next() { Minute result; if (this.minute != LAST_MINUTE_IN_HOUR) { result = new Minute(this.minute + 1, getHour()); } else { // we are at the last minute in the hour... Hour nextHour = (Hour) getHour().next(); if (nextHour != null) { result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour); } else { result = null; } } return result; } /** * Returns a serial index number for the minute. * * @return The serial index number. */ public long getSerialIndex() { long hourIndex = this.day.getSerialIndex() * 24L + this.hour; return hourIndex * 60L + this.minute; } /** * Returns the first millisecond of the minute. * * @param calendar the calendar which defines the timezone * (null not permitted). * * @return The first millisecond. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int day = this.day.getDayOfMonth(); calendar.clear(); calendar.set(year, month, day, this.hour, this.minute, 0); calendar.set(Calendar.MILLISECOND, 0); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the minute. * * @param calendar the calendar / timezone (null not * permitted). * * @return The last millisecond. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int day = this.day.getDayOfMonth(); calendar.clear(); calendar.set(year, month, day, this.hour, this.minute, 59); calendar.set(Calendar.MILLISECOND, 999); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Tests the equality of this object against an arbitrary Object. *

* This method will return true ONLY if the object is a Minute object * representing the same minute as this instance. * * @param obj the object to compare (null permitted). * * @return true if the minute and hour value of this and the * object are the same. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Minute)) { return false; } Minute that = (Minute) obj; if (this.minute != that.minute) { return false; } if (this.hour != that.hour) { return false; } return true; } /** * Returns a hash code for this object instance. The approach described * by Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + this.minute; result = 37 * result + this.hour; result = 37 * result + this.day.hashCode(); return result; } /** * Returns an integer indicating the order of this Minute object relative * to the specified object: * * negative == before, zero == same, positive == after. * * @param o1 object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Minute object // ------------------------------------------- if (o1 instanceof Minute) { Minute m = (Minute) o1; result = getHour().compareTo(m.getHour()); if (result == 0) { result = this.minute - m.getMinute(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Creates a Minute instance by parsing a string. The string is assumed to * be in the format "YYYY-MM-DD HH:MM", perhaps with leading or trailing * whitespace. * * @param s the minute string to parse. * * @return null, if the string is not parseable, the minute * otherwise. */ public static Minute parseMinute(String s) { Minute result = null; s = s.trim(); String daystr = s.substring(0, Math.min(10, s.length())); Day day = Day.parseDay(daystr); if (day != null) { String hmstr = s.substring( Math.min(daystr.length() + 1, s.length()), s.length() ); hmstr = hmstr.trim(); String hourstr = hmstr.substring(0, Math.min(2, hmstr.length())); int hour = Integer.parseInt(hourstr); if ((hour >= 0) && (hour <= 23)) { String minstr = hmstr.substring( Math.min(hourstr.length() + 1, hmstr.length()), hmstr.length() ); int minute = Integer.parseInt(minstr); if ((minute >= 0) && (minute <= 59)) { result = new Minute(minute, new Hour(hour, day)); } } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Month.java0000644000175000017500000004344011173030414025134 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------- * Month.java * ---------- * (C) Copyright 2001-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Chris Boek; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 14-Nov-2001 : Added method to get year as primitive (DG); * Override for toString() method (DG); * 18-Dec-2001 : Changed order of parameters in constructor (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 29-Jan-2002 : Worked on the parseMonth() method (DG); * 14-Feb-2002 : Fixed bugs in the Month constructors (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 19-Mar-2002 : Changed API for TimePeriod classes (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * 01-Nov-2005 : Fixed bug 1345383 (argument check in constructor) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 04-Apr-2007 : Fixed bug in Month(Date, TimeZone) constructor (CB); * 01-Sep-2008 : Added clarification for previous() and next() methods (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE, and updated parsing to handle * extended range in Year (DG); * 25-Nov-2008 : Added new constructor with Locale (DG); * 04-Feb-2009 : Fix for new constructor with Locale - bug 2564636 (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import org.jfree.date.MonthConstants; import org.jfree.date.SerialDate; /** * Represents a single month. This class is immutable, which is a requirement * for all {@link RegularTimePeriod} subclasses. */ public class Month extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = -5090216912548722570L; /** The month (1-12). */ private int month; /** The year in which the month falls. */ private int year; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Constructs a new Month, based on the current system time. */ public Month() { this(new Date()); } /** * Constructs a new month instance. * * @param month the month (in the range 1 to 12). * @param year the year. */ public Month(int month, int year) { if ((month < 1) || (month > 12)) { throw new IllegalArgumentException("Month outside valid range."); } this.month = month; this.year = year; peg(Calendar.getInstance()); } /** * Constructs a new month instance. * * @param month the month (in the range 1 to 12). * @param year the year. */ public Month(int month, Year year) { if ((month < 1) || (month > 12)) { throw new IllegalArgumentException("Month outside valid range."); } this.month = month; this.year = year.getYear(); peg(Calendar.getInstance()); } /** * Constructs a new Month instance, based on a date/time and * the default time zone. * * @param time the date/time (null not permitted). * * @see #Month(Date, TimeZone) */ public Month(Date time) { this(time, TimeZone.getDefault()); } /** * Constructs a new Month instance, based on a date/time and * a time zone. The first and last millisecond values are initially * pegged to the given time zone also. * * @param time the date/time. * @param zone the time zone (null not permitted). * * @deprecated Since 1.0.12, use {@link #Month(Date, TimeZone, Locale)} * instead. */ public Month(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Creates a new Month instance, based on the specified time, * zone and locale. * * @param time the current time. * @param zone the time zone. * @param locale the locale. * * @since 1.0.12 */ public Month(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.month = calendar.get(Calendar.MONTH) + 1; this.year = calendar.get(Calendar.YEAR); peg(calendar); } /** * Returns the year in which the month falls. * * @return The year in which the month falls (as a Year object). */ public Year getYear() { return new Year(this.year); } /** * Returns the year in which the month falls. * * @return The year in which the month falls (as an int). */ public int getYearValue() { return this.year; } /** * Returns the month. Note that 1=JAN, 2=FEB, ... * * @return The month. */ public int getMonth() { return this.month; } /** * Returns the first millisecond of the month. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the month. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the month. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the month. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the month preceding this one. Note that the returned * {@link Month} is "pegged" using the default time-zone, irrespective of * the time-zone used to peg of the current month (which is not recorded * anywhere). See the {@link #peg(Calendar)} method. * * @return The month preceding this one. */ public RegularTimePeriod previous() { Month result; if (this.month != MonthConstants.JANUARY) { result = new Month(this.month - 1, this.year); } else { if (this.year > 1900) { result = new Month(MonthConstants.DECEMBER, this.year - 1); } else { result = null; } } return result; } /** * Returns the month following this one. Note that the returned * {@link Month} is "pegged" using the default time-zone, irrespective of * the time-zone used to peg of the current month (which is not recorded * anywhere). See the {@link #peg(Calendar)} method. * * @return The month following this one. */ public RegularTimePeriod next() { Month result; if (this.month != MonthConstants.DECEMBER) { result = new Month(this.month + 1, this.year); } else { if (this.year < 9999) { result = new Month(MonthConstants.JANUARY, this.year + 1); } else { result = null; } } return result; } /** * Returns a serial index number for the month. * * @return The serial index number. */ public long getSerialIndex() { return this.year * 12L + this.month; } /** * Returns a string representing the month (e.g. "January 2002"). *

* To do: look at internationalisation. * * @return A string representing the month. */ public String toString() { return SerialDate.monthCodeToString(this.month) + " " + this.year; } /** * Tests the equality of this Month object to an arbitrary object. * Returns true if the target is a Month instance representing the same * month as this object. In all other cases, returns false. * * @param obj the object (null permitted). * * @return true if month and year of this and object are the * same. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Month)) { return false; } Month that = (Month) obj; if (this.month != that.month) { return false; } if (this.year != that.year) { return false; } return true; } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + this.month; result = 37 * result + this.year; return result; } /** * Returns an integer indicating the order of this Month object relative to * the specified * object: negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Month object // -------------------------------------------- if (o1 instanceof Month) { Month m = (Month) o1; result = this.year - m.getYearValue(); if (result == 0) { result = this.month - m.getMonth(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns the first millisecond of the month, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The first millisecond of the month. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { calendar.set(this.year, this.month - 1, 1, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); // in the following line, we'd rather call calendar.getTimeInMillis() // to avoid object creation, but that isn't supported in Java 1.3.1 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the month, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The last millisecond of the month. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { int eom = SerialDate.lastDayOfMonth(this.month, this.year); calendar.set(this.year, this.month - 1, eom, 23, 59, 59); calendar.set(Calendar.MILLISECOND, 999); // in the following line, we'd rather call calendar.getTimeInMillis() // to avoid object creation, but that isn't supported in Java 1.3.1 return calendar.getTime().getTime(); } /** * Parses the string argument as a month. This method is required to * accept the format "YYYY-MM". It will also accept "MM-YYYY". Anything * else, at the moment, is a bonus. * * @param s the string to parse (null permitted). * * @return null if the string is not parseable, the month * otherwise. */ public static Month parseMonth(String s) { Month result = null; if (s == null) { return result; } // trim whitespace from either end of the string s = s.trim(); int i = Month.findSeparator(s); String s1, s2; boolean yearIsFirst; // if there is no separator, we assume the first four characters // are YYYY if (i == -1) { yearIsFirst = true; s1 = s.substring(0, 5); s2 = s.substring(5); } else { s1 = s.substring(0, i).trim(); s2 = s.substring(i + 1, s.length()).trim(); // now it is trickier to determine if the month or year is first Year y1 = Month.evaluateAsYear(s1); if (y1 == null) { yearIsFirst = false; } else { Year y2 = Month.evaluateAsYear(s2); if (y2 == null) { yearIsFirst = true; } else { yearIsFirst = (s1.length() > s2.length()); } } } Year year; int month; if (yearIsFirst) { year = Month.evaluateAsYear(s1); month = SerialDate.stringToMonthCode(s2); } else { year = Month.evaluateAsYear(s2); month = SerialDate.stringToMonthCode(s1); } if (month == -1) { throw new TimePeriodFormatException("Can't evaluate the month."); } if (year == null) { throw new TimePeriodFormatException("Can't evaluate the year."); } result = new Month(month, year); return result; } /** * Finds the first occurrence of '-', or if that character is not found, * the first occurrence of ',', or the first occurrence of ' ' or '.' * * @param s the string to parse. * * @return The position of the separator character, or -1 if * none of the characters were found. */ private static int findSeparator(String s) { int result = s.indexOf('-'); if (result == -1) { result = s.indexOf(','); } if (result == -1) { result = s.indexOf(' '); } if (result == -1) { result = s.indexOf('.'); } return result; } /** * Creates a year from a string, or returns null (format * exceptions suppressed). * * @param s the string to parse. * * @return null if the string is not parseable, the year * otherwise. */ private static Year evaluateAsYear(String s) { Year result = null; try { result = Year.parseYear(s); } catch (TimePeriodFormatException e) { // suppress } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/MovingAverage.java0000644000175000017500000003244111173030414026600 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * MovingAverage.java * ------------------ * (C) Copyright 2003-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Benoit Xhenseval; * * Changes * ------- * 28-Jan-2003 : Version 1 (DG); * 10-Mar-2003 : Added createPointMovingAverage() method contributed by Benoit * Xhenseval (DG); * 01-Aug-2003 : Added new method for TimeSeriesCollection, and fixed bug in * XYDataset method (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * */ package org.jfree.data.time; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * A utility class for calculating moving averages of time series data. */ public class MovingAverage { /** * Creates a new {@link TimeSeriesCollection} containing a moving average * series for each series in the source collection. * * @param source the source collection. * @param suffix the suffix added to each source series name to create the * corresponding moving average series name. * @param periodCount the number of periods in the moving average * calculation. * @param skip the number of initial periods to skip. * * @return A collection of moving average time series. */ public static TimeSeriesCollection createMovingAverage( TimeSeriesCollection source, String suffix, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeriesCollection result = new TimeSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { TimeSeries sourceSeries = source.getSeries(i); TimeSeries maSeries = createMovingAverage(sourceSeries, sourceSeries.getKey() + suffix, periodCount, skip); result.addSeries(maSeries); } return result; } /** * Creates a new {@link TimeSeries} containing moving average values for * the given series. If the series is empty (contains zero items), the * result is an empty series. * * @param source the source series. * @param name the name of the new series. * @param periodCount the number of periods used in the average * calculation. * @param skip the number of initial periods to skip. * * @return The moving average series. */ public static TimeSeries createMovingAverage(TimeSeries source, String name, int periodCount, int skip) { if (source == null) { throw new IllegalArgumentException("Null source."); } if (periodCount < 1) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 1."); } TimeSeries result = new TimeSeries(name); if (source.getItemCount() > 0) { // if the initial averaging period is to be excluded, then // calculate the index of the // first data item to have an average calculated... long firstSerial = source.getDataItem(0).getPeriod().getSerialIndex() + skip; for (int i = source.getItemCount() - 1; i >= 0; i--) { // get the current data item... TimeSeriesDataItem current = source.getDataItem(i); RegularTimePeriod period = current.getPeriod(); long serial = period.getSerialIndex(); if (serial >= firstSerial) { // work out the average for the earlier values... int n = 0; double sum = 0.0; long serialLimit = period.getSerialIndex() - periodCount; int offset = 0; boolean finished = false; while ((offset < periodCount) && (!finished)) { if ((i - offset) >= 0) { TimeSeriesDataItem item = source.getDataItem( i - offset); RegularTimePeriod p = item.getPeriod(); Number v = item.getValue(); long currentIndex = p.getSerialIndex(); if (currentIndex > serialLimit) { if (v != null) { sum = sum + v.doubleValue(); n = n + 1; } } else { finished = true; } } offset = offset + 1; } if (n > 0) { result.add(period, sum / n); } else { result.add(period, null); } } } } return result; } /** * Creates a new {@link TimeSeries} containing moving average values for * the given series, calculated by number of points (irrespective of the * 'age' of those points). If the series is empty (contains zero items), * the result is an empty series. *

* Developed by Benoit Xhenseval (www.ObjectLab.co.uk). * * @param source the source series. * @param name the name of the new series. * @param pointCount the number of POINTS used in the average calculation * (not periods!) * * @return The moving average series. */ public static TimeSeries createPointMovingAverage(TimeSeries source, String name, int pointCount) { if (source == null) { throw new IllegalArgumentException("Null 'source'."); } if (pointCount < 2) { throw new IllegalArgumentException("periodCount must be greater " + "than or equal to 2."); } TimeSeries result = new TimeSeries(name); double rollingSumForPeriod = 0.0; for (int i = 0; i < source.getItemCount(); i++) { // get the current data item... TimeSeriesDataItem current = source.getDataItem(i); RegularTimePeriod period = current.getPeriod(); rollingSumForPeriod += current.getValue().doubleValue(); if (i > pointCount - 1) { // remove the point i-periodCount out of the rolling sum. TimeSeriesDataItem startOfMovingAvg = source.getDataItem( i - pointCount); rollingSumForPeriod -= startOfMovingAvg.getValue() .doubleValue(); result.add(period, rollingSumForPeriod / pointCount); } else if (i == pointCount - 1) { result.add(period, rollingSumForPeriod / pointCount); } } return result; } /** * Creates a new {@link XYDataset} containing the moving averages of each * series in the source dataset. * * @param source the source dataset. * @param suffix the string to append to source series names to create * target series names. * @param period the averaging period. * @param skip the length of the initial skip period. * * @return The dataset. */ public static XYDataset createMovingAverage(XYDataset source, String suffix, long period, long skip) { return createMovingAverage(source, suffix, (double) period, (double) skip); } /** * Creates a new {@link XYDataset} containing the moving averages of each * series in the source dataset. * * @param source the source dataset. * @param suffix the string to append to source series names to create * target series names. * @param period the averaging period. * @param skip the length of the initial skip period. * * @return The dataset. */ public static XYDataset createMovingAverage(XYDataset source, String suffix, double period, double skip) { if (source == null) { throw new IllegalArgumentException("Null source (XYDataset)."); } XYSeriesCollection result = new XYSeriesCollection(); for (int i = 0; i < source.getSeriesCount(); i++) { XYSeries s = createMovingAverage(source, i, source.getSeriesKey(i) + suffix, period, skip); result.addSeries(s); } return result; } /** * Creates a new {@link XYSeries} containing the moving averages of one * series in the source dataset. * * @param source the source dataset. * @param series the series index (zero based). * @param name the name for the new series. * @param period the averaging period. * @param skip the length of the initial skip period. * * @return The dataset. */ public static XYSeries createMovingAverage(XYDataset source, int series, String name, double period, double skip) { if (source == null) { throw new IllegalArgumentException("Null source (XYDataset)."); } if (period < Double.MIN_VALUE) { throw new IllegalArgumentException("period must be positive."); } if (skip < 0.0) { throw new IllegalArgumentException("skip must be >= 0.0."); } XYSeries result = new XYSeries(name); if (source.getItemCount(series) > 0) { // if the initial averaging period is to be excluded, then // calculate the lowest x-value to have an average calculated... double first = source.getXValue(series, 0) + skip; for (int i = source.getItemCount(series) - 1; i >= 0; i--) { // get the current data item... double x = source.getXValue(series, i); if (x >= first) { // work out the average for the earlier values... int n = 0; double sum = 0.0; double limit = x - period; int offset = 0; boolean finished = false; while (!finished) { if ((i - offset) >= 0) { double xx = source.getXValue(series, i - offset); Number yy = source.getY(series, i - offset); if (xx > limit) { if (yy != null) { sum = sum + yy.doubleValue(); n = n + 1; } } else { finished = true; } } else { finished = true; } offset = offset + 1; } if (n > 0) { result.add(x, sum / n); } else { result.add(x, null); } } } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Quarter.java0000644000175000017500000003725211173030414025476 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------ * Quarter.java * ------------ * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 18-Dec-2001 : Changed order of parameters in constructor (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 29-Jan-2002 : Added a new method parseQuarter(String) (DG); * 14-Feb-2002 : Fixed bug in Quarter(Date) constructor (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 19-Mar-2002 : Changed API for TimePeriod classes (DG); * 24-Jun-2002 : Removed main method (just test code) (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * 10-Dec-2005 : Fixed argument checking bug (1377239) in constructor (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * 25-Nov-2008 : Added new constructor with Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import org.jfree.date.MonthConstants; import org.jfree.date.SerialDate; /** * Defines a quarter (in a given year). The range supported is Q1 1900 to * Q4 9999. This class is immutable, which is a requirement for all * {@link RegularTimePeriod} subclasses. */ public class Quarter extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = 3810061714380888671L; /** Constant for quarter 1. */ public static final int FIRST_QUARTER = 1; /** Constant for quarter 4. */ public static final int LAST_QUARTER = 4; /** The first month in each quarter. */ public static final int[] FIRST_MONTH_IN_QUARTER = { 0, MonthConstants.JANUARY, MonthConstants.APRIL, MonthConstants.JULY, MonthConstants.OCTOBER }; /** The last month in each quarter. */ public static final int[] LAST_MONTH_IN_QUARTER = { 0, MonthConstants.MARCH, MonthConstants.JUNE, MonthConstants.SEPTEMBER, MonthConstants.DECEMBER }; /** The year in which the quarter falls. */ private short year; /** The quarter (1-4). */ private byte quarter; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Constructs a new Quarter, based on the current system date/time. */ public Quarter() { this(new Date()); } /** * Constructs a new quarter. * * @param year the year (1900 to 9999). * @param quarter the quarter (1 to 4). */ public Quarter(int quarter, int year) { if ((quarter < FIRST_QUARTER) || (quarter > LAST_QUARTER)) { throw new IllegalArgumentException("Quarter outside valid range."); } this.year = (short) year; this.quarter = (byte) quarter; peg(Calendar.getInstance()); } /** * Constructs a new quarter. * * @param quarter the quarter (1 to 4). * @param year the year (1900 to 9999). */ public Quarter(int quarter, Year year) { if ((quarter < FIRST_QUARTER) || (quarter > LAST_QUARTER)) { throw new IllegalArgumentException("Quarter outside valid range."); } this.year = (short) year.getYear(); this.quarter = (byte) quarter; peg(Calendar.getInstance()); } /** * Constructs a new instance, based on a date/time and the default time * zone. * * @param time the date/time (null not permitted). * * @see #Quarter(Date, TimeZone) */ public Quarter(Date time) { this(time, TimeZone.getDefault()); } /** * Constructs a Quarter, based on a date/time and time zone. * * @param time the date/time. * @param zone the zone (null not permitted). * * @deprecated Since 1.0.12, use {@link #Quarter(Date, TimeZone, Locale)} * instead. */ public Quarter(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Creates a new Quarter instance, using the specified * zone and locale. * * @param time the current time. * @param zone the time zone. * @param locale the locale. * * @since 1.0.12 */ public Quarter(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); int month = calendar.get(Calendar.MONTH) + 1; this.quarter = (byte) SerialDate.monthCodeToQuarter(month); this.year = (short) calendar.get(Calendar.YEAR); peg(calendar); } /** * Returns the quarter. * * @return The quarter. */ public int getQuarter() { return this.quarter; } /** * Returns the year. * * @return The year. */ public Year getYear() { return new Year(this.year); } /** * Returns the year. * * @return The year. * * @since 1.0.3 */ public int getYearValue() { return this.year; } /** * Returns the first millisecond of the quarter. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the quarter. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the quarter. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the quarter. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the quarter preceding this one. * * @return The quarter preceding this one (or null if this is * Q1 1900). */ public RegularTimePeriod previous() { Quarter result; if (this.quarter > FIRST_QUARTER) { result = new Quarter(this.quarter - 1, this.year); } else { if (this.year > 1900) { result = new Quarter(LAST_QUARTER, this.year - 1); } else { result = null; } } return result; } /** * Returns the quarter following this one. * * @return The quarter following this one (or null if this is Q4 9999). */ public RegularTimePeriod next() { Quarter result; if (this.quarter < LAST_QUARTER) { result = new Quarter(this.quarter + 1, this.year); } else { if (this.year < 9999) { result = new Quarter(FIRST_QUARTER, this.year + 1); } else { result = null; } } return result; } /** * Returns a serial index number for the quarter. * * @return The serial index number. */ public long getSerialIndex() { return this.year * 4L + this.quarter; } /** * Tests the equality of this Quarter object to an arbitrary object. * Returns true if the target is a Quarter instance * representing the same quarter as this object. In all other cases, * returns false. * * @param obj the object (null permitted). * * @return true if quarter and year of this and the object are * the same. */ public boolean equals(Object obj) { if (obj != null) { if (obj instanceof Quarter) { Quarter target = (Quarter) obj; return (this.quarter == target.getQuarter() && (this.year == target.getYearValue())); } else { return false; } } else { return false; } } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + this.quarter; result = 37 * result + this.year; return result; } /** * Returns an integer indicating the order of this Quarter object relative * to the specified object: * * negative == before, zero == same, positive == after. * * @param o1 the object to compare * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Quarter object // -------------------------------------------- if (o1 instanceof Quarter) { Quarter q = (Quarter) o1; result = this.year - q.getYearValue(); if (result == 0) { result = this.quarter - q.getQuarter(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns a string representing the quarter (e.g. "Q1/2002"). * * @return A string representing the quarter. */ public String toString() { return "Q" + this.quarter + "/" + this.year; } /** * Returns the first millisecond in the Quarter, evaluated using the * supplied calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The first millisecond in the Quarter. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { int month = Quarter.FIRST_MONTH_IN_QUARTER[this.quarter]; calendar.set(this.year, month - 1, 1, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); // in the following line, we'd rather call calendar.getTimeInMillis() // to avoid object creation, but that isn't supported in Java 1.3.1 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the Quarter, evaluated using the * supplied calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The last millisecond of the Quarter. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { int month = Quarter.LAST_MONTH_IN_QUARTER[this.quarter]; int eom = SerialDate.lastDayOfMonth(month, this.year); calendar.set(this.year, month - 1, eom, 23, 59, 59); calendar.set(Calendar.MILLISECOND, 999); // in the following line, we'd rather call calendar.getTimeInMillis() // to avoid object creation, but that isn't supported in Java 1.3.1 return calendar.getTime().getTime(); } /** * Parses the string argument as a quarter. *

* This method should accept the following formats: "YYYY-QN" and "QN-YYYY", * where the "-" can be a space, a forward-slash (/), comma or a dash (-). * @param s A string representing the quarter. * * @return The quarter. */ public static Quarter parseQuarter(String s) { // find the Q and the integer following it (remove both from the // string)... int i = s.indexOf("Q"); if (i == -1) { throw new TimePeriodFormatException("Missing Q."); } if (i == s.length() - 1) { throw new TimePeriodFormatException("Q found at end of string."); } String qstr = s.substring(i + 1, i + 2); int quarter = Integer.parseInt(qstr); String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); // replace any / , or - with a space remaining = remaining.replace('/', ' '); remaining = remaining.replace(',', ' '); remaining = remaining.replace('-', ' '); // parse the string... Year year = Year.parseYear(remaining.trim()); Quarter result = new Quarter(quarter, year); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/RegularTimePeriod.java0000644000175000017500000002777511173030414027447 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * RegularTimePeriod.java * ---------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 29-May-2002 : Implemented MonthConstants interface, so that these constants * are conveniently available (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 10-Jan-2003 : Renamed TimePeriod --> RegularTimePeriod (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); * 29-Apr-2004 : Changed getMiddleMillisecond() methods to fix bug 943985 (DG); * 25-Nov-2004 : Added utility methods (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Oct-2006 : Deprecated the WORKING_CALENDAR field and several methods, * added new peg() method (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ package org.jfree.data.time; import java.lang.reflect.Constructor; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; import org.jfree.date.MonthConstants; /** * An abstract class representing a unit of time. Convenient methods are * provided for calculating the next and previous time periods. Conversion * methods are defined that return the first and last milliseconds of the time * period. The results from these methods are timezone dependent. *

* This class is immutable, and all subclasses should be immutable also. */ public abstract class RegularTimePeriod implements TimePeriod, Comparable, MonthConstants { /** * Creates a time period that includes the specified millisecond, assuming * the given time zone. * * @param c the time period class. * @param millisecond the time. * @param zone the time zone. * * @return The time period. */ public static RegularTimePeriod createInstance(Class c, Date millisecond, TimeZone zone) { RegularTimePeriod result = null; try { Constructor constructor = c.getDeclaredConstructor( new Class[] {Date.class, TimeZone.class}); result = (RegularTimePeriod) constructor.newInstance( new Object[] {millisecond, zone}); } catch (Exception e) { // do nothing, so null is returned } return result; } /** * Returns a subclass of {@link RegularTimePeriod} that is smaller than * the specified class. * * @param c a subclass of {@link RegularTimePeriod}. * * @return A class. */ public static Class downsize(Class c) { if (c.equals(Year.class)) { return Quarter.class; } else if (c.equals(Quarter.class)) { return Month.class; } else if (c.equals(Month.class)) { return Day.class; } else if (c.equals(Day.class)) { return Hour.class; } else if (c.equals(Hour.class)) { return Minute.class; } else if (c.equals(Minute.class)) { return Second.class; } else if (c.equals(Second.class)) { return Millisecond.class; } else { return Millisecond.class; } } /** * Returns the time period preceding this one, or null if some * lower limit has been reached. * * @return The previous time period (possibly null). */ public abstract RegularTimePeriod previous(); /** * Returns the time period following this one, or null if some * limit has been reached. * * @return The next time period (possibly null). */ public abstract RegularTimePeriod next(); /** * Returns a serial index number for the time unit. * * @return The serial index number. */ public abstract long getSerialIndex(); ////////////////////////////////////////////////////////////////////////// /** * The default time zone. * * @deprecated As of 1.0.11, we discourage the use of this field - use * {@link TimeZone#getDefault()} instead. */ public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault(); /** * A working calendar (recycle to avoid unnecessary object creation). * * @deprecated This was a bad idea, don't use it! */ public static final Calendar WORKING_CALENDAR = Calendar.getInstance( DEFAULT_TIME_ZONE); /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public abstract void peg(Calendar calendar); /** * Returns the date/time that marks the start of the time period. This * method returns a new Date instance every time it is called. * * @return The start date/time. * * @see #getFirstMillisecond() */ public Date getStart() { return new Date(getFirstMillisecond()); } /** * Returns the date/time that marks the end of the time period. This * method returns a new Date instance every time it is called. * * @return The end date/time. * * @see #getLastMillisecond() */ public Date getEnd() { return new Date(getLastMillisecond()); } /** * Returns the first millisecond of the time period. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the time period. * * @see #getLastMillisecond() */ public abstract long getFirstMillisecond(); /** * Returns the first millisecond of the time period, evaluated within a * specific time zone. * * @param zone the time zone (null not permitted). * * @return The first millisecond of the time period. * * @deprecated As of 1.0.3, you should avoid using this method (it creates * a new Calendar instance every time it is called). You are advised * to call {@link #getFirstMillisecond(Calendar)} instead. * * @see #getLastMillisecond(TimeZone) */ public long getFirstMillisecond(TimeZone zone) { Calendar calendar = Calendar.getInstance(zone); return getFirstMillisecond(calendar); } /** * Returns the first millisecond of the time period, evaluated using the * supplied calendar (which incorporates a timezone). * * @param calendar the calendar (null not permitted). * * @return The first millisecond of the time period. * * @throws NullPointerException if calendar,/code> is * null. * * @see #getLastMillisecond(Calendar) */ public abstract long getFirstMillisecond(Calendar calendar); /** * Returns the last millisecond of the time period. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the time period. * * @see #getFirstMillisecond() */ public abstract long getLastMillisecond(); /** * Returns the last millisecond of the time period, evaluated within a * specific time zone. * * @param zone the time zone (null not permitted). * * @return The last millisecond of the time period. * * @deprecated As of 1.0.3, you should avoid using this method (it creates * a new Calendar instance every time it is called). You are advised * to call {@link #getLastMillisecond(Calendar)} instead. * * @see #getFirstMillisecond(TimeZone) */ public long getLastMillisecond(TimeZone zone) { Calendar calendar = Calendar.getInstance(zone); return getLastMillisecond(calendar); } /** * Returns the last millisecond of the time period, evaluated using the * supplied calendar (which incorporates a timezone). * * @param calendar the calendar (null not permitted). * * @return The last millisecond of the time period. * * @see #getFirstMillisecond(Calendar) */ public abstract long getLastMillisecond(Calendar calendar); /** * Returns the millisecond closest to the middle of the time period. * * @return The middle millisecond. */ public long getMiddleMillisecond() { long m1 = getFirstMillisecond(); long m2 = getLastMillisecond(); return m1 + (m2 - m1) / 2; } /** * Returns the millisecond closest to the middle of the time period, * evaluated within a specific time zone. * * @param zone the time zone (null not permitted). * * @return The middle millisecond. * * @deprecated As of 1.0.3, you should avoid using this method (it creates * a new Calendar instance every time it is called). You are advised * to call {@link #getMiddleMillisecond(Calendar)} instead. */ public long getMiddleMillisecond(TimeZone zone) { Calendar calendar = Calendar.getInstance(zone); long m1 = getFirstMillisecond(calendar); long m2 = getLastMillisecond(calendar); return m1 + (m2 - m1) / 2; } /** * Returns the millisecond closest to the middle of the time period, * evaluated using the supplied calendar (which incorporates a timezone). * * @param calendar the calendar. * * @return The middle millisecond. */ public long getMiddleMillisecond(Calendar calendar) { long m1 = getFirstMillisecond(calendar); long m2 = getLastMillisecond(calendar); return m1 + (m2 - m1) / 2; } /** * Returns a string representation of the time period. * * @return The string. */ public String toString() { return String.valueOf(getStart()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Second.java0000644000175000017500000003620311173030414025261 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * Second.java * ----------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 18-Dec-2001 : Changed order of parameters in constructor (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 14-Feb-2002 : Fixed bug in Second(Date) constructor, and changed start of * range to zero from one (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 13-Mar-2002 : Added parseSecond() method (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 05-Mar-2003 : Fixed bug in getLastMillisecond() picked up in JUnit * tests (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * 02-Mar-2009 : Added new constructor with Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * Represents a second in a particular day. This class is immutable, which is * a requirement for all {@link RegularTimePeriod} subclasses. */ public class Second extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = -6536564190712383466L; /** Useful constant for the first second in a minute. */ public static final int FIRST_SECOND_IN_MINUTE = 0; /** Useful constant for the last second in a minute. */ public static final int LAST_SECOND_IN_MINUTE = 59; /** The day. */ private Day day; /** The hour of the day. */ private byte hour; /** The minute. */ private byte minute; /** The second. */ private byte second; /** * The first millisecond. We don't store the last millisecond, because it * is always firstMillisecond + 999L. */ private long firstMillisecond; /** * Constructs a new Second, based on the system date/time. */ public Second() { this(new Date()); } /** * Constructs a new Second. * * @param second the second (0 to 24*60*60-1). * @param minute the minute (null not permitted). */ public Second(int second, Minute minute) { if (minute == null) { throw new IllegalArgumentException("Null 'minute' argument."); } this.day = minute.getDay(); this.hour = (byte) minute.getHourValue(); this.minute = (byte) minute.getMinute(); this.second = (byte) second; peg(Calendar.getInstance()); } /** * Creates a new second. * * @param second the second (0-59). * @param minute the minute (0-59). * @param hour the hour (0-23). * @param day the day (1-31). * @param month the month (1-12). * @param year the year (1900-9999). */ public Second(int second, int minute, int hour, int day, int month, int year) { this(second, new Minute(minute, hour, day, month, year)); } /** * Constructs a new instance from the specified date/time and the default * time zone.. * * @param time the time (null not permitted). * * @see #Second(Date, TimeZone) */ public Second(Date time) { this(time, TimeZone.getDefault(), Locale.getDefault()); } /** * Creates a new second based on the supplied time and time zone. * * @param time the instant in time. * @param zone the time zone. * * @deprecated As of 1.0.13, use the constructor that specifies the locale * also. */ public Second(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Creates a new second based on the supplied time and time zone. * * @param time the time (null not permitted). * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.13 */ public Second(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.second = (byte) calendar.get(Calendar.SECOND); this.minute = (byte) calendar.get(Calendar.MINUTE); this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); this.day = new Day(time, zone, locale); peg(calendar); } /** * Returns the second within the minute. * * @return The second (0 - 59). */ public int getSecond() { return this.second; } /** * Returns the minute. * * @return The minute (never null). */ public Minute getMinute() { return new Minute(this.minute, new Hour(this.hour, this.day)); } /** * Returns the first millisecond of the second. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the second. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the second. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the second. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.firstMillisecond + 999L; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); } /** * Returns the second preceding this one. * * @return The second preceding this one. */ public RegularTimePeriod previous() { Second result = null; if (this.second != FIRST_SECOND_IN_MINUTE) { result = new Second(this.second - 1, getMinute()); } else { Minute previous = (Minute) getMinute().previous(); if (previous != null) { result = new Second(LAST_SECOND_IN_MINUTE, previous); } } return result; } /** * Returns the second following this one. * * @return The second following this one. */ public RegularTimePeriod next() { Second result = null; if (this.second != LAST_SECOND_IN_MINUTE) { result = new Second(this.second + 1, getMinute()); } else { Minute next = (Minute) getMinute().next(); if (next != null) { result = new Second(FIRST_SECOND_IN_MINUTE, next); } } return result; } /** * Returns a serial index number for the minute. * * @return The serial index number. */ public long getSerialIndex() { long hourIndex = this.day.getSerialIndex() * 24L + this.hour; long minuteIndex = hourIndex * 60L + this.minute; return minuteIndex * 60L + this.second; } /** * Returns the first millisecond of the minute. * * @param calendar the calendar/timezone (null not permitted). * * @return The first millisecond. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { int year = this.day.getYear(); int month = this.day.getMonth() - 1; int day = this.day.getDayOfMonth(); calendar.clear(); calendar.set(year, month, day, this.hour, this.minute, this.second); calendar.set(Calendar.MILLISECOND, 0); //return calendar.getTimeInMillis(); // this won't work for JDK 1.3 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the second. * * @param calendar the calendar/timezone (null not permitted). * * @return The last millisecond. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { return getFirstMillisecond(calendar) + 999L; } /** * Tests the equality of this object against an arbitrary Object. *

* This method will return true ONLY if the object is a Second object * representing the same second as this instance. * * @param obj the object to compare (null permitted). * * @return true if second and minute of this and the object * are the same. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Second)) { return false; } Second that = (Second) obj; if (this.second != that.second) { return false; } if (this.minute != that.minute) { return false; } if (this.hour != that.hour) { return false; } if (!this.day.equals(that.day)) { return false; } return true; } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + this.second; result = 37 * result + this.minute; result = 37 * result + this.hour; result = 37 * result + this.day.hashCode(); return result; } /** * Returns an integer indicating the order of this Second object relative * to the specified * object: negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Second object // ------------------------------------------- if (o1 instanceof Second) { Second s = (Second) o1; if (this.firstMillisecond < s.firstMillisecond) { return -1; } else if (this.firstMillisecond > s.firstMillisecond) { return 1; } else { return 0; } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Creates a new instance by parsing a string. The string is assumed to * be in the format "YYYY-MM-DD HH:MM:SS", perhaps with leading or trailing * whitespace. * * @param s the string to parse. * * @return The second, or null if the string is not parseable. */ public static Second parseSecond(String s) { Second result = null; s = s.trim(); String daystr = s.substring(0, Math.min(10, s.length())); Day day = Day.parseDay(daystr); if (day != null) { String hmsstr = s.substring(Math.min(daystr.length() + 1, s.length()), s.length()); hmsstr = hmsstr.trim(); int l = hmsstr.length(); String hourstr = hmsstr.substring(0, Math.min(2, l)); String minstr = hmsstr.substring(Math.min(3, l), Math.min(5, l)); String secstr = hmsstr.substring(Math.min(6, l), Math.min(8, l)); int hour = Integer.parseInt(hourstr); if ((hour >= 0) && (hour <= 23)) { int minute = Integer.parseInt(minstr); if ((minute >= 0) && (minute <= 59)) { Minute m = new Minute(minute, new Hour(hour, day)); int second = Integer.parseInt(secstr); if ((second >= 0) && (second <= 59)) { result = new Second(second, m); } } } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/SimpleTimePeriod.java0000644000175000017500000001504711173030414027264 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * SimpleTimePeriod.java * --------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Oct-2002 : Added Javadocs (DG); * 10-Jan-2003 : Renamed TimeAllocation --> SimpleTimePeriod (DG); * 13-Mar-2003 : Added equals() method, and Serializable interface (DG); * 21-Oct-2003 : Added hashCode() method (DG); * 27-Jan-2005 : Implemented Comparable, to enable this class to be used * in the TimeTableXYDataset class (DG); * 02-Jun-2008 : Fixed problem with fields being mutable (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Date; /** * An arbitrary period of time, measured to millisecond precision using * java.util.Date. *

* This class is intentionally immutable (that is, once constructed, you cannot * alter the start and end attributes). */ public class SimpleTimePeriod implements TimePeriod, Comparable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8684672361131829554L; /** The start date/time. */ private long start; /** The end date/time. */ private long end; /** * Creates a new time allocation. * * @param start the start date/time in milliseconds. * @param end the end date/time in milliseconds. */ public SimpleTimePeriod(long start, long end) { if (start > end) { throw new IllegalArgumentException("Requires start <= end."); } this.start = start; this.end = end; } /** * Creates a new time allocation. * * @param start the start date/time (null not permitted). * @param end the end date/time (null not permitted). */ public SimpleTimePeriod(Date start, Date end) { this(start.getTime(), end.getTime()); } /** * Returns the start date/time. * * @return The start date/time (never null). */ public Date getStart() { return new Date(this.start); } /** * Returns the start date/time in milliseconds. * * @return The start. * * @since 1.0.10. */ public long getStartMillis() { return this.start; } /** * Returns the end date/time. * * @return The end date/time (never null). */ public Date getEnd() { return new Date(this.end); } /** * Returns the end date/time in milliseconds. * * @return The end. * * @since 1.0.10. */ public long getEndMillis() { return this.end; } /** * Tests this time period instance for equality with an arbitrary object. * The object is considered equal if it is an instance of {@link TimePeriod} * and it has the same start and end dates. * * @param obj the other object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimePeriod)) { return false; } TimePeriod that = (TimePeriod) obj; if (!this.getStart().equals(that.getStart())) { return false; } if (!this.getEnd().equals(that.getEnd())) { return false; } return true; } /** * Returns an integer that indicates the relative ordering of two * time periods. * * @param obj the object (null not permitted). * * @return An integer. * * @throws ClassCastException if obj is not an instance of * {@link TimePeriod}. */ public int compareTo(Object obj) { TimePeriod that = (TimePeriod) obj; long t0 = getStart().getTime(); long t1 = getEnd().getTime(); long m0 = t0 + (t1 - t0) / 2L; long t2 = that.getStart().getTime(); long t3 = that.getEnd().getTime(); long m1 = t2 + (t3 - t2) / 2L; if (m0 < m1) { return -1; } else if (m0 > m1) { return 1; } else { if (t0 < t2) { return -1; } else if (t0 > t2) { return 1; } else { if (t1 < t3) { return -1; } else if (t1 > t3) { return 1; } else { return 0; } } } } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here - see: *

* http://developer.java.sun.com/ * developer/Books/effectivejava/Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + (int) this.start; result = 37 * result + (int) this.end; return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimePeriod.java0000644000175000017500000000437211173030414026111 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * TimePeriod.java * --------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jan-2003 : Version 1 (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); * 27-Jan-2005 : Implemented Comparable (DG); * */ package org.jfree.data.time; import java.util.Date; /** * A period of time measured to millisecond precision using two instances of * java.util.Date. */ public interface TimePeriod extends Comparable { /** * Returns the start date/time. This will always be on or before the * end date. * * @return The start date/time (never null). */ public Date getStart(); /** * Returns the end date/time. This will always be on or after the * start date. * * @return The end date/time (never null). */ public Date getEnd(); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimePeriodAnchor.java0000644000175000017500000001014511173030414027237 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * TimePeriodAnchor.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 30-Jul-2003 : Version 1 (DG); * 01-Mar-2004 : Added readResolve() method (DG); * */ package org.jfree.data.time; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate one of three positions in a time period: * START, MIDDLE and END. */ public final class TimePeriodAnchor implements Serializable { /** For serialization. */ private static final long serialVersionUID = 2011955697457548862L; /** Start of period. */ public static final TimePeriodAnchor START = new TimePeriodAnchor("TimePeriodAnchor.START"); /** Middle of period. */ public static final TimePeriodAnchor MIDDLE = new TimePeriodAnchor("TimePeriodAnchor.MIDDLE"); /** End of period. */ public static final TimePeriodAnchor END = new TimePeriodAnchor("TimePeriodAnchor.END"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private TimePeriodAnchor(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof TimePeriodAnchor)) { return false; } TimePeriodAnchor position = (TimePeriodAnchor) obj; if (!this.name.equals(position.name)) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(TimePeriodAnchor.START)) { return TimePeriodAnchor.START; } else if (this.equals(TimePeriodAnchor.MIDDLE)) { return TimePeriodAnchor.MIDDLE; } else if (this.equals(TimePeriodAnchor.END)) { return TimePeriodAnchor.END; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimePeriodFormatException.java0000644000175000017500000000377511173030414031147 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * TimePeriodFormatException.java * ------------------------------ * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Dec-2001 : Version 1 (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); */ package org.jfree.data.time; /** * An exception that indicates an invalid format in a string representing a * time period. */ public class TimePeriodFormatException extends IllegalArgumentException { /** * Creates a new exception. * * @param message a message describing the exception. */ public TimePeriodFormatException(String message) { super(message); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimePeriodValue.java0000644000175000017500000001276311173030414027111 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * TimePeriodValue.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Apr-2003 : Version 1 (DG); * 03-Oct-2006 : Added null argument check to constructor (DG); * 07-Apr-2008 : Added a toString() override for debugging (DG); * */ package org.jfree.data.time; import java.io.Serializable; /** * Represents a time period and an associated value. */ public class TimePeriodValue implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 3390443360845711275L; /** The time period. */ private TimePeriod period; /** The value associated with the time period. */ private Number value; /** * Constructs a new data item. * * @param period the time period (null not permitted). * @param value the value associated with the time period. * * @throws IllegalArgumentException if period is * null. */ public TimePeriodValue(TimePeriod period, Number value) { if (period == null) { throw new IllegalArgumentException("Null 'period' argument."); } this.period = period; this.value = value; } /** * Constructs a new data item. * * @param period the time period (null not permitted). * @param value the value associated with the time period. * * @throws IllegalArgumentException if period is * null. */ public TimePeriodValue(TimePeriod period, double value) { this(period, new Double(value)); } /** * Returns the time period. * * @return The time period (never null). */ public TimePeriod getPeriod() { return this.period; } /** * Returns the value. * * @return The value (possibly null). * * @see #setValue(Number) */ public Number getValue() { return this.value; } /** * Sets the value for this data item. * * @param value the new value (null permitted). * * @see #getValue() */ public void setValue(Number value) { this.value = value; } /** * Tests this object for equality with the target object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof TimePeriodValue)) { return false; } TimePeriodValue timePeriodValue = (TimePeriodValue) obj; if (this.period != null ? !this.period.equals(timePeriodValue.period) : timePeriodValue.period != null) { return false; } if (this.value != null ? !this.value.equals(timePeriodValue.value) : timePeriodValue.value != null) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { int result; result = (this.period != null ? this.period.hashCode() : 0); result = 29 * result + (this.value != null ? this.value.hashCode() : 0); return result; } /** * Clones the object. *

* Note: no need to clone the period or value since they are immutable * classes. * * @return A clone. */ public Object clone() { Object clone = null; try { clone = super.clone(); } catch (CloneNotSupportedException e) { // won't get here... e.printStackTrace(); } return clone; } /** * Returns a string representing this instance, primarily for use in * debugging. * * @return A string. */ public String toString() { return "TimePeriodValue[" + getPeriod() + "," + getValue() + "]"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimePeriodValues.java0000644000175000017500000004405511173030414027273 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * TimePeriodValues.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Apr-2003 : Version 1 (DG); * 30-Jul-2003 : Added clone and equals methods while testing (DG); * 11-Mar-2005 : Fixed bug in bounds recalculation - see bug report * 1161329 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-Oct-2006 : Fixed NullPointerException in equals(), fire change event in * add() method, updated API docs (DG); * 07-Apr-2008 : Fixed bug with maxMiddleIndex in updateBounds() (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.jfree.data.general.Series; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesException; import org.jfree.util.ObjectUtilities; /** * A structure containing zero, one or many {@link TimePeriodValue} instances. * The time periods can overlap, and are maintained in the order that they are * added to the collection. *

* This is similar to the {@link TimeSeries} class, except that the time * periods can have irregular lengths. */ public class TimePeriodValues extends Series implements Serializable { /** For serialization. */ static final long serialVersionUID = -2210593619794989709L; /** Default value for the domain description. */ protected static final String DEFAULT_DOMAIN_DESCRIPTION = "Time"; /** Default value for the range description. */ protected static final String DEFAULT_RANGE_DESCRIPTION = "Value"; /** A description of the domain. */ private String domain; /** A description of the range. */ private String range; /** The list of data pairs in the series. */ private List data; /** Index of the time period with the minimum start milliseconds. */ private int minStartIndex = -1; /** Index of the time period with the maximum start milliseconds. */ private int maxStartIndex = -1; /** Index of the time period with the minimum middle milliseconds. */ private int minMiddleIndex = -1; /** Index of the time period with the maximum middle milliseconds. */ private int maxMiddleIndex = -1; /** Index of the time period with the minimum end milliseconds. */ private int minEndIndex = -1; /** Index of the time period with the maximum end milliseconds. */ private int maxEndIndex = -1; /** * Creates a new (empty) collection of time period values. * * @param name the name of the series (null not permitted). */ public TimePeriodValues(String name) { this(name, DEFAULT_DOMAIN_DESCRIPTION, DEFAULT_RANGE_DESCRIPTION); } /** * Creates a new time series that contains no data. *

* Descriptions can be specified for the domain and range. One situation * where this is helpful is when generating a chart for the time series - * axis labels can be taken from the domain and range description. * * @param name the name of the series (null not permitted). * @param domain the domain description. * @param range the range description. */ public TimePeriodValues(String name, String domain, String range) { super(name); this.domain = domain; this.range = range; this.data = new ArrayList(); } /** * Returns the domain description. * * @return The domain description (possibly null). * * @see #getRangeDescription() * @see #setDomainDescription(String) */ public String getDomainDescription() { return this.domain; } /** * Sets the domain description and fires a property change event (with the * property name Domain if the description changes). * * @param description the new description (null permitted). * * @see #getDomainDescription() */ public void setDomainDescription(String description) { String old = this.domain; this.domain = description; firePropertyChange("Domain", old, description); } /** * Returns the range description. * * @return The range description (possibly null). * * @see #getDomainDescription() * @see #setRangeDescription(String) */ public String getRangeDescription() { return this.range; } /** * Sets the range description and fires a property change event with the * name Range. * * @param description the new description (null permitted). * * @see #getRangeDescription() */ public void setRangeDescription(String description) { String old = this.range; this.range = description; firePropertyChange("Range", old, description); } /** * Returns the number of items in the series. * * @return The item count. */ public int getItemCount() { return this.data.size(); } /** * Returns one data item for the series. * * @param index the item index (in the range 0 to * getItemCount() - 1). * * @return One data item for the series. */ public TimePeriodValue getDataItem(int index) { return (TimePeriodValue) this.data.get(index); } /** * Returns the time period at the specified index. * * @param index the item index (in the range 0 to * getItemCount() - 1). * * @return The time period at the specified index. * * @see #getDataItem(int) */ public TimePeriod getTimePeriod(int index) { return getDataItem(index).getPeriod(); } /** * Returns the value at the specified index. * * @param index the item index (in the range 0 to * getItemCount() - 1). * * @return The value at the specified index (possibly null). * * @see #getDataItem(int) */ public Number getValue(int index) { return getDataItem(index).getValue(); } /** * Adds a data item to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. * * @param item the item (null not permitted). */ public void add(TimePeriodValue item) { if (item == null) { throw new IllegalArgumentException("Null item not allowed."); } this.data.add(item); updateBounds(item.getPeriod(), this.data.size() - 1); fireSeriesChanged(); } /** * Update the index values for the maximum and minimum bounds. * * @param period the time period. * @param index the index of the time period. */ private void updateBounds(TimePeriod period, int index) { long start = period.getStart().getTime(); long end = period.getEnd().getTime(); long middle = start + ((end - start) / 2); if (this.minStartIndex >= 0) { long minStart = getDataItem(this.minStartIndex).getPeriod() .getStart().getTime(); if (start < minStart) { this.minStartIndex = index; } } else { this.minStartIndex = index; } if (this.maxStartIndex >= 0) { long maxStart = getDataItem(this.maxStartIndex).getPeriod() .getStart().getTime(); if (start > maxStart) { this.maxStartIndex = index; } } else { this.maxStartIndex = index; } if (this.minMiddleIndex >= 0) { long s = getDataItem(this.minMiddleIndex).getPeriod().getStart() .getTime(); long e = getDataItem(this.minMiddleIndex).getPeriod().getEnd() .getTime(); long minMiddle = s + (e - s) / 2; if (middle < minMiddle) { this.minMiddleIndex = index; } } else { this.minMiddleIndex = index; } if (this.maxMiddleIndex >= 0) { long s = getDataItem(this.maxMiddleIndex).getPeriod().getStart() .getTime(); long e = getDataItem(this.maxMiddleIndex).getPeriod().getEnd() .getTime(); long maxMiddle = s + (e - s) / 2; if (middle > maxMiddle) { this.maxMiddleIndex = index; } } else { this.maxMiddleIndex = index; } if (this.minEndIndex >= 0) { long minEnd = getDataItem(this.minEndIndex).getPeriod().getEnd() .getTime(); if (end < minEnd) { this.minEndIndex = index; } } else { this.minEndIndex = index; } if (this.maxEndIndex >= 0) { long maxEnd = getDataItem(this.maxEndIndex).getPeriod().getEnd() .getTime(); if (end > maxEnd) { this.maxEndIndex = index; } } else { this.maxEndIndex = index; } } /** * Recalculates the bounds for the collection of items. */ private void recalculateBounds() { this.minStartIndex = -1; this.minMiddleIndex = -1; this.minEndIndex = -1; this.maxStartIndex = -1; this.maxMiddleIndex = -1; this.maxEndIndex = -1; for (int i = 0; i < this.data.size(); i++) { TimePeriodValue tpv = (TimePeriodValue) this.data.get(i); updateBounds(tpv.getPeriod(), i); } } /** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (null not permitted). * @param value the value. * * @see #add(TimePeriod, Number) */ public void add(TimePeriod period, double value) { TimePeriodValue item = new TimePeriodValue(period, value); add(item); } /** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (null not permitted). * @param value the value (null permitted). */ public void add(TimePeriod period, Number value) { TimePeriodValue item = new TimePeriodValue(period, value); add(item); } /** * Updates (changes) the value of a data item and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the index of the data item to update. * @param value the new value (null not permitted). */ public void update(int index, Number value) { TimePeriodValue item = getDataItem(index); item.setValue(value); fireSeriesChanged(); } /** * Deletes data from start until end index (end inclusive) and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param start the index of the first period to delete. * @param end the index of the last period to delete. */ public void delete(int start, int end) { for (int i = 0; i <= (end - start); i++) { this.data.remove(start); } recalculateBounds(); fireSeriesChanged(); } /** * Tests the series for equality with another object. * * @param obj the object (null permitted). * * @return true or false. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimePeriodValues)) { return false; } if (!super.equals(obj)) { return false; } TimePeriodValues that = (TimePeriodValues) obj; if (!ObjectUtilities.equal(this.getDomainDescription(), that.getDomainDescription())) { return false; } if (!ObjectUtilities.equal(this.getRangeDescription(), that.getRangeDescription())) { return false; } int count = getItemCount(); if (count != that.getItemCount()) { return false; } for (int i = 0; i < count; i++) { if (!getDataItem(i).equals(that.getDataItem(i))) { return false; } } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { int result; result = (this.domain != null ? this.domain.hashCode() : 0); result = 29 * result + (this.range != null ? this.range.hashCode() : 0); result = 29 * result + this.data.hashCode(); result = 29 * result + this.minStartIndex; result = 29 * result + this.maxStartIndex; result = 29 * result + this.minMiddleIndex; result = 29 * result + this.maxMiddleIndex; result = 29 * result + this.minEndIndex; result = 29 * result + this.maxEndIndex; return result; } /** * Returns a clone of the collection. *

* Notes: *

    *
  • no need to clone the domain and range descriptions, since String * object is immutable;
  • *
  • we pass over to the more general method createCopy(start, end). *
  • *
* * @return A clone of the time series. * * @throws CloneNotSupportedException if there is a cloning problem. */ public Object clone() throws CloneNotSupportedException { Object clone = createCopy(0, getItemCount() - 1); return clone; } /** * Creates a new instance by copying a subset of the data in this * collection. * * @param start the index of the first item to copy. * @param end the index of the last item to copy. * * @return A copy of a subset of the items. * * @throws CloneNotSupportedException if there is a cloning problem. */ public TimePeriodValues createCopy(int start, int end) throws CloneNotSupportedException { TimePeriodValues copy = (TimePeriodValues) super.clone(); copy.data = new ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { TimePeriodValue item = (TimePeriodValue) this.data.get(index); TimePeriodValue clone = (TimePeriodValue) item.clone(); try { copy.add(clone); } catch (SeriesException e) { System.err.println("Failed to add cloned item."); } } } return copy; } /** * Returns the index of the time period with the minimum start milliseconds. * * @return The index. */ public int getMinStartIndex() { return this.minStartIndex; } /** * Returns the index of the time period with the maximum start milliseconds. * * @return The index. */ public int getMaxStartIndex() { return this.maxStartIndex; } /** * Returns the index of the time period with the minimum middle * milliseconds. * * @return The index. */ public int getMinMiddleIndex() { return this.minMiddleIndex; } /** * Returns the index of the time period with the maximum middle * milliseconds. * * @return The index. */ public int getMaxMiddleIndex() { return this.maxMiddleIndex; } /** * Returns the index of the time period with the minimum end milliseconds. * * @return The index. */ public int getMinEndIndex() { return this.minEndIndex; } /** * Returns the index of the time period with the maximum end milliseconds. * * @return The index. */ public int getMaxEndIndex() { return this.maxEndIndex; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimePeriodValuesCollection.java0000644000175000017500000004047311173030414031307 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * TimePeriodValuesCollection.java * ------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Apr-2003 : Version 1 (DG); * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 06-Oct-2004 : Updated for changes in DomainInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-Oct-2006 : Deprecated get/setDomainIsPointsInTime() (DG); * 11-Jun-2007 : Fixed bug in getDomainBounds() method, and changed default * value for domainIsPointsInTime to false (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.util.ObjectUtilities; /** * A collection of {@link TimePeriodValues} objects. *

* This class implements the {@link org.jfree.data.xy.XYDataset} interface, as * well as the extended {@link IntervalXYDataset} interface. This makes it a * convenient dataset for use with the {@link org.jfree.chart.plot.XYPlot} * class. */ public class TimePeriodValuesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, Serializable { /** For serialization. */ private static final long serialVersionUID = -3077934065236454199L; /** Storage for the time series. */ private List data; /** * The position within a time period to return as the x-value (START, * MIDDLE or END). */ private TimePeriodAnchor xPosition; /** * A flag that indicates that the domain is 'points in time'. If this * flag is true, only the x-value is used to determine the range of values * in the domain, the start and end x-values are ignored. */ private boolean domainIsPointsInTime; /** * Constructs an empty dataset. */ public TimePeriodValuesCollection() { this((TimePeriodValues) null); } /** * Constructs a dataset containing a single series. Additional series can * be added. * * @param series the series (null ignored). */ public TimePeriodValuesCollection(TimePeriodValues series) { this.data = new java.util.ArrayList(); this.xPosition = TimePeriodAnchor.MIDDLE; this.domainIsPointsInTime = false; if (series != null) { this.data.add(series); series.addChangeListener(this); } } /** * Returns the position of the X value within each time period. * * @return The position (never null). * * @see #setXPosition(TimePeriodAnchor) */ public TimePeriodAnchor getXPosition() { return this.xPosition; } /** * Sets the position of the x axis within each time period. * * @param position the position (null not permitted). * * @see #getXPosition() */ public void setXPosition(TimePeriodAnchor position) { if (position == null) { throw new IllegalArgumentException("Null 'position' argument."); } this.xPosition = position; } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a series. * * @param series the index of the series (zero-based). * * @return The series. */ public TimePeriodValues getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Index 'series' out of range."); } return (TimePeriodValues) this.data.get(series); } /** * Returns the key for a series. * * @param series the index of the series (zero-based). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Adds a series to the collection. A * {@link org.jfree.data.general.DatasetChangeEvent} is sent to all * registered listeners. * * @param series the time series. */ public void addSeries(TimePeriodValues series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Removes the specified series from the collection. * * @param series the series to remove (null not permitted). */ public void removeSeries(TimePeriodValues series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.remove(series); series.removeChangeListener(this); fireDatasetChanged(); } /** * Removes a series from the collection. * * @param index the series index (zero-based). */ public void removeSeries(int index) { TimePeriodValues series = getSeries(index); if (series != null) { removeSeries(series); } } /** * Returns the number of items in the specified series. *

* This method is provided for convenience. * * @param series the index of the series of interest (zero-based). * * @return The number of items in the specified series. */ public int getItemCount(int series) { return getSeries(series).getItemCount(); } /** * Returns the x-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value for the specified series and item. */ public Number getX(int series, int item) { TimePeriodValues ts = (TimePeriodValues) this.data.get(series); TimePeriodValue dp = ts.getDataItem(item); TimePeriod period = dp.getPeriod(); return new Long(getX(period)); } /** * Returns the x-value for a time period. * * @param period the time period. * * @return The x-value. */ private long getX(TimePeriod period) { if (this.xPosition == TimePeriodAnchor.START) { return period.getStart().getTime(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { return period.getStart().getTime() / 2 + period.getEnd().getTime() / 2; } else if (this.xPosition == TimePeriodAnchor.END) { return period.getEnd().getTime(); } else { throw new IllegalStateException("TimePeriodAnchor unknown."); } } /** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The starting X value for the specified series and item. */ public Number getStartX(int series, int item) { TimePeriodValues ts = (TimePeriodValues) this.data.get(series); TimePeriodValue dp = ts.getDataItem(item); return new Long(dp.getPeriod().getStart().getTime()); } /** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The ending X value for the specified series and item. */ public Number getEndX(int series, int item) { TimePeriodValues ts = (TimePeriodValues) this.data.get(series); TimePeriodValue dp = ts.getDataItem(item); return new Long(dp.getPeriod().getEnd().getTime()); } /** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value for the specified series and item. */ public Number getY(int series, int item) { TimePeriodValues ts = (TimePeriodValues) this.data.get(series); TimePeriodValue dp = ts.getDataItem(item); return dp.getValue(); } /** * Returns the starting Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The starting Y value for the specified series and item. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The ending Y value for the specified series and item. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getLowerBound(); } return result; } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { boolean interval = includeInterval || this.domainIsPointsInTime; Range result = null; Range temp = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimePeriodValues series = (TimePeriodValues) iterator.next(); int count = series.getItemCount(); if (count > 0) { TimePeriod start = series.getTimePeriod( series.getMinStartIndex()); TimePeriod end = series.getTimePeriod(series.getMaxEndIndex()); if (!interval) { if (this.xPosition == TimePeriodAnchor.START) { TimePeriod maxStart = series.getTimePeriod( series.getMaxStartIndex()); temp = new Range(start.getStart().getTime(), maxStart.getStart().getTime()); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { TimePeriod minMiddle = series.getTimePeriod( series.getMinMiddleIndex()); long s1 = minMiddle.getStart().getTime(); long e1 = minMiddle.getEnd().getTime(); TimePeriod maxMiddle = series.getTimePeriod( series.getMaxMiddleIndex()); long s2 = maxMiddle.getStart().getTime(); long e2 = maxMiddle.getEnd().getTime(); temp = new Range(s1 + (e1 - s1) / 2, s2 + (e2 - s2) / 2); } else if (this.xPosition == TimePeriodAnchor.END) { TimePeriod minEnd = series.getTimePeriod( series.getMinEndIndex()); temp = new Range(minEnd.getEnd().getTime(), end.getEnd().getTime()); } } else { temp = new Range(start.getStart().getTime(), end.getEnd().getTime()); } result = Range.combine(result, temp); } } return result; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimePeriodValuesCollection)) { return false; } TimePeriodValuesCollection that = (TimePeriodValuesCollection) obj; if (this.domainIsPointsInTime != that.domainIsPointsInTime) { return false; } if (this.xPosition != that.xPosition) { return false; } if (!ObjectUtilities.equal(this.data, that.data)) { return false; } return true; } // --- DEPRECATED METHODS ------------------------------------------------- /** * Returns a flag that controls whether the domain is treated as 'points * in time'. This flag is used when determining the max and min values for * the domain. If true, then only the x-values are considered for the max * and min values. If false, then the start and end x-values will also be * taken into consideration * * @return The flag. * * @deprecated This flag is no longer used by JFreeChart (as of version * 1.0.3). */ public boolean getDomainIsPointsInTime() { return this.domainIsPointsInTime; } /** * Sets a flag that controls whether the domain is treated as 'points in * time', or time periods. * * @param flag the new value of the flag. * * @deprecated This flag is no longer used by JFreeChart (as of version * 1.0.3). */ public void setDomainIsPointsInTime(boolean flag) { this.domainIsPointsInTime = flag; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimeSeries.java0000644000175000017500000011507511173030414026124 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * TimeSeries.java * --------------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Bryan Scott; * Nick Guenther; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 14-Nov-2001 : Added listener mechanism (DG); * 15-Nov-2001 : Updated argument checking and exceptions in add() method (DG); * 29-Nov-2001 : Added properties to describe the domain and range (DG); * 07-Dec-2001 : Renamed TimeSeries --> BasicTimeSeries (DG); * 01-Mar-2002 : Updated import statements (DG); * 28-Mar-2002 : Added a method add(TimePeriod, double) (DG); * 27-Aug-2002 : Changed return type of delete method to void (DG); * 04-Oct-2002 : Added itemCount and historyCount attributes, fixed errors * reported by Checkstyle (DG); * 29-Oct-2002 : Added series change notification to addOrUpdate() method (DG); * 28-Jan-2003 : Changed name back to TimeSeries (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented * Serializable (DG); * 01-May-2003 : Updated equals() method (see bug report 727575) (DG); * 14-Aug-2003 : Added ageHistoryCountItems method (copied existing code for * contents) made a method and added to addOrUpdate. Made a * public method to enable ageing against a specified time * (eg now) as opposed to lastest time in series (BS); * 15-Oct-2003 : Added fix for setItemCount method - see bug report 804425. * Modified exception message in add() method to be more * informative (DG); * 13-Apr-2004 : Added clear() method (DG); * 21-May-2004 : Added an extra addOrUpdate() method (DG); * 15-Jun-2004 : Fixed NullPointerException in equals() method (DG); * 29-Nov-2004 : Fixed bug 1075255 (DG); * 17-Nov-2005 : Renamed historyCount --> maximumItemAge (DG); * 28-Nov-2005 : Changed maximumItemAge from int to long (DG); * 01-Dec-2005 : New add methods accept notify flag (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 24-May-2006 : Improved error handling in createCopy() methods (DG); * 01-Sep-2006 : Fixed bugs in removeAgedItems() methods - see bug report * 1550045 (DG); * 22-Mar-2007 : Simplified getDataItem(RegularTimePeriod) - see patch 1685500 * by Nick Guenther (DG); * 31-Oct-2007 : Implemented faster hashCode() (DG); * 21-Nov-2007 : Fixed clone() method (bug 1832432) (DG); * 10-Jan-2008 : Fixed createCopy(RegularTimePeriod, RegularTimePeriod) (bug * 1864222) (DG); * 13-Jan-2009 : Fixed constructors so that timePeriodClass doesn't need to * be specified in advance (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.TimeZone; import org.jfree.data.general.Series; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesException; import org.jfree.util.ObjectUtilities; /** * Represents a sequence of zero or more data items in the form (period, value) * where 'period' is some instance of a subclass of {@link RegularTimePeriod}. * The time series will ensure that (a) all data items have the same type of * period (for example, {@link Day}) and (b) that each period appears at * most one time in the series. */ public class TimeSeries extends Series implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -5032960206869675528L; /** Default value for the domain description. */ protected static final String DEFAULT_DOMAIN_DESCRIPTION = "Time"; /** Default value for the range description. */ protected static final String DEFAULT_RANGE_DESCRIPTION = "Value"; /** A description of the domain. */ private String domain; /** A description of the range. */ private String range; /** The type of period for the data. */ protected Class timePeriodClass; /** The list of data items in the series. */ protected List data; /** The maximum number of items for the series. */ private int maximumItemCount; /** * The maximum age of items for the series, specified as a number of * time periods. */ private long maximumItemAge; /** * Creates a new (empty) time series. By default, a daily time series is * created. Use one of the other constructors if you require a different * time period. * * @param name the series name (null not permitted). */ public TimeSeries(Comparable name) { this(name, DEFAULT_DOMAIN_DESCRIPTION, DEFAULT_RANGE_DESCRIPTION); } /** * Creates a new time series that contains no data. *

* Descriptions can be specified for the domain and range. One situation * where this is helpful is when generating a chart for the time series - * axis labels can be taken from the domain and range description. * * @param name the name of the series (null not permitted). * @param domain the domain description (null permitted). * @param range the range description (null permitted). * * @since 1.0.13 */ public TimeSeries(Comparable name, String domain, String range) { super(name); this.domain = domain; this.range = range; this.timePeriodClass = null; this.data = new java.util.ArrayList(); this.maximumItemCount = Integer.MAX_VALUE; this.maximumItemAge = Long.MAX_VALUE; } /** * Returns the domain description. * * @return The domain description (possibly null). * * @see #setDomainDescription(String) */ public String getDomainDescription() { return this.domain; } /** * Sets the domain description and sends a PropertyChangeEvent * (with the property name Domain) to all registered * property change listeners. * * @param description the description (null permitted). * * @see #getDomainDescription() */ public void setDomainDescription(String description) { String old = this.domain; this.domain = description; firePropertyChange("Domain", old, description); } /** * Returns the range description. * * @return The range description (possibly null). * * @see #setRangeDescription(String) */ public String getRangeDescription() { return this.range; } /** * Sets the range description and sends a PropertyChangeEvent * (with the property name Range) to all registered listeners. * * @param description the description (null permitted). * * @see #getRangeDescription() */ public void setRangeDescription(String description) { String old = this.range; this.range = description; firePropertyChange("Range", old, description); } /** * Returns the number of items in the series. * * @return The item count. */ public int getItemCount() { return this.data.size(); } /** * Returns the list of data items for the series (the list contains * {@link TimeSeriesDataItem} objects and is unmodifiable). * * @return The list of data items. */ public List getItems() { return Collections.unmodifiableList(this.data); } /** * Returns the maximum number of items that will be retained in the series. * The default value is Integer.MAX_VALUE. * * @return The maximum item count. * * @see #setMaximumItemCount(int) */ public int getMaximumItemCount() { return this.maximumItemCount; } /** * Sets the maximum number of items that will be retained in the series. * If you add a new item to the series such that the number of items will * exceed the maximum item count, then the FIRST element in the series is * automatically removed, ensuring that the maximum item count is not * exceeded. * * @param maximum the maximum (requires >= 0). * * @see #getMaximumItemCount() */ public void setMaximumItemCount(int maximum) { if (maximum < 0) { throw new IllegalArgumentException("Negative 'maximum' argument."); } this.maximumItemCount = maximum; int count = this.data.size(); if (count > maximum) { delete(0, count - maximum - 1); } } /** * Returns the maximum item age (in time periods) for the series. * * @return The maximum item age. * * @see #setMaximumItemAge(long) */ public long getMaximumItemAge() { return this.maximumItemAge; } /** * Sets the number of time units in the 'history' for the series. This * provides one mechanism for automatically dropping old data from the * time series. For example, if a series contains daily data, you might set * the history count to 30. Then, when you add a new data item, all data * items more than 30 days older than the latest value are automatically * dropped from the series. * * @param periods the number of time periods. * * @see #getMaximumItemAge() */ public void setMaximumItemAge(long periods) { if (periods < 0) { throw new IllegalArgumentException("Negative 'periods' argument."); } this.maximumItemAge = periods; removeAgedItems(true); // remove old items and notify if necessary } /** * Returns the time period class for this series. *

* Only one time period class can be used within a single series (enforced). * If you add a data item with a {@link Year} for the time period, then all * subsequent data items must also have a {@link Year} for the time period. * * @return The time period class (may be null but only for * an empty series). */ public Class getTimePeriodClass() { return this.timePeriodClass; } /** * Returns a data item for the series. * * @param index the item index (zero-based). * * @return The data item. * * @see #getDataItem(RegularTimePeriod) */ public TimeSeriesDataItem getDataItem(int index) { return (TimeSeriesDataItem) this.data.get(index); } /** * Returns the data item for a specific period. * * @param period the period of interest (null not allowed). * * @return The data item matching the specified period (or * null if there is no match). * * @see #getDataItem(int) */ public TimeSeriesDataItem getDataItem(RegularTimePeriod period) { int index = getIndex(period); if (index >= 0) { return (TimeSeriesDataItem) this.data.get(index); } else { return null; } } /** * Returns the time period at the specified index. * * @param index the index of the data item. * * @return The time period. */ public RegularTimePeriod getTimePeriod(int index) { return getDataItem(index).getPeriod(); } /** * Returns a time period that would be the next in sequence on the end of * the time series. * * @return The next time period. */ public RegularTimePeriod getNextTimePeriod() { RegularTimePeriod last = getTimePeriod(getItemCount() - 1); return last.next(); } /** * Returns a collection of all the time periods in the time series. * * @return A collection of all the time periods. */ public Collection getTimePeriods() { Collection result = new java.util.ArrayList(); for (int i = 0; i < getItemCount(); i++) { result.add(getTimePeriod(i)); } return result; } /** * Returns a collection of time periods in the specified series, but not in * this series, and therefore unique to the specified series. * * @param series the series to check against this one. * * @return The unique time periods. */ public Collection getTimePeriodsUniqueToOtherSeries(TimeSeries series) { Collection result = new java.util.ArrayList(); for (int i = 0; i < series.getItemCount(); i++) { RegularTimePeriod period = series.getTimePeriod(i); int index = getIndex(period); if (index < 0) { result.add(period); } } return result; } /** * Returns the index for the item (if any) that corresponds to a time * period. * * @param period the time period (null not permitted). * * @return The index. */ public int getIndex(RegularTimePeriod period) { if (period == null) { throw new IllegalArgumentException("Null 'period' argument."); } TimeSeriesDataItem dummy = new TimeSeriesDataItem( period, Integer.MIN_VALUE); return Collections.binarySearch(this.data, dummy); } /** * Returns the value at the specified index. * * @param index index of a value. * * @return The value (possibly null). */ public Number getValue(int index) { return getDataItem(index).getValue(); } /** * Returns the value for a time period. If there is no data item with the * specified period, this method will return null. * * @param period time period (null not permitted). * * @return The value (possibly null). */ public Number getValue(RegularTimePeriod period) { int index = getIndex(period); if (index >= 0) { return getValue(index); } else { return null; } } /** * Adds a data item to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. * * @param item the (timeperiod, value) pair (null not * permitted). */ public void add(TimeSeriesDataItem item) { add(item, true); } /** * Adds a data item to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. * * @param item the (timeperiod, value) pair (null not * permitted). * @param notify notify listeners? */ public void add(TimeSeriesDataItem item, boolean notify) { if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } Class c = item.getPeriod().getClass(); if (this.timePeriodClass == null) { this.timePeriodClass = c; } else if (!this.timePeriodClass.equals(c)) { StringBuffer b = new StringBuffer(); b.append("You are trying to add data where the time period class "); b.append("is "); b.append(item.getPeriod().getClass().getName()); b.append(", but the TimeSeries is expecting an instance of "); b.append(this.timePeriodClass.getName()); b.append("."); throw new SeriesException(b.toString()); } // make the change (if it's not a duplicate time period)... boolean added = false; int count = getItemCount(); if (count == 0) { this.data.add(item); added = true; } else { RegularTimePeriod last = getTimePeriod(getItemCount() - 1); if (item.getPeriod().compareTo(last) > 0) { this.data.add(item); added = true; } else { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); added = true; } else { StringBuffer b = new StringBuffer(); b.append("You are attempting to add an observation for "); b.append("the time period "); b.append(item.getPeriod().toString()); b.append(" but the series already contains an observation"); b.append(" for that time period. Duplicates are not "); b.append("permitted. Try using the addOrUpdate() method."); throw new SeriesException(b.toString()); } } } if (added) { // check if this addition will exceed the maximum item count... if (getItemCount() > this.maximumItemCount) { this.data.remove(0); } removeAgedItems(false); // remove old items if necessary, but // don't notify anyone, because that // happens next anyway... if (notify) { fireSeriesChanged(); } } } /** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (null not permitted). * @param value the value. */ public void add(RegularTimePeriod period, double value) { // defer argument checking... add(period, value, true); } /** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (null not permitted). * @param value the value. * @param notify notify listeners? */ public void add(RegularTimePeriod period, double value, boolean notify) { // defer argument checking... TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); add(item, notify); } /** * Adds a new data item to the series and sends * a {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners. * * @param period the time period (null not permitted). * @param value the value (null permitted). */ public void add(RegularTimePeriod period, Number value) { // defer argument checking... add(period, value, true); } /** * Adds a new data item to the series and sends a {@link SeriesChangeEvent} * to all registered listeners. * * @param period the time period (null not permitted). * @param value the value (null permitted). * @param notify notify listeners? */ public void add(RegularTimePeriod period, Number value, boolean notify) { // defer argument checking... TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); add(item, notify); } /** * Updates (changes) the value for a time period. Throws a * {@link SeriesException} if the period does not exist. * * @param period the period (null not permitted). * @param value the value (null permitted). */ public void update(RegularTimePeriod period, Number value) { TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value); int index = Collections.binarySearch(this.data, temp); if (index >= 0) { TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index); pair.setValue(value); fireSeriesChanged(); } else { throw new SeriesException("There is no existing value for the " + "specified 'period'."); } } /** * Updates (changes) the value of a data item. * * @param index the index of the data item. * @param value the new value (null permitted). */ public void update(int index, Number value) { TimeSeriesDataItem item = getDataItem(index); item.setValue(value); fireSeriesChanged(); } /** * Adds or updates data from one series to another. Returns another series * containing the values that were overwritten. * * @param series the series to merge with this. * * @return A series containing the values that were overwritten. */ public TimeSeries addAndOrUpdate(TimeSeries series) { TimeSeries overwritten = new TimeSeries("Overwritten values from: " + getKey()); for (int i = 0; i < series.getItemCount(); i++) { TimeSeriesDataItem item = series.getDataItem(i); TimeSeriesDataItem oldItem = addOrUpdate(item.getPeriod(), item.getValue()); if (oldItem != null) { overwritten.add(oldItem); } } return overwritten; } /** * Adds or updates an item in the times series and sends a * {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners. * * @param period the time period to add/update (null not * permitted). * @param value the new value. * * @return A copy of the overwritten data item, or null if no * item was overwritten. */ public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, double value) { return addOrUpdate(period, new Double(value)); } /** * Adds or updates an item in the times series and sends a * {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners. * * @param period the time period to add/update (null not * permitted). * @param value the new value (null permitted). * * @return A copy of the overwritten data item, or null if no * item was overwritten. */ public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, Number value) { if (period == null) { throw new IllegalArgumentException("Null 'period' argument."); } TimeSeriesDataItem overwritten = null; TimeSeriesDataItem key = new TimeSeriesDataItem(period, value); int index = Collections.binarySearch(this.data, key); if (index >= 0) { TimeSeriesDataItem existing = (TimeSeriesDataItem) this.data.get(index); overwritten = (TimeSeriesDataItem) existing.clone(); existing.setValue(value); removeAgedItems(false); // remove old items if necessary, but // don't notify anyone, because that // happens next anyway... fireSeriesChanged(); } else { this.data.add(-index - 1, new TimeSeriesDataItem(period, value)); this.timePeriodClass = period.getClass(); // check if this addition will exceed the maximum item count... if (getItemCount() > this.maximumItemCount) { this.data.remove(0); if (this.data.isEmpty()) { this.timePeriodClass = null; } } removeAgedItems(false); // remove old items if necessary, but // don't notify anyone, because that // happens next anyway... fireSeriesChanged(); } return overwritten; } /** * Age items in the series. Ensure that the timespan from the youngest to * the oldest record in the series does not exceed maximumItemAge time * periods. Oldest items will be removed if required. * * @param notify controls whether or not a {@link SeriesChangeEvent} is * sent to registered listeners IF any items are removed. */ public void removeAgedItems(boolean notify) { // check if there are any values earlier than specified by the history // count... if (getItemCount() > 1) { long latest = getTimePeriod(getItemCount() - 1).getSerialIndex(); boolean removed = false; while ((latest - getTimePeriod(0).getSerialIndex()) > this.maximumItemAge) { this.data.remove(0); removed = true; } if (removed && notify) { fireSeriesChanged(); } } } /** * Age items in the series. Ensure that the timespan from the supplied * time to the oldest record in the series does not exceed history count. * oldest items will be removed if required. * * @param latest the time to be compared against when aging data * (specified in milliseconds). * @param notify controls whether or not a {@link SeriesChangeEvent} is * sent to registered listeners IF any items are removed. */ public void removeAgedItems(long latest, boolean notify) { if (this.data.isEmpty()) { return; // nothing to do } // find the serial index of the period specified by 'latest' long index = Long.MAX_VALUE; try { Method m = RegularTimePeriod.class.getDeclaredMethod( "createInstance", new Class[] {Class.class, Date.class, TimeZone.class}); RegularTimePeriod newest = (RegularTimePeriod) m.invoke( this.timePeriodClass, new Object[] {this.timePeriodClass, new Date(latest), TimeZone.getDefault()}); index = newest.getSerialIndex(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } // check if there are any values earlier than specified by the history // count... boolean removed = false; while (getItemCount() > 0 && (index - getTimePeriod(0).getSerialIndex()) > this.maximumItemAge) { this.data.remove(0); removed = true; } if (removed && notify) { fireSeriesChanged(); } } /** * Removes all data items from the series and sends a * {@link SeriesChangeEvent} to all registered listeners. */ public void clear() { if (this.data.size() > 0) { this.data.clear(); this.timePeriodClass = null; fireSeriesChanged(); } } /** * Deletes the data item for the given time period and sends a * {@link SeriesChangeEvent} to all registered listeners. If there is no * item with the specified time period, this method does nothing. * * @param period the period of the item to delete (null not * permitted). */ public void delete(RegularTimePeriod period) { int index = getIndex(period); if (index >= 0) { this.data.remove(index); if (this.data.isEmpty()) { this.timePeriodClass = null; } fireSeriesChanged(); } } /** * Deletes data from start until end index (end inclusive). * * @param start the index of the first period to delete. * @param end the index of the last period to delete. */ public void delete(int start, int end) { if (end < start) { throw new IllegalArgumentException("Requires start <= end."); } for (int i = 0; i <= (end - start); i++) { this.data.remove(start); } if (this.data.isEmpty()) { this.timePeriodClass = null; } fireSeriesChanged(); } /** * Returns a clone of the time series. *

* Notes: *

    *
  • no need to clone the domain and range descriptions, since String * object is immutable;
  • *
  • we pass over to the more general method clone(start, end).
  • *
* * @return A clone of the time series. * * @throws CloneNotSupportedException not thrown by this class, but * subclasses may differ. */ public Object clone() throws CloneNotSupportedException { TimeSeries clone = (TimeSeries) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; } /** * Creates a new timeseries by copying a subset of the data in this time * series. * * @param start the index of the first time period to copy. * @param end the index of the last time period to copy. * * @return A series containing a copy of this times series from start until * end. * * @throws CloneNotSupportedException if there is a cloning problem. */ public TimeSeries createCopy(int start, int end) throws CloneNotSupportedException { if (start < 0) { throw new IllegalArgumentException("Requires start >= 0."); } if (end < start) { throw new IllegalArgumentException("Requires start <= end."); } TimeSeries copy = (TimeSeries) super.clone(); copy.data = new java.util.ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { TimeSeriesDataItem item = (TimeSeriesDataItem) this.data.get(index); TimeSeriesDataItem clone = (TimeSeriesDataItem) item.clone(); try { copy.add(clone); } catch (SeriesException e) { e.printStackTrace(); } } } return copy; } /** * Creates a new timeseries by copying a subset of the data in this time * series. * * @param start the first time period to copy (null not * permitted). * @param end the last time period to copy (null not * permitted). * * @return A time series containing a copy of this time series from start * until end. * * @throws CloneNotSupportedException if there is a cloning problem. */ public TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end) throws CloneNotSupportedException { if (start == null) { throw new IllegalArgumentException("Null 'start' argument."); } if (end == null) { throw new IllegalArgumentException("Null 'end' argument."); } if (start.compareTo(end) > 0) { throw new IllegalArgumentException( "Requires start on or before end."); } boolean emptyRange = false; int startIndex = getIndex(start); if (startIndex < 0) { startIndex = -(startIndex + 1); if (startIndex == this.data.size()) { emptyRange = true; // start is after last data item } } int endIndex = getIndex(end); if (endIndex < 0) { // end period is not in original series endIndex = -(endIndex + 1); // this is first item AFTER end period endIndex = endIndex - 1; // so this is last item BEFORE end } if ((endIndex < 0) || (endIndex < startIndex)) { emptyRange = true; } if (emptyRange) { TimeSeries copy = (TimeSeries) super.clone(); copy.data = new java.util.ArrayList(); return copy; } else { return createCopy(startIndex, endIndex); } } /** * Tests the series for equality with an arbitrary object. * * @param object the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object object) { if (object == this) { return true; } if (!(object instanceof TimeSeries)) { return false; } TimeSeries that = (TimeSeries) object; if (!ObjectUtilities.equal(getDomainDescription(), that.getDomainDescription())) { return false; } if (!ObjectUtilities.equal(getRangeDescription(), that.getRangeDescription())) { return false; } if (!ObjectUtilities.equal(this.timePeriodClass, that.timePeriodClass)) { return false; } if (getMaximumItemAge() != that.getMaximumItemAge()) { return false; } if (getMaximumItemCount() != that.getMaximumItemCount()) { return false; } int count = getItemCount(); if (count != that.getItemCount()) { return false; } for (int i = 0; i < count; i++) { if (!getDataItem(i).equals(that.getDataItem(i))) { return false; } } return super.equals(object); } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { int result = super.hashCode(); result = 29 * result + (this.domain != null ? this.domain.hashCode() : 0); result = 29 * result + (this.range != null ? this.range.hashCode() : 0); result = 29 * result + (this.timePeriodClass != null ? this.timePeriodClass.hashCode() : 0); // it is too slow to look at every data item, so let's just look at // the first, middle and last items... int count = getItemCount(); if (count > 0) { TimeSeriesDataItem item = getDataItem(0); result = 29 * result + item.hashCode(); } if (count > 1) { TimeSeriesDataItem item = getDataItem(count - 1); result = 29 * result + item.hashCode(); } if (count > 2) { TimeSeriesDataItem item = getDataItem(count / 2); result = 29 * result + item.hashCode(); } result = 29 * result + this.maximumItemCount; result = 29 * result + (int) this.maximumItemAge; return result; } /** * Creates a new (empty) time series with the specified name and class * of {@link RegularTimePeriod}. * * @param name the series name (null not permitted). * @param timePeriodClass the type of time period (null not * permitted). * * @deprecated As of 1.0.13, it is not necessary to specify the * timePeriodClass as this will be inferred when the * first data item is added to the dataset. */ public TimeSeries(Comparable name, Class timePeriodClass) { this(name, DEFAULT_DOMAIN_DESCRIPTION, DEFAULT_RANGE_DESCRIPTION, timePeriodClass); } /** * Creates a new time series that contains no data. *

* Descriptions can be specified for the domain and range. One situation * where this is helpful is when generating a chart for the time series - * axis labels can be taken from the domain and range description. * * @param name the name of the series (null not permitted). * @param domain the domain description (null permitted). * @param range the range description (null permitted). * @param timePeriodClass the type of time period (null not * permitted). * * @deprecated As of 1.0.13, it is not necessary to specify the * timePeriodClass as this will be inferred when the * first data item is added to the dataset. */ public TimeSeries(Comparable name, String domain, String range, Class timePeriodClass) { super(name); this.domain = domain; this.range = range; this.timePeriodClass = timePeriodClass; this.data = new java.util.ArrayList(); this.maximumItemCount = Integer.MAX_VALUE; this.maximumItemAge = Long.MAX_VALUE; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimeSeriesCollection.java0000644000175000017500000005532111173030414030135 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TimeSeriesCollection.java * ------------------------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 18-Oct-2001 : Added implementation of IntervalXYDataSource so that bar plots * (using numerical axes) can be plotted from time series * data (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 15-Nov-2001 : Added getSeries() method. Changed name from TimeSeriesDataset * to TimeSeriesCollection (DG); * 07-Dec-2001 : TimeSeries --> BasicTimeSeries (DG); * 01-Mar-2002 : Added a time zone offset attribute, to enable fast calculation * of the time period start and end values (DG); * 29-Mar-2002 : The collection now registers itself with all the time series * objects as a SeriesChangeListener. Removed redundant * calculateZoneOffset method (DG); * 06-Jun-2002 : Added a setting to control whether the x-value supplied in the * getXValue() method comes from the START, MIDDLE, or END of the * time period. This is a workaround for JFreeChart, where the * current date axis always labels the start of a time * period (DG); * 24-Jun-2002 : Removed unnecessary import (DG); * 24-Aug-2002 : Implemented DomainInfo interface, and added the * DomainIsPointsInTime flag (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 16-Oct-2002 : Added remove methods (DG); * 10-Jan-2003 : Changed method names in RegularTimePeriod class (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented * Serializable (DG); * 04-Sep-2003 : Added getSeries(String) method (DG); * 15-Sep-2003 : Added a removeAllSeries() method to match * XYSeriesCollection (DG); * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 06-Oct-2004 : Updated for changed in DomainInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 28-Mar-2005 : Fixed bug in getSeries(int) method (1170825) (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 13-Dec-2005 : Deprecated the 'domainIsPointsInTime' flag as it is * redundant. Fixes bug 1243050 (DG); * 04-May-2007 : Override getDomainOrder() to indicate that items are sorted * by x-value (ascending) (DG); * 08-May-2007 : Added indexOf(TimeSeries) method (DG); * 18-Jan-2008 : Changed getSeries(String) to getSeries(Comparable) (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.TimeZone; import org.jfree.data.DomainInfo; import org.jfree.data.DomainOrder; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.ObjectUtilities; /** * A collection of time series objects. This class implements the * {@link org.jfree.data.xy.XYDataset} interface, as well as the extended * {@link IntervalXYDataset} interface. This makes it a convenient dataset for * use with the {@link org.jfree.chart.plot.XYPlot} class. */ public class TimeSeriesCollection extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, Serializable { /** For serialization. */ private static final long serialVersionUID = 834149929022371137L; /** Storage for the time series. */ private List data; /** A working calendar (to recycle) */ private Calendar workingCalendar; /** * The point within each time period that is used for the X value when this * collection is used as an {@link org.jfree.data.xy.XYDataset}. This can * be the start, middle or end of the time period. */ private TimePeriodAnchor xPosition; /** * A flag that indicates that the domain is 'points in time'. If this * flag is true, only the x-value is used to determine the range of values * in the domain, the start and end x-values are ignored. * * @deprecated No longer used (as of 1.0.1). */ private boolean domainIsPointsInTime; /** * Constructs an empty dataset, tied to the default timezone. */ public TimeSeriesCollection() { this(null, TimeZone.getDefault()); } /** * Constructs an empty dataset, tied to a specific timezone. * * @param zone the timezone (null permitted, will use * TimeZone.getDefault() in that case). */ public TimeSeriesCollection(TimeZone zone) { // FIXME: need a locale as well as a timezone this(null, zone); } /** * Constructs a dataset containing a single series (more can be added), * tied to the default timezone. * * @param series the series (null permitted). */ public TimeSeriesCollection(TimeSeries series) { this(series, TimeZone.getDefault()); } /** * Constructs a dataset containing a single series (more can be added), * tied to a specific timezone. * * @param series a series to add to the collection (null * permitted). * @param zone the timezone (null permitted, will use * TimeZone.getDefault() in that case). */ public TimeSeriesCollection(TimeSeries series, TimeZone zone) { // FIXME: need a locale as well as a timezone if (zone == null) { zone = TimeZone.getDefault(); } this.workingCalendar = Calendar.getInstance(zone); this.data = new ArrayList(); if (series != null) { this.data.add(series); series.addChangeListener(this); } this.xPosition = TimePeriodAnchor.START; this.domainIsPointsInTime = true; } /** * Returns a flag that controls whether the domain is treated as 'points in * time'. This flag is used when determining the max and min values for * the domain. If true, then only the x-values are considered * for the max and min values. If false, then the start and * end x-values will also be taken into consideration. * * @return The flag. * * @deprecated This flag is no longer used (as of 1.0.1). */ public boolean getDomainIsPointsInTime() { return this.domainIsPointsInTime; } /** * Sets a flag that controls whether the domain is treated as 'points in * time', or time periods. * * @param flag the flag. * * @deprecated This flag is no longer used, as of 1.0.1. The * includeInterval flag in methods such as * {@link #getDomainBounds(boolean)} makes this unnecessary. */ public void setDomainIsPointsInTime(boolean flag) { this.domainIsPointsInTime = flag; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Returns the order of the domain values in this dataset. * * @return {@link DomainOrder#ASCENDING} */ public DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; } /** * Returns the position within each time period that is used for the X * value when the collection is used as an * {@link org.jfree.data.xy.XYDataset}. * * @return The anchor position (never null). */ public TimePeriodAnchor getXPosition() { return this.xPosition; } /** * Sets the position within each time period that is used for the X values * when the collection is used as an {@link XYDataset}, then sends a * {@link DatasetChangeEvent} is sent to all registered listeners. * * @param anchor the anchor position (null not permitted). */ public void setXPosition(TimePeriodAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.xPosition = anchor; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Returns a list of all the series in the collection. * * @return The list (which is unmodifiable). */ public List getSeries() { return Collections.unmodifiableList(this.data); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns the index of the specified series, or -1 if that series is not * present in the dataset. * * @param series the series (null not permitted). * * @return The series index. * * @since 1.0.6 */ public int indexOf(TimeSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } return this.data.indexOf(series); } /** * Returns a series. * * @param series the index of the series (zero-based). * * @return The series. */ public TimeSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException( "The 'series' argument is out of bounds (" + series + ")."); } return (TimeSeries) this.data.get(series); } /** * Returns the series with the specified key, or null if * there is no such series. * * @param key the series key (null permitted). * * @return The series with the given key. */ public TimeSeries getSeries(Comparable key) { TimeSeries result = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimeSeries series = (TimeSeries) iterator.next(); Comparable k = series.getKey(); if (k != null && k.equals(key)) { result = series; } } return result; } /** * Returns the key for a series. * * @param series the index of the series (zero-based). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { // check arguments...delegated // fetch the series name... return getSeries(series).getKey(); } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(TimeSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Removes the specified series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). */ public void removeSeries(TimeSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.remove(series); series.removeChangeListener(this); fireDatasetChanged(); } /** * Removes a series from the collection. * * @param index the series index (zero-based). */ public void removeSeries(int index) { TimeSeries series = getSeries(index); if (series != null) { removeSeries(series); } } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. */ public void removeAllSeries() { // deregister the collection as a change listener to each series in the // collection for (int i = 0; i < this.data.size(); i++) { TimeSeries series = (TimeSeries) this.data.get(i); series.removeChangeListener(this); } // remove all the series from the collection and notify listeners. this.data.clear(); fireDatasetChanged(); } /** * Returns the number of items in the specified series. This method is * provided for convenience. * * @param series the series index (zero-based). * * @return The item count. */ public int getItemCount(int series) { return getSeries(series).getItemCount(); } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ public double getXValue(int series, int item) { TimeSeries s = (TimeSeries) this.data.get(series); TimeSeriesDataItem i = s.getDataItem(item); RegularTimePeriod period = i.getPeriod(); return getX(period); } /** * Returns the x-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); TimeSeriesDataItem dp = ts.getDataItem(item); RegularTimePeriod period = dp.getPeriod(); return new Long(getX(period)); } /** * Returns the x-value for a time period. * * @param period the time period (null not permitted). * * @return The x-value. */ protected synchronized long getX(RegularTimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getFirstMillisecond(this.workingCalendar); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { result = period.getMiddleMillisecond(this.workingCalendar); } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getLastMillisecond(this.workingCalendar); } return result; } /** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public synchronized Number getStartX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); TimeSeriesDataItem dp = ts.getDataItem(item); return new Long(dp.getPeriod().getFirstMillisecond( this.workingCalendar)); } /** * Returns the ending X value for the specified series and item. * * @param series The series (zero-based index). * @param item The item (zero-based index). * * @return The value. */ public synchronized Number getEndX(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); TimeSeriesDataItem dp = ts.getDataItem(item); return new Long(dp.getPeriod().getLastMillisecond( this.workingCalendar)); } /** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value (possibly null). */ public Number getY(int series, int item) { TimeSeries ts = (TimeSeries) this.data.get(series); TimeSeriesDataItem dp = ts.getDataItem(item); return dp.getValue(); } /** * Returns the starting Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value (possibly null). */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series te series (zero-based index). * @param item the item (zero-based index). * * @return The value (possibly null). */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Returns the indices of the two data items surrounding a particular * millisecond value. * * @param series the series index. * @param milliseconds the time. * * @return An array containing the (two) indices of the items surrounding * the time. */ public int[] getSurroundingItems(int series, long milliseconds) { int[] result = new int[] {-1, -1}; TimeSeries timeSeries = getSeries(series); for (int i = 0; i < timeSeries.getItemCount(); i++) { Number x = getX(series, i); long m = x.longValue(); if (m <= milliseconds) { result[0] = i; } if (m >= milliseconds) { result[1] = i; break; } } return result; } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getLowerBound(); } return result; } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { Range result = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimeSeries series = (TimeSeries) iterator.next(); int count = series.getItemCount(); if (count > 0) { RegularTimePeriod start = series.getTimePeriod(0); RegularTimePeriod end = series.getTimePeriod(count - 1); Range temp; if (!includeInterval) { temp = new Range(getX(start), getX(end)); } else { temp = new Range( start.getFirstMillisecond(this.workingCalendar), end.getLastMillisecond(this.workingCalendar)); } result = Range.combine(result, temp); } } return result; } /** * Tests this time series collection for equality with another object. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimeSeriesCollection)) { return false; } TimeSeriesCollection that = (TimeSeriesCollection) obj; if (this.xPosition != that.xPosition) { return false; } if (this.domainIsPointsInTime != that.domainIsPointsInTime) { return false; } if (!ObjectUtilities.equal(this.data, that.data)) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { int result; result = this.data.hashCode(); result = 29 * result + (this.workingCalendar != null ? this.workingCalendar.hashCode() : 0); result = 29 * result + (this.xPosition != null ? this.xPosition.hashCode() : 0); result = 29 * result + (this.domainIsPointsInTime ? 1 : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimeSeriesDataItem.java0000644000175000017500000001630311173030414027527 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * TimeSeriesDataItem.java * ----------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 15-Nov-2001 : Updated Javadoc comments (DG); * 29-Nov-2001 : Added cloning (DG); * 24-Jun-2002 : Removed unnecessary import (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Renamed TimeSeriesDataPair --> TimeSeriesDataItem, moved to * com.jrefinery.data.time package, implemented Serializable (DG) */ package org.jfree.data.time; import java.io.Serializable; /** * Represents one data item in a time series. *

* The time period can be any of the following: *

    *
  • {@link Year}
  • *
  • {@link Quarter}
  • *
  • {@link Month}
  • *
  • {@link Week}
  • *
  • {@link Day}
  • *
  • {@link Hour}
  • *
  • {@link Minute}
  • *
  • {@link Second}
  • *
  • {@link Millisecond}
  • *
  • {@link FixedMillisecond}
  • *
* * The time period is an immutable property of the data item. Data items will * often be sorted within a list, and allowing the time period to be changed * could destroy the sort order. *

* Implements the Comparable interface so that standard Java * sorting can be used to keep the data items in order. * */ public class TimeSeriesDataItem implements Cloneable, Comparable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2235346966016401302L; /** The time period. */ private RegularTimePeriod period; /** The value associated with the time period. */ private Number value; /** * Constructs a new data item that associates a value with a time period. * * @param period the time period (null not permitted). * @param value the value (null permitted). */ public TimeSeriesDataItem(RegularTimePeriod period, Number value) { if (period == null) { throw new IllegalArgumentException("Null 'period' argument."); } this.period = period; this.value = value; } /** * Constructs a new data item that associates a value with a time period. * * @param period the time period (null not permitted). * @param value the value associated with the time period. */ public TimeSeriesDataItem(RegularTimePeriod period, double value) { this(period, new Double(value)); } /** * Returns the time period. * * @return The time period (never null). */ public RegularTimePeriod getPeriod() { return this.period; } /** * Returns the value. * * @return The value (null possible). */ public Number getValue() { return this.value; } /** * Sets the value for this data item. * * @param value the value (null permitted). */ public void setValue(Number value) { this.value = value; } /** * Tests this object for equality with an arbitrary object. * * @param o the other object. * * @return A boolean. */ public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof TimeSeriesDataItem)) { return false; } TimeSeriesDataItem timeSeriesDataItem = (TimeSeriesDataItem) o; if (this.period != null) { if (!this.period.equals(timeSeriesDataItem.period)) { return false; } } else if (timeSeriesDataItem.period != null) { return false; } if (this.value != null) { if (!this.value.equals(timeSeriesDataItem.value)) { return false; } } else if (timeSeriesDataItem.value != null) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = (this.period != null ? this.period.hashCode() : 0); result = 29 * result + (this.value != null ? this.value.hashCode() : 0); return result; } /** * Returns an integer indicating the order of this data pair object * relative to another object. *

* For the order we consider only the timing: * negative == before, zero == same, positive == after. * * @param o1 The object being compared to. * * @return An integer indicating the order of the data item object * relative to another object. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another TimeSeriesDataItem object // ------------------------------------------------------- if (o1 instanceof TimeSeriesDataItem) { TimeSeriesDataItem datapair = (TimeSeriesDataItem) o1; result = getPeriod().compareTo(datapair.getPeriod()); } // CASE 2 : Comparing to a general object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Clones the data item. Note: there is no need to clone the period or * value since they are immutable classes. * * @return A clone of the data item. */ public Object clone() { Object clone = null; try { clone = super.clone(); } catch (CloneNotSupportedException e) { // won't get here... e.printStackTrace(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimeSeriesTableModel.java0000644000175000017500000001643511173030414030055 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TimeSeriesTableModel.java * ------------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Nov-2001 : Version 1 (DG); * 05-Apr-2002 : Removed redundant first column (DG); * 24-Jun-2002 : Removed unnecessary local variable (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.data.time; import javax.swing.table.AbstractTableModel; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; /** * Wrapper around a time series to convert it to a table model for use in * a JTable. */ public class TimeSeriesTableModel extends AbstractTableModel implements SeriesChangeListener { /** The series. */ private TimeSeries series; /** A flag that controls whether the series is editable. */ private boolean editable; /** The new time period. */ private RegularTimePeriod newTimePeriod; /** The new value. */ private Number newValue; /** * Default constructor. */ public TimeSeriesTableModel() { this(new TimeSeries("Untitled")); } /** * Constructs a table model for a time series. * * @param series the time series. */ public TimeSeriesTableModel(TimeSeries series) { this(series, false); } /** * Creates a table model based on a time series. * * @param series the time series. * @param editable if true, the table is editable. */ public TimeSeriesTableModel(TimeSeries series, boolean editable) { this.series = series; this.series.addChangeListener(this); this.editable = editable; } /** * Returns the number of columns in the table model. For this particular * model, the column count is fixed at 2. * * @return The column count. */ public int getColumnCount() { return 2; } /** * Returns the column class in the table model. * * @param column The column index. * * @return The column class in the table model. */ public Class getColumnClass(int column) { if (column == 0) { return String.class; } else { if (column == 1) { return Double.class; } else { return null; } } } /** * Returns the name of a column * * @param column the column index. * * @return The name of a column. */ public String getColumnName(int column) { if (column == 0) { return "Period:"; } else { if (column == 1) { return "Value:"; } else { return null; } } } /** * Returns the number of rows in the table model. * * @return The row count. */ public int getRowCount() { return this.series.getItemCount(); } /** * Returns the data value for a cell in the table model. * * @param row the row number. * @param column the column number. * * @return The data value for a cell in the table model. */ public Object getValueAt(int row, int column) { if (row < this.series.getItemCount()) { if (column == 0) { return this.series.getTimePeriod(row); } else { if (column == 1) { return this.series.getValue(row); } else { return null; } } } else { if (column == 0) { return this.newTimePeriod; } else { if (column == 1) { return this.newValue; } else { return null; } } } } /** * Returns a flag indicating whether or not the specified cell is editable. * * @param row the row number. * @param column the column number. * * @return true if the specified cell is editable. */ public boolean isCellEditable(int row, int column) { if (this.editable) { if ((column == 0) || (column == 1)) { return true; } else { return false; } } else { return false; } } /** * Updates the time series. * * @param value the new value. * @param row the row. * @param column the column. */ public void setValueAt(Object value, int row, int column) { if (row < this.series.getItemCount()) { // update the time series appropriately if (column == 1) { try { Double v = Double.valueOf(value.toString()); this.series.update(row, v); } catch (NumberFormatException nfe) { System.err.println("Number format exception"); } } } else { if (column == 0) { // this.series.getClass().valueOf(value.toString()); this.newTimePeriod = null; } else if (column == 1) { this.newValue = Double.valueOf(value.toString()); } } } /** * Receives notification that the time series has been changed. Responds * by firing a table data change event. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { fireTableDataChanged(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/TimeTableXYDataset.java0000644000175000017500000004700511173030414027505 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * TimeTableXYDataset.java * ----------------------- * (C) Copyright 2004-2008, by Andreas Schroeder and Contributors. * * Original Author: Andreas Schroeder; * Contributor(s): David Gilbert (for Object Refinery Limited); * Rob Eden; * * Changes * ------- * 01-Apr-2004 : Version 1 (AS); * 05-May-2004 : Now implements AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 15-Sep-2004 : Added getXPosition(), setXPosition(), equals() and * clone() (DG); * 17-Nov-2004 : Updated methods for changes in DomainInfo interface (DG); * 25-Nov-2004 : Added getTimePeriod(int) method (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 27-Jan-2005 : Modified to use TimePeriod rather than RegularTimePeriod (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 25-Jul-2007 : Added clear() method by Rob Eden, see patch 1752205 (DG); * 04-Jun-2008 : Updated Javadocs (DG); * */ package org.jfree.data.time; import java.util.Calendar; import java.util.List; import java.util.Locale; import java.util.TimeZone; import org.jfree.data.DefaultKeyedValues2D; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.util.PublicCloneable; /** * A dataset for regular time periods that implements the * {@link TableXYDataset} interface. Note that the {@link TableXYDataset} * interface requires all series to share the same set of x-values. When * adding a new item (x, y) to one series, all other series * automatically get a new item (x, null) unless a non-null item * has already been specified. * * @see org.jfree.data.xy.TableXYDataset */ public class TimeTableXYDataset extends AbstractIntervalXYDataset implements Cloneable, PublicCloneable, IntervalXYDataset, DomainInfo, TableXYDataset { /** * The data structure to store the values. Each column represents * a series (elsewhere in JFreeChart rows are typically used for series, * but it doesn't matter that much since this data structure is private * and symmetrical anyway), each row contains values for the same * {@link RegularTimePeriod} (the rows are sorted into ascending order). */ private DefaultKeyedValues2D values; /** * A flag that indicates that the domain is 'points in time'. If this flag * is true, only the x-value (and not the x-interval) is used to determine * the range of values in the domain. */ private boolean domainIsPointsInTime; /** * The point within each time period that is used for the X value when this * collection is used as an {@link org.jfree.data.xy.XYDataset}. This can * be the start, middle or end of the time period. */ private TimePeriodAnchor xPosition; /** A working calendar (to recycle) */ private Calendar workingCalendar; /** * Creates a new dataset. */ public TimeTableXYDataset() { // defer argument checking this(TimeZone.getDefault(), Locale.getDefault()); } /** * Creates a new dataset with the given time zone. * * @param zone the time zone to use (null not permitted). */ public TimeTableXYDataset(TimeZone zone) { // defer argument checking this(zone, Locale.getDefault()); } /** * Creates a new dataset with the given time zone and locale. * * @param zone the time zone to use (null not permitted). * @param locale the locale to use (null not permitted). */ public TimeTableXYDataset(TimeZone zone, Locale locale) { if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } this.values = new DefaultKeyedValues2D(true); this.workingCalendar = Calendar.getInstance(zone, locale); this.xPosition = TimePeriodAnchor.START; } /** * Returns a flag that controls whether the domain is treated as 'points in * time'. *

* This flag is used when determining the max and min values for the domain. * If true, then only the x-values are considered for the max and min * values. If false, then the start and end x-values will also be taken * into consideration. * * @return The flag. * * @see #setDomainIsPointsInTime(boolean) */ public boolean getDomainIsPointsInTime() { return this.domainIsPointsInTime; } /** * Sets a flag that controls whether the domain is treated as 'points in * time', or time periods. A {@link DatasetChangeEvent} is sent to all * registered listeners. * * @param flag the new value of the flag. * * @see #getDomainIsPointsInTime() */ public void setDomainIsPointsInTime(boolean flag) { this.domainIsPointsInTime = flag; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Returns the position within each time period that is used for the X * value. * * @return The anchor position (never null). * * @see #setXPosition(TimePeriodAnchor) */ public TimePeriodAnchor getXPosition() { return this.xPosition; } /** * Sets the position within each time period that is used for the X values, * then sends a {@link DatasetChangeEvent} to all registered listeners. * * @param anchor the anchor position (null not permitted). * * @see #getXPosition() */ public void setXPosition(TimePeriodAnchor anchor) { if (anchor == null) { throw new IllegalArgumentException("Null 'anchor' argument."); } this.xPosition = anchor; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Adds a new data item to the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param period the time period. * @param y the value for this period. * @param seriesName the name of the series to add the value. * * @see #remove(TimePeriod, String) */ public void add(TimePeriod period, double y, String seriesName) { add(period, new Double(y), seriesName, true); } /** * Adds a new data item to the dataset and, if requested, sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param period the time period (null not permitted). * @param y the value for this period (null permitted). * @param seriesName the name of the series to add the value * (null not permitted). * @param notify whether dataset listener are notified or not. * * @see #remove(TimePeriod, String, boolean) */ public void add(TimePeriod period, Number y, String seriesName, boolean notify) { this.values.addValue(y, period, seriesName); if (notify) { fireDatasetChanged(); } } /** * Removes an existing data item from the dataset. * * @param period the (existing!) time period of the value to remove * (null not permitted). * @param seriesName the (existing!) series name to remove the value * (null not permitted). * * @see #add(TimePeriod, double, String) */ public void remove(TimePeriod period, String seriesName) { remove(period, seriesName, true); } /** * Removes an existing data item from the dataset and, if requested, * sends a {@link DatasetChangeEvent} to all registered listeners. * * @param period the (existing!) time period of the value to remove * (null not permitted). * @param seriesName the (existing!) series name to remove the value * (null not permitted). * @param notify whether dataset listener are notified or not. * * @see #add(TimePeriod, double, String) */ public void remove(TimePeriod period, String seriesName, boolean notify) { this.values.removeValue(period, seriesName); if (notify) { fireDatasetChanged(); } } /** * Removes all data items from the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.7 */ public void clear() { if (this.values.getRowCount() > 0) { this.values.clear(); fireDatasetChanged(); } } /** * Returns the time period for the specified item. Bear in mind that all * series share the same set of time periods. * * @param item the item index (0 <= i <= {@link #getItemCount()}). * * @return The time period. */ public TimePeriod getTimePeriod(int item) { return (TimePeriod) this.values.getRowKey(item); } /** * Returns the number of items in ALL series. * * @return The item count. */ public int getItemCount() { return this.values.getRowCount(); } /** * Returns the number of items in a series. This is the same value * that is returned by {@link #getItemCount()} since all series * share the same x-values (time periods). * * @param series the series (zero-based index, ignored). * * @return The number of items within the series. */ public int getItemCount(int series) { return getItemCount(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.values.getColumnCount(); } /** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The key for the series. */ public Comparable getSeriesKey(int series) { return this.values.getColumnKey(series); } /** * Returns the x-value for an item within a series. The x-values may or * may not be returned in ascending order, that is up to the class * implementing the interface. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getXValue(int series, int item) { TimePeriod period = (TimePeriod) this.values.getRowKey(item); return getXValue(period); } /** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting X value for the specified series and item. * * @see #getStartXValue(int, int) */ public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); } /** * Returns the start x-value (as a double primitive) for an item within * a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartXValue(int series, int item) { TimePeriod period = (TimePeriod) this.values.getRowKey(item); return period.getStart().getTime(); } /** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending X value for the specified series and item. * * @see #getEndXValue(int, int) */ public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); } /** * Returns the end x-value (as a double primitive) for an item within * a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getEndXValue(int series, int item) { TimePeriod period = (TimePeriod) this.values.getRowKey(item); return period.getEnd().getTime(); } /** * Returns the y-value for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value (possibly null). */ public Number getY(int series, int item) { return this.values.getValue(item, series); } /** * Returns the starting Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting Y value for the specified series and item. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending Y value for the specified series and item. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Returns the x-value for a time period. * * @param period the time period. * * @return The x-value. */ private long getXValue(TimePeriod period) { long result = 0L; if (this.xPosition == TimePeriodAnchor.START) { result = period.getStart().getTime(); } else if (this.xPosition == TimePeriodAnchor.MIDDLE) { long t0 = period.getStart().getTime(); long t1 = period.getEnd().getTime(); result = t0 + (t1 - t0) / 2L; } else if (this.xPosition == TimePeriodAnchor.END) { result = period.getEnd().getTime(); } return result; } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getLowerBound(); } return result; } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that controls whether or not the * x-intervals are taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { List keys = this.values.getRowKeys(); if (keys.isEmpty()) { return null; } TimePeriod first = (TimePeriod) keys.get(0); TimePeriod last = (TimePeriod) keys.get(keys.size() - 1); if (!includeInterval || this.domainIsPointsInTime) { return new Range(getXValue(first), getXValue(last)); } else { return new Range(first.getStart().getTime(), last.getEnd().getTime()); } } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TimeTableXYDataset)) { return false; } TimeTableXYDataset that = (TimeTableXYDataset) obj; if (this.domainIsPointsInTime != that.domainIsPointsInTime) { return false; } if (this.xPosition != that.xPosition) { return false; } if (!this.workingCalendar.getTimeZone().equals( that.workingCalendar.getTimeZone()) ) { return false; } if (!this.values.equals(that.values)) { return false; } return true; } /** * Returns a clone of this dataset. * * @return A clone. * * @throws CloneNotSupportedException if the dataset cannot be cloned. */ public Object clone() throws CloneNotSupportedException { TimeTableXYDataset clone = (TimeTableXYDataset) super.clone(); clone.values = (DefaultKeyedValues2D) this.values.clone(); clone.workingCalendar = (Calendar) this.workingCalendar.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Week.java0000644000175000017500000005325111173030414024743 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Week.java * --------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Aimin Han; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 18-Dec-2001 : Changed order of parameters in constructor (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 29-Jan-2002 : Worked on the parseWeek() method (DG); * 13-Feb-2002 : Fixed bug in Week(Date) constructor (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 05-Apr-2002 : Reinstated this class to the JCommon library (DG); * 24-Jun-2002 : Removed unnecessary main method (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 06-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 18-Oct-2002 : Changed to observe 52 or 53 weeks per year, consistent with * GregorianCalendar. Thanks to Aimin Han for the code (DG); * 02-Jan-2003 : Removed debug code (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * 24-May-2004 : Modified getFirstMillisecond() and getLastMillisecond() to * take account of firstDayOfWeek setting in Java's Calendar * class (DG); * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for * JDK 1.3 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Mar-2006 : Fix for bug 1448828, incorrect calculation of week and year * for the first few days of some years (DG); * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 09-Jan-2007 : Fixed bug in next() (DG); * 28-Aug-2007 : Added new constructor to avoid problem in creating new * instances (DG); * 19-Dec-2007 : Fixed bug in deprecated constructor (DG); * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * A calendar week. All years are considered to have 53 weeks, numbered from 1 * to 53, although in many cases the 53rd week is empty. Most of the time, the * 1st week of the year *begins* in the previous calendar year, but it always * finishes in the current year (this behaviour matches the workings of the * GregorianCalendar class). *

* This class is immutable, which is a requirement for all * {@link RegularTimePeriod} subclasses. */ public class Week extends RegularTimePeriod implements Serializable { /** For serialization. */ private static final long serialVersionUID = 1856387786939865061L; /** Constant for the first week in the year. */ public static final int FIRST_WEEK_IN_YEAR = 1; /** Constant for the last week in the year. */ public static final int LAST_WEEK_IN_YEAR = 53; /** The year in which the week falls. */ private short year; /** The week (1-53). */ private byte week; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Creates a new time period for the week in which the current system * date/time falls. */ public Week() { this(new Date()); } /** * Creates a time period representing the week in the specified year. * * @param week the week (1 to 53). * @param year the year (1900 to 9999). */ public Week(int week, int year) { if ((week < FIRST_WEEK_IN_YEAR) && (week > LAST_WEEK_IN_YEAR)) { throw new IllegalArgumentException( "The 'week' argument must be in the range 1 - 53."); } this.week = (byte) week; this.year = (short) year; peg(Calendar.getInstance()); } /** * Creates a time period representing the week in the specified year. * * @param week the week (1 to 53). * @param year the year (1900 to 9999). */ public Week(int week, Year year) { if ((week < FIRST_WEEK_IN_YEAR) && (week > LAST_WEEK_IN_YEAR)) { throw new IllegalArgumentException( "The 'week' argument must be in the range 1 - 53."); } this.week = (byte) week; this.year = (short) year.getYear(); peg(Calendar.getInstance()); } /** * Creates a time period for the week in which the specified date/time * falls, using the default time zone and locale (the locale can affect the * day-of-the-week that marks the beginning of the week, as well as the * minimal number of days in the first week of the year). * * @param time the time (null not permitted). * * @see #Week(Date, TimeZone, Locale) */ public Week(Date time) { // defer argument checking... this(time, TimeZone.getDefault(), Locale.getDefault()); } /** * Creates a time period for the week in which the specified date/time * falls, calculated relative to the specified time zone. * * @param time the date/time (null not permitted). * @param zone the time zone (null not permitted). * * @deprecated As of 1.0.7, use {@link #Week(Date, TimeZone, Locale)}. */ public Week(Date time, TimeZone zone) { // defer argument checking... this(time, zone, Locale.getDefault()); } /** * Creates a time period for the week in which the specified date/time * falls, calculated relative to the specified time zone. * * @param time the date/time (null not permitted). * @param zone the time zone (null not permitted). * @param locale the locale (null not permitted). * * @since 1.0.7 */ public Week(Date time, TimeZone zone, Locale locale) { if (time == null) { throw new IllegalArgumentException("Null 'time' argument."); } if (zone == null) { throw new IllegalArgumentException("Null 'zone' argument."); } if (locale == null) { throw new IllegalArgumentException("Null 'locale' argument."); } Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); // sometimes the last few days of the year are considered to fall in // the *first* week of the following year. Refer to the Javadocs for // GregorianCalendar. int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR); if (tempWeek == 1 && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) { this.week = 1; this.year = (short) (calendar.get(Calendar.YEAR) + 1); } else { this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR); int yyyy = calendar.get(Calendar.YEAR); // alternatively, sometimes the first few days of the year are // considered to fall in the *last* week of the previous year... if (calendar.get(Calendar.MONTH) == Calendar.JANUARY && this.week >= 52) { yyyy--; } this.year = (short) yyyy; } peg(calendar); } /** * Returns the year in which the week falls. * * @return The year (never null). */ public Year getYear() { return new Year(this.year); } /** * Returns the year in which the week falls, as an integer value. * * @return The year. */ public int getYearValue() { return this.year; } /** * Returns the week. * * @return The week. */ public int getWeek() { return this.week; } /** * Returns the first millisecond of the week. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the week. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the week. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the week. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the week preceding this one. This method will return * null for some lower limit on the range of weeks (currently * week 1, 1900). For week 1 of any year, the previous week is always week * 53, but week 53 may not contain any days (you should check for this). * * @return The preceding week (possibly null). */ public RegularTimePeriod previous() { Week result; if (this.week != FIRST_WEEK_IN_YEAR) { result = new Week(this.week - 1, this.year); } else { // we need to work out if the previous year has 52 or 53 weeks... if (this.year > 1900) { int yy = this.year - 1; Calendar prevYearCalendar = Calendar.getInstance(); prevYearCalendar.set(yy, Calendar.DECEMBER, 31); result = new Week(prevYearCalendar.getActualMaximum( Calendar.WEEK_OF_YEAR), yy); } else { result = null; } } return result; } /** * Returns the week following this one. This method will return * null for some upper limit on the range of weeks (currently * week 53, 9999). For week 52 of any year, the following week is always * week 53, but week 53 may not contain any days (you should check for * this). * * @return The following week (possibly null). */ public RegularTimePeriod next() { Week result; if (this.week < 52) { result = new Week(this.week + 1, this.year); } else { Calendar calendar = Calendar.getInstance(); calendar.set(this.year, Calendar.DECEMBER, 31); int actualMaxWeek = calendar.getActualMaximum(Calendar.WEEK_OF_YEAR); if (this.week < actualMaxWeek) { result = new Week(this.week + 1, this.year); } else { if (this.year < 9999) { result = new Week(FIRST_WEEK_IN_YEAR, this.year + 1); } else { result = null; } } } return result; } /** * Returns a serial index number for the week. * * @return The serial index number. */ public long getSerialIndex() { return this.year * 53L + this.week; } /** * Returns the first millisecond of the week, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The first millisecond of the week. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { Calendar c = (Calendar) calendar.clone(); c.clear(); c.set(Calendar.YEAR, this.year); c.set(Calendar.WEEK_OF_YEAR, this.week); c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); //return c.getTimeInMillis(); // this won't work for JDK 1.3 return c.getTime().getTime(); } /** * Returns the last millisecond of the week, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The last millisecond of the week. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { Calendar c = (Calendar) calendar.clone(); c.clear(); c.set(Calendar.YEAR, this.year); c.set(Calendar.WEEK_OF_YEAR, this.week + 1); c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); c.set(Calendar.HOUR, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); //return c.getTimeInMillis(); // this won't work for JDK 1.3 return c.getTime().getTime() - 1; } /** * Returns a string representing the week (e.g. "Week 9, 2002"). * * TODO: look at internationalisation. * * @return A string representing the week. */ public String toString() { return "Week " + this.week + ", " + this.year; } /** * Tests the equality of this Week object to an arbitrary object. Returns * true if the target is a Week instance representing the same week as this * object. In all other cases, returns false. * * @param obj the object (null permitted). * * @return true if week and year of this and object are the * same. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Week)) { return false; } Week that = (Week) obj; if (this.week != that.week) { return false; } if (this.year != that.year) { return false; } return true; } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; result = 37 * result + this.week; result = 37 * result + this.year; return result; } /** * Returns an integer indicating the order of this Week object relative to * the specified object: * * negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Week object // -------------------------------------------- if (o1 instanceof Week) { Week w = (Week) o1; result = this.year - w.getYear().getYear(); if (result == 0) { result = this.week - w.getWeek(); } } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Parses the string argument as a week. *

* This method is required to accept the format "YYYY-Wnn". It will also * accept "Wnn-YYYY". Anything else, at the moment, is a bonus. * * @param s string to parse. * * @return null if the string is not parseable, the week * otherwise. */ public static Week parseWeek(String s) { Week result = null; if (s != null) { // trim whitespace from either end of the string s = s.trim(); int i = Week.findSeparator(s); if (i != -1) { String s1 = s.substring(0, i).trim(); String s2 = s.substring(i + 1, s.length()).trim(); Year y = Week.evaluateAsYear(s1); int w; if (y != null) { w = Week.stringToWeek(s2); if (w == -1) { throw new TimePeriodFormatException( "Can't evaluate the week."); } result = new Week(w, y); } else { y = Week.evaluateAsYear(s2); if (y != null) { w = Week.stringToWeek(s1); if (w == -1) { throw new TimePeriodFormatException( "Can't evaluate the week."); } result = new Week(w, y); } else { throw new TimePeriodFormatException( "Can't evaluate the year."); } } } else { throw new TimePeriodFormatException( "Could not find separator."); } } return result; } /** * Finds the first occurrence of ' ', '-', ',' or '.' * * @param s the string to parse. * * @return -1 if none of the characters was found, the * index of the first occurrence otherwise. */ private static int findSeparator(String s) { int result = s.indexOf('-'); if (result == -1) { result = s.indexOf(','); } if (result == -1) { result = s.indexOf(' '); } if (result == -1) { result = s.indexOf('.'); } return result; } /** * Creates a year from a string, or returns null (format exceptions * suppressed). * * @param s string to parse. * * @return null if the string is not parseable, the year * otherwise. */ private static Year evaluateAsYear(String s) { Year result = null; try { result = Year.parseYear(s); } catch (TimePeriodFormatException e) { // suppress } return result; } /** * Converts a string to a week. * * @param s the string to parse. * @return -1 if the string does not contain a week number, * the number of the week otherwise. */ private static int stringToWeek(String s) { int result = -1; s = s.replace('W', ' '); s = s.trim(); try { result = Integer.parseInt(s); if ((result < 1) || (result > LAST_WEEK_IN_YEAR)) { result = -1; } } catch (NumberFormatException e) { // suppress } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/Year.java0000644000175000017500000003152511173030414024750 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------- * Year.java * --------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Oct-2001 : Version 1 (DG); * 14-Nov-2001 : Override for toString() method (DG); * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); * 29-Jan-2002 : Worked on parseYear() method (DG); * 14-Feb-2002 : Fixed bug in Year(Date) constructor (DG); * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to * evaluate with reference to a particular time zone (DG); * 19-Mar-2002 : Changed API for TimePeriod classes (DG); * 10-Sep-2002 : Added getSerialIndex() method (DG); * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 10-Jan-2003 : Changed base class and method names (DG); * 05-Mar-2003 : Fixed bug in getFirstMillisecond() picked up in JUnit * tests (DG); * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented * Serializable (DG); * 21-Oct-2003 : Added hashCode() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 16-Sep-2008 : Extended range of valid years, and deprecated * DEFAULT_TIME_ZONE (DG); * 25-Nov-2008 : Added new constructor with Locale (DG); * */ package org.jfree.data.time; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; /** * Represents a year in the range -9999 to 9999. This class is immutable, * which is a requirement for all {@link RegularTimePeriod} subclasses. */ public class Year extends RegularTimePeriod implements Serializable { /** * The minimum year value. * * @since 1.0.11 */ public static final int MINIMUM_YEAR = -9999; /** * The maximum year value. * * @since 1.0.11 */ public static final int MAXIMUM_YEAR = 9999; /** For serialization. */ private static final long serialVersionUID = -7659990929736074836L; /** The year. */ private short year; /** The first millisecond. */ private long firstMillisecond; /** The last millisecond. */ private long lastMillisecond; /** * Creates a new Year, based on the current system date/time. */ public Year() { this(new Date()); } /** * Creates a time period representing a single year. * * @param year the year. */ public Year(int year) { if ((year < Year.MINIMUM_YEAR) || (year > Year.MAXIMUM_YEAR)) { throw new IllegalArgumentException( "Year constructor: year (" + year + ") outside valid range."); } this.year = (short) year; peg(Calendar.getInstance()); } /** * Creates a new Year, based on a particular instant in time, * using the default time zone. * * @param time the time (null not permitted). * * @see #Year(Date, TimeZone) */ public Year(Date time) { this(time, TimeZone.getDefault()); } /** * Constructs a year, based on a particular instant in time and a time zone. * * @param time the time (null not permitted). * @param zone the time zone. * * @deprecated Since 1.0.12, use {@link #Year(Date, TimeZone, Locale)} * instead. */ public Year(Date time, TimeZone zone) { this(time, zone, Locale.getDefault()); } /** * Creates a new Year instance, for the specified time zone * and locale. * * @param time the current time (null not permitted). * @param zone the time zone. * @param locale the locale. * * @since 1.0.12 */ public Year(Date time, TimeZone zone, Locale locale) { Calendar calendar = Calendar.getInstance(zone, locale); calendar.setTime(time); this.year = (short) calendar.get(Calendar.YEAR); peg(calendar); } /** * Returns the year. * * @return The year. */ public int getYear() { return this.year; } /** * Returns the first millisecond of the year. This will be determined * relative to the time zone specified in the constructor, or in the * calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The first millisecond of the year. * * @see #getLastMillisecond() */ public long getFirstMillisecond() { return this.firstMillisecond; } /** * Returns the last millisecond of the year. This will be * determined relative to the time zone specified in the constructor, or * in the calendar instance passed in the most recent call to the * {@link #peg(Calendar)} method. * * @return The last millisecond of the year. * * @see #getFirstMillisecond() */ public long getLastMillisecond() { return this.lastMillisecond; } /** * Recalculates the start date/time and end date/time for this time period * relative to the supplied calendar (which incorporates a time zone). * * @param calendar the calendar (null not permitted). * * @since 1.0.3 */ public void peg(Calendar calendar) { this.firstMillisecond = getFirstMillisecond(calendar); this.lastMillisecond = getLastMillisecond(calendar); } /** * Returns the year preceding this one. * * @return The year preceding this one (or null if the * current year is -9999). */ public RegularTimePeriod previous() { if (this.year > Year.MINIMUM_YEAR) { return new Year(this.year - 1); } else { return null; } } /** * Returns the year following this one. * * @return The year following this one (or null if the current * year is 9999). */ public RegularTimePeriod next() { if (this.year < Year.MAXIMUM_YEAR) { return new Year(this.year + 1); } else { return null; } } /** * Returns a serial index number for the year. *

* The implementation simply returns the year number (e.g. 2002). * * @return The serial index number. */ public long getSerialIndex() { return this.year; } /** * Returns the first millisecond of the year, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The first millisecond of the year. * * @throws NullPointerException if calendar is * null. */ public long getFirstMillisecond(Calendar calendar) { calendar.set(this.year, Calendar.JANUARY, 1, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); // in the following line, we'd rather call calendar.getTimeInMillis() // to avoid object creation, but that isn't supported in Java 1.3.1 return calendar.getTime().getTime(); } /** * Returns the last millisecond of the year, evaluated using the supplied * calendar (which determines the time zone). * * @param calendar the calendar (null not permitted). * * @return The last millisecond of the year. * * @throws NullPointerException if calendar is * null. */ public long getLastMillisecond(Calendar calendar) { calendar.set(this.year, Calendar.DECEMBER, 31, 23, 59, 59); calendar.set(Calendar.MILLISECOND, 999); // in the following line, we'd rather call calendar.getTimeInMillis() // to avoid object creation, but that isn't supported in Java 1.3.1 return calendar.getTime().getTime(); } /** * Tests the equality of this Year object to an arbitrary * object. Returns true if the target is a Year * instance representing the same year as this object. In all other cases, * returns false. * * @param obj the object (null permitted). * * @return true if the year of this and the object are the * same. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Year)) { return false; } Year that = (Year) obj; return (this.year == that.year); } /** * Returns a hash code for this object instance. The approach described by * Joshua Bloch in "Effective Java" has been used here: *

* http://developer.java.sun.com/developer/Books/effectivejava * /Chapter3.pdf * * @return A hash code. */ public int hashCode() { int result = 17; int c = this.year; result = 37 * result + c; return result; } /** * Returns an integer indicating the order of this Year object * relative to the specified object: * * negative == before, zero == same, positive == after. * * @param o1 the object to compare. * * @return negative == before, zero == same, positive == after. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another Year object // ----------------------------------------- if (o1 instanceof Year) { Year y = (Year) o1; result = this.year - y.getYear(); } // CASE 2 : Comparing to another TimePeriod object // ----------------------------------------------- else if (o1 instanceof RegularTimePeriod) { // more difficult case - evaluate later... result = 0; } // CASE 3 : Comparing to a non-TimePeriod object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns a string representing the year.. * * @return A string representing the year. */ public String toString() { return Integer.toString(this.year); } /** * Parses the string argument as a year. *

* The string format is YYYY. * * @param s a string representing the year. * * @return null if the string is not parseable, the year * otherwise. */ public static Year parseYear(String s) { // parse the string... int y; try { y = Integer.parseInt(s.trim()); } catch (NumberFormatException e) { throw new TimePeriodFormatException("Cannot parse string."); } // create the year... try { return new Year(y); } catch (IllegalArgumentException e) { throw new TimePeriodFormatException("Year outside valid range."); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/time/package.html0000644000175000017500000000023211173030414025455 0ustar vincentvincent Interfaces and classes for time-related data. libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/0000755000175000017500000000000011216245562023053 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/CategoryDatasetHandler.java0000644000175000017500000001051111173030414030263 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryDatasetHandler.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A SAX handler for reading a {@link CategoryDataset} from an XML file. */ public class CategoryDatasetHandler extends RootHandler implements DatasetTags { /** The dataset under construction. */ private DefaultCategoryDataset dataset; /** * Creates a new handler. */ public CategoryDatasetHandler() { this.dataset = null; } /** * Returns the dataset. * * @return The dataset. */ public CategoryDataset getDataset() { return this.dataset; } /** * Adds an item to the dataset. * * @param rowKey the row key. * @param columnKey the column key. * @param value the value. */ public void addItem(Comparable rowKey, Comparable columnKey, Number value) { this.dataset.addValue(value, rowKey, columnKey); } /** * The start of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the element attributes. * * @throws SAXException for errors. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { DefaultHandler current = getCurrentHandler(); if (current != this) { current.startElement(namespaceURI, localName, qName, atts); } else if (qName.equals(CATEGORYDATASET_TAG)) { this.dataset = new DefaultCategoryDataset(); } else if (qName.equals(SERIES_TAG)) { CategorySeriesHandler subhandler = new CategorySeriesHandler(this); getSubHandlers().push(subhandler); subhandler.startElement(namespaceURI, localName, qName, atts); } else { throw new SAXException("Element not recognised: " + qName); } } /** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * * @throws SAXException for errors. */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { DefaultHandler current = getCurrentHandler(); if (current != this) { current.endElement(namespaceURI, localName, qName); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/CategorySeriesHandler.java0000644000175000017500000001126311173030414030135 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * CategorySeriesHandler.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; import java.util.Iterator; import org.jfree.data.DefaultKeyedValues; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A handler for reading a series for a category dataset. */ public class CategorySeriesHandler extends DefaultHandler implements DatasetTags { /** The root handler. */ private RootHandler root; /** The series key. */ private Comparable seriesKey; /** The values. */ private DefaultKeyedValues values; /** * Creates a new item handler. * * @param root the root handler. */ public CategorySeriesHandler(RootHandler root) { this.root = root; this.values = new DefaultKeyedValues(); } /** * Sets the series key. * * @param key the key. */ public void setSeriesKey(Comparable key) { this.seriesKey = key; } /** * Adds an item to the temporary storage for the series. * * @param key the key. * @param value the value. */ public void addItem(Comparable key, final Number value) { this.values.addValue(key, value); } /** * The start of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the attributes. * * @throws SAXException for errors. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (qName.equals(SERIES_TAG)) { setSeriesKey(atts.getValue("name")); ItemHandler subhandler = new ItemHandler(this.root, this); this.root.pushSubHandler(subhandler); } else if (qName.equals(ITEM_TAG)) { ItemHandler subhandler = new ItemHandler(this.root, this); this.root.pushSubHandler(subhandler); subhandler.startElement(namespaceURI, localName, qName, atts); } else { throw new SAXException( "Expecting or tag...found " + qName ); } } /** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. */ public void endElement(String namespaceURI, String localName, String qName) { if (this.root instanceof CategoryDatasetHandler) { CategoryDatasetHandler handler = (CategoryDatasetHandler) this.root; Iterator iterator = this.values.getKeys().iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number value = this.values.getValue(key); handler.addItem(this.seriesKey, key, value); } this.root.popSubHandler(); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/DatasetReader.java0000644000175000017500000001113111173030414026411 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * DatasetReader.java * ------------------ * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Nov-2002 : Version 1 (DG); * */ package org.jfree.data.xml; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.PieDataset; import org.xml.sax.SAXException; /** * A utility class for reading datasets from XML. */ public class DatasetReader { /** * Reads a {@link PieDataset} from an XML file. * * @param file the file. * * @return A dataset. * * @throws IOException if there is a problem reading the file. */ public static PieDataset readPieDatasetFromXML(File file) throws IOException { InputStream in = new FileInputStream(file); return readPieDatasetFromXML(in); } /** * Reads a {@link PieDataset} from a stream. * * @param in the input stream. * * @return A dataset. * * @throws IOException if there is an I/O error. */ public static PieDataset readPieDatasetFromXML(InputStream in) throws IOException { PieDataset result = null; SAXParserFactory factory = SAXParserFactory.newInstance(); try { SAXParser parser = factory.newSAXParser(); PieDatasetHandler handler = new PieDatasetHandler(); parser.parse(in, handler); result = handler.getDataset(); } catch (SAXException e) { System.out.println(e.getMessage()); } catch (ParserConfigurationException e2) { System.out.println(e2.getMessage()); } return result; } /** * Reads a {@link CategoryDataset} from a file. * * @param file the file. * * @return A dataset. * * @throws IOException if there is a problem reading the file. */ public static CategoryDataset readCategoryDatasetFromXML(File file) throws IOException { InputStream in = new FileInputStream(file); return readCategoryDatasetFromXML(in); } /** * Reads a {@link CategoryDataset} from a stream. * * @param in the stream. * * @return A dataset. * * @throws IOException if there is a problem reading the file. */ public static CategoryDataset readCategoryDatasetFromXML(InputStream in) throws IOException { CategoryDataset result = null; SAXParserFactory factory = SAXParserFactory.newInstance(); try { SAXParser parser = factory.newSAXParser(); CategoryDatasetHandler handler = new CategoryDatasetHandler(); parser.parse(in, handler); result = handler.getDataset(); } catch (SAXException e) { System.out.println(e.getMessage()); } catch (ParserConfigurationException e2) { System.out.println(e2.getMessage()); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/DatasetTags.java0000644000175000017500000000435111173030414026113 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * DatasetTags.java * ---------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; /** * Constants for the tags that identify the elements in the XML files. */ public interface DatasetTags { /** The 'PieDataset' element name. */ public static final String PIEDATASET_TAG = "PieDataset"; /** The 'CategoryDataset' element name. */ public static final String CATEGORYDATASET_TAG = "CategoryDataset"; /** The 'Series' element name. */ public static final String SERIES_TAG = "Series"; /** The 'Item' element name. */ public static final String ITEM_TAG = "Item"; /** The 'Key' element name. */ public static final String KEY_TAG = "Key"; /** The 'Value' element name. */ public static final String VALUE_TAG = "Value"; } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/ItemHandler.java0000644000175000017500000001153311173030414026103 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ItemHandler.java * ---------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A handler for reading key-value items. */ public class ItemHandler extends DefaultHandler implements DatasetTags { /** The root handler. */ private RootHandler root; /** The parent handler (can be the same as root, but not always). */ private DefaultHandler parent; /** The key. */ private Comparable key; /** The value. */ private Number value; /** * Creates a new item handler. * * @param root the root handler. * @param parent the parent handler. */ public ItemHandler(RootHandler root, DefaultHandler parent) { this.root = root; this.parent = parent; this.key = null; this.value = null; } /** * Returns the key that has been read by the handler, or null. * * @return The key. */ public Comparable getKey() { return this.key; } /** * Sets the key. * * @param key the key. */ public void setKey(Comparable key) { this.key = key; } /** * Returns the key that has been read by the handler, or null. * * @return The value. */ public Number getValue() { return this.value; } /** * Sets the value. * * @param value the value. */ public void setValue(Number value) { this.value = value; } /** * The start of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the attributes. * * @throws SAXException for errors. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (qName.equals(ITEM_TAG)) { KeyHandler subhandler = new KeyHandler(this.root, this); this.root.pushSubHandler(subhandler); } else if (qName.equals(VALUE_TAG)) { ValueHandler subhandler = new ValueHandler(this.root, this); this.root.pushSubHandler(subhandler); } else { throw new SAXException( "Expected or ...found " + qName ); } } /** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. */ public void endElement(String namespaceURI, String localName, String qName) { if (this.parent instanceof PieDatasetHandler) { PieDatasetHandler handler = (PieDatasetHandler) this.parent; handler.addItem(this.key, this.value); this.root.popSubHandler(); } else if (this.parent instanceof CategorySeriesHandler) { CategorySeriesHandler handler = (CategorySeriesHandler) this.parent; handler.addItem(this.key, this.value); this.root.popSubHandler(); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/KeyHandler.java0000644000175000017500000001126711173030414025741 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * KeyHandler.java * --------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A SAX handler for reading a key. */ public class KeyHandler extends DefaultHandler implements DatasetTags { /** The root handler. */ private RootHandler rootHandler; /** The item handler. */ private ItemHandler itemHandler; /** Storage for the current CDATA */ private StringBuffer currentText; /** The key. */ //private Comparable key; /** * Creates a new handler. * * @param rootHandler the root handler. * @param itemHandler the item handler. */ public KeyHandler(RootHandler rootHandler, ItemHandler itemHandler) { this.rootHandler = rootHandler; this.itemHandler = itemHandler; this.currentText = new StringBuffer(); //this.key = null; } /** * The start of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the attributes. * * @throws SAXException for errors. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (qName.equals(KEY_TAG)) { clearCurrentText(); } else { throw new SAXException("Expecting but found " + qName); } } /** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * * @throws SAXException for errors. */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (qName.equals(KEY_TAG)) { this.itemHandler.setKey(getCurrentText()); this.rootHandler.popSubHandler(); this.rootHandler.pushSubHandler( new ValueHandler(this.rootHandler, this.itemHandler) ); } else { throw new SAXException("Expecting but found " + qName); } } /** * Receives some (or all) of the text in the current element. * * @param ch character buffer. * @param start the start index. * @param length the length of the valid character data. */ public void characters(char[] ch, int start, int length) { if (this.currentText != null) { this.currentText.append(String.copyValueOf(ch, start, length)); } } /** * Returns the current text of the textbuffer. * * @return The current text. */ protected String getCurrentText() { return this.currentText.toString(); } /** * Removes all text from the textbuffer at the end of a CDATA section. */ protected void clearCurrentText() { this.currentText.delete(0, this.currentText.length()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/PieDatasetHandler.java0000644000175000017500000001011611173030414027224 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * PieDatasetHandler.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A SAX handler for reading a {@link PieDataset} from an XML file. */ public class PieDatasetHandler extends RootHandler implements DatasetTags { /** The pie dataset under construction. */ private DefaultPieDataset dataset; /** * Default constructor. */ public PieDatasetHandler() { this.dataset = null; } /** * Returns the dataset. * * @return The dataset. */ public PieDataset getDataset() { return this.dataset; } /** * Adds an item to the dataset under construction. * * @param key the key. * @param value the value. */ public void addItem(Comparable key, Number value) { this.dataset.setValue(key, value); } /** * Starts an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the element attributes. * * @throws SAXException for errors. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { DefaultHandler current = getCurrentHandler(); if (current != this) { current.startElement(namespaceURI, localName, qName, atts); } else if (qName.equals(PIEDATASET_TAG)) { this.dataset = new DefaultPieDataset(); } else if (qName.equals(ITEM_TAG)) { ItemHandler subhandler = new ItemHandler(this, this); getSubHandlers().push(subhandler); subhandler.startElement(namespaceURI, localName, qName, atts); } } /** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * * @throws SAXException for errors. */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { DefaultHandler current = getCurrentHandler(); if (current != this) { current.endElement(namespaceURI, localName, qName); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/RootHandler.java0000644000175000017500000000713411173030414026132 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * RootHandler.java * ---------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * */ package org.jfree.data.xml; import java.util.Stack; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A SAX handler that delegates work to sub-handlers. */ public class RootHandler extends DefaultHandler implements DatasetTags { /** The sub-handlers. */ private Stack subHandlers; /** * Creates a new handler. */ public RootHandler() { this.subHandlers = new Stack(); } /** * Returns the stack of sub handlers. * * @return The sub-handler stack. */ public Stack getSubHandlers() { return this.subHandlers; } /** * Receives some (or all) of the text in the current element. * * @param ch character buffer. * @param start the start index. * @param length the length of the valid character data. * * @throws SAXException for errors. */ public void characters(char[] ch, int start, int length) throws SAXException { DefaultHandler handler = getCurrentHandler(); if (handler != this) { handler.characters(ch, start, length); } } /** * Returns the handler at the top of the stack. * * @return The handler. */ public DefaultHandler getCurrentHandler() { DefaultHandler result = this; if (this.subHandlers != null) { if (this.subHandlers.size() > 0) { Object top = this.subHandlers.peek(); if (top != null) { result = (DefaultHandler) top; } } } return result; } /** * Pushes a sub-handler onto the stack. * * @param subhandler the sub-handler. */ public void pushSubHandler(DefaultHandler subhandler) { this.subHandlers.push(subhandler); } /** * Pops a sub-handler from the stack. * * @return The sub-handler. */ public DefaultHandler popSubHandler() { return (DefaultHandler) this.subHandlers.pop(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/ValueHandler.java0000644000175000017500000001164611173030414026266 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * ValueHandler.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Luke Quinane; * * Changes * ------- * 23-Jan-2003 : Version 1 (DG); * 25-Nov-2003 : Patch to handle 'NaN' values (DG); * */ package org.jfree.data.xml; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; /** * A handler for reading a 'Value' element. */ public class ValueHandler extends DefaultHandler implements DatasetTags { /** The root handler. */ private RootHandler rootHandler; /** The item handler. */ private ItemHandler itemHandler; /** Storage for the current CDATA */ private StringBuffer currentText; /** * Creates a new value handler. * * @param rootHandler the root handler. * @param itemHandler the item handler. */ public ValueHandler(RootHandler rootHandler, ItemHandler itemHandler) { this.rootHandler = rootHandler; this.itemHandler = itemHandler; this.currentText = new StringBuffer(); } /** * The start of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * @param atts the attributes. * * @throws SAXException for errors. */ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if (qName.equals(VALUE_TAG)) { // no attributes to read clearCurrentText(); } else { throw new SAXException("Expecting but found " + qName); } } /** * The end of an element. * * @param namespaceURI the namespace. * @param localName the element name. * @param qName the element name. * * @throws SAXException for errors. */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (qName.equals(VALUE_TAG)) { Number value; try { value = Double.valueOf(this.currentText.toString()); if (((Double) value).isNaN()) { value = null; } } catch (NumberFormatException e1) { value = null; } this.itemHandler.setValue(value); this.rootHandler.popSubHandler(); } else { throw new SAXException("Expecting but found " + qName); } } /** * Receives some (or all) of the text in the current element. * * @param ch character buffer. * @param start the start index. * @param length the length of the valid character data. */ public void characters(char[] ch, int start, int length) { if (this.currentText != null) { this.currentText.append(String.copyValueOf(ch, start, length)); } } /** * Returns the current text of the textbuffer. * * @return The current text. */ protected String getCurrentText() { return this.currentText.toString(); } /** * Removes all text from the textbuffer at the end of a CDATA section. */ protected void clearCurrentText() { this.currentText.delete(0, this.currentText.length()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xml/package.html0000644000175000017500000000023111173030414025316 0ustar vincentvincent Support for reading datasets from XML files. libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/0000755000175000017500000000000011216245562022713 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/AbstractIntervalXYDataset.java0000644000175000017500000000770111173030414030610 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * AbstractIntervalXYDataset.java * ------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited). * Contributor(s): -; * * Changes * ------- * 05-May-2004 : Version 1 (DG); * 15-Jul-2004 : Switched getStartX() and getStartXValue() methods and * others (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * */ package org.jfree.data.xy; /** * An base class that you can use to create new implementations of the * {@link IntervalXYDataset} interface. */ public abstract class AbstractIntervalXYDataset extends AbstractXYDataset implements IntervalXYDataset { /** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartXValue(int series, int item) { double result = Double.NaN; Number x = getStartX(series, item); if (x != null) { result = x.doubleValue(); } return result; } /** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getEndXValue(int series, int item) { double result = Double.NaN; Number x = getEndX(series, item); if (x != null) { result = x.doubleValue(); } return result; } /** * Returns the start y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartYValue(int series, int item) { double result = Double.NaN; Number y = getStartY(series, item); if (y != null) { result = y.doubleValue(); } return result; } /** * Returns the end y-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public double getEndYValue(int series, int item) { double result = Double.NaN; Number y = getEndY(series, item); if (y != null) { result = y.doubleValue(); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/AbstractXYDataset.java0000644000175000017500000000622711173030414027105 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * AbstractXYDataset.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited). * Contributor(s): -; * * Changes * ------- * 05-May-2004 : Version 1 (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * */ package org.jfree.data.xy; import org.jfree.data.DomainOrder; import org.jfree.data.general.AbstractSeriesDataset; /** * An base class that you can use to create new implementations of the * {@link XYDataset} interface. */ public abstract class AbstractXYDataset extends AbstractSeriesDataset implements XYDataset { /** * Returns the order of the domain (X) values. * * @return The domain order. */ public DomainOrder getDomainOrder() { return DomainOrder.NONE; } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getXValue(int series, int item) { double result = Double.NaN; Number x = getX(series, item); if (x != null) { result = x.doubleValue(); } return result; } /** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getYValue(int series, int item) { double result = Double.NaN; Number y = getY(series, item); if (y != null) { result = y.doubleValue(); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/AbstractXYZDataset.java0000644000175000017500000000443511173030414027236 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * AbstractXYZDataset.java * ----------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited). * Contributor(s): -; * * Changes * ------- * 05-May-2004 : Version 1 (DG); * 15-Jul-2004 : Switched getZ() and getZValue() (DG); * */ package org.jfree.data.xy; /** * An base class that you can use to create new implementations of the * {@link XYZDataset} interface. */ public abstract class AbstractXYZDataset extends AbstractXYDataset implements XYZDataset { /** * Returns the z-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The z-value. */ public double getZValue(int series, int item) { double result = Double.NaN; Number z = getZ(series, item); if (z != null) { result = z.doubleValue(); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/CategoryTableXYDataset.java0000644000175000017500000003206211173030414030063 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * CategoryTableXYDataset.java * --------------------------- * (C) Copyright 2004-2008, by Andreas Schroeder and Contributors. * * Original Author: Andreas Schroeder; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 31-Mar-2004 : Version 1 (AS); * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched interval access method names (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * 17-Nov-2004 : Updates required by changes to DomainInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 05-Oct-2005 : Made the interval delegate a dataset change listener (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 22-Apr-2008 : Implemented PublicCloneable, and fixed clone() method (DG); * */ package org.jfree.data.xy; import org.jfree.data.DefaultKeyedValues2D; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.util.PublicCloneable; /** * An implementation variant of the {@link TableXYDataset} where every series * shares the same x-values (required for generating stacked area charts). * This implementation uses a {@link DefaultKeyedValues2D} Object as backend * implementation and is hence more "category oriented" than the {@link * DefaultTableXYDataset} implementation. *

* This implementation provides no means to remove data items yet. * This is due to the lack of such facility in the DefaultKeyedValues2D class. *

* This class also implements the {@link IntervalXYDataset} interface, but this * implementation is provisional. */ public class CategoryTableXYDataset extends AbstractIntervalXYDataset implements TableXYDataset, IntervalXYDataset, DomainInfo, PublicCloneable { /** * The backing data structure. */ private DefaultKeyedValues2D values; /** A delegate for controlling the interval width. */ private IntervalXYDelegate intervalDelegate; /** * Creates a new empty CategoryTableXYDataset. */ public CategoryTableXYDataset() { this.values = new DefaultKeyedValues2D(true); this.intervalDelegate = new IntervalXYDelegate(this); addChangeListener(this.intervalDelegate); } /** * Adds a data item to this dataset and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param x the x value. * @param y the y value. * @param seriesName the name of the series to add the data item. */ public void add(double x, double y, String seriesName) { add(new Double(x), new Double(y), seriesName, true); } /** * Adds a data item to this dataset and, if requested, sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param x the x value. * @param y the y value. * @param seriesName the name of the series to add the data item. * @param notify notify listeners? */ public void add(Number x, Number y, String seriesName, boolean notify) { this.values.addValue(y, (Comparable) x, seriesName); if (notify) { fireDatasetChanged(); } } /** * Removes a value from the dataset. * * @param x the x-value. * @param seriesName the series name. */ public void remove(double x, String seriesName) { remove(new Double(x), seriesName, true); } /** * Removes an item from the dataset. * * @param x the x-value. * @param seriesName the series name. * @param notify notify listeners? */ public void remove(Number x, String seriesName, boolean notify) { this.values.removeValue((Comparable) x, seriesName); if (notify) { fireDatasetChanged(); } } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.values.getColumnCount(); } /** * Returns the key for a series. * * @param series the series index (zero-based). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { return this.values.getColumnKey(series); } /** * Returns the number of x values in the dataset. * * @return The item count. */ public int getItemCount() { return this.values.getRowCount(); } /** * Returns the number of items in the specified series. * Returns the same as {@link CategoryTableXYDataset#getItemCount()}. * * @param series the series index (zero-based). * * @return The item count. */ public int getItemCount(int series) { return getItemCount(); // all series have the same number of items in // this dataset } /** * Returns the x-value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getX(int series, int item) { return (Number) this.values.getRowKey(item); } /** * Returns the starting X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The starting X value. */ public Number getStartX(int series, int item) { return this.intervalDelegate.getStartX(series, item); } /** * Returns the ending X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The ending X value. */ public Number getEndX(int series, int item) { return this.intervalDelegate.getEndX(series, item); } /** * Returns the y-value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y value (possibly null). */ public Number getY(int series, int item) { return this.values.getValue(item, series); } /** * Returns the starting Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The starting Y value. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The ending Y value. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { return this.intervalDelegate.getDomainLowerBound(includeInterval); } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { return this.intervalDelegate.getDomainUpperBound(includeInterval); } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { if (includeInterval) { return this.intervalDelegate.getDomainBounds(includeInterval); } else { return DatasetUtilities.iterateDomainBounds(this, includeInterval); } } /** * Returns the interval position factor. * * @return The interval position factor. */ public double getIntervalPositionFactor() { return this.intervalDelegate.getIntervalPositionFactor(); } /** * Sets the interval position factor. Must be between 0.0 and 1.0 inclusive. * If the factor is 0.5, the gap is in the middle of the x values. If it * is lesser than 0.5, the gap is farther to the left and if greater than * 0.5 it gets farther to the right. * * @param d the new interval position factor. */ public void setIntervalPositionFactor(double d) { this.intervalDelegate.setIntervalPositionFactor(d); fireDatasetChanged(); } /** * Returns the full interval width. * * @return The interval width to use. */ public double getIntervalWidth() { return this.intervalDelegate.getIntervalWidth(); } /** * Sets the interval width to a fixed value, and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param d the new interval width (must be > 0). */ public void setIntervalWidth(double d) { this.intervalDelegate.setFixedIntervalWidth(d); fireDatasetChanged(); } /** * Returns whether the interval width is automatically calculated or not. * * @return whether the width is automatically calculated or not. */ public boolean isAutoWidth() { return this.intervalDelegate.isAutoWidth(); } /** * Sets the flag that indicates whether the interval width is automatically * calculated or not. * * @param b the flag. */ public void setAutoWidth(boolean b) { this.intervalDelegate.setAutoWidth(b); fireDatasetChanged(); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (!(obj instanceof CategoryTableXYDataset)) { return false; } CategoryTableXYDataset that = (CategoryTableXYDataset) obj; if (!this.intervalDelegate.equals(that.intervalDelegate)) { return false; } if (!this.values.equals(that.values)) { return false; } return true; } /** * Returns an independent copy of this dataset. * * @return A clone. * * @throws CloneNotSupportedException if there is some reason that cloning * cannot be performed. */ public Object clone() throws CloneNotSupportedException { CategoryTableXYDataset clone = (CategoryTableXYDataset) super.clone(); clone.values = (DefaultKeyedValues2D) this.values.clone(); clone.intervalDelegate = new IntervalXYDelegate(clone); // need to configure the intervalDelegate to match the original clone.intervalDelegate.setFixedIntervalWidth(getIntervalWidth()); clone.intervalDelegate.setAutoWidth(isAutoWidth()); clone.intervalDelegate.setIntervalPositionFactor( getIntervalPositionFactor()); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultHighLowDataset.java0000644000175000017500000003161411173030414027725 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultHighLowDataset.java * -------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2002 : Version 1 (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 06-May-2004 : Now extends AbstractXYDataset and added new methods from * HighLowDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 28-Nov-2006 : Added equals() method override (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.util.Arrays; import java.util.Date; import org.jfree.util.PublicCloneable; /** * A simple implementation of the {@link OHLCDataset} interface. See also * the {@link DefaultOHLCDataset} class, which provides another implementation * that is very similar. */ public class DefaultHighLowDataset extends AbstractXYDataset implements OHLCDataset, PublicCloneable { /** The series key. */ private Comparable seriesKey; /** Storage for the dates. */ private Date[] date; /** Storage for the high values. */ private Number[] high; /** Storage for the low values. */ private Number[] low; /** Storage for the open values. */ private Number[] open; /** Storage for the close values. */ private Number[] close; /** Storage for the volume values. */ private Number[] volume; /** * Constructs a new high/low/open/close dataset. *

* The current implementation allows only one series in the dataset. * This may be extended in a future version. * * @param seriesKey the key for the series (null not * permitted). * @param date the dates (null not permitted). * @param high the high values (null not permitted). * @param low the low values (null not permitted). * @param open the open values (null not permitted). * @param close the close values (null not permitted). * @param volume the volume values (null not permitted). */ public DefaultHighLowDataset(Comparable seriesKey, Date[] date, double[] high, double[] low, double[] open, double[] close, double[] volume) { if (seriesKey == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (date == null) { throw new IllegalArgumentException("Null 'date' argument."); } this.seriesKey = seriesKey; this.date = date; this.high = createNumberArray(high); this.low = createNumberArray(low); this.open = createNumberArray(open); this.close = createNumberArray(close); this.volume = createNumberArray(volume); } /** * Returns the key for the series stored in this dataset. * * @param series the index of the series (ignored, this dataset supports * only one series and this method always returns the key for series 0). * * @return The series key (never null). */ public Comparable getSeriesKey(int series) { return this.seriesKey; } /** * Returns the x-value for one item in a series. The value returned is a * Long instance generated from the underlying * Date object. To avoid generating a new object instance, * you might prefer to call {@link #getXValue(int, int)}. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. * * @see #getXValue(int, int) * @see #getXDate(int, int) */ public Number getX(int series, int item) { return new Long(this.date[item].getTime()); } /** * Returns the x-value for one item in a series, as a Date. *

* This method is provided for convenience only. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value as a Date. * * @see #getX(int, int) */ public Date getXDate(int series, int item) { return this.date[item]; } /** * Returns the y-value for one item in a series. *

* This method (from the {@link XYDataset} interface) is mapped to the * {@link #getCloseValue(int, int)} method. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value. * * @see #getYValue(int, int) */ public Number getY(int series, int item) { return getClose(series, item); } /** * Returns the high-value for one item in a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. * * @see #getHighValue(int, int) */ public Number getHigh(int series, int item) { return this.high[item]; } /** * Returns the high-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. * * @see #getHigh(int, int) */ public double getHighValue(int series, int item) { double result = Double.NaN; Number high = getHigh(series, item); if (high != null) { result = high.doubleValue(); } return result; } /** * Returns the low-value for one item in a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. * * @see #getLowValue(int, int) */ public Number getLow(int series, int item) { return this.low[item]; } /** * Returns the low-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. * * @see #getLow(int, int) */ public double getLowValue(int series, int item) { double result = Double.NaN; Number low = getLow(series, item); if (low != null) { result = low.doubleValue(); } return result; } /** * Returns the open-value for one item in a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The open-value. * * @see #getOpenValue(int, int) */ public Number getOpen(int series, int item) { return this.open[item]; } /** * Returns the open-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The open-value. * * @see #getOpen(int, int) */ public double getOpenValue(int series, int item) { double result = Double.NaN; Number open = getOpen(series, item); if (open != null) { result = open.doubleValue(); } return result; } /** * Returns the close-value for one item in a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. * * @see #getCloseValue(int, int) */ public Number getClose(int series, int item) { return this.close[item]; } /** * Returns the close-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. * * @see #getClose(int, int) */ public double getCloseValue(int series, int item) { double result = Double.NaN; Number close = getClose(series, item); if (close != null) { result = close.doubleValue(); } return result; } /** * Returns the volume-value for one item in a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The volume-value. * * @see #getVolumeValue(int, int) */ public Number getVolume(int series, int item) { return this.volume[item]; } /** * Returns the volume-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The volume-value. * * @see #getVolume(int, int) */ public double getVolumeValue(int series, int item) { double result = Double.NaN; Number volume = getVolume(series, item); if (volume != null) { result = volume.doubleValue(); } return result; } /** * Returns the number of series in the dataset. *

* This implementation only allows one series. * * @return The number of series. */ public int getSeriesCount() { return 1; } /** * Returns the number of items in the specified series. * * @param series the index (zero-based) of the series. * * @return The number of items in the specified series. */ public int getItemCount(int series) { return this.date.length; } /** * Tests this dataset for equality with an arbitrary instance. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultHighLowDataset)) { return false; } DefaultHighLowDataset that = (DefaultHighLowDataset) obj; if (!this.seriesKey.equals(that.seriesKey)) { return false; } if (!Arrays.equals(this.date, that.date)) { return false; } if (!Arrays.equals(this.open, that.open)) { return false; } if (!Arrays.equals(this.high, that.high)) { return false; } if (!Arrays.equals(this.low, that.low)) { return false; } if (!Arrays.equals(this.close, that.close)) { return false; } if (!Arrays.equals(this.volume, that.volume)) { return false; } return true; } /** * Constructs an array of Number objects from an array of doubles. * * @param data the double values to convert (null not * permitted). * * @return The data as an array of Number objects. */ public static Number[] createNumberArray(double[] data) { Number[] result = new Number[data.length]; for (int i = 0; i < data.length; i++) { result[i] = new Double(data[i]); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultIntervalXYDataset.java0000644000175000017500000004737011173030414030437 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * DefaultIntervalXYDataset.java * ----------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Oct-2006 : Version 1 (DG); * 02-Nov-2006 : Fixed a problem with adding a new series with the same key * as an existing series (see bug 1589392) (DG); * 28-Nov-2006 : New override for clone() (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A dataset that defines a range (interval) for both the x-values and the * y-values. This implementation uses six arrays to store the x, start-x, * end-x, y, start-y and end-y values. *

* An alternative implementation of the {@link IntervalXYDataset} interface * is provided by the {@link XYIntervalSeriesCollection} class. * * @since 1.0.3 */ public class DefaultIntervalXYDataset extends AbstractIntervalXYDataset implements PublicCloneable { /** * Storage for the series keys. This list must be kept in sync with the * seriesList. */ private List seriesKeys; /** * Storage for the series in the dataset. We use a list because the * order of the series is significant. This list must be kept in sync * with the seriesKeys list. */ private List seriesList; /** * Creates a new DefaultIntervalXYDataset instance, initially * containing no data. */ public DefaultIntervalXYDataset() { this.seriesKeys = new java.util.ArrayList(); this.seriesList = new java.util.ArrayList(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.seriesList.size(); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for the series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (Comparable) this.seriesKeys.get(series); } /** * Returns the number of items in the specified series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * specified range. */ public int getItemCount(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } double[][] seriesArray = (double[][]) this.seriesList.get(series); return seriesArray[0].length; } /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getX(int, int) */ public double getXValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[0][item]; } /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getY(int, int) */ public double getYValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[3][item]; } /** * Returns the starting x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The starting x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getStartX(int, int) */ public double getStartXValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[1][item]; } /** * Returns the ending x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The ending x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getEndX(int, int) */ public double getEndXValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[2][item]; } /** * Returns the starting y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The starting y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getStartY(int, int) */ public double getStartYValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[4][item]; } /** * Returns the ending y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The ending y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getEndY(int, int) */ public double getEndYValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[5][item]; } /** * Returns the ending x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The ending x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getEndXValue(int, int) */ public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); } /** * Returns the ending y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The ending y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getEndYValue(int, int) */ public Number getEndY(int series, int item) { return new Double(getEndYValue(series, item)); } /** * Returns the starting x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The starting x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getStartXValue(int, int) */ public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); } /** * Returns the starting y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The starting y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getStartYValue(int, int) */ public Number getStartY(int series, int item) { return new Double(getStartYValue(series, item)); } /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getXValue(int, int) */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getYValue(int, int) */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Adds a series or if a series with the same key already exists replaces * the data for that series, then sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param seriesKey the series key (null not permitted). * @param data the data (must be an array with length 6, containing six * arrays of equal length, the first containing the x-values and the * second containing the y-values). */ public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 6) { throw new IllegalArgumentException( "The 'data' array must have length == 6."); } int length = data[0].length; if (length != data[1].length || length != data[2].length || length != data[3].length || length != data[4].length || length != data[5].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { // add a new series this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { // replace an existing series this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } /** * Tests this DefaultIntervalXYDataset instance for equality * with an arbitrary object. This method returns true if and * only if: *

    *
  • obj is not null;
  • *
  • obj is an instance of * DefaultIntervalXYDataset;
  • *
  • both datasets have the same number of series, each containing * exactly the same values.
  • *
* * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultIntervalXYDataset)) { return false; } DefaultIntervalXYDataset that = (DefaultIntervalXYDataset) obj; if (!this.seriesKeys.equals(that.seriesKeys)) { return false; } for (int i = 0; i < this.seriesList.size(); i++) { double[][] d1 = (double[][]) this.seriesList.get(i); double[][] d2 = (double[][]) that.seriesList.get(i); double[] d1x = d1[0]; double[] d2x = d2[0]; if (!Arrays.equals(d1x, d2x)) { return false; } double[] d1xs = d1[1]; double[] d2xs = d2[1]; if (!Arrays.equals(d1xs, d2xs)) { return false; } double[] d1xe = d1[2]; double[] d2xe = d2[2]; if (!Arrays.equals(d1xe, d2xe)) { return false; } double[] d1y = d1[3]; double[] d2y = d2[3]; if (!Arrays.equals(d1y, d2y)) { return false; } double[] d1ys = d1[4]; double[] d2ys = d2[4]; if (!Arrays.equals(d1ys, d2ys)) { return false; } double[] d1ye = d1[5]; double[] d2ye = d2[5]; if (!Arrays.equals(d1ye, d2ye)) { return false; } } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result; result = this.seriesKeys.hashCode(); result = 29 * result + this.seriesList.hashCode(); return result; } /** * Returns a clone of this dataset. * * @return A clone. * * @throws CloneNotSupportedException if the dataset contains a series with * a key that cannot be cloned. */ public Object clone() throws CloneNotSupportedException { DefaultIntervalXYDataset clone = (DefaultIntervalXYDataset) super.clone(); clone.seriesKeys = new java.util.ArrayList(this.seriesKeys); clone.seriesList = new ArrayList(this.seriesList.size()); for (int i = 0; i < this.seriesList.size(); i++) { double[][] data = (double[][]) this.seriesList.get(i); double[] x = data[0]; double[] xStart = data[1]; double[] xEnd = data[2]; double[] y = data[3]; double[] yStart = data[4]; double[] yEnd = data[5]; double[] xx = new double[x.length]; double[] xxStart = new double[xStart.length]; double[] xxEnd = new double[xEnd.length]; double[] yy = new double[y.length]; double[] yyStart = new double[yStart.length]; double[] yyEnd = new double[yEnd.length]; System.arraycopy(x, 0, xx, 0, x.length); System.arraycopy(xStart, 0, xxStart, 0, xStart.length); System.arraycopy(xEnd, 0, xxEnd, 0, xEnd.length); System.arraycopy(y, 0, yy, 0, y.length); System.arraycopy(yStart, 0, yyStart, 0, yStart.length); System.arraycopy(yEnd, 0, yyEnd, 0, yEnd.length); clone.seriesList.add(i, new double[][] {xx, xxStart, xxEnd, yy, yyStart, yyEnd}); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultOHLCDataset.java0000644000175000017500000002247611173030414027117 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DefaultOHLCDataset.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Dec-2003 : Version 1 (DG); * 05-May-2004 : Now extends AbstractXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 29-Apr-2005 : Added equals() method (DG); * 22-Apr-2008 : Implemented PublicCloneable, and fixed cloning bug (DG); * */ package org.jfree.data.xy; import java.util.Arrays; import java.util.Date; import org.jfree.util.PublicCloneable; /** * A simple implementation of the {@link OHLCDataset} interface. This * implementation supports only one series. */ public class DefaultOHLCDataset extends AbstractXYDataset implements OHLCDataset, PublicCloneable { /** The series key. */ private Comparable key; /** Storage for the data items. */ private OHLCDataItem[] data; /** * Creates a new dataset. * * @param key the series key. * @param data the data items. */ public DefaultOHLCDataset(Comparable key, OHLCDataItem[] data) { this.key = key; this.data = data; } /** * Returns the series key. * * @param series the series index (ignored). * * @return The series key. */ public Comparable getSeriesKey(int series) { return this.key; } /** * Returns the x-value for a data item. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The x-value. */ public Number getX(int series, int item) { return new Long(this.data[item].getDate().getTime()); } /** * Returns the x-value for a data item as a date. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The x-value as a date. */ public Date getXDate(int series, int item) { return this.data[item].getDate(); } /** * Returns the y-value. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The y value. */ public Number getY(int series, int item) { return getClose(series, item); } /** * Returns the high value. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The high value. */ public Number getHigh(int series, int item) { return this.data[item].getHigh(); } /** * Returns the high-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. */ public double getHighValue(int series, int item) { double result = Double.NaN; Number high = getHigh(series, item); if (high != null) { result = high.doubleValue(); } return result; } /** * Returns the low value. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The low value. */ public Number getLow(int series, int item) { return this.data[item].getLow(); } /** * Returns the low-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. */ public double getLowValue(int series, int item) { double result = Double.NaN; Number low = getLow(series, item); if (low != null) { result = low.doubleValue(); } return result; } /** * Returns the open value. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The open value. */ public Number getOpen(int series, int item) { return this.data[item].getOpen(); } /** * Returns the open-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The open-value. */ public double getOpenValue(int series, int item) { double result = Double.NaN; Number open = getOpen(series, item); if (open != null) { result = open.doubleValue(); } return result; } /** * Returns the close value. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The close value. */ public Number getClose(int series, int item) { return this.data[item].getClose(); } /** * Returns the close-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. */ public double getCloseValue(int series, int item) { double result = Double.NaN; Number close = getClose(series, item); if (close != null) { result = close.doubleValue(); } return result; } /** * Returns the trading volume. * * @param series the series index (ignored). * @param item the item index (zero-based). * * @return The trading volume. */ public Number getVolume(int series, int item) { return this.data[item].getVolume(); } /** * Returns the volume-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The volume-value. */ public double getVolumeValue(int series, int item) { double result = Double.NaN; Number volume = getVolume(series, item); if (volume != null) { result = volume.doubleValue(); } return result; } /** * Returns the series count. * * @return 1. */ public int getSeriesCount() { return 1; } /** * Returns the item count for the specified series. * * @param series the series index (ignored). * * @return The item count. */ public int getItemCount(int series) { return this.data.length; } /** * Sorts the data into ascending order by date. */ public void sortDataByDate() { Arrays.sort(this.data); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DefaultOHLCDataset)) { return false; } DefaultOHLCDataset that = (DefaultOHLCDataset) obj; if (!this.key.equals(that.key)) { return false; } if (!Arrays.equals(this.data, that.data)) { return false; } return true; } /** * Returns an independent copy of this dataset. * * @return A clone. * * @throws CloneNotSupportedException */ public Object clone() throws CloneNotSupportedException { DefaultOHLCDataset clone = (DefaultOHLCDataset) super.clone(); clone.data = new OHLCDataItem[this.data.length]; System.arraycopy(this.data, 0, clone.data, 0, this.data.length); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultTableXYDataset.java0000644000175000017500000005264011173030414027676 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultTableXYDataset.java * -------------------------- * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): Jody Brownell; * David Gilbert (for Object Refinery Limited); * Andreas Schroeder; * * Changes: * -------- * 27-Jul-2003 : XYDataset that forces each series to have a value for every * X-point which is essential for stacked XY area charts (RA); * 18-Aug-2003 : Fixed event notification when removing and updating * series (RA); * 22-Sep-2003 : Functionality moved from TableXYDataset to * DefaultTableXYDataset (RA); * 23-Dec-2003 : Added patch for large datasets, submitted by Jody * Brownell (DG); * 16-Feb-2004 : Added pruning methods (DG); * 31-Mar-2004 : Provisional implementation of IntervalXYDataset (AS); * 01-Apr-2004 : Sound implementation of IntervalXYDataset (AS); * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * 05-Oct-2005 : Made the interval delegate a dataset listener (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * An {@link XYDataset} where every series shares the same x-values (required * for generating stacked area charts). */ public class DefaultTableXYDataset extends AbstractIntervalXYDataset implements TableXYDataset, IntervalXYDataset, DomainInfo, PublicCloneable { /** * Storage for the data - this list will contain zero, one or many * XYSeries objects. */ private List data = null; /** Storage for the x values. */ private HashSet xPoints = null; /** A flag that controls whether or not events are propogated. */ private boolean propagateEvents = true; /** A flag that controls auto pruning. */ private boolean autoPrune = false; /** The delegate used to control the interval width. */ private IntervalXYDelegate intervalDelegate; /** * Creates a new empty dataset. */ public DefaultTableXYDataset() { this(false); } /** * Creates a new empty dataset. * * @param autoPrune a flag that controls whether or not x-values are * removed whenever the corresponding y-values are all * null. */ public DefaultTableXYDataset(boolean autoPrune) { this.autoPrune = autoPrune; this.data = new ArrayList(); this.xPoints = new HashSet(); this.intervalDelegate = new IntervalXYDelegate(this, false); addChangeListener(this.intervalDelegate); } /** * Returns the flag that controls whether or not x-values are removed from * the dataset when the corresponding y-values are all null. * * @return A boolean. */ public boolean isAutoPrune() { return this.autoPrune; } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. The series should be configured to NOT * allow duplicate x-values. * * @param series the series (null not permitted). */ public void addSeries(XYSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (series.getAllowDuplicateXValues()) { throw new IllegalArgumentException( "Cannot accept XYSeries that allow duplicate values. " + "Use XYSeries(seriesName, , false) constructor." ); } updateXPoints(series); this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Adds any unique x-values from 'series' to the dataset, and also adds any * x-values that are in the dataset but not in 'series' to the series. * * @param series the series (null not permitted). */ private void updateXPoints(XYSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' not permitted."); } HashSet seriesXPoints = new HashSet(); boolean savedState = this.propagateEvents; this.propagateEvents = false; for (int itemNo = 0; itemNo < series.getItemCount(); itemNo++) { Number xValue = series.getX(itemNo); seriesXPoints.add(xValue); if (!this.xPoints.contains(xValue)) { this.xPoints.add(xValue); int seriesCount = this.data.size(); for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) { XYSeries dataSeries = (XYSeries) this.data.get(seriesNo); if (!dataSeries.equals(series)) { dataSeries.add(xValue, null); } } } } Iterator iterator = this.xPoints.iterator(); while (iterator.hasNext()) { Number xPoint = (Number) iterator.next(); if (!seriesXPoints.contains(xPoint)) { series.add(xPoint, null); } } this.propagateEvents = savedState; } /** * Updates the x-values for all the series in the dataset. */ public void updateXPoints() { this.propagateEvents = false; for (int s = 0; s < this.data.size(); s++) { updateXPoints((XYSeries) this.data.get(s)); } if (this.autoPrune) { prune(); } this.propagateEvents = true; } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns the number of x values in the dataset. * * @return The number of x values in the dataset. */ public int getItemCount() { if (this.xPoints == null) { return 0; } else { return this.xPoints.size(); } } /** * Returns a series. * * @param series the series (zero-based index). * * @return The series (never null). */ public XYSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Index outside valid range."); } return (XYSeries) this.data.get(series); } /** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The key for a series. */ public Comparable getSeriesKey(int series) { // check arguments...delegated return getSeries(series).getKey(); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The number of items in the specified series. */ public int getItemCount(int series) { // check arguments...delegated return getSeries(series).getItemCount(); } /** * Returns the x-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value for the specified series and item. */ public Number getX(int series, int item) { XYSeries s = (XYSeries) this.data.get(series); XYDataItem dataItem = s.getDataItem(item); return dataItem.getX(); } /** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The starting X value. */ public Number getStartX(int series, int item) { return this.intervalDelegate.getStartX(series, item); } /** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The ending X value. */ public Number getEndX(int series, int item) { return this.intervalDelegate.getEndX(series, item); } /** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param index the index of the item of interest (zero-based). * * @return The y-value for the specified series and item (possibly * null). */ public Number getY(int series, int index) { XYSeries ts = (XYSeries) this.data.get(series); XYDataItem dataItem = ts.getDataItem(index); return dataItem.getY(); } /** * Returns the starting Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The starting Y value. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The ending Y value. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. */ public void removeAllSeries() { // Unregister the collection as a change listener to each series in // the collection. for (int i = 0; i < this.data.size(); i++) { XYSeries series = (XYSeries) this.data.get(i); series.removeChangeListener(this); } // Remove all the series from the collection and notify listeners. this.data.clear(); this.xPoints.clear(); fireDatasetChanged(); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). */ public void removeSeries(XYSeries series) { // check arguments... if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } // remove the series... if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); if (this.data.size() == 0) { this.xPoints.clear(); } fireDatasetChanged(); } } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (zero based index). */ public void removeSeries(int series) { // check arguments... if ((series < 0) || (series > getSeriesCount())) { throw new IllegalArgumentException("Index outside valid range."); } // fetch the series, remove the change listener, then remove the series. XYSeries s = (XYSeries) this.data.get(series); s.removeChangeListener(this); this.data.remove(series); if (this.data.size() == 0) { this.xPoints.clear(); } else if (this.autoPrune) { prune(); } fireDatasetChanged(); } /** * Removes the items from all series for a given x value. * * @param x the x-value. */ public void removeAllValuesForX(Number x) { if (x == null) { throw new IllegalArgumentException("Null 'x' argument."); } boolean savedState = this.propagateEvents; this.propagateEvents = false; for (int s = 0; s < this.data.size(); s++) { XYSeries series = (XYSeries) this.data.get(s); series.remove(x); } this.propagateEvents = savedState; this.xPoints.remove(x); fireDatasetChanged(); } /** * Returns true if all the y-values for the specified x-value * are null and false otherwise. * * @param x the x-value. * * @return A boolean. */ protected boolean canPrune(Number x) { for (int s = 0; s < this.data.size(); s++) { XYSeries series = (XYSeries) this.data.get(s); if (series.getY(series.indexOf(x)) != null) { return false; } } return true; } /** * Removes all x-values for which all the y-values are null. */ public void prune() { HashSet hs = (HashSet) this.xPoints.clone(); Iterator iterator = hs.iterator(); while (iterator.hasNext()) { Number x = (Number) iterator.next(); if (canPrune(x)) { removeAllValuesForX(x); } } } /** * This method receives notification when a series belonging to the dataset * changes. It responds by updating the x-points for the entire dataset * and sending a {@link DatasetChangeEvent} to all registered listeners. * * @param event information about the change. */ public void seriesChanged(SeriesChangeEvent event) { if (this.propagateEvents) { updateXPoints(); fireDatasetChanged(); } } /** * Tests this collection for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultTableXYDataset)) { return false; } DefaultTableXYDataset that = (DefaultTableXYDataset) obj; if (this.autoPrune != that.autoPrune) { return false; } if (this.propagateEvents != that.propagateEvents) { return false; } if (!this.intervalDelegate.equals(that.intervalDelegate)) { return false; } if (!ObjectUtilities.equal(this.data, that.data)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = (this.data != null ? this.data.hashCode() : 0); result = 29 * result + (this.xPoints != null ? this.xPoints.hashCode() : 0); result = 29 * result + (this.propagateEvents ? 1 : 0); result = 29 * result + (this.autoPrune ? 1 : 0); return result; } /** * Returns an independent copy of this dataset. * * @return A clone. * * @throws CloneNotSupportedException if there is some reason that cloning * cannot be performed. */ public Object clone() throws CloneNotSupportedException { DefaultTableXYDataset clone = (DefaultTableXYDataset) super.clone(); int seriesCount = this.data.size(); clone.data = new java.util.ArrayList(seriesCount); for (int i = 0; i < seriesCount; i++) { XYSeries series = (XYSeries) this.data.get(i); clone.data.add(series.clone()); } clone.intervalDelegate = new IntervalXYDelegate(clone); // need to configure the intervalDelegate to match the original clone.intervalDelegate.setFixedIntervalWidth(getIntervalWidth()); clone.intervalDelegate.setAutoWidth(isAutoWidth()); clone.intervalDelegate.setIntervalPositionFactor( getIntervalPositionFactor()); clone.updateXPoints(); return clone; } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { return this.intervalDelegate.getDomainLowerBound(includeInterval); } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { return this.intervalDelegate.getDomainUpperBound(includeInterval); } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { if (includeInterval) { return this.intervalDelegate.getDomainBounds(includeInterval); } else { return DatasetUtilities.iterateDomainBounds(this, includeInterval); } } /** * Returns the interval position factor. * * @return The interval position factor. */ public double getIntervalPositionFactor() { return this.intervalDelegate.getIntervalPositionFactor(); } /** * Sets the interval position factor. Must be between 0.0 and 1.0 inclusive. * If the factor is 0.5, the gap is in the middle of the x values. If it * is lesser than 0.5, the gap is farther to the left and if greater than * 0.5 it gets farther to the right. * * @param d the new interval position factor. */ public void setIntervalPositionFactor(double d) { this.intervalDelegate.setIntervalPositionFactor(d); fireDatasetChanged(); } /** * returns the full interval width. * * @return The interval width to use. */ public double getIntervalWidth() { return this.intervalDelegate.getIntervalWidth(); } /** * Sets the interval width to a fixed value, and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param d the new interval width (must be > 0). */ public void setIntervalWidth(double d) { this.intervalDelegate.setFixedIntervalWidth(d); fireDatasetChanged(); } /** * Returns whether the interval width is automatically calculated or not. * * @return A flag that determines whether or not the interval width is * automatically calculated. */ public boolean isAutoWidth() { return this.intervalDelegate.isAutoWidth(); } /** * Sets the flag that indicates whether the interval width is automatically * calculated or not. * * @param b a boolean. */ public void setAutoWidth(boolean b) { this.intervalDelegate.setAutoWidth(b); fireDatasetChanged(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultWindDataset.java0000644000175000017500000003422011173030414027261 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DefaultWindDataset.java * ----------------------- * (C) Copyright 2001-2008, by Achilleus Mantzios and Contributors. * * Original Author: Achilleus Mantzios; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 06-Feb-2002 : Version 1, based on code contributed by Achilleus * Mantzios (DG); * 05-May-2004 : Now extends AbstractXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; import org.jfree.util.PublicCloneable; /** * A default implementation of the {@link WindDataset} interface. */ public class DefaultWindDataset extends AbstractXYDataset implements WindDataset, PublicCloneable { /** The keys for the series. */ private List seriesKeys; /** Storage for the series data. */ private List allSeriesData; /** * Constructs a new, empty, dataset. Since there are currently no methods * to add data to an existing dataset, you should probably use a different * constructor. */ public DefaultWindDataset() { this.seriesKeys = new java.util.ArrayList(); this.allSeriesData = new java.util.ArrayList(); } /** * Constructs a dataset based on the specified data array. * * @param data the data (null not permitted). * * @throws NullPointerException if data is null. */ public DefaultWindDataset(Object[][][] data) { this(seriesNameListFromDataArray(data), data); } /** * Constructs a dataset based on the specified data array. * * @param seriesNames the names of the series (null not * permitted). * @param data the wind data. * * @throws NullPointerException if seriesNames is * null. */ public DefaultWindDataset(String[] seriesNames, Object[][][] data) { this(Arrays.asList(seriesNames), data); } /** * Constructs a dataset based on the specified data array. The array * can contain multiple series, each series can contain multiple items, * and each item is as follows: *
    *
  • data[series][item][0] - the date (either a * Date or a Number that is the milliseconds * since 1-Jan-1970);
  • *
  • data[series][item][1] - the wind direction (1 - 12, * like the numbers on a clock face);
  • *
  • data[series][item][2] - the wind force (1 - 12 on the * Beaufort scale)
  • *
* * @param seriesKeys the names of the series (null not * permitted). * @param data the wind dataset (null not permitted). * * @throws IllegalArgumentException if seriesKeys is * null. * @throws IllegalArgumentException if the number of series keys does not * match the number of series in the array. * @throws NullPointerException if data is null. */ public DefaultWindDataset(List seriesKeys, Object[][][] data) { if (seriesKeys == null) { throw new IllegalArgumentException("Null 'seriesKeys' argument."); } if (seriesKeys.size() != data.length) { throw new IllegalArgumentException("The number of series keys does " + "not match the number of series in the data array."); } this.seriesKeys = seriesKeys; int seriesCount = data.length; this.allSeriesData = new java.util.ArrayList(seriesCount); for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) { List oneSeriesData = new java.util.ArrayList(); int maxItemCount = data[seriesIndex].length; for (int itemIndex = 0; itemIndex < maxItemCount; itemIndex++) { Object xObject = data[seriesIndex][itemIndex][0]; if (xObject != null) { Number xNumber; if (xObject instanceof Number) { xNumber = (Number) xObject; } else { if (xObject instanceof Date) { Date xDate = (Date) xObject; xNumber = new Long(xDate.getTime()); } else { xNumber = new Integer(0); } } Number windDir = (Number) data[seriesIndex][itemIndex][1]; Number windForce = (Number) data[seriesIndex][itemIndex][2]; oneSeriesData.add(new WindDataItem(xNumber, windDir, windForce)); } } Collections.sort(oneSeriesData); this.allSeriesData.add(seriesIndex, oneSeriesData); } } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.allSeriesData.size(); } /** * Returns the number of items in a series. * * @param series the series (zero-based index). * * @return The item count. */ public int getItemCount(int series) { if (series < 0 || series >= getSeriesCount()) { throw new IllegalArgumentException("Invalid series index: " + series); } List oneSeriesData = (List) this.allSeriesData.get(series); return oneSeriesData.size(); } /** * Returns the key for a series. * * @param series the series (zero-based index). * * @return The series key. */ public Comparable getSeriesKey(int series) { if (series < 0 || series >= getSeriesCount()) { throw new IllegalArgumentException("Invalid series index: " + series); } return (Comparable) this.seriesKeys.get(series); } /** * Returns the x-value for one item within a series. This should represent * a point in time, encoded as milliseconds in the same way as * java.util.Date. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value for the item within the series. */ public Number getX(int series, int item) { List oneSeriesData = (List) this.allSeriesData.get(series); WindDataItem windItem = (WindDataItem) oneSeriesData.get(item); return windItem.getX(); } /** * Returns the y-value for one item within a series. This maps to the * {@link #getWindForce(int, int)} method and is implemented because * WindDataset is an extension of {@link XYDataset}. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value for the item within the series. */ public Number getY(int series, int item) { return getWindForce(series, item); } /** * Returns the wind direction for one item within a series. This is a * number between 0 and 12, like the numbers on an upside-down clock face. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The wind direction for the item within the series. */ public Number getWindDirection(int series, int item) { List oneSeriesData = (List) this.allSeriesData.get(series); WindDataItem windItem = (WindDataItem) oneSeriesData.get(item); return windItem.getWindDirection(); } /** * Returns the wind force for one item within a series. This is a number * between 0 and 12, as defined by the Beaufort scale. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The wind force for the item within the series. */ public Number getWindForce(int series, int item) { List oneSeriesData = (List) this.allSeriesData.get(series); WindDataItem windItem = (WindDataItem) oneSeriesData.get(item); return windItem.getWindForce(); } /** * Utility method for automatically generating series names. * * @param data the wind data (null not permitted). * * @return An array of Series N with N = { 1 .. data.length }. * * @throws NullPointerException if data is null. */ public static List seriesNameListFromDataArray(Object[][] data) { int seriesCount = data.length; List seriesNameList = new java.util.ArrayList(seriesCount); for (int i = 0; i < seriesCount; i++) { seriesNameList.add("Series " + (i + 1)); } return seriesNameList; } /** * Checks this WindDataset for equality with an arbitrary * object. This method returns true if and only if: *
    *
  • obj is not null;
  • *
  • obj is an instance of * DefaultWindDataset;
  • *
  • both datasets have the same number of series containing identical * values.
  • *
      * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DefaultWindDataset)) { return false; } DefaultWindDataset that = (DefaultWindDataset) obj; if (!this.seriesKeys.equals(that.seriesKeys)) { return false; } if (!this.allSeriesData.equals(that.allSeriesData)) { return false; } return true; } } /** * A wind data item. */ class WindDataItem implements Comparable, Serializable { /** The x-value. */ private Number x; /** The wind direction. */ private Number windDir; /** The wind force. */ private Number windForce; /** * Creates a new wind data item. * * @param x the x-value. * @param windDir the direction. * @param windForce the force. */ public WindDataItem(Number x, Number windDir, Number windForce) { this.x = x; this.windDir = windDir; this.windForce = windForce; } /** * Returns the x-value. * * @return The x-value. */ public Number getX() { return this.x; } /** * Returns the wind direction. * * @return The wind direction. */ public Number getWindDirection() { return this.windDir; } /** * Returns the wind force. * * @return The wind force. */ public Number getWindForce() { return this.windForce; } /** * Compares this item to another object. * * @param object the other object. * * @return An int that indicates the relative comparison. */ public int compareTo(Object object) { if (object instanceof WindDataItem) { WindDataItem item = (WindDataItem) object; if (this.x.doubleValue() > item.x.doubleValue()) { return 1; } else if (this.x.equals(item.x)) { return 0; } else { return -1; } } else { throw new ClassCastException("WindDataItem.compareTo(error)"); } } /** * Tests this WindDataItem for equality with an arbitrary * object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return false; } if (!(obj instanceof WindDataItem)) { return false; } WindDataItem that = (WindDataItem) obj; if (!this.x.equals(that.x)) { return false; } if (!this.windDir.equals(that.windDir)) { return false; } if (!this.windForce.equals(that.windForce)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultXYDataset.java0000644000175000017500000003170311173030414026723 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DefaultXYDataset.java * --------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jul-2006 : Version 1 (DG); * 02-Nov-2006 : Fixed a problem with adding a new series with the same key * as an existing series (see bug 1589392) (DG); * 25-Jan-2007 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.jfree.data.DomainOrder; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A default implementation of the {@link XYDataset} interface that stores * data values in arrays of double primitives. * * @since 1.0.2 */ public class DefaultXYDataset extends AbstractXYDataset implements XYDataset, PublicCloneable { /** * Storage for the series keys. This list must be kept in sync with the * seriesList. */ private List seriesKeys; /** * Storage for the series in the dataset. We use a list because the * order of the series is significant. This list must be kept in sync * with the seriesKeys list. */ private List seriesList; /** * Creates a new DefaultXYDataset instance, initially * containing no data. */ public DefaultXYDataset() { this.seriesKeys = new java.util.ArrayList(); this.seriesList = new java.util.ArrayList(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.seriesList.size(); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for the series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (Comparable) this.seriesKeys.get(series); } /** * Returns the index of the series with the specified key, or -1 if there * is no such series in the dataset. * * @param seriesKey the series key (null permitted). * * @return The index, or -1. */ public int indexOf(Comparable seriesKey) { return this.seriesKeys.indexOf(seriesKey); } /** * Returns the order of the domain (x-) values in the dataset. In this * implementation, we cannot guarantee that the x-values are ordered, so * this method returns DomainOrder.NONE. * * @return DomainOrder.NONE. */ public DomainOrder getDomainOrder() { return DomainOrder.NONE; } /** * Returns the number of items in the specified series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * specified range. */ public int getItemCount(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } double[][] seriesArray = (double[][]) this.seriesList.get(series); return seriesArray[0].length; } /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getX(int, int) */ public double getXValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[0][item]; } /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getXValue(int, int) */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getY(int, int) */ public double getYValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[1][item]; } /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getX(int, int) */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Adds a series or if a series with the same key already exists replaces * the data for that series, then sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param seriesKey the series key (null not permitted). * @param data the data (must be an array with length 2, containing two * arrays of equal length, the first containing the x-values and the * second containing the y-values). */ public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 2) { throw new IllegalArgumentException( "The 'data' array must have length == 2."); } if (data[0].length != data[1].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { // add a new series this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { // replace an existing series this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } /** * Removes a series from the dataset, then sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param seriesKey the series key (null not permitted). * */ public void removeSeries(Comparable seriesKey) { int seriesIndex = indexOf(seriesKey); if (seriesIndex >= 0) { this.seriesKeys.remove(seriesIndex); this.seriesList.remove(seriesIndex); notifyListeners(new DatasetChangeEvent(this, this)); } } /** * Tests this DefaultXYDataset instance for equality with an * arbitrary object. This method returns true if and only if: *
        *
      • obj is not null;
      • *
      • obj is an instance of * DefaultXYDataset;
      • *
      • both datasets have the same number of series, each containing * exactly the same values.
      • *
      * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultXYDataset)) { return false; } DefaultXYDataset that = (DefaultXYDataset) obj; if (!this.seriesKeys.equals(that.seriesKeys)) { return false; } for (int i = 0; i < this.seriesList.size(); i++) { double[][] d1 = (double[][]) this.seriesList.get(i); double[][] d2 = (double[][]) that.seriesList.get(i); double[] d1x = d1[0]; double[] d2x = d2[0]; if (!Arrays.equals(d1x, d2x)) { return false; } double[] d1y = d1[1]; double[] d2y = d2[1]; if (!Arrays.equals(d1y, d2y)) { return false; } } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result; result = this.seriesKeys.hashCode(); result = 29 * result + this.seriesList.hashCode(); return result; } /** * Creates an independent copy of this dataset. * * @return The cloned dataset. * * @throws CloneNotSupportedException if there is a problem cloning the * dataset (for instance, if a non-cloneable object is used for a * series key). */ public Object clone() throws CloneNotSupportedException { DefaultXYDataset clone = (DefaultXYDataset) super.clone(); clone.seriesKeys = new java.util.ArrayList(this.seriesKeys); clone.seriesList = new ArrayList(this.seriesList.size()); for (int i = 0; i < this.seriesList.size(); i++) { double[][] data = (double[][]) this.seriesList.get(i); double[] x = data[0]; double[] y = data[1]; double[] xx = new double[x.length]; double[] yy = new double[y.length]; System.arraycopy(x, 0, xx, 0, x.length); System.arraycopy(y, 0, yy, 0, y.length); clone.seriesList.add(i, new double[][] {xx, yy}); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/DefaultXYZDataset.java0000644000175000017500000003564511173030414027066 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DefaultXYZDataset.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-Jul-2006 : Version 1 (DG); * 06-Oct-2006 : Fixed API doc warnings (DG); * 02-Nov-2006 : Fixed a problem with adding a new series with the same key * as an existing series (see bug 1589392) (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.jfree.data.DomainOrder; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.PublicCloneable; /** * A default implementation of the {@link XYZDataset} interface that stores * data values in arrays of double primitives. * * @since 1.0.2 */ public class DefaultXYZDataset extends AbstractXYZDataset implements XYZDataset, PublicCloneable { /** * Storage for the series keys. This list must be kept in sync with the * seriesList. */ private List seriesKeys; /** * Storage for the series in the dataset. We use a list because the * order of the series is significant. This list must be kept in sync * with the seriesKeys list. */ private List seriesList; /** * Creates a new DefaultXYZDataset instance, initially * containing no data. */ public DefaultXYZDataset() { this.seriesKeys = new java.util.ArrayList(); this.seriesList = new java.util.ArrayList(); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.seriesList.size(); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for the series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (Comparable) this.seriesKeys.get(series); } /** * Returns the index of the series with the specified key, or -1 if there * is no such series in the dataset. * * @param seriesKey the series key (null permitted). * * @return The index, or -1. */ public int indexOf(Comparable seriesKey) { return this.seriesKeys.indexOf(seriesKey); } /** * Returns the order of the domain (x-) values in the dataset. In this * implementation, we cannot guarantee that the x-values are ordered, so * this method returns DomainOrder.NONE. * * @return DomainOrder.NONE. */ public DomainOrder getDomainOrder() { return DomainOrder.NONE; } /** * Returns the number of items in the specified series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * specified range. */ public int getItemCount(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } double[][] seriesArray = (double[][]) this.seriesList.get(series); return seriesArray[0].length; } /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getX(int, int) */ public double getXValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[0][item]; } /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getXValue(int, int) */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getY(int, int) */ public double getYValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[1][item]; } /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getX(int, int) */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Returns the z-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The z-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getZ(int, int) */ public double getZValue(int series, int item) { double[][] seriesData = (double[][]) this.seriesList.get(series); return seriesData[2][item]; } /** * Returns the z-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The z-value. * * @throws ArrayIndexOutOfBoundsException if series is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if item is not * within the specified range. * * @see #getZ(int, int) */ public Number getZ(int series, int item) { return new Double(getZValue(series, item)); } /** * Adds a series or if a series with the same key already exists replaces * the data for that series, then sends a {@link DatasetChangeEvent} to * all registered listeners. * * @param seriesKey the series key (null not permitted). * @param data the data (must be an array with length 3, containing three * arrays of equal length, the first containing the x-values, the * second containing the y-values and the third containing the * z-values). */ public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 3) { throw new IllegalArgumentException( "The 'data' array must have length == 3."); } if (data[0].length != data[1].length || data[0].length != data[2].length) { throw new IllegalArgumentException("The 'data' array must contain " + "three arrays all having the same length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { // add a new series this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { // replace an existing series this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } /** * Removes a series from the dataset, then sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param seriesKey the series key (null not permitted). * */ public void removeSeries(Comparable seriesKey) { int seriesIndex = indexOf(seriesKey); if (seriesIndex >= 0) { this.seriesKeys.remove(seriesIndex); this.seriesList.remove(seriesIndex); notifyListeners(new DatasetChangeEvent(this, this)); } } /** * Tests this DefaultXYDataset instance for equality with an * arbitrary object. This method returns true if and only if: *
        *
      • obj is not null;
      • *
      • obj is an instance of * DefaultXYDataset;
      • *
      • both datasets have the same number of series, each containing * exactly the same values.
      • *
      * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultXYZDataset)) { return false; } DefaultXYZDataset that = (DefaultXYZDataset) obj; if (!this.seriesKeys.equals(that.seriesKeys)) { return false; } for (int i = 0; i < this.seriesList.size(); i++) { double[][] d1 = (double[][]) this.seriesList.get(i); double[][] d2 = (double[][]) that.seriesList.get(i); double[] d1x = d1[0]; double[] d2x = d2[0]; if (!Arrays.equals(d1x, d2x)) { return false; } double[] d1y = d1[1]; double[] d2y = d2[1]; if (!Arrays.equals(d1y, d2y)) { return false; } double[] d1z = d1[2]; double[] d2z = d2[2]; if (!Arrays.equals(d1z, d2z)) { return false; } } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result; result = this.seriesKeys.hashCode(); result = 29 * result + this.seriesList.hashCode(); return result; } /** * Creates an independent copy of this dataset. * * @return The cloned dataset. * * @throws CloneNotSupportedException if there is a problem cloning the * dataset (for instance, if a non-cloneable object is used for a * series key). */ public Object clone() throws CloneNotSupportedException { DefaultXYZDataset clone = (DefaultXYZDataset) super.clone(); clone.seriesKeys = new java.util.ArrayList(this.seriesKeys); clone.seriesList = new ArrayList(this.seriesList.size()); for (int i = 0; i < this.seriesList.size(); i++) { double[][] data = (double[][]) this.seriesList.get(i); double[] x = data[0]; double[] y = data[1]; double[] z = data[2]; double[] xx = new double[x.length]; double[] yy = new double[y.length]; double[] zz = new double[z.length]; System.arraycopy(x, 0, xx, 0, x.length); System.arraycopy(y, 0, yy, 0, y.length); System.arraycopy(z, 0, zz, 0, z.length); clone.seriesList.add(i, new double[][] {xx, yy, zz}); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/IntervalXYDataset.java0000644000175000017500000001070711173030414027124 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * IntervalXYDataset.java * ---------------------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: Mark Watson (www.markwatson.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 18-Oct-2001 : Version 1, thanks to Mark Watson (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc (DG); * 06-May-2004 : Added methods that return double primitives (DG); * */ package org.jfree.data.xy; /** * An extension of the {@link XYDataset} interface that allows a range of data * to be defined for the X values, the Y values, or both the X and Y values. * This interface is used to support (among other things) bar plots against * numerical axes. */ public interface IntervalXYDataset extends XYDataset { /** * Returns the starting X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartX(int series, int item); /** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The start x-value. */ public double getStartXValue(int series, int item); /** * Returns the ending X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndX(int series, int item); /** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The end x-value. */ public double getEndXValue(int series, int item); /** * Returns the starting Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartY(int series, int item); /** * Returns the start y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The start y-value. */ public double getStartYValue(int series, int item); /** * Returns the ending Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndY(int series, int item); /** * Returns the end y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The end y-value. */ public double getEndYValue(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/IntervalXYDelegate.java0000644000175000017500000004110611173030414027246 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * IntervalXYDelegate.java * ----------------------- * (C) Copyright 2004-2009, by Andreas Schroeder and Contributors. * * Original Author: Andreas Schroeder; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 31-Mar-2004 : Version 1 (AS); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * 04-Nov-2004 : Added argument check for setIntervalWidth() method (DG); * 17-Nov-2004 : New methods to reflect changes in DomainInfo (DG); * 11-Jan-2005 : Removed deprecated methods in preparation for the 1.0.0 * release (DG); * 21-Feb-2005 : Made public and added equals() method (DG); * 06-Oct-2005 : Implemented DatasetChangeListener to recalculate * autoIntervalWidth (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 06-Mar-2009 : Implemented hashCode() (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import org.jfree.chart.HashUtilities; import org.jfree.data.DomainInfo; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.general.DatasetUtilities; import org.jfree.util.PublicCloneable; /** * A delegate that handles the specification or automatic calculation of the * interval surrounding the x-values in a dataset. This is used to extend * a regular {@link XYDataset} to support the {@link IntervalXYDataset} * interface. *

      * The decorator pattern was not used because of the several possibly * implemented interfaces of the decorated instance (e.g. * {@link TableXYDataset}, {@link RangeInfo}, {@link DomainInfo} etc.). *

      * The width can be set manually or calculated automatically. The switch * autoWidth allows to determine which behavior is used. The auto width * calculation tries to find the smallest gap between two x-values in the * dataset. If there is only one item in the series, the auto width * calculation fails and falls back on the manually set interval width (which * is itself defaulted to 1.0). */ public class IntervalXYDelegate implements DatasetChangeListener, DomainInfo, Serializable, Cloneable, PublicCloneable { /** For serialization. */ private static final long serialVersionUID = -685166711639592857L; /** * The dataset to enhance. */ private XYDataset dataset; /** * A flag to indicate whether the width should be calculated automatically. */ private boolean autoWidth; /** * A value between 0.0 and 1.0 that indicates the position of the x-value * within the interval. */ private double intervalPositionFactor; /** * The fixed interval width (defaults to 1.0). */ private double fixedIntervalWidth; /** * The automatically calculated interval width. */ private double autoIntervalWidth; /** * Creates a new delegate that. * * @param dataset the underlying dataset (null not permitted). */ public IntervalXYDelegate(XYDataset dataset) { this(dataset, true); } /** * Creates a new delegate for the specified dataset. * * @param dataset the underlying dataset (null not permitted). * @param autoWidth a flag that controls whether the interval width is * calculated automatically. */ public IntervalXYDelegate(XYDataset dataset, boolean autoWidth) { if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } this.dataset = dataset; this.autoWidth = autoWidth; this.intervalPositionFactor = 0.5; this.autoIntervalWidth = Double.POSITIVE_INFINITY; this.fixedIntervalWidth = 1.0; } /** * Returns true if the interval width is automatically * calculated, and false otherwise. * * @return A boolean. */ public boolean isAutoWidth() { return this.autoWidth; } /** * Sets the flag that indicates whether the interval width is automatically * calculated. If the flag is set to true, the interval is * recalculated. *

      * Note: recalculating the interval amounts to changing the data values * represented by the dataset. The calling dataset must fire an * appropriate {@link DatasetChangeEvent}. * * @param b a boolean. */ public void setAutoWidth(boolean b) { this.autoWidth = b; if (b) { this.autoIntervalWidth = recalculateInterval(); } } /** * Returns the interval position factor. * * @return The interval position factor. */ public double getIntervalPositionFactor() { return this.intervalPositionFactor; } /** * Sets the interval position factor. This controls how the interval is * aligned to the x-value. For a value of 0.5, the interval is aligned * with the x-value in the center. For a value of 0.0, the interval is * aligned with the x-value at the lower end of the interval, and for a * value of 1.0, the interval is aligned with the x-value at the upper * end of the interval. *

      * Note that changing the interval position factor amounts to changing the * data values represented by the dataset. Therefore, the dataset that is * using this delegate is responsible for generating the * appropriate {@link DatasetChangeEvent}. * * @param d the new interval position factor (in the range * 0.0 to 1.0 inclusive). */ public void setIntervalPositionFactor(double d) { if (d < 0.0 || 1.0 < d) { throw new IllegalArgumentException( "Argument 'd' outside valid range."); } this.intervalPositionFactor = d; } /** * Returns the fixed interval width. * * @return The fixed interval width. */ public double getFixedIntervalWidth() { return this.fixedIntervalWidth; } /** * Sets the fixed interval width and, as a side effect, sets the * autoWidth flag to false. *

      * Note that changing the interval width amounts to changing the data * values represented by the dataset. Therefore, the dataset * that is using this delegate is responsible for generating the * appropriate {@link DatasetChangeEvent}. * * @param w the width (negative values not permitted). */ public void setFixedIntervalWidth(double w) { if (w < 0.0) { throw new IllegalArgumentException("Negative 'w' argument."); } this.fixedIntervalWidth = w; this.autoWidth = false; } /** * Returns the interval width. This method will return either the * auto calculated interval width or the manually specified interval * width, depending on the {@link #isAutoWidth()} result. * * @return The interval width to use. */ public double getIntervalWidth() { if (isAutoWidth() && !Double.isInfinite(this.autoIntervalWidth)) { // everything is fine: autoWidth is on, and an autoIntervalWidth // was set. return this.autoIntervalWidth; } else { // either autoWidth is off or autoIntervalWidth was not set. return this.fixedIntervalWidth; } } /** * Returns the start value of the x-interval for an item within a series. * * @param series the series index. * @param item the item index. * * @return The start value of the x-interval (possibly null). * * @see #getStartXValue(int, int) */ public Number getStartX(int series, int item) { Number startX = null; Number x = this.dataset.getX(series, item); if (x != null) { startX = new Double(x.doubleValue() - (getIntervalPositionFactor() * getIntervalWidth())); } return startX; } /** * Returns the start value of the x-interval for an item within a series. * * @param series the series index. * @param item the item index. * * @return The start value of the x-interval. * * @see #getStartX(int, int) */ public double getStartXValue(int series, int item) { return this.dataset.getXValue(series, item) - getIntervalPositionFactor() * getIntervalWidth(); } /** * Returns the end value of the x-interval for an item within a series. * * @param series the series index. * @param item the item index. * * @return The end value of the x-interval (possibly null). * * @see #getEndXValue(int, int) */ public Number getEndX(int series, int item) { Number endX = null; Number x = this.dataset.getX(series, item); if (x != null) { endX = new Double(x.doubleValue() + ((1.0 - getIntervalPositionFactor()) * getIntervalWidth())); } return endX; } /** * Returns the end value of the x-interval for an item within a series. * * @param series the series index. * @param item the item index. * * @return The end value of the x-interval. * * @see #getEndX(int, int) */ public double getEndXValue(int series, int item) { return this.dataset.getXValue(series, item) + (1.0 - getIntervalPositionFactor()) * getIntervalWidth(); } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getLowerBound(); } return result; } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; } /** * Returns the range of the values in the dataset's domain, including * or excluding the interval around each x-value as specified. * * @param includeInterval a flag that determines whether or not the * x-interval should be taken into account. * * @return The range. */ public Range getDomainBounds(boolean includeInterval) { // first get the range without the interval, then expand it for the // interval width Range range = DatasetUtilities.findDomainBounds(this.dataset, false); if (includeInterval && range != null) { double lowerAdj = getIntervalWidth() * getIntervalPositionFactor(); double upperAdj = getIntervalWidth() - lowerAdj; range = new Range(range.getLowerBound() - lowerAdj, range.getUpperBound() + upperAdj); } return range; } /** * Handles events from the dataset by recalculating the interval if * necessary. * * @param e the event. */ public void datasetChanged(DatasetChangeEvent e) { // TODO: by coding the event with some information about what changed // in the dataset, we could make the recalculation of the interval // more efficient in some cases (for instance, if the change is // just an update to a y-value, then the x-interval doesn't need // updating)... if (this.autoWidth) { this.autoIntervalWidth = recalculateInterval(); } } /** * Recalculate the minimum width "from scratch". * * @return The minimum width. */ private double recalculateInterval() { double result = Double.POSITIVE_INFINITY; int seriesCount = this.dataset.getSeriesCount(); for (int series = 0; series < seriesCount; series++) { result = Math.min(result, calculateIntervalForSeries(series)); } return result; } /** * Calculates the interval width for a given series. * * @param series the series index. * * @return The interval width. */ private double calculateIntervalForSeries(int series) { double result = Double.POSITIVE_INFINITY; int itemCount = this.dataset.getItemCount(series); if (itemCount > 1) { double prev = this.dataset.getXValue(series, 0); for (int item = 1; item < itemCount; item++) { double x = this.dataset.getXValue(series, item); result = Math.min(result, x - prev); prev = x; } } return result; } /** * Tests the delegate for equality with an arbitrary object. The * equality test considers two delegates to be equal if they would * calculate the same intervals for any given dataset (for this reason, the * dataset itself is NOT included in the equality test, because it is just * a reference back to the current 'owner' of the delegate). * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof IntervalXYDelegate)) { return false; } IntervalXYDelegate that = (IntervalXYDelegate) obj; if (this.autoWidth != that.autoWidth) { return false; } if (this.intervalPositionFactor != that.intervalPositionFactor) { return false; } if (this.fixedIntervalWidth != that.fixedIntervalWidth) { return false; } return true; } /** * @return A clone of this delegate. * * @throws CloneNotSupportedException if the object cannot be cloned. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int hash = 5; hash = HashUtilities.hashCode(hash, this.autoWidth); hash = HashUtilities.hashCode(hash, this.intervalPositionFactor); hash = HashUtilities.hashCode(hash, this.fixedIntervalWidth); return hash; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/IntervalXYZDataset.java0000644000175000017500000000752111173030414027256 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * IntervalXYZDataset.java * ----------------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 31-Oct-2001 : Version 1 (DG); * */ package org.jfree.data.xy; /** * An extension of the {@link XYZDataset} interface that allows a range of data * to be defined for any of the X values, the Y values, and the Z values. */ public interface IntervalXYZDataset extends XYZDataset { /** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting X value for the specified series and item. */ public Number getStartXValue(int series, int item); /** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending X value for the specified series and item. */ public Number getEndXValue(int series, int item); /** * Returns the starting Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting Y value for the specified series and item. */ public Number getStartYValue(int series, int item); /** * Returns the ending Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending Y value for the specified series and item. */ public Number getEndYValue(int series, int item); /** * Returns the starting Z value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting Z value for the specified series and item. */ public Number getStartZValue(int series, int item); /** * Returns the ending Z value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending Z value for the specified series and item. */ public Number getEndZValue(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/MatrixSeries.java0000644000175000017500000001546511173030414026176 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * MatrixSeries.java * ----------------- * (C) Copyright 2003-2008, by Barak Naveh and Contributors. * * Original Author: Barak Naveh; * Contributor(s): David Gilbert (for Object Refinery Limited); * Zhitao Wang; * * Changes * ------- * 10-Jul-2003 : Version 1 contributed by Barak Naveh (DG); * 10-Feb-2004 : Fixed Checkstyle complaints (DG); * 21-May-2004 : Fixed bug 940188 - problem in getItemColumn() and * getItemRow() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 27-Nov-2006 : Fixed bug in equals() method (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import org.jfree.data.general.Series; /** * Represents a dense matrix M[i,j] where each Mij item of the matrix has a * value (default is 0). */ public class MatrixSeries extends Series implements Serializable { /** For serialization. */ private static final long serialVersionUID = 7934188527308315704L; /** Series matrix values */ protected double[][] data; /** * Constructs a new matrix series. *

      * By default, all matrix items are initialzed to 0. *

      * * @param name series name (null not permitted). * @param rows the number of rows. * @param columns the number of columns. */ public MatrixSeries(String name, int rows, int columns) { super(name); this.data = new double[rows][columns]; zeroAll(); } /** * Returns the number of columns in this matrix series. * * @return The number of columns in this matrix series. */ public int getColumnsCount() { return this.data[0].length; } /** * Return the matrix item at the specified index. Note that this method * creates a new Double instance every time it is called. * * @param itemIndex item index. * * @return The matrix item at the specified index. * * @see #get(int, int) */ public Number getItem(int itemIndex) { int i = getItemRow(itemIndex); int j = getItemColumn(itemIndex); Number n = new Double(get(i, j)); return n; } /** * Returns the column of the specified item. * * @param itemIndex the index of the item. * * @return The column of the specified item. */ public int getItemColumn(int itemIndex) { //assert itemIndex >= 0 && itemIndex < getItemCount(); return itemIndex % getColumnsCount(); } /** * Returns the number of items in the series. * * @return The item count. */ public int getItemCount() { return getRowCount() * getColumnsCount(); } /** * Returns the row of the specified item. * * @param itemIndex the index of the item. * * @return The row of the specified item. */ public int getItemRow(int itemIndex) { //assert itemIndex >= 0 && itemIndex < getItemCount(); return itemIndex / getColumnsCount(); } /** * Returns the number of rows in this matrix series. * * @return The number of rows in this matrix series. */ public int getRowCount() { return this.data.length; } /** * Returns the value of the specified item in this matrix series. * * @param i the row of the item. * @param j the column of the item. * * @return The value of the specified item in this matrix series. * * @see #getItem(int) * @see #update(int, int, double) */ public double get(int i, int j) { return this.data[i][j]; } /** * Updates the value of the specified item in this matrix series. * * @param i the row of the item. * @param j the column of the item. * @param mij the new value for the item. * * @see #get(int, int) */ public void update(int i, int j, double mij) { this.data[i][j] = mij; fireSeriesChanged(); } /** * Sets all matrix values to zero and sends a * {@link org.jfree.data.general.SeriesChangeEvent} to all registered * listeners. */ public void zeroAll() { int rows = getRowCount(); int columns = getColumnsCount(); for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { this.data[row][column] = 0.0; } } fireSeriesChanged(); } /** * Tests this object instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof MatrixSeries)) { return false; } MatrixSeries that = (MatrixSeries) obj; if (!(getRowCount() == that.getRowCount())) { return false; } if (!(getColumnsCount() == that.getColumnsCount())) { return false; } for (int r = 0; r < getRowCount(); r++) { for (int c = 0; c < getColumnsCount(); c++) { if (get(r, c) != that.get(r, c)) { return false; } } } return super.equals(obj); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/MatrixSeriesCollection.java0000644000175000017500000002427011173030414030204 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * MatrixSeriesCollection.java * --------------------------- * (C) Copyright 2003-2008, by Barak Naveh and Contributors. * * Original Author: Barak Naveh; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 10-Jul-2003 : Version 1 contributed by Barak Naveh (DG); * 05-May-2004 : Now extends AbstractXYZDataset (DG); * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 27-Nov-2006 : Added clone() override (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); */ package org.jfree.data.xy; import java.io.Serializable; import java.util.List; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * Represents a collection of {@link MatrixSeries} that can be used as a * dataset. * * @see org.jfree.data.xy.MatrixSeries */ public class MatrixSeriesCollection extends AbstractXYZDataset implements XYZDataset, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -3197705779242543945L; /** The series that are included in the collection. */ private List seriesList; /** * Constructs an empty dataset. */ public MatrixSeriesCollection() { this(null); } /** * Constructs a dataset and populates it with a single matrix series. * * @param series the time series. */ public MatrixSeriesCollection(MatrixSeries series) { this.seriesList = new java.util.ArrayList(); if (series != null) { this.seriesList.add(series); series.addChangeListener(this); } } /** * Returns the number of items in the specified series. * * @param seriesIndex zero-based series index. * * @return The number of items in the specified series. */ public int getItemCount(int seriesIndex) { return getSeries(seriesIndex).getItemCount(); } /** * Returns the series having the specified index. * * @param seriesIndex zero-based series index. * * @return The series. * * @throws IllegalArgumentException */ public MatrixSeries getSeries(int seriesIndex) { if ((seriesIndex < 0) || (seriesIndex > getSeriesCount())) { throw new IllegalArgumentException("Index outside valid range."); } MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); return series; } /** * Returns the number of series in the collection. * * @return The number of series in the collection. */ public int getSeriesCount() { return this.seriesList.size(); } /** * Returns the key for a series. * * @param seriesIndex zero-based series index. * * @return The key for a series. */ public Comparable getSeriesKey(int seriesIndex) { return getSeries(seriesIndex).getKey(); } /** * Returns the j index value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex zero-based series index. * @param itemIndex zero-based item index. * * @return The j index value for the specified matrix item. * * @see org.jfree.data.xy.XYDataset#getXValue(int, int) */ public Number getX(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); int x = series.getItemColumn(itemIndex); return new Integer(x); // I know it's bad to create object. better idea? } /** * Returns the i index value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex zero-based series index. * @param itemIndex zero-based item index. * * @return The i index value for the specified matrix item. * * @see org.jfree.data.xy.XYDataset#getYValue(int, int) */ public Number getY(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); int y = series.getItemRow(itemIndex); return new Integer(y); // I know it's bad to create object. better idea? } /** * Returns the Mij item value of the specified Mij matrix item in the * specified matrix series. * * @param seriesIndex the series (zero-based index). * @param itemIndex zero-based item index. * * @return The Mij item value for the specified matrix item. * * @see org.jfree.data.xy.XYZDataset#getZValue(int, int) */ public Number getZ(int seriesIndex, int itemIndex) { MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); Number z = series.getItem(itemIndex); return z; } /** * Adds a series to the collection. *

      * Notifies all registered listeners that the dataset has changed. *

      * * @param series the series. * * @throws IllegalArgumentException */ public void addSeries(MatrixSeries series) { // check arguments... if (series == null) { throw new IllegalArgumentException("Cannot add null series."); } // FIXME: Check that there isn't already a series with the same key // add the series... this.seriesList.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Tests this collection for equality with an arbitrary object. * * @param obj the object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj instanceof MatrixSeriesCollection) { MatrixSeriesCollection c = (MatrixSeriesCollection) obj; return ObjectUtilities.equal(this.seriesList, c.seriesList); } return false; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return (this.seriesList != null ? this.seriesList.hashCode() : 0); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem. */ public Object clone() throws CloneNotSupportedException { MatrixSeriesCollection clone = (MatrixSeriesCollection) super.clone(); clone.seriesList = (List) ObjectUtilities.deepClone(this.seriesList); return clone; } /** * Removes all the series from the collection. *

      * Notifies all registered listeners that the dataset has changed. *

      */ public void removeAllSeries() { // Unregister the collection as a change listener to each series in // the collection. for (int i = 0; i < this.seriesList.size(); i++) { MatrixSeries series = (MatrixSeries) this.seriesList.get(i); series.removeChangeListener(this); } // Remove all the series from the collection and notify listeners. this.seriesList.clear(); fireDatasetChanged(); } /** * Removes a series from the collection. *

      * Notifies all registered listeners that the dataset has changed. *

      * * @param series the series. * * @throws IllegalArgumentException */ public void removeSeries(MatrixSeries series) { // check arguments... if (series == null) { throw new IllegalArgumentException("Cannot remove null series."); } // remove the series... if (this.seriesList.contains(series)) { series.removeChangeListener(this); this.seriesList.remove(series); fireDatasetChanged(); } } /** * Removes a series from the collection. *

      * Notifies all registered listeners that the dataset has changed. * * @param seriesIndex the series (zero based index). * * @throws IllegalArgumentException */ public void removeSeries(int seriesIndex) { // check arguments... if ((seriesIndex < 0) || (seriesIndex > getSeriesCount())) { throw new IllegalArgumentException("Index outside valid range."); } // fetch the series, remove the change listener, then remove the series. MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); series.removeChangeListener(this); this.seriesList.remove(seriesIndex); fireDatasetChanged(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/NormalizedMatrixSeries.java0000644000175000017500000001124311173030414030211 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * NormalizedMatrixSeries.java * --------------------------- * (C) Copyright 2003-2008, by Barak Naveh and Contributors. * * Original Author: Barak Naveh; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 10-Jul-2003 : Version 1 contributed by Barak Naveh (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.xy; /** * Represents a dense normalized matrix M[i,j] where each Mij item of the * matrix has a value (default is 0). When a matrix item is observed using * getItem method, it is normalized, that is, divided by the * total sum of all items. It can be also be scaled by setting a scale factor. */ public class NormalizedMatrixSeries extends MatrixSeries { /** The default scale factor. */ public static final double DEFAULT_SCALE_FACTOR = 1.0; /** * A factor that multiplies each item in this series when observed using * getItem method. */ private double m_scaleFactor = DEFAULT_SCALE_FACTOR; /** The sum of all items in this matrix */ private double m_totalSum; /** * Constructor for NormalizedMatrixSeries. * * @param name the series name. * @param rows the number of rows. * @param columns the number of columns. */ public NormalizedMatrixSeries(String name, int rows, int columns) { super(name, rows, columns); /* * we assum super is always initialized to all-zero matrix, so the * total sum should be 0 upon initialization. However, we set it to * Double.MIN_VALUE to get the same effect and yet avoid division by 0 * upon initialization. */ this.m_totalSum = Double.MIN_VALUE; } /** * Returns an item. * * @param itemIndex the index. * * @return The value. * * @see org.jfree.data.xy.MatrixSeries#getItem(int) */ public Number getItem(int itemIndex) { int i = getItemRow(itemIndex); int j = getItemColumn(itemIndex); double mij = get(i, j) * this.m_scaleFactor; Number n = new Double(mij / this.m_totalSum); return n; } /** * Sets the factor that multiplies each item in this series when observed * using getItem mehtod. * * @param factor new factor to set. * * @see #DEFAULT_SCALE_FACTOR */ public void setScaleFactor(double factor) { this.m_scaleFactor = factor; // FIXME: this should generate a series change event } /** * Returns the factor that multiplies each item in this series when * observed using getItem mehtod. * * @return The factor */ public double getScaleFactor() { return this.m_scaleFactor; } /** * Updates the value of the specified item in this matrix series. * * @param i the row of the item. * @param j the column of the item. * @param mij the new value for the item. * * @see #get(int, int) */ public void update(int i, int j, double mij) { this.m_totalSum -= get(i, j); this.m_totalSum += mij; super.update(i, j, mij); } /** * @see org.jfree.data.xy.MatrixSeries#zeroAll() */ public void zeroAll() { this.m_totalSum = 0; super.zeroAll(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/OHLCDataItem.java0000644000175000017500000001350611173030414025707 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * OHLCDataItem.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Dec-2003 : Version 1 (DG); * 29-Apr-2005 : Added equals() method (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.Date; /** * Represents a single (open-high-low-close) data item in * an {@link DefaultOHLCDataset}. This data item is commonly used * to summarise the trading activity of a financial commodity for * a fixed period (most often one day). */ public class OHLCDataItem implements Comparable, Serializable { /** For serialization. */ private static final long serialVersionUID = 7753817154401169901L; /** The date. */ private Date date; /** The open value. */ private Number open; /** The high value. */ private Number high; /** The low value. */ private Number low; /** The close value. */ private Number close; /** The trading volume (number of shares, contracts or whatever). */ private Number volume; /** * Creates a new item. * * @param date the date (null not permitted). * @param open the open value. * @param high the high value. * @param low the low value. * @param close the close value. * @param volume the volume. */ public OHLCDataItem(Date date, double open, double high, double low, double close, double volume) { if (date == null) { throw new IllegalArgumentException("Null 'date' argument."); } this.date = date; this.open = new Double(open); this.high = new Double(high); this.low = new Double(low); this.close = new Double(close); this.volume = new Double(volume); } /** * Returns the date that the data item relates to. * * @return The date (never null). */ public Date getDate() { return this.date; } /** * Returns the open value. * * @return The open value. */ public Number getOpen() { return this.open; } /** * Returns the high value. * * @return The high value. */ public Number getHigh() { return this.high; } /** * Returns the low value. * * @return The low value. */ public Number getLow() { return this.low; } /** * Returns the close value. * * @return The close value. */ public Number getClose() { return this.close; } /** * Returns the volume. * * @return The volume. */ public Number getVolume() { return this.volume; } /** * Checks this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof OHLCDataItem)) { return false; } OHLCDataItem that = (OHLCDataItem) obj; if (!this.date.equals(that.date)) { return false; } if (!this.high.equals(that.high)) { return false; } if (!this.low.equals(that.low)) { return false; } if (!this.open.equals(that.open)) { return false; } if (!this.close.equals(that.close)) { return false; } return true; } /** * Compares this object with the specified object for order. Returns a * negative integer, zero, or a positive integer as this object is less * than, equal to, or greater than the specified object. * * @param object the object to compare to. * * @return A negative integer, zero, or a positive integer as this object * is less than, equal to, or greater than the specified object. */ public int compareTo(Object object) { if (object instanceof OHLCDataItem) { OHLCDataItem item = (OHLCDataItem) object; return this.date.compareTo(item.date); } else { throw new ClassCastException("OHLCDataItem.compareTo()."); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/OHLCDataset.java0000644000175000017500000001217311173030414025603 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * OHLCDataset.java * ---------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Sylvain Vieujot; * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Updated header info (DG); * 16-Oct-2001 : Moved to package com.jrefinery.data.* (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 05-Feb-2002 : Added getVolumeValue() method, as requested by Sylvain * Vieujot (DG); * 05-May-2004 : Added methods that return double primitives (DG); * 26-Jul-2004 : Switched names of methods that return Number vs * primitives (DG); * 06-Sep-2004 : Renamed HighLowDataset --> OHLCDataset (DG); * */ package org.jfree.data.xy; /** * An interface that defines data in the form of (x, high, low, open, close) * tuples. */ public interface OHLCDataset extends XYDataset { /** * Returns the high-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getHigh(int series, int item); /** * Returns the high-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The high-value. */ public double getHighValue(int series, int item); /** * Returns the low-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getLow(int series, int item); /** * Returns the low-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The low-value. */ public double getLowValue(int series, int item); /** * Returns the open-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getOpen(int series, int item); /** * Returns the open-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The open-value. */ public double getOpenValue(int series, int item); /** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getClose(int series, int item); /** * Returns the close-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The close-value. */ public double getCloseValue(int series, int item); /** * Returns the volume for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getVolume(int series, int item); /** * Returns the volume-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The volume-value. */ public double getVolumeValue(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/TableXYDataset.java0000644000175000017500000000435211173030414026366 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * TableXYDataset.java * ------------------- * (C) Copyright 2000-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 22-Sep-2003 : Changed to be an interface. Previous functionality moved to * DefaultTableXYDataset; * 16-Feb-2004 : Updated Javadocs (DG); * */ package org.jfree.data.xy; /** * A dataset containing one or more data series containing (x, y) data items, * where all series in the dataset share the same set of x-values. This is a * restricted form of the {@link XYDataset} interface (which allows independent * x-values between series). This is used primarily by the * {@link org.jfree.chart.renderer.xy.StackedXYAreaRenderer}. */ public interface TableXYDataset extends XYDataset { /** * Returns the number of items every series. * * @return The item count. */ public int getItemCount(); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/Vector.java0000644000175000017500000000744711173030414025022 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * Vector.java * ----------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Added getLength() and getAngle() methods, thanks to * matinh (DG); * 25-May-2007 : Moved from experimental to the main source tree (DG); * */ package org.jfree.data.xy; import java.io.Serializable; /** * A vector. * * @since 1.0.6 */ public class Vector implements Serializable { /** The vector x. */ private double x; /** The vector y. */ private double y; /** * Creates a new instance of Vector. * * @param x the x-component. * @param y the y-component. */ public Vector(double x, double y) { this.x = x; this.y = y; } /** * Returns the x-value. * * @return The x-value. */ public double getX() { return this.x; } /** * Returns the y-value. * * @return The y-value. */ public double getY() { return this.y; } /** * Returns the length of the vector. * * @return The vector length. */ public double getLength() { return Math.sqrt((this.x * this.x) + (this.y * this.y)); } /** * Returns the angle of the vector. * * @return The angle of the vector. */ public double getAngle() { return Math.atan2(this.y, this.x); } /** * Tests this vector for equality with an arbitrary object. * * @param obj the object (null not permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Vector)) { return false; } Vector that = (Vector) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/VectorDataItem.java0000644000175000017500000000715111173030414026423 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * VectorDataItem.java * ------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Added getVector(), renamed getDeltaX() --> getVectorX(), * and likewise for getDeltaY() (DG); * 25-May-2007 : Moved from experimental to the main source tree (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; /** * A data item representing data in the form (x, y, deltaX, deltaY), intended * for use by the {@link VectorSeries} class. * * @since 1.0.6 */ public class VectorDataItem extends ComparableObjectItem { /** * Creates a new instance of YIntervalItem. * * @param x the x-value. * @param y the y-value. * @param deltaX the vector x. * @param deltaY the vector y. */ public VectorDataItem(double x, double y, double deltaX, double deltaY) { super(new XYCoordinate(x, y), new Vector(deltaX, deltaY)); } /** * Returns the x-value. * * @return The x-value (never null). */ public double getXValue() { XYCoordinate xy = (XYCoordinate) getComparable(); return xy.getX(); } /** * Returns the y-value. * * @return The y-value. */ public double getYValue() { XYCoordinate xy = (XYCoordinate) getComparable(); return xy.getY(); } /** * Returns the vector. * * @return The vector (possibly null). */ public Vector getVector() { return (Vector) getObject(); } /** * Returns the x-component for the vector. * * @return The x-component. */ public double getVectorX() { Vector vi = (Vector) getObject(); if (vi != null) { return vi.getX(); } else { return Double.NaN; } } /** * Returns the y-component for the vector. * * @return The y-component. */ public double getVectorY() { Vector vi = (Vector) getObject(); if (vi != null) { return vi.getY(); } else { return Double.NaN; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/VectorSeries.java0000644000175000017500000001253311173030414026165 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * VectorSeries.java * ----------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Renamed getDeltaXValue() --> getVectorXValue(), and likewise * for getDeltaYValue() (DG); * 25-May-2007 : Added remove(int) and clear() methods, and moved from the * experimental to the main source tree (DG); * 27-Nov-2007 : Removed redundant clear() method (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; import org.jfree.data.ComparableObjectSeries; import org.jfree.data.general.SeriesChangeEvent; /** * A list of (x,y, deltaX, deltaY) data items. * * @since 1.0.6 * * @see VectorSeriesCollection */ public class VectorSeries extends ComparableObjectSeries { /** * Creates a new empty series. * * @param key the series key (null not permitted). */ public VectorSeries(Comparable key) { this(key, false, true); } /** * Constructs a new series that contains no data. You can specify * whether or not duplicate x-values are allowed for the series. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. * @param allowDuplicateXValues a flag that controls whether duplicate * x-values are allowed. */ public VectorSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key, autoSort, allowDuplicateXValues); } /** * Adds a data item to the series. * * @param x the x-value. * @param y the y-value. * @param deltaX the vector x. * @param deltaY the vector y. */ public void add(double x, double y, double deltaX, double deltaY) { super.add(new VectorDataItem(x, y, deltaX, deltaY), true); } /** * Removes the item at the specified index and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the index. * * @return The item removed. */ public ComparableObjectItem remove(int index) { VectorDataItem result = (VectorDataItem) this.data.remove(index); fireSeriesChanged(); return result; } /** * Returns the x-value for the specified item. * * @param index the item index. * * @return The x-value. */ public double getXValue(int index) { VectorDataItem item = (VectorDataItem) this.getDataItem(index); return item.getXValue(); } /** * Returns the y-value for the specified item. * * @param index the item index. * * @return The y-value. */ public double getYValue(int index) { VectorDataItem item = (VectorDataItem) getDataItem(index); return item.getYValue(); } /** * Returns the x-component of the vector for an item in the series. * * @param index the item index. * * @return The x-component of the vector. */ public double getVectorXValue(int index) { VectorDataItem item = (VectorDataItem) getDataItem(index); return item.getVectorX(); } /** * Returns the y-component of the vector for an item in the series. * * @param index the item index. * * @return The y-component of the vector. */ public double getVectorYValue(int index) { VectorDataItem item = (VectorDataItem) getDataItem(index); return item.getVectorY(); } /** * Returns the data item at the specified index. * * @param index the item index. * * @return The data item. */ public ComparableObjectItem getDataItem(int index) { // overridden to make public return super.getDataItem(index); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/VectorSeriesCollection.java0000644000175000017500000002454411173030414030206 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * VectorSeriesCollection.java * --------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Added indexOf(), removeSeries() and removeAllSeries() * methods (DG); * 25-May-2007 : Moved from experimental to the main source tree (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A collection of {@link VectorSeries} objects. * * @since 1.0.6 */ public class VectorSeriesCollection extends AbstractXYDataset implements VectorXYDataset, PublicCloneable, Serializable { /** Storage for the data series. */ private List data; /** * Creates a new instance of VectorSeriesCollection. */ public VectorSeriesCollection() { this.data = new java.util.ArrayList(); } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(VectorSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Removes the specified series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). * * @return A boolean indicating whether the series has actually been * removed. */ public boolean removeSeries(VectorSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } boolean removed = this.data.remove(series); if (removed) { series.removeChangeListener(this); fireDatasetChanged(); } return removed; } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. */ public void removeAllSeries() { // deregister the collection as a change listener to each series in the // collection for (int i = 0; i < this.data.size(); i++) { VectorSeries series = (VectorSeries) this.data.get(i); series.removeChangeListener(this); } // remove all the series from the collection and notify listeners. this.data.clear(); fireDatasetChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public VectorSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (VectorSeries) this.data.get(series); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for a series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Returns the index of the specified series, or -1 if that series is not * present in the dataset. * * @param series the series (null not permitted). * * @return The series index. */ public int indexOf(VectorSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } return this.data.indexOf(series); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public int getItemCount(int series) { // defer argument checking return getSeries(series).getItemCount(); } /** * Returns the x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public double getXValue(int series, int item) { VectorSeries s = (VectorSeries) this.data.get(series); VectorDataItem di = (VectorDataItem) s.getDataItem(item); return di.getXValue(); } /** * Returns the x-value for an item within a series. Note that this method * creates a new {@link Double} instance every time it is called---use * {@link #getXValue(int, int)} instead, if possible. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); } /** * Returns the y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The y-value. */ public double getYValue(int series, int item) { VectorSeries s = (VectorSeries) this.data.get(series); VectorDataItem di = (VectorDataItem) s.getDataItem(item); return di.getYValue(); } /** * Returns the y-value for an item within a series. Note that this method * creates a new {@link Double} instance every time it is called---use * {@link #getYValue(int, int)} instead, if possible. * * @param series the series index. * @param item the item index. * * @return The y-value. */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Returns the vector for an item in a series. * * @param series the series index. * @param item the item index. * * @return The vector (possibly null). */ public Vector getVector(int series, int item) { VectorSeries s = (VectorSeries) this.data.get(series); VectorDataItem di = (VectorDataItem) s.getDataItem(item); return di.getVector(); } /** * Returns the x-component of the vector for an item in a series. * * @param series the series index. * @param item the item index. * * @return The x-component of the vector. */ public double getVectorXValue(int series, int item) { VectorSeries s = (VectorSeries) this.data.get(series); VectorDataItem di = (VectorDataItem) s.getDataItem(item); return di.getVectorX(); } /** * Returns the y-component of the vector for an item in a series. * * @param series the series index. * @param item the item index. * * @return The y-component of the vector. */ public double getVectorYValue(int series, int item) { VectorSeries s = (VectorSeries) this.data.get(series); VectorDataItem di = (VectorDataItem) s.getDataItem(item); return di.getVectorY(); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof VectorSeriesCollection)) { return false; } VectorSeriesCollection that = (VectorSeriesCollection) obj; return ObjectUtilities.equal(this.data, that.data); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem. */ public Object clone() throws CloneNotSupportedException { VectorSeriesCollection clone = (VectorSeriesCollection) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/VectorXYDataset.java0000644000175000017500000000621211173030414026576 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * VectorXYDataset.java * -------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Renamed getDeltaXValue() as getVectorXValue(), and likewise * for getDeltaYValue(), and replaced getDeltaX()/getDeltaY() * with getVector() (DG); * 25-May-2007 : Moved from experimental to the main source tree (DG); * */ package org.jfree.data.xy; /** * An extension of the {@link XYDataset} interface that allows a vector to be * defined at a specific (x, y) location. * * @since 1.0.6 */ public interface VectorXYDataset extends XYDataset { /** * Returns the x-component of the vector for an item in a series. * * @param series the series index. * @param item the item index. * * @return The x-component of the vector. */ public double getVectorXValue(int series, int item); /** * Returns the y-component of the vector for an item in a series. * * @param series the series index. * @param item the item index. * * @return The y-component of the vector. */ public double getVectorYValue(int series, int item); /** * Returns the vector for an item in a series. Depending on the particular * dataset implementation, this may involve creating a new {@link Vector} * instance --- if you are just interested in the x and y components, * use the {@link #getVectorXValue(int, int)} and * {@link #getVectorYValue(int, int)} methods instead. * * @param series the series index. * @param item the item index. * * @return The vector (possibly null). */ public Vector getVector(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/WindDataset.java0000644000175000017500000000537011173030414025760 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * WindDataset.java * ---------------- * (C) Copyright 2001-2008, by Achilleus Mantzios and Contributors. * * Original Author: Achilleus Mantzios; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 06-Feb-2002 : Version 1, based on code contributed by Achilleus * Mantzios (DG); * */ package org.jfree.data.xy; /** * Interface for a dataset that supplies wind intensity and direction values * observed at various points in time. */ public interface WindDataset extends XYDataset { /** * Returns the wind direction (should be in the range 0 to 12, * corresponding to the positions on an upside-down clock face). * * @param series the series (in the range 0 to * getSeriesCount() - 1). * @param item the item (in the range 0 to * getItemCount(series) - 1). * * @return The wind direction. */ public Number getWindDirection(int series, int item); /** * Returns the wind force on the Beaufort scale (0 to 12). See: *

      * http://en.wikipedia.org/wiki/Beaufort_scale * * @param series the series (in the range 0 to * getSeriesCount() - 1). * @param item the item (in the range 0 to * getItemCount(series) - 1). * * @return The wind force. */ public Number getWindForce(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XIntervalDataItem.java0000644000175000017500000000663211173030414027100 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XIntervalDataItem.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; /** * An item representing data in the form (x, x-low, x-high, y). * * @since 1.0.3 */ public class XIntervalDataItem extends ComparableObjectItem { /** * Creates a new instance of XIntervalDataItem. * * @param x the x-value. * @param xLow the lower bound of the x-interval. * @param xHigh the upper bound of the x-interval. * @param y the y-value. */ public XIntervalDataItem(double x, double xLow, double xHigh, double y) { super(new Double(x), new YWithXInterval(y, xLow, xHigh)); } /** * Returns the x-value. * * @return The x-value (never null). */ public Number getX() { return (Number) getComparable(); } /** * Returns the y-value. * * @return The y-value. */ public double getYValue() { YWithXInterval interval = (YWithXInterval) getObject(); if (interval != null) { return interval.getY(); } else { return Double.NaN; } } /** * Returns the lower bound of the x-interval. * * @return The lower bound of the x-interval. */ public double getXLowValue() { YWithXInterval interval = (YWithXInterval) getObject(); if (interval != null) { return interval.getXLow(); } else { return Double.NaN; } } /** * Returns the upper bound of the x-interval. * * @return The upper bound of the x-interval. */ public double getXHighValue() { YWithXInterval interval = (YWithXInterval) getObject(); if (interval != null) { return interval.getXHigh(); } else { return Double.NaN; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XIntervalSeries.java0000644000175000017500000001173211173030414026637 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XIntervalSeries.java * -------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 11-Apr-2008 : Added getXLowValue() and getXHighValue() methods (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; import org.jfree.data.ComparableObjectSeries; /** * A list of (x, x-low, x-high, y) data items. * * @since 1.0.3 * * @see XIntervalSeriesCollection */ public class XIntervalSeries extends ComparableObjectSeries { /** * Creates a new empty series. By default, items added to the series will * be sorted into ascending order by x-value, and duplicate x-values will * be allowed (these defaults can be modified with another constructor. * * @param key the series key (null not permitted). */ public XIntervalSeries(Comparable key) { this(key, true, true); } /** * Constructs a new xy-series that contains no data. You can specify * whether or not duplicate x-values are allowed for the series. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. * @param allowDuplicateXValues a flag that controls whether duplicate * x-values are allowed. */ public XIntervalSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key, autoSort, allowDuplicateXValues); } /** * Adds a data item to the series. * * @param x the x-value. * @param y the y-value. * @param xLow the lower bound of the y-interval. * @param xHigh the upper bound of the y-interval. */ public void add(double x, double xLow, double xHigh, double y) { super.add(new XIntervalDataItem(x, xLow, xHigh, y), true); } /** * Returns the x-value for the specified item. * * @param index the item index. * * @return The x-value (never null). */ public Number getX(int index) { XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); return item.getX(); } /** * Returns the lower bound of the x-interval for the specified item. * * @param index the item index. * * @return The lower bound of the x-interval. * * @since 1.0.10 */ public double getXLowValue(int index) { XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); return item.getXLowValue(); } /** * Returns the upper bound of the x-interval for the specified item. * * @param index the item index. * * @return The upper bound of the x-interval. * * @since 1.0.10 */ public double getXHighValue(int index) { XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); return item.getXHighValue(); } /** * Returns the y-value for the specified item. * * @param index the item index. * * @return The y-value. */ public double getYValue(int index) { XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); return item.getYValue(); } /** * Returns the data item at the specified index. * * @param index the item index. * * @return The data item. */ public ComparableObjectItem getDataItem(int index) { return super.getDataItem(index); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XIntervalSeriesCollection.java0000644000175000017500000002600311173030414030650 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * XIntervalSeriesCollection.java * ------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 27-Nov-2006 : Added clone() override (DG); * 18-Jan-2008 : Added removeSeries() and removeAllSeries() methods (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A collection of {@link XIntervalSeries} objects. * * @since 1.0.3 * * @see XIntervalSeries */ public class XIntervalSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, PublicCloneable, Serializable { /** Storage for the data series. */ private List data; /** * Creates a new instance of XIntervalSeriesCollection. */ public XIntervalSeriesCollection() { this.data = new java.util.ArrayList(); } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(XIntervalSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public XIntervalSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (XIntervalSeries) this.data.get(series); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for a series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public int getItemCount(int series) { // defer argument checking return getSeries(series).getItemCount(); } /** * Returns the x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getX(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); return di.getX(); } /** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartXValue(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); return s.getXLowValue(item); } /** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public double getEndXValue(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); return s.getXHighValue(item); } /** * Returns the y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getYValue(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); return s.getYValue(item); } /** * Returns the y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The y-value. */ public Number getY(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); return new Double(di.getYValue()); } /** * Returns the start x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getStartX(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); return new Double(di.getXLowValue()); } /** * Returns the end x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getEndX(int series, int item) { XIntervalSeries s = (XIntervalSeries) this.data.get(series); XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); return new Double(di.getXHighValue()); } /** * Returns the start y-value for an item within a series. This method * maps directly to {@link #getY(int, int)}. * * @param series the series index. * @param item the item index. * * @return The start y-value. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the end y-value for an item within a series. This method * maps directly to {@link #getY(int, int)}. * * @param series the series index. * @param item the item index. * * @return The end y-value. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * * @since 1.0.10 */ public void removeSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds."); } XIntervalSeries ts = (XIntervalSeries) this.data.get(series); ts.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). * * @since 1.0.10 */ public void removeSeries(XIntervalSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.10 */ public void removeAllSeries() { // Unregister the collection as a change listener to each series in // the collection. for (int i = 0; i < this.data.size(); i++) { XIntervalSeries series = (XIntervalSeries) this.data.get(i); series.removeChangeListener(this); } this.data.clear(); fireDatasetChanged(); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XIntervalSeriesCollection)) { return false; } XIntervalSeriesCollection that = (XIntervalSeriesCollection) obj; return ObjectUtilities.equal(this.data, that.data); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem. */ public Object clone() throws CloneNotSupportedException { XIntervalSeriesCollection clone = (XIntervalSeriesCollection) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYBarDataset.java0000644000175000017500000002643611173030414026052 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * XYBarDataset.java * ----------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Mar-2004 : Version 1 (DG); * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 25-Jan-2007 : Added some accessor methods, plus new equals() and clone() * overrides (DG); * 30-Jan-2007 : Added method overrides to prevent unnecessary object * creation (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.util.PublicCloneable; /** * A dataset wrapper class that converts a standard {@link XYDataset} into an * {@link IntervalXYDataset} suitable for use in creating XY bar charts. */ public class XYBarDataset extends AbstractIntervalXYDataset implements IntervalXYDataset, DatasetChangeListener, PublicCloneable { /** The underlying dataset. */ private XYDataset underlying; /** The bar width. */ private double barWidth; /** * Creates a new dataset. * * @param underlying the underlying dataset (null not * permitted). * @param barWidth the width of the bars. */ public XYBarDataset(XYDataset underlying, double barWidth) { this.underlying = underlying; this.underlying.addChangeListener(this); this.barWidth = barWidth; } /** * Returns the underlying dataset that was specified via the constructor. * * @return The underlying dataset (never null). * * @since 1.0.4 */ public XYDataset getUnderlyingDataset() { return this.underlying; } /** * Returns the bar width. * * @return The bar width. * * @see #setBarWidth(double) * @since 1.0.4 */ public double getBarWidth() { return this.barWidth; } /** * Sets the bar width and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param barWidth the bar width. * * @see #getBarWidth() * @since 1.0.4 */ public void setBarWidth(double barWidth) { this.barWidth = barWidth; notifyListeners(new DatasetChangeEvent(this, this)); } /** * Returns the number of series in the dataset. * * @return The series count. */ public int getSeriesCount() { return this.underlying.getSeriesCount(); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The series key. */ public Comparable getSeriesKey(int series) { return this.underlying.getSeriesKey(series); } /** * Returns the number of items in a series. * * @param series the series index (zero-based). * * @return The item count. */ public int getItemCount(int series) { return this.underlying.getItemCount(series); } /** * Returns the x-value for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value. * * @see #getXValue(int, int) */ public Number getX(int series, int item) { return this.underlying.getX(series, item); } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. * * @see #getX(int, int) */ public double getXValue(int series, int item) { return this.underlying.getXValue(series, item); } /** * Returns the y-value for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value (possibly null). * * @see #getYValue(int, int) */ public Number getY(int series, int item) { return this.underlying.getY(series, item); } /** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. * * @see #getY(int, int) */ public double getYValue(int series, int item) { return this.underlying.getYValue(series, item); } /** * Returns the starting X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartX(int series, int item) { Number result = null; Number xnum = this.underlying.getX(series, item); if (xnum != null) { result = new Double(xnum.doubleValue() - this.barWidth / 2.0); } return result; } /** * Returns the starting x-value (as a double primitive) for an item within * a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. * * @see #getXValue(int, int) */ public double getStartXValue(int series, int item) { return getXValue(series, item) - this.barWidth / 2.0; } /** * Returns the ending X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndX(int series, int item) { Number result = null; Number xnum = this.underlying.getX(series, item); if (xnum != null) { result = new Double(xnum.doubleValue() + this.barWidth / 2.0); } return result; } /** * Returns the ending x-value (as a double primitive) for an item within * a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. * * @see #getXValue(int, int) */ public double getEndXValue(int series, int item) { return getXValue(series, item) + this.barWidth / 2.0; } /** * Returns the starting Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getStartY(int series, int item) { return this.underlying.getY(series, item); } /** * Returns the starting y-value (as a double primitive) for an item within * a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. * * @see #getYValue(int, int) */ public double getStartYValue(int series, int item) { return getYValue(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public Number getEndY(int series, int item) { return this.underlying.getY(series, item); } /** * Returns the ending y-value (as a double primitive) for an item within * a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. * * @see #getYValue(int, int) */ public double getEndYValue(int series, int item) { return getYValue(series, item); } /** * Receives notification of an dataset change event. * * @param event information about the event. */ public void datasetChanged(DatasetChangeEvent event) { notifyListeners(event); } /** * Tests this dataset for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYBarDataset)) { return false; } XYBarDataset that = (XYBarDataset) obj; if (!this.underlying.equals(that.underlying)) { return false; } if (this.barWidth != that.barWidth) { return false; } return true; } /** * Returns an independent copy of the dataset. Note that: *

        *
      • the underlying dataset is only cloned if it implements the * {@link PublicCloneable} interface;
      • *
      • the listeners registered with this dataset are not carried over to * the cloned dataset.
      • *
      * * @return An independent copy of the dataset. * * @throws CloneNotSupportedException if the dataset cannot be cloned for * any reason. */ public Object clone() throws CloneNotSupportedException { XYBarDataset clone = (XYBarDataset) super.clone(); if (this.underlying instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.underlying; clone.underlying = (XYDataset) pc.clone(); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYCoordinate.java0000644000175000017500000001112711173030414026116 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * XYCoordinate.java * ----------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 25-May-2007 : Moved from experimental to the main source tree (DG); * */ package org.jfree.data.xy; import java.io.Serializable; /** * Represents an (x, y) coordinate. * * @since 1.0.6 */ public class XYCoordinate implements Comparable, Serializable { /** The x-coordinate. */ private double x; /** The y-coordinate. */ private double y; /** * Creates a new coordinate for the point (0.0, 0.0). */ public XYCoordinate() { this(0.0, 0.0); } /** * Creates a new coordinate for the point (x, y). * * @param x the x-coordinate. * @param y the y-coordinate. */ public XYCoordinate(double x, double y) { this.x = x; this.y = y; } /** * Returns the x-coordinate. * * @return The x-coordinate. */ public double getX() { return this.x; } /** * Returns the y-coordinate. * * @return The y-coordinate. */ public double getY() { return this.y; } /** * Tests this coordinate for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYCoordinate)) { return false; } XYCoordinate that = (XYCoordinate) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; } /** * Returns a hash code for this instance. * * @return A hash code. */ public int hashCode() { int result = 193; long temp = Double.doubleToLongBits(this.x); result = 37 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.y); result = 37 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a string representation of this instance, primarily for * debugging purposes. * * @return A string. */ public String toString() { return "(" + this.x + ", " + this.y + ")"; } /** * Compares this instance against an arbitrary object. * * @param obj the object (null not permitted). * * @return An integer indicating the relative order of the items. */ public int compareTo(Object obj) { if (!(obj instanceof XYCoordinate)) { throw new IllegalArgumentException("Incomparable object."); } XYCoordinate that = (XYCoordinate) obj; if (this.x > that.x) { return 1; } else if (this.x < that.x) { return -1; } else { if (this.y > that.y) { return 1; } else if (this.y < that.y) { return -1; } } return 0; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYDataItem.java0000644000175000017500000001637611173030414025532 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * XYDataItem.java * --------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Aug-2003 : Renamed XYDataPair --> XYDataItem (DG); * 03-Feb-2004 : Fixed bug in equals() method (DG); * 21-Feb-2005 : Added setY(double) method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 30-Nov-2007 : Implemented getXValue() and getYValue(), plus toString() for * debugging use (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import org.jfree.util.ObjectUtilities; /** * Represents one (x, y) data item for an {@link XYSeries}. */ public class XYDataItem implements Cloneable, Comparable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2751513470325494890L; /** The x-value (null not permitted). */ private Number x; /** The y-value. */ private Number y; /** * Constructs a new data item. * * @param x the x-value (null NOT permitted). * @param y the y-value (null permitted). */ public XYDataItem(Number x, Number y) { if (x == null) { throw new IllegalArgumentException("Null 'x' argument."); } this.x = x; this.y = y; } /** * Constructs a new data item. * * @param x the x-value. * @param y the y-value. */ public XYDataItem(double x, double y) { this(new Double(x), new Double(y)); } /** * Returns the x-value. * * @return The x-value (never null). */ public Number getX() { return this.x; } /** * Returns the x-value as a double primitive. * * @return The x-value. * * @see #getX() * @see #getYValue() * * @since 1.0.9 */ public double getXValue() { // this.x is not allowed to be null... return this.x.doubleValue(); } /** * Returns the y-value. * * @return The y-value (possibly null). */ public Number getY() { return this.y; } /** * Returns the y-value as a double primitive. * * @return The y-value. * * @see #getY() * @see #getXValue() * * @since 1.0.9 */ public double getYValue() { double result = Double.NaN; if (this.y != null) { result = this.y.doubleValue(); } return result; } /** * Sets the y-value for this data item. Note that there is no * corresponding method to change the x-value. * * @param y the new y-value. */ public void setY(double y) { setY(new Double(y)); } /** * Sets the y-value for this data item. Note that there is no * corresponding method to change the x-value. * * @param y the new y-value (null permitted). */ public void setY(Number y) { this.y = y; } /** * Returns an integer indicating the order of this object relative to * another object. *

      * For the order we consider only the x-value: * negative == "less-than", zero == "equal", positive == "greater-than". * * @param o1 the object being compared to. * * @return An integer indicating the order of this data pair object * relative to another object. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another TimeSeriesDataPair object // ------------------------------------------------------- if (o1 instanceof XYDataItem) { XYDataItem dataItem = (XYDataItem) o1; double compare = this.x.doubleValue() - dataItem.getX().doubleValue(); if (compare > 0.0) { result = 1; } else { if (compare < 0.0) { result = -1; } else { result = 0; } } } // CASE 2 : Comparing to a general object // --------------------------------------------- else { // consider time periods to be ordered after general objects result = 1; } return result; } /** * Returns a clone of this object. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class, but * subclasses may differ. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests if this object is equal to another. * * @param obj the object to test against for equality (null * permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYDataItem)) { return false; } XYDataItem that = (XYDataItem) obj; if (!this.x.equals(that.x)) { return false; } if (!ObjectUtilities.equal(this.y, that.y)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = this.x.hashCode(); result = 29 * result + (this.y != null ? this.y.hashCode() : 0); return result; } /** * Returns a string representing this instance, primarily for debugging * use. * * @return A string. */ public String toString() { return "[" + getXValue() + ", " + getYValue() + "]"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYDataset.java0000644000175000017500000001131511173030414025413 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * XYDataset.java * -------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 15-Oct-2001 : Moved to a new package (com.jrefinery.data.*) (DG); * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); * 17-Nov-2001 : Now extends SeriesDataset (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 29-Jul-2004 : Added getDomainOrder() method (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * */ package org.jfree.data.xy; import org.jfree.data.DomainOrder; import org.jfree.data.general.SeriesDataset; /** * An interface through which data in the form of (x, y) items can be accessed. */ public interface XYDataset extends SeriesDataset { /** * Returns the order of the domain (or X) values returned by the dataset. * * @return The order (never null). */ public DomainOrder getDomainOrder(); /** * Returns the number of items in a series. *

      * It is recommended that classes that implement this method should throw * an IllegalArgumentException if the series * argument is outside the specified range. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The item count. */ public int getItemCount(int series); /** * Returns the x-value for an item within a series. The x-values may or * may not be returned in ascending order, that is up to the class * implementing the interface. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value (never null). */ public Number getX(int series, int item); /** * Returns the x-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The x-value. */ public double getXValue(int series, int item); /** * Returns the y-value for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value (possibly null). */ public Number getY(int series, int item); /** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * @param item the item index (in the range 0 to * getItemCount(series)). * * @return The y-value. */ public double getYValue(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYDatasetTableModel.java0000644000175000017500000001713311173030414027350 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYDatasetTableModel.java * ------------------------ * (C)opyright 2003-2008, by Bryan Scott and Contributors. * * Original Author: Bryan Scott ; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Jul-2003 : Version 1 contributed by Bryan Scott (DG); * 27-Apr-2005 : Change XYDataset --> TableXYDataset because the table model * assumes all series share the same x-values, and this is not * enforced by XYDataset. Also fixed bug 1191046, a problem * in the getValueAt() method (DG); * */ package org.jfree.data.xy; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableModel; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; /** * A READ-ONLY wrapper around a {@link TableXYDataset} to convert it to a * table model for use in a JTable. The first column of the table shows the * x-values, the remaining columns show the y-values for each series (series 0 * appears in column 1, series 1 appears in column 2, etc). *

      * TO DO: *

        *
      • implement proper naming for x axis (getColumnName)
      • *
      • implement setValueAt to remove READ-ONLY constraint (not sure how)
      • *
      */ public class XYDatasetTableModel extends AbstractTableModel implements TableModel, DatasetChangeListener { /** The dataset. */ TableXYDataset model = null; /** * Default constructor. */ public XYDatasetTableModel() { super(); } /** * Creates a new table model based on the specified dataset. * * @param dataset the dataset. */ public XYDatasetTableModel(TableXYDataset dataset) { this(); this.model = dataset; this.model.addChangeListener(this); } /** * Sets the model (dataset). * * @param dataset the dataset. */ public void setModel(TableXYDataset dataset) { this.model = dataset; this.model.addChangeListener(this); fireTableDataChanged(); } /** * Returns the number of rows. * * @return The row count. */ public int getRowCount() { if (this.model == null) { return 0; } return this.model.getItemCount(); } /** * Gets the number of columns in the model. * * @return The number of columns in the model. */ public int getColumnCount() { if (this.model == null) { return 0; } return this.model.getSeriesCount() + 1; } /** * Returns the column name. * * @param column the column index. * * @return The column name. */ public String getColumnName(int column) { if (this.model == null) { return super.getColumnName(column); } if (column < 1) { return "X Value"; } else { return this.model.getSeriesKey(column - 1).toString(); } } /** * Returns a value of the specified cell. * Column 0 is the X axis, Columns 1 and over are the Y axis * * @param row the row number. * @param column the column number. * * @return The value of the specified cell. */ public Object getValueAt(int row, int column) { if (this.model == null) { return null; } if (column < 1) { return this.model.getX(0, row); } else { return this.model.getY(column - 1, row); } } /** * Receives notification that the underlying dataset has changed. * * @param event the event * * @see DatasetChangeListener */ public void datasetChanged(DatasetChangeEvent event) { fireTableDataChanged(); } /** * Returns a flag indicating whether or not the specified cell is editable. * * @param row the row number. * @param column the column number. * * @return true if the specified cell is editable. */ public boolean isCellEditable(int row, int column) { return false; } /** * Updates the {@link XYDataset} if allowed. * * @param value the new value. * @param row the row. * @param column the column. */ public void setValueAt(Object value, int row, int column) { if (isCellEditable(row, column)) { // XYDataset only provides methods for reading a dataset... } } // /** // * Run a demonstration of the table model interface. // * // * @param args ignored. // * // * @throws Exception when an error occurs. // */ // public static void main(String args[]) throws Exception { // JFrame frame = new JFrame(); // JPanel panel = new JPanel(); // panel.setLayout(new BorderLayout()); // // XYSeries s1 = new XYSeries("Series 1", true, false); // for (int i = 0; i < 10; i++) { // s1.add(i, Math.random()); // } // XYSeries s2 = new XYSeries("Series 2", true, false); // for (int i = 0; i < 15; i++) { // s2.add(i, Math.random()); // } // DefaultTableXYDataset dataset = new DefaultTableXYDataset(); // dataset.addSeries(s1); // dataset.addSeries(s2); // XYDatasetTableModel tablemodel = new XYDatasetTableModel(); // // tablemodel.setModel(dataset); // // JTable dataTable = new JTable(tablemodel); // JScrollPane scroll = new JScrollPane(dataTable); // scroll.setPreferredSize(new Dimension(600, 150)); // // JFreeChart chart = ChartFactory.createXYLineChart( // "XY Series Demo", // "X", "Y", dataset, PlotOrientation.VERTICAL, // true, // true, // false // ); // // ChartPanel chartPanel = new ChartPanel(chart); // // panel.add(chartPanel, BorderLayout.CENTER); // panel.add(scroll, BorderLayout.SOUTH); // // frame.setContentPane(panel); // frame.setSize(600, 500); // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.show(); // RefineryUtilities.centerFrameOnScreen(frame); // } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYDomainInfo.java0000644000175000017500000000441511173030414026054 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * XYDomainInfo.java * ----------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2009 : Version 1 (DG); * */ package org.jfree.data.xy; import java.util.List; import org.jfree.data.Range; /** * An interface that can (optionally) be implemented by a dataset to assist in * determining the minimum and maximum x-values in the dataset. * * @since 1.0.13 */ public interface XYDomainInfo { /** * Returns the range of the values in this dataset's domain. * * @param visibleSeriesKeys the keys of the visible series. * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (or null if the dataset contains no * values). */ public Range getDomainBounds(List visibleSeriesKeys, boolean includeInterval); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYInterval.java0000644000175000017500000001056111173030414025614 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * XYInterval.java * --------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy; import java.io.Serializable; /** * An xy-interval. This class is used internally by the * {@link XYIntervalDataItem} class. * * @since 1.0.3 */ public class XYInterval implements Serializable { /** The lower bound of the x-interval. */ private double xLow; /** The upper bound of the y-interval. */ private double xHigh; /** The y-value. */ private double y; /** The lower bound of the y-interval. */ private double yLow; /** The upper bound of the y-interval. */ private double yHigh; /** * Creates a new instance of XYInterval. * * @param xLow the lower bound of the x-interval. * @param xHigh the upper bound of the y-interval. * @param y the y-value. * @param yLow the lower bound of the y-interval. * @param yHigh the upper bound of the y-interval. */ public XYInterval(double xLow, double xHigh, double y, double yLow, double yHigh) { this.xLow = xLow; this.xHigh = xHigh; this.y = y; this.yLow = yLow; this.yHigh = yHigh; } /** * Returns the lower bound of the x-interval. * * @return The lower bound of the x-interval. */ public double getXLow() { return this.xLow; } /** * Returns the upper bound of the x-interval. * * @return The upper bound of the x-interval. */ public double getXHigh() { return this.xHigh; } /** * Returns the y-value. * * @return The y-value. */ public double getY() { return this.y; } /** * Returns the lower bound of the y-interval. * * @return The lower bound of the y-interval. */ public double getYLow() { return this.yLow; } /** * Returns the upper bound of the y-interval. * * @return The upper bound of the y-interval. */ public double getYHigh() { return this.yHigh; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYInterval)) { return false; } XYInterval that = (XYInterval) obj; if (this.xLow != that.xLow) { return false; } if (this.xHigh != that.xHigh) { return false; } if (this.y != that.y) { return false; } if (this.yLow != that.yLow) { return false; } if (this.yHigh != that.yHigh) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYIntervalDataItem.java0000644000175000017500000001044111173030414027222 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYIntervalDataItem.java * ----------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; /** * An item representing data in the form (x, x-low, x-high, y, y-low, y-high). * * @since 1.0.3 */ public class XYIntervalDataItem extends ComparableObjectItem { /** * Creates a new instance of XYIntervalItem. * * @param x the x-value. * @param xLow the lower bound of the x-interval. * @param xHigh the upper bound of the x-interval. * @param y the y-value. * @param yLow the lower bound of the y-interval. * @param yHigh the upper bound of the y-interval. */ public XYIntervalDataItem(double x, double xLow, double xHigh, double y, double yLow, double yHigh) { super(new Double(x), new XYInterval(xLow, xHigh, y, yLow, yHigh)); } /** * Returns the x-value. * * @return The x-value (never null). */ public Double getX() { return (Double) getComparable(); } /** * Returns the y-value. * * @return The y-value. */ public double getYValue() { XYInterval interval = (XYInterval) getObject(); if (interval != null) { return interval.getY(); } else { return Double.NaN; } } /** * Returns the lower bound of the x-interval. * * @return The lower bound of the x-interval. */ public double getXLowValue() { XYInterval interval = (XYInterval) getObject(); if (interval != null) { return interval.getXLow(); } else { return Double.NaN; } } /** * Returns the upper bound of the x-interval. * * @return The upper bound of the x-interval. */ public double getXHighValue() { XYInterval interval = (XYInterval) getObject(); if (interval != null) { return interval.getXHigh(); } else { return Double.NaN; } } /** * Returns the lower bound of the y-interval. * * @return The lower bound of the y-interval. */ public double getYLowValue() { XYInterval interval = (XYInterval) getObject(); if (interval != null) { return interval.getYLow(); } else { return Double.NaN; } } /** * Returns the upper bound of the y-interval. * * @return The upper bound of the y-interval. */ public double getYHighValue() { XYInterval interval = (XYInterval) getObject(); if (interval != null) { return interval.getYHigh(); } else { return Double.NaN; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYIntervalSeries.java0000644000175000017500000001377411173030414027000 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYIntervalSeries.java * --------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 13-Feb-2007 : Added several new accessor methods (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; import org.jfree.data.ComparableObjectSeries; /** * A list of (x, x-low, x-high, y, y-low, y-high) data items. * * @since 1.0.3 * * @see XYIntervalSeriesCollection */ public class XYIntervalSeries extends ComparableObjectSeries { /** * Creates a new empty series. By default, items added to the series will * be sorted into ascending order by x-value, and duplicate x-values will * be allowed (these defaults can be modified with another constructor). * * @param key the series key (null not permitted). */ public XYIntervalSeries(Comparable key) { this(key, true, true); } /** * Constructs a new xy-series that contains no data. You can specify * whether or not duplicate x-values are allowed for the series. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. * @param allowDuplicateXValues a flag that controls whether duplicate * x-values are allowed. */ public XYIntervalSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key, autoSort, allowDuplicateXValues); } /** * Adds a data item to the series. * * @param x the x-value. * @param xLow the lower bound of the x-interval. * @param xHigh the upper bound of the x-interval. * @param y the y-value. * @param yLow the lower bound of the y-interval. * @param yHigh the upper bound of the y-interval. */ public void add(double x, double xLow, double xHigh, double y, double yLow, double yHigh) { super.add(new XYIntervalDataItem(x, xLow, xHigh, y, yLow, yHigh), true); } /** * Returns the x-value for the specified item. * * @param index the item index. * * @return The x-value (never null). */ public Number getX(int index) { XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); return item.getX(); } /** * Returns the lower bound of the x-interval for the specified item in the * series. * * @param index the item index. * * @return The lower bound of the x-interval. * * @since 1.0.5 */ public double getXLowValue(int index) { XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); return item.getXLowValue(); } /** * Returns the upper bound of the x-interval for the specified item in the * series. * * @param index the item index. * * @return The upper bound of the x-interval. * * @since 1.0.5 */ public double getXHighValue(int index) { XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); return item.getXHighValue(); } /** * Returns the y-value for the specified item. * * @param index the item index. * * @return The y-value. */ public double getYValue(int index) { XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); return item.getYValue(); } /** * Returns the lower bound of the Y-interval for the specified item in the * series. * * @param index the item index. * * @return The lower bound of the Y-interval. * * @since 1.0.5 */ public double getYLowValue(int index) { XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); return item.getYLowValue(); } /** * Returns the upper bound of the y-interval for the specified item in the * series. * * @param index the item index. * * @return The upper bound of the y-interval. * * @since 1.0.5 */ public double getYHighValue(int index) { XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); return item.getYHighValue(); } /** * Returns the data item at the specified index. * * @param index the item index. * * @return The data item. */ public ComparableObjectItem getDataItem(int index) { return super.getDataItem(index); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYIntervalSeriesCollection.java0000644000175000017500000002740411173030414031007 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * XYIntervalSeriesCollection.java * ------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 13-Feb-2007 : Provided a number of method overrides that enhance * performance, and added a proper clone() * implementation (DG); * 18-Jan-2008 : Added removeSeries() and removeAllSeries() methods (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A collection of {@link XYIntervalSeries} objects. * * @since 1.0.3 * * @see XYIntervalSeries */ public class XYIntervalSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, PublicCloneable, Serializable { /** Storage for the data series. */ private List data; /** * Creates a new instance of XIntervalSeriesCollection. */ public XYIntervalSeriesCollection() { this.data = new java.util.ArrayList(); } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(XYIntervalSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public XYIntervalSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (XYIntervalSeries) this.data.get(series); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for a series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public int getItemCount(int series) { // defer argument checking return getSeries(series).getItemCount(); } /** * Returns the x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getX(int series, int item) { XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); return s.getX(item); } /** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartXValue(int series, int item) { XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); return s.getXLowValue(item); } /** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getEndXValue(int series, int item) { XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); return s.getXHighValue(item); } /** * Returns the y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getYValue(int series, int item) { XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); return s.getYValue(item); } /** * Returns the start y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartYValue(int series, int item) { XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); return s.getYLowValue(item); } /** * Returns the end y-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public double getEndYValue(int series, int item) { XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); return s.getYHighValue(item); } /** * Returns the y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The y-value. */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); } /** * Returns the start x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); } /** * Returns the end x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); } /** * Returns the start y-value for an item within a series. This method * maps directly to {@link #getY(int, int)}. * * @param series the series index. * @param item the item index. * * @return The start y-value. */ public Number getStartY(int series, int item) { return new Double(getStartYValue(series, item)); } /** * Returns the end y-value for an item within a series. This method * maps directly to {@link #getY(int, int)}. * * @param series the series index. * @param item the item index. * * @return The end y-value. */ public Number getEndY(int series, int item) { return new Double(getEndYValue(series, item)); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * * @since 1.0.10 */ public void removeSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds."); } XYIntervalSeries ts = (XYIntervalSeries) this.data.get(series); ts.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). * * @since 1.0.10 */ public void removeSeries(XYIntervalSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.10 */ public void removeAllSeries() { // Unregister the collection as a change listener to each series in // the collection. for (int i = 0; i < this.data.size(); i++) { XYIntervalSeries series = (XYIntervalSeries) this.data.get(i); series.removeChangeListener(this); } this.data.clear(); fireDatasetChanged(); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYIntervalSeriesCollection)) { return false; } XYIntervalSeriesCollection that = (XYIntervalSeriesCollection) obj; return ObjectUtilities.equal(this.data, that.data); } /** * Returns a clone of this dataset. * * @return A clone of this dataset. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { XYIntervalSeriesCollection clone = (XYIntervalSeriesCollection) super.clone(); int seriesCount = getSeriesCount(); clone.data = new java.util.ArrayList(seriesCount); for (int i = 0; i < this.data.size(); i++) { clone.data.set(i, getSeries(i).clone()); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYRangeInfo.java0000644000175000017500000000451411173030414025701 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * XYRangeInfo.java * ---------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2009 : Version 1 (DG); * */ package org.jfree.data.xy; import java.util.List; import org.jfree.data.Range; /** * An interface that can (optionally) be implemented by a dataset to assist in * determining the minimum and maximum y-values. * * @since 1.0.13 */ public interface XYRangeInfo { /** * Returns the range of the values in this dataset's range. * * @param visibleSeriesKeys the keys of the visible series. * @param xRange the x-range (null not permitted). * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (or null if the dataset contains no * values). */ public Range getRangeBounds(List visibleSeriesKeys, Range xRange, boolean includeInterval); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYSeries.java0000644000175000017500000010177011173030414025265 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * XYSeries.java * ------------- * (C) Copyright 2001-2009, Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Aaron Metzger; * Jonathan Gabbai; * Richard Atkinson; * Michel Santos; * Ted Schwartz (fix for bug 1955483); * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 03-Apr-2002 : Added an add(double, double) method (DG); * 29-Apr-2002 : Added a clear() method (ARM); * 06-Jun-2002 : Updated Javadoc comments (DG); * 29-Aug-2002 : Modified to give user control over whether or not duplicate * x-values are allowed (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 11-Nov-2002 : Added maximum item count, code contributed by Jonathan * Gabbai (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 04-Aug-2003 : Added getItems() method (DG); * 15-Aug-2003 : Changed 'data' from private to protected, added new add() * methods with a 'notify' argument (DG); * 22-Sep-2003 : Added getAllowDuplicateXValues() method (RA); * 29-Jan-2004 : Added autoSort attribute, based on a contribution by * Michel Santos - see patch 886740 (DG); * 03-Feb-2004 : Added indexOf() method (DG); * 16-Feb-2004 : Added remove() method (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * 21-Feb-2005 : Added update(Number, Number) and addOrUpdate(Number, Number) * methods (DG); * 03-May-2005 : Added a new constructor, fixed the setMaximumItemCount() * method to remove items (and notify listeners) if necessary, * fixed the add() and addOrUpdate() methods to handle unsorted * series (DG); * ------------- JFreeChart 1.0.x --------------------------------------------- * 11-Jan-2005 : Renamed update(int, Number) --> updateByIndex() (DG); * 15-Jan-2007 : Added toArray() method (DG); * 31-Oct-2007 : Implemented faster hashCode() (DG); * 22-Nov-2007 : Reimplemented clone() (DG); * 01-May-2008 : Fixed bug 1955483 in addOrUpdate() method, thanks to * Ted Schwartz (DG); * 24-Nov-2008 : Further fix for 1955483 (DG); * 06-Mar-2009 : Added minX, maxX, minY and maxY fields (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.data.general.Series; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesException; import org.jfree.util.ObjectUtilities; /** * Represents a sequence of zero or more data items in the form (x, y). By * default, items in the series will be sorted into ascending order by x-value, * and duplicate x-values are permitted. Both the sorting and duplicate * defaults can be changed in the constructor. Y-values can be * null to represent missing values. */ public class XYSeries extends Series implements Cloneable, Serializable { /** For serialization. */ static final long serialVersionUID = -5908509288197150436L; // In version 0.9.12, in response to several developer requests, I changed // the 'data' attribute from 'private' to 'protected', so that others can // make subclasses that work directly with the underlying data structure. /** Storage for the data items in the series. */ protected List data; /** The maximum number of items for the series. */ private int maximumItemCount = Integer.MAX_VALUE; /** * A flag that controls whether the items are automatically sorted * (by x-value ascending). */ private boolean autoSort; /** A flag that controls whether or not duplicate x-values are allowed. */ private boolean allowDuplicateXValues; /** The lowest x-value in the series, excluding Double.NaN values. */ private double minX; /** The highest x-value in the series, excluding Double.NaN values. */ private double maxX; /** The lowest y-value in the series, excluding Double.NaN values. */ private double minY; /** The highest y-value in the series, excluding Double.NaN values. */ private double maxY; /** * Creates a new empty series. By default, items added to the series will * be sorted into ascending order by x-value, and duplicate x-values will * be allowed (these defaults can be modified with another constructor. * * @param key the series key (null not permitted). */ public XYSeries(Comparable key) { this(key, true, true); } /** * Constructs a new empty series, with the auto-sort flag set as requested, * and duplicate values allowed. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. */ public XYSeries(Comparable key, boolean autoSort) { this(key, autoSort, true); } /** * Constructs a new xy-series that contains no data. You can specify * whether or not duplicate x-values are allowed for the series. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. * @param allowDuplicateXValues a flag that controls whether duplicate * x-values are allowed. */ public XYSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key); this.data = new java.util.ArrayList(); this.autoSort = autoSort; this.allowDuplicateXValues = allowDuplicateXValues; this.minX = Double.NaN; this.maxX = Double.NaN; this.minY = Double.NaN; this.maxY = Double.NaN; } /** * Returns the smallest x-value in the series, ignoring any Double.NaN * values. This method returns Double.NaN if there is no smallest x-value * (for example, when the series is empty). * * @return The smallest x-value. * * @see #getMaxX() * * @since 1.0.13 */ public double getMinX() { return this.minX; } /** * Returns the largest x-value in the series, ignoring any Double.NaN * values. This method returns Double.NaN if there is no largest x-value * (for example, when the series is empty). * * @return The largest x-value. * * @see #getMinX() * * @since 1.0.13 */ public double getMaxX() { return this.maxX; } /** * Returns the smallest y-value in the series, ignoring any null and * Double.NaN values. This method returns Double.NaN if there is no * smallest y-value (for example, when the series is empty). * * @return The smallest y-value. * * @see #getMaxY() * * @since 1.0.13 */ public double getMinY() { return this.minY; } /** * Returns the largest y-value in the series, ignoring any Double.NaN * values. This method returns Double.NaN if there is no largest y-value * (for example, when the series is empty). * * @return The largest y-value. * * @see #getMinY() * * @since 1.0.13 */ public double getMaxY() { return this.maxY; } /** * Updates the cached values for the minimum and maximum data values. * * @param item the item added (null not permitted). * * @since 1.0.13 */ private void updateBoundsForAddedItem(XYDataItem item) { double x = item.getXValue(); this.minX = minIgnoreNaN(this.minX, x); this.maxX = maxIgnoreNaN(this.maxX, x); if (item.getY() != null) { double y = item.getYValue(); this.minY = minIgnoreNaN(this.minY, y); this.maxY = maxIgnoreNaN(this.maxY, y); } } /** * Updates the cached values for the minimum and maximum data values on * the basis that the specified item has just been removed. * * @param item the item added (null not permitted). * * @since 1.0.13 */ private void updateBoundsForRemovedItem(XYDataItem item) { boolean itemContributesToXBounds = false; boolean itemContributesToYBounds = false; double x = item.getXValue(); if (!Double.isNaN(x)) { if (x <= this.minX || x >= this.maxX) { itemContributesToXBounds = true; } } if (item.getY() != null) { double y = item.getYValue(); if (!Double.isNaN(y)) { if (y <= this.minY || y >= this.maxY) { itemContributesToYBounds = true; } } } if (itemContributesToYBounds) { findBoundsByIteration(); } else if (itemContributesToXBounds) { if (getAutoSort()) { this.minX = getX(0).doubleValue(); this.maxX = getX(getItemCount() - 1).doubleValue(); } else { findBoundsByIteration(); } } } /** * Finds the bounds of the x and y values for the series, by iterating * through all the data items. * * @since 1.0.13 */ private void findBoundsByIteration() { this.minX = Double.NaN; this.maxX = Double.NaN; this.minY = Double.NaN; this.maxY = Double.NaN; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { XYDataItem item = (XYDataItem) iterator.next(); updateBoundsForAddedItem(item); } } /** * Returns the flag that controls whether the items in the series are * automatically sorted. There is no setter for this flag, it must be * defined in the series constructor. * * @return A boolean. */ public boolean getAutoSort() { return this.autoSort; } /** * Returns a flag that controls whether duplicate x-values are allowed. * This flag can only be set in the constructor. * * @return A boolean. */ public boolean getAllowDuplicateXValues() { return this.allowDuplicateXValues; } /** * Returns the number of items in the series. * * @return The item count. * * @see #getItems() */ public int getItemCount() { return this.data.size(); } /** * Returns the list of data items for the series (the list contains * {@link XYDataItem} objects and is unmodifiable). * * @return The list of data items. */ public List getItems() { return Collections.unmodifiableList(this.data); } /** * Returns the maximum number of items that will be retained in the series. * The default value is Integer.MAX_VALUE. * * @return The maximum item count. * * @see #setMaximumItemCount(int) */ public int getMaximumItemCount() { return this.maximumItemCount; } /** * Sets the maximum number of items that will be retained in the series. * If you add a new item to the series such that the number of items will * exceed the maximum item count, then the first element in the series is * automatically removed, ensuring that the maximum item count is not * exceeded. *

      * Typically this value is set before the series is populated with data, * but if it is applied later, it may cause some items to be removed from * the series (in which case a {@link SeriesChangeEvent} will be sent to * all registered listeners). * * @param maximum the maximum number of items for the series. */ public void setMaximumItemCount(int maximum) { this.maximumItemCount = maximum; int remove = this.data.size() - maximum; if (remove > 0) { this.data.subList(0, remove).clear(); findBoundsByIteration(); fireSeriesChanged(); } } /** * Adds a data item to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. * * @param item the (x, y) item (null not permitted). */ public void add(XYDataItem item) { // argument checking delegated... add(item, true); } /** * Adds a data item to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. * * @param x the x value. * @param y the y value. */ public void add(double x, double y) { add(new Double(x), new Double(y), true); } /** * Adds a data item to the series and, if requested, sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param x the x value. * @param y the y value. * @param notify a flag that controls whether or not a * {@link SeriesChangeEvent} is sent to all registered * listeners. */ public void add(double x, double y, boolean notify) { add(new Double(x), new Double(y), notify); } /** * Adds a data item to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. The unusual pairing of parameter types is to * make it easier to add null y-values. * * @param x the x value. * @param y the y value (null permitted). */ public void add(double x, Number y) { add(new Double(x), y); } /** * Adds a data item to the series and, if requested, sends a * {@link SeriesChangeEvent} to all registered listeners. The unusual * pairing of parameter types is to make it easier to add null y-values. * * @param x the x value. * @param y the y value (null permitted). * @param notify a flag that controls whether or not a * {@link SeriesChangeEvent} is sent to all registered * listeners. */ public void add(double x, Number y, boolean notify) { add(new Double(x), y, notify); } /** * Adds a new data item to the series (in the correct position if the * autoSort flag is set for the series) and sends a * {@link SeriesChangeEvent} to all registered listeners. *

      * Throws an exception if the x-value is a duplicate AND the * allowDuplicateXValues flag is false. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). * * @throws SeriesException if the x-value is a duplicate and the * allowDuplicateXValues flag is not set for this series. */ public void add(Number x, Number y) { // argument checking delegated... add(x, y, true); } /** * Adds new data to the series and, if requested, sends a * {@link SeriesChangeEvent} to all registered listeners. *

      * Throws an exception if the x-value is a duplicate AND the * allowDuplicateXValues flag is false. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). * @param notify a flag the controls whether or not a * {@link SeriesChangeEvent} is sent to all registered * listeners. */ public void add(Number x, Number y, boolean notify) { // delegate argument checking to XYDataItem... XYDataItem item = new XYDataItem(x, y); add(item, notify); } /** * Adds a data item to the series and, if requested, sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param item the (x, y) item (null not permitted). * @param notify a flag that controls whether or not a * {@link SeriesChangeEvent} is sent to all registered * listeners. */ public void add(XYDataItem item, boolean notify) { if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } if (this.autoSort) { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); } else { if (this.allowDuplicateXValues) { // need to make sure we are adding *after* any duplicates int size = this.data.size(); while (index < size && item.compareTo( this.data.get(index)) == 0) { index++; } if (index < this.data.size()) { this.data.add(index, item); } else { this.data.add(item); } } else { throw new SeriesException("X-value already exists."); } } } else { if (!this.allowDuplicateXValues) { // can't allow duplicate values, so we need to check whether // there is an item with the given x-value already int index = indexOf(item.getX()); if (index >= 0) { throw new SeriesException("X-value already exists."); } } this.data.add(item); } updateBoundsForAddedItem(item); if (getItemCount() > this.maximumItemCount) { XYDataItem removed = (XYDataItem) this.data.remove(0); updateBoundsForRemovedItem(removed); } if (notify) { fireSeriesChanged(); } } /** * Deletes a range of items from the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param start the start index (zero-based). * @param end the end index (zero-based). */ public void delete(int start, int end) { this.data.subList(start, end + 1).clear(); findBoundsByIteration(); fireSeriesChanged(); } /** * Removes the item at the specified index and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the index. * * @return The item removed. */ public XYDataItem remove(int index) { XYDataItem removed = (XYDataItem) this.data.remove(index); updateBoundsForRemovedItem(removed); fireSeriesChanged(); return removed; } /** * Removes an item with the specified x-value and sends a * {@link SeriesChangeEvent} to all registered listeners. Note that when * a series permits multiple items with the same x-value, this method * could remove any one of the items with that x-value. * * @param x the x-value. * @return The item removed. */ public XYDataItem remove(Number x) { return remove(indexOf(x)); } /** * Removes all data items from the series and sends a * {@link SeriesChangeEvent} to all registered listeners. */ public void clear() { if (this.data.size() > 0) { this.data.clear(); this.minX = Double.NaN; this.maxX = Double.NaN; this.minY = Double.NaN; this.maxY = Double.NaN; fireSeriesChanged(); } } /** * Return the data item with the specified index. * * @param index the index. * * @return The data item with the specified index. */ public XYDataItem getDataItem(int index) { return (XYDataItem) this.data.get(index); } /** * Returns the x-value at the specified index. * * @param index the index (zero-based). * * @return The x-value (never null). */ public Number getX(int index) { return getDataItem(index).getX(); } /** * Returns the y-value at the specified index. * * @param index the index (zero-based). * * @return The y-value (possibly null). */ public Number getY(int index) { return getDataItem(index).getY(); } /** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value (null permitted). * * @deprecated Renamed {@link #updateByIndex(int, Number)} to avoid * confusion with the {@link #update(Number, Number)} method. */ public void update(int index, Number y) { XYDataItem item = getDataItem(index); // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = item.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } item.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } fireSeriesChanged(); } /** * A function to find the minimum of two values, but ignoring any * Double.NaN values. * * @param a the first value. * @param b the second value. * * @return The minimum of the two values. */ private double minIgnoreNaN(double a, double b) { if (Double.isNaN(a)) { return b; } else { if (Double.isNaN(b)) { return a; } else { return Math.min(a, b); } } } /** * A function to find the maximum of two values, but ignoring any * Double.NaN values. * * @param a the first value. * @param b the second value. * * @return The maximum of the two values. */ private double maxIgnoreNaN(double a, double b) { if (Double.isNaN(a)) { return b; } else { if (Double.isNaN(b)) { return a; } else { return Math.max(a, b); } } } /** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value (null permitted). * * @since 1.0.1 */ public void updateByIndex(int index, Number y) { update(index, y); } /** * Updates an item in the series. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). * * @throws SeriesException if there is no existing item with the specified * x-value. */ public void update(Number x, Number y) { int index = indexOf(x); if (index < 0) { throw new SeriesException("No observation for x = " + x); } else { updateByIndex(index, y); } } /** * Adds or updates an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param x the x-value. * @param y the y-value. * * @return The item that was overwritten, if any. * * @since 1.0.10 */ public XYDataItem addOrUpdate(double x, double y) { return addOrUpdate(new Double(x), new Double(y)); } /** * Adds or updates an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). * * @return A copy of the overwritten data item, or null if no * item was overwritten. */ public XYDataItem addOrUpdate(Number x, Number y) { if (x == null) { throw new IllegalArgumentException("Null 'x' argument."); } if (this.allowDuplicateXValues) { add(x, y); return null; } // if we get to here, we know that duplicate X values are not permitted XYDataItem overwritten = null; int index = indexOf(x); if (index >= 0) { XYDataItem existing = (XYDataItem) this.data.get(index); try { overwritten = (XYDataItem) existing.clone(); } catch (CloneNotSupportedException e) { throw new SeriesException("Couldn't clone XYDataItem!"); } // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = existing.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } existing.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = minIgnoreNaN(this.maxY, yy); } } else { // if the series is sorted, the negative index is a result from // Collections.binarySearch() and tells us where to insert the // new item...otherwise it will be just -1 and we should just // append the value to the list... XYDataItem item = new XYDataItem(x, y); if (this.autoSort) { this.data.add(-index - 1, item); } else { this.data.add(item); } updateBoundsForAddedItem(item); // check if this addition will exceed the maximum item count... if (getItemCount() > this.maximumItemCount) { XYDataItem removed = (XYDataItem) this.data.remove(0); updateBoundsForRemovedItem(removed); } } fireSeriesChanged(); return overwritten; } /** * Returns the index of the item with the specified x-value, or a negative * index if the series does not contain an item with that x-value. Be * aware that for an unsorted series, the index is found by iterating * through all items in the series. * * @param x the x-value (null not permitted). * * @return The index. */ public int indexOf(Number x) { if (this.autoSort) { return Collections.binarySearch(this.data, new XYDataItem(x, null)); } else { for (int i = 0; i < this.data.size(); i++) { XYDataItem item = (XYDataItem) this.data.get(i); if (item.getX().equals(x)) { return i; } } return -1; } } /** * Returns a new array containing the x and y values from this series. * * @return A new array containing the x and y values from this series. * * @since 1.0.4 */ public double[][] toArray() { int itemCount = getItemCount(); double[][] result = new double[2][itemCount]; for (int i = 0; i < itemCount; i++) { result[0][i] = this.getX(i).doubleValue(); Number y = getY(i); if (y != null) { result[1][i] = y.doubleValue(); } else { result[1][i] = Double.NaN; } } return result; } /** * Returns a clone of the series. * * @return A clone of the series. * * @throws CloneNotSupportedException if there is a cloning problem. */ public Object clone() throws CloneNotSupportedException { XYSeries clone = (XYSeries) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; } /** * Creates a new series by copying a subset of the data in this time series. * * @param start the index of the first item to copy. * @param end the index of the last item to copy. * * @return A series containing a copy of this series from start until end. * * @throws CloneNotSupportedException if there is a cloning problem. */ public XYSeries createCopy(int start, int end) throws CloneNotSupportedException { XYSeries copy = (XYSeries) super.clone(); copy.data = new java.util.ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { XYDataItem item = (XYDataItem) this.data.get(index); XYDataItem clone = (XYDataItem) item.clone(); try { copy.add(clone); } catch (SeriesException e) { System.err.println("Unable to add cloned data item."); } } } return copy; } /** * Tests this series for equality with an arbitrary object. * * @param obj the object to test against for equality * (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYSeries)) { return false; } if (!super.equals(obj)) { return false; } XYSeries that = (XYSeries) obj; if (this.maximumItemCount != that.maximumItemCount) { return false; } if (this.autoSort != that.autoSort) { return false; } if (this.allowDuplicateXValues != that.allowDuplicateXValues) { return false; } if (!ObjectUtilities.equal(this.data, that.data)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); // it is too slow to look at every data item, so let's just look at // the first, middle and last items... int count = getItemCount(); if (count > 0) { XYDataItem item = getDataItem(0); result = 29 * result + item.hashCode(); } if (count > 1) { XYDataItem item = getDataItem(count - 1); result = 29 * result + item.hashCode(); } if (count > 2) { XYDataItem item = getDataItem(count / 2); result = 29 * result + item.hashCode(); } result = 29 * result + this.maximumItemCount; result = 29 * result + (this.autoSort ? 1 : 0); result = 29 * result + (this.allowDuplicateXValues ? 1 : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYSeriesCollection.java0000644000175000017500000005377711173030414027316 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYSeriesCollection.java * ----------------------- * (C) Copyright 2001-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Aaron Metzger; * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 03-Apr-2002 : Added change listener code (DG); * 29-Apr-2002 : Added removeSeries, removeAllSeries methods (ARM); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 04-Aug-2003 : Added getSeries() method (DG); * 31-Mar-2004 : Modified to use an XYIntervalDelegate. * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * 17-Nov-2004 : Updated for changes to DomainInfo interface (DG); * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); * 28-Mar-2005 : Fixed bug in getSeries(int) method (1170825) (DG); * 05-Oct-2005 : Made the interval delegate a dataset listener (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 27-Nov-2006 : Added clone() override (DG); * 08-May-2007 : Added indexOf(XYSeries) method (DG); * 03-Dec-2007 : Added getSeries(Comparable) method (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * 27-Feb-2009 : Overridden getDomainOrder() to detect when all series are * sorted in ascending order (DG); * 06-Mar-2009 : Implemented RangeInfo (DG); * 06-Mar-2009 : Fixed equals() implementation (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.chart.HashUtilities; import org.jfree.data.DomainInfo; import org.jfree.data.DomainOrder; import org.jfree.data.Range; import org.jfree.data.RangeInfo; import org.jfree.data.UnknownKeyException; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * Represents a collection of {@link XYSeries} objects that can be used as a * dataset. */ public class XYSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, RangeInfo, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7590013825931496766L; /** The series that are included in the collection. */ private List data; /** The interval delegate (used to calculate the start and end x-values). */ private IntervalXYDelegate intervalDelegate; /** * Constructs an empty dataset. */ public XYSeriesCollection() { this(null); } /** * Constructs a dataset and populates it with a single series. * * @param series the series (null ignored). */ public XYSeriesCollection(XYSeries series) { this.data = new java.util.ArrayList(); this.intervalDelegate = new IntervalXYDelegate(this, false); addChangeListener(this.intervalDelegate); if (series != null) { this.data.add(series); series.addChangeListener(this); } } /** * Returns the order of the domain (X) values, if this is known. * * @return The domain order. */ public DomainOrder getDomainOrder() { int seriesCount = getSeriesCount(); for (int i = 0; i < seriesCount; i++) { XYSeries s = getSeries(i); if (!s.getAutoSort()) { return DomainOrder.NONE; // we can't be sure of the order } } return DomainOrder.ASCENDING; } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(XYSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series index (zero-based). */ public void removeSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds."); } // fetch the series, remove the change listener, then remove the series. XYSeries ts = (XYSeries) this.data.get(series); ts.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). */ public void removeSeries(XYSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. */ public void removeAllSeries() { // Unregister the collection as a change listener to each series in // the collection. for (int i = 0; i < this.data.size(); i++) { XYSeries series = (XYSeries) this.data.get(i); series.removeChangeListener(this); } // Remove all the series from the collection and notify listeners. this.data.clear(); fireDatasetChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a list of all the series in the collection. * * @return The list (which is unmodifiable). */ public List getSeries() { return Collections.unmodifiableList(this.data); } /** * Returns the index of the specified series, or -1 if that series is not * present in the dataset. * * @param series the series (null not permitted). * * @return The series index. * * @since 1.0.6 */ public int indexOf(XYSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } return this.data.indexOf(series); } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public XYSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (XYSeries) this.data.get(series); } /** * Returns a series from the collection. * * @param key the key (null not permitted). * * @return The series with the specified key. * * @throws UnknownKeyException if key is not found in the * collection. * * @since 1.0.9 */ public XYSeries getSeries(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { XYSeries series = (XYSeries) iterator.next(); if (key.equals(series.getKey())) { return series; } } throw new UnknownKeyException("Key not found: " + key); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for a series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public int getItemCount(int series) { // defer argument checking return getSeries(series).getItemCount(); } /** * Returns the x-value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public Number getX(int series, int item) { XYSeries ts = (XYSeries) this.data.get(series); XYDataItem xyItem = ts.getDataItem(item); return xyItem.getX(); } /** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The starting X value. */ public Number getStartX(int series, int item) { return this.intervalDelegate.getStartX(series, item); } /** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The ending X value. */ public Number getEndX(int series, int item) { return this.intervalDelegate.getEndX(series, item); } /** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param index the index of the item of interest (zero-based). * * @return The value (possibly null). */ public Number getY(int series, int index) { XYSeries ts = (XYSeries) this.data.get(series); XYDataItem xyItem = ts.getDataItem(index); return xyItem.getY(); } /** * Returns the starting Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The starting Y value. */ public Number getStartY(int series, int item) { return getY(series, item); } /** * Returns the ending Y value for the specified series and item. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The ending Y value. */ public Number getEndY(int series, int item) { return getY(series, item); } /** * Tests this collection for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof XYSeriesCollection)) { return false; } XYSeriesCollection that = (XYSeriesCollection) obj; if (!this.intervalDelegate.equals(that.intervalDelegate)) { return false; } return ObjectUtilities.equal(this.data, that.data); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem. */ public Object clone() throws CloneNotSupportedException { XYSeriesCollection clone = (XYSeriesCollection) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); clone.intervalDelegate = (IntervalXYDelegate) this.intervalDelegate.clone(); return clone; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int hash = 5; hash = HashUtilities.hashCode(hash, this.intervalDelegate); hash = HashUtilities.hashCode(hash, this.data); return hash; } /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { if (includeInterval) { return this.intervalDelegate.getDomainLowerBound(includeInterval); } else { double result = Double.NaN; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double lowX = series.getMinX(); if (Double.isNaN(result)) { result = lowX; } else { if (!Double.isNaN(lowX)) { result = Math.min(result, lowX); } } } return result; } } /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { if (includeInterval) { return this.intervalDelegate.getDomainUpperBound(includeInterval); } else { double result = Double.NaN; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double hiX = series.getMaxX(); if (Double.isNaN(result)) { result = hiX; } else { if (!Double.isNaN(hiX)) { result = Math.max(result, hiX); } } } return result; } } /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range (or null if the dataset contains no * values). */ public Range getDomainBounds(boolean includeInterval) { if (includeInterval) { return this.intervalDelegate.getDomainBounds(includeInterval); } else { double lower = Double.POSITIVE_INFINITY; double upper = Double.NEGATIVE_INFINITY; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double minX = series.getMinX(); if (!Double.isNaN(minX)) { lower = Math.min(lower, minX); } double maxX = series.getMaxX(); if (!Double.isNaN(maxX)) { upper = Math.max(upper, maxX); } } if (lower > upper) { return null; } else { return new Range(lower, upper); } } } /** * Returns the interval width. This is used to calculate the start and end * x-values, if/when the dataset is used as an {@link IntervalXYDataset}. * * @return The interval width. */ public double getIntervalWidth() { return this.intervalDelegate.getIntervalWidth(); } /** * Sets the interval width and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param width the width (negative values not permitted). */ public void setIntervalWidth(double width) { if (width < 0.0) { throw new IllegalArgumentException("Negative 'width' argument."); } this.intervalDelegate.setFixedIntervalWidth(width); fireDatasetChanged(); } /** * Returns the interval position factor. * * @return The interval position factor. */ public double getIntervalPositionFactor() { return this.intervalDelegate.getIntervalPositionFactor(); } /** * Sets the interval position factor. This controls where the x-value is in * relation to the interval surrounding the x-value (0.0 means the x-value * will be positioned at the start, 0.5 in the middle, and 1.0 at the end). * * @param factor the factor. */ public void setIntervalPositionFactor(double factor) { this.intervalDelegate.setIntervalPositionFactor(factor); fireDatasetChanged(); } /** * Returns whether the interval width is automatically calculated or not. * * @return Whether the width is automatically calculated or not. */ public boolean isAutoWidth() { return this.intervalDelegate.isAutoWidth(); } /** * Sets the flag that indicates wether the interval width is automatically * calculated or not. * * @param b a boolean. */ public void setAutoWidth(boolean b) { this.intervalDelegate.setAutoWidth(b); fireDatasetChanged(); } /** * Returns the range of the values in this dataset's range. * * @param includeInterval ignored. * * @return The range (or null if the dataset contains no * values). */ public Range getRangeBounds(boolean includeInterval) { double lower = Double.POSITIVE_INFINITY; double upper = Double.NEGATIVE_INFINITY; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double minY = series.getMinY(); if (!Double.isNaN(minY)) { lower = Math.min(lower, minY); } double maxY = series.getMaxY(); if (!Double.isNaN(maxY)) { upper = Math.max(upper, maxY); } } if (lower > upper) { return null; } else { return new Range(lower, upper); } } /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. */ public double getRangeLowerBound(boolean includeInterval) { double result = Double.NaN; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double lowY = series.getMinY(); if (Double.isNaN(result)) { result = lowY; } else { if (!Double.isNaN(lowY)) { result = Math.min(result, lowY); } } } return result; } /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ public double getRangeUpperBound(boolean includeInterval) { double result = Double.NaN; int seriesCount = getSeriesCount(); for (int s = 0; s < seriesCount; s++) { XYSeries series = getSeries(s); double hiY = series.getMaxY(); if (Double.isNaN(result)) { result = hiY; } else { if (!Double.isNaN(hiY)) { result = Math.max(result, hiY); } } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XYZDataset.java0000644000175000017500000000472711173030414025556 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * XYZDataset.java * --------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 31-Oct-2001 : Initial version (DG); * 05-May-2004 : Added getZ() method; * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * */ package org.jfree.data.xy; /** * The interface through which JFreeChart obtains data in the form of (x, y, z) * items - used for XY and XYZ plots. */ public interface XYZDataset extends XYDataset { /** * Returns the z-value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The z-value (possibly null). */ public Number getZ(int series, int item); /** * Returns the z-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The z-value. */ public double getZValue(int series, int item); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/XisSymbolic.java0000644000175000017500000000514011173030414026011 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * XisSymbolic.java * ---------------- * (C) Copyright 2006-2008, by Anthony Boulestreau and Contributors. * * Original Author: Anthony Boulestreau; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 29-Mar-2002 : First version (AB); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.xy; /** * Represent a data set where X is a symbolic values. Each symbolic value is * linked with an Integer. */ public interface XisSymbolic { /** * Returns the list of symbolic values. * * @return An array of symbolic values. */ public String[] getXSymbolicValues(); /** * Returns the symbolic value of the data set specified by * series and item parameters. * * @param series value of the serie. * @param item value of the item. * * @return The symbolic value. */ public String getXSymbolicValue(int series, int item); /** * Returns the symbolic value linked with the specified * Integer. * * @param val value of the integer linked with the symbolic value. * * @return The symbolic value. */ public String getXSymbolicValue(Integer val); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/YInterval.java0000644000175000017500000000673011173030414025467 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * YInterval.java * -------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy; import java.io.Serializable; /** * A y-interval. This class is used internally by the * {@link YIntervalDataItem} class. * * @since 1.0.3 */ public class YInterval implements Serializable { /** The y-value. */ private double y; /** The lower bound of the y-interval. */ private double yLow; /** The upper bound of the y-interval. */ private double yHigh; /** * Creates a new instance of YInterval. * * @param y the y-value. * @param yLow the lower bound of the y-interval. * @param yHigh the upper bound of the y-interval. */ public YInterval(double y, double yLow, double yHigh) { this.y = y; this.yLow = yLow; this.yHigh = yHigh; } /** * Returns the y-value. * * @return The y-value. */ public double getY() { return this.y; } /** * Returns the lower bound of the y-interval. * * @return The lower bound of the y-interval. */ public double getYLow() { return this.yLow; } /** * Returns the upper bound of the y-interval. * * @return The upper bound of the y-interval. */ public double getYHigh() { return this.yHigh; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof YInterval)) { return false; } YInterval that = (YInterval) obj; if (this.y != that.y) { return false; } if (this.yLow != that.yLow) { return false; } if (this.yHigh != that.yHigh) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/YIntervalDataItem.java0000644000175000017500000000656311173030414027104 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * YIntervalDataItem.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; /** * An item representing data in the form (x, y, y-low, y-high). * * @since 1.0.3 */ public class YIntervalDataItem extends ComparableObjectItem { /** * Creates a new instance of YIntervalItem. * * @param x the x-value. * @param y the y-value. * @param yLow the lower bound of the y-interval. * @param yHigh the upper bound of the y-interval. */ public YIntervalDataItem(double x, double y, double yLow, double yHigh) { super(new Double(x), new YInterval(y, yLow, yHigh)); } /** * Returns the x-value. * * @return The x-value (never null). */ public Double getX() { return (Double) getComparable(); } /** * Returns the y-value. * * @return The y-value. */ public double getYValue() { YInterval interval = (YInterval) getObject(); if (interval != null) { return interval.getY(); } else { return Double.NaN; } } /** * Returns the lower bound of the y-interval. * * @return The lower bound of the y-interval. */ public double getYLowValue() { YInterval interval = (YInterval) getObject(); if (interval != null) { return interval.getYLow(); } else { return Double.NaN; } } /** * Returns the upper bound of the y-interval. * * @return The upper bound of the y-interval. */ public double getYHighValue() { YInterval interval = (YInterval) getObject(); if (interval != null) { return interval.getYHigh(); } else { return Double.NaN; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/YIntervalSeries.java0000644000175000017500000001200411173030414026631 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * YIntervalSeries.java * -------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 20-Feb-2007 : Added getYHighValue() and getYLowValue() methods (DG); * */ package org.jfree.data.xy; import org.jfree.data.ComparableObjectItem; import org.jfree.data.ComparableObjectSeries; /** * A list of (x, y, y-low, y-high) data items. * * @since 1.0.3 * * @see YIntervalSeriesCollection */ public class YIntervalSeries extends ComparableObjectSeries { /** * Creates a new empty series. By default, items added to the series will * be sorted into ascending order by x-value, and duplicate x-values will * be allowed (these defaults can be modified with another constructor. * * @param key the series key (null not permitted). */ public YIntervalSeries(Comparable key) { this(key, true, true); } /** * Constructs a new xy-series that contains no data. You can specify * whether or not duplicate x-values are allowed for the series. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. * @param allowDuplicateXValues a flag that controls whether duplicate * x-values are allowed. */ public YIntervalSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key, autoSort, allowDuplicateXValues); } /** * Adds a data item to the series. * * @param x the x-value. * @param y the y-value. * @param yLow the lower bound of the y-interval. * @param yHigh the upper bound of the y-interval. */ public void add(double x, double y, double yLow, double yHigh) { super.add(new YIntervalDataItem(x, y, yLow, yHigh), true); } /** * Returns the x-value for the specified item. * * @param index the item index. * * @return The x-value (never null). */ public Number getX(int index) { YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); return item.getX(); } /** * Returns the y-value for the specified item. * * @param index the item index. * * @return The y-value. */ public double getYValue(int index) { YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); return item.getYValue(); } /** * Returns the lower bound of the Y-interval for the specified item in the * series. * * @param index the item index. * * @return The lower bound of the Y-interval. * * @since 1.0.5 */ public double getYLowValue(int index) { YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); return item.getYLowValue(); } /** * Returns the upper bound of the y-interval for the specified item in the * series. * * @param index the item index. * * @return The upper bound of the y-interval. * * @since 1.0.5 */ public double getYHighValue(int index) { YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); return item.getYHighValue(); } /** * Returns the data item at the specified index. * * @param index the item index. * * @return The data item. */ public ComparableObjectItem getDataItem(int index) { return super.getDataItem(index); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/YIntervalSeriesCollection.java0000644000175000017500000002552411173030414030660 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * YIntervalSeriesCollection.java * ------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 27-Nov-2006 : Added clone() override (DG); * 20-Feb-2007 : Added getYValue(), getStartYValue() and getEndYValue() * methods (DG); * 18-Jan-2008 : Added removeSeries() and removeAllSeries() methods (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); * */ package org.jfree.data.xy; import java.io.Serializable; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A collection of {@link YIntervalSeries} objects. * * @since 1.0.3 * * @see YIntervalSeries */ public class YIntervalSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, PublicCloneable, Serializable { /** Storage for the data series. */ private List data; /** * Creates a new instance of YIntervalSeriesCollection. */ public YIntervalSeriesCollection() { this.data = new java.util.ArrayList(); } /** * Adds a series to the collection and sends a {@link DatasetChangeEvent} * to all registered listeners. * * @param series the series (null not permitted). */ public void addSeries(YIntervalSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); } /** * Returns the number of series in the collection. * * @return The series count. */ public int getSeriesCount() { return this.data.size(); } /** * Returns a series from the collection. * * @param series the series index (zero-based). * * @return The series. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public YIntervalSeries getSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (YIntervalSeries) this.data.get(series); } /** * Returns the key for a series. * * @param series the series index (in the range 0 to * getSeriesCount() - 1). * * @return The key for a series. * * @throws IllegalArgumentException if series is not in the * specified range. */ public Comparable getSeriesKey(int series) { // defer argument checking return getSeries(series).getKey(); } /** * Returns the number of items in the specified series. * * @param series the series (zero-based index). * * @return The item count. * * @throws IllegalArgumentException if series is not in the * range 0 to getSeriesCount() - 1. */ public int getItemCount(int series) { // defer argument checking return getSeries(series).getItemCount(); } /** * Returns the x-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getX(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return s.getX(item); } /** * Returns the y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getYValue(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return s.getYValue(item); } /** * Returns the start y-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ public double getStartYValue(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return s.getYLowValue(item); } /** * Returns the end y-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The value. */ public double getEndYValue(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return s.getYHighValue(item); } /** * Returns the y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The y-value. */ public Number getY(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return new Double(s.getYValue(item)); } /** * Returns the start x-value for an item within a series. This method * maps directly to {@link #getX(int, int)}. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getStartX(int series, int item) { return getX(series, item); } /** * Returns the end x-value for an item within a series. This method * maps directly to {@link #getX(int, int)}. * * @param series the series index. * @param item the item index. * * @return The x-value. */ public Number getEndX(int series, int item) { return getX(series, item); } /** * Returns the start y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The start y-value. */ public Number getStartY(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return new Double(s.getYLowValue(item)); } /** * Returns the end y-value for an item within a series. * * @param series the series index. * @param item the item index. * * @return The end y-value. */ public Number getEndY(int series, int item) { YIntervalSeries s = (YIntervalSeries) this.data.get(series); return new Double(s.getYHighValue(item)); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series index (zero-based). * * @since 1.0.10 */ public void removeSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds."); } YIntervalSeries ts = (YIntervalSeries) this.data.get(series); ts.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } /** * Removes a series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param series the series (null not permitted). * * @since 1.0.10 */ public void removeSeries(YIntervalSeries series) { if (series == null) { throw new IllegalArgumentException("Null 'series' argument."); } if (this.data.contains(series)) { series.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } } /** * Removes all the series from the collection and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.10 */ public void removeAllSeries() { // Unregister the collection as a change listener to each series in // the collection. for (int i = 0; i < this.data.size(); i++) { YIntervalSeries series = (YIntervalSeries) this.data.get(i); series.removeChangeListener(this); } this.data.clear(); fireDatasetChanged(); } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof YIntervalSeriesCollection)) { return false; } YIntervalSeriesCollection that = (YIntervalSeriesCollection) obj; return ObjectUtilities.equal(this.data, that.data); } /** * Returns a clone of this instance. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem. */ public Object clone() throws CloneNotSupportedException { YIntervalSeriesCollection clone = (YIntervalSeriesCollection) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/YWithXInterval.java0000644000175000017500000000753411173030414026456 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * YWithXInterval.java * ------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy; import java.io.Serializable; /** * A y-value plus the bounds for the related x-interval. This curious * combination exists as an implementation detail, to fit into the structure * of the ComparableObjectSeries class. It would have been possible to * simply reuse the {@link YInterval} class by assuming that the y-interval * in fact represents the x-interval, however I decided it was better to * duplicate some code in order to document the real intent. * * @since 1.0.3 */ public class YWithXInterval implements Serializable { /** The y-value. */ private double y; /** The lower bound of the x-interval. */ private double xLow; /** The upper bound of the x-interval. */ private double xHigh; /** * Creates a new instance of YWithXInterval. * * @param y the y-value. * @param xLow the lower bound of the x-interval. * @param xHigh the upper bound of the x-interval. */ public YWithXInterval(double y, double xLow, double xHigh) { this.y = y; this.xLow = xLow; this.xHigh = xHigh; } /** * Returns the y-value. * * @return The y-value. */ public double getY() { return this.y; } /** * Returns the lower bound of the x-interval. * * @return The lower bound of the x-interval. */ public double getXLow() { return this.xLow; } /** * Returns the upper bound of the x-interval. * * @return The upper bound of the x-interval. */ public double getXHigh() { return this.xHigh; } /** * Tests this instance for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof YWithXInterval)) { return false; } YWithXInterval that = (YWithXInterval) obj; if (this.y != that.y) { return false; } if (this.xLow != that.xLow) { return false; } if (this.xHigh != that.xHigh) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/YisSymbolic.java0000644000175000017500000000533311173030414026016 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * YisSymbolic.java * ---------------- * (C) Copyright 2006-2008, by Anthony Boulestreau and Contributors. * * Original Author: Anthony Boulestreau; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes (from 21-Aug-2001) * -------------------------- * 29-Mar-2002 : First version (AB); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.data.xy; /** * Represent a data set where Y is a symbolic values. Each symbolic value is * linked with an Integer. */ public interface YisSymbolic { /** * Returns the list of symbolic values. * * @return The symbolic values. */ public String[] getYSymbolicValues(); /** * Returns the symbolic value of the data set specified by * series and item parameters. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The symbolic value. */ public String getYSymbolicValue(int series, int item); /** * Returns the symbolic value linked with the specified * Integer. * * @param val value of the integer linked with the symbolic value. * * @return The symbolic value. */ public String getYSymbolicValue(Integer val); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/xy/package.html0000644000175000017500000000031011173030414025154 0ustar vincentvincent A package containing the {@link org.jfree.data.xy.XYDataset} interface and related classes. libjfreechart-java-1.0.13.orig/source/org/jfree/data/ComparableObjectItem.java0000644000175000017500000001264511173030414027127 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ComparableObjectItem.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Oct-2006 : New class, based on XYDataItem (DG); * */ package org.jfree.data; import java.io.Serializable; import org.jfree.util.ObjectUtilities; /** * Represents one (Comparable, Object) data item for use in a * {@link ComparableObjectSeries}. * * @since 1.0.3 */ public class ComparableObjectItem implements Cloneable, Comparable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2751513470325494890L; /** The x-value. */ private Comparable x; /** The y-value. */ private Object obj; /** * Constructs a new data item. * * @param x the x-value (null NOT permitted). * @param y the y-value (null permitted). */ public ComparableObjectItem(Comparable x, Object y) { if (x == null) { throw new IllegalArgumentException("Null 'x' argument."); } this.x = x; this.obj = y; } /** * Returns the x-value. * * @return The x-value (never null). */ protected Comparable getComparable() { return this.x; } /** * Returns the y-value. * * @return The y-value (possibly null). */ protected Object getObject() { return this.obj; } /** * Sets the y-value for this data item. Note that there is no * corresponding method to change the x-value. * * @param y the new y-value (null permitted). */ protected void setObject(Object y) { this.obj = y; } /** * Returns an integer indicating the order of this object relative to * another object. *

      * For the order we consider only the x-value: * negative == "less-than", zero == "equal", positive == "greater-than". * * @param o1 the object being compared to. * * @return An integer indicating the order of this data pair object * relative to another object. */ public int compareTo(Object o1) { int result; // CASE 1 : Comparing to another ComparableObjectItem object // --------------------------------------------------------- if (o1 instanceof ComparableObjectItem) { ComparableObjectItem that = (ComparableObjectItem) o1; return this.x.compareTo(that.x); } // CASE 2 : Comparing to a general object // --------------------------------------------- else { // consider these to be ordered after general objects result = 1; } return result; } /** * Returns a clone of this object. * * @return A clone. * * @throws CloneNotSupportedException not thrown by this class, but * subclasses may differ. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Tests if this object is equal to another. * * @param obj the object to test against for equality (null * permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ComparableObjectItem)) { return false; } ComparableObjectItem that = (ComparableObjectItem) obj; if (!this.x.equals(that.x)) { return false; } if (!ObjectUtilities.equal(this.obj, that.obj)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = this.x.hashCode(); result = 29 * result + (this.obj != null ? this.obj.hashCode() : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/ComparableObjectSeries.java0000644000175000017500000003577211173030414027471 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * ComparableObjectSeries.java * --------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Oct-2006 : New class (DG); * 31-Oct-2007 : Implemented faster hashCode() (DG); * 27-Nov-2007 : Changed clear() from protected to public (DG); * */ package org.jfree.data; import java.io.Serializable; import java.util.Collections; import java.util.List; import org.jfree.data.general.Series; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesException; import org.jfree.util.ObjectUtilities; /** * A (possibly ordered) list of (Comparable, Object) data items. * * @since 1.0.3 */ public class ComparableObjectSeries extends Series implements Cloneable, Serializable { /** Storage for the data items in the series. */ protected List data; /** The maximum number of items for the series. */ private int maximumItemCount = Integer.MAX_VALUE; /** A flag that controls whether the items are automatically sorted. */ private boolean autoSort; /** A flag that controls whether or not duplicate x-values are allowed. */ private boolean allowDuplicateXValues; /** * Creates a new empty series. By default, items added to the series will * be sorted into ascending order by x-value, and duplicate x-values will * be allowed (these defaults can be modified with another constructor. * * @param key the series key (null not permitted). */ public ComparableObjectSeries(Comparable key) { this(key, true, true); } /** * Constructs a new series that contains no data. You can specify * whether or not duplicate x-values are allowed for the series. * * @param key the series key (null not permitted). * @param autoSort a flag that controls whether or not the items in the * series are sorted. * @param allowDuplicateXValues a flag that controls whether duplicate * x-values are allowed. */ public ComparableObjectSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key); this.data = new java.util.ArrayList(); this.autoSort = autoSort; this.allowDuplicateXValues = allowDuplicateXValues; } /** * Returns the flag that controls whether the items in the series are * automatically sorted. There is no setter for this flag, it must be * defined in the series constructor. * * @return A boolean. */ public boolean getAutoSort() { return this.autoSort; } /** * Returns a flag that controls whether duplicate x-values are allowed. * This flag can only be set in the constructor. * * @return A boolean. */ public boolean getAllowDuplicateXValues() { return this.allowDuplicateXValues; } /** * Returns the number of items in the series. * * @return The item count. */ public int getItemCount() { return this.data.size(); } /** * Returns the maximum number of items that will be retained in the series. * The default value is Integer.MAX_VALUE. * * @return The maximum item count. * @see #setMaximumItemCount(int) */ public int getMaximumItemCount() { return this.maximumItemCount; } /** * Sets the maximum number of items that will be retained in the series. * If you add a new item to the series such that the number of items will * exceed the maximum item count, then the first element in the series is * automatically removed, ensuring that the maximum item count is not * exceeded. *

      * Typically this value is set before the series is populated with data, * but if it is applied later, it may cause some items to be removed from * the series (in which case a {@link SeriesChangeEvent} will be sent to * all registered listeners. * * @param maximum the maximum number of items for the series. */ public void setMaximumItemCount(int maximum) { this.maximumItemCount = maximum; boolean dataRemoved = false; while (this.data.size() > maximum) { this.data.remove(0); dataRemoved = true; } if (dataRemoved) { fireSeriesChanged(); } } /** * Adds new data to the series and sends a {@link SeriesChangeEvent} to * all registered listeners. *

      * Throws an exception if the x-value is a duplicate AND the * allowDuplicateXValues flag is false. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). */ protected void add(Comparable x, Object y) { // argument checking delegated... add(x, y, true); } /** * Adds new data to the series and, if requested, sends a * {@link SeriesChangeEvent} to all registered listeners. *

      * Throws an exception if the x-value is a duplicate AND the * allowDuplicateXValues flag is false. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). * @param notify a flag the controls whether or not a * {@link SeriesChangeEvent} is sent to all registered * listeners. */ protected void add(Comparable x, Object y, boolean notify) { // delegate argument checking to XYDataItem... ComparableObjectItem item = new ComparableObjectItem(x, y); add(item, notify); } /** * Adds a data item to the series and, if requested, sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param item the (x, y) item (null not permitted). * @param notify a flag that controls whether or not a * {@link SeriesChangeEvent} is sent to all registered * listeners. */ protected void add(ComparableObjectItem item, boolean notify) { if (item == null) { throw new IllegalArgumentException("Null 'item' argument."); } if (this.autoSort) { int index = Collections.binarySearch(this.data, item); if (index < 0) { this.data.add(-index - 1, item); } else { if (this.allowDuplicateXValues) { // need to make sure we are adding *after* any duplicates int size = this.data.size(); while (index < size && item.compareTo(this.data.get(index)) == 0) { index++; } if (index < this.data.size()) { this.data.add(index, item); } else { this.data.add(item); } } else { throw new SeriesException("X-value already exists."); } } } else { if (!this.allowDuplicateXValues) { // can't allow duplicate values, so we need to check whether // there is an item with the given x-value already int index = indexOf(item.getComparable()); if (index >= 0) { throw new SeriesException("X-value already exists."); } } this.data.add(item); } if (getItemCount() > this.maximumItemCount) { this.data.remove(0); } if (notify) { fireSeriesChanged(); } } /** * Returns the index of the item with the specified x-value, or a negative * index if the series does not contain an item with that x-value. Be * aware that for an unsorted series, the index is found by iterating * through all items in the series. * * @param x the x-value (null not permitted). * * @return The index. */ public int indexOf(Comparable x) { if (this.autoSort) { return Collections.binarySearch(this.data, new ComparableObjectItem( x, null)); } else { for (int i = 0; i < this.data.size(); i++) { ComparableObjectItem item = (ComparableObjectItem) this.data.get(i); if (item.getComparable().equals(x)) { return i; } } return -1; } } /** * Updates an item in the series. * * @param x the x-value (null not permitted). * @param y the y-value (null permitted). * * @throws SeriesException if there is no existing item with the specified * x-value. */ protected void update(Comparable x, Object y) { int index = indexOf(x); if (index < 0) { throw new SeriesException("No observation for x = " + x); } else { ComparableObjectItem item = getDataItem(index); item.setObject(y); fireSeriesChanged(); } } /** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value (null permitted). */ protected void updateByIndex(int index, Object y) { ComparableObjectItem item = getDataItem(index); item.setObject(y); fireSeriesChanged(); } /** * Return the data item with the specified index. * * @param index the index. * * @return The data item with the specified index. */ protected ComparableObjectItem getDataItem(int index) { return (ComparableObjectItem) this.data.get(index); } /** * Deletes a range of items from the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param start the start index (zero-based). * @param end the end index (zero-based). */ protected void delete(int start, int end) { for (int i = start; i <= end; i++) { this.data.remove(start); } fireSeriesChanged(); } /** * Removes all data items from the series and, unless the series is * already empty, sends a {@link SeriesChangeEvent} to all registered * listeners. */ public void clear() { if (this.data.size() > 0) { this.data.clear(); fireSeriesChanged(); } } /** * Removes the item at the specified index and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the index. * * @return The item removed. */ protected ComparableObjectItem remove(int index) { ComparableObjectItem result = (ComparableObjectItem) this.data.remove( index); fireSeriesChanged(); return result; } /** * Removes the item with the specified x-value and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param x the x-value. * @return The item removed. */ public ComparableObjectItem remove(Comparable x) { return remove(indexOf(x)); } /** * Tests this series for equality with an arbitrary object. * * @param obj the object to test against for equality * (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ComparableObjectSeries)) { return false; } if (!super.equals(obj)) { return false; } ComparableObjectSeries that = (ComparableObjectSeries) obj; if (this.maximumItemCount != that.maximumItemCount) { return false; } if (this.autoSort != that.autoSort) { return false; } if (this.allowDuplicateXValues != that.allowDuplicateXValues) { return false; } if (!ObjectUtilities.equal(this.data, that.data)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result = super.hashCode(); // it is too slow to look at every data item, so let's just look at // the first, middle and last items... int count = getItemCount(); if (count > 0) { ComparableObjectItem item = getDataItem(0); result = 29 * result + item.hashCode(); } if (count > 1) { ComparableObjectItem item = getDataItem(count - 1); result = 29 * result + item.hashCode(); } if (count > 2) { ComparableObjectItem item = getDataItem(count / 2); result = 29 * result + item.hashCode(); } result = 29 * result + this.maximumItemCount; result = 29 * result + (this.autoSort ? 1 : 0); result = 29 * result + (this.allowDuplicateXValues ? 1 : 0); return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/DataUtilities.java0000644000175000017500000002416011173030414025654 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * DataUtilities.java * ------------------ * (C) Copyright 2003-2009, by Object Refinery Limited and contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Peter Kolb (patch 2511330); * * Changes * ------- * 05-Mar-2003 : Version 1 (DG); * 03-Mar-2005 : Moved createNumberArray() and createNumberArray2D() methods * from the DatasetUtilities class (DG); * 17-May-2005 : Added calculateColumnTotal() and calculateRowTotal() * methods (DG); * 28-Jan-2009 : Added equal(double[][], double[][]) method (DG); * 28-Jan-2009 : Added clone(double[][]) method (DG); * 04-Feb-2009 : Added calculateColumnTotal/RowTotal variants (PK); * */ package org.jfree.data; import java.util.Arrays; import org.jfree.data.general.DatasetUtilities; /** * Utility methods for use with some of the data classes (but not the datasets, * see {@link DatasetUtilities}). */ public abstract class DataUtilities { /** * Tests two arrays for equality. To be considered equal, the arrays must * have exactly the same dimensions, and the values in each array must also * match (two values that qre both NaN or both INF are considered equal * in this test). * * @param a the first array (null permitted). * @param b the second array (null permitted). * * @return A boolean. * * @since 1.0.13 */ public static boolean equal(double[][] a, double[][] b) { if (a == null) { return (b == null); } if (b == null) { return false; // already know 'a' isn't null } if (a.length != b.length) { return false; } for (int i = 0; i < a.length; i++) { if (!Arrays.equals(a[i], b[i])) { return false; } } return true; } /** * Returns a clone of the specified array. * * @param source the source array (null not permitted). * * @return A clone of the array. * * @since 1.0.13 */ public static double[][] clone(double[][] source) { if (source == null) { throw new IllegalArgumentException("Null 'source' argument."); } double[][] clone = new double[source.length][]; for (int i = 0; i < source.length; i++) { if (source[i] != null) { double[] row = new double[source[i].length]; System.arraycopy(source[i], 0, row, 0, source[i].length); clone[i] = row; } } return clone; } /** * Returns the total of the values in one column of the supplied data * table. * * @param data the table of values (null not permitted). * @param column the column index (zero-based). * * @return The total of the values in the specified column. */ public static double calculateColumnTotal(Values2D data, int column) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int rowCount = data.getRowCount(); for (int r = 0; r < rowCount; r++) { Number n = data.getValue(r, column); if (n != null) { total += n.doubleValue(); } } return total; } /** * Returns the total of the values in one column of the supplied data * table by taking only the row numbers in the array into account. * * @param data the table of values (null not permitted). * @param column the column index (zero-based). * @param validRows the array with valid rows (zero-based). * * @return The total of the valid values in the specified column. * * @since 1.0.13 */ public static double calculateColumnTotal(Values2D data, int column, int[] validRows) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int rowCount = data.getRowCount(); for (int v = 0; v < validRows.length; v++) { int row = validRows[v]; if (row < rowCount) { Number n = data.getValue(row, column); if (n != null) { total += n.doubleValue(); } } } return total; } /** * Returns the total of the values in one row of the supplied data * table. * * @param data the table of values (null not permitted). * @param row the row index (zero-based). * * @return The total of the values in the specified row. */ public static double calculateRowTotal(Values2D data, int row) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int columnCount = data.getColumnCount(); for (int c = 0; c < columnCount; c++) { Number n = data.getValue(row, c); if (n != null) { total += n.doubleValue(); } } return total; } /** * Returns the total of the values in one row of the supplied data * table by taking only the column numbers in the array into account. * * @param data the table of values (null not permitted). * @param row the row index (zero-based). * @param validCols the array with valid cols (zero-based). * * @return The total of the valid values in the specified row. * * @since 1.0.13 */ public static double calculateRowTotal(Values2D data, int row, int[] validCols) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } double total = 0.0; int colCount = data.getColumnCount(); for (int v = 0; v < validCols.length; v++) { int col = validCols[v]; if (col < colCount) { Number n = data.getValue(row, col); if (n != null) { total += n.doubleValue(); } } } return total; } /** * Constructs an array of Number objects from an array of * double primitives. * * @param data the data (null not permitted). * * @return An array of Double. */ public static Number[] createNumberArray(double[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } Number[] result = new Number[data.length]; for (int i = 0; i < data.length; i++) { result[i] = new Double(data[i]); } return result; } /** * Constructs an array of arrays of Number objects from a * corresponding structure containing double primitives. * * @param data the data (null not permitted). * * @return An array of Double. */ public static Number[][] createNumberArray2D(double[][] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } int l1 = data.length; Number[][] result = new Number[l1][]; for (int i = 0; i < l1; i++) { result[i] = createNumberArray(data[i]); } return result; } /** * Returns a {@link KeyedValues} instance that contains the cumulative * percentage values for the data in another {@link KeyedValues} instance. *

      * The percentages are values between 0.0 and 1.0 (where 1.0 = 100%). * * @param data the data (null not permitted). * * @return The cumulative percentages. */ public static KeyedValues getCumulativePercentages(KeyedValues data) { if (data == null) { throw new IllegalArgumentException("Null 'data' argument."); } DefaultKeyedValues result = new DefaultKeyedValues(); double total = 0.0; for (int i = 0; i < data.getItemCount(); i++) { Number v = data.getValue(i); if (v != null) { total = total + v.doubleValue(); } } double runningTotal = 0.0; for (int i = 0; i < data.getItemCount(); i++) { Number v = data.getValue(i); if (v != null) { runningTotal = runningTotal + v.doubleValue(); } result.addValue(data.getKey(i), new Double(runningTotal / total)); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/DefaultKeyedValue.java0000644000175000017500000001241611173030414026453 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DefaultKeyedValue.java * ---------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 31-Oct-2002 : Version 1 (DG); * 13-Mar-2003 : Added equals() method, and implemented Serializable (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.base (DG); * 15-Sep-2004 : Added PublicCloneable interface (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 11-Jun-2007 : Added toString() method to help with debugging (DG); * 15-Feb-2008 : Prevent null key (DG); * 07-Apr-2008 : Removed to-do item (DG); * */ package org.jfree.data; import java.io.Serializable; import org.jfree.util.PublicCloneable; /** * A (key, value) pair. This class provides a default implementation * of the {@link KeyedValue} interface. */ public class DefaultKeyedValue implements KeyedValue, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -7388924517460437712L; /** The key. */ private Comparable key; /** The value. */ private Number value; /** * Creates a new (key, value) item. * * @param key the key (should be immutable, null not * permitted). * @param value the value (null permitted). */ public DefaultKeyedValue(Comparable key, Number value) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } this.key = key; this.value = value; } /** * Returns the key. * * @return The key (never null). */ public Comparable getKey() { return this.key; } /** * Returns the value. * * @return The value (possibly null). */ public Number getValue() { return this.value; } /** * Sets the value. * * @param value the value (null permitted). */ public synchronized void setValue(Number value) { this.value = value; } /** * Tests this key-value pair for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof DefaultKeyedValue)) { return false; } DefaultKeyedValue that = (DefaultKeyedValue) obj; if (!this.key.equals(that.key)) { return false; } if (this.value != null ? !this.value.equals(that.value) : that.value != null) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = (this.key != null ? this.key.hashCode() : 0); result = 29 * result + (this.value != null ? this.value.hashCode() : 0); return result; } /** * Returns a clone. It is assumed that both the key and value are * immutable objects, so only the references are cloned, not the objects * themselves. * * @return A clone. * * @throws CloneNotSupportedException Not thrown by this class, but * subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { DefaultKeyedValue clone = (DefaultKeyedValue) super.clone(); return clone; } /** * Returns a string representing this instance, primarily useful for * debugging. * * @return A string. */ public String toString() { return "(" + this.key.toString() + ", " + this.value.toString() + ")"; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/DefaultKeyedValues.java0000644000175000017500000003557311173030414026647 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DefaultKeyedValues.java * ----------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Thomas Morgner; * * Changes: * -------- * 31-Oct-2002 : Version 1 (DG); * 11-Feb-2003 : Fixed bug in getValue(key) method for unrecognised key (DG); * 05-Mar-2003 : Added methods to sort stored data 'by key' or 'by value' (DG); * 13-Mar-2003 : Implemented Serializable (DG); * 08-Apr-2003 : Modified removeValue(Comparable) method to fix bug 717049 (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * 27-Aug-2003 : Moved SortOrder from org.jfree.data --> org.jfree.util (DG); * 09-Feb-2004 : Modified getIndex() method - see bug report 893256 (DG); * 15-Sep-2004 : Updated clone() method and added PublicCloneable * interface (DG); * 25-Nov-2004 : Small update to the clone() implementation (DG); * 24-Feb-2005 : Added methods addValue(Comparable, double) and * setValue(Comparable, double) for convenience (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 31-Jul-2006 : Added a clear() method (DG); * 01-Aug-2006 : Added argument check to getIndex() method (DG); * 30-Apr-2007 : Added insertValue() methods (DG); * 31-Oct-2007 : Performance improvements by using separate lists for keys and * values (TM); * 21-Nov-2007 : Fixed bug in removeValue() method from previous patch (DG); * */ package org.jfree.data; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.List; import org.jfree.util.PublicCloneable; import org.jfree.util.SortOrder; /** * An ordered list of (key, value) items. This class provides a default * implementation of the {@link KeyedValues} interface. */ public class DefaultKeyedValues implements KeyedValues, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 8468154364608194797L; /** Storage for the keys. */ private ArrayList keys; /** Storage for the values. */ private ArrayList values; /** * Contains (key, Integer) mappings, where the Integer is the index for * the key in the list. */ private HashMap indexMap; /** * Creates a new collection (initially empty). */ public DefaultKeyedValues() { this.keys = new ArrayList(); this.values = new ArrayList(); this.indexMap = new HashMap(); } /** * Returns the number of items (values) in the collection. * * @return The item count. */ public int getItemCount() { return this.indexMap.size(); } /** * Returns a value. * * @param item the item of interest (zero-based index). * * @return The value (possibly null). * * @throws IndexOutOfBoundsException if item is out of bounds. */ public Number getValue(int item) { return (Number) this.values.get(item); } /** * Returns a key. * * @param index the item index (zero-based). * * @return The row key. * * @throws IndexOutOfBoundsException if item is out of bounds. */ public Comparable getKey(int index) { return (Comparable) this.keys.get(index); } /** * Returns the index for a given key. * * @param key the key (null not permitted). * * @return The index, or -1 if the key is not recognised. * * @throws IllegalArgumentException if key is * null. */ public int getIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } final Integer i = (Integer) this.indexMap.get(key); if (i == null) { return -1; // key not found } return i.intValue(); } /** * Returns the keys for the values in the collection. * * @return The keys (never null). */ public List getKeys() { return (List) this.keys.clone(); } /** * Returns the value for a given key. * * @param key the key (null not permitted). * * @return The value (possibly null). * * @throws UnknownKeyException if the key is not recognised. * * @see #getValue(int) */ public Number getValue(Comparable key) { int index = getIndex(key); if (index < 0) { throw new UnknownKeyException("Key not found: " + key); } return getValue(index); } /** * Updates an existing value, or adds a new value to the collection. * * @param key the key (null not permitted). * @param value the value. * * @see #addValue(Comparable, Number) */ public void addValue(Comparable key, double value) { addValue(key, new Double(value)); } /** * Adds a new value to the collection, or updates an existing value. * This method passes control directly to the * {@link #setValue(Comparable, Number)} method. * * @param key the key (null not permitted). * @param value the value (null permitted). */ public void addValue(Comparable key, Number value) { setValue(key, value); } /** * Updates an existing value, or adds a new value to the collection. * * @param key the key (null not permitted). * @param value the value. */ public void setValue(Comparable key, double value) { setValue(key, new Double(value)); } /** * Updates an existing value, or adds a new value to the collection. * * @param key the key (null not permitted). * @param value the value (null permitted). */ public void setValue(Comparable key, Number value) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } int keyIndex = getIndex(key); if (keyIndex >= 0) { this.keys.set(keyIndex, key); this.values.set(keyIndex, value); } else { this.keys.add(key); this.values.add(value); this.indexMap.put(key, new Integer(this.keys.size() - 1)); } } /** * Inserts a new value at the specified position in the dataset or, if * there is an existing item with the specified key, updates the value * for that item and moves it to the specified position. * * @param position the position (in the range 0 to getItemCount()). * @param key the key (null not permitted). * @param value the value. * * @since 1.0.6 */ public void insertValue(int position, Comparable key, double value) { insertValue(position, key, new Double(value)); } /** * Inserts a new value at the specified position in the dataset or, if * there is an existing item with the specified key, updates the value * for that item and moves it to the specified position. * * @param position the position (in the range 0 to getItemCount()). * @param key the key (null not permitted). * @param value the value (null permitted). * * @since 1.0.6 */ public void insertValue(int position, Comparable key, Number value) { if (position < 0 || position > getItemCount()) { throw new IllegalArgumentException("'position' out of bounds."); } if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } int pos = getIndex(key); if (pos == position) { this.keys.set(pos, key); this.values.set(pos, value); } else { if (pos >= 0) { this.keys.remove(pos); this.values.remove(pos); } this.keys.add(position, key); this.values.add(position, value); rebuildIndex(); } } /** * Rebuilds the key to indexed-position mapping after an positioned insert * or a remove operation. */ private void rebuildIndex () { this.indexMap.clear(); for (int i = 0; i < this.keys.size(); i++) { final Object key = this.keys.get(i); this.indexMap.put(key, new Integer(i)); } } /** * Removes a value from the collection. * * @param index the index of the item to remove (in the range * 0 to getItemCount() - 1). * * @throws IndexOutOfBoundsException if index is not within * the specified range. */ public void removeValue(int index) { this.keys.remove(index); this.values.remove(index); rebuildIndex(); } /** * Removes a value from the collection. * * @param key the item key (null not permitted). * * @throws IllegalArgumentException if key is * null. * @throws UnknownKeyException if key is not recognised. */ public void removeValue(Comparable key) { int index = getIndex(key); if (index < 0) { throw new UnknownKeyException("The key (" + key + ") is not recognised."); } removeValue(index); } /** * Clears all values from the collection. * * @since 1.0.2 */ public void clear() { this.keys.clear(); this.values.clear(); this.indexMap.clear(); } /** * Sorts the items in the list by key. * * @param order the sort order (null not permitted). */ public void sortByKeys(SortOrder order) { final int size = this.keys.size(); final DefaultKeyedValue[] data = new DefaultKeyedValue[size]; for (int i = 0; i < size; i++) { data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i), (Number) this.values.get(i)); } Comparator comparator = new KeyedValueComparator( KeyedValueComparatorType.BY_KEY, order); Arrays.sort(data, comparator); clear(); for (int i = 0; i < data.length; i++) { final DefaultKeyedValue value = data[i]; addValue(value.getKey(), value.getValue()); } } /** * Sorts the items in the list by value. If the list contains * null values, they will sort to the end of the list, * irrespective of the sort order. * * @param order the sort order (null not permitted). */ public void sortByValues(SortOrder order) { final int size = this.keys.size(); final DefaultKeyedValue[] data = new DefaultKeyedValue[size]; for (int i = 0; i < size; i++) { data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i), (Number) this.values.get(i)); } Comparator comparator = new KeyedValueComparator( KeyedValueComparatorType.BY_VALUE, order); Arrays.sort(data, comparator); clear(); for (int i = 0; i < data.length; i++) { final DefaultKeyedValue value = data[i]; addValue(value.getKey(), value.getValue()); } } /** * Tests if this object is equal to another. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof KeyedValues)) { return false; } KeyedValues that = (KeyedValues) obj; int count = getItemCount(); if (count != that.getItemCount()) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return (this.keys != null ? this.keys.hashCode() : 0); } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses might. */ public Object clone() throws CloneNotSupportedException { DefaultKeyedValues clone = (DefaultKeyedValues) super.clone(); clone.keys = (ArrayList) this.keys.clone(); clone.values = (ArrayList) this.values.clone(); clone.indexMap = (HashMap) this.indexMap.clone(); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/DefaultKeyedValues2D.java0000644000175000017500000004424111173030414027025 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * DefaultKeyedValues2D.java * ------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andreas Schroeder; * * Changes * ------- * 28-Oct-2002 : Version 1 (DG); * 21-Jan-2003 : Updated Javadocs (DG); * 13-Mar-2003 : Implemented Serializable (DG); * 18-Aug-2003 : Implemented Cloneable (DG); * 31-Mar-2004 : Made the rows optionally sortable by a flag (AS); * 01-Apr-2004 : Implemented remove method (AS); * 05-Apr-2004 : Added clear() method (DG); * 15-Sep-2004 : Fixed clone() method (DG); * 12-Jan-2005 : Fixed bug in getValue() method (DG); * 23-Mar-2005 : Implemented PublicCloneable (DG); * 09-Jun-2005 : Modified getValue() method to throw exception for unknown * keys (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 18-Jan-2007 : Fixed bug in getValue() method (DG); * 30-Mar-2007 : Fixed bug 1690654, problem with removeValue() (DG); * 21-Nov-2007 : Fixed bug (1835955) in removeColumn(Comparable) method (DG); * 23-Nov-2007 : Added argument checks to removeRow(Comparable) to make it * consistent with the removeRow(Comparable) method (DG); * */ package org.jfree.data; import java.io.Serializable; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A data structure that stores zero, one or many values, where each value * is associated with two keys (a 'row' key and a 'column' key). The keys * should be (a) instances of {@link Comparable} and (b) immutable. */ public class DefaultKeyedValues2D implements KeyedValues2D, PublicCloneable, Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -5514169970951994748L; /** The row keys. */ private List rowKeys; /** The column keys. */ private List columnKeys; /** The row data. */ private List rows; /** If the row keys should be sorted by their comparable order. */ private boolean sortRowKeys; /** * Creates a new instance (initially empty). */ public DefaultKeyedValues2D() { this(false); } /** * Creates a new instance (initially empty). * * @param sortRowKeys if the row keys should be sorted. */ public DefaultKeyedValues2D(boolean sortRowKeys) { this.rowKeys = new java.util.ArrayList(); this.columnKeys = new java.util.ArrayList(); this.rows = new java.util.ArrayList(); this.sortRowKeys = sortRowKeys; } /** * Returns the row count. * * @return The row count. * * @see #getColumnCount() */ public int getRowCount() { return this.rowKeys.size(); } /** * Returns the column count. * * @return The column count. * * @see #getRowCount() */ public int getColumnCount() { return this.columnKeys.size(); } /** * Returns the value for a given row and column. * * @param row the row index. * @param column the column index. * * @return The value. * * @see #getValue(Comparable, Comparable) */ public Number getValue(int row, int column) { Number result = null; DefaultKeyedValues rowData = (DefaultKeyedValues) this.rows.get(row); if (rowData != null) { Comparable columnKey = (Comparable) this.columnKeys.get(column); // the row may not have an entry for this key, in which case the // return value is null int index = rowData.getIndex(columnKey); if (index >= 0) { result = rowData.getValue(index); } } return result; } /** * Returns the key for a given row. * * @param row the row index (in the range 0 to {@link #getRowCount()} - 1). * * @return The row key. * * @see #getRowIndex(Comparable) * @see #getColumnKey(int) */ public Comparable getRowKey(int row) { return (Comparable) this.rowKeys.get(row); } /** * Returns the row index for a given key. * * @param key the key (null not permitted). * * @return The row index. * * @see #getRowKey(int) * @see #getColumnIndex(Comparable) */ public int getRowIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } if (this.sortRowKeys) { return Collections.binarySearch(this.rowKeys, key); } else { return this.rowKeys.indexOf(key); } } /** * Returns the row keys in an unmodifiable list. * * @return The row keys. * * @see #getColumnKeys() */ public List getRowKeys() { return Collections.unmodifiableList(this.rowKeys); } /** * Returns the key for a given column. * * @param column the column (in the range 0 to {@link #getColumnCount()} * - 1). * * @return The key. * * @see #getColumnIndex(Comparable) * @see #getRowKey(int) */ public Comparable getColumnKey(int column) { return (Comparable) this.columnKeys.get(column); } /** * Returns the column index for a given key. * * @param key the key (null not permitted). * * @return The column index. * * @see #getColumnKey(int) * @see #getRowIndex(Comparable) */ public int getColumnIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } return this.columnKeys.indexOf(key); } /** * Returns the column keys in an unmodifiable list. * * @return The column keys. * * @see #getRowKeys() */ public List getColumnKeys() { return Collections.unmodifiableList(this.columnKeys); } /** * Returns the value for the given row and column keys. This method will * throw an {@link UnknownKeyException} if either key is not defined in the * data structure. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The value (possibly null). * * @see #addValue(Number, Comparable, Comparable) * @see #removeValue(Comparable, Comparable) */ public Number getValue(Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } // check that the column key is defined in the 2D structure if (!(this.columnKeys.contains(columnKey))) { throw new UnknownKeyException("Unrecognised columnKey: " + columnKey); } // now fetch the row data - need to bear in mind that the row // structure may not have an entry for the column key, but that we // have already checked that the key is valid for the 2D structure int row = getRowIndex(rowKey); if (row >= 0) { DefaultKeyedValues rowData = (DefaultKeyedValues) this.rows.get(row); int col = rowData.getIndex(columnKey); return (col >= 0 ? rowData.getValue(col) : null); } else { throw new UnknownKeyException("Unrecognised rowKey: " + rowKey); } } /** * Adds a value to the table. Performs the same function as * #setValue(Number, Comparable, Comparable). * * @param value the value (null permitted). * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #setValue(Number, Comparable, Comparable) * @see #removeValue(Comparable, Comparable) */ public void addValue(Number value, Comparable rowKey, Comparable columnKey) { // defer argument checking setValue(value, rowKey, columnKey); } /** * Adds or updates a value. * * @param value the value (null permitted). * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #addValue(Number, Comparable, Comparable) * @see #removeValue(Comparable, Comparable) */ public void setValue(Number value, Comparable rowKey, Comparable columnKey) { DefaultKeyedValues row; int rowIndex = getRowIndex(rowKey); if (rowIndex >= 0) { row = (DefaultKeyedValues) this.rows.get(rowIndex); } else { row = new DefaultKeyedValues(); if (this.sortRowKeys) { rowIndex = -rowIndex - 1; this.rowKeys.add(rowIndex, rowKey); this.rows.add(rowIndex, row); } else { this.rowKeys.add(rowKey); this.rows.add(row); } } row.setValue(columnKey, value); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } } /** * Removes a value from the table by setting it to null. If * all the values in the specified row and/or column are now * null, the row and/or column is removed from the table. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #addValue(Number, Comparable, Comparable) */ public void removeValue(Comparable rowKey, Comparable columnKey) { setValue(null, rowKey, columnKey); // 1. check whether the row is now empty. boolean allNull = true; int rowIndex = getRowIndex(rowKey); DefaultKeyedValues row = (DefaultKeyedValues) this.rows.get(rowIndex); for (int item = 0, itemCount = row.getItemCount(); item < itemCount; item++) { if (row.getValue(item) != null) { allNull = false; break; } } if (allNull) { this.rowKeys.remove(rowIndex); this.rows.remove(rowIndex); } // 2. check whether the column is now empty. allNull = true; //int columnIndex = getColumnIndex(columnKey); for (int item = 0, itemCount = this.rows.size(); item < itemCount; item++) { row = (DefaultKeyedValues) this.rows.get(item); int columnIndex = row.getIndex(columnKey); if (columnIndex >= 0 && row.getValue(columnIndex) != null) { allNull = false; break; } } if (allNull) { for (int item = 0, itemCount = this.rows.size(); item < itemCount; item++) { row = (DefaultKeyedValues) this.rows.get(item); int columnIndex = row.getIndex(columnKey); if (columnIndex >= 0) { row.removeValue(columnIndex); } } this.columnKeys.remove(columnKey); } } /** * Removes a row. * * @param rowIndex the row index. * * @see #removeRow(Comparable) * @see #removeColumn(int) */ public void removeRow(int rowIndex) { this.rowKeys.remove(rowIndex); this.rows.remove(rowIndex); } /** * Removes a row from the table. * * @param rowKey the row key (null not permitted). * * @see #removeRow(int) * @see #removeColumn(Comparable) * * @throws UnknownKeyException if rowKey is not defined in the * table. */ public void removeRow(Comparable rowKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } int index = getRowIndex(rowKey); if (index >= 0) { removeRow(index); } else { throw new UnknownKeyException("Unknown key: " + rowKey); } } /** * Removes a column. * * @param columnIndex the column index. * * @see #removeColumn(Comparable) * @see #removeRow(int) */ public void removeColumn(int columnIndex) { Comparable columnKey = getColumnKey(columnIndex); removeColumn(columnKey); } /** * Removes a column from the table. * * @param columnKey the column key (null not permitted). * * @throws UnknownKeyException if the table does not contain a column with * the specified key. * @throws IllegalArgumentException if columnKey is * null. * * @see #removeColumn(int) * @see #removeRow(Comparable) */ public void removeColumn(Comparable columnKey) { if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } if (!this.columnKeys.contains(columnKey)) { throw new UnknownKeyException("Unknown key: " + columnKey); } Iterator iterator = this.rows.iterator(); while (iterator.hasNext()) { DefaultKeyedValues rowData = (DefaultKeyedValues) iterator.next(); int index = rowData.getIndex(columnKey); if (index >= 0) { rowData.removeValue(columnKey); } } this.columnKeys.remove(columnKey); } /** * Clears all the data and associated keys. */ public void clear() { this.rowKeys.clear(); this.columnKeys.clear(); this.rows.clear(); } /** * Tests if this object is equal to another. * * @param o the other object (null permitted). * * @return A boolean. */ public boolean equals(Object o) { if (o == null) { return false; } if (o == this) { return true; } if (!(o instanceof KeyedValues2D)) { return false; } KeyedValues2D kv2D = (KeyedValues2D) o; if (!getRowKeys().equals(kv2D.getRowKeys())) { return false; } if (!getColumnKeys().equals(kv2D.getColumnKeys())) { return false; } int rowCount = getRowCount(); if (rowCount != kv2D.getRowCount()) { return false; } int colCount = getColumnCount(); if (colCount != kv2D.getColumnCount()) { return false; } for (int r = 0; r < rowCount; r++) { for (int c = 0; c < colCount; c++) { Number v1 = getValue(r, c); Number v2 = kv2D.getValue(r, c); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; result = this.rowKeys.hashCode(); result = 29 * result + this.columnKeys.hashCode(); result = 29 * result + this.rows.hashCode(); return result; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { DefaultKeyedValues2D clone = (DefaultKeyedValues2D) super.clone(); // for the keys, a shallow copy should be fine because keys // should be immutable... clone.columnKeys = new java.util.ArrayList(this.columnKeys); clone.rowKeys = new java.util.ArrayList(this.rowKeys); // but the row data requires a deep copy clone.rows = (List) ObjectUtilities.deepClone(this.rows); return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/DomainInfo.java0000644000175000017500000000637711173030414025144 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * DomainInfo.java * --------------- * (C) Copyright 2000-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 15-Nov-2001 : Moved to package com.jrefinery.data.* (DG); * Updated Javadoc comments (DG); * 22-Apr-2002 : Added getValueRange() method (DG); * 12-Jul-2002 : Renamed getValueRange() --> getDomainRange() (DG); * 06-Oct-2004 : Renamed getDomainRange() --> getDomainBounds() (DG); * 17-Nov-2004 : Added 'includeInterval' argument to all methods (DG); * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * */ package org.jfree.data; /** * An interface (optional) that can be implemented by a dataset to assist in * determining the minimum and maximum values. */ public interface DomainInfo { /** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval); /** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval); /** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range (or null if the dataset contains no * values). */ public Range getDomainBounds(boolean includeInterval); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/DomainOrder.java0000644000175000017500000000762511173030414025321 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * DomainOrder.java * ---------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 29-Jul-2004 : Version 1 (DG); * */ package org.jfree.data; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate sorting order if any (ascending, descending or none). */ public final class DomainOrder implements Serializable { /** For serialization. */ private static final long serialVersionUID = 4902774943512072627L; /** No order. */ public static final DomainOrder NONE = new DomainOrder("DomainOrder.NONE"); /** Ascending order. */ public static final DomainOrder ASCENDING = new DomainOrder("DomainOrder.ASCENDING"); /** Descending order. */ public static final DomainOrder DESCENDING = new DomainOrder("DomainOrder.DESCENDING"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private DomainOrder(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof DomainOrder)) { return false; } DomainOrder that = (DomainOrder) obj; if (!this.name.equals(that.toString())) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(DomainOrder.ASCENDING)) { return DomainOrder.ASCENDING; } else if (this.equals(DomainOrder.DESCENDING)) { return DomainOrder.DESCENDING; } else if (this.equals(DomainOrder.NONE)) { return DomainOrder.NONE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyToGroupMap.java0000644000175000017500000002426111173030414025617 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * KeyToGroupMap.java * ------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2004 : Version 1 (DG); * 07-Jul-2004 : Added a group list to ensure group index is consistent, fixed * cloning problem (DG); * 18-Aug-2005 : Added casts in clone() method to suppress 1.5 compiler * warnings - see patch 1260587 (DG); * */ package org.jfree.data; import java.io.Serializable; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A class that maps keys (instances of Comparable) to groups. */ public class KeyToGroupMap implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2228169345475318082L; /** The default group. */ private Comparable defaultGroup; /** The groups. */ private List groups; /** A mapping between keys and groups. */ private Map keyToGroupMap; /** * Creates a new map with a default group named 'Default Group'. */ public KeyToGroupMap() { this("Default Group"); } /** * Creates a new map with the specified default group. * * @param defaultGroup the default group (null not permitted). */ public KeyToGroupMap(Comparable defaultGroup) { if (defaultGroup == null) { throw new IllegalArgumentException("Null 'defaultGroup' argument."); } this.defaultGroup = defaultGroup; this.groups = new ArrayList(); this.keyToGroupMap = new HashMap(); } /** * Returns the number of groups in the map. * * @return The number of groups in the map. */ public int getGroupCount() { return this.groups.size() + 1; } /** * Returns a list of the groups (always including the default group) in the * map. The returned list is independent of the map, so altering the list * will have no effect. * * @return The groups (never null). */ public List getGroups() { List result = new ArrayList(); result.add(this.defaultGroup); Iterator iterator = this.groups.iterator(); while (iterator.hasNext()) { Comparable group = (Comparable) iterator.next(); if (!result.contains(group)) { result.add(group); } } return result; } /** * Returns the index for the group. * * @param group the group. * * @return The group index (or -1 if the group is not represented within * the map). */ public int getGroupIndex(Comparable group) { int result = this.groups.indexOf(group); if (result < 0) { if (this.defaultGroup.equals(group)) { result = 0; } } else { result = result + 1; } return result; } /** * Returns the group that a key is mapped to. * * @param key the key (null not permitted). * * @return The group (never null, returns the default group if * there is no mapping for the specified key). */ public Comparable getGroup(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable result = this.defaultGroup; Comparable group = (Comparable) this.keyToGroupMap.get(key); if (group != null) { result = group; } return result; } /** * Maps a key to a group. * * @param key the key (null not permitted). * @param group the group (null permitted, clears any * existing mapping). */ public void mapKeyToGroup(Comparable key, Comparable group) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } Comparable currentGroup = getGroup(key); if (!currentGroup.equals(this.defaultGroup)) { if (!currentGroup.equals(group)) { int count = getKeyCount(currentGroup); if (count == 1) { this.groups.remove(currentGroup); } } } if (group == null) { this.keyToGroupMap.remove(key); } else { if (!this.groups.contains(group)) { if (!this.defaultGroup.equals(group)) { this.groups.add(group); } } this.keyToGroupMap.put(key, group); } } /** * Returns the number of keys mapped to the specified group. This method * won't always return an accurate result for the default group, since * explicit mappings are not required for this group. * * @param group the group (null not permitted). * * @return The key count. */ public int getKeyCount(Comparable group) { if (group == null) { throw new IllegalArgumentException("Null 'group' argument."); } int result = 0; Iterator iterator = this.keyToGroupMap.values().iterator(); while (iterator.hasNext()) { Comparable g = (Comparable) iterator.next(); if (group.equals(g)) { result++; } } return result; } /** * Tests the map for equality against an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof KeyToGroupMap)) { return false; } KeyToGroupMap that = (KeyToGroupMap) obj; if (!ObjectUtilities.equal(this.defaultGroup, that.defaultGroup)) { return false; } if (!this.keyToGroupMap.equals(that.keyToGroupMap)) { return false; } return true; } /** * Returns a clone of the map. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning the * map. */ public Object clone() throws CloneNotSupportedException { KeyToGroupMap result = (KeyToGroupMap) super.clone(); result.defaultGroup = (Comparable) KeyToGroupMap.clone(this.defaultGroup); result.groups = (List) KeyToGroupMap.clone(this.groups); result.keyToGroupMap = (Map) KeyToGroupMap.clone(this.keyToGroupMap); return result; } /** * Attempts to clone the specified object using reflection. * * @param object the object (null permitted). * * @return The cloned object, or the original object if cloning failed. */ private static Object clone(Object object) { if (object == null) { return null; } Class c = object.getClass(); Object result = null; try { Method m = c.getMethod("clone", (Class[]) null); if (Modifier.isPublic(m.getModifiers())) { try { result = m.invoke(object, (Object[]) null); } catch (Exception e) { e.printStackTrace(); } } } catch (NoSuchMethodException e) { result = object; } return result; } /** * Returns a clone of the list. * * @param list the list. * * @return A clone of the list. * * @throws CloneNotSupportedException if the list could not be cloned. */ private static Collection clone(Collection list) throws CloneNotSupportedException { Collection result = null; if (list != null) { try { List clone = (List) list.getClass().newInstance(); Iterator iterator = list.iterator(); while (iterator.hasNext()) { clone.add(KeyToGroupMap.clone(iterator.next())); } result = clone; } catch (Exception e) { throw new CloneNotSupportedException("Exception."); } } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedObject.java0000644000175000017500000001022211173030414025271 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * KeyedObject.java * ---------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Feb-2003 : Version 1 (DG); * 27-Jan-2003 : Implemented Cloneable and Serializable, and added an equals() * method (DG); * */ package org.jfree.data; import java.io.Serializable; import org.jfree.util.ObjectUtilities; import org.jfree.util.PublicCloneable; /** * A (key, object) pair. */ public class KeyedObject implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 2677930479256885863L; /** The key. */ private Comparable key; /** The object. */ private Object object; /** * Creates a new (key, object) pair. * * @param key the key. * @param object the object (null permitted). */ public KeyedObject(Comparable key, Object object) { this.key = key; this.object = object; } /** * Returns the key. * * @return The key. */ public Comparable getKey() { return this.key; } /** * Returns the object. * * @return The object (possibly null). */ public Object getObject() { return this.object; } /** * Sets the object. * * @param object the object (null permitted). */ public void setObject(Object object) { this.object = object; } /** * Returns a clone of this object. It is assumed that the key is an * immutable object, so it is not deep-cloned. The object is deep-cloned * if it implements {@link PublicCloneable}, otherwise a shallow clone is * made. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { KeyedObject clone = (KeyedObject) super.clone(); if (this.object instanceof PublicCloneable) { PublicCloneable pc = (PublicCloneable) this.object; clone.object = pc.clone(); } return clone; } /** * Tests if this object is equal to another. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof KeyedObject)) { return false; } KeyedObject that = (KeyedObject) obj; if (!ObjectUtilities.equal(this.key, that.key)) { return false; } if (!ObjectUtilities.equal(this.object, that.object)) { return false; } return true; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedObjects.java0000644000175000017500000002465411173030414025472 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * KeyedObjects.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 31-Oct-2002 : Version 1 (DG); * 11-Jan-2005 : Minor tidy up (DG); * 28-Sep-2007 : Clean up equals() method (DG); * 03-Oct-2007 : Make method behaviour consistent with DefaultKeyedValues (DG); * */ package org.jfree.data; import java.io.Serializable; import java.util.Iterator; import java.util.List; import org.jfree.util.PublicCloneable; /** * A collection of (key, object) pairs. */ public class KeyedObjects implements Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = 1321582394193530984L; /** Storage for the data. */ private List data; /** * Creates a new collection (initially empty). */ public KeyedObjects() { this.data = new java.util.ArrayList(); } /** * Returns the number of items (values) in the collection. * * @return The item count. */ public int getItemCount() { return this.data.size(); } /** * Returns an object from the list. * * @param item the item index (zero-based). * * @return The object (possibly null). * * @throws IndexOutOfBoundsException if item is out of bounds. */ public Object getObject(int item) { Object result = null; KeyedObject kobj = (KeyedObject) this.data.get(item); if (kobj != null) { result = kobj.getObject(); } return result; } /** * Returns the key at the specified position in the list. * * @param index the item index (zero-based). * * @return The row key. * * @throws IndexOutOfBoundsException if item is out of bounds. * * @see #getIndex(Comparable) */ public Comparable getKey(int index) { Comparable result = null; KeyedObject item = (KeyedObject) this.data.get(index); if (item != null) { result = item.getKey(); } return result; } /** * Returns the index for a given key, or -1. * * @param key the key (null not permitted). * * @return The index, or -1 if the key is unrecognised. * * @see #getKey(int) */ public int getIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } int i = 0; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { KeyedObject ko = (KeyedObject) iterator.next(); if (ko.getKey().equals(key)) { return i; } i++; } return -1; } /** * Returns a list containing all the keys in the list. * * @return The keys (never null). */ public List getKeys() { List result = new java.util.ArrayList(); Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { KeyedObject ko = (KeyedObject) iterator.next(); result.add(ko.getKey()); } return result; } /** * Returns the object for a given key. If the key is not recognised, the * method should return null. * * @param key the key. * * @return The object (possibly null). * * @see #addObject(Comparable, Object) */ public Object getObject(Comparable key) { int index = getIndex(key); if (index < 0) { throw new UnknownKeyException("The key (" + key + ") is not recognised."); } return getObject(index); } /** * Adds a new object to the collection, or overwrites an existing object. * This is the same as the {@link #setObject(Comparable, Object)} method. * * @param key the key. * @param object the object. * * @see #getObject(Comparable) */ public void addObject(Comparable key, Object object) { setObject(key, object); } /** * Replaces an existing object, or adds a new object to the collection. * This is the same as the {@link #addObject(Comparable, Object)} * method. * * @param key the key (null not permitted). * @param object the object. * * @see #getObject(Comparable) */ public void setObject(Comparable key, Object object) { int keyIndex = getIndex(key); if (keyIndex >= 0) { KeyedObject ko = (KeyedObject) this.data.get(keyIndex); ko.setObject(object); } else { KeyedObject ko = new KeyedObject(key, object); this.data.add(ko); } } /** * Inserts a new value at the specified position in the dataset or, if * there is an existing item with the specified key, updates the value * for that item and moves it to the specified position. * * @param position the position (in the range 0 to * getItemCount()). * @param key the key (null not permitted). * @param value the value (null permitted). * * @since 1.0.7 */ public void insertValue(int position, Comparable key, Object value) { if (position < 0 || position > this.data.size()) { throw new IllegalArgumentException("'position' out of bounds."); } if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } int pos = getIndex(key); if (pos >= 0) { this.data.remove(pos); } KeyedObject item = new KeyedObject(key, value); if (position <= this.data.size()) { this.data.add(position, item); } else { this.data.add(item); } } /** * Removes a value from the collection. * * @param index the index of the item to remove. * * @see #removeValue(Comparable) */ public void removeValue(int index) { this.data.remove(index); } /** * Removes a value from the collection. * * @param key the key (null not permitted). * * @see #removeValue(int) * * @throws UnknownKeyException if the key is not recognised. */ public void removeValue(Comparable key) { // defer argument checking int index = getIndex(key); if (index < 0) { throw new UnknownKeyException("The key (" + key.toString() + ") is not recognised."); } removeValue(index); } /** * Clears all values from the collection. * * @since 1.0.7 */ public void clear() { this.data.clear(); } /** * Returns a clone of this object. Keys in the list should be immutable * and are not cloned. Objects in the list are cloned only if they * implement {@link PublicCloneable}. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { KeyedObjects clone = (KeyedObjects) super.clone(); clone.data = new java.util.ArrayList(); Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { KeyedObject ko = (KeyedObject) iterator.next(); clone.data.add(ko.clone()); } return clone; } /** * Tests this object for equality with an arbitrary object. * * @param obj the object (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof KeyedObjects)) { return false; } KeyedObjects that = (KeyedObjects) obj; int count = getItemCount(); if (count != that.getItemCount()) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Object o1 = getObject(i); Object o2 = that.getObject(i); if (o1 == null) { if (o2 != null) { return false; } } else { if (!o1.equals(o2)) { return false; } } } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return (this.data != null ? this.data.hashCode() : 0); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedObjects2D.java0000644000175000017500000003772311173030414025661 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * KeyedObject2D.java * ------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Feb-2003 : Version 1 (DG); * 01-Mar-2004 : Added equals() and clone() methods and implemented * Serializable (DG); * 03-Oct-2007 : Updated getObject() to handle modified behaviour in * KeyedObjects class, added clear() method (DG); * */ package org.jfree.data; import java.io.Serializable; import java.util.Collections; import java.util.Iterator; import java.util.List; /** * A data structure that stores zero, one or many objects, where each object is * associated with two keys (a 'row' key and a 'column' key). */ public class KeyedObjects2D implements Cloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -1015873563138522374L; /** The row keys. */ private List rowKeys; /** The column keys. */ private List columnKeys; /** The row data. */ private List rows; /** * Creates a new instance (initially empty). */ public KeyedObjects2D() { this.rowKeys = new java.util.ArrayList(); this.columnKeys = new java.util.ArrayList(); this.rows = new java.util.ArrayList(); } /** * Returns the row count. * * @return The row count. * * @see #getColumnCount() */ public int getRowCount() { return this.rowKeys.size(); } /** * Returns the column count. * * @return The column count. * * @see #getRowCount() */ public int getColumnCount() { return this.columnKeys.size(); } /** * Returns the object for a given row and column. * * @param row the row index (in the range 0 to getRowCount() - 1). * @param column the column index (in the range 0 to getColumnCount() - 1). * * @return The object (possibly null). * * @see #getObject(Comparable, Comparable) */ public Object getObject(int row, int column) { Object result = null; KeyedObjects rowData = (KeyedObjects) this.rows.get(row); if (rowData != null) { Comparable columnKey = (Comparable) this.columnKeys.get(column); if (columnKey != null) { int index = rowData.getIndex(columnKey); if (index >= 0) { result = rowData.getObject(columnKey); } } } return result; } /** * Returns the key for a given row. * * @param row the row index (zero based). * * @return The row index. * * @see #getRowIndex(Comparable) */ public Comparable getRowKey(int row) { return (Comparable) this.rowKeys.get(row); } /** * Returns the row index for a given key, or -1 if the key * is not recognised. * * @param key the key (null not permitted). * * @return The row index. * * @see #getRowKey(int) */ public int getRowIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } return this.rowKeys.indexOf(key); } /** * Returns the row keys. * * @return The row keys (never null). * * @see #getRowKeys() */ public List getRowKeys() { return Collections.unmodifiableList(this.rowKeys); } /** * Returns the key for a given column. * * @param column the column. * * @return The key. * * @see #getColumnIndex(Comparable) */ public Comparable getColumnKey(int column) { return (Comparable) this.columnKeys.get(column); } /** * Returns the column index for a given key, or -1 if the key * is not recognised. * * @param key the key (null not permitted). * * @return The column index. * * @see #getColumnKey(int) */ public int getColumnIndex(Comparable key) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); } return this.columnKeys.indexOf(key); } /** * Returns the column keys. * * @return The column keys (never null). * * @see #getRowKeys() */ public List getColumnKeys() { return Collections.unmodifiableList(this.columnKeys); } /** * Returns the object for the given row and column keys. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The object (possibly null). * * @throws IllegalArgumentException if rowKey or * columnKey is null. * @throws UnknownKeyException if rowKey or * columnKey is not recognised. */ public Object getObject(Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } int row = this.rowKeys.indexOf(rowKey); if (row < 0) { throw new UnknownKeyException("Row key (" + rowKey + ") not recognised."); } int column = this.columnKeys.indexOf(columnKey); if (column < 0) { throw new UnknownKeyException("Column key (" + columnKey + ") not recognised."); } KeyedObjects rowData = (KeyedObjects) this.rows.get(row); int index = rowData.getIndex(columnKey); if (index >= 0) { return rowData.getObject(index); } else { return null; } } /** * Adds an object to the table. Performs the same function as setObject(). * * @param object the object. * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). */ public void addObject(Object object, Comparable rowKey, Comparable columnKey) { setObject(object, rowKey, columnKey); } /** * Adds or updates an object. * * @param object the object. * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). */ public void setObject(Object object, Comparable rowKey, Comparable columnKey) { if (rowKey == null) { throw new IllegalArgumentException("Null 'rowKey' argument."); } if (columnKey == null) { throw new IllegalArgumentException("Null 'columnKey' argument."); } KeyedObjects row; int rowIndex = this.rowKeys.indexOf(rowKey); if (rowIndex >= 0) { row = (KeyedObjects) this.rows.get(rowIndex); } else { this.rowKeys.add(rowKey); row = new KeyedObjects(); this.rows.add(row); } row.setObject(columnKey, object); int columnIndex = this.columnKeys.indexOf(columnKey); if (columnIndex < 0) { this.columnKeys.add(columnKey); } } /** * Removes an object from the table by setting it to null. If * all the objects in the specified row and/or column are now * null, the row and/or column is removed from the table. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @see #addObject(Object, Comparable, Comparable) */ public void removeObject(Comparable rowKey, Comparable columnKey) { int rowIndex = getRowIndex(rowKey); if (rowIndex < 0) { throw new UnknownKeyException("Row key (" + rowKey + ") not recognised."); } int columnIndex = getColumnIndex(columnKey); if (columnIndex < 0) { throw new UnknownKeyException("Column key (" + columnKey + ") not recognised."); } setObject(null, rowKey, columnKey); // 1. check whether the row is now empty. boolean allNull = true; KeyedObjects row = (KeyedObjects) this.rows.get(rowIndex); for (int item = 0, itemCount = row.getItemCount(); item < itemCount; item++) { if (row.getObject(item) != null) { allNull = false; break; } } if (allNull) { this.rowKeys.remove(rowIndex); this.rows.remove(rowIndex); } // 2. check whether the column is now empty. allNull = true; for (int item = 0, itemCount = this.rows.size(); item < itemCount; item++) { row = (KeyedObjects) this.rows.get(item); int colIndex = row.getIndex(columnKey); if (colIndex >= 0 && row.getObject(colIndex) != null) { allNull = false; break; } } if (allNull) { for (int item = 0, itemCount = this.rows.size(); item < itemCount; item++) { row = (KeyedObjects) this.rows.get(item); int colIndex = row.getIndex(columnKey); if (colIndex >= 0) { row.removeValue(colIndex); } } this.columnKeys.remove(columnKey); } } /** * Removes an entire row from the table. * * @param rowIndex the row index. * * @see #removeColumn(int) */ public void removeRow(int rowIndex) { this.rowKeys.remove(rowIndex); this.rows.remove(rowIndex); } /** * Removes an entire row from the table. * * @param rowKey the row key (null not permitted). * * @throws UnknownKeyException if rowKey is not recognised. * * @see #removeColumn(Comparable) */ public void removeRow(Comparable rowKey) { int index = getRowIndex(rowKey); if (index < 0) { throw new UnknownKeyException("Row key (" + rowKey + ") not recognised."); } removeRow(index); } /** * Removes an entire column from the table. * * @param columnIndex the column index. * * @see #removeRow(int) */ public void removeColumn(int columnIndex) { Comparable columnKey = getColumnKey(columnIndex); removeColumn(columnKey); } /** * Removes an entire column from the table. * * @param columnKey the column key (null not permitted). * * @throws UnknownKeyException if rowKey is not recognised. * * @see #removeRow(Comparable) */ public void removeColumn(Comparable columnKey) { int index = getColumnIndex(columnKey); if (index < 0) { throw new UnknownKeyException("Column key (" + columnKey + ") not recognised."); } Iterator iterator = this.rows.iterator(); while (iterator.hasNext()) { KeyedObjects rowData = (KeyedObjects) iterator.next(); int i = rowData.getIndex(columnKey); if (i >= 0) { rowData.removeValue(i); } } this.columnKeys.remove(columnKey); } /** * Clears all the data and associated keys. * * @since 1.0.7 */ public void clear() { this.rowKeys.clear(); this.columnKeys.clear(); this.rows.clear(); } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof KeyedObjects2D)) { return false; } KeyedObjects2D that = (KeyedObjects2D) obj; if (!getRowKeys().equals(that.getRowKeys())) { return false; } if (!getColumnKeys().equals(that.getColumnKeys())) { return false; } int rowCount = getRowCount(); if (rowCount != that.getRowCount()) { return false; } int colCount = getColumnCount(); if (colCount != that.getColumnCount()) { return false; } for (int r = 0; r < rowCount; r++) { for (int c = 0; c < colCount; c++) { Object v1 = getObject(r, c); Object v2 = that.getObject(r, c); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } } return true; } /** * Returns a hashcode for this object. * * @return A hashcode. */ public int hashCode() { int result; result = this.rowKeys.hashCode(); result = 29 * result + this.columnKeys.hashCode(); result = 29 * result + this.rows.hashCode(); return result; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException this class will not throw this * exception, but subclasses (if any) might. */ public Object clone() throws CloneNotSupportedException { KeyedObjects2D clone = (KeyedObjects2D) super.clone(); clone.columnKeys = new java.util.ArrayList(this.columnKeys); clone.rowKeys = new java.util.ArrayList(this.rowKeys); clone.rows = new java.util.ArrayList(this.rows.size()); Iterator iterator = this.rows.iterator(); while (iterator.hasNext()) { KeyedObjects row = (KeyedObjects) iterator.next(); clone.rows.add(row.clone()); } return clone; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedValue.java0000644000175000017500000000364611173030414025153 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * KeyedValue.java * --------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 31-Oct-2002 : Version 1 (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.base (DG); * */ package org.jfree.data; /** * A (key, value) pair. * * @see DefaultKeyedValue */ public interface KeyedValue extends Value { /** * Returns the key associated with the value. The key returned by this * method should be immutable. * * @return The key (never null). */ public Comparable getKey(); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedValueComparator.java0000644000175000017500000001246011173030414027175 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * KeyedValueComparator.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Mar-2003 : Version 1 (DG); * 27-Aug-2003 : Moved SortOrder from org.jfree.data --> org.jfree.util (DG); * 12-Jan-2005 : Added accessor methods (DG); * */ package org.jfree.data; import java.util.Comparator; import org.jfree.util.SortOrder; /** * A utility class that can compare and order two {@link KeyedValue} instances * and sort them into ascending or descending order by key or by value. */ public class KeyedValueComparator implements Comparator { /** The comparator type. */ private KeyedValueComparatorType type; /** The sort order. */ private SortOrder order; /** * Creates a new comparator. * * @param type the type (BY_KEY or BY_VALUE, * null not permitted). * @param order the order (null not permitted). */ public KeyedValueComparator(KeyedValueComparatorType type, SortOrder order) { if (order == null) { throw new IllegalArgumentException("Null 'order' argument."); } this.type = type; this.order = order; } /** * Returns the type. * * @return The type (never null). */ public KeyedValueComparatorType getType() { return this.type; } /** * Returns the sort order. * * @return The sort order (never null). */ public SortOrder getOrder() { return this.order; } /** * Compares two {@link KeyedValue} instances and returns an * int that indicates the relative order of the two objects. * * @param o1 object 1. * @param o2 object 2. * * @return An int indicating the relative order of the objects. */ public int compare(Object o1, Object o2) { if (o2 == null) { return -1; } if (o1 == null) { return 1; } int result; KeyedValue kv1 = (KeyedValue) o1; KeyedValue kv2 = (KeyedValue) o2; if (this.type == KeyedValueComparatorType.BY_KEY) { if (this.order.equals(SortOrder.ASCENDING)) { result = kv1.getKey().compareTo(kv2.getKey()); } else if (this.order.equals(SortOrder.DESCENDING)) { result = kv2.getKey().compareTo(kv1.getKey()); } else { throw new IllegalArgumentException("Unrecognised sort order."); } } else if (this.type == KeyedValueComparatorType.BY_VALUE) { Number n1 = kv1.getValue(); Number n2 = kv2.getValue(); if (n2 == null) { return -1; } if (n1 == null) { return 1; } double d1 = n1.doubleValue(); double d2 = n2.doubleValue(); if (this.order.equals(SortOrder.ASCENDING)) { if (d1 > d2) { result = 1; } else if (d1 < d2) { result = -1; } else { result = 0; } } else if (this.order.equals(SortOrder.DESCENDING)) { if (d1 > d2) { result = -1; } else if (d1 < d2) { result = 1; } else { result = 0; } } else { throw new IllegalArgumentException("Unrecognised sort order."); } } else { throw new IllegalArgumentException("Unrecognised type."); } return result; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedValueComparatorType.java0000644000175000017500000000633211173030414030040 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * KeyedValueComparatorType.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Mar-2003 : Version 1 (DG); * */ package org.jfree.data; /** * Used to indicate the type of a {@link KeyedValueComparator} : 'by key' or * 'by value'. */ public final class KeyedValueComparatorType { /** An object representing 'by key' sorting. */ public static final KeyedValueComparatorType BY_KEY = new KeyedValueComparatorType("KeyedValueComparatorType.BY_KEY"); /** An object representing 'by value' sorting. */ public static final KeyedValueComparatorType BY_VALUE = new KeyedValueComparatorType("KeyedValueComparatorType.BY_VALUE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private KeyedValueComparatorType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param o the other object. * * @return A boolean. */ public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof KeyedValueComparatorType)) { return false; } KeyedValueComparatorType type = (KeyedValueComparatorType) o; if (!this.name.equals(type.name)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { return this.name.hashCode(); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedValues.java0000644000175000017500000000702311173030414025327 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * KeyedValues.java * ---------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 23-Oct-2002 : Version 1 (DG); * 12-Jan-2005 : Updated Javadocs to specify new behaviour when key * is not recognised (DG); * ------------- JFREECHART 1.0.0 --------------------------------------------- * 02-May-2006 : Updated API docs (DG); * */ package org.jfree.data; import java.util.List; /** * An ordered list of (key, value) items where the keys are unique and * non-null. * * @see Values * @see DefaultKeyedValues */ public interface KeyedValues extends Values { /** * Returns the key associated with the item at a given position. Note * that some implementations allow re-ordering of the data items, so the * result may be transient. * * @param index the item index (in the range 0 to * getItemCount() - 1). * * @return The key (never null). * * @throws IndexOutOfBoundsException if index is not in the * specified range. */ public Comparable getKey(int index); /** * Returns the index for a given key. * * @param key the key (null not permitted). * * @return The index, or -1 if the key is unrecognised. * * @throws IllegalArgumentException if key is * null. */ public int getIndex(Comparable key); /** * Returns the keys for the values in the collection. Note that you can * access the values in this collection by key or by index. For this * reason, the key order is important - this method should return the keys * in order. The returned list may be unmodifiable. * * @return The keys (never null). */ public List getKeys(); /** * Returns the value for a given key. * * @param key the key. * * @return The value (possibly null). * * @throws UnknownKeyException if the key is not recognised. */ public Number getValue(Comparable key); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/KeyedValues2D.java0000644000175000017500000000673411173030414025525 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * KeyedValues2D.java * ------------------ * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Oct-2002 : Version 1 (DG); * 12-Jan-2005 : Updated Javadocs (DG); * */ package org.jfree.data; import java.util.List; /** * An extension of the {@link Values2D} interface where a unique key is * associated with the row and column indices. */ public interface KeyedValues2D extends Values2D { /** * Returns the row key for a given index. * * @param row the row index (zero-based). * * @return The row key. * * @throws IndexOutOfBoundsException if row is out of bounds. */ public Comparable getRowKey(int row); /** * Returns the row index for a given key. * * @param key the row key. * * @return The row index, or -1 if the key is unrecognised. */ public int getRowIndex(Comparable key); /** * Returns the row keys. * * @return The keys. */ public List getRowKeys(); /** * Returns the column key for a given index. * * @param column the column index (zero-based). * * @return The column key. * * @throws IndexOutOfBoundsException if row is out of bounds. */ public Comparable getColumnKey(int column); /** * Returns the column index for a given key. * * @param key the column key. * * @return The column index, or -1 if the key is unrecognised. */ public int getColumnIndex(Comparable key); /** * Returns the column keys. * * @return The keys. */ public List getColumnKeys(); /** * Returns the value associated with the specified keys. * * @param rowKey the row key (null not permitted). * @param columnKey the column key (null not permitted). * * @return The value. * * @throws UnknownKeyException if either key is not recognised. */ public Number getValue(Comparable rowKey, Comparable columnKey); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/Range.java0000644000175000017500000003167711173030414024156 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------- * Range.java * ---------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Chuanhao Chiu; * Bill Kelemen; * Nicolas Brodu; * Sergei Ivanov; * * Changes (from 23-Jun-2001) * -------------------------- * 22-Apr-2002 : Version 1, loosely based by code by Bill Kelemen (DG); * 30-Apr-2002 : Added getLength() and getCentralValue() methods. Changed * argument check in constructor (DG); * 13-Jun-2002 : Added contains(double) method (DG); * 22-Aug-2002 : Added fix to combine method where both ranges are null, thanks * to Chuanhao Chiu for reporting and fixing this (DG); * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 14-Aug-2003 : Added equals() method (DG); * 27-Aug-2003 : Added toString() method (BK); * 11-Sep-2003 : Added Clone Support (NB); * 23-Sep-2003 : Fixed Checkstyle issues (DG); * 25-Sep-2003 : Oops, Range immutable, clone not necessary (NB); * 05-May-2004 : Added constrain() and intersects() methods (DG); * 18-May-2004 : Added expand() method (DG); * ------------- JFreeChart 1.0.x --------------------------------------------- * 11-Jan-2006 : Added new method expandToInclude(Range, double) (DG); * 18-Dec-2007 : New methods intersects(Range) and scale(...) thanks to Sergei * Ivanov (DG); * */ package org.jfree.data; import java.io.Serializable; /** * Represents an immutable range of values. */ public strictfp class Range implements Serializable { /** For serialization. */ private static final long serialVersionUID = -906333695431863380L; /** The lower bound of the range. */ private double lower; /** The upper bound of the range. */ private double upper; /** * Creates a new range. * * @param lower the lower bound (must be <= upper bound). * @param upper the upper bound (must be >= lower bound). */ public Range(double lower, double upper) { if (lower > upper) { String msg = "Range(double, double): require lower (" + lower + ") <= upper (" + upper + ")."; throw new IllegalArgumentException(msg); } this.lower = lower; this.upper = upper; } /** * Returns the lower bound for the range. * * @return The lower bound. */ public double getLowerBound() { return this.lower; } /** * Returns the upper bound for the range. * * @return The upper bound. */ public double getUpperBound() { return this.upper; } /** * Returns the length of the range. * * @return The length. */ public double getLength() { return this.upper - this.lower; } /** * Returns the central value for the range. * * @return The central value. */ public double getCentralValue() { return this.lower / 2.0 + this.upper / 2.0; } /** * Returns true if the range contains the specified value and * false otherwise. * * @param value the value to lookup. * * @return true if the range contains the specified value. */ public boolean contains(double value) { return (value >= this.lower && value <= this.upper); } /** * Returns true if the range intersects with the specified * range, and false otherwise. * * @param b0 the lower bound (should be <= b1). * @param b1 the upper bound (should be >= b0). * * @return A boolean. */ public boolean intersects(double b0, double b1) { if (b0 <= this.lower) { return (b1 > this.lower); } else { return (b0 < this.upper && b1 >= b0); } } /** * Returns true if the range intersects with the specified * range, and false otherwise. * * @param range another range (null not permitted). * * @return A boolean. * * @since 1.0.9 */ public boolean intersects(Range range) { return intersects(range.getLowerBound(), range.getUpperBound()); } /** * Returns the value within the range that is closest to the specified * value. * * @param value the value. * * @return The constrained value. */ public double constrain(double value) { double result = value; if (!contains(value)) { if (value > this.upper) { result = this.upper; } else if (value < this.lower) { result = this.lower; } } return result; } /** * Creates a new range by combining two existing ranges. *

      * Note that: *

        *
      • either range can be null, in which case the other * range is returned;
      • *
      • if both ranges are null the return value is * null.
      • *
      * * @param range1 the first range (null permitted). * @param range2 the second range (null permitted). * * @return A new range (possibly null). */ public static Range combine(Range range1, Range range2) { if (range1 == null) { return range2; } else { if (range2 == null) { return range1; } else { double l = Math.min(range1.getLowerBound(), range2.getLowerBound()); double u = Math.max(range1.getUpperBound(), range2.getUpperBound()); return new Range(l, u); } } } /** * Returns a range that includes all the values in the specified * range AND the specified value. * * @param range the range (null permitted). * @param value the value that must be included. * * @return A range. * * @since 1.0.1 */ public static Range expandToInclude(Range range, double value) { if (range == null) { return new Range(value, value); } if (value < range.getLowerBound()) { return new Range(value, range.getUpperBound()); } else if (value > range.getUpperBound()) { return new Range(range.getLowerBound(), value); } else { return range; } } /** * Creates a new range by adding margins to an existing range. * * @param range the range (null not permitted). * @param lowerMargin the lower margin (expressed as a percentage of the * range length). * @param upperMargin the upper margin (expressed as a percentage of the * range length). * * @return The expanded range. */ public static Range expand(Range range, double lowerMargin, double upperMargin) { if (range == null) { throw new IllegalArgumentException("Null 'range' argument."); } double length = range.getLength(); double lower = range.getLowerBound() - length * lowerMargin; double upper = range.getUpperBound() + length * upperMargin; if (lower > upper) { lower = lower / 2.0 + upper / 2.0; upper = lower; } return new Range(lower, upper); } /** * Shifts the range by the specified amount. * * @param base the base range (null not permitted). * @param delta the shift amount. * * @return A new range. */ public static Range shift(Range base, double delta) { return shift(base, delta, false); } /** * Shifts the range by the specified amount. * * @param base the base range (null not permitted). * @param delta the shift amount. * @param allowZeroCrossing a flag that determines whether or not the * bounds of the range are allowed to cross * zero after adjustment. * * @return A new range. */ public static Range shift(Range base, double delta, boolean allowZeroCrossing) { if (base == null) { throw new IllegalArgumentException("Null 'base' argument."); } if (allowZeroCrossing) { return new Range(base.getLowerBound() + delta, base.getUpperBound() + delta); } else { return new Range(shiftWithNoZeroCrossing(base.getLowerBound(), delta), shiftWithNoZeroCrossing(base.getUpperBound(), delta)); } } /** * Returns the given value adjusted by delta but * with a check to prevent the result from crossing 0.0. * * @param value the value. * @param delta the adjustment. * * @return The adjusted value. */ private static double shiftWithNoZeroCrossing(double value, double delta) { if (value > 0.0) { return Math.max(value + delta, 0.0); } else if (value < 0.0) { return Math.min(value + delta, 0.0); } else { return value + delta; } } /** * Scales the range by the specified factor. * * @param base the base range (null not permitted). * @param factor the scaling factor (must be non-negative). * * @return A new range. * * @since 1.0.9 */ public static Range scale(Range base, double factor) { if (base == null) { throw new IllegalArgumentException("Null 'base' argument."); } if (factor < 0) { throw new IllegalArgumentException("Negative 'factor' argument."); } return new Range(base.getLowerBound() * factor, base.getUpperBound() * factor); } /** * Tests this object for equality with an arbitrary object. * * @param obj the object to test against (null permitted). * * @return A boolean. */ public boolean equals(Object obj) { if (!(obj instanceof Range)) { return false; } Range range = (Range) obj; if (!(this.lower == range.lower)) { return false; } if (!(this.upper == range.upper)) { return false; } return true; } /** * Returns a hash code. * * @return A hash code. */ public int hashCode() { int result; long temp; temp = Double.doubleToLongBits(this.lower); result = (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(this.upper); result = 29 * result + (int) (temp ^ (temp >>> 32)); return result; } /** * Returns a string representation of this Range. * * @return A String "Range[lower,upper]" where lower=lower range and * upper=upper range. */ public String toString() { return ("Range[" + this.lower + "," + this.upper + "]"); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/RangeInfo.java0000644000175000017500000000641011173030414024755 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * RangeInfo.java * -------------- * (C) Copyright 2000-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes (from 18-Sep-2001) * -------------------------- * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); * 15-Nov-2001 : Moved to package com.jrefinery.data.* (DG); * Updated Javadoc comments (DG); * 22-Apr-2002 : Added getValueRange() method (DG); * 17-Nov-2004 : Replaced getMinimumRangeValue() --> getRangeLowerBound(), * getMaximumRangeValue() --> getRangeUpperBound(), * getValueRange() --> getRangeBounds(). * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 * release (DG); * */ package org.jfree.data; /** * An interface (optional) that can be implemented by a dataset to assist in * determining the minimum and maximum values. See also {@link DomainInfo}. */ public interface RangeInfo { /** * Returns the minimum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The minimum value. */ public double getRangeLowerBound(boolean includeInterval); /** * Returns the maximum y-value in the dataset. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The maximum value. */ public double getRangeUpperBound(boolean includeInterval); /** * Returns the range of the values in this dataset's range. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range (or null if the dataset contains no * values). */ public Range getRangeBounds(boolean includeInterval); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/RangeType.java0000644000175000017500000000760711173030414025014 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * RangeType.java * -------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 24-Feb-2005 : Version 1 (DG); * */ package org.jfree.data; import java.io.ObjectStreamException; import java.io.Serializable; /** * Used to indicate the type of range to display on an axis (full, positive or * negative). */ public final class RangeType implements Serializable { /** For serialization. */ private static final long serialVersionUID = -9073319010650549239L; /** Full range (positive and negative). */ public static final RangeType FULL = new RangeType("RangeType.FULL"); /** Positive range. */ public static final RangeType POSITIVE = new RangeType("RangeType.POSITIVE"); /** Negative range. */ public static final RangeType NEGATIVE = new RangeType("RangeType.NEGATIVE"); /** The name. */ private String name; /** * Private constructor. * * @param name the name. */ private RangeType(String name) { this.name = name; } /** * Returns a string representing the object. * * @return The string. */ public String toString() { return this.name; } /** * Returns true if this object is equal to the specified * object, and false otherwise. * * @param obj the other object. * * @return A boolean. */ public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof RangeType)) { return false; } RangeType that = (RangeType) obj; if (!this.name.equals(that.toString())) { return false; } return true; } /** * Returns a hash code value for the object. * * @return The hashcode */ public int hashCode() { return this.name.hashCode(); } /** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { if (this.equals(RangeType.FULL)) { return RangeType.FULL; } else if (this.equals(RangeType.POSITIVE)) { return RangeType.POSITIVE; } else if (this.equals(RangeType.NEGATIVE)) { return RangeType.NEGATIVE; } return null; } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/UnknownKeyException.java0000644000175000017500000000356511173030414027104 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * UnknownKeyException.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-Jan-2005 : Version 1 (DG); * */ package org.jfree.data; /** * An exception that indicates an unknown key value. */ public class UnknownKeyException extends IllegalArgumentException { /** * Creates a new exception. * * @param message a message describing the exception. */ public UnknownKeyException(String message) { super(message); } } libjfreechart-java-1.0.13.orig/source/org/jfree/data/Value.java0000644000175000017500000000346011173030414024163 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------- * Value.java * ---------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Oct-2002 : Version 1 (DG); * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.base (DG); * */ package org.jfree.data; /** * A general purpose interface for accessing a value. */ public interface Value { /** * Returns the value. * * @return The value (possibly null). */ public Number getValue(); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/Values.java0000644000175000017500000000457011173030414024351 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------- * Values.java * ----------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 08-Nov-2001 : Version 1 (DG); * 23-Oct-2002 : Renamed getValueCount --> getItemCount (DG);# * ------------- JFREECHART 1.0.x --------------------------------------------- * 02-May-2006 : Updated API docs (DG); * */ package org.jfree.data; /** * An interface through which (single-dimension) data values can be accessed. */ public interface Values { /** * Returns the number of items (values) in the collection. * * @return The item count (possibly zero). */ public int getItemCount(); /** * Returns the value with the specified index. * * @param index the item index (in the range 0 to * getItemCount() - 1). * * @return The value (possibly null). * * @throws IndexOutOfBoundsException if index is not in the * specified range. */ public Number getValue(int index); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/Values2D.java0000644000175000017500000000447111173030414024537 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * Values2D.java * ------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Oct-2002 : Version 1 (DG); * */ package org.jfree.data; /** * A general purpose interface that can be used to access a table of values. */ public interface Values2D { /** * Returns the number of rows in the table. * * @return The row count. */ public int getRowCount(); /** * Returns the number of columns in the table. * * @return The column count. */ public int getColumnCount(); /** * Returns a value from the table. * * @param row the row index (zero-based). * @param column the column index (zero-based). * * @return The value (possibly null). * * @throws IndexOutOfBoundsException if the row * or column is out of bounds. */ public Number getValue(int row, int column); } libjfreechart-java-1.0.13.orig/source/org/jfree/data/package.html0000644000175000017500000000025711173030414024526 0ustar vincentvincent The base package for classes that represent various types of data. libjfreechart-java-1.0.13.orig/source/overview.html0000644000175000017500000000066511173030414022211 0ustar vincentvincent JFreeChart is a free chart library for Java that can generate a wide variety of charts for use in applications, applets and servlets.

      Please visit http://www.jfree.org/jfreechart/index.html for the latest information about JFreeChart. libjfreechart-java-1.0.13.orig/swt/0000755000175000017500000000000011216245562016775 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/0000755000175000017500000000000011173030414017552 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/0000755000175000017500000000000011173030414020645 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/0000755000175000017500000000000011173030414023342 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/0000755000175000017500000000000011173030414024443 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/0000755000175000017500000000000011216245562025272 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/demo/0000755000175000017500000000000011216245562026216 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java0000644000175000017500000001416211173030414032025 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * SWTBarChartDemo1.java * --------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Henry Proudhon (henry.proudhon AT ensmp.fr). * * Changes * ------- * 23-Aug-2006 : New class (DG); * */ package org.jfree.experimental.chart.swt.demo; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.experimental.chart.swt.ChartComposite; /** * An SWT demo. */ public class SWTBarChartDemo1 { /** * Returns a sample dataset. * * @return The dataset. */ private static CategoryDataset createDataset() { // row keys... String series1 = "First"; String series2 = "Second"; String series3 = "Third"; // column keys... String category1 = "Category 1"; String category2 = "Category 2"; String category3 = "Category 3"; String category4 = "Category 4"; String category5 = "Category 5"; // create the dataset... DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, category1); dataset.addValue(4.0, series1, category2); dataset.addValue(3.0, series1, category3); dataset.addValue(5.0, series1, category4); dataset.addValue(5.0, series1, category5); dataset.addValue(5.0, series2, category1); dataset.addValue(7.0, series2, category2); dataset.addValue(6.0, series2, category3); dataset.addValue(8.0, series2, category4); dataset.addValue(4.0, series2, category5); dataset.addValue(4.0, series3, category1); dataset.addValue(3.0, series3, category2); dataset.addValue(2.0, series3, category3); dataset.addValue(3.0, series3, category4); dataset.addValue(6.0, series3, category5); return dataset; } /** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart( "SWTBarChartDemo1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // the SWTGraphics2D class doesn't handle GradientPaint well, so // replace the gradient painter from the default theme with a // standard painter... renderer.setBarPainter(new StandardBarPainter()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { JFreeChart chart = createChart(createDataset()); Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 300); shell.setLayout(new FillLayout()); shell.setText("Test for jfreechart running with SWT"); ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); frame.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/demo/SWTMultipleAxisDemo1.java0000644000175000017500000001675011173030414032764 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * SWTMultipleAxisDemo1.java * ------------------------- * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Henry Proudhon; * * Changes * ------- * 23-Aug-2006 : New class (HP); * */ package org.jfree.experimental.chart.swt.demo; import java.awt.Color; import javax.swing.JPanel; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.title.TextTitle; import org.jfree.data.time.Minute; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.XYDataset; import org.jfree.experimental.chart.swt.ChartComposite; import org.jfree.ui.RectangleInsets; /** * This demo shows a time series chart that has multiple range axes. */ public class SWTMultipleAxisDemo1 { /** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setFixedDimension(10.0); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; } /** * Creates a sample dataset. * * @param name the dataset name. * @param base the starting value. * @param start the starting period. * @param count the number of values to generate. * * @return The dataset. */ private static XYDataset createDataset(String name, double base, RegularTimePeriod start, int count) { TimeSeries series = new TimeSeries(name); RegularTimePeriod period = start; double value = base; for (int i = 0; i < count; i++) { series.add(period, value); period = period.next(); value = value * (1 + (Math.random() - 0.495) / 10.0); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); return dataset; } /** * Creates a panel for the demo (used by SuperDemo.java). * * @return A panel. */ public static JPanel createDemoPanel() { JFreeChart chart = createChart(); return new ChartPanel(chart); } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { final JFreeChart chart = createChart(); final Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 300); shell.setLayout(new FillLayout()); shell.setText("Test for jfreechart running with SWT"); ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); frame.setDisplayToolTips(false); frame.setHorizontalAxisTrace(true); frame.setVerticalAxisTrace(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java0000644000175000017500000001007111173030414032031 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * SWTPieChartDemo1.java * --------------------- * (C) Copyright 2006, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): * * Changes * ------- * 23-Aug-2006 : New class (DG); * */ package org.jfree.experimental.chart.swt.demo; import java.awt.Font; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.experimental.chart.swt.ChartComposite; /** * This demo shows a time series chart that has multiple range axes. */ public class SWTPieChartDemo1 { /** * Creates a sample dataset. * * @return A sample dataset. */ private static PieDataset createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); return dataset; } /** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false ); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { JFreeChart chart = createChart(createDataset()); Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 400); shell.setLayout(new FillLayout()); shell.setText("Test for jfreechart running with SWT"); final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); //frame.setDisplayToolTips(false); frame.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/demo/SWTTimeSeriesDemo.java0000644000175000017500000001541111173030414032325 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * SWTTimeSeriesDemo.java * --------------------- * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Henry Proudhon (henry.proudhon AT ensmp.fr); * * Changes * ------- * 30-Jan-2007 : New class derived from TimeSeriesDemo.java (HP); * */ package org.jfree.experimental.chart.swt.demo; import java.awt.Color; import java.text.SimpleDateFormat; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.time.Month; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.XYDataset; import org.jfree.experimental.chart.swt.ChartComposite; import org.jfree.ui.RectangleInsets; /** * An example of a time series chart. For the most part, default settings are * used, except that the renderer is modified to show filled shapes (as well as * lines) at each data point. */ public class SWTTimeSeriesDemo { /** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; } /** * Creates a dataset, consisting of two series of monthly data. * * @return The dataset. */ private static XYDataset createDataset() { TimeSeries s1 = new TimeSeries("L&G European Index Trust"); s1.add(new Month(2, 2001), 181.8); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; } /** * Starting point for the demonstration application. * * @param args ignored. */ public static void main(String[] args) { final JFreeChart chart = createChart(createDataset()); final Display display = new Display(); Shell shell = new Shell(display); shell.setSize(600, 300); shell.setLayout(new FillLayout()); shell.setText("Time series demo for jfreechart running with SWT"); ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); frame.setDisplayToolTips(true); frame.setHorizontalAxisTrace(false); frame.setVerticalAxisTrace(false); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/0000755000175000017500000000000011216245562026560 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java0000644000175000017500000003653111173030414032072 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * SWTAxisEditor.java * ------------------ * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 07-Feb-2007 : Fixed bug 1647749, handle null axis labels (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt.editor; import java.awt.Paint; import java.util.ResourceBundle; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FontDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.experimental.swt.SWTPaintCanvas; import org.jfree.experimental.swt.SWTUtils; /** * An editor for axis properties. */ class SWTAxisEditor extends Composite { /** The axis label. */ private Text label; /** The font used to draw the axis labels. */ private FontData labelFont; /** The paint (color) used to draw the axis labels. */ private Color labelPaintColor; /** The font used to draw the axis tick labels. */ private FontData tickLabelFont; /** The paint (color) used to draw the axis tick labels. */ private Color tickLabelPaintColor; /** A field showing a description of the label font. */ private Text labelFontField; /** * A field containing a description of the font * for displaying tick labels on the axis. */ private Text tickLabelFontField; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** Font object used to handle a change of font. */ private Font font; /** A flag that indicates whether or not the tick labels are visible. */ private Button showTickLabelsCheckBox; /** A flag that indicates whether or not the tick marks are visible. */ private Button showTickMarksCheckBox; /** A tabbed pane for... */ private TabFolder otherTabs; /** * Standard constructor: builds a composite for displaying/editing * the properties of the specified axis. * * @param parent The parent composite. * @param style The SWT style of the SwtAxisEditor. * @param axis the axis whose properties are to be displayed/edited * in the composite. */ public SWTAxisEditor(Composite parent, int style, Axis axis) { super(parent, style); this.labelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getLabelFont(), true); this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getLabelPaint()); this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), axis.getTickLabelFont(), true); this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), axis.getTickLabelPaint()); FillLayout layout = new FillLayout(SWT.VERTICAL); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1 new Label(general, SWT.NONE).setText(localizationResources.getString( "Label")); this.label = new Text(general, SWT.BORDER); if (axis.getLabel() != null) { this.label.setText(axis.getLabel()); } this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); new Label(general, SWT.NONE).setText(""); //empty cell // row 2 new Label(general, SWT.NONE).setText(localizationResources.getString( "Font")); this.labelFontField = new Text(general, SWT.BORDER); this.labelFontField.setText(this.labelFont.toString()); this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button selectFontButton = new Button(general, SWT.PUSH); selectFontButton.setText(localizationResources.getString("Select...")); selectFontButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the color-change dialog FontDialog dlg = new FontDialog(getShell()); dlg.setText(localizationResources.getString( "Font_Selection")); dlg.setFontList(new FontData[] { SWTAxisEditor.this.labelFont }); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTAxisEditor.this.font != null) { SWTAxisEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTAxisEditor.this.font = new Font( getShell().getDisplay(), dlg.getFontList()); //label.setFont(font); SWTAxisEditor.this.labelFontField.setText( SWTAxisEditor.this.font.getFontData()[0] .toString()); SWTAxisEditor.this.labelFont = SWTAxisEditor.this.font.getFontData()[0]; } } } ); // row 3 new Label(general, SWT.NONE).setText(localizationResources.getString( "Paint")); // Use a colored text field to show the color final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.labelPaintColor); GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); canvasGridData.heightHint = 20; colorCanvas.setLayoutData(canvasGridData); Button selectColorButton = new Button(general, SWT.PUSH); selectColorButton.setText(localizationResources.getString("Select...")); selectColorButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the color-change dialog ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Title_Color")); dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB()); RGB rgb = dlg.open(); if (rgb != null) { // create the new color and set it to the // SwtPaintCanvas SWTAxisEditor.this.labelPaintColor = new Color( getDisplay(), rgb); colorCanvas.setColor( SWTAxisEditor.this.labelPaintColor); } } } ); Group other = new Group(this, SWT.NONE); FillLayout tabLayout = new FillLayout(); tabLayout.marginHeight = tabLayout.marginWidth = 4; other.setLayout(tabLayout); other.setText(localizationResources.getString("Other")); this.otherTabs = new TabFolder(other, SWT.NONE); TabItem item1 = new TabItem(this.otherTabs, SWT.NONE); item1.setText(" " + localizationResources.getString("Ticks") + " "); Composite ticks = new Composite(this.otherTabs, SWT.NONE); ticks.setLayout(new GridLayout(3, false)); this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK); this.showTickLabelsCheckBox.setText(localizationResources.getString( "Show_tick_labels")); this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible()); this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); new Label(ticks, SWT.NONE).setText(localizationResources.getString( "Tick_label_font")); this.tickLabelFontField = new Text(ticks, SWT.BORDER); this.tickLabelFontField.setText(this.tickLabelFont.toString()); //tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(), // axis.getTickLabelFont())); this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH); selectTickLabelFontButton.setText(localizationResources.getString( "Select...")); selectTickLabelFontButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the font-change dialog FontDialog dlg = new FontDialog(getShell()); dlg.setText(localizationResources.getString( "Font_Selection")); dlg.setFontList(new FontData[] { SWTAxisEditor.this.tickLabelFont}); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTAxisEditor.this.font != null) { SWTAxisEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTAxisEditor.this.font = new Font( getShell().getDisplay(), dlg.getFontList()); //tickLabelFontField.setFont(font); SWTAxisEditor.this.tickLabelFontField.setText( SWTAxisEditor.this.font.getFontData()[0] .toString()); SWTAxisEditor.this.tickLabelFont = SWTAxisEditor.this.font.getFontData()[0]; } } } ); this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK); this.showTickMarksCheckBox.setText(localizationResources.getString( "Show_tick_marks")); this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible()); this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); item1.setControl(ticks); } /** * A static method that returns a panel that is appropriate * for the axis type. * * @param parent the parent. * @param style the style. * @param axis the axis whose properties are to be displayed/edited * in the composite. * @return A composite or nullnull. */ public static SWTAxisEditor getInstance(Composite parent, int style, Axis axis) { if (axis != null) { // return the appropriate axis editor if (axis instanceof NumberAxis) return new SWTNumberAxisEditor(parent, style, (NumberAxis) axis); else return new SWTAxisEditor(parent, style, axis); } else return null; } /** * Returns a reference to the tabbed composite. * * @return A reference to the tabbed composite. */ public TabFolder getOtherTabs() { return this.otherTabs; } /** * Returns the current axis label. * * @return The current axis label. */ public String getLabel() { return this.label.getText(); } /** * Returns the current label font. * * @return The current label font. */ public java.awt.Font getLabelFont() { return SWTUtils.toAwtFont(getDisplay(), this.labelFont, true); } /** * Returns the current label paint. * * @return The current label paint. */ public Paint getTickLabelPaint() { return SWTUtils.toAwtColor(this.tickLabelPaintColor); } /** * Returns the current label font. * * @return The current label font. */ public java.awt.Font getTickLabelFont() { return SWTUtils.toAwtFont(getDisplay(), this.tickLabelFont, true); } /** * Returns the current label paint. * * @return The current label paint. */ public Paint getLabelPaint() { return SWTUtils.toAwtColor(this.labelPaintColor); } /** * Sets the properties of the specified axis to match * the properties defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { axis.setLabel(getLabel()); axis.setLabelFont(getLabelFont()); axis.setLabelPaint(getLabelPaint()); axis.setTickMarksVisible(this.showTickMarksCheckBox.getSelection()); axis.setTickLabelsVisible(this.showTickLabelsCheckBox.getSelection()); axis.setTickLabelFont(getTickLabelFont()); axis.setTickLabelPaint(getTickLabelPaint()); } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java0000644000175000017500000001443311173030414032224 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * SWTChartEditor.java * ------------------- * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt.editor; import java.util.ResourceBundle; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.jfree.chart.JFreeChart; import org.jfree.chart.editor.ChartEditor; import org.jfree.chart.util.ResourceBundleWrapper; /** * An editor for chart properties. */ public class SWTChartEditor implements ChartEditor { /** The shell */ private Shell shell; /** The chart which the properties have to be edited */ private JFreeChart chart; /** A composite for displaying/editing the properties of the title. */ private SWTTitleEditor titleEditor; /** A composite for displaying/editing the properties of the plot. */ private SWTPlotEditor plotEditor; /** A composite for displaying/editing the other properties of the chart. */ private SWTOtherEditor otherEditor; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Creates a new editor. * * @param display the display. * @param chart2edit the chart to edit. */ public SWTChartEditor(Display display, JFreeChart chart2edit) { this.shell = new Shell(display, SWT.DIALOG_TRIM); this.shell.setSize(400, 500); this.chart = chart2edit; this.shell.setText(ResourceBundleWrapper.getBundle( "org.jfree.chart.LocalizationBundle").getString( "Chart_Properties")); GridLayout layout = new GridLayout(2, true); layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5; this.shell.setLayout(layout); Composite main = new Composite(this.shell, SWT.NONE); main.setLayout(new FillLayout()); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); TabFolder tab = new TabFolder(main, SWT.BORDER); // build first tab TabItem item1 = new TabItem(tab, SWT.NONE); item1.setText(" " + localizationResources.getString("Title") + " "); this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle()); item1.setControl(this.titleEditor); // build second tab TabItem item2 = new TabItem(tab, SWT.NONE); item2.setText(" " + localizationResources.getString("Plot") + " "); this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot()); item2.setControl(this.plotEditor); // build the third tab TabItem item3 = new TabItem(tab, SWT.NONE); item3.setText(" " + localizationResources.getString("Other") + " "); this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart); item3.setControl(this.otherEditor); // ok and cancel buttons Button ok = new Button(this.shell, SWT.PUSH | SWT.OK); ok.setText(" Ok "); ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); ok.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateChart(SWTChartEditor.this.chart); SWTChartEditor.this.shell.dispose(); } }); Button cancel = new Button(this.shell, SWT.PUSH); cancel.setText(" Cancel "); cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); cancel.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { SWTChartEditor.this.shell.dispose(); } }); } /** * Opens the editor. */ public void open() { this.shell.open(); this.shell.layout(); while (!this.shell.isDisposed()) { if (!this.shell.getDisplay().readAndDispatch()) { this.shell.getDisplay().sleep(); } } } /** * Updates the chart properties. * * @param chart the chart. */ public void updateChart(JFreeChart chart) { this.titleEditor.setTitleProperties(chart); this.plotEditor.updatePlotProperties(chart.getPlot()); this.otherEditor.updateChartProperties(chart); } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java0000644000175000017500000002112411173030414033233 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * SWTNumberAxisEditor.java * ------------------------ * (C) Copyright 2006, 2007, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * */ package org.jfree.experimental.chart.swt.editor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.NumberAxis; /** * An editor for {@link NumberAxis} properties. */ class SWTNumberAxisEditor extends SWTAxisEditor implements FocusListener { /** A flag that indicates whether or not the axis range is determined * automatically. */ private boolean autoRange; /** The lowest value in the axis range. */ private double minimumValue; /** The highest value in the axis range. */ private double maximumValue; /** A checkbox that indicates whether or not the axis range is determined * automatically. */ private Button autoRangeCheckBox; /** A text field for entering the minimum value in the axis range. */ private Text minimumRangeValue; /** A text field for entering the maximum value in the axis range. */ private Text maximumRangeValue; /** * Creates a new editor. * * @param parent the parent. * @param style the style. * @param axis the axis. */ public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) { super(parent, style, axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE); item2.setText(" " + localizationResources.getString("Range") + " "); Composite range = new Composite(getOtherTabs(), SWT.NONE); range.setLayout(new GridLayout(2, true)); item2.setControl(range); this.autoRangeCheckBox = new Button(range, SWT.CHECK); this.autoRangeCheckBox.setText(localizationResources.getString( "Auto-adjust_range")); this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); this.autoRangeCheckBox.setSelection(this.autoRange); this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toggleAutoRange(); } }); new Label(range, SWT.NONE).setText(localizationResources.getString( "Minimum_range_value")); this.minimumRangeValue = new Text(range, SWT.BORDER); this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.minimumRangeValue.setEnabled(!this.autoRange); //this.minimumRangeValue.addModifyListener(this); //this.minimumRangeValue.addVerifyListener(this); this.minimumRangeValue.addFocusListener(this); new Label(range, SWT.NONE).setText(localizationResources.getString( "Maximum_range_value")); this.maximumRangeValue = new Text(range, SWT.BORDER); this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.maximumRangeValue.setEnabled(!this.autoRange); //this.maximumRangeValue.addModifyListener(this); //this.maximumRangeValue.addVerifyListener(this); this.maximumRangeValue.addFocusListener(this); } /** * Toggle the auto range setting. */ public void toggleAutoRange() { this.autoRange = this.autoRangeCheckBox.getSelection(); if (this.autoRange) { this.minimumRangeValue.setText(Double.toString(this.minimumValue)); this.minimumRangeValue.setEnabled(false); this.maximumRangeValue.setText(Double.toString(this.maximumValue)); this.maximumRangeValue.setEnabled(false); } else { this.minimumRangeValue.setEnabled(true); this.maximumRangeValue.setEnabled(true); } } /** * Revalidate the range minimum: * it should be less than the current maximum. * * @param candidate the minimum value * * @return A boolean. */ public boolean validateMinimum(String candidate) { boolean valid = true; try { if (Double.parseDouble(candidate) >= this.maximumValue) { valid = false; } } catch (NumberFormatException e) { valid = false; } return valid; } /** * Revalidate the range maximum: * it should be greater than the current minimum * * @param candidate the maximum value * * @return A boolean. */ public boolean validateMaximum(String candidate) { boolean valid = true; try { if (Double.parseDouble(candidate) <= this.minimumValue) { valid = false; } } catch (NumberFormatException e) { valid = false; } return valid; } /* (non-Javadoc) * @see org.eclipse.swt.events.FocusListener#focusGained( * org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) { // don't need to do anything } /* (non-Javadoc) * @see org.eclipse.swt.events.FocusListener#focusLost( * org.eclipse.swt.events.FocusEvent) */ public void focusLost(FocusEvent e) { if (e.getSource() == this.minimumRangeValue) { // verify min value if (!validateMinimum(this.minimumRangeValue.getText())) this.minimumRangeValue.setText(String.valueOf( this.minimumValue)); else this.minimumValue = Double.parseDouble( this.minimumRangeValue.getText()); } else if (e.getSource() == this.maximumRangeValue) { // verify max value if (!validateMaximum(this.maximumRangeValue.getText())) this.maximumRangeValue.setText(String.valueOf( this.maximumValue)); else this.maximumValue = Double.parseDouble( this.maximumRangeValue.getText()); } } /** * Sets the properties of the specified axis to match * the properties defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); NumberAxis numberAxis = (NumberAxis) axis; numberAxis.setAutoRange(this.autoRange); if (!this.autoRange) { numberAxis.setRange(this.minimumValue, this.maximumValue); } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java0000644000175000017500000001316011173030414032240 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * SWTOtherEditor.java * ------------------- * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt.editor; import java.util.ResourceBundle; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.jfree.chart.JFreeChart; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.experimental.swt.SWTPaintCanvas; import org.jfree.experimental.swt.SWTUtils; /** * An editor for miscellaneous chart properties. */ class SWTOtherEditor extends Composite { /** A checkbox indicating whether or not * the chart is drawn with anti-aliasing. */ private Button antialias; /** The chart background color. */ private SWTPaintCanvas backgroundPaintCanvas; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); } /** * Updates the chart. * * @param chart the chart. */ public void updateChartProperties(JFreeChart chart) { chart.setAntiAlias(this.antialias.getSelection()); chart.setBackgroundPaint(SWTUtils.toAwtColor( this.backgroundPaintCanvas.getColor())); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.javalibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.j0000644000175000017500000002640311173030414033371 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * SWTPlotAppearanceEditor.java * ---------------------------- * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt.editor; import java.awt.BasicStroke; import java.awt.Stroke; import java.util.ResourceBundle; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Spinner; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.experimental.swt.SWTPaintCanvas; import org.jfree.experimental.swt.SWTUtils; /** * An editor for plot properties. */ class SWTPlotAppearanceEditor extends Composite { private Spinner selectStroke; /** The stroke (pen) used to draw the outline of the plot. */ private SWTStrokeCanvas strokeCanvas; /** The paint (color) used to fill the background of the plot. */ private SWTPaintCanvas backgroundPaintCanvas; /** The paint (color) used to draw the outline of the plot. */ private SWTPaintCanvas outlinePaintCanvas; /** The orientation for the plot. */ private PlotOrientation plotOrientation; private Combo orientation; /** Orientation constants. */ private final static String[] orientationNames = {"Vertical", "Horizontal"}; private final static int ORIENTATION_VERTICAL = 0; private final static int ORIENTATION_HORIZONTAL = 1; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); GridLayout groupLayout = new GridLayout(3, false); groupLayout.marginHeight = groupLayout.marginWidth = 4; general.setLayout(groupLayout); general.setText(localizationResources.getString("General")); // row 1: stroke new Label(general, SWT.NONE).setText(localizationResources.getString( "Outline_stroke")); this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE); this.strokeCanvas.setStroke(plot.getOutlineStroke()); GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); strokeGridData.heightHint = 20; this.strokeCanvas.setLayoutData(strokeGridData); this.selectStroke = new Spinner(general, SWT.BORDER); this.selectStroke.setMinimum(1); this.selectStroke.setMaximum(3); this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); this.selectStroke.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { int w = SWTPlotAppearanceEditor.this.selectStroke .getSelection(); if (w > 0) { SWTPlotAppearanceEditor.this.strokeCanvas.setStroke( new BasicStroke(w)); SWTPlotAppearanceEditor.this.strokeCanvas.redraw(); } } } ); // row 2: outline color new Label(general, SWT.NONE).setText(localizationResources.getString( "Outline_Paint")); this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint())); GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); outlineGridData.heightHint = 20; this.outlinePaintCanvas.setLayoutData(outlineGridData); Button selectOutlineColor = new Button(general, SWT.PUSH); selectOutlineColor.setText(localizationResources.getString( "Select...")); selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectOutlineColor.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Outline_Paint")); dlg.setRGB(SWTPlotAppearanceEditor.this .outlinePaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.outlinePaintCanvas .setColor(new Color(getDisplay(), rgb)); } } } ); // row 3: background paint new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTPlotAppearanceEditor.this .backgroundPaintCanvas.getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTPlotAppearanceEditor.this.backgroundPaintCanvas .setColor(new Color(getDisplay(), rgb)); } } } ); // row 4: orientation if (plot instanceof CategoryPlot) { this.plotOrientation = ((CategoryPlot) plot).getOrientation(); } else if (plot instanceof XYPlot) { this.plotOrientation = ((XYPlot) plot).getOrientation(); } if (this.plotOrientation != null) { boolean isVertical = this.plotOrientation.equals(PlotOrientation.VERTICAL); int index = isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL; new Label(general, SWT.NONE).setText( localizationResources.getString("Orientation")); this.orientation = new Combo(general, SWT.DROP_DOWN); this.orientation.setItems(orientationNames); this.orientation.select(index); this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 2, 1)); this.orientation.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { switch (SWTPlotAppearanceEditor.this.orientation .getSelectionIndex()) { case ORIENTATION_VERTICAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; break; case ORIENTATION_HORIZONTAL: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.HORIZONTAL; break; default: SWTPlotAppearanceEditor.this.plotOrientation = PlotOrientation.VERTICAL; } } } ); } } /** * Returns the plot orientation. * * @return The plot orientation. */ public PlotOrientation getPlotOrientation() { return this.plotOrientation; } /** * Returns the background paint. * * @return The background paint. */ public Color getBackGroundPaint() { return this.backgroundPaintCanvas.getColor(); } /** * Returns the outline paint. * * @return The outline paint. */ public Color getOutlinePaint() { return this.outlinePaintCanvas.getColor(); } /** * Returns the stroke. * * @return The stroke. */ public Stroke getStroke() { return this.strokeCanvas.getStroke(); } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java0000644000175000017500000001705311173030414032102 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * SWTPlotEditor.java * ------------------ * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt.editor; import java.awt.Stroke; import java.util.ResourceBundle; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.jfree.chart.axis.Axis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.experimental.swt.SWTUtils; /** * An editor for plot properties. */ class SWTPlotEditor extends Composite { /** * A panel used to display/edit the properties of the domain axis (if any). */ private SWTAxisEditor domainAxisPropertyPanel; /** * A panel used to display/edit the properties of the range axis (if any). */ private SWTAxisEditor rangeAxisPropertyPanel; private SWTPlotAppearanceEditor plotAppearance; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Creates a new editor for the specified plot. * * @param parent the parent. * @param style the style. * @param plot the plot. */ public SWTPlotEditor(Composite parent, int style, Plot plot) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group plotType = new Group(this, SWT.NONE); FillLayout plotTypeLayout = new FillLayout(); plotTypeLayout.marginHeight = plotTypeLayout.marginWidth = 4; plotType.setLayout(plotTypeLayout); plotType.setText(plot.getPlotType() + localizationResources.getString( ":")); TabFolder tabs = new TabFolder(plotType, SWT.NONE); //deal with domain axis TabItem item1 = new TabItem(tabs, SWT.NONE); item1.setText(localizationResources.getString("Domain_Axis")); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = SWTAxisEditor.getInstance(tabs, SWT.NONE, domainAxis); item1.setControl(this.domainAxisPropertyPanel); //deal with range axis TabItem item2 = new TabItem(tabs, SWT.NONE); item2.setText(localizationResources.getString("Range_Axis")); Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = SWTAxisEditor.getInstance(tabs, SWT.NONE, rangeAxis); item2.setControl(this.rangeAxisPropertyPanel); //deal with plot appearance TabItem item3 = new TabItem(tabs, SWT.NONE); item3.setText(localizationResources.getString("Appearance")); this.plotAppearance = new SWTPlotAppearanceEditor(tabs, SWT.NONE, plot); item3.setControl(this.plotAppearance); } /** * Returns the current outline stroke. * * @return The current outline stroke. */ public Color getBackgroundPaint() { return this.plotAppearance.getBackGroundPaint(); } /** * Returns the current outline stroke. * * @return The current outline stroke. */ public Color getOutlinePaint() { return this.plotAppearance.getOutlinePaint(); } /** * Returns the current outline stroke. * * @return The current outline stroke. */ public Stroke getOutlineStroke() { return this.plotAppearance.getStroke(); } /** * Updates the plot properties to match the properties * defined on the panel. * * @param plot The plot. */ public void updatePlotProperties(Plot plot) { // set the plot properties... plot.setBackgroundPaint(SWTUtils.toAwtColor(getBackgroundPaint())); plot.setOutlinePaint(SWTUtils.toAwtColor(getOutlinePaint())); plot.setOutlineStroke(getOutlineStroke()); // set the axis properties if (this.domainAxisPropertyPanel != null) { Axis domainAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; domainAxis = p.getDomainAxis(); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; domainAxis = p.getDomainAxis(); } if (domainAxis != null) this.domainAxisPropertyPanel.setAxisProperties(domainAxis); } if (this.rangeAxisPropertyPanel != null) { Axis rangeAxis = null; if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; rangeAxis = p.getRangeAxis(); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; rangeAxis = p.getRangeAxis(); } if (rangeAxis != null) this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis); } if (this.plotAppearance.getPlotOrientation() != null) { if (plot instanceof CategoryPlot) { CategoryPlot p = (CategoryPlot) plot; p.setOrientation(this.plotAppearance.getPlotOrientation()); } else if (plot instanceof XYPlot) { XYPlot p = (XYPlot) plot; p.setOrientation(this.plotAppearance.getPlotOrientation()); } } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java0000644000175000017500000000765311173030414032425 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * SWTStrokeCanvas.java * -------------------- * (C) Copyright 2006, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * */ package org.jfree.experimental.chart.swt.editor; import java.awt.BasicStroke; import java.awt.Stroke; import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; /** * A control for displaying a Stroke sample. */ class SWTStrokeCanvas extends Canvas { /** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param image the image. */ public SWTStrokeCanvas(Composite parent, int style, Image image) { this(parent, style); } /** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTStrokeCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { BasicStroke stroke = (BasicStroke) getStroke(); if (stroke != null) { int x, y; Rectangle rect = getClientArea(); x = (rect.width - 100) / 2; y = (rect.height - 16) / 2; Transform swtTransform = new Transform(e.gc.getDevice()); e.gc.getTransform(swtTransform); swtTransform.translate(x, y); e.gc.setTransform(swtTransform); swtTransform.dispose(); e.gc.setBackground(getDisplay().getSystemColor( SWT.COLOR_BLACK)); e.gc.setLineWidth((int) stroke.getLineWidth()); e.gc.drawLine(10, 8, 90, 8); } } }); } /** * Sets the stroke. * * @param stroke the stroke. */ public void setStroke(Stroke stroke) { if (stroke instanceof BasicStroke) { setData(stroke); } else { throw new RuntimeException( "Can only handle 'Basic Stroke' at present."); } } /** * Returns the stroke. * * @return The stroke. */ public BasicStroke getStroke() { return (BasicStroke) this.getData(); } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java0000644000175000017500000002564011173030414032246 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * SWTTitleEditor.java * ------------------- * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt.editor; import java.util.ResourceBundle; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.ColorDialog; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FontDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.jfree.chart.JFreeChart; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.experimental.swt.SWTPaintCanvas; import org.jfree.experimental.swt.SWTUtils; /** * An editor for chart title properties. */ class SWTTitleEditor extends Composite { /** Whether or not to display the title on the chart. */ private boolean showTitle; /** The checkbox to indicate whether or not to display the title. */ private Button showTitleCheckBox; /** A field for displaying/editing the title text. */ private Text titleField; /** The font used to draw the title. */ private FontData titleFont; /** A field for displaying a description of the title font. */ private Text fontField; /** The button to use to select a new title font. */ private Button selectFontButton; /** The paint (color) used to draw the title. */ private Color titleColor; /** The button to use to select a new paint (color) to draw the title. */ private Button selectColorButton; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** Font object used to handle a change of font. */ private Font font; /** * Standard constructor: builds a panel for displaying/editing the * properties of the specified title. * * @param parent the parent. * @param style the style. * @param title the title, which should be changed. * */ SWTTitleEditor(Composite parent, int style, Title title) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); TextTitle t = (title != null ? (TextTitle) title : new TextTitle(localizationResources.getString("Title"))); this.showTitle = (title != null); this.titleFont = SWTUtils.toSwtFontData(getDisplay(), t.getFont(), true); this.titleColor = SWTUtils.toSwtColor(getDisplay(), t.getPaint()); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1 Label label = new Label(general, SWT.NONE); label.setText(localizationResources.getString("Show_Title")); GridData gridData = new GridData(); gridData.horizontalSpan = 2; label.setLayoutData(gridData); this.showTitleCheckBox = new Button(general, SWT.CHECK); this.showTitleCheckBox.setSelection(this.showTitle); this.showTitleCheckBox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); this.showTitleCheckBox.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { SWTTitleEditor.this.showTitle = SWTTitleEditor.this .showTitleCheckBox.getSelection(); } }); // row 2 new Label(general, SWT.NONE).setText(localizationResources.getString( "Text")); this.titleField = new Text(general, SWT.BORDER); this.titleField.setText(t.getText()); this.titleField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); new Label(general, SWT.NONE).setText(""); // row 3 new Label(general, SWT.NONE).setText(localizationResources.getString( "Font")); this.fontField = new Text(general, SWT.BORDER); this.fontField.setText(this.titleFont.toString()); this.fontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); this.selectFontButton = new Button(general, SWT.PUSH); this.selectFontButton.setText(localizationResources.getString( "Select...")); this.selectFontButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the font-change dialog FontDialog dlg = new FontDialog(getShell()); dlg.setText(localizationResources.getString( "Font_Selection")); dlg.setFontList(new FontData[] { SWTTitleEditor.this.titleFont }); if (dlg.open() != null) { // Dispose of any fonts we have created if (SWTTitleEditor.this.font != null) { SWTTitleEditor.this.font.dispose(); } // Create the new font and set it into the title // label SWTTitleEditor.this.font = new Font( getShell().getDisplay(), dlg.getFontList()); //titleField.setFont(font); SWTTitleEditor.this.fontField.setText( SWTTitleEditor.this.font.getFontData()[0] .toString()); SWTTitleEditor.this.titleFont = SWTTitleEditor.this.font.getFontData()[0]; } } } ); // row 4 new Label(general, SWT.NONE).setText(localizationResources.getString( "Color")); // Use a SwtPaintCanvas to show the color, note that we must set the // heightHint. final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.titleColor); GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); canvasGridData.heightHint = 20; colorCanvas.setLayoutData(canvasGridData); this.selectColorButton = new Button(general, SWT.PUSH); this.selectColorButton.setText(localizationResources.getString( "Select...")); this.selectColorButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the color-change dialog ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Title_Color")); dlg.setRGB(SWTTitleEditor.this.titleColor.getRGB()); RGB rgb = dlg.open(); if (rgb != null) { // create the new color and set it to the // SwtPaintCanvas SWTTitleEditor.this.titleColor = new Color( getDisplay(), rgb); colorCanvas.setColor( SWTTitleEditor.this.titleColor); } } } ); } /** * Returns the title text entered in the panel. * * @return The title text entered in the panel. */ public String getTitleText() { return this.titleField.getText(); } /** * Returns the font selected in the panel. * * @return The font selected in the panel. */ public FontData getTitleFont() { return this.titleFont; } /** * Returns the font selected in the panel. * * @return The font selected in the panel. */ public Color getTitleColor() { return this.titleColor; } /** * Sets the properties of the specified title to match the properties * defined on this panel. * * @param chart the chart whose title is to be modified. */ public void setTitleProperties(JFreeChart chart) { if (this.showTitle) { TextTitle title = chart.getTitle(); if (title == null) { title = new TextTitle(); chart.setTitle(title); } title.setText(getTitleText()); title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), true)); title.setPaint(SWTUtils.toAwtColor(getTitleColor())); } else { chart.setTitle((TextTitle) null); } } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/chart/swt/ChartComposite.java0000644000175000017500000021000511173030414031045 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * ChartComposite.java * ------------------- * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * Cedric Chabanois (cchabanois AT no-log.org); * Christoph Beck; * * Changes * ------- * 19-Jun-2006 : New class (HP); * 06-Nov-2006 : Added accessor methods for zoomInFactor and zoomOutFactor (DG); * 28-Nov-2006 : Added support for trace lines (HP); * 30-Nov-2006 : Improved zoom box handling (HP); * 06-Dec-2006 : Added (simplified) tool tip support (HP); * 11-Dec-2006 : Fixed popup menu location by fgiust, bug 1612770 (HP); * 31-Jan-2007 : Fixed some issues with the trace lines, fixed cross hair not * being drawn, added getter and setter methods for the trace * lines (HP); * 07-Apr-2007 : Changed this.redraw() into canvas.redraw() to fix redraw * problems (HP); * 19-May-2007 : Small fix in paintControl to check for null charts, bug * 1719260 (HP); * 19-May-2007 : Corrected bug with scaling when the drawing region is larger * than maximum draw width/height (HP); * 23-May-2007 : Added some dispose call to free SWT resources, patch sent by * Cédric Chabanois (CC); * 06-Jun-2007 : Fixed minor issues with tooltips. bug reported and fix * proposed by Christoph Beck, bug 1726404 (HP); * 22-Oct-2007 : Added addChartMouseListener and removeChartMouseListener * methods as suggested by Christoph Beck, bug 1742002 (HP); * 22-Oct-2007 : Fixed bug in zooming with multiple plots (HP); * 22-Oct-2007 : Check for null zoom point when restoring auto range and domain * bounds (HP); * 22-Oct-2007 : Pass mouse moved events to listening ChartMouseListeners (HP); * 22-Oct-2007 : Refactored class, now implements PaintListener, MouseListener, * MouseMoveListener. Made the chart field be private again and * added new method addSWTListener to allow custom behavior. * 14-Nov-2007 : Create canvas with SWT.DOUBLE_BUFFER, added * getChartRenderingInfo(), is/setDomainZoomable() and * is/setRangeZoomable() as per feature request (DG); * 11-Jul-2008 : Bug 1994355 fix (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.experimental.chart.swt; import java.awt.Graphics; import java.awt.Point; import java.awt.RenderingHints; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.File; import java.io.IOException; import java.util.EventListener; import java.util.ResourceBundle; import javax.swing.event.EventListenerList; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.HelpListener; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.MessageBox; import org.jfree.chart.ChartMouseEvent; import org.jfree.chart.ChartMouseListener; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.event.ChartProgressEvent; import org.jfree.chart.event.ChartProgressListener; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; import org.jfree.chart.plot.Zoomable; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.experimental.chart.swt.editor.SWTChartEditor; import org.jfree.experimental.swt.SWTGraphics2D; import org.jfree.experimental.swt.SWTUtils; /** * A SWT GUI composite for displaying a {@link JFreeChart} object. *

      * The composite listens to the chart to receive notification of changes to any * component of the chart. The chart is redrawn automatically whenever this * notification is received. */ public class ChartComposite extends Composite implements ChartChangeListener, ChartProgressListener, PaintListener, SelectionListener, MouseListener, MouseMoveListener, Printable { /** Default setting for buffer usage. */ public static final boolean DEFAULT_BUFFER_USED = false; /** The default panel width. */ public static final int DEFAULT_WIDTH = 680; /** The default panel height. */ public static final int DEFAULT_HEIGHT = 420; /** The default limit below which chart scaling kicks in. */ public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300; /** The default limit below which chart scaling kicks in. */ public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; /** The default limit below which chart scaling kicks in. */ public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 800; /** The default limit below which chart scaling kicks in. */ public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 600; /** The minimum size required to perform a zoom on a rectangle */ public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; /** Properties action command. */ public static final String PROPERTIES_COMMAND = "PROPERTIES"; /** Save action command. */ public static final String SAVE_COMMAND = "SAVE"; /** Print action command. */ public static final String PRINT_COMMAND = "PRINT"; /** Zoom in (both axes) action command. */ public static final String ZOOM_IN_BOTH_COMMAND = "ZOOM_IN_BOTH"; /** Zoom in (domain axis only) action command. */ public static final String ZOOM_IN_DOMAIN_COMMAND = "ZOOM_IN_DOMAIN"; /** Zoom in (range axis only) action command. */ public static final String ZOOM_IN_RANGE_COMMAND = "ZOOM_IN_RANGE"; /** Zoom out (both axes) action command. */ public static final String ZOOM_OUT_BOTH_COMMAND = "ZOOM_OUT_BOTH"; /** Zoom out (domain axis only) action command. */ public static final String ZOOM_OUT_DOMAIN_COMMAND = "ZOOM_DOMAIN_BOTH"; /** Zoom out (range axis only) action command. */ public static final String ZOOM_OUT_RANGE_COMMAND = "ZOOM_RANGE_BOTH"; /** Zoom reset (both axes) action command. */ public static final String ZOOM_RESET_BOTH_COMMAND = "ZOOM_RESET_BOTH"; /** Zoom reset (domain axis only) action command. */ public static final String ZOOM_RESET_DOMAIN_COMMAND = "ZOOM_RESET_DOMAIN"; /** Zoom reset (range axis only) action command. */ public static final String ZOOM_RESET_RANGE_COMMAND = "ZOOM_RESET_RANGE"; /** The chart that is displayed in the panel. */ private JFreeChart chart; /** The canvas to display the chart. */ private Canvas canvas; /** Storage for registered (chart) mouse listeners. */ private EventListenerList chartMouseListeners; /** A flag that controls whether or not the off-screen buffer is used. */ private boolean useBuffer; /** A flag that indicates that the buffer should be refreshed. */ private boolean refreshBuffer; /** A flag that indicates that the tooltips should be displayed. */ private boolean displayToolTips; /** A buffer for the rendered chart. */ private org.eclipse.swt.graphics.Image chartBuffer; /** The height of the chart buffer. */ private int chartBufferHeight; /** The width of the chart buffer. */ private int chartBufferWidth; /** * The minimum width for drawing a chart (uses scaling for smaller widths). */ private int minimumDrawWidth; /** * The minimum height for drawing a chart (uses scaling for smaller * heights). */ private int minimumDrawHeight; /** * The maximum width for drawing a chart (uses scaling for bigger * widths). */ private int maximumDrawWidth; /** * The maximum height for drawing a chart (uses scaling for bigger * heights). */ private int maximumDrawHeight; /** The popup menu for the frame. */ private Menu popup; /** The drawing info collected the last time the chart was drawn. */ private ChartRenderingInfo info; /** The chart anchor point. */ private Point2D anchor; /** The scale factor used to draw the chart. */ private double scaleX; /** The scale factor used to draw the chart. */ private double scaleY; /** The plot orientation. */ private PlotOrientation orientation = PlotOrientation.VERTICAL; /** A flag that controls whether or not domain zooming is enabled. */ private boolean domainZoomable = false; /** A flag that controls whether or not range zooming is enabled. */ private boolean rangeZoomable = false; /** * The zoom rectangle starting point (selected by the user with a mouse * click). This is a point on the screen, not the chart (which may have * been scaled up or down to fit the panel). */ private org.eclipse.swt.graphics.Point zoomPoint = null; /** The zoom rectangle (selected by the user with the mouse). */ private transient Rectangle zoomRectangle = null; /** Controls if the zoom rectangle is drawn as an outline or filled. */ //TODO private boolean fillZoomRectangle = true; /** The minimum distance required to drag the mouse to trigger a zoom. */ private int zoomTriggerDistance; /** A flag that controls whether or not horizontal tracing is enabled. */ private boolean horizontalAxisTrace = false; /** A flag that controls whether or not vertical tracing is enabled. */ private boolean verticalAxisTrace = false; /** A vertical trace line. */ private transient int verticalTraceLineX; /** A horizontal trace line. */ private transient int horizontalTraceLineY; /** Menu item for zooming in on a chart (both axes). */ private MenuItem zoomInBothMenuItem; /** Menu item for zooming in on a chart (domain axis). */ private MenuItem zoomInDomainMenuItem; /** Menu item for zooming in on a chart (range axis). */ private MenuItem zoomInRangeMenuItem; /** Menu item for zooming out on a chart. */ private MenuItem zoomOutBothMenuItem; /** Menu item for zooming out on a chart (domain axis). */ private MenuItem zoomOutDomainMenuItem; /** Menu item for zooming out on a chart (range axis). */ private MenuItem zoomOutRangeMenuItem; /** Menu item for resetting the zoom (both axes). */ private MenuItem zoomResetBothMenuItem; /** Menu item for resetting the zoom (domain axis only). */ private MenuItem zoomResetDomainMenuItem; /** Menu item for resetting the zoom (range axis only). */ private MenuItem zoomResetRangeMenuItem; /** A flag that controls whether or not file extensions are enforced. */ private boolean enforceFileExtensions; /** The factor used to zoom in on an axis range. */ private double zoomInFactor = 0.5; /** The factor used to zoom out on an axis range. */ private double zoomOutFactor = 2.0; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.LocalizationBundle"); /** * Create a new chart composite with a default FillLayout. * This way, when drawn, the chart will fill all the space. * @param comp The parent. * @param style The style of the composite. */ public ChartComposite(Composite comp, int style) { this(comp, style, null, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_BUFFER_USED, true, // properties true, // save true, // print true, // zoom true // tooltips ); } /** * Constructs a panel that displays the specified chart. * * @param comp The parent. * @param style The style of the composite. * @param chart the chart. */ public ChartComposite(Composite comp, int style, JFreeChart chart) { this(comp, style, chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_BUFFER_USED, true, // properties true, // save true, // print true, // zoom true // tooltips ); } /** * Constructs a panel containing a chart. * * @param comp The parent. * @param style The style of the composite. * @param chart the chart. * @param useBuffer a flag controlling whether or not an off-screen buffer * is used. */ public ChartComposite(Composite comp, int style, JFreeChart chart, boolean useBuffer) { this(comp, style, chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, useBuffer, true, // properties true, // save true, // print true, // zoom true // tooltips ); } /** * Constructs a JFreeChart panel. * * @param comp The parent. * @param style The style of the composite. * @param chart the chart. * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should * be added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. */ public ChartComposite( Composite comp, int style, JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) { this( comp, style, chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, DEFAULT_MAXIMUM_DRAW_HEIGHT, DEFAULT_BUFFER_USED, properties, save, print, zoom, tooltips ); } /** * Constructs a JFreeChart panel. * * @param comp The parent. * @param style The style of the composite. * @param jfreechart the chart. * @param width the preferred width of the panel. * @param height the preferred height of the panel. * @param minimumDrawW the minimum drawing width. * @param minimumDrawH the minimum drawing height. * @param maximumDrawW the maximum drawing width. * @param maximumDrawH the maximum drawing height. * @param usingBuffer a flag that indicates whether to use the off-screen * buffer to improve performance (at the expense of * memory). * @param properties a flag indicating whether or not the chart property * editor should be available via the popup menu. * @param save a flag indicating whether or not save options should be * available via the popup menu. * @param print a flag indicating whether or not the print option * should be available via the popup menu. * @param zoom a flag indicating whether or not zoom options should be * added to the popup menu. * @param tooltips a flag indicating whether or not tooltips should be * enabled for the chart. */ public ChartComposite(Composite comp, int style, JFreeChart jfreechart, int width, int height, int minimumDrawW, int minimumDrawH, int maximumDrawW, int maximumDrawH, boolean usingBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) { super(comp, style); setChart(jfreechart); this.chartMouseListeners = new EventListenerList(); setLayout(new FillLayout()); this.info = new ChartRenderingInfo(); this.useBuffer = usingBuffer; this.refreshBuffer = false; this.minimumDrawWidth = minimumDrawW; this.minimumDrawHeight = minimumDrawH; this.maximumDrawWidth = maximumDrawW; this.maximumDrawHeight = maximumDrawH; this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; setDisplayToolTips(tooltips); // create the canvas and add the required listeners this.canvas = new Canvas(this, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND); this.canvas.addPaintListener(this); this.canvas.addMouseListener(this); this.canvas.addMouseMoveListener(this); // set up popup menu... this.popup = null; if (properties || save || print || zoom) this.popup = createPopupMenu(properties, save, print, zoom); this.enforceFileExtensions = true; } /** * Returns the X scale factor for the chart. This will be 1.0 if no * scaling has been used. * * @return The scale factor. */ public double getScaleX() { return this.scaleX; } /** * Returns the Y scale factory for the chart. This will be 1.0 if no * scaling has been used. * * @return The scale factor. */ public double getScaleY() { return this.scaleY; } /** * Returns the anchor point. * * @return The anchor point (possibly null). */ public Point2D getAnchor() { return this.anchor; } /** * Sets the anchor point. This method is provided for the use of * subclasses, not end users. * * @param anchor the anchor point (null permitted). */ protected void setAnchor(Point2D anchor) { this.anchor = anchor; } /** * Returns the chart contained in the panel. * * @return The chart (possibly null). */ public JFreeChart getChart() { return this.chart; } /** * Sets the chart that is displayed in the panel. * * @param chart the chart (null permitted). */ public void setChart(JFreeChart chart) { // stop listening for changes to the existing chart if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } // add the new chart this.chart = chart; if (chart != null) { this.chart.addChangeListener(this); this.chart.addProgressListener(this); Plot plot = chart.getPlot(); this.domainZoomable = false; this.rangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = z.isDomainZoomable(); this.rangeZoomable = z.isRangeZoomable(); this.orientation = z.getOrientation(); } } else { this.domainZoomable = false; this.rangeZoomable = false; } if (this.useBuffer) { this.refreshBuffer = true; } } /** * Returns the chart rendering info from the most recent chart redraw. * * @return The chart rendering info (possibly null). */ public ChartRenderingInfo getChartRenderingInfo() { return this.info; } /** * Returns the flag that determines whether or not zooming is enabled for * the domain axis. * * @return A boolean. */ public boolean isDomainZoomable() { return this.domainZoomable; } /** * Sets the flag that controls whether or not zooming is enable for the * domain axis. A check is made to ensure that the current plot supports * zooming for the domain values. * * @param flag true enables zooming if possible. */ public void setDomainZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.domainZoomable = flag && (z.isDomainZoomable()); } } else { this.domainZoomable = false; } } /** * Returns the flag that determines whether or not zooming is enabled for * the range axis. * * @return A boolean. */ public boolean isRangeZoomable() { return this.rangeZoomable; } /** * A flag that controls mouse-based zooming on the vertical axis. * * @param flag true enables zooming. */ public void setRangeZoomable(boolean flag) { if (flag) { Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.rangeZoomable = flag && (z.isRangeZoomable()); } } else { this.rangeZoomable = false; } } /** * Returns the zoom in factor. * * @return The zoom in factor. * * @see #setZoomInFactor(double) */ public double getZoomInFactor() { return this.zoomInFactor; } /** * Sets the zoom in factor. * * @param factor the factor. * * @see #getZoomInFactor() */ public void setZoomInFactor(double factor) { this.zoomInFactor = factor; } /** * Returns the zoom out factor. * * @return The zoom out factor. * * @see #setZoomOutFactor(double) */ public double getZoomOutFactor() { return this.zoomOutFactor; } /** * Sets the zoom out factor. * * @param factor the factor. * * @see #getZoomOutFactor() */ public void setZoomOutFactor(double factor) { this.zoomOutFactor = factor; } /** * Displays a dialog that allows the user to edit the properties for the * current chart. */ private void attemptEditChartProperties() { SWTChartEditor editor = new SWTChartEditor(this.canvas.getDisplay(), this.chart); //ChartEditorManager.getChartEditor(canvas.getDisplay(), this.chart); editor.open(); } /** * Returns true if file extensions should be enforced, and * false otherwise. * * @return The flag. */ public boolean isEnforceFileExtensions() { return this.enforceFileExtensions; } /** * Sets a flag that controls whether or not file extensions are enforced. * * @param enforce the new flag value. */ public void setEnforceFileExtensions(boolean enforce) { this.enforceFileExtensions = enforce; } /** * Opens a file chooser and gives the user an opportunity to save the chart * in PNG format. * * @throws IOException if there is an I/O error. */ public void doSaveAs() throws IOException { FileDialog fileDialog = new FileDialog(this.canvas.getShell(), SWT.SAVE); String[] extensions = {"*.png"}; fileDialog.setFilterExtensions(extensions); String filename = fileDialog.open(); if (filename != null) { if (isEnforceFileExtensions()) { if (!filename.endsWith(".png")) { filename = filename + ".png"; } } //TODO replace getSize by getBounds ? ChartUtilities.saveChartAsPNG(new File(filename), this.chart, this.canvas.getSize().x, this.canvas.getSize().y); } } /** * Returns a point based on (x, y) but constrained to be within the bounds * of the given rectangle. This method could be moved to JCommon. * * @param x the x-coordinate. * @param y the y-coordinate. * @param area the rectangle (null not permitted). * * @return A point within the rectangle. */ private org.eclipse.swt.graphics.Point getPointInRectangle(int x, int y, Rectangle area) { x = Math.max(area.x, Math.min(x, area.x + area.width)); y = Math.max(area.y, Math.min(y, area.y + area.height)); return new org.eclipse.swt.graphics.Point(x, y); } /** * Zooms in on an anchor point (specified in screen coordinate space). * * @param x the x value (in screen coordinates). * @param y the y value (in screen coordinates). */ public void zoomInBoth(double x, double y) { zoomInDomain(x, y); zoomInRange(x, y); } /** * Decreases the length of the domain axis, centered about the given * coordinate on the screen. The length of the domain axis is reduced * by the value of {@link #getZoomInFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomInDomain(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable plot = (Zoomable) p; plot.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } } /** * Decreases the length of the range axis, centered about the given * coordinate on the screen. The length of the range axis is reduced by * the value of {@link #getZoomInFactor()}. * * @param x the x-coordinate (in screen coordinates). * @param y the y coordinate (in screen coordinates). */ public void zoomInRange(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } } /** * Zooms out on an anchor point (specified in screen coordinate space). * * @param x the x value (in screen coordinates). * @param y the y value (in screen coordinates). */ public void zoomOutBoth(double x, double y) { zoomOutDomain(x, y); zoomOutRange(x, y); } /** * Increases the length of the domain axis, centered about the given * coordinate on the screen. The length of the domain axis is increased * by the value of {@link #getZoomOutFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomOutDomain(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } } /** * Increases the length the range axis, centered about the given * coordinate on the screen. The length of the range axis is increased * by the value of {@link #getZoomOutFactor()}. * * @param x the x coordinate (in screen coordinates). * @param y the y-coordinate (in screen coordinates). */ public void zoomOutRange(double x, double y) { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(), translateScreenToJava2D(new Point((int) x, (int) y))); } } /** * Zooms in on a selected region. * * @param selection the selected region. */ public void zoom(Rectangle selection) { // get the origin of the zoom selection in the Java2D space used for // drawing the chart (that is, before any scaling to fit the panel) Point2D selectOrigin = translateScreenToJava2D( new Point(selection.x, selection.y)); PlotRenderingInfo plotInfo = this.info.getPlotInfo(); Rectangle scaledDataArea = getScreenDataArea( (selection.x + selection.width / 2), (selection.y + selection.height / 2)); if ((selection.height > 0) && (selection.width > 0)) { double hLower = (selection.x - scaledDataArea.x) / (double) scaledDataArea.width; double hUpper = (selection.x + selection.width - scaledDataArea.x) / (double) scaledDataArea.width; double vLower = (scaledDataArea.y + scaledDataArea.height - selection.y - selection.height) / (double) scaledDataArea.height; double vUpper = (scaledDataArea.y + scaledDataArea.height - selection.y) / (double) scaledDataArea.height; Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; if (z.getOrientation() == PlotOrientation.HORIZONTAL) { z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin); z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin); } else { z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin); z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin); } } } } /** * Receives notification of changes to the chart, and redraws the chart. * * @param event details of the chart change event. */ public void chartChanged(ChartChangeEvent event) { this.refreshBuffer = true; Plot plot = this.chart.getPlot(); if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; this.orientation = z.getOrientation(); } this.canvas.redraw(); } /** * Forces a redraw of the canvas by invoking a new PaintEvent. */ public void forceRedraw() { Event ev = new Event(); ev.gc = new GC(this.canvas); ev.x = 0; ev.y = 0; ev.width = this.canvas.getBounds().width; ev.height = this.canvas.getBounds().height; ev.count = 0; this.canvas.notifyListeners(SWT.Paint, ev); ev.gc.dispose(); } /** * Adds a listener to the list of objects listening for chart mouse events. * * @param listener the listener (null not permitted). */ public void addChartMouseListener(ChartMouseListener listener) { this.chartMouseListeners.add(ChartMouseListener.class, listener); } /** * Removes a listener from the list of objects listening for chart mouse * events. * * @param listener the listener. */ public void removeChartMouseListener(ChartMouseListener listener) { this.chartMouseListeners.remove(ChartMouseListener.class, listener); } /** * Receives notification of a chart progress event. * * @param event the event. */ public void chartProgress(ChartProgressEvent event) { // does nothing - override if necessary } /** * Restores the auto-range calculation on both axes. */ public void restoreAutoBounds() { restoreAutoDomainBounds(); restoreAutoRangeBounds(); } /** * Restores the auto-range calculation on the domain axis. */ public void restoreAutoDomainBounds() { Plot p = this.chart.getPlot(); if (p instanceof Zoomable) { Zoomable z = (Zoomable) p; // we need to guard against this.zoomPoint being null org.eclipse.swt.graphics.Point zp = (this.zoomPoint != null ? this.zoomPoint : new org.eclipse.swt.graphics.Point(0, 0)); z.zoomDomainAxes(0.0, this.info.getPlotInfo(), SWTUtils.toAwtPoint(zp)); } } /** * Restores the auto-range calculation on the range axis. */ public void restoreAutoRangeBounds() { Plot p = this.chart.getPlot(); if (p instanceof ValueAxisPlot) { Zoomable z = (Zoomable) p; // we need to guard against this.zoomPoint being null org.eclipse.swt.graphics.Point zp = (this.zoomPoint != null ? this.zoomPoint : new org.eclipse.swt.graphics.Point(0, 0)); z.zoomRangeAxes(0.0, this.info.getPlotInfo(), SWTUtils.toAwtPoint(zp)); } } /** * Applies any scaling that is in effect for the chart drawing to the * given rectangle. * * @param rect the rectangle. * * @return A new scaled rectangle. */ public Rectangle scale(Rectangle2D rect) { Rectangle insets = this.getClientArea(); int x = (int) Math.round(rect.getX() * getScaleX()) + insets.x; int y = (int) Math.round(rect.getY() * this.getScaleY()) + insets.y; int w = (int) Math.round(rect.getWidth() * this.getScaleX()); int h = (int) Math.round(rect.getHeight() * this.getScaleY()); return new Rectangle(x, y, w, h); } /** * Returns the data area for the chart (the area inside the axes) with the * current scaling applied (that is, the area as it appears on screen). * * @return The scaled data area. */ public Rectangle getScreenDataArea() { Rectangle2D dataArea = this.info.getPlotInfo().getDataArea(); Rectangle clientArea = this.getClientArea(); int x = (int) (dataArea.getX() * this.scaleX + clientArea.x); int y = (int) (dataArea.getY() * this.scaleY + clientArea.y); int w = (int) (dataArea.getWidth() * this.scaleX); int h = (int) (dataArea.getHeight() * this.scaleY); return new Rectangle(x, y, w, h); } /** * Returns the data area (the area inside the axes) for the plot or subplot, * with the current scaling applied. * * @param x the x-coordinate (for subplot selection). * @param y the y-coordinate (for subplot selection). * * @return The scaled data area. */ public Rectangle getScreenDataArea(int x, int y) { PlotRenderingInfo plotInfo = this.info.getPlotInfo(); Rectangle result; if (plotInfo.getSubplotCount() == 0) result = getScreenDataArea(); else { // get the origin of the zoom selection in the Java2D space used for // drawing the chart (that is, before any scaling to fit the panel) Point2D selectOrigin = translateScreenToJava2D(new Point(x, y)); int subplotIndex = plotInfo.getSubplotIndex(selectOrigin); if (subplotIndex == -1) { return null; } result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea()); } return result; } /** * Translates a Java2D point on the chart to a screen location. * * @param java2DPoint the Java2D point. * * @return The screen location. */ public Point translateJava2DToScreen(Point2D java2DPoint) { Rectangle insets = this.getClientArea(); int x = (int) (java2DPoint.getX() * this.scaleX + insets.x); int y = (int) (java2DPoint.getY() * this.scaleY + insets.y); return new Point(x, y); } /** * Translates a screen location to a Java SWT point. * * @param screenPoint the screen location. * * @return The Java2D coordinates. */ public Point translateScreenToJavaSWT(Point screenPoint) { Rectangle insets = this.getClientArea(); int x = (int) ((screenPoint.x - insets.x) / this.scaleX); int y = (int) ((screenPoint.y - insets.y) / this.scaleY); return new Point(x, y); } /** * Translates a screen location to a Java2D point. * * @param screenPoint the screen location. * * @return The Java2D coordinates. */ public Point2D translateScreenToJava2D(Point screenPoint) { Rectangle insets = this.getClientArea(); int x = (int) ((screenPoint.x - insets.x) / this.scaleX); int y = (int) ((screenPoint.y - insets.y) / this.scaleY); return new Point2D.Double(x, y); } /** * Returns the flag that controls whether or not a horizontal axis trace * line is drawn over the plot area at the current mouse location. * * @return A boolean. */ public boolean getHorizontalAxisTrace() { return this.horizontalAxisTrace; } /** * A flag that controls trace lines on the horizontal axis. * * @param flag true enables trace lines for the mouse * pointer on the horizontal axis. */ public void setHorizontalAxisTrace(boolean flag) { this.horizontalAxisTrace = flag; } /** * Returns the flag that controls whether or not a vertical axis trace * line is drawn over the plot area at the current mouse location. * * @return A boolean. */ public boolean getVerticalAxisTrace() { return this.verticalAxisTrace; } /** * A flag that controls trace lines on the vertical axis. * * @param flag true enables trace lines for the mouse * pointer on the vertical axis. */ public void setVerticalAxisTrace(boolean flag) { this.verticalAxisTrace = flag; } /** * @param displayToolTips the displayToolTips to set */ public void setDisplayToolTips(boolean displayToolTips) { this.displayToolTips = displayToolTips; } /** * Returns a string for the tooltip. * * @param e the mouse event. * * @return A tool tip or null if no tooltip is available. */ public String getToolTipText(org.eclipse.swt.events.MouseEvent e) { String result = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { Rectangle insets = getClientArea(); ChartEntity entity = entities.getEntity( (int) ((e.x - insets.x) / this.scaleX), (int) ((e.y - insets.y) / this.scaleY)); if (entity != null) { result = entity.getToolTipText(); } } } return result; } /** * The idea is to modify the zooming options depending on the type of chart * being displayed by the panel. * * @param x horizontal position of the popup. * @param y vertical position of the popup. */ protected void displayPopupMenu(int x, int y) { if (this.popup != null) { // go through each zoom menu item and decide whether or not to // enable it... Plot plot = this.chart.getPlot(); boolean isDomainZoomable = false; boolean isRangeZoomable = false; if (plot instanceof Zoomable) { Zoomable z = (Zoomable) plot; isDomainZoomable = z.isDomainZoomable(); isRangeZoomable = z.isRangeZoomable(); } if (this.zoomInDomainMenuItem != null) { this.zoomInDomainMenuItem.setEnabled(isDomainZoomable); } if (this.zoomOutDomainMenuItem != null) { this.zoomOutDomainMenuItem.setEnabled(isDomainZoomable); } if (this.zoomResetDomainMenuItem != null) { this.zoomResetDomainMenuItem.setEnabled(isDomainZoomable); } if (this.zoomInRangeMenuItem != null) { this.zoomInRangeMenuItem.setEnabled(isRangeZoomable); } if (this.zoomOutRangeMenuItem != null) { this.zoomOutRangeMenuItem.setEnabled(isRangeZoomable); } if (this.zoomResetRangeMenuItem != null) { this.zoomResetRangeMenuItem.setEnabled(isRangeZoomable); } if (this.zoomInBothMenuItem != null) { this.zoomInBothMenuItem.setEnabled(isDomainZoomable & isRangeZoomable); } if (this.zoomOutBothMenuItem != null) { this.zoomOutBothMenuItem.setEnabled(isDomainZoomable & isRangeZoomable); } if (this.zoomResetBothMenuItem != null) { this.zoomResetBothMenuItem.setEnabled(isDomainZoomable & isRangeZoomable); } this.popup.setLocation(x, y); this.popup.setVisible(true); } } /** * Creates a print job for the chart. */ public void createChartPrintJob() { //FIXME try to replace swing print stuff by swt PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { MessageBox messageBox = new MessageBox( this.canvas.getShell(), SWT.OK | SWT.ICON_ERROR); messageBox.setMessage(e.getMessage()); messageBox.open(); } } } } /** * Creates a popup menu for the canvas. * * @param properties include a menu item for the chart property editor. * @param save include a menu item for saving the chart. * @param print include a menu item for printing the chart. * @param zoom include menu items for zooming. * * @return The popup menu. */ protected Menu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { Menu result = new Menu(this); boolean separator = false; if (properties) { MenuItem propertiesItem = new MenuItem(result, SWT.PUSH); propertiesItem.setText(localizationResources.getString( "Properties...")); propertiesItem.setData(PROPERTIES_COMMAND); propertiesItem.addSelectionListener(this); separator = true; } if (save) { if (separator) { new MenuItem(result, SWT.SEPARATOR); separator = false; } MenuItem saveItem = new MenuItem(result, SWT.NONE); saveItem.setText(localizationResources.getString("Save_as...")); saveItem.setData(SAVE_COMMAND); saveItem.addSelectionListener(this); separator = true; } if (print) { if (separator) { new MenuItem(result, SWT.SEPARATOR); separator = false; } MenuItem printItem = new MenuItem(result, SWT.NONE); printItem.setText(localizationResources.getString("Print...")); printItem.setData(PRINT_COMMAND); printItem.addSelectionListener(this); separator = true; } if (zoom) { if (separator) { new MenuItem(result, SWT.SEPARATOR); separator = false; } Menu zoomInMenu = new Menu(result); MenuItem zoomInMenuItem = new MenuItem(result, SWT.CASCADE); zoomInMenuItem.setText(localizationResources.getString("Zoom_In")); zoomInMenuItem.setMenu(zoomInMenu); this.zoomInBothMenuItem = new MenuItem(zoomInMenu, SWT.PUSH); this.zoomInBothMenuItem.setText(localizationResources.getString( "All_Axes")); this.zoomInBothMenuItem.setData(ZOOM_IN_BOTH_COMMAND); this.zoomInBothMenuItem.addSelectionListener(this); new MenuItem(zoomInMenu, SWT.SEPARATOR); this.zoomInDomainMenuItem = new MenuItem(zoomInMenu, SWT.PUSH); this.zoomInDomainMenuItem.setText(localizationResources.getString( "Domain_Axis")); this.zoomInDomainMenuItem.setData(ZOOM_IN_DOMAIN_COMMAND); this.zoomInDomainMenuItem.addSelectionListener(this); this.zoomInRangeMenuItem = new MenuItem(zoomInMenu, SWT.PUSH); this.zoomInRangeMenuItem.setText(localizationResources.getString( "Range_Axis")); this.zoomInRangeMenuItem.setData(ZOOM_IN_RANGE_COMMAND); this.zoomInRangeMenuItem.addSelectionListener(this); Menu zoomOutMenu = new Menu(result); MenuItem zoomOutMenuItem = new MenuItem(result, SWT.CASCADE); zoomOutMenuItem.setText(localizationResources.getString( "Zoom_Out")); zoomOutMenuItem.setMenu(zoomOutMenu); this.zoomOutBothMenuItem = new MenuItem(zoomOutMenu, SWT.PUSH); this.zoomOutBothMenuItem.setText(localizationResources.getString( "All_Axes")); this.zoomOutBothMenuItem.setData(ZOOM_OUT_BOTH_COMMAND); this.zoomOutBothMenuItem.addSelectionListener(this); new MenuItem(zoomOutMenu, SWT.SEPARATOR); this.zoomOutDomainMenuItem = new MenuItem(zoomOutMenu, SWT.PUSH); this.zoomOutDomainMenuItem.setText(localizationResources.getString( "Domain_Axis")); this.zoomOutDomainMenuItem.setData(ZOOM_OUT_DOMAIN_COMMAND); this.zoomOutDomainMenuItem.addSelectionListener(this); this.zoomOutRangeMenuItem = new MenuItem(zoomOutMenu, SWT.PUSH); this.zoomOutRangeMenuItem.setText( localizationResources.getString("Range_Axis")); this.zoomOutRangeMenuItem.setData(ZOOM_OUT_RANGE_COMMAND); this.zoomOutRangeMenuItem.addSelectionListener(this); Menu autoRangeMenu = new Menu(result); MenuItem autoRangeMenuItem = new MenuItem(result, SWT.CASCADE); autoRangeMenuItem.setText(localizationResources.getString( "Auto_Range")); autoRangeMenuItem.setMenu(autoRangeMenu); this.zoomResetBothMenuItem = new MenuItem(autoRangeMenu, SWT.PUSH); this.zoomResetBothMenuItem.setText(localizationResources.getString( "All_Axes")); this.zoomResetBothMenuItem.setData(ZOOM_RESET_BOTH_COMMAND); this.zoomResetBothMenuItem.addSelectionListener(this); new MenuItem(autoRangeMenu, SWT.SEPARATOR); this.zoomResetDomainMenuItem = new MenuItem(autoRangeMenu, SWT.PUSH); this.zoomResetDomainMenuItem.setText( localizationResources.getString("Domain_Axis")); this.zoomResetDomainMenuItem.setData(ZOOM_RESET_DOMAIN_COMMAND); this.zoomResetDomainMenuItem.addSelectionListener(this); this.zoomResetRangeMenuItem = new MenuItem(autoRangeMenu, SWT.PUSH); this.zoomResetRangeMenuItem.setText( localizationResources.getString("Range_Axis")); this.zoomResetRangeMenuItem.setData(ZOOM_RESET_RANGE_COMMAND); this.zoomResetRangeMenuItem.addSelectionListener(this); } return result; } /** * Handles action events generated by the popup menu. * * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected( * org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } /** * Handles action events generated by the popup menu. * * @see org.eclipse.swt.events.SelectionListener#widgetSelected( * org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { String command = (String) ((MenuItem) e.getSource()).getData(); if (command.equals(PROPERTIES_COMMAND)) { attemptEditChartProperties(); } else if (command.equals(SAVE_COMMAND)) { try { doSaveAs(); } catch (IOException ex) { ex.printStackTrace(); } } else if (command.equals(PRINT_COMMAND)) { createChartPrintJob(); } /* in the next zoomPoint.x and y replace by e.x and y for now. * this helps to handle the mouse events and besides, * those values are unused AFAIK. */ else if (command.equals(ZOOM_IN_BOTH_COMMAND)) { zoomInBoth(e.x, e.y); } else if (command.equals(ZOOM_IN_DOMAIN_COMMAND)) { zoomInDomain(e.x, e.y); } else if (command.equals(ZOOM_IN_RANGE_COMMAND)) { zoomInRange(e.x, e.y); } else if (command.equals(ZOOM_OUT_BOTH_COMMAND)) { zoomOutBoth(e.x, e.y); } else if (command.equals(ZOOM_OUT_DOMAIN_COMMAND)) { zoomOutDomain(e.x, e.y); } else if (command.equals(ZOOM_OUT_RANGE_COMMAND)) { zoomOutRange(e.x, e.y); } else if (command.equals(ZOOM_RESET_BOTH_COMMAND)) { restoreAutoBounds(); } else if (command.equals(ZOOM_RESET_DOMAIN_COMMAND)) { restoreAutoDomainBounds(); } else if (command.equals(ZOOM_RESET_RANGE_COMMAND)) { restoreAutoRangeBounds(); } this.forceRedraw(); } /** * Not implemented. * * @param graphics the graphics. * @param pageFormat the page format. * @param pageIndex the page index. * * @return ?. * * @throws PrinterException if there is a problem. */ public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex != 0) { return NO_SUCH_PAGE; } /* CairoImage image = new CairoImage( this.getBounds().width, this.getBounds().height); Graphics2D g2 = image.createGraphics2D(); double x = pageFormat.getImageableX(); double y = pageFormat.getImageableY(); double w = pageFormat.getImageableWidth(); double h = pageFormat.getImageableHeight(); this.chart.draw( g2, new Rectangle2D.Double(x, y, w, h), this.anchor, null ); */ return PAGE_EXISTS; } /** * Hook an SWT listener on the canvas where the chart is drawn. * The purpose of this method is to allow some degree of customization. * * @param listener The SWT listener to attach to the canvas. */ public void addSWTListener(EventListener listener) { if (listener instanceof ControlListener) { this.canvas.addControlListener((ControlListener) listener); } else if (listener instanceof DisposeListener) { this.canvas.addDisposeListener((DisposeListener) listener); // } // else if (listener instanceof DragDetectListener) { // this.canvas.addDragDetectListener((DragDetectListener) listener); } else if (listener instanceof FocusListener) { this.canvas.addFocusListener((FocusListener) listener); } else if (listener instanceof HelpListener) { this.canvas.addHelpListener((HelpListener) listener); } else if (listener instanceof KeyListener) { this.canvas.addKeyListener((KeyListener) listener); // } // else if (listener instanceof MenuDetectListener) { // this.canvas.addMenuDetectListener((MenuDetectListener) listener); } else if (listener instanceof MouseListener) { this.canvas.addMouseListener((MouseListener) listener); } else if (listener instanceof MouseMoveListener) { this.canvas.addMouseMoveListener((MouseMoveListener) listener); } else if (listener instanceof MouseTrackListener) { this.canvas.addMouseTrackListener((MouseTrackListener) listener); // } else if (listener instanceof MouseWheelListener) { // this.canvas.addMouseWheelListener((MouseWheelListener) listener); } else if (listener instanceof PaintListener) { this.canvas.addPaintListener((PaintListener) listener); } else if (listener instanceof TraverseListener) { this.canvas.addTraverseListener((TraverseListener) listener); } } /** * Does nothing - override if necessary. * * @param event the mouse event. */ public void mouseDoubleClick(MouseEvent event) { // do nothing, override if necessary } /** * Handles a mouse down event. * * @param event the event. */ public void mouseDown(MouseEvent event) { Rectangle scaledDataArea = getScreenDataArea(event.x, event.y); if (scaledDataArea == null) return; this.zoomPoint = getPointInRectangle(event.x, event.y, scaledDataArea); int x = (int) ((event.x - getClientArea().x) / this.scaleX); int y = (int) ((event.y - getClientArea().y) / this.scaleY); this.anchor = new Point2D.Double(x, y); this.chart.setNotify(true); // force a redraw this.canvas.redraw(); // new entity code ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } Object[] listeners = this.chartMouseListeners.getListeners( ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse down event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } } /** * Handles a mouse up event. * * @param event the event. */ public void mouseUp(MouseEvent event) { boolean hZoom, vZoom; if (this.zoomRectangle == null) { Rectangle screenDataArea = getScreenDataArea(event.x, event.y); if (screenDataArea != null) { this.zoomPoint = getPointInRectangle(event.x, event.y, screenDataArea); } if (this.popup != null && event.button == 3) { org.eclipse.swt.graphics.Point pt = this.canvas.toDisplay( event.x, event.y); displayPopupMenu(pt.x, pt.y); } } else { hZoom = false; vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } boolean zoomTrigger1 = hZoom && Math.abs(this.zoomRectangle.width) >= this.zoomTriggerDistance; boolean zoomTrigger2 = vZoom && Math.abs(this.zoomRectangle.height) >= this.zoomTriggerDistance; if (zoomTrigger1 || zoomTrigger2) { // if the box has been drawn backwards, restore the auto bounds if ((hZoom && (this.zoomRectangle.x + this.zoomRectangle.width < this.zoomPoint.x)) || (vZoom && (this.zoomRectangle.y + this.zoomRectangle.height < this.zoomPoint.y))) restoreAutoBounds(); else { zoom(this.zoomRectangle); } this.canvas.redraw(); } } this.zoomPoint = null; this.zoomRectangle = null; } /** * Handles a mouse move event. * * @param event the mouse event. */ public void mouseMove(MouseEvent event) { // handle axis trace if (this.horizontalAxisTrace || this.verticalAxisTrace) { this.horizontalTraceLineY = event.y; this.verticalTraceLineX = event.x; this.canvas.redraw(); } // handle tool tips in a simple way if (this.displayToolTips) { String s = getToolTipText(event); if (s == null && this.canvas.getToolTipText() != null || s != null && !s.equals(this.canvas.getToolTipText())) this.canvas.setToolTipText(s); } // handle zoom box boolean hZoom, vZoom; if (this.zoomPoint != null) { Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, this.zoomPoint.y); org.eclipse.swt.graphics.Point movingPoint = getPointInRectangle(event.x, event.y, scaledDataArea); if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... this.zoomRectangle = new Rectangle(this.zoomPoint.x, this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, movingPoint.y - this.zoomPoint.y); } else if (hZoom) { this.zoomRectangle = new Rectangle(this.zoomPoint.x, scaledDataArea.y, movingPoint.x - this.zoomPoint.x, scaledDataArea.height); } else if (vZoom) { int ymax = Math.max(movingPoint.y, scaledDataArea.y); this.zoomRectangle = new Rectangle( scaledDataArea.x, this.zoomPoint.y, scaledDataArea.width, ymax - this.zoomPoint.y); } this.canvas.redraw(); } // new entity code ChartEntity entity = null; int x = (int) ((event.x - getClientArea().x) / this.scaleX); int y = (int) ((event.y - getClientArea().y) / this.scaleY); if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } Object[] listeners = this.chartMouseListeners.getListeners( ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse move event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } } /** * Paints the control. * * @param e the paint event. */ public void paintControl(PaintEvent e) { // first determine the size of the chart rendering area... // TODO workout insets for SWT Rectangle available = getBounds(); // skip if chart is null if (this.chart == null) { this.canvas.drawBackground(e.gc, available.x, available.y, available.width, available.height); return; } SWTGraphics2D sg2 = new SWTGraphics2D(e.gc); // work out if scaling is required... boolean scale = false; int drawWidth = available.width; int drawHeight = available.height; if (drawWidth == 0.0 || drawHeight == 0.0) return; this.scaleX = 1.0; this.scaleY = 1.0; if (drawWidth < this.minimumDrawWidth) { this.scaleX = (double) drawWidth / this.minimumDrawWidth; drawWidth = this.minimumDrawWidth; scale = true; } else if (drawWidth > this.maximumDrawWidth) { this.scaleX = (double) drawWidth / this.maximumDrawWidth; drawWidth = this.maximumDrawWidth; scale = true; } if (drawHeight < this.minimumDrawHeight) { this.scaleY = (double) drawHeight / this.minimumDrawHeight; drawHeight = this.minimumDrawHeight; scale = true; } else if (drawHeight > this.maximumDrawHeight) { this.scaleY = (double) drawHeight / this.maximumDrawHeight; drawHeight = this.maximumDrawHeight; scale = true; } // are we using the chart buffer? if (this.useBuffer) { //SwtGraphics2D sg2 = new SwtGraphics2D(e.gc); this.chartBuffer = (org.eclipse.swt.graphics.Image) this.canvas.getData("double-buffer-image"); // do we need to fill the buffer? if (this.chartBuffer == null || this.chartBufferWidth != available.width || this.chartBufferHeight != available.height) { this.chartBufferWidth = available.width; this.chartBufferHeight = available.height; if (this.chartBuffer != null) { this.chartBuffer.dispose(); } this.chartBuffer = new org.eclipse.swt.graphics.Image( getDisplay(), this.chartBufferWidth, this.chartBufferHeight); this.refreshBuffer = true; } // do we need to redraw the buffer? if (this.refreshBuffer) { // Performs the actual drawing here ... GC gci = new GC(this.chartBuffer); // anti-aliasing if (this.chart.getAntiAlias()) { gci.setAntialias(SWT.ON); } if (this.chart.getTextAntiAlias() == RenderingHints.KEY_TEXT_ANTIALIASING) { gci.setTextAntialias(SWT.ON); } SWTGraphics2D sg2d = new SWTGraphics2D(gci); if (scale) { sg2d.scale(this.scaleX, this.scaleY); this.chart.draw(sg2d, new Rectangle2D.Double(0, 0, drawWidth, drawHeight), getAnchor(), this.info); } else { this.chart.draw(sg2d, new Rectangle2D.Double(0, 0, drawWidth, drawHeight), getAnchor(), this.info); } this.canvas.setData("double-buffer-image", this.chartBuffer); sg2d.dispose(); gci.dispose(); this.refreshBuffer = false; } // zap the buffer onto the canvas... sg2.drawImage(this.chartBuffer, 0, 0); } // or redrawing the chart every time... else { if (this.chart.getAntiAlias()) { e.gc.setAntialias(SWT.ON); } if (this.chart.getTextAntiAlias() == RenderingHints.KEY_TEXT_ANTIALIASING) { e.gc.setTextAntialias(SWT.ON); } this.chart.draw(sg2, new Rectangle2D.Double(0, 0, getBounds().width, getBounds().height), getAnchor(), this.info); } Rectangle area = getScreenDataArea(); // TODO see if we need to apply some line color and style to the // axis traces if (this.horizontalAxisTrace && area.x < this.verticalTraceLineX && area.x + area.width > this.verticalTraceLineX) { e.gc.drawLine(this.verticalTraceLineX, area.y, this.verticalTraceLineX, area.y + area.height); } if (this.verticalAxisTrace && area.y < this.horizontalTraceLineY && area.y + area.height > this.horizontalTraceLineY) { e.gc.drawLine(area.x, this.horizontalTraceLineY, area.x + area.width, this.horizontalTraceLineY); } this.verticalTraceLineX = 0; this.horizontalTraceLineY = 0; if (this.zoomRectangle != null) { e.gc.drawRectangle(this.zoomRectangle); } sg2.dispose(); } /** * Disposes the control. */ public void dispose() { if (this.chartBuffer != null) this.chartBuffer.dispose(); // de-register the composite as a listener for the chart. if (this.chart != null) { this.chart.removeChangeListener(this); this.chart.removeProgressListener(this); } super.dispose(); } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/swt/0000755000175000017500000000000011216245562024171 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/swt/SWTGraphics2D.java0000644000175000017500000012734611173030414027363 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * SWTGraphics2D.java * ------------------ * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): Cedric Chabanois (cchabanois AT no-log.org); * David Gilbert (for Object Refinery Limited); * Ronnie Duan (see bug report 2583891); * * Changes * ------- * 14-Jun-2006 : New class (HP); * 29-Jan-2007 : Fixed the fillRect method (HP); * 31-Jan-2007 : Moved the dummy JPanel to SWTUtils.java, * implemented the drawLine method (HP); * 07-Apr-2007 : Dispose some of the swt ressources, * thanks to silent for pointing this out (HP); * 23-May-2007 : Removed resource leaks by adding a resource pool (CC); * 15-Jun-2007 : Fixed compile error for JDK 1.4 (DG); * 22-Oct-2007 : Implemented clipping (HP); * 22-Oct-2007 : Implemented some AlphaComposite support (HP); * 23-Oct-2007 : Added mechanism for storing RenderingHints (which are * still ignored at this point) (DG); * 23-Oct-2007 : Implemented drawPolygon(), drawPolyline(), drawOval(), * fillOval(), drawArc() and fillArc() (DG); * 27-Nov-2007 : Implemented a couple of drawImage() methods (DG); * 18-Nov-2008 : Check for GradientPaint in setPaint() method (DG); * 27-Feb-2009 : Implemented fillPolygon() - see bug 2583891 (DG); * */ package org.jfree.experimental.swt; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Paint; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.Stroke; import java.awt.RenderingHints.Key; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.awt.image.ImageObserver; import java.awt.image.RenderedImage; import java.awt.image.renderable.RenderableImage; import java.text.AttributedCharacterIterator; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Path; import org.eclipse.swt.graphics.Resource; import org.eclipse.swt.graphics.Transform; /** * This is a class utility to draw Graphics2D stuff on a swt composite. * It is presently developed to use JFreeChart with the Standard * Widget Toolkit but may be of a wider use later. */ public class SWTGraphics2D extends Graphics2D { /** The swt graphic composite */ private GC gc; /** * The rendering hints. For now, these are not used, but at least the * basic mechanism is present. */ private RenderingHints hints; /** A reference to the compositing rule to apply. This is necessary * due to the poor compositing interface of the SWT toolkit. */ private java.awt.Composite composite; /** A HashMap to store the Swt color resources. */ private Map colorsPool = new HashMap(); /** A HashMap to store the Swt font resources. */ private Map fontsPool = new HashMap(); /** A HashMap to store the Swt transform resources. */ private Map transformsPool = new HashMap(); /** A List to store the Swt resources. */ private List resourcePool = new ArrayList(); /** * Creates a new instance. * * @param gc the graphics context. */ public SWTGraphics2D(GC gc) { super(); this.gc = gc; this.hints = new RenderingHints(null); this.composite = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f); } /** * Not implemented yet - see {@link Graphics#create()}. * * @return null. */ public Graphics create() { // TODO Auto-generated method stub return null; } /** * Not implemented yet - see {@link Graphics2D#getDeviceConfiguration()}. * * @return null. */ public GraphicsConfiguration getDeviceConfiguration() { // TODO Auto-generated method stub return null; } /** * Returns the current value for the specified hint key, or * null if no value is set. * * @param hintKey the hint key (null permitted). * * @return The hint value, or null. * * @see #setRenderingHint(RenderingHints.Key, Object) */ public Object getRenderingHint(Key hintKey) { return this.hints.get(hintKey); } /** * Sets the value for a rendering hint. For now, this graphics context * ignores all hints. * * @param hintKey the key (null not permitted). * @param hintValue the value (must be compatible with the specified key). * * @throws IllegalArgumentException if hintValue is not * compatible with the hintKey. * * @see #getRenderingHint(RenderingHints.Key) */ public void setRenderingHint(Key hintKey, Object hintValue) { this.hints.put(hintKey, hintValue); } /** * Returns a copy of the hints collection for this graphics context. * * @return A copy of the hints collection. */ public RenderingHints getRenderingHints() { return (RenderingHints) this.hints.clone(); } /** * Adds the hints in the specified map to the graphics context, replacing * any existing hints. For now, this graphics context ignores all hints. * * @param hints the hints (null not permitted). * * @see #setRenderingHints(Map) */ public void addRenderingHints(Map hints) { this.hints.putAll(hints); } /** * Replaces the existing hints with those contained in the specified * map. Note that, for now, this graphics context ignores all hints. * * @param hints the hints (null not permitted). * * @see #addRenderingHints(Map) */ public void setRenderingHints(Map hints) { if (hints == null) { throw new NullPointerException("Null 'hints' argument."); } this.hints = new RenderingHints(hints); } /** * Returns the current paint for this graphics context. * * @return The current paint. * * @see #setPaint(Paint) */ public Paint getPaint() { // TODO: it might be a good idea to keep a reference to the color // specified in setPaint() or setColor(), rather than creating a // new object every time getPaint() is called. return SWTUtils.toAwtColor(this.gc.getForeground()); } /** * Sets the paint for this graphics context. For now, this graphics * context only supports instances of {@link Color} or * {@link GradientPaint} (in the latter case there is no real gradient * support, the paint used is the Color returned by * getColor1()). * * @param paint the paint (null not permitted). * * @see #getPaint() * @see #setColor(Color) */ public void setPaint(Paint paint) { if (paint instanceof Color) { setColor((Color) paint); } else if (paint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) paint; setColor(gp.getColor1()); } else { throw new RuntimeException("Can only handle 'Color' at present."); } } /** * Returns the current color for this graphics context. * * @return The current color. * * @see #setColor(Color) */ public Color getColor() { // TODO: it might be a good idea to keep a reference to the color // specified in setPaint() or setColor(), rather than creating a // new object every time getPaint() is called. return SWTUtils.toAwtColor(this.gc.getForeground()); } /** * Sets the current color for this graphics context. * * @param color the color. * * @see #getColor() */ public void setColor(Color color) { org.eclipse.swt.graphics.Color swtColor = getSwtColorFromPool(color); this.gc.setForeground(swtColor); // handle transparency and compositing. if (this.composite instanceof AlphaComposite) { AlphaComposite acomp = (AlphaComposite) this.composite; switch (acomp.getRule()) { case AlphaComposite.SRC_OVER: this.gc.setAlpha((int) (color.getAlpha() * acomp.getAlpha())); break; default: this.gc.setAlpha(color.getAlpha()); break; } } } /** * Sets the background colour. * * @param color the colour. */ public void setBackground(Color color) { org.eclipse.swt.graphics.Color swtColor = getSwtColorFromPool(color); this.gc.setBackground(swtColor); } /** * Returns the background colour. * * @return The background colour. */ public Color getBackground() { return SWTUtils.toAwtColor(this.gc.getBackground()); } /** * Not implemented - see {@link Graphics#setPaintMode()}. */ public void setPaintMode() { // TODO Auto-generated method stub } /** * Not implemented - see {@link Graphics#setXORMode(Color)}. * * @param color the colour. */ public void setXORMode(Color color) { // TODO Auto-generated method stub } /** * Returns the current composite. * * @return The current composite. * * @see #setComposite(Composite) */ public Composite getComposite() { return this.composite; } /** * Sets the current composite. This implementation currently supports * only the {@link AlphaComposite} class. * * @param comp the composite. */ public void setComposite(Composite comp) { this.composite = comp; if (comp instanceof AlphaComposite) { AlphaComposite acomp = (AlphaComposite) comp; int alpha = (int) (acomp.getAlpha() * 0xFF); this.gc.setAlpha(alpha); } else { System.out.println("warning, can only handle alpha composite at the moment."); } } /** * Returns the current stroke for this graphics context. * * @return The current stroke. * * @see #setStroke(Stroke) */ public Stroke getStroke() { return new BasicStroke(this.gc.getLineWidth(), this.gc.getLineCap(), this.gc.getLineJoin()); } /** * Sets the stroke for this graphics context. For now, this implementation * only recognises the {@link BasicStroke} class. * * @param stroke the stroke (null not permitted). * * @see #getStroke() */ public void setStroke(Stroke stroke) { if (stroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke) stroke; // linewidth this.gc.setLineWidth((int) bs.getLineWidth()); // line join switch (bs.getLineJoin()) { case BasicStroke.JOIN_BEVEL : this.gc.setLineJoin(SWT.JOIN_BEVEL); break; case BasicStroke.JOIN_MITER : this.gc.setLineJoin(SWT.JOIN_MITER); break; case BasicStroke.JOIN_ROUND : this.gc.setLineJoin(SWT.JOIN_ROUND); break; } // line cap switch (bs.getEndCap()) { case BasicStroke.CAP_BUTT : this.gc.setLineCap(SWT.CAP_FLAT); break; case BasicStroke.CAP_ROUND : this.gc.setLineCap(SWT.CAP_ROUND); break; case BasicStroke.CAP_SQUARE : this.gc.setLineCap(SWT.CAP_SQUARE); break; } // set the line style to solid by default this.gc.setLineStyle(SWT.LINE_SOLID); // apply dash style if any float[] dashes = bs.getDashArray(); if (dashes != null) { int[] swtDashes = new int[dashes.length]; for (int i = 0; i < swtDashes.length; i++) { swtDashes[i] = (int) dashes[i]; } this.gc.setLineDash(swtDashes); } } else { throw new RuntimeException( "Can only handle 'Basic Stroke' at present."); } } /** * Applies the specified clip. * * @param s the shape for the clip. */ public void clip(Shape s) { Path path = toSwtPath(s); this.gc.setClipping(path); path.dispose(); } /** * Returns the clip bounds. * * @return The clip bounds. */ public Rectangle getClipBounds() { org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping(); return new Rectangle(clip.x, clip.y, clip.width, clip.height); } /** * Sets the clipping to the intersection of the current clip region and * the specified rectangle. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the width. * @param height the height. */ public void clipRect(int x, int y, int width, int height) { org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping(); clip.intersects(x, y, width, height); this.gc.setClipping(clip); } /** * Returns the current clip. * * @return The current clip. */ public Shape getClip() { return SWTUtils.toAwtRectangle(this.gc.getClipping()); } /** * Sets the clip region. * * @param clip the clip. */ public void setClip(Shape clip) { if (clip == null) { return; } Path clipPath = toSwtPath(clip); this.gc.setClipping(clipPath); clipPath.dispose(); } /** * Sets the clip region to the specified rectangle. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the width. * @param height the height. */ public void setClip(int x, int y, int width, int height) { this.gc.setClipping(x, y, width, height); } /** * Returns the current transform. * * @return The current transform. */ public AffineTransform getTransform() { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); AffineTransform awtTransform = toAwtTransform(swtTransform); swtTransform.dispose(); return awtTransform; } /** * Sets the current transform. * * @param t the transform. */ public void setTransform(AffineTransform t) { Transform transform = getSwtTransformFromPool(t); this.gc.setTransform(transform); } /** * Concatenates the specified transform to the existing transform. * * @param t the transform. */ public void transform(AffineTransform t) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.multiply(getSwtTransformFromPool(t)); this.gc.setTransform(swtTransform); swtTransform.dispose(); } /** * Applies a translation. * * @param x the translation along the x-axis. * @param y the translation along the y-axis. */ public void translate(int x, int y) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.translate(x, y); this.gc.setTransform(swtTransform); swtTransform.dispose(); } /** * Applies a translation. * * @param tx the translation along the x-axis. * @param ty the translation along the y-axis. */ public void translate(double tx, double ty) { translate((int) tx, (int) ty); } /** * Applies a rotation transform. * * @param theta the angle of rotation. */ public void rotate(double theta) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.rotate((float) (theta * 180 / Math.PI)); this.gc.setTransform(swtTransform); swtTransform.dispose(); } /** * Not implemented - see {@link Graphics2D#rotate(double, double, double)}. * * @see java.awt.Graphics2D#rotate(double, double, double) */ public void rotate(double theta, double x, double y) { // TODO Auto-generated method stub } /** * Applies a scale transform. * * @param scaleX the scale factor along the x-axis. * @param scaleY the scale factor along the y-axis. */ public void scale(double scaleX, double scaleY) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); swtTransform.scale((float) scaleX, (float) scaleY); this.gc.setTransform(swtTransform); swtTransform.dispose(); } /** * Applies a shear transform. * * @param shearX the x-factor. * @param shearY the y-factor. */ public void shear(double shearX, double shearY) { Transform swtTransform = new Transform(this.gc.getDevice()); this.gc.getTransform(swtTransform); Transform shear = new Transform(this.gc.getDevice(), 1f, (float) shearX, (float) shearY, 1f, 0, 0); swtTransform.multiply(shear); this.gc.setTransform(swtTransform); swtTransform.dispose(); } /** * Draws the outline of the specified shape using the current stroke and * paint settings. * * @param shape the shape (null not permitted). * * @see #getPaint() * @see #getStroke() * @see #fill(Shape) */ public void draw(Shape shape) { Path path = toSwtPath(shape); this.gc.drawPath(path); path.dispose(); } /** * Draws a line from (x1, y1) to (x2, y2) using the current stroke * and paint settings. * * @param x1 the x-coordinate for the starting point. * @param y1 the y-coordinate for the starting point. * @param x2 the x-coordinate for the ending point. * @param y2 the y-coordinate for the ending point. * * @see #draw(Shape) */ public void drawLine(int x1, int y1, int x2, int y2) { this.gc.drawLine(x1, y1, x2, y2); } /** * Draws the outline of the polygon specified by the given points, using * the current paint and stroke settings. * * @param xPoints the x-coordinates. * @param yPoints the y-coordinates. * @param npoints the number of points in the polygon. * * @see #draw(Shape) */ public void drawPolygon(int [] xPoints, int [] yPoints, int npoints) { drawPolyline(xPoints, yPoints, npoints); if (npoints > 1) { this.gc.drawLine(xPoints[npoints - 1], yPoints[npoints - 1], xPoints[0], yPoints[0]); } } /** * Draws a sequence of connected lines specified by the given points, using * the current paint and stroke settings. * * @param xPoints the x-coordinates. * @param yPoints the y-coordinates. * @param npoints the number of points in the polygon. * * @see #draw(Shape) */ public void drawPolyline(int [] xPoints, int [] yPoints, int npoints) { if (npoints > 1) { int x0 = xPoints[0]; int y0 = yPoints[0]; int x1 = 0, y1 = 0; for (int i = 1; i < npoints; i++) { x1 = xPoints[i]; y1 = yPoints[i]; this.gc.drawLine(x0, y0, x1, y1); x0 = x1; y0 = y1; } } } /** * Draws an oval that fits within the specified rectangular region. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the frame width. * @param height the frame height. * * @see #fillOval(int, int, int, int) * @see #draw(Shape) */ public void drawOval(int x, int y, int width, int height) { this.gc.drawOval(x, y, width - 1, height - 1); } /** * Draws an arc that is part of an ellipse that fits within the specified * framing rectangle. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the frame width. * @param height the frame height. * @param arcStart the arc starting point, in degrees. * @param arcAngle the extent of the arc. * * @see #fillArc(int, int, int, int, int, int) */ public void drawArc(int x, int y, int width, int height, int arcStart, int arcAngle) { this.gc.drawArc(x, y, width - 1, height - 1, arcStart, arcAngle); } /** * Draws a rectangle with rounded corners that fits within the specified * framing rectangle. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the frame width. * @param height the frame height. * @param arcWidth the width of the arc defining the roundedness of the * rectangle's corners. * @param arcHeight the height of the arc defining the roundedness of the * rectangle's corners. * * @see #fillRoundRect(int, int, int, int, int, int) */ public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { this.gc.drawRoundRectangle(x, y, width - 1, height - 1, arcWidth, arcHeight); } /** * Fills the specified shape using the current paint. * * @param shape the shape (null not permitted). * * @see #getPaint() * @see #draw(Shape) */ public void fill(Shape shape) { Path path = toSwtPath(shape); // Note that for consistency with the AWT implementation, it is // necessary to switch temporarily the foreground and background // colours switchColors(); this.gc.fillPath(path); switchColors(); path.dispose(); } /** * Fill a rectangle area on the swt graphic composite. * The fillRectangle method of the GC * class uses the background color so we must switch colors. * @see java.awt.Graphics#fillRect(int, int, int, int) */ public void fillRect(int x, int y, int width, int height) { this.switchColors(); this.gc.fillRectangle(x, y, width, height); this.switchColors(); } /** * Fills the specified rectangle with the current background colour. * * @param x the x-coordinate for the rectangle. * @param y the y-coordinate for the rectangle. * @param width the width. * @param height the height. * * @see #fillRect(int, int, int, int) */ public void clearRect(int x, int y, int width, int height) { Paint saved = getPaint(); setPaint(getBackground()); fillRect(x, y, width, height); setPaint(saved); } /** * Fills the specified polygon. * * @param xPoints the x-coordinates. * @param yPoints the y-coordinates. * @param npoints the number of points. */ public void fillPolygon(int[] xPoints, int[] yPoints, int npoints) { int[] pointArray = new int[npoints * 2]; for (int i = 0; i < npoints; i++) { pointArray[2 * i] = xPoints[i]; pointArray[2 * i + 1] = yPoints[i]; } switchColors(); this.gc.fillPolygon(pointArray); switchColors(); } /** * Draws a rectangle with rounded corners that fits within the specified * framing rectangle. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the frame width. * @param height the frame height. * @param arcWidth the width of the arc defining the roundedness of the * rectangle's corners. * @param arcHeight the height of the arc defining the roundedness of the * rectangle's corners. * * @see #drawRoundRect(int, int, int, int, int, int) */ public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { switchColors(); this.gc.fillRoundRectangle(x, y, width - 1, height - 1, arcWidth, arcHeight); switchColors(); } /** * Fills an oval that fits within the specified rectangular region. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the frame width. * @param height the frame height. * * @see #drawOval(int, int, int, int) * @see #fill(Shape) */ public void fillOval(int x, int y, int width, int height) { switchColors(); this.gc.fillOval(x, y, width - 1, height - 1); switchColors(); } /** * Fills an arc that is part of an ellipse that fits within the specified * framing rectangle. * * @param x the x-coordinate. * @param y the y-coordinate. * @param width the frame width. * @param height the frame height. * @param arcStart the arc starting point, in degrees. * @param arcAngle the extent of the arc. * * @see #drawArc(int, int, int, int, int, int) */ public void fillArc(int x, int y, int width, int height, int arcStart, int arcAngle) { switchColors(); this.gc.fillArc(x, y, width - 1, height - 1, arcStart, arcAngle); switchColors(); } /** * Returns the font in form of an awt font created * with the parameters of the font of the swt graphic * composite. * @see java.awt.Graphics#getFont() */ public Font getFont() { // retrieve the swt font description in an os indept way FontData[] fontData = this.gc.getFont().getFontData(); // create a new awt font with the appropiate data return SWTUtils.toAwtFont(this.gc.getDevice(), fontData[0], true); } /** * Set the font swt graphic composite from the specified * awt font. Be careful that the newly created swt font * must be disposed separately. * @see java.awt.Graphics#setFont(java.awt.Font) */ public void setFont(Font font) { org.eclipse.swt.graphics.Font swtFont = getSwtFontFromPool(font); this.gc.setFont(swtFont); } /** * Returns the font metrics. * * @param font the font. * * @return The font metrics. */ public FontMetrics getFontMetrics(Font font) { return SWTUtils.DUMMY_PANEL.getFontMetrics(font); } /** * Returns the font render context. * * @return The font render context. */ public FontRenderContext getFontRenderContext() { FontRenderContext fontRenderContext = new FontRenderContext( new AffineTransform(), true, true); return fontRenderContext; } /** * Not implemented - see {@link Graphics2D#drawGlyphVector(GlyphVector, * float, float)}. */ public void drawGlyphVector(GlyphVector g, float x, float y) { // TODO Auto-generated method stub } /** * Draws a string on the receiver. note that * to be consistent with the awt method, * the y has to be modified with the ascent of the font. * * @see java.awt.Graphics#drawString(java.lang.String, int, int) */ public void drawString(String text, int x, int y) { float fm = this.gc.getFontMetrics().getAscent(); this.gc.drawString(text, x, (int) (y - fm), true); } /** * Draws a string at the specified position. * * @param text the string. * @param x the x-coordinate. * @param y the y-coordinate. */ public void drawString(String text, float x, float y) { float fm = this.gc.getFontMetrics().getAscent(); this.gc.drawString(text, (int) x, (int) (y - fm), true); } /** * Draws a string at the specified position. * * @param iterator the string. * @param x the x-coordinate. * @param y the y-coordinate. */ public void drawString(AttributedCharacterIterator iterator, int x, int y) { // TODO Auto-generated method stub } /** * Draws a string at the specified position. * * @param iterator the string. * @param x the x-coordinate. * @param y the y-coordinate. */ public void drawString(AttributedCharacterIterator iterator, float x, float y) { // TODO Auto-generated method stub } /** * Not implemented - see {@link Graphics2D#hit(Rectangle, Shape, boolean)}. * * @return false. */ public boolean hit(Rectangle rect, Shape text, boolean onStroke) { // TODO Auto-generated method stub return false; } /** * Not implemented - see {@link Graphics#copyArea(int, int, int, int, int, * int)}. */ public void copyArea(int x, int y, int width, int height, int dx, int dy) { // TODO Auto-generated method stub } /** * Not implemented - see {@link Graphics2D#drawImage(Image, * AffineTransform, ImageObserver)}. * * @param image the image. * @param xform the transform. * @param obs an image observer. * * @return A boolean. */ public boolean drawImage(Image image, AffineTransform xform, ImageObserver obs) { // TODO Auto-generated method stub return false; } /** * Draws an image. * * @param image the image. * @param op the image operation. * @param x the x-coordinate. * @param y the y-coordinate. */ public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y) { org.eclipse.swt.graphics.Image im = new org.eclipse.swt.graphics.Image( this.gc.getDevice(), SWTUtils.convertToSWT(image)); this.gc.drawImage(im, x, y); im.dispose(); } /** * Draws an SWT image with the top left corner of the image aligned to the * point (x, y). * * @param image the image. * @param x the x-coordinate. * @param y the y-coordinate. */ public void drawImage(org.eclipse.swt.graphics.Image image, int x, int y) { this.gc.drawImage(image, x, y); } /** * Not implemented - see {@link Graphics2D#drawRenderedImage(RenderedImage, * AffineTransform)}. * * @param image the image. * @param xform the transform. */ public void drawRenderedImage(RenderedImage image, AffineTransform xform) { // TODO Auto-generated method stub } /** * Not implemented - see {@link Graphics2D#drawRenderableImage( * RenderableImage, AffineTransform)}. * * @param image the image. * @param xform the transform. */ public void drawRenderableImage(RenderableImage image, AffineTransform xform) { // TODO Auto-generated method stub } /** * Draws an image with the top left corner aligned to the point (x, y). * * @param image the image. * @param x the x-coordinate. * @param y the y-coordinate. * @param observer ignored here. * * @return true if the image has been drawn. */ public boolean drawImage(Image image, int x, int y, ImageObserver observer) { ImageData data = SWTUtils.convertAWTImageToSWT(image); if (data == null) { return false; } org.eclipse.swt.graphics.Image im = new org.eclipse.swt.graphics.Image( this.gc.getDevice(), data); this.gc.drawImage(im, x, y); im.dispose(); return true; } /** * Draws an image with the top left corner aligned to the point (x, y), * and scaled to the specified width and height. * * @param image the image. * @param x the x-coordinate. * @param y the y-coordinate. * @param width the width for the rendered image. * @param height the height for the rendered image. * @param observer ignored here. * * @return true if the image has been drawn. */ public boolean drawImage(Image image, int x, int y, int width, int height, ImageObserver observer) { ImageData data = SWTUtils.convertAWTImageToSWT(image); if (data == null) { return false; } org.eclipse.swt.graphics.Image im = new org.eclipse.swt.graphics.Image( this.gc.getDevice(), data); org.eclipse.swt.graphics.Rectangle bounds = im.getBounds(); this.gc.drawImage(im, 0, 0, bounds.width, bounds.height, x, y, width, height); im.dispose(); return true; } /** * Draws an image. * * @param image (null not permitted). * @param x the x-coordinate. * @param y the y-coordinate. * @param bgcolor the background color. * @param observer an image observer. * * @return A boolean. */ public boolean drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer) { if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return false; } Paint savedPaint = getPaint(); fill(new Rectangle2D.Double(x, y, w, h)); setPaint(savedPaint); return drawImage(image, x, y, observer); } /** * Draws an image. * * @param image the image (null not permitted). * @param x the x-coordinate. * @param y the y-coordinate. * @param width the width. * @param height the height. * @param bgcolor the background colour. * @param observer an image observer. * * @return A boolean. */ public boolean drawImage(Image image, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return false; } Paint savedPaint = getPaint(); fill(new Rectangle2D.Double(x, y, w, h)); setPaint(savedPaint); return drawImage(image, x, y, width, height, observer); } /** * Not implemented - see {@link Graphics#drawImage(Image, int, int, int, * int, int, int, int, int, ImageObserver)}. * * @param image the image. * @param dx1 * @param dy1 * @param dx2 * @param dy2 * @param sx1 * @param sy1 * @param sx2 * @param sy2 * @param observer */ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { // TODO Auto-generated method stub return false; } /** * Not implemented - see {@link Graphics#drawImage(Image, int, int, int, * int, int, int, int, int, Color, ImageObserver)}. * * @param image the image. * @param dx1 * @param dy1 * @param dx2 * @param dy2 * @param sx1 * @param sy1 * @param sx2 * @param sy2 * @param bgcolor * @param observer */ public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) { // TODO Auto-generated method stub return false; } /** * Releases resources held by this instance (but note that the caller * must dispose of the 'GC' passed to the constructor). * * @see java.awt.Graphics#dispose() */ public void dispose() { // we dispose resources we own but user must dispose gc disposeResourcePool(); } /** * Add given swt resource to the resource pool. All resources added * to the resource pool will be disposed when {@link #dispose()} is called. * * @param resource the resource to add to the pool. * @return the swt Resource just added. */ private Resource addToResourcePool(Resource resource) { this.resourcePool.add(resource); return resource; } /** * Dispose the resource pool. */ private void disposeResourcePool() { for (Iterator it = this.resourcePool.iterator(); it.hasNext();) { Resource resource = (Resource) it.next(); resource.dispose(); } this.fontsPool.clear(); this.colorsPool.clear(); this.transformsPool.clear(); this.resourcePool.clear(); } /** * Internal method to convert a AWT font object into * a SWT font resource. If a corresponding SWT font * instance is already in the pool, it will be used * instead of creating a new one. This is used in * {@link #setFont()} for instance. * * @param font The AWT font to convert. * @return The SWT font instance. */ private org.eclipse.swt.graphics.Font getSwtFontFromPool(Font font) { org.eclipse.swt.graphics.Font swtFont = (org.eclipse.swt.graphics.Font) this.fontsPool.get(font); if (swtFont == null) { swtFont = new org.eclipse.swt.graphics.Font(this.gc.getDevice(), SWTUtils.toSwtFontData(this.gc.getDevice(), font, true)); addToResourcePool(swtFont); this.fontsPool.put(font, swtFont); } return swtFont; } /** * Internal method to convert a AWT color object into * a SWT color resource. If a corresponding SWT color * instance is already in the pool, it will be used * instead of creating a new one. This is used in * {@link #setColor()} for instance. * * @param awtColor The AWT color to convert. * @return A SWT color instance. */ private org.eclipse.swt.graphics.Color getSwtColorFromPool(Color awtColor) { org.eclipse.swt.graphics.Color swtColor = (org.eclipse.swt.graphics.Color) // we can't use the following valueOf() method, because it // won't compile with JDK1.4 // this.colorsPool.get(Integer.valueOf(awtColor.getRGB())); this.colorsPool.get(new Integer(awtColor.getRGB())); if (swtColor == null) { swtColor = SWTUtils.toSwtColor(this.gc.getDevice(), awtColor); addToResourcePool(swtColor); // see comment above //this.colorsPool.put(Integer.valueOf(awtColor.getRGB()), swtColor); this.colorsPool.put(new Integer(awtColor.getRGB()), swtColor); } return swtColor; } /** * Internal method to convert a AWT transform object into * a SWT transform resource. If a corresponding SWT transform * instance is already in the pool, it will be used * instead of creating a new one. This is used in * {@link #setTransform()} for instance. * * @param awtTransform The AWT transform to convert. * @return A SWT transform instance. */ private Transform getSwtTransformFromPool(AffineTransform awtTransform) { Transform t = (Transform) this.transformsPool.get(awtTransform); if (t == null) { t = new Transform(this.gc.getDevice()); double[] matrix = new double[6]; awtTransform.getMatrix(matrix); t.setElements((float) matrix[0], (float) matrix[1], (float) matrix[2], (float) matrix[3], (float) matrix[4], (float) matrix[5]); addToResourcePool(t); this.transformsPool.put(awtTransform, t); } return t; } /** * Perform a switch between foreground and background * color of gc. This is needed for consistency with * the awt behaviour, and is required notably for the * filling methods. */ private void switchColors() { org.eclipse.swt.graphics.Color bg = this.gc.getBackground(); org.eclipse.swt.graphics.Color fg = this.gc.getForeground(); this.gc.setBackground(fg); this.gc.setForeground(bg); } /** * Converts an AWT Shape into a SWT Path. * * @param shape the shape (null not permitted). * * @return The path. */ private Path toSwtPath(Shape shape) { int type; float[] coords = new float[6]; Path path = new Path(this.gc.getDevice()); PathIterator pit = shape.getPathIterator(null); while (!pit.isDone()) { type = pit.currentSegment(coords); switch (type) { case (PathIterator.SEG_MOVETO): path.moveTo(coords[0], coords[1]); break; case (PathIterator.SEG_LINETO): path.lineTo(coords[0], coords[1]); break; case (PathIterator.SEG_QUADTO): path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case (PathIterator.SEG_CUBICTO): path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case (PathIterator.SEG_CLOSE): path.close(); break; default: break; } pit.next(); } return path; } /** * Converts an SWT transform into the equivalent AWT transform. * * @param swtTransform the SWT transform. * * @return The AWT transform. */ private AffineTransform toAwtTransform(Transform swtTransform) { float[] elements = new float[6]; swtTransform.getElements(elements); AffineTransform awtTransform = new AffineTransform(elements); return awtTransform; } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/swt/SWTPaintCanvas.java0000644000175000017500000000737611173030414027644 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * SwtPaintCanvas.java * ------------------- * (C) Copyright 2000-2007, by Object Refinery Limited. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 04-Aug-2006 : New class (HP); * 25-Oct-2007 : Fixed Eclipse warnings (DG); * */ package org.jfree.experimental.swt; import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; /** * A paint canvas. */ public class SWTPaintCanvas extends Canvas { private Color myColor; /** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param color the color. */ public SWTPaintCanvas(Composite parent, int style, Color color) { this(parent, style); setColor(color); } /** * Creates a new instance. * * @param parent the parent. * @param style the style. */ public SWTPaintCanvas(Composite parent, int style) { super(parent, style); addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setForeground(e.gc.getDevice().getSystemColor( SWT.COLOR_BLACK)); e.gc.setBackground(SWTPaintCanvas.this.myColor); e.gc.fillRectangle(getClientArea()); e.gc.drawRectangle(getClientArea().x, getClientArea().y, getClientArea().width - 1, getClientArea().height - 1); } }); } /** * Sets the color. * * @param color the color. */ public void setColor(Color color) { if (this.myColor != null) { this.myColor.dispose(); } //this.myColor = new Color(getDisplay(), color.getRGB()); this.myColor = color; } /** * Returns the color. * * @return The color. */ public Color getColor() { return this.myColor; } /** * Overridden to do nothing. * * @param c the color. */ public void setBackground(Color c) { return; } /** * Overridden to do nothing. * * @param c the color. */ public void setForeground(Color c) { return; } /** * Frees resources. */ public void dispose() { this.myColor.dispose(); } } libjfreechart-java-1.0.13.orig/swt/org/jfree/experimental/swt/SWTUtils.java0000644000175000017500000004370411173030414026530 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * SWTUtils.java * ------------- * (C) Copyright 2006, 2007, by Henry Proudhon and Contributors. * * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s): Rainer Blessing; * David Gilbert (david.gilbert@object-refinery.com); * Christoph Beck. * * Changes * ------- * 01-Aug-2006 : New class (HP); * 16-Jan-2007 : Use FontData.getHeight() instead of direct field access (RB); * 31-Jan-2007 : Moved the dummy JPanel from SWTGraphics2D.java, * added a new convert method for mouse events (HP); * 12-Jul-2007 : Improved the mouse event conversion with buttons * and modifiers handling, patch sent by Christoph Beck (HP); * 27-Aug-2007 : Modified toAwtMouseEvent signature (HP); * 27-Nov-2007 : Moved convertToSWT() method from SWTGraphics2D and added * convertAWTImageToSWT() (DG); * 01-Jul-2008 : Simplify AWT/SWT font style conversions (HP); * */ package org.jfree.experimental.swt; import java.awt.Graphics; import java.awt.Image; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DirectColorModel; import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; import javax.swing.JPanel; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; /** * Utility class gathering some useful and general method. * Mainly convert forth and back graphical stuff between * awt and swt. */ public class SWTUtils { private final static String Az = "ABCpqr"; /** A dummy JPanel used to provide font metrics. */ protected static final JPanel DUMMY_PANEL = new JPanel(); /** * Create a FontData object which encapsulate * the essential data to create a swt font. The data is taken * from the provided awt Font. *

      Generally speaking, given a font size, the returned swt font * will display differently on the screen than the awt one. * Because the SWT toolkit use native graphical resources whenever * it is possible, this fact is platform dependent. To address * this issue, it is possible to enforce the method to return * a font with the same size (or at least as close as possible) * as the awt one. *

      When the object is no more used, the user must explicitly * call the dispose method on the returned font to free the * operating system resources (the garbage collector won't do it). * * @param device The swt device to draw on (display or gc device). * @param font The awt font from which to get the data. * @param ensureSameSize A boolean used to enforce the same size * (in pixels) between the awt font and the newly created swt font. * @return a FontData object. */ public static FontData toSwtFontData(Device device, java.awt.Font font, boolean ensureSameSize) { FontData fontData = new FontData(); fontData.setName(font.getFamily()); // SWT and AWT share the same style constants. fontData.setStyle(font.getStyle()); // convert the font size (in pt for awt) to height in pixels for swt int height = (int) Math.round(font.getSize() * 72.0 / device.getDPI().y); fontData.setHeight(height); // hack to ensure the newly created swt fonts will be rendered with the // same height as the awt one if (ensureSameSize) { GC tmpGC = new GC(device); Font tmpFont = new Font(device, fontData); tmpGC.setFont(tmpFont); if (tmpGC.textExtent(Az).x > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { while (tmpGC.textExtent(Az).x > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { tmpFont.dispose(); height--; fontData.setHeight(height); tmpFont = new Font(device, fontData); tmpGC.setFont(tmpFont); } } else if (tmpGC.textExtent(Az).x < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { while (tmpGC.textExtent(Az).x < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { tmpFont.dispose(); height++; fontData.setHeight(height); tmpFont = new Font(device, fontData); tmpGC.setFont(tmpFont); } } tmpFont.dispose(); tmpGC.dispose(); } return fontData; } /** * Create an awt font by converting as much information * as possible from the provided swt FontData. *

      Generally speaking, given a font size, an swt font will * display differently on the screen than the corresponding awt * one. Because the SWT toolkit use native graphical ressources whenever * it is possible, this fact is platform dependent. To address * this issue, it is possible to enforce the method to return * an awt font with the same height as the swt one. * * @param device The swt device being drawn on (display or gc device). * @param fontData The swt font to convert. * @param ensureSameSize A boolean used to enforce the same size * (in pixels) between the swt font and the newly created awt font. * @return An awt font converted from the provided swt font. */ public static java.awt.Font toAwtFont(Device device, FontData fontData, boolean ensureSameSize) { int height = (int) Math.round(fontData.getHeight() * device.getDPI().y / 72.0); // hack to ensure the newly created awt fonts will be rendered with the // same height as the swt one if (ensureSameSize) { GC tmpGC = new GC(device); Font tmpFont = new Font(device, fontData); tmpGC.setFont(tmpFont); JPanel DUMMY_PANEL = new JPanel(); java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { height--; tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } } else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { height++; tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } } tmpFont.dispose(); tmpGC.dispose(); } return new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } /** * Create an awt font by converting as much information * as possible from the provided swt Font. * * @param device The swt device to draw on (display or gc device). * @param font The swt font to convert. * @return An awt font converted from the provided swt font. */ public static java.awt.Font toAwtFont(Device device, Font font) { FontData fontData = font.getFontData()[0]; return toAwtFont(device, fontData, true); } /** * Creates an awt color instance to match the rgb values * of the specified swt color. * * @param color The swt color to match. * @return an awt color abject. */ public static java.awt.Color toAwtColor(Color color) { return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue()); } /** * Creates a swt color instance to match the rgb values * of the specified awt paint. For now, this method test * if the paint is a color and then return the adequate * swt color. Otherwise plain black is assumed. * * @param device The swt device to draw on (display or gc device). * @param paint The awt color to match. * @return a swt color object. */ public static Color toSwtColor(Device device, java.awt.Paint paint) { java.awt.Color color; if (paint instanceof java.awt.Color) { color = (java.awt.Color) paint; } else { try { throw new Exception("only color is supported at present... " + "setting paint to uniform black color"); } catch (Exception e) { e.printStackTrace(); color = new java.awt.Color(0, 0, 0); } } return new org.eclipse.swt.graphics.Color(device, color.getRed(), color.getGreen(), color.getBlue()); } /** * Creates a swt color instance to match the rgb values * of the specified awt color. alpha channel is not supported. * Note that the dispose method will need to be called on the * returned object. * * @param device The swt device to draw on (display or gc device). * @param color The awt color to match. * @return a swt color object. */ public static Color toSwtColor(Device device, java.awt.Color color) { return new org.eclipse.swt.graphics.Color(device, color.getRed(), color.getGreen(), color.getBlue()); } /** * Transform an awt Rectangle2d instance into a swt one. * The coordinates are rounded to integer for the swt object. * @param rect2d The awt rectangle to map. * @return an swt Rectangle object. */ public static Rectangle toSwtRectangle(Rectangle2D rect2d) { return new Rectangle( (int) Math.round(rect2d.getMinX()), (int) Math.round(rect2d.getMinY()), (int) Math.round(rect2d.getWidth()), (int) Math.round(rect2d.getHeight())); } /** * Transform a swt Rectangle instance into an awt one. * @param rect the swt Rectangle * @return a Rectangle2D.Double instance with * the eappropriate location and size. */ public static Rectangle2D toAwtRectangle(Rectangle rect) { Rectangle2D rect2d = new Rectangle2D.Double(); rect2d.setRect(rect.x, rect.y, rect.width, rect.height); return rect2d; } /** * Returns an AWT point with the same coordinates as the specified * SWT point. * * @param p the SWT point (null not permitted). * * @return An AWT point with the same coordinates as p. * * @see #toSwtPoint(java.awt.Point) */ public static Point2D toAwtPoint(Point p) { return new java.awt.Point(p.x, p.y); } /** * Returns an SWT point with the same coordinates as the specified * AWT point. * * @param p the AWT point (null not permitted). * * @return An SWT point with the same coordinates as p. * * @see #toAwtPoint(Point) */ public static Point toSwtPoint(java.awt.Point p) { return new Point(p.x, p.y); } /** * Returns an SWT point with the same coordinates as the specified AWT * point (rounded to integer values). * * @param p the AWT point (null not permitted). * * @return An SWT point with the same coordinates as p. * * @see #toAwtPoint(Point) */ public static Point toSwtPoint(java.awt.geom.Point2D p) { return new Point((int) Math.round(p.getX()), (int) Math.round(p.getY())); } /** * Creates an AWT MouseEvent from a swt event. * This method helps passing SWT mouse event to awt components. * @param event The swt event. * @return A AWT mouse event based on the given SWT event. */ public static MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event) { int button = MouseEvent.NOBUTTON; switch (event.button) { case 1: button = MouseEvent.BUTTON1; break; case 2: button = MouseEvent.BUTTON2; break; case 3: button = MouseEvent.BUTTON3; break; } int modifiers = 0; if ((event.stateMask & SWT.CTRL) != 0) { modifiers |= InputEvent.CTRL_DOWN_MASK; } if ((event.stateMask & SWT.SHIFT) != 0) { modifiers |= InputEvent.SHIFT_DOWN_MASK; } if ((event.stateMask & SWT.ALT) != 0) { modifiers |= InputEvent.ALT_DOWN_MASK; } MouseEvent awtMouseEvent = new MouseEvent(DUMMY_PANEL, event.hashCode(), event.time, modifiers, event.x, event.y, 1, false, button); return awtMouseEvent; } /** * Converts an AWT image to SWT. * * @param image the image (null not permitted). * * @return Image data. */ public static ImageData convertAWTImageToSWT(Image image) { if (image == null) { throw new IllegalArgumentException("Null 'image' argument."); } int w = image.getWidth(null); int h = image.getHeight(null); if (w == -1 || h == -1) { return null; } BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics g = bi.getGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); return convertToSWT(bi); } /** * Converts a buffered image to SWT ImageData. * * @param bufferedImage the buffered image (null not * permitted). * * @return The image data. */ public static ImageData convertToSWT(BufferedImage bufferedImage) { if (bufferedImage.getColorModel() instanceof DirectColorModel) { DirectColorModel colorModel = (DirectColorModel) bufferedImage.getColorModel(); PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(), colorModel.getBlueMask()); ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette); WritableRaster raster = bufferedImage.getRaster(); int[] pixelArray = new int[3]; for (int y = 0; y < data.height; y++) { for (int x = 0; x < data.width; x++) { raster.getPixel(x, y, pixelArray); int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2])); data.setPixel(x, y, pixel); } } return data; } else if (bufferedImage.getColorModel() instanceof IndexColorModel) { IndexColorModel colorModel = (IndexColorModel) bufferedImage.getColorModel(); int size = colorModel.getMapSize(); byte[] reds = new byte[size]; byte[] greens = new byte[size]; byte[] blues = new byte[size]; colorModel.getReds(reds); colorModel.getGreens(greens); colorModel.getBlues(blues); RGB[] rgbs = new RGB[size]; for (int i = 0; i < rgbs.length; i++) { rgbs[i] = new RGB(reds[i] & 0xFF, greens[i] & 0xFF, blues[i] & 0xFF); } PaletteData palette = new PaletteData(rgbs); ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette); data.transparentPixel = colorModel.getTransparentPixel(); WritableRaster raster = bufferedImage.getRaster(); int[] pixelArray = new int[1]; for (int y = 0; y < data.height; y++) { for (int x = 0; x < data.width; x++) { raster.getPixel(x, y, pixelArray); data.setPixel(x, y, pixelArray[0]); } } return data; } return null; } } libjfreechart-java-1.0.13.orig/swt/README0000644000175000017500000000352011173030414017643 0ustar vincentvincentEXPERIMENTAL SWT CODE FOR JFREECHART ------------------------------------ 07 November 2006 SWT is the Java Standard Widget Toolkit [1], an open source (released under the Eclipse Public License) and portable library to create user interfaces. The SWT interfaces will use native widget on any operating system it supports. This code provide support for using the JFreeChart library directly into SWT Composites. Note that there is the alternative to use the SWT_AWT class but it will run only with SUN JRE and Java 1.5 (and it is not native, so potentially much slower). To compile this code, you will need to link it against the swt.jar of the target os. Indeed while the API is totally cross platform, the implementation is platform dependent since it calls on native widget if available (much faster) and only rely on a Java implementation if it is not. An ant script: build-swt.xml is provided to help you build the code. This file contains two compile targets to build the following jar: * swtgraphics2d.jar - The generic classes not JFreeChart specific. * jfreechart-1.0.x-swt.jar - The specific JFreeChart SWT classes. To get a successful build id pretty straightforward, download the SWT library from eclipse.org [1]. Unpack the archive in the JFreeChart tree as libswt. If you need to build for multiple OS, put all the SWT in there. For instance (with SWT version 3.2): libswt | `--swt-linux-gtk-x86 | | | `--swt.jar | `--libswt-gtk-3232.so | `-- etc... `--swt-win32-win32-x86 | `--swt.jar `--swt-win32-3232.dll Then you need to edit the build-swt.xml script and change line 14 to what is needed. Of course all of the paths are relative. You can change it to whatever you like provided the path in the xml file is correct. Then just run: ant -buildfile build-swt.xml [1] http://www.eclipse.org/swt/ libjfreechart-java-1.0.13.orig/tests/0000755000175000017500000000000011173030414017310 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/0000755000175000017500000000000011173030414020077 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/0000755000175000017500000000000011173030414021172 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/0000755000175000017500000000000011173030414022273 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/0000755000175000017500000000000011173030414024630 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/0000755000175000017500000000000011216245562025773 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java0000644000175000017500000000676711173030414033440 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * AnnotationsPackageTests.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-Aug-2003 : Version 1 (DG); * 29-Sep-2004 : Added tests for XYShapeAnnotation class (DG); * 19-Jan-2005 : Added tests for XYBoxAnnotation class (DG); * 29-Jul-2005 : Added tests for new CategoryLineAnnotation class (DG); * 10-Jul-2006 : Added XYPolygonAnnotationTests (DG); * 02-Oct-2006 : Added CategoryPointerAnnotationTests (DG); * */ package org.jfree.chart.annotations.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.annotations * package. These tests can be run using JUnit (http://www.junit.org). */ public class AnnotationsPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.annotations"); suite.addTestSuite(CategoryLineAnnotationTests.class); suite.addTestSuite(CategoryPointerAnnotationTests.class); suite.addTestSuite(CategoryTextAnnotationTests.class); suite.addTestSuite(TextAnnotationTests.class); suite.addTestSuite(XYBoxAnnotationTests.class); suite.addTestSuite(XYDrawableAnnotationTests.class); suite.addTestSuite(XYImageAnnotationTests.class); suite.addTestSuite(XYLineAnnotationTests.class); suite.addTestSuite(XYPointerAnnotationTests.class); suite.addTestSuite(XYPolygonAnnotationTests.class); suite.addTestSuite(XYShapeAnnotationTests.class); suite.addTestSuite(XYTextAnnotationTests.class); suite.addTestSuite(XYTitleAnnotationTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public AnnotationsPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/CategoryLineAnnotationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/CategoryLineAnnotationTests.j0000644000175000017500000001444311173030414033605 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * CategoryLineAnnotationTests.java * -------------------------------- * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jul-2005 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.CategoryLineAnnotation; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CategoryLineAnnotationTests} class. */ public class CategoryLineAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryLineAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryLineAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { BasicStroke s1 = new BasicStroke(1.0f); BasicStroke s2 = new BasicStroke(2.0f); CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.red, s1); CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.red, s1); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); // category 1 a1.setCategory1("Category A"); assertFalse(a1.equals(a2)); a2.setCategory1("Category A"); assertTrue(a1.equals(a2)); // value 1 a1.setValue1(0.15); assertFalse(a1.equals(a2)); a2.setValue1(0.15); assertTrue(a1.equals(a2)); // category 2 a1.setCategory2("Category B"); assertFalse(a1.equals(a2)); a2.setCategory2("Category B"); assertTrue(a1.equals(a2)); // value 2 a1.setValue2(0.25); assertFalse(a1.equals(a2)); a2.setValue2(0.25); assertTrue(a1.equals(a2)); // paint a1.setPaint(Color.yellow); assertFalse(a1.equals(a2)); a2.setPaint(Color.yellow); assertTrue(a1.equals(a2)); // stroke a1.setStroke(s2); assertFalse(a1.equals(a2)); a2.setStroke(s2); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); CategoryLineAnnotation a2 = null; try { a2 = (CategoryLineAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { CategoryLineAnnotation a1 = new CategoryLineAnnotation( "Category 1", 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); CategoryLineAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (CategoryLineAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/CategoryPointerAnnotationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/CategoryPointerAnnotationTest0000644000175000017500000001573511173030414033730 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * CategoryPointerAnnotationTests.java * ----------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Oct-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.CategoryPointerAnnotation; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CategoryPointerAnnotation} class. */ public class CategoryPointerAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryPointerAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryPointerAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "Key 1", 20.0, Math.PI); CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label", "Key 1", 20.0, Math.PI); assertTrue(a1.equals(a2)); a1 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI); assertFalse(a1.equals(a2)); a2 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI); assertTrue(a1.equals(a2)); a1.setCategory("Key 2"); assertFalse(a1.equals(a2)); a2.setCategory("Key 2"); assertTrue(a1.equals(a2)); a1.setValue(22.0); assertFalse(a1.equals(a2)); a2.setValue(22.0); assertTrue(a1.equals(a2)); //private double angle; a1.setAngle(Math.PI / 4.0); assertFalse(a1.equals(a2)); a2.setAngle(Math.PI / 4.0); assertTrue(a1.equals(a2)); //private double tipRadius; a1.setTipRadius(20.0); assertFalse(a1.equals(a2)); a2.setTipRadius(20.0); assertTrue(a1.equals(a2)); //private double baseRadius; a1.setBaseRadius(5.0); assertFalse(a1.equals(a2)); a2.setBaseRadius(5.0); assertTrue(a1.equals(a2)); //private double arrowLength; a1.setArrowLength(33.0); assertFalse(a1.equals(a2)); a2.setArrowLength(33.0); assertTrue(a1.equals(a2)); //private double arrowWidth; a1.setArrowWidth(9.0); assertFalse(a1.equals(a2)); a2.setArrowWidth(9.0); assertTrue(a1.equals(a2)); //private Stroke arrowStroke; Stroke stroke = new BasicStroke(1.5f); a1.setArrowStroke(stroke); assertFalse(a1.equals(a2)); a2.setArrowStroke(stroke); assertTrue(a1.equals(a2)); //private Paint arrowPaint; a1.setArrowPaint(Color.blue); assertFalse(a1.equals(a2)); a2.setArrowPaint(Color.blue); assertTrue(a1.equals(a2)); //private double labelOffset; a1.setLabelOffset(10.0); assertFalse(a1.equals(a2)); a2.setLabelOffset(10.0); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); CategoryPointerAnnotation a2 = null; try { a2 = (CategoryPointerAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); CategoryPointerAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (CategoryPointerAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/CategoryTextAnnotationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/CategoryTextAnnotationTests.j0000644000175000017500000001274711173030414033647 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * CategoryTextAnnotationTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.CategoryTextAnnotation; import org.jfree.chart.axis.CategoryAnchor; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CategoryTextAnnotation} class. */ public class CategoryTextAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryTextAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryTextAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); // category a1.setCategory("Category 2"); assertFalse(a1.equals(a2)); a2.setCategory("Category 2"); assertTrue(a1.equals(a2)); // categoryAnchor a1.setCategoryAnchor(CategoryAnchor.START); assertFalse(a1.equals(a2)); a2.setCategoryAnchor(CategoryAnchor.START); assertTrue(a1.equals(a2)); // value a1.setValue(0.15); assertFalse(a1.equals(a2)); a2.setValue(0.15); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0); CategoryTextAnnotation a2 = null; try { a2 = (CategoryTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (CategoryTextAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/TextAnnotationTests.java0000644000175000017500000001042611173030414032631 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * TextAnnotationTests.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added testHashCode() method (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.CategoryTextAnnotation; import org.jfree.chart.annotations.TextAnnotation; import org.jfree.ui.TextAnchor; /** * Tests for the {@link TextAnnotation} class. */ public class TextAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TextAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TextAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); // text a1.setText("Text"); assertFalse(a1.equals(a2)); a2.setText("Text"); assertTrue(a1.equals(a2)); // font a1.setFont(new Font("Serif", Font.BOLD, 18)); assertFalse(a1.equals(a2)); a2.setFont(new Font("Serif", Font.BOLD, 18)); assertTrue(a1.equals(a2)); // paint a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.pink)); assertFalse(a1.equals(a2)); a2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.pink)); assertTrue(a1.equals(a2)); // textAnchor a1.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertTrue(a1.equals(a2)); // rotationAnchor a1.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertTrue(a1.equals(a2)); // rotationAngle a1.setRotationAngle(Math.PI); assertFalse(a1.equals(a2)); a2.setRotationAngle(Math.PI); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYBoxAnnotationTests.java0000644000175000017500000002066511173030414032724 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYBoxAnnotationTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Jan-2005 : Version 1 (DG); * 26-Feb-2008 : Added testDrawWithNullInfo() method (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYBoxAnnotation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.util.PublicCloneable; /** * Some tests for the {@link XYBoxAnnotation} class. */ public class XYBoxAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBoxAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBoxAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); XYBoxAnnotation a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); // x0 a1 = new XYBoxAnnotation(2.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(2.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); // stroke a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), Color.red, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), Color.red, Color.blue); assertTrue(a1.equals(a2)); GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red); GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red); GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.white); GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.white); // outlinePaint a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1a, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1b, Color.blue); assertTrue(a1.equals(a2)); // fillPaint a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1a, gp2a); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1b, gp2b); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); XYBoxAnnotation a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); XYBoxAnnotation a2 = null; try { a2 = (XYBoxAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); XYBoxAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (XYBoxAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown. */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYLineAndShapeRenderer()); plot.addAnnotation(new XYBoxAnnotation(10.0, 12.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue)); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYDrawableAnnotationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYDrawableAnnotationTests.jav0000644000175000017500000001724711173030414033556 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * XYDrawableAnnotationTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 01-Oct-2004 : Fixed bugs in tests (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.io.Serializable; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.XYDrawableAnnotation; import org.jfree.ui.Drawable; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYDrawableAnnotation} class. */ public class XYDrawableAnnotationTests extends TestCase { static class TestDrawable implements Drawable, Cloneable, Serializable { /** * Default constructor. */ public TestDrawable() { } /** * Draws something. * @param g2 the graphics device. * @param area the area in which to draw. */ public void draw(Graphics2D g2, Rectangle2D area) { // do nothing } /** * Tests this object for equality with an arbitrary object. * @param obj the object to test against (null permitted). * @return A boolean. */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TestDrawable)) { return false; } return true; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ public Object clone() throws CloneNotSupportedException { return super.clone(); } } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYDrawableAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYDrawableAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); assertTrue(a1.equals(a2)); a1 = new XYDrawableAnnotation(11.0, 20.0, 100.0, 200.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 20.0, 100.0, 200.0, new TestDrawable()); assertTrue(a1.equals(a2)); a1 = new XYDrawableAnnotation(11.0, 22.0, 100.0, 200.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 100.0, 200.0, new TestDrawable()); assertTrue(a1.equals(a2)); a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 200.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 200.0, new TestDrawable()); assertTrue(a1.equals(a2)); a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, new TestDrawable()); assertTrue(a1.equals(a2)); a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, 2.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, 2.0, new TestDrawable()); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = null; try { a2 = (XYDrawableAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (XYDrawableAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYImageAnnotationTests.java0000644000175000017500000001214311173030414033206 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XYImageAnnotationTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-May-2004 : Version 1 (DG); * 01-Dec-2006 : Updated testEquals() for new field (DG); * 09-Jan-2007 : Comment out failing test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.Image; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYImageAnnotation; import org.jfree.ui.RectangleAnchor; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYImageAnnotation} class. */ public class XYImageAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYImageAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYImageAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Image image = JFreeChart.INFO.getLogo(); XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image); XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image); assertTrue(a1.equals(a2)); a1 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT); assertFalse(a1.equals(a2)); a2 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Image image = JFreeChart.INFO.getLogo(); XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image); XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, JFreeChart.INFO.getLogo()); XYImageAnnotation a2 = null; try { a2 = (XYImageAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, JFreeChart.INFO.getLogo()); assertTrue(a1 instanceof PublicCloneable); } // FIXME: Make this test pass // /** // * Serialize an instance, restore it, and check for equality. // */ // public void testSerialization() { // XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, // JFreeChart.INFO.getLogo()); // XYImageAnnotation a2 = null; // try { // ByteArrayOutputStream buffer = new ByteArrayOutputStream(); // ObjectOutput out = new ObjectOutputStream(buffer); // out.writeObject(a1); // out.close(); // // ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( // buffer.toByteArray())); // a2 = (XYImageAnnotation) in.readObject(); // in.close(); // } // catch (Exception e) { // e.printStackTrace(); // } // assertEquals(a1, a2); // } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYLineAnnotationTests.java0000644000175000017500000001566311173030414033065 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYLineAnnotationTests.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.XYLineAnnotation; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYLineAnnotation} class. */ public class XYLineAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYLineAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYLineAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); a1 = new XYLineAnnotation(11.0, 20.0, 100.0, 200.0, stroke, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 20.0, 100.0, 200.0, stroke, Color.blue); assertTrue(a1.equals(a2)); a1 = new XYLineAnnotation(11.0, 21.0, 100.0, 200.0, stroke, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 100.0, 200.0, stroke, Color.blue); assertTrue(a1.equals(a2)); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke, Color.blue); assertTrue(a1.equals(a2)); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 201.0, stroke, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 201.0, stroke, Color.blue); assertTrue(a1.equals(a2)); Stroke stroke2 = new BasicStroke(0.99f); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, Color.blue); assertTrue(a1.equals(a2)); GradientPaint g1 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white); GradientPaint g2 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, g1); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, g2); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); XYLineAnnotation a2 = null; try { a2 = (XYLineAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.blue); XYLineAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (XYLineAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYPointerAnnotationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYPointerAnnotationTests.java0000644000175000017500000001573011173030414033611 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * XYPointerAnnotationTests.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 13-Oct-2003 : Expanded test for equals() method (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 20-Feb-2006 : Added 'x' and 'y' checks to testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.XYPointerAnnotation; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYPointerAnnotation} class. */ public class XYPointerAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYPointerAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYPointerAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); assertTrue(a1.equals(a2)); a1 = new XYPointerAnnotation("Label2", 10.0, 20.0, Math.PI); assertFalse(a1.equals(a2)); a2 = new XYPointerAnnotation("Label2", 10.0, 20.0, Math.PI); assertTrue(a1.equals(a2)); a1.setX(11.0); assertFalse(a1.equals(a2)); a2.setX(11.0); assertTrue(a1.equals(a2)); a1.setY(22.0); assertFalse(a1.equals(a2)); a2.setY(22.0); assertTrue(a1.equals(a2)); //private double angle; a1.setAngle(Math.PI / 4.0); assertFalse(a1.equals(a2)); a2.setAngle(Math.PI / 4.0); assertTrue(a1.equals(a2)); //private double tipRadius; a1.setTipRadius(20.0); assertFalse(a1.equals(a2)); a2.setTipRadius(20.0); assertTrue(a1.equals(a2)); //private double baseRadius; a1.setBaseRadius(5.0); assertFalse(a1.equals(a2)); a2.setBaseRadius(5.0); assertTrue(a1.equals(a2)); //private double arrowLength; a1.setArrowLength(33.0); assertFalse(a1.equals(a2)); a2.setArrowLength(33.0); assertTrue(a1.equals(a2)); //private double arrowWidth; a1.setArrowWidth(9.0); assertFalse(a1.equals(a2)); a2.setArrowWidth(9.0); assertTrue(a1.equals(a2)); //private Stroke arrowStroke; Stroke stroke = new BasicStroke(1.5f); a1.setArrowStroke(stroke); assertFalse(a1.equals(a2)); a2.setArrowStroke(stroke); assertTrue(a1.equals(a2)); //private Paint arrowPaint; a1.setArrowPaint(Color.blue); assertFalse(a1.equals(a2)); a2.setArrowPaint(Color.blue); assertTrue(a1.equals(a2)); //private double labelOffset; a1.setLabelOffset(10.0); assertFalse(a1.equals(a2)); a2.setLabelOffset(10.0); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = null; try { a2 = (XYPointerAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (XYPointerAnnotation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYPolygonAnnotationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYPolygonAnnotationTests.java0000644000175000017500000001647011173030414033622 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * XYPolygonAnnotationTests.java * ----------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jul-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.XYPolygonAnnotation; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYPolygonAnnotation} class. */ public class XYPolygonAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYPolygonAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYPolygonAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Stroke stroke1 = new BasicStroke(2.0f); Stroke stroke2 = new BasicStroke(2.5f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); XYPolygonAnnotation a2 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); assertTrue(a1.equals(a2)); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, Color.red, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, Color.red, Color.blue); assertTrue(a1.equals(a2)); GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.white); GradientPaint gp2 = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.white); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp1, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp2, Color.blue); assertTrue(a1.equals(a2)); GradientPaint gp3 = new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.white); GradientPaint gp4 = new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.white); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp1, gp3); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp2, gp4); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Stroke stroke = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke, Color.red, Color.blue); XYPolygonAnnotation a2 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke, Color.red, Color.blue); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); XYPolygonAnnotation a2 = null; try { a2 = (XYPolygonAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); XYPolygonAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (XYPolygonAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYShapeAnnotationTests.java0000644000175000017500000001702411173030414033227 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XYShapeAnnotationTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Sep-2004 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.XYShapeAnnotation; import org.jfree.util.PublicCloneable; /** * Some tests for the {@link XYShapeAnnotation} class. */ public class XYShapeAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYShapeAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYShapeAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); // shape a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(1.2f), Color.red, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); // stroke a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), Color.red, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), Color.red, Color.blue); assertTrue(a1.equals(a2)); GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red); GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red); GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.white); GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.white); // outlinePaint a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1a, Color.blue); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1b, Color.blue); assertTrue(a1.equals(a2)); // fillPaint a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1a, gp2a); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1b, gp2b); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = null; try { a2 = (XYShapeAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (XYShapeAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYTextAnnotationTests.java0000644000175000017500000001642011173030414033112 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYTextAnnotationTests.java * -------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 26-Jan-2006 : Extended equals() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 12-Feb-2009 : Updated testEquals() (DG); * */ package org.jfree.chart.annotations.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.ui.TextAnchor; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYTextAnnotation} class. */ public class XYTextAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYTextAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYTextAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0); assertTrue(a1.equals(a2)); // text a1 = new XYTextAnnotation("ABC", 10.0, 20.0); assertFalse(a1.equals(a2)); a2 = new XYTextAnnotation("ABC", 10.0, 20.0); assertTrue(a1.equals(a2)); // x a1 = new XYTextAnnotation("ABC", 11.0, 20.0); assertFalse(a1.equals(a2)); a2 = new XYTextAnnotation("ABC", 11.0, 20.0); assertTrue(a1.equals(a2)); // y a1 = new XYTextAnnotation("ABC", 11.0, 22.0); assertFalse(a1.equals(a2)); a2 = new XYTextAnnotation("ABC", 11.0, 22.0); assertTrue(a1.equals(a2)); // font a1.setFont(new Font("Serif", Font.PLAIN, 23)); assertFalse(a1.equals(a2)); a2.setFont(new Font("Serif", Font.PLAIN, 23)); assertTrue(a1.equals(a2)); // paint GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow); GradientPaint gp2 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow); a1.setPaint(gp1); assertFalse(a1.equals(a2)); a2.setPaint(gp2); assertTrue(a1.equals(a2)); // rotation anchor a1.setRotationAnchor(TextAnchor.BASELINE_RIGHT); assertFalse(a1.equals(a2)); a2.setRotationAnchor(TextAnchor.BASELINE_RIGHT); assertTrue(a1.equals(a2)); // rotation angle a1.setRotationAngle(12.3); assertFalse(a1.equals(a2)); a2.setRotationAngle(12.3); assertTrue(a1.equals(a2)); // text anchor a1.setTextAnchor(TextAnchor.BASELINE_RIGHT); assertFalse(a1.equals(a2)); a2.setTextAnchor(TextAnchor.BASELINE_RIGHT); assertTrue(a1.equals(a2)); a1.setBackgroundPaint(gp1); assertFalse(a1.equals(a2)); a2.setBackgroundPaint(gp1); assertTrue(a1.equals(a2)); a1.setOutlinePaint(gp1); assertFalse(a1.equals(a2)); a2.setOutlinePaint(gp1); assertTrue(a1.equals(a2)); a1.setOutlineStroke(new BasicStroke(1.2f)); assertFalse(a1.equals(a2)); a2.setOutlineStroke(new BasicStroke(1.2f)); assertTrue(a1.equals(a2)); a1.setOutlineVisible(!a1.isOutlineVisible()); assertFalse(a1.equals(a2)); a2.setOutlineVisible(a1.isOutlineVisible()); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = null; try { a2 = (XYTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Checks that this class implements PublicCloneable. */ public void testPublicCloneable() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); a1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); XYTextAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (XYTextAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java0000644000175000017500000001525211173030414033251 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XYTitleAnnotationTests.java * --------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Apr-2007 : Version 1 (DG); * 26-Feb-2008 : Added testDrawWithNullInfo() (DG); * */ package org.jfree.chart.annotations.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTitleAnnotation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.TextTitle; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; /** * Tests for the {@link XYTitleAnnotation} class. */ public class XYTitleAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYTitleAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYTitleAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); assertTrue(a1.equals(a2)); a1 = new XYTitleAnnotation(1.1, 2.0, t); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.0, t); assertTrue(a1.equals(a2)); a1 = new XYTitleAnnotation(1.1, 2.2, t); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.2, t); assertTrue(a1.equals(a2)); TextTitle t2 = new TextTitle("Title 2"); a1 = new XYTitleAnnotation(1.1, 2.2, t2); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.2, t2); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = null; try { a2 = (XYTitleAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (XYTitleAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown. */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYLineAndShapeRenderer()); plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, new TextTitle("Hello World!"))); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/annotations/junit/package.html0000644000175000017500000000026511173030414030245 0ustar vincentvincent Tests for the classes in the org.jfree.chart.annotations package. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/0000755000175000017500000000000011173030414023237 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/0000755000175000017500000000000011216245562024402 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/AxisLocationTests.java0000644000175000017500000000772711173030414030670 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * AxisLocationTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jul-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.AxisLocation; /** * Tests for the {@link AxisLocation} class. */ public class AxisLocationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AxisLocationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AxisLocationTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { assertEquals(AxisLocation.TOP_OR_RIGHT, AxisLocation.TOP_OR_RIGHT); assertEquals(AxisLocation.BOTTOM_OR_RIGHT, AxisLocation.BOTTOM_OR_RIGHT); assertEquals(AxisLocation.TOP_OR_LEFT, AxisLocation.TOP_OR_LEFT); assertEquals(AxisLocation.BOTTOM_OR_LEFT, AxisLocation.BOTTOM_OR_LEFT); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { AxisLocation a1 = AxisLocation.TOP_OR_RIGHT; AxisLocation a2 = AxisLocation.TOP_OR_RIGHT; assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { AxisLocation location1 = AxisLocation.BOTTOM_OR_RIGHT; AxisLocation location2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(location1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); location2 = (AxisLocation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(location1, location2); boolean same = location1 == location2; assertEquals(true, same); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/AxisPackageTests.java0000644000175000017500000001117511173030414030443 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * AxisPackageTests.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Bill Kelemen; * * Changes: * -------- * 26-Mar-2003 : Version 1 (DG); * 25-May-2003 : Added SegmentedTimelineTests (BK); * 17-Feb-2004 : Added extra tests (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 21-Mar-2007 : Added ExtendedCategoryAxisTests (DG); * 02-Aug-2007 : Added LogAxisTests and TickUnitsTests (DG); * 25-Oct-2007 : Added StandardTickUnitSourceTests (DG); * 13-Nov-2007 : Added ModuloAxisTests (DG); * */ package org.jfree.chart.axis.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.axis package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class AxisPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.axis"); suite.addTestSuite(AxisLocationTests.class); suite.addTestSuite(AxisSpaceTests.class); suite.addTestSuite(AxisTests.class); suite.addTestSuite(CategoryAnchorTests.class); suite.addTestSuite(CategoryAxisTests.class); suite.addTestSuite(CategoryAxis3DTests.class); suite.addTestSuite(CategoryLabelPositionTests.class); suite.addTestSuite(CategoryLabelPositionsTests.class); suite.addTestSuite(CategoryLabelWidthTypeTests.class); suite.addTestSuite(CategoryTickTests.class); suite.addTestSuite(ColorBarTests.class); suite.addTestSuite(CyclicNumberAxisTests.class); suite.addTestSuite(DateAxisTests.class); suite.addTestSuite(DateTickTests.class); suite.addTestSuite(DateTickMarkPositionTests.class); suite.addTestSuite(DateTickUnitTests.class); suite.addTestSuite(ExtendedCategoryAxisTests.class); suite.addTestSuite(LogAxisTests.class); suite.addTestSuite(LogarithmicAxisTests.class); suite.addTestSuite(MarkerAxisBandTests.class); suite.addTestSuite(ModuloAxisTests.class); suite.addTestSuite(MonthDateFormatTests.class); suite.addTestSuite(NumberAxisTests.class); suite.addTestSuite(NumberAxis3DTests.class); suite.addTestSuite(NumberTickUnitTests.class); suite.addTestSuite(PeriodAxisTests.class); suite.addTestSuite(PeriodAxisLabelInfoTests.class); suite.addTestSuite(QuarterDateFormatTests.class); suite.addTestSuite(SegmentedTimelineTests.class); suite.addTestSuite(SegmentedTimelineTests2.class); suite.addTestSuite(StandardTickUnitSourceTests.class); suite.addTestSuite(SubCategoryAxisTests.class); suite.addTestSuite(SymbolAxisTests.class); suite.addTestSuite(TickUnitsTests.class); suite.addTestSuite(ValueAxisTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public AxisPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/AxisSpaceTests.java0000644000175000017500000000716711173030414030151 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * AxisSpaceTests.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode test (DG); * */ package org.jfree.chart.axis.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.AxisSpace; /** * Tests for the {@link AxisSpace} class. */ public class AxisSpaceTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AxisSpaceTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AxisSpaceTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { AxisSpace a1 = new AxisSpace(); AxisSpace a2 = new AxisSpace(); assertEquals(a1, a2); a1.setTop(1.11); assertFalse(a1.equals(a2)); a2.setTop(1.11); assertTrue(a1.equals(a2)); a1.setBottom(2.22); assertFalse(a1.equals(a2)); a2.setBottom(2.22); assertTrue(a1.equals(a2)); a1.setLeft(3.33); assertFalse(a1.equals(a2)); a2.setLeft(3.33); assertTrue(a1.equals(a2)); a1.setRight(4.44); assertFalse(a1.equals(a2)); a2.setRight(4.44); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { AxisSpace s1 = new AxisSpace(); AxisSpace s2 = new AxisSpace(); assertTrue(s1.equals(s2)); int h1 = s1.hashCode(); int h2 = s2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { AxisSpace s1 = new AxisSpace(); AxisSpace s2 = null; try { s2 = (AxisSpace) s1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/AxisTests.java0000644000175000017500000002022711173030414027165 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * AxisTests.java * -------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2003 : Version 1 (DG); * 06-Jan-2004 : Added tests for axis line attributes (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 25-Sep-2008 : Extended equals() to cover new fields (DG); * */ package org.jfree.chart.axis.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.CategoryAxis; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link Axis} class. */ public class AxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AxisTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { CategoryAxis a1 = new CategoryAxis("Test"); a1.setAxisLinePaint(Color.red); CategoryAxis a2 = null; try { a2 = (CategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Axis a1 = new CategoryAxis("Test"); Axis a2 = new CategoryAxis("Test"); assertTrue(a1.equals(a2)); // visible flag... a1.setVisible(false); assertFalse(a1.equals(a2)); a2.setVisible(false); assertTrue(a1.equals(a2)); // label... a1.setLabel("New Label"); assertFalse(a1.equals(a2)); a2.setLabel("New Label"); assertTrue(a1.equals(a2)); // label font... a1.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); assertFalse(a1.equals(a2)); a2.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); assertTrue(a1.equals(a2)); // label paint... a1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.black)); assertFalse(a1.equals(a2)); a2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.black)); assertTrue(a1.equals(a2)); // label insets... a1.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertFalse(a1.equals(a2)); a2.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertTrue(a1.equals(a2)); // label angle... a1.setLabelAngle(1.23); assertFalse(a1.equals(a2)); a2.setLabelAngle(1.23); assertTrue(a1.equals(a2)); // axis line visible... a1.setAxisLineVisible(false); assertFalse(a1.equals(a2)); a2.setAxisLineVisible(false); assertTrue(a1.equals(a2)); // axis line stroke... BasicStroke s = new BasicStroke(1.1f); a1.setAxisLineStroke(s); assertFalse(a1.equals(a2)); a2.setAxisLineStroke(s); assertTrue(a1.equals(a2)); // axis line paint... a1.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.black)); assertFalse(a1.equals(a2)); a2.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.black)); assertTrue(a1.equals(a2)); // tick labels visible flag... a1.setTickLabelsVisible(false); assertFalse(a1.equals(a2)); a2.setTickLabelsVisible(false); assertTrue(a1.equals(a2)); // tick label font... a1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); assertFalse(a1.equals(a2)); a2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); assertTrue(a1.equals(a2)); // tick label paint... a1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.black)); assertFalse(a1.equals(a2)); a2.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.black)); assertTrue(a1.equals(a2)); // tick label insets... a1.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertFalse(a1.equals(a2)); a2.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertTrue(a1.equals(a2)); // tick marks visible flag... a1.setTickMarksVisible(false); assertFalse(a1.equals(a2)); a2.setTickMarksVisible(false); assertTrue(a1.equals(a2)); // tick mark inside length... a1.setTickMarkInsideLength(1.23f); assertFalse(a1.equals(a2)); a2.setTickMarkInsideLength(1.23f); assertTrue(a1.equals(a2)); // tick mark outside length... a1.setTickMarkOutsideLength(1.23f); assertFalse(a1.equals(a2)); a2.setTickMarkOutsideLength(1.23f); assertTrue(a1.equals(a2)); // tick mark stroke... a1.setTickMarkStroke(new BasicStroke(2.0f)); assertFalse(a1.equals(a2)); a2.setTickMarkStroke(new BasicStroke(2.0f)); assertTrue(a1.equals(a2)); // tick mark paint... a1.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.black)); assertFalse(a1.equals(a2)); a2.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.black)); assertTrue(a1.equals(a2)); // tick mark outside length... a1.setFixedDimension(3.21f); assertFalse(a1.equals(a2)); a2.setFixedDimension(3.21f); assertTrue(a1.equals(a2)); a1.setMinorTickMarksVisible(true); assertFalse(a1.equals(a2)); a2.setMinorTickMarksVisible(true); assertTrue(a1.equals(a2)); a1.setMinorTickMarkInsideLength(1.23f); assertFalse(a1.equals(a2)); a2.setMinorTickMarkInsideLength(1.23f); assertTrue(a1.equals(a2)); a1.setMinorTickMarkOutsideLength(3.21f); assertFalse(a1.equals(a2)); a2.setMinorTickMarkOutsideLength(3.21f); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Axis a1 = new CategoryAxis("Test"); Axis a2 = new CategoryAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryAnchorTests.java0000644000175000017500000000764611173030414031203 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CategoryAnchorTests.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryAnchor; /** * Tests for the {@link CategoryAnchor} class. */ public class CategoryAnchorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryAnchorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryAnchorTests(String name) { super(name); } /** * Check that the equals() method distinguishes known instances. */ public void testEquals() { assertEquals(CategoryAnchor.START, CategoryAnchor.START); assertEquals(CategoryAnchor.MIDDLE, CategoryAnchor.MIDDLE); assertEquals(CategoryAnchor.END, CategoryAnchor.END); assertFalse(CategoryAnchor.START.equals(CategoryAnchor.END)); assertFalse(CategoryAnchor.MIDDLE.equals(CategoryAnchor.END)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryAnchor a1 = CategoryAnchor.START; CategoryAnchor a2 = CategoryAnchor.START; assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryAnchor a1 = CategoryAnchor.MIDDLE; CategoryAnchor a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (CategoryAnchor) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); assertTrue(a1 == a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryAxis3DTests.java0000644000175000017500000000677311173030414031064 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CategoryAxis3DTests.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryAxis3D; /** * Tests for the {@link CategoryAxis3D} class. */ public class CategoryAxis3DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryAxis3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryAxis3DTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { CategoryAxis3D a1 = new CategoryAxis3D("Test"); CategoryAxis3D a2 = null; try { a2 = (CategoryAxis3D) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryAxis3D a1 = new CategoryAxis3D("Test Axis"); CategoryAxis3D a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (CategoryAxis3D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryAxisTests.java0000644000175000017500000001771011173030414030666 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * CategoryAxisTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added clone() test (DG); * 07-Jan-2005 : Added hashCode() test (DG); * */ package org.jfree.chart.axis.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; /** * Tests for the {@link CategoryAxis} class. */ public class CategoryAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryAxisTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryAxis a1 = new CategoryAxis("Test"); CategoryAxis a2 = new CategoryAxis("Test"); assertTrue(a1.equals(a2)); // lowerMargin a1.setLowerMargin(0.15); assertFalse(a1.equals(a2)); a2.setLowerMargin(0.15); assertTrue(a1.equals(a2)); // upperMargin a1.setUpperMargin(0.15); assertFalse(a1.equals(a2)); a2.setUpperMargin(0.15); assertTrue(a1.equals(a2)); // categoryMargin a1.setCategoryMargin(0.15); assertFalse(a1.equals(a2)); a2.setCategoryMargin(0.15); assertTrue(a1.equals(a2)); // maxCategoryLabelWidthRatio a1.setMaximumCategoryLabelWidthRatio(0.98f); assertFalse(a1.equals(a2)); a2.setMaximumCategoryLabelWidthRatio(0.98f); assertTrue(a1.equals(a2)); // categoryLabelPositionOffset a1.setCategoryLabelPositionOffset(11); assertFalse(a1.equals(a2)); a2.setCategoryLabelPositionOffset(11); assertTrue(a1.equals(a2)); // categoryLabelPositions a1.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); assertFalse(a1.equals(a2)); a2.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); assertTrue(a1.equals(a2)); // categoryLabelToolTips a1.addCategoryLabelToolTip("Test", "Check"); assertFalse(a1.equals(a2)); a2.addCategoryLabelToolTip("Test", "Check"); assertTrue(a1.equals(a2)); // tickLabelFont a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21)); assertFalse(a1.equals(a2)); a2.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21)); assertTrue(a1.equals(a2)); // tickLabelPaint a1.setTickLabelPaint("C1", Color.red); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", Color.red); assertTrue(a1.equals(a2)); // tickLabelPaint2 a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryAxis a1 = new CategoryAxis("Test"); CategoryAxis a2 = new CategoryAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CategoryAxis a1 = new CategoryAxis("Test"); CategoryAxis a2 = null; try { a2 = (CategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that cloning works. This test customises the font and paint * per category label. */ public void testCloning2() { CategoryAxis a1 = new CategoryAxis("Test"); a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 15)); a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); CategoryAxis a2 = null; try { a2 = (CategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check that changing a tick label font in a1 doesn't change a2 a1.setTickLabelFont("C1", null); assertFalse(a1.equals(a2)); a2.setTickLabelFont("C1", null); assertTrue(a1.equals(a2)); // check that changing a tick label paint in a1 doesn't change a2 a1.setTickLabelPaint("C1", Color.yellow); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", Color.yellow); assertTrue(a1.equals(a2)); // check that changing a category label tooltip in a1 doesn't change a2 a1.addCategoryLabelToolTip("C1", "XYZ"); assertFalse(a1.equals(a2)); a2.addCategoryLabelToolTip("C1", "XYZ"); assertTrue(a1.equals(a2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryAxis a1 = new CategoryAxis("Test Axis"); a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); CategoryAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (CategoryAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryLabelPositionTests.java0000644000175000017500000001611611173030414032525 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * CategoryLabelPositionTests.java * ------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Feb-2004 : Version 1 (DG); * 07-Jan-2005 : Improved testEquals() code and added hashCode() test (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryLabelPosition; import org.jfree.chart.axis.CategoryLabelWidthType; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.TextAnchor; /** * Tests for the {@link CategoryLabelPosition} class. */ public class CategoryLabelPositionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryLabelPositionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryLabelPositionTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { CategoryLabelPosition p1 = new CategoryLabelPosition( RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); CategoryLabelPosition p2 = new CategoryLabelPosition( RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.RANGE, 0.44f); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.44f); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.55f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.55f); assertTrue(p1.equals(p2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryLabelPosition a1 = new CategoryLabelPosition(); CategoryLabelPosition a2 = new CategoryLabelPosition(); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryLabelPosition p1 = new CategoryLabelPosition(); CategoryLabelPosition p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryLabelPosition) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryLabelPositionsTests.java0000644000175000017500000002147511173030414032714 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * CategoryLabelPositionsTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Feb-2004 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryLabelPosition; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.RectangleAnchor; /** * Tests for the {@link CategoryLabelPositions} class. */ public class CategoryLabelPositionsTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryLabelPositionsTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryLabelPositionsTests(String name) { super(name); } private static final RectangleAnchor RA_TOP = RectangleAnchor.TOP; private static final RectangleAnchor RA_BOTTOM = RectangleAnchor.BOTTOM; /** * Check that the equals method distinguishes all fields. */ public void testEquals() { CategoryLabelPositions p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); CategoryLabelPositions p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertEquals(p1, p2); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(!p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(!p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(!p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(p1.equals(p2)); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER)); assertTrue(!p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER)); assertTrue(p1.equals(p2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryLabelPositions p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); CategoryLabelPositions p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertTrue(p1.equals(p2)); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryLabelPositions p1 = CategoryLabelPositions.STANDARD; CategoryLabelPositions p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryLabelPositions) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryLabelWidthTypeTests.java0000644000175000017500000000757211173030414032650 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * CategoryLabelWidthTypeTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryLabelWidthType; /** * Tests for the {@link CategoryLabelWidthType} class. */ public class CategoryLabelWidthTypeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryLabelWidthTypeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryLabelWidthTypeTests(String name) { super(name); } /** * Confirm that the equals() method distinguishes the known values. */ public void testEquals() { assertEquals(CategoryLabelWidthType.CATEGORY, CategoryLabelWidthType.CATEGORY); assertEquals(CategoryLabelWidthType.RANGE, CategoryLabelWidthType.RANGE); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CategoryLabelWidthType a1 = CategoryLabelWidthType.CATEGORY; CategoryLabelWidthType a2 = CategoryLabelWidthType.CATEGORY; assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryLabelWidthType w1 = CategoryLabelWidthType.RANGE; CategoryLabelWidthType w2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(w1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); w2 = (CategoryLabelWidthType) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(w1, w2); assertTrue(w1 == w2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CategoryTickTests.java0000644000175000017500000001420311173030414030646 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * CategoryTickTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryTick; import org.jfree.text.TextBlock; import org.jfree.text.TextBlockAnchor; import org.jfree.text.TextLine; import org.jfree.ui.TextAnchor; /** * Tests for the {@link CategoryTick} class. */ public class CategoryTickTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryTickTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryTickTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Comparable c1 = "C1"; Comparable c2 = "C2"; TextBlock tb1 = new TextBlock(); tb1.addLine(new TextLine("Block 1")); TextBlock tb2 = new TextBlock(); tb1.addLine(new TextLine("Block 2")); TextBlockAnchor tba1 = TextBlockAnchor.CENTER; TextBlockAnchor tba2 = TextBlockAnchor.BOTTOM_CENTER; TextAnchor ta1 = TextAnchor.CENTER; TextAnchor ta2 = TextAnchor.BASELINE_LEFT; CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); assertTrue(t1.equals(t2)); t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f); assertTrue(t1.equals(t2)); t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f); assertTrue(t1.equals(t2)); t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f); assertTrue(t1.equals(t2)); t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f); assertTrue(t1.equals(t2)); t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Comparable c1 = "C1"; TextBlock tb1 = new TextBlock(); tb1.addLine(new TextLine("Block 1")); tb1.addLine(new TextLine("Block 2")); TextBlockAnchor tba1 = TextBlockAnchor.CENTER; TextAnchor ta1 = TextAnchor.CENTER; CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CategoryTick t1 = new CategoryTick( "C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f ); CategoryTick t2 = null; try { t2 = (CategoryTick) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryTick t1 = new CategoryTick("C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f); CategoryTick t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (CategoryTick) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/ColorBarTests.java0000644000175000017500000001074711173030414027772 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * ColorBarTests.java * ------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() method (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.ColorBar; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.GreyPalette; /** * Tests for the ColorBar class. */ public class ColorBarTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ColorBarTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ColorBarTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { ColorBar c1 = new ColorBar("Test"); ColorBar c2 = new ColorBar("Test"); assertEquals(c1, c2); c1.setAxis(new NumberAxis("Axis 1")); assertTrue(!c1.equals(c2)); c2.setAxis(new NumberAxis("Axis 1")); assertTrue(c1.equals(c2)); c1.setColorPalette(new GreyPalette()); assertTrue(!c1.equals(c2)); c2.setColorPalette(new GreyPalette()); assertTrue(c1.equals(c2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { ColorBar c1 = new ColorBar("Test"); ColorBar c2 = new ColorBar("Test"); assertTrue(c1.equals(c2)); int h1 = c1.hashCode(); int h2 = c2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ColorBar c1 = new ColorBar("Test"); ColorBar c2 = null; try { c2 = (ColorBar) c1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ColorBar a1 = new ColorBar("Test Axis"); ColorBar a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (ColorBar) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/CyclicNumberAxisTests.java0000644000175000017500000001341711173030414031470 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * CyclicAxisTests.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: Nicolas Brodu * Contributor(s): -; * * Changes * ------- * 19-Nov-2003 : First version (NB); * 05-Oct-2004 : Removed extension of NumberAxisTests (DG); * 07-Jan-2004 : Added test for hashCode() (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.axis.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CyclicNumberAxis; /** * Tests for the {@link CyclicNumberAxis} class. */ public class CyclicNumberAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CyclicNumberAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CyclicNumberAxisTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test"); CyclicNumberAxis a2 = null; try { a2 = (CyclicNumberAxis) a1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test"); CyclicNumberAxis a2 = new CyclicNumberAxis(10, 0, "Test"); assertTrue(a1.equals(a2)); // period a1.setPeriod(5); assertFalse(a1.equals(a2)); a2.setPeriod(5); assertTrue(a1.equals(a2)); // offset a1.setOffset(2.0); assertFalse(a1.equals(a2)); a2.setOffset(2.0); assertTrue(a1.equals(a2)); // advance line Paint a1.setAdvanceLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.black)); assertFalse(a1.equals(a2)); a2.setAdvanceLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.black)); assertTrue(a1.equals(a2)); // advance line Stroke Stroke stroke = new BasicStroke(0.2f); a1.setAdvanceLineStroke(stroke); assertFalse(a1.equals(a2)); a2.setAdvanceLineStroke(stroke); assertTrue(a1.equals(a2)); // advance line Visible a1.setAdvanceLineVisible(!a1.isAdvanceLineVisible()); assertFalse(a1.equals(a2)); a2.setAdvanceLineVisible(a1.isAdvanceLineVisible()); assertTrue(a1.equals(a2)); // cycle bound mapping a1.setBoundMappedToLastCycle(!a1.isBoundMappedToLastCycle()); assertFalse(a1.equals(a2)); a2.setBoundMappedToLastCycle(a1.isBoundMappedToLastCycle()); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test"); CyclicNumberAxis a2 = new CyclicNumberAxis(10, 0, "Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test Axis"); CyclicNumberAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (CyclicNumberAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/DateAxisTests.java0000644000175000017500000012252311173030414027765 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * DateAxisTests.java * ------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Apr-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() method (DG); * 25-Sep-2005 : New tests for bug 1564977 (DG); * 19-Apr-2007 : Added further checks for setMinimumDate() and * setMaximumDate() (DG); * 03-May-2007 : Replaced the tests for the previousStandardDate() method with * new tests that check that the previousStandardDate and the * next standard date do in fact span the reference date (DG); * 25-Nov-2008 : Added testBug2201869 (DG); * */ package org.jfree.chart.axis.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.DateTick; import org.jfree.chart.axis.DateTickMarkPosition; import org.jfree.chart.axis.DateTickUnit; import org.jfree.chart.axis.SegmentedTimeline; import org.jfree.data.time.DateRange; import org.jfree.data.time.Day; import org.jfree.data.time.Hour; import org.jfree.data.time.Millisecond; import org.jfree.data.time.Month; import org.jfree.data.time.Second; import org.jfree.data.time.Year; import org.jfree.ui.RectangleEdge; /** * Tests for the {@link DateAxis} class. */ public class DateAxisTests extends TestCase { static class MyDateAxis extends DateAxis { /** * Creates a new instance. * * @param label the label. */ public MyDateAxis(String label) { super(label); } public Date previousStandardDate(Date d, DateTickUnit unit) { return super.previousStandardDate(d, unit); } } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DateAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DateAxisTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertTrue(a1.equals(a2)); assertFalse(a1.equals(null)); assertFalse(a1.equals("Some non-DateAxis object")); // tickUnit a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); assertFalse(a1.equals(a2)); a2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); assertTrue(a1.equals(a2)); // dateFormatOverride a1.setDateFormatOverride(new SimpleDateFormat("yyyy")); assertFalse(a1.equals(a2)); a2.setDateFormatOverride(new SimpleDateFormat("yyyy")); assertTrue(a1.equals(a2)); // tickMarkPosition a1.setTickMarkPosition(DateTickMarkPosition.END); assertFalse(a1.equals(a2)); a2.setTickMarkPosition(DateTickMarkPosition.END); assertTrue(a1.equals(a2)); // timeline a1.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); assertFalse(a1.equals(a2)); a2.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); assertTrue(a1.equals(a2)); } /** * A test for bug report 1472942. The DateFormat.equals() method is not * checking the range attribute. */ public void test1472942() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertTrue(a1.equals(a2)); // range a1.setRange(new Date(1L), new Date(2L)); assertFalse(a1.equals(a2)); a2.setRange(new Date(1L), new Date(2L)); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = null; try { a2 = (DateAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Test that the setRange() method works. */ public void testSetRange() { DateAxis axis = new DateAxis("Test Axis"); Calendar calendar = Calendar.getInstance(); calendar.set(1999, Calendar.JANUARY, 3); Date d1 = calendar.getTime(); calendar.set(1999, Calendar.JANUARY, 31); Date d2 = calendar.getTime(); axis.setRange(d1, d2); DateRange range = (DateRange) axis.getRange(); assertEquals(d1, range.getLowerDate()); assertEquals(d2, range.getUpperDate()); } /** * Test that the setMaximumDate() method works. */ public void testSetMaximumDate() { DateAxis axis = new DateAxis("Test Axis"); Date date = new Date(); axis.setMaximumDate(date); assertEquals(date, axis.getMaximumDate()); // check that setting the max date to something on or before the // current min date works... Date d1 = new Date(); Date d2 = new Date(d1.getTime() + 1); Date d0 = new Date(d1.getTime() - 1); axis.setMaximumDate(d2); axis.setMinimumDate(d1); axis.setMaximumDate(d1); assertEquals(d0, axis.getMinimumDate()); } /** * Test that the setMinimumDate() method works. */ public void testSetMinimumDate() { DateAxis axis = new DateAxis("Test Axis"); Date d1 = new Date(); Date d2 = new Date(d1.getTime() + 1); axis.setMaximumDate(d2); axis.setMinimumDate(d1); assertEquals(d1, axis.getMinimumDate()); // check that setting the min date to something on or after the // current min date works... Date d3 = new Date(d2.getTime() + 1); axis.setMinimumDate(d2); assertEquals(d3, axis.getMaximumDate()); } /** * Tests two doubles for 'near enough' equality. * * @param d1 number 1. * @param d2 number 2. * @param tolerance maximum tolerance. * * @return A boolean. */ private boolean same(double d1, double d2, double tolerance) { return (Math.abs(d1 - d2) < tolerance); } /** * Test the translation of Java2D values to data values. */ public void testJava2DToValue() { DateAxis axis = new DateAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertTrue(same(y1, 95.8333333, 1.0)); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertTrue(same(y2, 95.8333333, 1.0)); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertTrue(same(x1, 58.125, 1.0)); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertTrue(same(x2, 58.125, 1.0)); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertTrue(same(y3, 54.1666667, 1.0)); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertTrue(same(y4, 54.1666667, 1.0)); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertTrue(same(x3, 91.875, 1.0)); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertTrue(same(x4, 91.875, 1.0)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateAxis a1 = new DateAxis("Test Axis"); DateAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DateAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = a1.equals(a2); assertTrue(b); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 year. */ public void testPreviousStandardDateYearA() { MyDateAxis axis = new MyDateAxis("Year"); Year y2006 = new Year(2006); Year y2007 = new Year(2007); // five dates to check... Date d0 = new Date(y2006.getFirstMillisecond()); Date d1 = new Date(y2006.getFirstMillisecond() + 500L); Date d2 = new Date(y2006.getMiddleMillisecond()); Date d3 = new Date(y2006.getMiddleMillisecond() + 500L); Date d4 = new Date(y2006.getLastMillisecond()); Date end = new Date(y2007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.YEAR, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 years (just for the sake of having a multiple). */ public void testPreviousStandardDateYearB() { MyDateAxis axis = new MyDateAxis("Year"); Year y2006 = new Year(2006); Year y2007 = new Year(2007); // five dates to check... Date d0 = new Date(y2006.getFirstMillisecond()); Date d1 = new Date(y2006.getFirstMillisecond() + 500L); Date d2 = new Date(y2006.getMiddleMillisecond()); Date d3 = new Date(y2006.getMiddleMillisecond() + 500L); Date d4 = new Date(y2006.getLastMillisecond()); Date end = new Date(y2007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.YEAR, 10); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 month. */ public void testPreviousStandardDateMonthA() { MyDateAxis axis = new MyDateAxis("Month"); Month nov2006 = new Month(11, 2006); Month dec2006 = new Month(12, 2006); // five dates to check... Date d0 = new Date(nov2006.getFirstMillisecond()); Date d1 = new Date(nov2006.getFirstMillisecond() + 500L); Date d2 = new Date(nov2006.getMiddleMillisecond()); Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L); Date d4 = new Date(nov2006.getLastMillisecond()); Date end = new Date(dec2006.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 3 months (just for the sake of having a multiple). */ public void testPreviousStandardDateMonthB() { MyDateAxis axis = new MyDateAxis("Month"); Month nov2006 = new Month(11, 2006); Month dec2006 = new Month(12, 2006); // five dates to check... Date d0 = new Date(nov2006.getFirstMillisecond()); Date d1 = new Date(nov2006.getFirstMillisecond() + 500L); Date d2 = new Date(nov2006.getMiddleMillisecond()); Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L); Date d4 = new Date(nov2006.getLastMillisecond()); Date end = new Date(dec2006.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 3); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 day. */ public void testPreviousStandardDateDayA() { MyDateAxis axis = new MyDateAxis("Day"); Day apr12007 = new Day(1, 4, 2007); Day apr22007 = new Day(2, 4, 2007); // five dates to check... Date d0 = new Date(apr12007.getFirstMillisecond()); Date d1 = new Date(apr12007.getFirstMillisecond() + 500L); Date d2 = new Date(apr12007.getMiddleMillisecond()); Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L); Date d4 = new Date(apr12007.getLastMillisecond()); Date end = new Date(apr22007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 7 days (just for the sake of having a multiple). */ public void testPreviousStandardDateDayB() { MyDateAxis axis = new MyDateAxis("Day"); Day apr12007 = new Day(1, 4, 2007); Day apr22007 = new Day(2, 4, 2007); // five dates to check... Date d0 = new Date(apr12007.getFirstMillisecond()); Date d1 = new Date(apr12007.getFirstMillisecond() + 500L); Date d2 = new Date(apr12007.getMiddleMillisecond()); Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L); Date d4 = new Date(apr12007.getLastMillisecond()); Date end = new Date(apr22007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 hour. */ public void testPreviousStandardDateHourA() { MyDateAxis axis = new MyDateAxis("Hour"); Hour h0 = new Hour(12, 1, 4, 2007); Hour h1 = new Hour(13, 1, 4, 2007); // five dates to check... Date d0 = new Date(h0.getFirstMillisecond()); Date d1 = new Date(h0.getFirstMillisecond() + 500L); Date d2 = new Date(h0.getMiddleMillisecond()); Date d3 = new Date(h0.getMiddleMillisecond() + 500L); Date d4 = new Date(h0.getLastMillisecond()); Date end = new Date(h1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 6 hours (just for the sake of having a multiple). */ public void testPreviousStandardDateHourB() { MyDateAxis axis = new MyDateAxis("Hour"); Hour h0 = new Hour(12, 1, 4, 2007); Hour h1 = new Hour(13, 1, 4, 2007); // five dates to check... Date d0 = new Date(h0.getFirstMillisecond()); Date d1 = new Date(h0.getFirstMillisecond() + 500L); Date d2 = new Date(h0.getMiddleMillisecond()); Date d3 = new Date(h0.getMiddleMillisecond() + 500L); Date d4 = new Date(h0.getLastMillisecond()); Date end = new Date(h1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 6); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 second. */ public void testPreviousStandardDateSecondA() { MyDateAxis axis = new MyDateAxis("Second"); Second s0 = new Second(58, 31, 12, 1, 4, 2007); Second s1 = new Second(59, 31, 12, 1, 4, 2007); // five dates to check... Date d0 = new Date(s0.getFirstMillisecond()); Date d1 = new Date(s0.getFirstMillisecond() + 50L); Date d2 = new Date(s0.getMiddleMillisecond()); Date d3 = new Date(s0.getMiddleMillisecond() + 50L); Date d4 = new Date(s0.getLastMillisecond()); Date end = new Date(s1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.SECOND, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 5 seconds (just for the sake of having a multiple). */ public void testPreviousStandardDateSecondB() { MyDateAxis axis = new MyDateAxis("Second"); Second s0 = new Second(58, 31, 12, 1, 4, 2007); Second s1 = new Second(59, 31, 12, 1, 4, 2007); // five dates to check... Date d0 = new Date(s0.getFirstMillisecond()); Date d1 = new Date(s0.getFirstMillisecond() + 50L); Date d2 = new Date(s0.getMiddleMillisecond()); Date d3 = new Date(s0.getMiddleMillisecond() + 50L); Date d4 = new Date(s0.getLastMillisecond()); Date end = new Date(s1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.SECOND, 5); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ public void testPreviousStandardDateMillisecondA() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ public void testPreviousStandardDateMillisecondB() { MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); } /** * A test to reproduce bug 2201869. */ public void testBug2201869() { TimeZone tz = TimeZone.getTimeZone("GMT"); GregorianCalendar c = new GregorianCalendar(tz, Locale.UK); DateAxis axis = new DateAxis("Date", tz, Locale.UK); SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy", Locale.UK); sdf.setCalendar(c); axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, sdf)); Day d1 = new Day(1, 3, 2008); d1.peg(c); Day d2 = new Day(30, 6, 2008); d2.peg(c); axis.setRange(d1.getStart(), d2.getEnd()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100); axis.setTickMarkPosition(DateTickMarkPosition.END); List ticks = axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.BOTTOM); assertEquals(3, ticks.size()); DateTick t1 = (DateTick) ticks.get(0); assertEquals("31-Mar-2008", t1.getText()); DateTick t2 = (DateTick) ticks.get(1); assertEquals("30-Apr-2008", t2.getText()); DateTick t3 = (DateTick) ticks.get(2); assertEquals("31-May-2008", t3.getText()); // now repeat for a vertical axis ticks = axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.LEFT); assertEquals(3, ticks.size()); t1 = (DateTick) ticks.get(0); assertEquals("31-Mar-2008", t1.getText()); t2 = (DateTick) ticks.get(1); assertEquals("30-Apr-2008", t2.getText()); t3 = (DateTick) ticks.get(2); assertEquals("31-May-2008", t3.getText()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/DateTickMarkPositionTests.java0000644000175000017500000001011111173030414032300 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * DateTickMarkPositionTests.java * ------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-May-2004 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.DateTickMarkPosition; /** * Tests for the {@link DateTickMarkPosition} class. */ public class DateTickMarkPositionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DateTickMarkPositionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DateTickMarkPositionTests(String name) { super(name); } /** * Test equals() method. */ public void testEquals() { assertEquals(DateTickMarkPosition.START, DateTickMarkPosition.START); assertEquals(DateTickMarkPosition.MIDDLE, DateTickMarkPosition.MIDDLE); assertEquals(DateTickMarkPosition.END, DateTickMarkPosition.END); assertFalse(DateTickMarkPosition.START.equals(null)); assertFalse(DateTickMarkPosition.START.equals( DateTickMarkPosition.END)); assertFalse(DateTickMarkPosition.MIDDLE.equals( DateTickMarkPosition.END)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DateTickMarkPosition a1 = DateTickMarkPosition.END; DateTickMarkPosition a2 = DateTickMarkPosition.END; assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateTickMarkPosition p1 = DateTickMarkPosition.MIDDLE; DateTickMarkPosition p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (DateTickMarkPosition) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); assertTrue(p1 == p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/DateTickTests.java0000644000175000017500000001365611173030414027761 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * DateTickTests.java * ------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * 25-Sep-2008 : Extended testEquals() to cover new fields (DG); */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.DateTick; import org.jfree.chart.axis.TickType; import org.jfree.ui.TextAnchor; /** * Tests for the {@link DateTick} class. */ public class DateTickTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DateTickTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DateTickTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Date d1 = new Date(0L); Date d2 = new Date(1L); String l1 = "Label 1"; String l2 = "Label 2"; TextAnchor ta1 = TextAnchor.CENTER; TextAnchor ta2 = TextAnchor.BASELINE_LEFT; DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); assertTrue(t1.equals(t2)); t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0); assertTrue(t1.equals(t2)); t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0); assertTrue(t1.equals(t2)); t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0); assertTrue(t1.equals(t2)); t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0); assertTrue(t1.equals(t2)); t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); assertTrue(t1.equals(t2)); t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI); assertFalse(t1.equals(t2)); t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Date d1 = new Date(0L); String l1 = "Label 1"; TextAnchor ta1 = TextAnchor.CENTER; DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0); DateTick t2 = null; try { t2 = (DateTick) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0); DateTick t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (DateTick) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/DateTickUnitTests.java0000644000175000017500000000740411173030414030613 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DateTickUnitTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.DateTickUnit; /** * Tests for the {@link DateTickUnit} class. */ public class DateTickUnitTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DateTickUnitTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DateTickUnitTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DateTickUnit t1 = new DateTickUnit(DateTickUnit.DAY, 1); DateTickUnit t2 = new DateTickUnit(DateTickUnit.DAY, 1); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DateTickUnit t1 = new DateTickUnit(DateTickUnit.DAY, 1); DateTickUnit t2 = new DateTickUnit(DateTickUnit.DAY, 1); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateTickUnit a1 = new DateTickUnit(DateTickUnit.DAY, 7); DateTickUnit a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DateTickUnit) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/ExtendedCategoryAxisTests.java0000644000175000017500000001506411173030414032347 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * ExtendedCategoryAxisTests.java * ------------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.ExtendedCategoryAxis; /** * Tests for the {@link ExtendedCategoryAxis} class. */ public class ExtendedCategoryAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ExtendedCategoryAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ExtendedCategoryAxisTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); assertTrue(a1.equals(a2)); a1.addSubLabel("C1", "C1-sublabel"); assertFalse(a1.equals(a2)); a2.addSubLabel("C1", "C1-sublabel"); assertTrue(a1.equals(a2)); a1.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); assertFalse(a1.equals(a2)); a2.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); assertTrue(a1.equals(a2)); a1.setSubLabelPaint(Color.red); assertFalse(a1.equals(a2)); a2.setSubLabelPaint(Color.red); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = null; try { a2 = (ExtendedCategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check independence a1.addSubLabel("C1", "ABC"); assertFalse(a1.equals(a2)); a2.addSubLabel("C1", "ABC"); assertTrue(a1.equals(a2)); } /** * Confirm that cloning works. This test customises the font and paint * per category label. */ public void testCloning2() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 15)); a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); ExtendedCategoryAxis a2 = null; try { a2 = (ExtendedCategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check that changing a tick label font in a1 doesn't change a2 a1.setTickLabelFont("C1", null); assertFalse(a1.equals(a2)); a2.setTickLabelFont("C1", null); assertTrue(a1.equals(a2)); // check that changing a tick label paint in a1 doesn't change a2 a1.setTickLabelPaint("C1", Color.yellow); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", Color.yellow); assertTrue(a1.equals(a2)); // check that changing a category label tooltip in a1 doesn't change a2 a1.addCategoryLabelToolTip("C1", "XYZ"); assertFalse(a1.equals(a2)); a2.addCategoryLabelToolTip("C1", "XYZ"); assertTrue(a1.equals(a2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); a1.setSubLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); ExtendedCategoryAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (ExtendedCategoryAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/LogAxisTests.java0000644000175000017500000002541111173030414027627 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * LogAxisTests.java * ----------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Jul-2007 : Version 1 (DG); * 08-Apr-2008 : Fixed incorrect testEquals() method (DG); * */ package org.jfree.chart.axis.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.LogAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.RectangleEdge; /** * Tests for the {@link LogAxis} class. */ public class LogAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LogAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LogAxisTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { LogAxis a1 = new LogAxis("Test"); LogAxis a2 = null; try { a2 = (LogAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { LogAxis a1 = new LogAxis("Test"); LogAxis a2 = new LogAxis("Test"); assertTrue(a1.equals(a2)); a1.setBase(2.0); assertFalse(a1.equals(a2)); a2.setBase(2.0); assertTrue(a1.equals(a2)); a1.setSmallestValue(0.1); assertFalse(a1.equals(a2)); a2.setSmallestValue(0.1); assertTrue(a1.equals(a2)); a1.setMinorTickCount(8); assertFalse(a1.equals(a2)); a2.setMinorTickCount(8); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { LogAxis a1 = new LogAxis("Test"); LogAxis a2 = new LogAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } private static final double EPSILON = 0.0000001; /** * Test the translation of Java2D values to data values. */ public void testTranslateJava2DToValue() { LogAxis axis = new LogAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(94.3874312681693, y1, EPSILON); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(94.3874312681693, y2, EPSILON); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(55.961246381405, x1, EPSILON); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(55.961246381405, x2, EPSILON); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(52.9731547179647, y3, EPSILON); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(52.9731547179647, y4, EPSILON); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(89.3475453695651, x3, EPSILON); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(89.3475453695651, x4, EPSILON); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LogAxis a1 = new LogAxis("Test Axis"); LogAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (LogAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * A simple test for the auto-range calculation looking at a * LogAxis used as the range axis for a CategoryPlot. */ public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart( "Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the original dataset is replaced with a new dataset. */ public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(96.59363289248458, axis.getLowerBound(), EPSILON); assertEquals(207.0529847682752, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(895.2712433374774, axis.getLowerBound(), EPSILON); assertEquals(1005.2819262292991, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot( "Test", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false ); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot( "Test", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false ); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); } /** * Some checks for the setLowerBound() method. */ public void testSetLowerBound() { LogAxis axis = new LogAxis("X"); axis.setRange(0.0, 10.0); axis.setLowerBound(5.0); assertEquals(5.0, axis.getLowerBound(), EPSILON); axis.setLowerBound(10.0); assertEquals(10.0, axis.getLowerBound(), EPSILON); assertEquals(11.0, axis.getUpperBound(), EPSILON); } /** * Checks the default value for the tickMarksVisible flag. */ public void testTickMarksVisibleDefault() { LogAxis axis = new LogAxis("Log Axis"); assertTrue(axis.isTickMarksVisible()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/LogarithmicAxisTests.java0000644000175000017500000002325411173030414031353 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * LogarithmicAxisTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 02-Mar-2007 : Added tests from bug report 880597 (DG); * */ package org.jfree.chart.axis.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.LogarithmicAxis; import org.jfree.ui.RectangleEdge; /** * Tests for the {@link LogarithmicAxis} class. */ public class LogarithmicAxisTests extends TestCase { static class MyLogarithmicAxis extends LogarithmicAxis { /** * Creates a new instance. * * @param label the label. */ public MyLogarithmicAxis(String label) { super(label); } /* (non-Javadoc) * @see org.jfree.chart.axis.LogarithmicAxis#switchedLog10(double) */ protected double switchedLog10(double val) { return super.switchedLog10(val); } } /** Tolerance for floating point comparisons */ public static double EPSILON = 0.000001; MyLogarithmicAxis axis = null; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LogarithmicAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LogarithmicAxisTests(String name) { super(name); } /** * Sets up a new axis. * * @throws Exception */ protected void setUp() throws Exception { this.axis = new MyLogarithmicAxis("Value (log)"); this.axis.setAllowNegativesFlag(false); this.axis.setLog10TickLabelsFlag(false); this.axis.setLowerMargin(0.0); this.axis.setUpperMargin(0.0); this.axis.setLowerBound(0.2); this.axis.setUpperBound(100.0); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LogarithmicAxis a1 = new LogarithmicAxis("Test Axis"); LogarithmicAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (LogarithmicAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * Test if adjustedLog10 and adjustedPow10 are inverses of each other */ public void testAdjustedLog10() { checkLogPowRoundTrip(20); checkLogPowRoundTrip(10); checkLogPowRoundTrip(5); checkLogPowRoundTrip(2); checkLogPowRoundTrip(1); checkLogPowRoundTrip(0.5); checkLogPowRoundTrip(0.2); checkLogPowRoundTrip(0.0001); } private void checkLogPowRoundTrip(double value) { assertEquals("log(pow(x)) = x", value, this.axis.adjustedLog10( this.axis.adjustedPow10(value)), EPSILON); assertEquals("pow(log(x)) = x", value, this.axis.adjustedPow10( this.axis.adjustedLog10(value)), EPSILON); } /** * Test if switchedLog10 and switchedPow10 are inverses of each other */ public void testSwitchedLog10() { assertFalse("Axis should not allow negative values", this.axis.getAllowNegativesFlag()); assertEquals(Math.log(0.5) / LogarithmicAxis.LOG10_VALUE, this.axis.switchedLog10(0.5), EPSILON); checkSwitchedLogPowRoundTrip(20); checkSwitchedLogPowRoundTrip(10); checkSwitchedLogPowRoundTrip(5); checkSwitchedLogPowRoundTrip(2); checkSwitchedLogPowRoundTrip(1); checkSwitchedLogPowRoundTrip(0.5); checkSwitchedLogPowRoundTrip(0.2); checkSwitchedLogPowRoundTrip(0.0001); } private void checkSwitchedLogPowRoundTrip(double value) { assertEquals("log(pow(x)) = x", value, this.axis.switchedLog10( this.axis.switchedPow10(value)), EPSILON); assertEquals("pow(log(x)) = x", value, this.axis.switchedPow10( this.axis.switchedLog10(value)), EPSILON); } /** * Test of java2DToValue method. */ public void testJava2DToValue() { Rectangle2D plotArea = new Rectangle2D.Double(22, 33, 500, 500); RectangleEdge edge = RectangleEdge.BOTTOM; // set axis bounds to be both greater than 1 this.axis.setRange(10, 20); checkPointsToValue(edge, plotArea); // check for bounds interval that includes 1 this.axis.setRange(0.5, 10); checkPointsToValue(edge, plotArea); // check for bounds interval that includes 1 this.axis.setRange(0.2, 20); checkPointsToValue(edge, plotArea); // check for both bounds smaller than 1 this.axis.setRange(0.2, 0.7); checkPointsToValue(edge, plotArea); } /** * Test of valueToJava2D method. */ public void testValueToJava2D() { Rectangle2D plotArea = new Rectangle2D.Double(22, 33, 500, 500); RectangleEdge edge = RectangleEdge.BOTTOM; // set axis bounds to be both greater than 1 this.axis.setRange(10, 20); checkPointsToJava2D(edge, plotArea); // check for bounds interval that includes 1 this.axis.setRange(0.5, 10); checkPointsToJava2D(edge, plotArea); // check for bounds interval that includes 1 this.axis.setRange(0.2, 20); checkPointsToJava2D(edge, plotArea); // check for both bounds smaller than 1 this.axis.setRange(0.2, 0.7); checkPointsToJava2D(edge, plotArea); } private void checkPointsToJava2D(RectangleEdge edge, Rectangle2D plotArea) { assertEquals("Left most point on the axis should be beginning of " + "range.", plotArea.getX(), this.axis.valueToJava2D( this.axis.getLowerBound(), plotArea, edge), EPSILON); assertEquals("Right most point on the axis should be end of range.", plotArea.getX() + plotArea.getWidth(), this.axis.valueToJava2D(this.axis.getUpperBound(), plotArea, edge), EPSILON); assertEquals("Center point on the axis should geometric mean of the bounds.", plotArea.getX() + (plotArea.getWidth() / 2), this.axis.valueToJava2D(Math.sqrt(this.axis.getLowerBound() * this.axis.getUpperBound()), plotArea, edge), EPSILON); } /** * Check the translation java2D to value for left, right, and center point. * * @param edge the edge. * @param plotArea the plot area. */ private void checkPointsToValue(RectangleEdge edge, Rectangle2D plotArea) { assertEquals("Right most point on the axis should be end of range.", this.axis.getUpperBound(), this.axis.java2DToValue( plotArea.getX() + plotArea.getWidth(), plotArea, edge), EPSILON); assertEquals("Left most point on the axis should be beginning of " + "range.", this.axis.getLowerBound(), this.axis.java2DToValue(plotArea.getX(), plotArea, edge), EPSILON); assertEquals("Center point on the axis should geometric mean of the " + "bounds.", Math.sqrt(this.axis.getUpperBound() * this.axis.getLowerBound()), this.axis.java2DToValue( plotArea.getX() + (plotArea.getWidth() / 2), plotArea, edge), EPSILON); } /** * Runs all tests in this class. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(LogarithmicAxisTests.class); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/MarkerAxisBandTests.java0000644000175000017500000001205311173030414031112 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * MarkerAxisBandTests.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 07-Jan-2005 : Added tests for equals() and hashCode() (DG); * */ package org.jfree.chart.axis.junit; import java.awt.Font; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.MarkerAxisBand; /** * Tests for the {@link MarkerAxisBand} class. */ public class MarkerAxisBandTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MarkerAxisBandTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MarkerAxisBandTests(String name) { super(name); } /** * Test that the equals() method can distinguish all fields. */ public void testEquals() { Font font1 = new Font("SansSerif", Font.PLAIN, 12); Font font2 = new Font("SansSerif", Font.PLAIN, 14); MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); MarkerAxisBand a2 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); assertEquals(a1, a2); a1 = new MarkerAxisBand(null, 2.0, 1.0, 1.0, 1.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 1.0, 1.0, 1.0, font1); assertTrue(a1.equals(a2)); a1 = new MarkerAxisBand(null, 2.0, 3.0, 1.0, 1.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 1.0, 1.0, font1); assertTrue(a1.equals(a2)); a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 1.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 1.0, font1); assertTrue(a1.equals(a2)); a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font1); assertTrue(a1.equals(a2)); a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font2); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font2); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Font font1 = new Font("SansSerif", Font.PLAIN, 12); MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); MarkerAxisBand a2 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, null); MarkerAxisBand a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (MarkerAxisBand) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/ModuloAxisTests.java0000644000175000017500000001052311173030414030343 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ModuloAxisTests.java * -------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Nov-2007 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.ModuloAxis; import org.jfree.data.Range; /** * Tests for the {@link ModuloAxis} class. */ public class ModuloAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ModuloAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ModuloAxisTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = null; try { a2 = (ModuloAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = new ModuloAxis("Test", new Range(0.0, 1.0)); assertTrue(a1.equals(a2)); a1.setDisplayRange(0.1, 1.1); assertFalse(a1.equals(a2)); a2.setDisplayRange(0.1, 1.1); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = new ModuloAxis("Test", new Range(0.0, 1.0)); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (ModuloAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/MonthDateFormatTests.java0000644000175000017500000001411211173030414031311 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * MonthDateFormatTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-May-2005 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.MonthDateFormat; /** * Some tests for the {@link MonthDateFormat} class. */ public class MonthDateFormatTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MonthDateFormatTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MonthDateFormatTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = new MonthDateFormat(); assertTrue(mf1.equals(mf2)); assertTrue(mf2.equals(mf1)); boolean[] showYear1 = new boolean [12]; showYear1[0] = true; boolean[] showYear2 = new boolean [12]; showYear1[1] = true; // time zone mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.US, 1, showYear1, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.US, 1, showYear1, new SimpleDateFormat("yy")); assertTrue(mf1.equals(mf2)); // locale mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 1, showYear1, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 1, showYear1, new SimpleDateFormat("yy")); assertTrue(mf1.equals(mf2)); // chars mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear1, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear1, new SimpleDateFormat("yy")); assertTrue(mf1.equals(mf2)); // showYear[] mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yy")); assertTrue(mf1.equals(mf2)); // yearFormatter mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yyyy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yyyy")); assertTrue(mf1.equals(mf2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = new MonthDateFormat(); assertTrue(mf1.equals(mf2)); int h1 = mf1.hashCode(); int h2 = mf2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = null; mf2 = (MonthDateFormat) mf1.clone(); assertTrue(mf1 != mf2); assertTrue(mf1.getClass() == mf2.getClass()); assertTrue(mf1.equals(mf2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(mf1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); mf2 = (MonthDateFormat) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertTrue(mf1.equals(mf2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/NumberAxis3DTests.java0000644000175000017500000000604711173030414030531 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * NumberAxis3DTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.NumberAxis3D; /** * Tests for the {@link NumberAxis3D} class. */ public class NumberAxis3DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(NumberAxis3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public NumberAxis3DTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { NumberAxis3D a1 = new NumberAxis3D("Test Axis"); NumberAxis3D a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (NumberAxis3D) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/NumberAxisTests.java0000644000175000017500000004044411173030414030341 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * NumberAxisTests.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 14-Aug-2003 : Added tests for equals() method (DG); * 05-Oct-2004 : Added tests to pick up a bug in the auto-range calculation for * a domain axis on an XYPlot using an XYSeriesCollection (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * 11-Jan-2006 : Fixed testAutoRange2() and testAutoRange3() following changes * to BarRenderer (DG); * 20-Feb-2006 : Added rangeType field to equals() test (DG); * */ package org.jfree.chart.axis.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberTickUnit; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.data.RangeType; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.RectangleEdge; /** * Tests for the {@link NumberAxis} class. */ public class NumberAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(NumberAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public NumberAxisTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = null; try { a2 = (NumberAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = new NumberAxis("Test"); assertTrue(a1.equals(a2)); //private boolean autoRangeIncludesZero; a1.setAutoRangeIncludesZero(false); assertFalse(a1.equals(a2)); a2.setAutoRangeIncludesZero(false); assertTrue(a1.equals(a2)); //private boolean autoRangeStickyZero; a1.setAutoRangeStickyZero(false); assertFalse(a1.equals(a2)); a2.setAutoRangeStickyZero(false); assertTrue(a1.equals(a2)); //private NumberTickUnit tickUnit; a1.setTickUnit(new NumberTickUnit(25.0)); assertFalse(a1.equals(a2)); a2.setTickUnit(new NumberTickUnit(25.0)); assertTrue(a1.equals(a2)); //private NumberFormat numberFormatOverride; a1.setNumberFormatOverride(new DecimalFormat("0.00")); assertFalse(a1.equals(a2)); a2.setNumberFormatOverride(new DecimalFormat("0.00")); assertTrue(a1.equals(a2)); a1.setRangeType(RangeType.POSITIVE); assertFalse(a1.equals(a2)); a2.setRangeType(RangeType.POSITIVE); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = new NumberAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } private static final double EPSILON = 0.0000001; /** * Test the translation of Java2D values to data values. */ public void testTranslateJava2DToValue() { NumberAxis axis = new NumberAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(y1, 95.8333333, EPSILON); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(y2, 95.8333333, EPSILON); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(x1, 58.125, EPSILON); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(x2, 58.125, EPSILON); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(y3, 54.1666667, EPSILON); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(y4, 54.1666667, EPSILON); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(x3, 91.875, EPSILON); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(x4, 91.875, EPSILON); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { NumberAxis a1 = new NumberAxis("Test Axis"); NumberAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (NumberAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. */ public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart( "Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); assertEquals(axis.getLowerBound(), 0.0, EPSILON); assertEquals(axis.getUpperBound(), 210.0, EPSILON); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false. */ public void testAutoRange2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false AND the * original dataset is replaced with a new dataset. */ public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(axis.getLowerBound(), 895.0, EPSILON); assertEquals(axis.getUpperBound(), 1005.0, EPSILON); } /** * A check for the interaction between the 'autoRangeIncludesZero' flag * and the base setting in the BarRenderer. */ public void testAutoRange4() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setIncludeBaseInRange(false); assertEquals(95.0, axis.getLowerBound(), EPSILON); assertEquals(205.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(false); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(false); assertEquals(895.0, axis.getLowerBound(), EPSILON); assertEquals(1005.0, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot( "Test", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false ); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getDomainAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(0.9, axis.getLowerBound(), EPSILON); assertEquals(3.1, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot( "Test", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false ); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(0.9, axis.getLowerBound(), EPSILON); assertEquals(3.1, axis.getUpperBound(), EPSILON); } // /** // * Some checks for the setRangeType() method. // */ // public void testSetRangeType() { // // NumberAxis axis = new NumberAxis("X"); // axis.setRangeType(RangeType.POSITIVE); // assertEquals(RangeType.POSITIVE, axis.getRangeType()); // // // test a change to RangeType.POSITIVE // axis.setRangeType(RangeType.FULL); // axis.setRange(-5.0, 5.0); // axis.setRangeType(RangeType.POSITIVE); // assertEquals(new Range(0.0, 5.0), axis.getRange()); // // axis.setRangeType(RangeType.FULL); // axis.setRange(-10.0, -5.0); // axis.setRangeType(RangeType.POSITIVE); // assertEquals(new Range(0.0, axis.getAutoRangeMinimumSize()), // axis.getRange()); // // // test a change to RangeType.NEGATIVE // axis.setRangeType(RangeType.FULL); // axis.setRange(-5.0, 5.0); // axis.setRangeType(RangeType.NEGATIVE); // assertEquals(new Range(-5.0, 0.0), axis.getRange()); // // axis.setRangeType(RangeType.FULL); // axis.setRange(5.0, 10.0); // axis.setRangeType(RangeType.NEGATIVE); // assertEquals(new Range(-axis.getAutoRangeMinimumSize(), 0.0), // axis.getRange()); // // // try null // boolean pass = false; // try { // axis.setRangeType(null); // } // catch (IllegalArgumentException e) { // pass = true; // } // assertTrue(pass); // } /** * Some checks for the setLowerBound() method. */ public void testSetLowerBound() { NumberAxis axis = new NumberAxis("X"); axis.setRange(0.0, 10.0); axis.setLowerBound(5.0); assertEquals(5.0, axis.getLowerBound(), EPSILON); axis.setLowerBound(10.0); assertEquals(10.0, axis.getLowerBound(), EPSILON); assertEquals(11.0, axis.getUpperBound(), EPSILON); //axis.setRangeType(RangeType.POSITIVE); //axis.setLowerBound(-5.0); //assertEquals(0.0, axis.getLowerBound(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/NumberTickUnitTests.java0000644000175000017500000001075611173030414031172 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * NumberTickUnitTests.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 5-Jul-2005 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.NumberTickUnit; /** * Some tests for the {@link NumberTickUnit} class. */ public class NumberTickUnitTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(NumberTickUnitTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public NumberTickUnitTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); assertTrue(t1.equals(t2)); assertTrue(t2.equals(t1)); t1 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); assertFalse(t1.equals(t2)); t2 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); assertTrue(t1.equals(t2)); t1 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); assertFalse(t1.equals(t2)); t2 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * This is an immutable class so it doesn't need to be cloneable. */ public void testCloning() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); assertFalse(t1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (NumberTickUnit) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/PeriodAxisLabelInfoTests.java0000644000175000017500000001714711173030414032113 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * PeriodAxisLabelInfoTests.java * ----------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jun-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * */ package org.jfree.chart.axis.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.PeriodAxisLabelInfo; import org.jfree.data.time.Day; import org.jfree.data.time.Month; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link PeriodAxisLabelInfo} class. */ public class PeriodAxisLabelInfoTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PeriodAxisLabelInfoTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PeriodAxisLabelInfoTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); assertTrue(info1.equals(info2)); assertTrue(info2.equals(info1)); Class c1 = Day.class; Class c2 = Month.class; DateFormat df1 = new SimpleDateFormat("d"); DateFormat df2 = new SimpleDateFormat("MMM"); RectangleInsets sp1 = new RectangleInsets(1, 1, 1, 1); RectangleInsets sp2 = new RectangleInsets(2, 2, 2, 2); Font lf1 = new Font("SansSerif", Font.PLAIN, 10); Font lf2 = new Font("SansSerif", Font.BOLD, 9); Paint lp1 = Color.black; Paint lp2 = Color.blue; boolean b1 = true; boolean b2 = false; Stroke s1 = new BasicStroke(0.5f); Stroke s2 = new BasicStroke(0.25f); Paint dp1 = Color.red; Paint dp2 = Color.green; info1 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); info2 = new PeriodAxisLabelInfo(c1, df1, sp1, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); assertTrue(info1.equals(info2)); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); assertTrue(info1.equals(info2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); assertTrue(info1.equals(info2)); int h1 = info1.hashCode(); int h2 = info2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = null; try { info2 = (PeriodAxisLabelInfo) info1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(info1 != info2); assertTrue(info1.getClass() == info2.getClass()); assertTrue(info1.equals(info2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(info1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); info2 = (PeriodAxisLabelInfo) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = info1.equals(info2); assertTrue(b); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/PeriodAxisTests.java0000644000175000017500000002553411173030414030336 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PeriodAxisTests.java * -------------------- * (C) Copyright 2004-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jun-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() method (DG); * 08-Apr-2008 : Added test1932146() (DG); * 16-Jan-2009 : Added test2490803() (DG); * 02-Mar-2009 : Added testEqualsWithLocale (DG); * */ package org.jfree.chart.axis.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.SimpleDateFormat; import java.util.GregorianCalendar; import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.PeriodAxis; import org.jfree.chart.axis.PeriodAxisLabelInfo; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.event.AxisChangeListener; import org.jfree.data.Range; import org.jfree.data.time.DateRange; import org.jfree.data.time.Day; import org.jfree.data.time.Minute; import org.jfree.data.time.Month; import org.jfree.data.time.Quarter; import org.jfree.data.time.Second; import org.jfree.data.time.Year; /** * Tests for the {@link PeriodAxis} class. */ public class PeriodAxisTests extends TestCase implements AxisChangeListener { /** The last event received. */ private AxisChangeEvent lastEvent; /** * Receives and records an {@link AxisChangeEvent}. * * @param event the event. */ public void axisChanged(AxisChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PeriodAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PeriodAxisTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = new PeriodAxis("Test"); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); a1.setFirst(new Year(2000)); assertFalse(a1.equals(a2)); a2.setFirst(new Year(2000)); assertTrue(a1.equals(a2)); a1.setLast(new Year(2004)); assertFalse(a1.equals(a2)); a2.setLast(new Year(2004)); assertTrue(a1.equals(a2)); a1.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); assertFalse(a1.equals(a2)); a2.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); assertTrue(a1.equals(a2)); a1.setAutoRangeTimePeriodClass(Quarter.class); assertFalse(a1.equals(a2)); a2.setAutoRangeTimePeriodClass(Quarter.class); assertTrue(a1.equals(a2)); PeriodAxisLabelInfo info[] = new PeriodAxisLabelInfo[1]; info[0] = new PeriodAxisLabelInfo(Month.class, new SimpleDateFormat("MMM")); a1.setLabelInfo(info); assertFalse(a1.equals(a2)); a2.setLabelInfo(info); assertTrue(a1.equals(a2)); a1.setMajorTickTimePeriodClass(Minute.class); assertFalse(a1.equals(a2)); a2.setMajorTickTimePeriodClass(Minute.class); assertTrue(a1.equals(a2)); a1.setMinorTickMarksVisible(!a1.isMinorTickMarksVisible()); assertFalse(a1.equals(a2)); a2.setMinorTickMarksVisible(a1.isMinorTickMarksVisible()); assertTrue(a1.equals(a2)); a1.setMinorTickTimePeriodClass(Minute.class); assertFalse(a1.equals(a2)); a2.setMinorTickTimePeriodClass(Minute.class); assertTrue(a1.equals(a2)); Stroke s = new BasicStroke(1.23f); a1.setMinorTickMarkStroke(s); assertFalse(a1.equals(a2)); a2.setMinorTickMarkStroke(s); assertTrue(a1.equals(a2)); a1.setMinorTickMarkPaint(Color.blue); assertFalse(a1.equals(a2)); a2.setMinorTickMarkPaint(Color.blue); assertTrue(a1.equals(a2)); } /** * Confirm that the equals() method can distinguish the locale field (which * is new in version 1.0.13). */ public void testEqualsWithLocale() { PeriodAxis a1 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.JAPAN); PeriodAxis a2 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.JAPAN); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); a1 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.UK); assertFalse(a1.equals(a2)); a2 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.UK); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = new PeriodAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = null; try { a2 = (PeriodAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // some checks that the clone is independent of the original a1.setLabel("New Label"); assertFalse(a1.equals(a2)); a2.setLabel("New Label"); assertTrue(a1.equals(a2)); a1.setFirst(new Year(1920)); assertFalse(a1.equals(a2)); a2.setFirst(new Year(1920)); assertTrue(a1.equals(a2)); a1.setLast(new Year(2020)); assertFalse(a1.equals(a2)); a2.setLast(new Year(2020)); assertTrue(a1.equals(a2)); PeriodAxisLabelInfo[] info = new PeriodAxisLabelInfo[2]; info[0] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); info[1] = new PeriodAxisLabelInfo(Year.class, new SimpleDateFormat("yyyy")); a1.setLabelInfo(info); assertFalse(a1.equals(a2)); a2.setLabelInfo(info); assertTrue(a1.equals(a2)); a1.setAutoRangeTimePeriodClass(Second.class); assertFalse(a1.equals(a2)); a2.setAutoRangeTimePeriodClass(Second.class); assertTrue(a1.equals(a2)); a1.setTimeZone(new SimpleTimeZone(123, "Bogus")); assertFalse(a1.equals(a2)); a2.setTimeZone(new SimpleTimeZone(123, "Bogus")); assertTrue(a1.equals(a2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PeriodAxis a1 = new PeriodAxis("Test Axis"); PeriodAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (PeriodAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = a1.equals(a2); assertTrue(b); } /** * A test for bug 1932146. */ public void test1932146() { PeriodAxis axis = new PeriodAxis("TestAxis"); axis.addChangeListener(this); this.lastEvent = null; axis.setRange(new DateRange(0L, 1000L)); assertTrue(this.lastEvent != null); } private static final double EPSILON = 0.0000000001; /** * A test for the setRange() method (because the axis shows whole time * periods, the range set for the axis will most likely be wider than the * one specified). */ public void test2490803() { Locale savedLocale = Locale.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault(); try { Locale.setDefault(Locale.FRANCE); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris")); GregorianCalendar c0 = new GregorianCalendar(); c0.clear(); /* c0.set(2009, Calendar.JANUARY, 16, 12, 34, 56); System.out.println(c0.getTime().getTime()); c0.clear(); c0.set(2009, Calendar.JANUARY, 17, 12, 34, 56); System.out.println(c0.getTime().getTime()); */ PeriodAxis axis = new PeriodAxis("TestAxis"); axis.setRange(new Range(1232105696000L, 1232192096000L), false, false); Range r = axis.getRange(); Day d0 = new Day(16, 1, 2009); Day d1 = new Day(17, 1, 2009); assertEquals(d0.getFirstMillisecond(), r.getLowerBound(), EPSILON); assertEquals(d1.getLastMillisecond() + 1.0, r.getUpperBound(), EPSILON); } finally { TimeZone.setDefault(savedTimeZone); Locale.setDefault(savedLocale); } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/QuarterDateFormatTests.java0000644000175000017500000001312511173030414031652 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * QuarterDateFormatTests.java * --------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-May-2005 : Version 1 (DG); * 08-Jun-2007 : Added check for new field in testEquals() (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.QuarterDateFormat; /** * Tests for the {@link QuarterDateFormat} class. */ public class QuarterDateFormatTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(QuarterDateFormatTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public QuarterDateFormatTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); assertTrue(qf1.equals(qf2)); assertTrue(qf2.equals(qf1)); qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"}); assertFalse(qf1.equals(qf2)); qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"}); assertTrue(qf1.equals(qf2)); qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}); assertFalse(qf1.equals(qf2)); qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}); assertTrue(qf1.equals(qf2)); qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}, true); assertFalse(qf1.equals(qf2)); qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}, true); assertTrue(qf1.equals(qf2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); assertTrue(qf1.equals(qf2)); int h1 = qf1.hashCode(); int h2 = qf2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = null; qf2 = (QuarterDateFormat) qf1.clone(); assertTrue(qf1 != qf2); assertTrue(qf1.getClass() == qf2.getClass()); assertTrue(qf1.equals(qf2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(qf1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); qf2 = (QuarterDateFormat) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertTrue(qf1.equals(qf2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/SegmentedTimelineTests.java0000644000175000017500000013172611173030414031672 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * SegmentedTimelineTests.java * ---------------------------- * (C) Copyright 2003-2008, by Bill Kelemen and Contributors. * * Original Author: Bill Kelemen; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 24-May-2003 : Version 1 (BK); * 07-Jan-2005 : Added test for hashCode() method (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.Format; import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Iterator; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.SegmentedTimeline; /** * JUnit Tests for the {@link SegmentedTimeline} class. */ public class SegmentedTimelineTests extends TestCase { /** These constants control test cycles in the validateXXXX methods. */ private static final int TEST_CYCLE_START = 0; /** These constants control test cycles in the validateXXXX methods. */ private static final int TEST_CYCLE_END = 1000; /** These constants control test cycles in the validateXXXX methods. */ private static final int TEST_CYCLE_INC = 55; /** Number of ms in five years */ private static final long FIVE_YEARS = 5 * 365 * SegmentedTimeline.DAY_SEGMENT_SIZE; /** Number format object for ms tests. */ private static final NumberFormat NUMBER_FORMAT = NumberFormat.getNumberInstance(); /** Date format object for Monday through Friday tests. */ private static final SimpleDateFormat DATE_FORMAT; /** Date format object 9:00 AM to 4:00 PM tests. */ private static final SimpleDateFormat DATE_TIME_FORMAT; /** Some ms exceptions for ms testing. */ private static final String[] MS_EXCEPTIONS = {"0", "2", "4", "10", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "47", "58", "100", "101"}; /** Some ms4 exceptions for ms testing. */ private static final String[] MS2_BASE_TIMELINE_EXCEPTIONS = {"0", "8", "16", "24", "32", "40", "48", "56", "64", "72", "80", "88", "96", "104", "112", "120", "128", "136"}; /** US non-trading dates in 2000 through 2002 to test exceptions. */ private static final String[] US_HOLIDAYS = {"2000-01-17", "2000-02-21", "2000-04-21", "2000-05-29", "2000-07-04", "2000-09-04", "2000-11-23", "2000-12-25", "2001-01-01", "2001-01-15", "2001-02-19", "2001-04-13", "2001-05-28", "2001-07-04", "2001-09-03", "2001-09-11", "2001-09-12", "2001-09-13", "2001-09-14", "2001-11-22", "2001-12-25", "2002-01-01", "2002-01-21", "2002-02-18", "2002-03-29", "2002-05-27", "2002-07-04", "2002-09-02", "2002-11-28", "2002-12-25"}; /** Some test exceptions for the fifteen min timeline. */ private static final String[] FIFTEEN_MIN_EXCEPTIONS = { "2000-01-10 09:00:00", "2000-01-10 09:15:00", "2000-01-10 09:30:00", "2000-01-10 09:45:00", "2000-01-10 10:00:00", "2000-01-10 10:15:00", "2000-02-15 09:00:00", "2000-02-15 09:15:00", "2000-02-15 09:30:00", "2000-02-15 09:45:00", "2000-02-15 10:00:00", "2000-02-15 10:15:00", "2000-02-16 11:00:00", "2000-02-16 11:15:00", "2000-02-16 11:30:00", "2000-02-16 11:45:00", "2000-02-16 12:00:00", "2000-02-16 12:15:00", "2000-02-16 12:30:00", "2000-02-16 12:45:00", "2000-02-16 01:00:00", "2000-02-16 01:15:00", "2000-02-16 01:30:00", "2000-02-16 01:45:00", "2000-05-17 11:45:00", "2000-05-17 12:00:00", "2000-05-17 12:15:00", "2000-05-17 12:30:00", "2000-05-17 12:45:00", "2000-05-17 01:00:00", "2000-05-17 01:15:00", "2000-05-17 01:30:00", "2000-05-17 01:45:00", "2000-05-17 02:00:00", "2000-05-17 02:15:00", "2000-05-17 02:30:00", "2000-05-17 02:45:00", "2000-05-17 03:00:00", "2000-05-17 03:15:00", "2000-05-17 03:30:00", "2000-05-17 03:45:00", "2000-05-17 04:00:00"}; /** Our 1-ms test timeline using 5 included and 2 excluded segments. */ private SegmentedTimeline msTimeline; /** * Our 1-ms test timeline (with baseTimeline) using 2 included and 2 * excluded segments. */ private SegmentedTimeline ms2Timeline; /** * Our 4-ms test base timeline for ms2Timeline using 1 included and 1 * excluded segments */ private SegmentedTimeline ms2BaseTimeline; /** Our test Monday through Friday test timeline. */ private SegmentedTimeline mondayFridayTimeline; /** Our 9:00 AM to 4:00 PM fifteen minute timeline. */ private SegmentedTimeline fifteenMinTimeline; /** ms from 1970-01-01 to first monday after 2001-01-01. */ private Calendar monday; /** ms from 1970-01-01 to 9 am first monday after 2001-01-01. */ private Calendar monday9am; /** Static initialization block. */ static { DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); DATE_FORMAT.setTimeZone(SegmentedTimeline.NO_DST_TIME_ZONE); DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DATE_TIME_FORMAT.setTimeZone(SegmentedTimeline.NO_DST_TIME_ZONE); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SegmentedTimelineTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SegmentedTimelineTests(String name) { super(name); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @throws Exception if there is a problem. */ protected void setUp() throws Exception { // setup our test timelines // // Legend for comments below: // = Segments included in the final timeline // EE = Excluded segments via timeline rules // xx = Exception segments inherited from base timeline exclusions // 1-ms test timeline using 5 included and 2 excluded segments. // // timeline start time = 0 // | // v // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 .. // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+.. // | | | | | |EE|EE| | | | | |EE|EE| | | | | | |EE|EE| <-- msTimeline // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+.. // \_________ ________/ \_/ // \/ | // segment group segment size = 1 ms // this.msTimeline = new SegmentedTimeline(1, 5, 2); this.msTimeline.setStartTime(0); // 4-ms test base timeline for ms2Timeline using 1 included and 1 // excluded segments // // timeline start time = 0 // | // v // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // | | | | |EE|EE|EE|EE| | | | |EE|EE|EE|EE| | | | | <-- ms2BaseTimeline // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // \__________ _________/ \____ _____/ // \/ \/ // segment group segment size = 4 ms // this.ms2BaseTimeline = new SegmentedTimeline(4, 1, 1); this.ms2BaseTimeline.setStartTime(0); // 1-ms test timeline (with a baseTimeline) using 2 included and 2 // excluded segments centered inside each base segment // // The ms2Timeline without a base would look like this: // // timeline start time = 1 // | // v // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // |EE| | |EE|EE| | |EE|EE| | |EE|EE| | |EE|EE| | |EE| <-- ms2Timeline // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // \____ _____/ \_/ // \/ | // segment group segment size = 1 ms // // With the base timeline some originally included segments are now // removed (see "xx" below): // // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // |EE| | |EE|EE|xx|xx|EE|EE| | |EE|EE|xx|xx|EE|EE| | |EE| <-- ms2Timeline // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // | | | | |EE|EE|EE|EE| | | | |EE|EE|EE|EE| | | | | <-- ms2BaseTimeline // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... // this.ms2Timeline = new SegmentedTimeline(1, 2, 2); this.ms2Timeline.setStartTime(1); this.ms2Timeline.setBaseTimeline(this.ms2BaseTimeline); // test monday though friday timeline this.mondayFridayTimeline = SegmentedTimeline.newMondayThroughFridayTimeline(); // test 9am-4pm Monday through Friday timeline this.fifteenMinTimeline = SegmentedTimeline.newFifteenMinuteTimeline(); // find first Monday after 2001-01-01 Calendar cal = new GregorianCalendar( SegmentedTimeline.NO_DST_TIME_ZONE); cal.set(2001, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { cal.add(Calendar.DATE, 1); } this.monday = (Calendar) cal.clone(); // calculate 9am on the first Monday after 2001-01-01 cal.add(Calendar.HOUR, 9); this.monday9am = (Calendar) cal.clone(); } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @throws Exception if there is a problem. */ protected void tearDown() throws Exception { // does nothing } ////////////////////////////////////////////////////////////////////////// // test construction process ////////////////////////////////////////////////////////////////////////// /** * Tests that the new method that created the msTimeline segmented * timeline did so correctly. */ public void testMsSegmentedTimeline() { // verify attributes set during object construction assertEquals(1, this.msTimeline.getSegmentSize()); assertEquals(0, this.msTimeline.getStartTime()); assertEquals(5, this.msTimeline.getSegmentsIncluded()); assertEquals(2, this.msTimeline.getSegmentsExcluded()); } /** * Tests that the new method that created the ms2Timeline segmented * timeline did so correctly. */ public void testMs2SegmentedTimeline() { // verify attributes set during object construction assertEquals(1, this.ms2Timeline.getSegmentSize()); assertEquals(1, this.ms2Timeline.getStartTime()); assertEquals(2, this.ms2Timeline.getSegmentsIncluded()); assertEquals(2, this.ms2Timeline.getSegmentsExcluded()); assertEquals(this.ms2BaseTimeline, this.ms2Timeline.getBaseTimeline()); } /** * Tests that the factory method that creates Monday through Friday * segmented timeline does so correctly. */ public void testMondayThroughFridaySegmentedTimeline() { // verify attributes set during object construction assertEquals(SegmentedTimeline.DAY_SEGMENT_SIZE, this.mondayFridayTimeline.getSegmentSize()); assertEquals(SegmentedTimeline.FIRST_MONDAY_AFTER_1900, this.mondayFridayTimeline.getStartTime()); assertEquals(5, this.mondayFridayTimeline.getSegmentsIncluded()); assertEquals(2, this.mondayFridayTimeline.getSegmentsExcluded()); } /** * Tests that the factory method that creates a 15-min 9:00 AM 4:00 PM * segmented axis does so correctly. */ public void testFifteenMinSegmentedTimeline() { assertEquals(SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE, this.fifteenMinTimeline.getSegmentSize()); assertEquals(SegmentedTimeline.FIRST_MONDAY_AFTER_1900 + 36 * this.fifteenMinTimeline.getSegmentSize(), this.fifteenMinTimeline.getStartTime()); assertEquals(28, this.fifteenMinTimeline.getSegmentsIncluded()); assertEquals(68, this.fifteenMinTimeline.getSegmentsExcluded()); } ////////////////////////////////////////////////////////////////////////// // test one-segment and adjacent segments ////////////////////////////////////////////////////////////////////////// /** * Tests one segment of the ms timeline. Internal indices * inside one segment as well as adjacent segments are verified. */ public void testMsSegment() { verifyOneSegment(this.msTimeline); } /** * Tests one segment of the ms timeline. Internal indices * inside one segment as well as adjacent segments are verified. */ public void testMs2Segment() { verifyOneSegment(this.ms2Timeline); } /** * Tests one segment of the Monday through Friday timeline. Internal indices * inside one segment as well as adjacent segments are verified. */ public void testMondayThroughFridaySegment() { verifyOneSegment(this.mondayFridayTimeline); } /** * Tests one segment of the Fifteen timeline. Internal indices * inside one segment as well as adjacent segments are verified. */ public void testFifteenMinSegment() { verifyOneSegment(this.fifteenMinTimeline); } /** * Tests one segment of the Monday through Friday timeline. Internal indices * inside one segment as well as adjacent segments are verified. * @param timeline the timeline to use for verifications. */ public void verifyOneSegment(SegmentedTimeline timeline) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { // get two consecutive segments for various tests SegmentedTimeline.Segment segment1 = timeline.getSegment( this.monday.getTime().getTime() + testCycle); SegmentedTimeline.Segment segment2 = timeline.getSegment( segment1.getSegmentEnd() + 1); // verify segments are consecutive and correct assertEquals(segment1.getSegmentNumber() + 1, segment2.getSegmentNumber()); assertEquals(segment1.getSegmentEnd() + 1, segment2.getSegmentStart()); assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize() - 1, segment1.getSegmentEnd()); assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize(), segment2.getSegmentStart()); assertEquals(segment1.getSegmentEnd() + timeline.getSegmentSize(), segment2.getSegmentEnd()); // verify various indices inside a segment are the same segment long delta; if (timeline.getSegmentSize() > 1000000) { delta = timeline.getSegmentSize() / 10000; } else if (timeline.getSegmentSize() > 100000) { delta = timeline.getSegmentSize() / 1000; } else if (timeline.getSegmentSize() > 10000) { delta = timeline.getSegmentSize() / 100; } else if (timeline.getSegmentSize() > 1000) { delta = timeline.getSegmentSize() / 10; } else if (timeline.getSegmentSize() > 100) { delta = timeline.getSegmentSize() / 5; } else { delta = 1; } long start = segment1.getSegmentStart() + delta; long end = segment1.getSegmentStart() + timeline.getSegmentSize() - 1; SegmentedTimeline.Segment lastSeg = timeline.getSegment( segment1.getSegmentStart()); SegmentedTimeline.Segment seg; for (long i = start; i < end; i += delta) { seg = timeline.getSegment(i); assertEquals(lastSeg.getSegmentNumber(), seg.getSegmentNumber()); assertEquals(lastSeg.getSegmentStart(), seg.getSegmentStart()); assertEquals(lastSeg.getSegmentEnd(), seg.getSegmentEnd()); assertTrue(lastSeg.getMillisecond() < seg.getMillisecond()); lastSeg = seg; } // try next segment seg = timeline.getSegment(end + 1); assertEquals(segment2.getSegmentNumber(), seg.getSegmentNumber()); assertEquals(segment2.getSegmentStart(), seg.getSegmentStart()); assertEquals(segment2.getSegmentEnd(), seg.getSegmentEnd()); } } ////////////////////////////////////////////////////////////////////////// // test inc methods ////////////////////////////////////////////////////////////////////////// /** * Tests the inc methods on the msTimeline. */ public void testMsInc() { verifyInc(this.msTimeline); } /** * Tests the inc methods on the msTimeline. */ public void testMs2Inc() { verifyInc(this.ms2Timeline); } /** * Tests the inc methods on the Monday through Friday timeline. */ public void testMondayThroughFridayInc() { verifyInc(this.mondayFridayTimeline); } /** * Tests the inc methods on the Fifteen minute timeline. */ public void testFifteenMinInc() { verifyInc(this.fifteenMinTimeline); } /** * Tests the inc methods. * @param timeline the timeline to use for verifications. */ public void verifyInc(SegmentedTimeline timeline) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { long m = timeline.getSegmentSize(); SegmentedTimeline.Segment segment = timeline.getSegment(testCycle); SegmentedTimeline.Segment seg1 = segment.copy(); for (int i = 0; i < 1000; i++) { // test inc() method SegmentedTimeline.Segment seg2 = seg1.copy(); seg2.inc(); if ((seg1.getSegmentEnd() + 1) != seg2.getSegmentStart()) { // logically consecutive segments non-physically consecutive // (with non-contained time in between) assertTrue(!timeline.containsDomainRange( seg1.getSegmentEnd() + 1, seg2.getSegmentStart() - 1)); assertEquals(0, (seg2.getSegmentStart() - seg1.getSegmentStart()) % m); assertEquals(0, (seg2.getSegmentEnd() - seg1.getSegmentEnd()) % m); assertEquals(0, (seg2.getMillisecond() - seg1.getMillisecond()) % m); } else { // physically consecutive assertEquals(seg1.getSegmentStart() + m, seg2.getSegmentStart()); assertEquals(seg1.getSegmentEnd() + m, seg2.getSegmentEnd()); assertEquals(seg1.getMillisecond() + m, seg2.getMillisecond()); } // test inc(n) method SegmentedTimeline.Segment seg3 = seg1.copy(); SegmentedTimeline.Segment seg4 = seg1.copy(); for (int j = 0; j < i; j++) { seg3.inc(); } seg4.inc(i); assertEquals(seg3.getSegmentStart(), seg4.getSegmentStart()); assertEquals(seg3.getSegmentEnd(), seg4.getSegmentEnd()); assertEquals(seg3.getMillisecond(), seg4.getMillisecond()); // go to another segment to continue test seg1.inc(); } } } ////////////////////////////////////////////////////////////////////////// // main include and excluded segments ////////////////////////////////////////////////////////////////////////// /** * Tests that the msTimeline's included and excluded * segments are being calculated correctly. */ public void testMsIncludedAndExcludedSegments() { verifyIncludedAndExcludedSegments(this.msTimeline, 0); } /** * Tests that the ms2Timeline's included and excluded * segments are being calculated correctly. */ public void testMs2IncludedAndExcludedSegments() { verifyIncludedAndExcludedSegments(this.ms2Timeline, 1); } /** * Tests that the Monday through Friday timeline's included and excluded * segments are being calculated correctly. The test is performed starting * on the first monday after 1/1/2000 and for five years. */ public void testMondayThroughFridayIncludedAndExcludedSegments() { verifyIncludedAndExcludedSegments(this.mondayFridayTimeline, this.monday.getTime().getTime()); } /** * Tests that the Fifteen-Min timeline's included and excluded * segments are being calculated correctly. The test is performed starting * on the first monday after 1/1/2000 and for five years. */ public void testFifteenMinIncludedAndExcludedSegments() { verifyIncludedAndExcludedSegments(this.fifteenMinTimeline, this.monday9am.getTime().getTime()); } /** * Tests that a timeline's included and excluded segments are being * calculated correctly. * * @param timeline the timeline to verify * @param n the first segment number to start verifying */ public void verifyIncludedAndExcludedSegments(SegmentedTimeline timeline, long n) { // clear any exceptions in this timeline timeline.setExceptionSegments(new java.util.ArrayList()); // test some included and excluded segments SegmentedTimeline.Segment segment = timeline.getSegment(n); for (int i = 0; i < 1000; i++) { int d = (i % timeline.getGroupSegmentCount()); if (d < timeline.getSegmentsIncluded()) { // should be an included segment assertTrue(segment.inIncludeSegments()); assertTrue(!segment.inExcludeSegments()); assertTrue(!segment.inExceptionSegments()); } else { // should be an excluded segment assertTrue(!segment.inIncludeSegments()); assertTrue(segment.inExcludeSegments()); assertTrue(!segment.inExceptionSegments()); } segment.inc(); } } ////////////////////////////////////////////////////////////////////////// // test exception segments ////////////////////////////////////////////////////////////////////////// /** * Tests methods related to exceptions methods in the msTimeline. * * @throws ParseException if there is a parsing error. */ public void testMsExceptionSegments() throws ParseException { verifyExceptionSegments(this.msTimeline, MS_EXCEPTIONS, NUMBER_FORMAT); } /** * Tests methods related to exceptions methods in the ms2BaseTimeline. * * @throws ParseException if there is a parsing error. */ public void testMs2BaseTimelineExceptionSegments() throws ParseException { verifyExceptionSegments(this.ms2BaseTimeline, MS2_BASE_TIMELINE_EXCEPTIONS, NUMBER_FORMAT); } /** * Tests methods related to exceptions methods in the mondayFridayTimeline. * * @throws ParseException if there is a parsing error. */ public void testMondayThoughFridayExceptionSegments() throws ParseException { verifyExceptionSegments(this.mondayFridayTimeline, US_HOLIDAYS, DATE_FORMAT); } /** * Tests methods related to exceptions methods in the fifteenMinTimeline. * * @throws ParseException if there is a parsing error. */ public void testFifteenMinExceptionSegments() throws ParseException { verifyExceptionSegments(this.fifteenMinTimeline, FIFTEEN_MIN_EXCEPTIONS, DATE_TIME_FORMAT); } /** * Tests methods related to adding exceptions. * * @param timeline the timeline to verify * @param exceptionString array of Strings that represent the exceptions * @param fmt Format object that can parse the exceptionString strings * * @throws ParseException if there is a parsing error. */ public void verifyExceptionSegments(SegmentedTimeline timeline, String[] exceptionString, Format fmt) throws ParseException { // fill in the exceptions long[] exception = verifyFillInExceptions(timeline, exceptionString, fmt); int m = exception.length; // verify list of exceptions assertEquals(exception.length, timeline.getExceptionSegments().size()); SegmentedTimeline.Segment lastSegment = timeline.getSegment( exception[m - 1]); for (int i = 0; i < m; i++) { SegmentedTimeline.Segment segment = timeline.getSegment( exception[i]); assertTrue(segment.inExceptionSegments()); // include current exception and last one assertEquals(m - i, timeline.getExceptionSegmentCount( segment.getSegmentStart(), lastSegment.getSegmentEnd())); // exclude current exception and last one assertEquals(Math.max(0, m - i - 2), timeline.getExceptionSegmentCount(exception[i] + 1, exception[m - 1] - 1)); } } ////////////////////////////////////////////////////////////////////////// // test timeline translations ////////////////////////////////////////////////////////////////////////// /** * Tests translations for 1-ms timeline * * @throws ParseException if there is a parsing error. */ public void testMsTranslations() throws ParseException { verifyFillInExceptions(this.msTimeline, MS_EXCEPTIONS, NUMBER_FORMAT); verifyTranslations(this.msTimeline, 0); } /** * Tests translations for the base timeline used for the ms2Timeline * * @throws ParseException if there is a parsing error. */ public void testMs2BaseTimelineTranslations() throws ParseException { verifyFillInExceptions(this.ms2BaseTimeline, MS2_BASE_TIMELINE_EXCEPTIONS, NUMBER_FORMAT); verifyTranslations(this.ms2BaseTimeline, 0); } /** * Tests translations for the Monday through Friday timeline * * @throws ParseException if there is a parsing error. */ public void testMs2Translations() throws ParseException { fillInBaseTimelineExceptions(this.ms2Timeline, MS2_BASE_TIMELINE_EXCEPTIONS, NUMBER_FORMAT); fillInBaseTimelineExclusionsAsExceptions(this.ms2Timeline, 0, 5000); verifyTranslations(this.ms2Timeline, 1); } /** * Tests translations for the Monday through Friday timeline * * @throws ParseException if there is a parsing error. */ public void textMondayThroughFridayTranslations() throws ParseException { verifyFillInExceptions(this.mondayFridayTimeline, US_HOLIDAYS, DATE_FORMAT); verifyTranslations(this.mondayFridayTimeline, this.monday.getTime().getTime()); } /** * Tests translations for the Fifteen Min timeline * * @throws ParseException if there is a parsing error. */ public void testFifteenMinTranslations() throws ParseException { verifyFillInExceptions(this.fifteenMinTimeline, FIFTEEN_MIN_EXCEPTIONS, DATE_TIME_FORMAT); fillInBaseTimelineExceptions(this.fifteenMinTimeline, US_HOLIDAYS, DATE_FORMAT); fillInBaseTimelineExclusionsAsExceptions(this.fifteenMinTimeline, this.monday9am.getTime().getTime(), this.monday9am.getTime().getTime() + FIVE_YEARS); verifyTranslations(this.fifteenMinTimeline, this.monday9am.getTime().getTime()); } /** * Tests translations between timelines. * * @param timeline the timeline to use for verifications. * @param startTest ??. */ public void verifyTranslations(SegmentedTimeline timeline, long startTest) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { long millisecond = startTest + testCycle * timeline.getSegmentSize(); SegmentedTimeline.Segment segment = timeline.getSegment( millisecond); for (int i = 0; i < 1000; i++) { long translatedValue = timeline.toTimelineValue( segment.getMillisecond()); long newValue = timeline.toMillisecond(translatedValue); if (segment.inExcludeSegments() || segment.inExceptionSegments()) { // the reverse transformed value will be in the start of the // next non-excluded and non-exception segment SegmentedTimeline.Segment tempSegment = segment.copy(); tempSegment.moveIndexToStart(); do { tempSegment.inc(); } while (!tempSegment.inIncludeSegments()); assertEquals(tempSegment.getMillisecond(), newValue); } else { assertEquals(segment.getMillisecond(), newValue); } segment.inc(); } } } ////////////////////////////////////////////////////////////////////////// // test serialization ////////////////////////////////////////////////////////////////////////// /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { verifySerialization(this.msTimeline); verifySerialization(this.ms2Timeline); verifySerialization(this.ms2BaseTimeline); verifySerialization(SegmentedTimeline.newMondayThroughFridayTimeline()); verifySerialization(SegmentedTimeline.newFifteenMinuteTimeline()); } /** * Tests serialization of an instance. * @param a1 The timeline to verify the serialization */ private void verifySerialization(SegmentedTimeline a1) { SegmentedTimeline a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (SegmentedTimeline) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * Adds an array of exceptions to the timeline. The timeline exception list * is first cleared. * @param timeline The timeline where the exceptions will be stored * @param exceptionString The exceptions to load * @param fmt The date formatter to use to parse each exceptions[i] value * @throws ParseException If there is any exception parsing each * exceptions[i] value. * @return An array of Dates[] containing each exception date. */ private long[] verifyFillInExceptions(SegmentedTimeline timeline, String[] exceptionString, Format fmt) throws ParseException { // make sure there are no exceptions timeline.setExceptionSegments(new java.util.ArrayList()); assertEquals(0, timeline.getExceptionSegments().size()); // add our exceptions and store locally in ArrayList of Longs ArrayList exceptionList = new ArrayList(); for (int i = 0; i < exceptionString.length; i++) { long e; if (fmt instanceof NumberFormat) { e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue(); } else { e = timeline.getTime(((SimpleDateFormat) fmt) .parse(exceptionString[i])); } // only add an exception if it is currently an included segment SegmentedTimeline.Segment segment = timeline.getSegment(e); if (segment.inIncludeSegments()) { timeline.addException(e); exceptionList.add(new Long(e)); assertEquals(exceptionList.size(), timeline.getExceptionSegments().size()); assertTrue(segment.inExceptionSegments()); } } // make array of exceptions long[] exception = new long[exceptionList.size()]; int i = 0; for (Iterator iter = exceptionList.iterator(); iter.hasNext();) { Long l = (Long) iter.next(); exception[i++] = l.longValue(); } return (exception); } /** * Adds an array of exceptions relative to the base timeline. * * @param timeline The timeline where the exceptions will be stored * @param exceptionString The exceptions to load * @param fmt The date formatter to use to parse each exceptions[i] value * @throws ParseException If there is any exception parsing each * exceptions[i] value. */ private void fillInBaseTimelineExceptions(SegmentedTimeline timeline, String[] exceptionString, Format fmt) throws ParseException { SegmentedTimeline baseTimeline = timeline.getBaseTimeline(); for (int i = 0; i < exceptionString.length; i++) { long e; if (fmt instanceof NumberFormat) { e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue(); } else { e = timeline.getTime(((SimpleDateFormat) fmt) .parse(exceptionString[i])); } timeline.addBaseTimelineException(e); // verify all timeline segments included in the // baseTimeline.segment are now exceptions SegmentedTimeline.Segment segment1 = baseTimeline.getSegment(e); for (SegmentedTimeline.Segment segment2 = timeline.getSegment(segment1.getSegmentStart()); segment2.getSegmentStart() <= segment1.getSegmentEnd(); segment2.inc()) { if (!segment2.inExcludeSegments()) { assertTrue(segment2.inExceptionSegments()); } } } } /** * Adds new exceptions to a timeline. The exceptions are the excluded * segments from its base timeline. * * @param timeline the timeline. * @param from the start. * @param to the end. */ private void fillInBaseTimelineExclusionsAsExceptions( SegmentedTimeline timeline, long from, long to) { // add the base timeline exclusions as timeline's esceptions timeline.addBaseTimelineExclusions(from, to); // validate base timeline exclusions added as timeline's esceptions for (SegmentedTimeline.Segment segment1 = timeline.getBaseTimeline() .getSegment(from); segment1.getSegmentStart() <= to; segment1.inc()) { if (segment1.inExcludeSegments()) { // verify all timeline segments included in the // baseTimeline.segment are now exceptions for (SegmentedTimeline.Segment segment2 = timeline.getSegment( segment1.getSegmentStart()); segment2.getSegmentStart() <= segment1.getSegmentEnd(); segment2.inc()) { if (!segment2.inExcludeSegments()) { assertTrue(segment2.inExceptionSegments()); } } } } } /** * Confirm that cloning works. */ public void testCloning() { SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); SegmentedTimeline l2 = null; try { l2 = (SegmentedTimeline) l1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(l1 != l2); assertTrue(l1.getClass() == l2.getClass()); assertTrue(l1.equals(l2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); SegmentedTimeline l2 = new SegmentedTimeline(1000, 5, 2); assertTrue(l1.equals(l2)); l1 = new SegmentedTimeline(1000, 5, 2); l2 = new SegmentedTimeline(1001, 5, 2); assertFalse(l1.equals(l2)); l1 = new SegmentedTimeline(1000, 5, 2); l2 = new SegmentedTimeline(1000, 4, 2); assertFalse(l1.equals(l2)); l1 = new SegmentedTimeline(1000, 5, 2); l2 = new SegmentedTimeline(1000, 5, 1); assertFalse(l1.equals(l2)); l1 = new SegmentedTimeline(1000, 5, 2); l2 = new SegmentedTimeline(1000, 5, 2); // start time... l1.setStartTime(1234L); assertFalse(l1.equals(l2)); l2.setStartTime(1234L); assertTrue(l1.equals(l2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); SegmentedTimeline l2 = new SegmentedTimeline(1000, 5, 2); assertTrue(l1.equals(l2)); int h1 = l1.hashCode(); int h2 = l2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); SegmentedTimeline l2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(l1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); l2 = (SegmentedTimeline) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = l1.equals(l2); assertTrue(b); } ////////////////////////////////////////////////////////////////////////// // utility methods ////////////////////////////////////////////////////////////////////////// /** * Tests a basic segmented timeline. */ public void testBasicSegmentedTimeline() { SegmentedTimeline stl = new SegmentedTimeline(10, 2, 3); stl.setStartTime(946684800000L); // 1-Jan-2000 assertFalse(stl.containsDomainValue(946684799999L)); assertTrue(stl.containsDomainValue(946684800000L)); assertTrue(stl.containsDomainValue(946684800019L)); assertFalse(stl.containsDomainValue(946684800020L)); assertFalse(stl.containsDomainValue(946684800049L)); assertTrue(stl.containsDomainValue(946684800050L)); assertTrue(stl.containsDomainValue(946684800069L)); assertFalse(stl.containsDomainValue(946684800070L)); assertFalse(stl.containsDomainValue(946684800099L)); assertTrue(stl.containsDomainValue(946684800100L)); assertEquals(0, stl.toTimelineValue(946684800000L)); assertEquals(19, stl.toTimelineValue(946684800019L)); assertEquals(20, stl.toTimelineValue(946684800020L)); assertEquals(20, stl.toTimelineValue(946684800049L)); assertEquals(20, stl.toTimelineValue(946684800050L)); assertEquals(39, stl.toTimelineValue(946684800069L)); assertEquals(40, stl.toTimelineValue(946684800070L)); assertEquals(40, stl.toTimelineValue(946684800099L)); assertEquals(40, stl.toTimelineValue(946684800100L)); assertEquals(946684800000L, stl.toMillisecond(0)); assertEquals(946684800019L, stl.toMillisecond(19)); assertEquals(946684800050L, stl.toMillisecond(20)); assertEquals(946684800069L, stl.toMillisecond(39)); assertEquals(946684800100L, stl.toMillisecond(40)); } /** * Tests a basic time line with one exception. */ public void testSegmentedTimelineWithException1() { SegmentedTimeline stl = new SegmentedTimeline(10, 2, 3); stl.setStartTime(946684800000L); // 1-Jan-2000 stl.addException(946684800050L); assertFalse(stl.containsDomainValue(946684799999L)); assertTrue(stl.containsDomainValue(946684800000L)); assertTrue(stl.containsDomainValue(946684800019L)); assertFalse(stl.containsDomainValue(946684800020L)); assertFalse(stl.containsDomainValue(946684800049L)); assertFalse(stl.containsDomainValue(946684800050L)); assertFalse(stl.containsDomainValue(946684800059L)); assertTrue(stl.containsDomainValue(946684800060L)); assertTrue(stl.containsDomainValue(946684800069L)); assertFalse(stl.containsDomainValue(946684800070L)); assertFalse(stl.containsDomainValue(946684800099L)); assertTrue(stl.containsDomainValue(946684800100L)); //long v = stl.toTimelineValue(946684800020L); assertEquals(0, stl.toTimelineValue(946684800000L)); assertEquals(19, stl.toTimelineValue(946684800019L)); assertEquals(20, stl.toTimelineValue(946684800020L)); assertEquals(20, stl.toTimelineValue(946684800049L)); assertEquals(20, stl.toTimelineValue(946684800050L)); assertEquals(29, stl.toTimelineValue(946684800069L)); assertEquals(30, stl.toTimelineValue(946684800070L)); assertEquals(30, stl.toTimelineValue(946684800099L)); assertEquals(30, stl.toTimelineValue(946684800100L)); assertEquals(946684800000L, stl.toMillisecond(0)); assertEquals(946684800019L, stl.toMillisecond(19)); assertEquals(946684800060L, stl.toMillisecond(20)); assertEquals(946684800069L, stl.toMillisecond(29)); assertEquals(946684800100L, stl.toMillisecond(30)); } ////////////////////////////////////////////////////////////////////////// // main method only for debug ////////////////////////////////////////////////////////////////////////// /** * Only use to debug JUnit suite. * * @param args ignored. * * @throws Exception if there is some problem. */ public static void main(String[] args) throws Exception { SegmentedTimelineTests test = new SegmentedTimelineTests("Test"); test.setUp(); test.testMondayThoughFridayExceptionSegments(); test.tearDown(); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/SegmentedTimelineTests2.java0000644000175000017500000004114511173030414031747 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * SegmentedTimelineTests2.java * ---------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Aug-2004 : Added standard header (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.axis.junit; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; import junit.framework.TestCase; import org.jfree.chart.axis.SegmentedTimeline; /** * Some tests for the {@link SegmentedTimeline} class. */ public class SegmentedTimelineTests2 extends TestCase { /** * Constructor */ public SegmentedTimelineTests2() { super(); } /** * Test 1 checks 9am Friday 26 March 2004 converts to a timeline value and * back again correctly. This is prior to Daylight Saving. */ public void test1() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Locale savedLocale = Locale.getDefault(); Locale.setDefault(Locale.UK); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 26); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); assertTrue("test1", value == (900000 * 34) && date.getTime() == reverted.getTime()); TimeZone.setDefault(savedZone); Locale.setDefault(savedLocale); } /** * Test 2 checks 9.15am Friday 26 March 2004 converts to a timeline value * and back again correctly. This is prior to Daylight Saving. */ public void test2() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 26); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 15); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); assertTrue( "test2", value == (900000 * 34 + 900000) && date.getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Test 3 checks 9.30am Friday 26 March 2004 converts to a timeline value * and back again correctly. This is prior to Daylight Saving. */ public void test3() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 26); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); assertTrue( "test2", value == (900000 * 34 + 900000 * 2) && date.getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Test 4 checks 9.30am Friday 26 March 2004 (+ 1 millisecond) converts to * a timeline value and back again correctly. This is prior to Daylight * Saving. */ public void test4() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 26); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 1); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); assertTrue( "test4", value == (900000 * 34 + 900000 * 2 + 1) && date.getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Test 5 checks 5.30pm Thursday 25 March 2004 converts to a timeline * value and back again correctly. As it is in the excluded segment, we * expect it to map to 9am, Friday 26 March 2004. This is prior to * Daylight Saving. */ public void test5() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 25); cal.set(Calendar.HOUR_OF_DAY, 17); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); Calendar expectedReverted = Calendar.getInstance(Locale.UK); expectedReverted.set(Calendar.YEAR, 2004); expectedReverted.set(Calendar.MONTH, Calendar.MARCH); expectedReverted.set(Calendar.DAY_OF_MONTH, 26); expectedReverted.set(Calendar.HOUR_OF_DAY, 9); expectedReverted.set(Calendar.MINUTE, 0); expectedReverted.set(Calendar.SECOND, 0); expectedReverted.set(Calendar.MILLISECOND, 0); assertTrue( "test5", value == (900000 * 34) && expectedReverted.getTime().getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Test 6 checks that 9am on Sunday 28 March 2004 converts to the timeline * value and back again correctly. Note that Saturday and Sunday are * excluded from the timeline, so we expect the value to map to 9am on * Monday 29 March 2004. This is during daylight saving. */ public void test6() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 28); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); Calendar expectedReverted = Calendar.getInstance(Locale.UK); expectedReverted.set(Calendar.YEAR, 2004); expectedReverted.set(Calendar.MONTH, Calendar.MARCH); expectedReverted.set(Calendar.DAY_OF_MONTH, 29); expectedReverted.set(Calendar.HOUR_OF_DAY, 9); expectedReverted.set(Calendar.MINUTE, 0); expectedReverted.set(Calendar.SECOND, 0); expectedReverted.set(Calendar.MILLISECOND, 0); assertTrue( "test6", value == (900000 * 34 * 2) && expectedReverted.getTime().getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Test 7 checks 9am Monday 29 March 2004 converts to a timeline value and * back again correctly. This is during Daylight Saving. */ public void test7() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 29); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); Calendar expectedReverted = Calendar.getInstance(); expectedReverted.set(Calendar.YEAR, 2004); expectedReverted.set(Calendar.MONTH, Calendar.MARCH); expectedReverted.set(Calendar.DAY_OF_MONTH, 29); expectedReverted.set(Calendar.HOUR_OF_DAY, 9); expectedReverted.set(Calendar.MINUTE, 0); expectedReverted.set(Calendar.SECOND, 0); expectedReverted.set(Calendar.MILLISECOND, 0); assertTrue( "test7", value == (900000 * 34 * 2) && expectedReverted.getTime().getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Test 8. */ public void test8() { TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 29); cal.set(Calendar.HOUR_OF_DAY, 10); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date date = cal.getTime(); SegmentedTimeline timeline = getTimeline(); // Add exception in included segments cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 29); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 15); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); timeline.addException(cal.getTime()); long value = timeline.toTimelineValue(date); long ms = timeline.toMillisecond(value); Calendar cal2 = Calendar.getInstance(Locale.UK); cal2.setTime(new Date(ms)); Date reverted = cal2.getTime(); Calendar expectedReverted = Calendar.getInstance(); expectedReverted.set(Calendar.YEAR, 2004); expectedReverted.set(Calendar.MONTH, Calendar.MARCH); expectedReverted.set(Calendar.DAY_OF_MONTH, 29); expectedReverted.set(Calendar.HOUR_OF_DAY, 10); expectedReverted.set(Calendar.MINUTE, 0); expectedReverted.set(Calendar.SECOND, 0); expectedReverted.set(Calendar.MILLISECOND, 0); assertTrue( "test8", value == (900000 * 34 * 2 + 900000 * (4 - 1)) && expectedReverted.getTime().getTime() == reverted.getTime() ); TimeZone.setDefault(savedZone); } /** * Creates a timeline from 9am on Thursday 25 March 2004 to 5pm on * Tuesday 30 March 2004, for the UK locale. * * @return A timeline. */ private SegmentedTimeline getTimeline() { Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 25); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date from = cal.getTime(); cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 2004); cal.set(Calendar.MONTH, Calendar.MARCH); cal.set(Calendar.DAY_OF_MONTH, 30); cal.set(Calendar.HOUR_OF_DAY, 17); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date to = cal.getTime(); return getTimeline(from, to); } /** * Returns a segmented timeline for 15 minute segments, Monday to Friday * only, between 9am and 5pm. The UK locale is used. * * @param start the start date. * @param end the end date. * * @return The timeline. */ private SegmentedTimeline getTimeline(Date start, Date end) { Calendar cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 9); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date open = cal.getTime(); cal = Calendar.getInstance(Locale.UK); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 17); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date close = cal.getTime(); SegmentedTimeline result = null; // Create a segmented time line (segment size : 15 minutes) long quarterHourCount = (close.getTime() - open.getTime()) / SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE; long totalQuarterHourCount = SegmentedTimeline.DAY_SEGMENT_SIZE / SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE; result = new SegmentedTimeline( SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE, (int) quarterHourCount, (int) (totalQuarterHourCount - quarterHourCount) ); result.setAdjustForDaylightSaving(true); // Set start time result.setStartTime(start.getTime()); // Saturday and Sundays are non business hours result.setBaseTimeline( SegmentedTimeline.newMondayThroughFridayTimeline() ); /* PUT exclusions in test */ if (start != null && end != null) { result.addBaseTimelineExclusions(start.getTime(), end.getTime()); } return result; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/StandardTickUnitSourceTests.java0000644000175000017500000000666411173030414032666 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * StandardTickUnitSourceTests.java * -------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Oct-2007 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.StandardTickUnitSource; /** * Tests for the {@link StandardTickUnitSource} class. */ public class StandardTickUnitSourceTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardTickUnitSourceTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardTickUnitSourceTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardTickUnitSource t1 = new StandardTickUnitSource(); StandardTickUnitSource t2 = new StandardTickUnitSource(); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardTickUnitSource t1 = new StandardTickUnitSource(); StandardTickUnitSource t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); t2 = (StandardTickUnitSource) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java0000644000175000017500000001414211173030414031334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * SubCategoryAxisTests.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * 13-Nov-2008 : Added test2275695() (DG); * */ package org.jfree.chart.axis.junit; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.SubCategoryAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; /** * Tests for the {@link SubCategoryAxis} class. */ public class SubCategoryAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SubCategoryAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SubCategoryAxisTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { SubCategoryAxis a1 = new SubCategoryAxis("Test"); SubCategoryAxis a2 = new SubCategoryAxis("Test"); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); // subcategories a1.addSubCategory("Sub 1"); assertFalse(a1.equals(a2)); a2.addSubCategory("Sub 1"); assertTrue(a1.equals(a2)); // subLabelFont a1.setSubLabelFont(new Font("Serif", Font.BOLD, 15)); assertFalse(a1.equals(a2)); a2.setSubLabelFont(new Font("Serif", Font.BOLD, 15)); assertTrue(a1.equals(a2)); // subLabelPaint a1.setSubLabelPaint(Color.red); assertFalse(a1.equals(a2)); a2.setSubLabelPaint(Color.red); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { SubCategoryAxis a1 = new SubCategoryAxis("Test"); SubCategoryAxis a2 = new SubCategoryAxis("Test"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { SubCategoryAxis a1 = new SubCategoryAxis("Test"); a1.addSubCategory("SubCategoryA"); SubCategoryAxis a2 = null; try { a2 = (SubCategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SubCategoryAxis a1 = new SubCategoryAxis("Test Axis"); a1.addSubCategory("SubCategoryA"); SubCategoryAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (SubCategoryAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * A check for the NullPointerException in bug 2275695. */ public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/SymbolAxisTests.java0000644000175000017500000001150111173030414030346 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * SymbolicAxisTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 25-Jul-2007 : Added new field in testEquals() (DG); * */ package org.jfree.chart.axis.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.SymbolAxis; /** * Tests for the {@link SymbolAxis} class. */ public class SymbolAxisTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SymbolAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SymbolAxisTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { String[] tickLabels = new String[] {"One", "Two", "Three"}; SymbolAxis a1 = new SymbolAxis("Test Axis", tickLabels); SymbolAxis a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); a2 = (SymbolAxis) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } /** * Confirm that cloning works. */ public void testCloning() { SymbolAxis a1 = new SymbolAxis("Axis", new String[] {"A", "B"}); SymbolAxis a2 = null; try { a2 = (SymbolAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { SymbolAxis a1 = new SymbolAxis("Axis", new String[] {"A", "B"}); SymbolAxis a2 = new SymbolAxis("Axis", new String[] {"A", "B"}); assertTrue(a1.equals(a2)); assertTrue(a2.equals(a1)); a1 = new SymbolAxis("Axis 2", new String[] {"A", "B"}); assertFalse(a1.equals(a2)); a2 = new SymbolAxis("Axis 2", new String[] {"A", "B"}); assertTrue(a1.equals(a2)); a1 = new SymbolAxis("Axis 2", new String[] {"C", "B"}); assertFalse(a1.equals(a2)); a2 = new SymbolAxis("Axis 2", new String[] {"C", "B"}); assertTrue(a1.equals(a2)); a1.setGridBandsVisible(false); assertFalse(a1.equals(a2)); a2.setGridBandsVisible(false); assertTrue(a1.equals(a2)); a1.setGridBandPaint(Color.black); assertFalse(a1.equals(a2)); a2.setGridBandPaint(Color.black); assertTrue(a1.equals(a2)); a1.setGridBandAlternatePaint(Color.red); assertFalse(a1.equals(a2)); a2.setGridBandAlternatePaint(Color.red); assertTrue(a1.equals(a2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/TickUnitsTests.java0000644000175000017500000000753611173030414030206 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * TickUnitsTests.java * ------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Aug-2007 : Version 1 (DG); * */ package org.jfree.chart.axis.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.TickUnits; /** * Tests for the {@link TickUnits} class. */ public class TickUnitsTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TickUnitsTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TickUnitsTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); t2 = (TickUnits) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } /** * Confirm that cloning works. */ public void testCloning() { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = null; try { t2 = (TickUnits) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = (TickUnits) NumberAxis.createIntegerTickUnits(); assertTrue(t1.equals(t2)); assertTrue(t2.equals(t1)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/ValueAxisTests.java0000644000175000017500000001644611173030414030172 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * ValueAxisTests.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2003 : Version 1 (DG); * 22-Mar-2007 : Extended testEquals() for new field (DG); * */ package org.jfree.chart.axis.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Stroke; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Tests for the {@link ValueAxis} class. */ public class ValueAxisTests extends TestCase { private static final double EPSILON = 0.000000001; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ValueAxisTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ValueAxisTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { ValueAxis a1 = new NumberAxis("Test"); ValueAxis a2 = null; try { a2 = (NumberAxis) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = new NumberAxis("Test"); assertTrue(a1.equals(a2)); // axis line visible flag... a1.setAxisLineVisible(false); assertFalse(a1.equals(a2)); a2.setAxisLineVisible(false); assertTrue(a1.equals(a2)); // positiveArrowVisible; a1.setPositiveArrowVisible(true); assertFalse(a1.equals(a2)); a2.setPositiveArrowVisible(true); assertTrue(a1.equals(a2)); // negativeArrowVisible; a1.setNegativeArrowVisible(true); assertFalse(a1.equals(a2)); a2.setNegativeArrowVisible(true); assertTrue(a1.equals(a2)); //private Shape upArrow; //private Shape downArrow; //private Shape leftArrow; //private Shape rightArrow; // axisLinePaint a1.setAxisLinePaint(Color.blue); assertFalse(a1.equals(a2)); a2.setAxisLinePaint(Color.blue); assertTrue(a1.equals(a2)); // axisLineStroke Stroke stroke = new BasicStroke(2.0f); a1.setAxisLineStroke(stroke); assertFalse(a1.equals(a2)); a2.setAxisLineStroke(stroke); assertTrue(a1.equals(a2)); // inverted a1.setInverted(true); assertFalse(a1.equals(a2)); a2.setInverted(true); assertTrue(a1.equals(a2)); // range a1.setRange(new Range(50.0, 75.0)); assertFalse(a1.equals(a2)); a2.setRange(new Range(50.0, 75.0)); assertTrue(a1.equals(a2)); // autoRange a1.setAutoRange(true); assertFalse(a1.equals(a2)); a2.setAutoRange(true); assertTrue(a1.equals(a2)); // autoRangeMinimumSize a1.setAutoRangeMinimumSize(3.33); assertFalse(a1.equals(a2)); a2.setAutoRangeMinimumSize(3.33); assertTrue(a1.equals(a2)); a1.setDefaultAutoRange(new Range(1.2, 3.4)); assertFalse(a1.equals(a2)); a2.setDefaultAutoRange(new Range(1.2, 3.4)); assertTrue(a1.equals(a2)); // upperMargin a1.setUpperMargin(0.09); assertFalse(a1.equals(a2)); a2.setUpperMargin(0.09); assertTrue(a1.equals(a2)); // lowerMargin a1.setLowerMargin(0.09); assertFalse(a1.equals(a2)); a2.setLowerMargin(0.09); assertTrue(a1.equals(a2)); //private double fixedAutoRange; a1.setFixedAutoRange(50.0); assertFalse(a1.equals(a2)); a2.setFixedAutoRange(50.0); assertTrue(a1.equals(a2)); //private boolean autoTickUnitSelection; a1.setAutoTickUnitSelection(false); assertFalse(a1.equals(a2)); a2.setAutoTickUnitSelection(false); assertTrue(a1.equals(a2)); //private TickUnits standardTickUnits; a1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); assertFalse(a1.equals(a2)); a2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); assertTrue(a1.equals(a2)); // verticalTickLabels a1.setVerticalTickLabels(true); assertFalse(a1.equals(a2)); a2.setVerticalTickLabels(true); assertTrue(a1.equals(a2)); //private int autoTickIndex; //protected double reservedForTickLabels; //protected double reservedForAxisLabel; } /** * Tests the the lower and upper margin settings produce the expected * results. */ public void testAxisMargins() { XYSeries series = new XYSeries("S1"); series.add(100.0, 1.1); series.add(200.0, 2.2); XYSeriesCollection dataset = new XYSeriesCollection(series); dataset.setIntervalWidth(0.0); JFreeChart chart = ChartFactory.createScatterPlot( "Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false ); ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis(); Range r = domainAxis.getRange(); assertEquals(110.0, r.getLength(), EPSILON); domainAxis.setLowerMargin(0.10); domainAxis.setUpperMargin(0.10); r = domainAxis.getRange(); assertEquals(120.0, r.getLength(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/axis/junit/package.html0000644000175000017500000000022111173030414026644 0ustar vincentvincent Tests for the axis classes and interfaces. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/0000755000175000017500000000000011173030414023365 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/0000755000175000017500000000000011216245562024530 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/AbstractBlockTests.java0000644000175000017500000001317611173030414031132 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * AbstractBlockTests.java * ----------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.awt.Color; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.AbstractBlock; import org.jfree.chart.block.BlockBorder; import org.jfree.chart.block.EmptyBlock; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link AbstractBlock} class. */ public class AbstractBlockTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AbstractBlockTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AbstractBlockTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = new EmptyBlock(1.0, 2.0); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1.setID("Test"); assertFalse(b1.equals(b2)); b2.setID("Test"); assertTrue(b1.equals(b2)); b1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2)); b1.setFrame(new BlockBorder(Color.red)); assertFalse(b1.equals(b2)); b2.setFrame(new BlockBorder(Color.red)); assertTrue(b1.equals(b2)); b1.setPadding(new RectangleInsets(2.0, 4.0, 6.0, 8.0)); assertFalse(b1.equals(b2)); b2.setPadding(new RectangleInsets(2.0, 4.0, 6.0, 8.0)); assertTrue(b1.equals(b2)); b1.setWidth(1.23); assertFalse(b1.equals(b2)); b2.setWidth(1.23); assertTrue(b1.equals(b2)); b1.setHeight(4.56); assertFalse(b1.equals(b2)); b2.setHeight(4.56); assertTrue(b1.equals(b2)); b1.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2)); b1 = new EmptyBlock(1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.0); assertTrue(b1.equals(b2)); b1 = new EmptyBlock(1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.2); assertTrue(b1.equals(b2)); } /** * Confirm that cloning works. */ public void testCloning() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); Rectangle2D bounds1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); b1.setBounds(bounds1); EmptyBlock b2 = null; try { b2 = (EmptyBlock) b1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); bounds1.setFrame(2.0, 4.0, 6.0, 8.0); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(2.0, 4.0, 6.0, 8.0)); assertTrue(b1.equals(b2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (EmptyBlock) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(b1, b2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/BlockBorderTests.java0000644000175000017500000001100111173030414030565 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * BlockBorderTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * 23-Feb-2005 : Extended equals() test (DG); * */ package org.jfree.chart.block.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.BlockBorder; import org.jfree.ui.RectangleInsets; import org.jfree.util.UnitType; /** * Tests for the {@link BlockBorder} class. */ public class BlockBorderTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BlockBorderTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BlockBorderTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.red); BlockBorder b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.red); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); // insets b1 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0), Color.red); assertFalse(b1.equals(b2)); b2 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0), Color.red); assertTrue(b1.equals(b2)); // paint b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.blue); assertFalse(b1.equals(b2)); b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.blue); assertTrue(b1.equals(b2)); } /** * Immutable - cloning not necessary. */ public void testCloning() { BlockBorder b1 = new BlockBorder(); assertFalse(b1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); BlockBorder b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); b2 = (BlockBorder) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertTrue(b1.equals(b2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/BlockContainerTests.java0000644000175000017500000001063511173030414031306 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * BlockContainerTests.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.ColumnArrangement; import org.jfree.chart.block.EmptyBlock; import org.jfree.chart.block.FlowArrangement; /** * Tests for the {@link BlockContainer} class. */ public class BlockContainerTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BlockContainerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BlockContainerTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { BlockContainer c1 = new BlockContainer(new FlowArrangement()); BlockContainer c2 = new BlockContainer(new FlowArrangement()); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c2)); c1.setArrangement(new ColumnArrangement()); assertFalse(c1.equals(c2)); c2.setArrangement(new ColumnArrangement()); assertTrue(c1.equals(c2)); c1.add(new EmptyBlock(1.2, 3.4)); assertFalse(c1.equals(c2)); c2.add(new EmptyBlock(1.2, 3.4)); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { BlockContainer c1 = new BlockContainer(new FlowArrangement()); c1.add(new EmptyBlock(1.2, 3.4)); BlockContainer c2 = null; try { c2 = (BlockContainer) c1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BlockContainer c1 = new BlockContainer(); c1.add(new EmptyBlock(1.2, 3.4)); BlockContainer c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); c2 = (BlockContainer) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(c1, c2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/BlockPackageTests.java0000644000175000017500000000637311173030414030723 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * BlockPackageTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 22-Oct-2004 : Version 1 (DG); * 18-Jan-2005 : Added main() method (DG); * 04-Feb-2005 : Added new tests (DG); * 01-Sep-2005 : New tests for LabelBlock (DG); * 16-Mar-2007 : Added AbstractBlockTests, ColorBlockTests and * LineBorderTests (DG); * */ package org.jfree.chart.block.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.block package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class BlockPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.block"); suite.addTestSuite(AbstractBlockTests.class); suite.addTestSuite(BlockBorderTests.class); suite.addTestSuite(BlockContainerTests.class); suite.addTestSuite(BorderArrangementTests.class); suite.addTestSuite(ColorBlockTests.class); suite.addTestSuite(ColumnArrangementTests.class); suite.addTestSuite(EmptyBlockTests.class); suite.addTestSuite(FlowArrangementTests.class); suite.addTestSuite(GridArrangementTests.class); suite.addTestSuite(LabelBlockTests.class); suite.addTestSuite(LineBorderTests.class); suite.addTestSuite(RectangleConstraintTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public BlockPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/BorderArrangementTests.java0000644000175000017500000010074511173030414032014 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * BorderArrangementTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2004 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.Block; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.BorderArrangement; import org.jfree.chart.block.EmptyBlock; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.Size2D; /** * Tests for the {@link BorderArrangement} class. */ public class BorderArrangementTests extends TestCase { private static final double EPSILON = 0.0000000001; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BorderArrangementTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BorderArrangementTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { BorderArrangement b1 = new BorderArrangement(); BorderArrangement b2 = new BorderArrangement(); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b1)); b1.add(new EmptyBlock(99.0, 99.0), null); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(99.0, 99.0), null); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); assertTrue(b1.equals(b2)); b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); assertTrue(b1.equals(b2)); } /** * Immutable - cloning is not necessary. */ public void testCloning() { BorderArrangement b1 = new BorderArrangement(); assertFalse(b1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BorderArrangement b1 = new BorderArrangement(); BorderArrangement b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (BorderArrangement) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(b1, b2); } /** * Run some checks on sizing. */ public void testSizing() { BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); // TBLRC // 00000 - no items Size2D size = container.arrange(g2); assertEquals(0.0, size.width, EPSILON); assertEquals(0.0, size.height, EPSILON); // TBLRC // 00001 - center item only container.add(new EmptyBlock(123.4, 567.8)); size = container.arrange(g2); assertEquals(123.4, size.width, EPSILON); assertEquals(567.8, size.height, EPSILON); // TBLRC // 00010 - right item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00011 - right and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // try case where right item is shorter than center item container.clear(); Block rb = new EmptyBlock(12.3, 15.6); container.add(new EmptyBlock(10.0, 20.0)); container.add(rb, RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(20.0, size.height, EPSILON); assertEquals(20.0, rb.getBounds().getHeight(), EPSILON); // TBLRC // 00100 - left item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00101 - left and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // try case where left item is shorter than center item container.clear(); Block lb = new EmptyBlock(12.3, 15.6); container.add(new EmptyBlock(10.0, 20.0)); container.add(lb, RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(20.0, size.height, EPSILON); assertEquals(20.0, lb.getBounds().getHeight(), EPSILON); // TBLRC // 00110 - left and right items container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00111 - left, right and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(27.7, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01000 - bottom item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01001 - bottom and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01010 - bottom and right only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01011 - bottom, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(31.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01100 container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01101 - bottom, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(31.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01110 - bottom. left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(31.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01111 container.clear(); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 10000 - top item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 10001 - top and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10010 - right and top only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10011 - top, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(33.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10100 - top and left only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10101 - top, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(33.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10110 - top, left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(33.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10111 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(12.0, size.height, EPSILON); // TBLRC // 11000 - top and bottom only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 11001 container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11010 - top, bottom and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11011 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(16.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11100 container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11101 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(14.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11110 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(12.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 11111 - all container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); } /** * Run some checks on sizing when there is a fixed width constraint. */ public void testSizingWithWidthConstraint() { RectangleConstraint constraint = new RectangleConstraint( 10.0, new Range(10.0, 10.0), LengthConstraintType.FIXED, 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE); BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); // TBLRC // 00001 - center item only container.add(new EmptyBlock(5.0, 6.0)); Size2D size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); container.clear(); container.add(new EmptyBlock(15.0, 16.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 00010 - right item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00011 - right and center items container.clear(); container.add(new EmptyBlock(7.0, 20.0)); container.add(new EmptyBlock(8.0, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00100 - left item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00101 - left and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00110 - left and right items container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00111 - left, right and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01000 - bottom item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01001 - bottom and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01010 - bottom and right only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01011 - bottom, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01100 container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01101 - bottom, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01110 - bottom. left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01111 container.clear(); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 10000 - top item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 10001 - top and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10010 - right and top only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10011 - top, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10100 - top and left only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10101 - top, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10110 - top, left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10111 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(12.0, size.height, EPSILON); // TBLRC // 11000 - top and bottom only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 11001 container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11010 - top, bottom and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11011 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11100 container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11101 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11110 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 11111 - all container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 00000 - no items container.clear(); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(0.0, size.height, EPSILON); } /** * This test is for a particular bug that arose just prior to the release * of JFreeChart 1.0.10. A BorderArrangement with LEFT, CENTRE and RIGHT * blocks that is too wide, by default, for the available space, wasn't * shrinking the centre block as expected. */ public void testBugX() { RectangleConstraint constraint = new RectangleConstraint( new Range(0.0, 200.0), new Range(0.0, 100.0)); BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(30.0, 6.0)); Size2D size = container.arrange(g2, constraint); assertEquals(60.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); container.clear(); container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(300.0, 6.0)); size = container.arrange(g2, constraint); assertEquals(200.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/ColorBlockTests.java0000644000175000017500000001160611173030414030441 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ColorBlockTests.java * -------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.awt.Color; import java.awt.GradientPaint; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.ColorBlock; /** * Tests for the {@link ColorBlock} class. */ public class ColorBlockTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ColorBlockTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ColorBlockTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { ColorBlock b1 = new ColorBlock(Color.red, 1.0, 2.0); ColorBlock b2 = new ColorBlock(Color.red, 1.0, 2.0); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1 = new ColorBlock(Color.blue, 1.0, 2.0); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.blue, 1.0, 2.0); assertTrue(b1.equals(b2)); b1 = new ColorBlock(Color.blue, 1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.blue, 1.1, 2.0); assertTrue(b1.equals(b2)); b1 = new ColorBlock(Color.blue, 1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.blue, 1.1, 2.2); assertTrue(b1.equals(b2)); } /** * Confirm that cloning works. */ public void testCloning() { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); b1.setBounds(bounds1); ColorBlock b2 = null; try { b2 = (ColorBlock) b1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check independence bounds1.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); ColorBlock b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (ColorBlock) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(b1, b2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/ColumnArrangementTests.java0000644000175000017500000001212011173030414032021 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * ColumnArrangementTests.java * --------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.ColumnArrangement; import org.jfree.chart.block.FlowArrangement; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.VerticalAlignment; /** * Tests for the {@link ColumnArrangement} class. */ public class ColumnArrangementTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ColumnArrangementTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ColumnArrangementTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { ColumnArrangement c1 = new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); ColumnArrangement c2 = new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertTrue(c1.equals(c2)); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertTrue(c1.equals(c2)); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertTrue(c1.equals(c2)); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertTrue(c1.equals(c2)); } /** * Immutable - cloning is not necessary. */ public void testCloning() { FlowArrangement f1 = new FlowArrangement(); assertFalse(f1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); FlowArrangement f2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); f2 = (FlowArrangement) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(f1, f2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/EmptyBlockTests.java0000644000175000017500000001002511173030414030453 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * EmptyBlockTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.EmptyBlock; /** * Tests for the {@link EmptyBlock} class. */ public class EmptyBlockTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(EmptyBlockTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public EmptyBlockTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = new EmptyBlock(1.0, 2.0); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1 = new EmptyBlock(1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.0); assertTrue(b1.equals(b2)); b1 = new EmptyBlock(1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.2); assertTrue(b1.equals(b2)); } /** * Confirm that cloning works. */ public void testCloning() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = null; try { b2 = (EmptyBlock) b1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (EmptyBlock) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(b1, b2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/FlowArrangementTests.java0000644000175000017500000001177311173030414031510 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * FlowArrangementTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.FlowArrangement; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.VerticalAlignment; /** * Tests for the {@link FlowArrangement} class. */ public class FlowArrangementTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(FlowArrangementTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public FlowArrangementTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); FlowArrangement f2 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); assertTrue(f1.equals(f2)); assertTrue(f2.equals(f1)); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertTrue(f1.equals(f2)); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertTrue(f1.equals(f2)); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertTrue(f1.equals(f2)); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertTrue(f1.equals(f2)); } /** * Immutable - cloning is not necessary. */ public void testCloning() { FlowArrangement f1 = new FlowArrangement(); assertFalse(f1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); FlowArrangement f2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); f2 = (FlowArrangement) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(f1, f2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/GridArrangementTests.java0000644000175000017500000002555611173030414031472 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * GridArrangementTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Mar-2005 : Version 1 (DG); * 03-Dec-2008 : Added more tests (DG); * */ package org.jfree.chart.block.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.Block; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.block.EmptyBlock; import org.jfree.chart.block.GridArrangement; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.data.Range; import org.jfree.ui.Size2D; /** * Tests for the {@link GridArrangement} class. */ public class GridArrangementTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GridArrangementTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GridArrangementTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { GridArrangement f1 = new GridArrangement(11, 22); GridArrangement f2 = new GridArrangement(11, 22); assertTrue(f1.equals(f2)); assertTrue(f2.equals(f1)); f1 = new GridArrangement(33, 22); assertFalse(f1.equals(f2)); f2 = new GridArrangement(33, 22); assertTrue(f1.equals(f2)); f1 = new GridArrangement(33, 44); assertFalse(f1.equals(f2)); f2 = new GridArrangement(33, 44); assertTrue(f1.equals(f2)); } /** * Immutable - cloning is not necessary. */ public void testCloning() { GridArrangement f1 = new GridArrangement(1, 2); assertFalse(f1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GridArrangement f1 = new GridArrangement(33, 44); GridArrangement f2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); f2 = (GridArrangement) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(f1, f2); } private static final double EPSILON = 0.000000001; /** * Test arrangement with no constraints. */ public void testNN() { BlockContainer c = createTestContainer1(); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(90.0, s.width, EPSILON); assertEquals(33.0, s.height, EPSILON); } /** * Test arrangement with a fixed width and no height constraint. */ public void testFN() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = new RectangleConstraint(100.0, null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE); Size2D s = c.arrange(null, constraint); assertEquals(100.0, s.width, EPSILON); assertEquals(33.0, s.height, EPSILON); } /** * Test arrangement with a fixed height and no width constraint. */ public void testNF() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = RectangleConstraint.NONE.toFixedHeight( 100.0); Size2D s = c.arrange(null, constraint); assertEquals(90.0, s.width, EPSILON); assertEquals(100.0, s.height, EPSILON); } /** * Test arrangement with a range for the width and a fixed height. */ public void testRF() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, 60.0), 100.0); Size2D s = c.arrange(null, constraint); assertEquals(60.0, s.width, EPSILON); assertEquals(100.0, s.height, EPSILON); } /** * Test arrangement with a range for the width and height. */ public void testRR() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, 60.0), new Range(50.0, 70.0)); Size2D s = c.arrange(null, constraint); assertEquals(60.0, s.width, EPSILON); assertEquals(50.0, s.height, EPSILON); } /** * Test arrangement with a range for the width and no height constraint. */ public void testRN() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = RectangleConstraint.NONE.toRangeWidth( new Range(40.0, 60.0)); Size2D s = c.arrange(null, constraint); assertEquals(60.0, s.width, EPSILON); assertEquals(33.0, s.height, EPSILON); } /** * Test arrangement with a range for the height and no width constraint. */ public void testNR() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = RectangleConstraint.NONE.toRangeHeight( new Range(40.0, 60.0)); Size2D s = c.arrange(null, constraint); assertEquals(90.0, s.width, EPSILON); assertEquals(40.0, s.height, EPSILON); } private BlockContainer createTestContainer1() { Block b1 = new EmptyBlock(10, 11); Block b2 = new EmptyBlock(20, 22); Block b3 = new EmptyBlock(30, 33); BlockContainer result = new BlockContainer(new GridArrangement(1, 3)); result.add(b1); result.add(b2); result.add(b3); return result; } /** * The arrangement should be able to handle null blocks in the layout. */ public void testNullBlock_FF() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, new RectangleConstraint(20, 10)); assertEquals(20.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle null blocks in the layout. */ public void testNullBlock_FN() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(10)); assertEquals(10.0, s.getWidth(), EPSILON); assertEquals(0.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle null blocks in the layout. */ public void testNullBlock_FR() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, 10.0))); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(5.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle null blocks in the layout. */ public void testNullBlock_NN() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(0.0, s.getWidth(), EPSILON); assertEquals(0.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_FF() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, new RectangleConstraint(200, 100)); assertEquals(200.0, s.getWidth(), EPSILON); assertEquals(100.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_FN() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(30.0)); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_FR() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, 10.0))); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ public void testGridNotFull_NN() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(15.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/LabelBlockTests.java0000644000175000017500000001343611173030414030405 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * LabelBlockTests.java * -------------------- * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Sep-2005 : Version 1 (DG); * 16-Mar-2007 : Check GradientPaint in testSerialization() (DG); * 10-Feb-2009 : Added new fields to testEquals() (DG); * */ package org.jfree.chart.block.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.LabelBlock; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.RectangleAnchor; /** * Some tests for the {@link LabelBlock} class. */ public class LabelBlockTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LabelBlockTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LabelBlockTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), Color.red); LabelBlock b2 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), Color.red); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1 = new LabelBlock("XYZ", new Font("Dialog", Font.PLAIN, 12), Color.red); assertFalse(b1.equals(b2)); b2 = new LabelBlock("XYZ", new Font("Dialog", Font.PLAIN, 12), Color.red); assertTrue(b1.equals(b2)); b1 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.red); assertFalse(b1.equals(b2)); b2 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.red); assertTrue(b1.equals(b2)); b1 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.blue); assertFalse(b1.equals(b2)); b2 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.blue); assertTrue(b1.equals(b2)); b1.setToolTipText("Tooltip"); assertFalse(b1.equals(b2)); b2.setToolTipText("Tooltip"); assertTrue(b1.equals(b2)); b1.setURLText("URL"); assertFalse(b1.equals(b2)); b2.setURLText("URL"); assertTrue(b1.equals(b2)); b1.setContentAlignmentPoint(TextBlockAnchor.CENTER_RIGHT); assertFalse(b1.equals(b2)); b2.setContentAlignmentPoint(TextBlockAnchor.CENTER_RIGHT); assertTrue(b1.equals(b2)); b1.setTextAnchor(RectangleAnchor.BOTTOM_RIGHT); assertFalse(b1.equals(b2)); b2.setTextAnchor(RectangleAnchor.BOTTOM_RIGHT); assertTrue(b1.equals(b2)); } /** * Confirm that cloning works. */ public void testCloning() { LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), Color.red); LabelBlock b2 = null; try { b2 = (LabelBlock) b1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue); LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp); LabelBlock b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (LabelBlock) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/LineBorderTests.java0000644000175000017500000001152011173030414030430 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * LineBorderTests.java * -------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.LineBorder; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link LineBorder} class. */ public class LineBorderTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineBorderTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineBorderTests(String name) { super(name); } /** * Confirm that the equals() method can distinguish all the required fields. */ public void testEquals() { LineBorder b1 = new LineBorder(Color.red, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); LineBorder b2 = new LineBorder(Color.red, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1 = new LineBorder(Color.blue, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.blue, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertTrue(b1.equals(b2)); b1 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertTrue(b1.equals(b2)); b1 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2)); } /** * Immutable - cloning not necessary. */ public void testCloning() { LineBorder b1 = new LineBorder(); assertFalse(b1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LineBorder b1 = new LineBorder(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); LineBorder b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); b2 = (LineBorder) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertTrue(b1.equals(b2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/block/junit/RectangleConstraintTests.java0000644000175000017500000001270311173030414032360 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * RectangleConstraintTests.java * ----------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Oct-2004 : Version 1 (DG); * */ package org.jfree.chart.block.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.LengthConstraintType; import org.jfree.chart.block.RectangleConstraint; import org.jfree.data.Range; import org.jfree.ui.Size2D; /** * Tests for the {@link RectangleConstraint} class. */ public class RectangleConstraintTests extends TestCase { private static final double EPSILON = 0.0000000001; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RectangleConstraintTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RectangleConstraintTests(String name) { super(name); } /** * Run some checks on the constrained size calculation. */ public void testCalculateConstrainedSize() { Size2D s; // NONE / NONE RectangleConstraint c1 = RectangleConstraint.NONE; s = c1.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.4, EPSILON); // NONE / RANGE RectangleConstraint c2 = new RectangleConstraint( 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c2.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.0, EPSILON); // NONE / FIXED RectangleConstraint c3 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c3.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); // RANGE / NONE RectangleConstraint c4 = new RectangleConstraint( 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE ); s = c4.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 2.0, EPSILON); assertEquals(s.height, 3.4, EPSILON); // RANGE / RANGE RectangleConstraint c5 = new RectangleConstraint( 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c5.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 2.0, EPSILON); assertEquals(s.height, 3.0, EPSILON); // RANGE / FIXED RectangleConstraint c6 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c6.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); // FIXED / NONE RectangleConstraint c7 = RectangleConstraint.NONE; s = c7.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.4, EPSILON); // FIXED / RANGE RectangleConstraint c8 = new RectangleConstraint( 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c8.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.0, EPSILON); // FIXED / FIXED RectangleConstraint c9 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c9.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/0000755000175000017500000000000011173030414023607 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/0000755000175000017500000000000011216245562024752 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/CategoryItemEntityTests.java0000644000175000017500000001340711173030414032424 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * CategoryItemEntityTests.java * ---------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.CategoryItemEntity; import org.jfree.data.category.DefaultCategoryDataset; /** * Tests for the {@link CategoryItemEntity} class. */ public class CategoryItemEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryItemEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryItemEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); CategoryItemEntity e2 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); e1.setCategory("C1"); assertFalse(e1.equals(e2)); e2.setCategory("C1"); assertTrue(e1.equals(e2)); e1.setCategoryIndex(0); assertFalse(e1.equals(e2)); e2.setCategoryIndex(0); assertTrue(e1.equals(e2)); e1.setSeries(0); assertFalse(e1.equals(e2)); e2.setSeries(0); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); CategoryItemEntity e2 = null; try { e2 = (CategoryItemEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); CategoryItemEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); e2 = (CategoryItemEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(e1, e2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/CategoryLabelEntityTests.java0000644000175000017500000001175411173030414032550 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * CategoryLabelEntityTests.java * ----------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Nov-2007 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.CategoryLabelEntity; /** * Tests for the {@link CategoryLabelEntity} class. */ public class CategoryLabelEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryLabelEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryLabelEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); CategoryLabelEntity e2 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertTrue(e1.equals(e2)); e1 = new CategoryLabelEntity("B", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertFalse(e1.equals(e2)); e2 = new CategoryLabelEntity("B", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); CategoryLabelEntity e2 = null; try { e2 = (CategoryLabelEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); CategoryLabelEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); e2 = (CategoryLabelEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(e1, e2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/ContourEntityTests.java0000644000175000017500000001134711173030414031462 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * ContourEntityTests.java * ----------------------- * (C) Copyright 2004, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.ContourEntity; /** * Tests for the ContourEntity class. */ public class ContourEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ContourEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ContourEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ContourEntity e1 = new ContourEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); ContourEntity e2 = new ContourEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); e1.setIndex(99); assertFalse(e1.equals(e2)); e2.setIndex(99); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { ContourEntity e1 = new ContourEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); ContourEntity e2 = null; try { e2 = (ContourEntity) e1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ContourEntity e1 = new ContourEntity( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" ); ContourEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); e2 = (ContourEntity) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(e1, e2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/EntityPackageTests.java0000644000175000017500000000572611173030414031370 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * EntityPackageTests.java * ----------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 19-May-2004 : Version 1 (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 13-Nov-2007 : Added CategoryLabelEntityTests (DG); * */ package org.jfree.chart.entity.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.entity package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class EntityPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.entity"); suite.addTestSuite(CategoryItemEntityTests.class); suite.addTestSuite(CategoryLabelEntityTests.class); suite.addTestSuite(ContourEntityTests.class); suite.addTestSuite(LegendItemEntityTests.class); suite.addTestSuite(PieSectionEntityTests.class); suite.addTestSuite(StandardEntityCollectionTests.class); suite.addTestSuite(TickLabelEntityTests.class); suite.addTestSuite(XYItemEntityTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public EntityPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/LegendItemEntityTests.java0000644000175000017500000001207711173030414032047 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * LegendItemEntityTests.java * -------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * 18-May-2007 : Added checks for new fields (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.LegendItemEntity; import org.jfree.data.category.DefaultCategoryDataset; /** * Tests for the {@link LegendItemEntity} class. */ public class LegendItemEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LegendItemEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LegendItemEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); LegendItemEntity e2 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); e1.setDataset(new DefaultCategoryDataset()); assertFalse(e1.equals(e2)); e2.setDataset(new DefaultCategoryDataset()); assertTrue(e1.equals(e2)); e1.setSeriesKey("A"); assertFalse(e1.equals(e2)); e2.setSeriesKey("A"); assertTrue(e1.equals(e2)); e1.setSeriesIndex(7); assertFalse(e1.equals(e2)); e2.setSeriesIndex(7); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); LegendItemEntity e2 = null; try { e2 = (LegendItemEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); LegendItemEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); e2 = (LegendItemEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(e1, e2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/PieSectionEntityTests.java0000644000175000017500000001257711173030414032101 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * PieSectionEntityTests.java * -------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.PieSectionEntity; import org.jfree.data.general.DefaultPieDataset; /** * Tests for the {@link PieSectionEntity} class. */ public class PieSectionEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PieSectionEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PieSectionEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", "ToolTip", "URL"); PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", "ToolTip", "URL"); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); e1.setDataset(null); assertFalse(e1.equals(e2)); e2.setDataset(null); assertTrue(e1.equals(e2)); e1.setPieIndex(99); assertFalse(e1.equals(e2)); e2.setPieIndex(99); assertTrue(e1.equals(e2)); e1.setSectionIndex(66); assertFalse(e1.equals(e2)); e2.setSectionIndex(66); assertTrue(e1.equals(e2)); e1.setSectionKey("ABC"); assertFalse(e1.equals(e2)); e2.setSectionKey("ABC"); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", "ToolTip", "URL"); PieSectionEntity e2 = null; try { e2 = (PieSectionEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", "ToolTip", "URL"); PieSectionEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); e2 = (PieSectionEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(e1, e2); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java0000644000175000017500000001211011173030414033572 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * StandardEntityCollectionTests.java * ---------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.PieSectionEntity; import org.jfree.chart.entity.StandardEntityCollection; import org.jfree.data.general.DefaultPieDataset; /** * Tests for the {@link StandardEntityCollection} class. */ public class StandardEntityCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardEntityCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardEntityCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardEntityCollection c1 = new StandardEntityCollection(); StandardEntityCollection c2 = new StandardEntityCollection(); assertTrue(c1.equals(c2)); PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); c1.add(e1); assertFalse(c1.equals(c2)); PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); c2.add(e2); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); StandardEntityCollection c1 = new StandardEntityCollection(); c1.add(e1); StandardEntityCollection c2 = null; try { c2 = (StandardEntityCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence c1.clear(); assertFalse(c1.equals(c2)); c2.clear(); assertTrue(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", "ToolTip", "URL"); StandardEntityCollection c1 = new StandardEntityCollection(); c1.add(e1); StandardEntityCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (StandardEntityCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/TickLabelEntityTests.java0000644000175000017500000001111511173030414031654 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TickLabelEntityTests.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.TickLabelEntity; /** * Tests for the {@link TickLabelEntity} class. */ public class TickLabelEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TickLabelEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TickLabelEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); TickLabelEntity e2 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); TickLabelEntity e2 = null; try { e2 = (TickLabelEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); TickLabelEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); e2 = (TickLabelEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(e1, e2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/entity/junit/XYItemEntityTests.java0000644000175000017500000001171211173030414031204 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XYItemEntityTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.entity.XYItemEntity; import org.jfree.data.time.TimeSeriesCollection; /** * Tests for the {@link XYItemEntity} class. */ public class XYItemEntityTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYItemEntityTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYItemEntityTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); XYItemEntity e2 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); assertTrue(e1.equals(e2)); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(e1.equals(e2)); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertTrue(e1.equals(e2)); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertTrue(e1.equals(e2)); e1.setSeriesIndex(88); assertFalse(e1.equals(e2)); e2.setSeriesIndex(88); assertTrue(e1.equals(e2)); e1.setItem(88); assertFalse(e1.equals(e2)); e2.setItem(88); assertTrue(e1.equals(e2)); } /** * Confirm that cloning works. */ public void testCloning() { XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); XYItemEntity e2 = null; try { e2 = (XYItemEntity) e1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(e1 != e2); assertTrue(e1.getClass() == e2.getClass()); assertTrue(e1.equals(e2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); XYItemEntity e2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); e2 = (XYItemEntity) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(e1, e2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/0000755000175000017500000000000011173030414024053 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/0000755000175000017500000000000011216245562025216 5ustar vincentvincent././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/DynamicDriveToolTipTagFragmentGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/DynamicDriveToolTipTagFragmentGe0000644000175000017500000000563011173030414033420 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------------------- * DynamicDriveToolTipTagFragmentGeneratorTests.java * ------------------------------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.imagemap.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator; /** * Tests for the {@link DynamicDriveToolTipTagFragmentGenerator} class. */ public class DynamicDriveToolTipTagFragmentGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DynamicDriveToolTipTagFragmentGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DynamicDriveToolTipTagFragmentGeneratorTests(String name) { super(name); } /** * Some checks for the generateURLFragment() method. */ public void testGenerateURLFragment() { OverLIBToolTipTagFragmentGenerator g = new OverLIBToolTipTagFragmentGenerator(); assertEquals(" onMouseOver=\"return overlib('abc');\"" + " onMouseOut=\"return nd();\"", g.generateToolTipFragment("abc")); assertEquals(" onMouseOver=\"return overlib(" + "'It\\'s \\\"A\\\", 100.0');\" onMouseOut=\"return nd();\"", g.generateToolTipFragment("It\'s \"A\", 100.0")); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/ImageMapPackageTests.java0000644000175000017500000000567011173030414032036 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ImageMapPackageTests.java * ------------------------- * (C) Copyright 2007-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 05-Dec-2007 : Version 1 (DG); * 25-Mar-2009 : Added DynamicDriveToolTipTagFragmentGeneratorTests, * ImageMapUtilitiesTests and * OverLIBToolTipTagFragmentGeneratorTests (DG); * */ package org.jfree.chart.imagemap.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.imagemap package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class ImageMapPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.imagemap"); suite.addTestSuite(DynamicDriveToolTipTagFragmentGeneratorTests.class); suite.addTestSuite(ImageMapUtilitiesTests.class); suite.addTestSuite(OverLIBToolTipTagFragmentGeneratorTests.class); suite.addTestSuite(StandardToolTipTagFragmentGeneratorTests.class); suite.addTestSuite(StandardURLTagFragmentGeneratorTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public ImageMapPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/ImageMapUtilitiesTests.java0000644000175000017500000000647311173030414032460 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * ImageMapUtilitiesTests.java * --------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.imagemap.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.imagemap.ImageMapUtilities; /** * Tests for the {@link ImageMapUtilities} class. */ public class ImageMapUtilitiesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ImageMapUtilitiesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ImageMapUtilitiesTests(String name) { super(name); } /** * Some checks for the htmlEscape() method. */ public void testHTMLEscape() { assertEquals("", ImageMapUtilities.htmlEscape("")); assertEquals("abc", ImageMapUtilities.htmlEscape("abc")); assertEquals("&", ImageMapUtilities.htmlEscape("&")); assertEquals(""", ImageMapUtilities.htmlEscape("\"")); assertEquals("<", ImageMapUtilities.htmlEscape("<")); assertEquals(">", ImageMapUtilities.htmlEscape(">")); assertEquals("'", ImageMapUtilities.htmlEscape("\'")); assertEquals("\abc", ImageMapUtilities.htmlEscape("\\abc")); assertEquals("abc\n", ImageMapUtilities.htmlEscape("abc\n")); } /** * Some checks for the javascriptEscape() method. */ public void testJavascriptEscape() { assertEquals("", ImageMapUtilities.javascriptEscape("")); assertEquals("abc", ImageMapUtilities.javascriptEscape("abc")); assertEquals("\\\'", ImageMapUtilities.javascriptEscape("\'")); assertEquals("\\\"", ImageMapUtilities.javascriptEscape("\"")); assertEquals("\\\\", ImageMapUtilities.javascriptEscape("\\")); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/OverLIBToolTipTagFragmentGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/OverLIBToolTipTagFragmentGenerat0000644000175000017500000000556511173030414033345 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------------- * OverLIBToolTipTagFragmentGeneratorTests.java * -------------------------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.imagemap.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.imagemap.OverLIBToolTipTagFragmentGenerator; /** * Tests for the {@link OverLIBToolTipTagFragmentGenerator} class. */ public class OverLIBToolTipTagFragmentGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OverLIBToolTipTagFragmentGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OverLIBToolTipTagFragmentGeneratorTests(String name) { super(name); } /** * Some checks for the generateURLFragment() method. */ public void testGenerateURLFragment() { OverLIBToolTipTagFragmentGenerator g = new OverLIBToolTipTagFragmentGenerator(); assertEquals(" onMouseOver=\"return overlib('abc');\"" + " onMouseOut=\"return nd();\"", g.generateToolTipFragment("abc")); assertEquals(" onMouseOver=\"return overlib(" + "'It\\'s \\\"A\\\", 100.0');\" onMouseOut=\"return nd();\"", g.generateToolTipFragment("It\'s \"A\", 100.0")); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/StandardToolTipTagFragmentGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/StandardToolTipTagFragmentGenera0000644000175000017500000000541511173030414033451 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------------- * StandardToolTipTagFragmentGeneratorTests.java * --------------------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Dec-2007 : Version 1 (DG); * */ package org.jfree.chart.imagemap.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.imagemap.StandardToolTipTagFragmentGenerator; /** * Tests for the {@link StandardToolTipTagFragmentGeneratorTests} class. */ public class StandardToolTipTagFragmentGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardToolTipTagFragmentGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardToolTipTagFragmentGeneratorTests(String name) { super(name); } /** * Some checks for the generateURLFragment() method. */ public void testGenerateURLFragment() { StandardToolTipTagFragmentGenerator g = new StandardToolTipTagFragmentGenerator(); assertEquals(" title=\"abc\" alt=\"\"", g.generateToolTipFragment("abc")); assertEquals(" title=\"Series "A", 100.0\" alt=\"\"", g.generateToolTipFragment("Series \"A\", 100.0")); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/StandardURLTagFragmentGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/imagemap/junit/StandardURLTagFragmentGeneratorT0000644000175000017500000000547411173030414033377 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------------- * StandardURLTagFragmentGeneratorTests.java * ----------------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Dec-2007 : Version 1 (DG); * */ package org.jfree.chart.imagemap.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.imagemap.StandardURLTagFragmentGenerator; /** * Tests for the {@link StandardURLTagFragmentGeneratorTests} class. */ public class StandardURLTagFragmentGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardURLTagFragmentGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardURLTagFragmentGeneratorTests(String name) { super(name); } /** * Some checks for the generateURLFragment() method. */ public void testGenerateURLFragment() { StandardURLTagFragmentGenerator g = new StandardURLTagFragmentGenerator(); assertEquals(" href=\"abc\"", g.generateURLFragment("abc")); assertEquals(" href=\"images/abc.png\"", g.generateURLFragment("images/abc.png")); assertEquals(" href=\"http://www.jfree.org/images/abc.png\"", g.generateURLFragment("http://www.jfree.org/images/abc.png")); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/0000755000175000017500000000000011216245562023436 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/AreaChartTests.java0000644000175000017500000001535411173030414027154 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * AreaChartTests.java * ------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Tests for an area chart. */ public class AreaChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AreaChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AreaChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createAreaChart(); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the chart's dataset and then checks that the new dataset is OK. */ public void testReplaceDataset() { Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset( "S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Create an area chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createAreaChart() { Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); return ChartFactory.createAreaChart("Area Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, true, true); } /** * A chart change listener. */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/BarChart3DTests.java0000644000175000017500000001577511173030414027206 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * BarChart3DTests.java * -------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 25-Jun-2002 : Removed redundant code (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 14-Jul-2003 : Renamed BarChart3DTests.java (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Tests for a 3D bar chart. */ public class BarChart3DTests extends TestCase { /** The chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BarChart3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BarChart3DTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createBarChart3D(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the dataset and checks that the data range is as expected. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createBarChart3D() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createBarChart3D("Bar Chart 3D", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, true, true); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/BarChartTests.java0000644000175000017500000001611111173030414027000 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * BarChartTests.java * ------------------ * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 25-Jun-2002 : Removed redundant code (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 14-Jul-2003 : Renamed BarChartTests.java (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Tests for a bar chart. */ public class BarChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BarChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BarChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createBarChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the chart's dataset and then checks that the new dataset is OK. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createBarChart() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createBarChart( "Bar Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend true, true ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/ChartPackageTests.java0000644000175000017500000000740111173030414027631 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * ChartPackageTests.java * ---------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 21-May-2004 : Added PieChart3DTests (DG); * 02-Mar-2007 : Added missing tests (DG); * 06-Mar-2007 : Added HashUtilitiesTests (DG); * 14-Aug-2008 : Added StandardChartThemeTests (DG); * */ package org.jfree.chart.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class ChartPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart"); suite.addTestSuite(AreaChartTests.class); suite.addTestSuite(BarChartTests.class); suite.addTestSuite(BarChart3DTests.class); suite.addTestSuite(ChartPanelTests.class); suite.addTestSuite(ChartRenderingInfoTests.class); suite.addTestSuite(GanttChartTests.class); suite.addTestSuite(HashUtilitiesTests.class); suite.addTestSuite(JFreeChartTests.class); suite.addTestSuite(LegendItemTests.class); suite.addTestSuite(LegendItemCollectionTests.class); suite.addTestSuite(LineChartTests.class); suite.addTestSuite(LineChart3DTests.class); suite.addTestSuite(MeterChartTests.class); suite.addTestSuite(PaintMapTests.class); suite.addTestSuite(PieChartTests.class); suite.addTestSuite(PieChart3DTests.class); suite.addTestSuite(ScatterPlotTests.class); suite.addTestSuite(StackedAreaChartTests.class); suite.addTestSuite(StackedBarChartTests.class); suite.addTestSuite(StackedBarChart3DTests.class); suite.addTestSuite(StandardChartThemeTests.class); suite.addTestSuite(StrokeMapTests.class); suite.addTestSuite(TimeSeriesChartTests.class); suite.addTestSuite(WaterfallChartTests.class); suite.addTestSuite(XYAreaChartTests.class); suite.addTestSuite(XYBarChartTests.class); suite.addTestSuite(XYLineChartTests.class); suite.addTestSuite(XYStepAreaChartTests.class); suite.addTestSuite(XYStepChartTests.class); return suite; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/ChartPanelTests.java0000644000175000017500000002744311173030414027345 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ChartPanelTests.java * -------------------- * (C) Copyright 2004-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Jul-2004 : Version 1 (DG); * 12-Jan-2009 : Added test2502355() (DG); * */ package org.jfree.chart.junit; import java.awt.geom.Rectangle2D; import java.util.EventListener; import java.util.List; import javax.swing.event.CaretListener; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartMouseEvent; import org.jfree.chart.ChartMouseListener; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.DefaultXYDataset; /** * Tests for the {@link ChartPanel} class. */ public class ChartPanelTests extends TestCase implements ChartChangeListener, ChartMouseListener { private List chartChangeEvents = new java.util.ArrayList(); /** * Receives a chart change event and stores it in a list for later * inspection. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.chartChangeEvents.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ChartPanelTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ChartPanelTests(String name) { super(name); } /** * Test that the constructor will accept a null chart. */ public void testConstructor1() { ChartPanel panel = new ChartPanel(null); assertEquals(null, panel.getChart()); } /** * Test that it is possible to set the panel's chart to null. */ public void testSetChart() { JFreeChart chart = new JFreeChart(new XYPlot()); ChartPanel panel = new ChartPanel(chart); panel.setChart(null); assertEquals(null, panel.getChart()); } /** * Check the behaviour of the getListeners() method. */ public void testGetListeners() { ChartPanel p = new ChartPanel(null); p.addChartMouseListener(this); EventListener[] listeners = p.getListeners(ChartMouseListener.class); assertEquals(1, listeners.length); assertEquals(this, listeners[0]); // try a listener type that isn't registered listeners = p.getListeners(CaretListener.class); assertEquals(0, listeners.length); p.removeChartMouseListener(this); listeners = p.getListeners(ChartMouseListener.class); assertEquals(0, listeners.length); // try a null argument boolean pass = false; try { listeners = p.getListeners((Class) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); // try a class that isn't a listener pass = false; try { listeners = p.getListeners(Integer.class); } catch (ClassCastException e) { pass = true; } assertTrue(pass); } /** * Ignores a mouse click event. * * @param event the event. */ public void chartMouseClicked(ChartMouseEvent event) { // ignore } /** * Ignores a mouse move event. * * @param event the event. */ public void chartMouseMoved(ChartMouseEvent event) { // ignore } /** * Checks that a call to the zoom() method generates just one * ChartChangeEvent. */ public void test2502355_zoom() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoom(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the zoomInBoth() method generates just one * ChartChangeEvent. */ public void test2502355_zoomInBoth() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomInBoth(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the zoomOutBoth() method generates just one * ChartChangeEvent. */ public void test2502355_zoomOutBoth() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomOutBoth(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the restoreAutoBounds() method generates just one * ChartChangeEvent. */ public void test2502355_restoreAutoBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoBounds(); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the zoomInDomain() method, for a plot with more * than one domain axis, generates just one ChartChangeEvent. */ public void test2502355_zoomInDomain() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomInDomain(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the zoomInRange() method, for a plot with more * than one range axis, generates just one ChartChangeEvent. */ public void test2502355_zoomInRange() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomInRange(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the zoomOutDomain() method, for a plot with more * than one domain axis, generates just one ChartChangeEvent. */ public void test2502355_zoomOutDomain() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomOutDomain(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the zoomOutRange() method, for a plot with more * than one range axis, generates just one ChartChangeEvent. */ public void test2502355_zoomOutRange() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomOutRange(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the restoreAutoDomainBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ public void test2502355_restoreAutoDomainBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoDomainBounds(); assertEquals(1, this.chartChangeEvents.size()); } /** * Checks that a call to the restoreAutoRangeBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ public void test2502355_restoreAutoRangeBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoRangeBounds(); assertEquals(1, this.chartChangeEvents.size()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/ChartRenderingInfoTests.java0000644000175000017500000001433011173030414031026 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * ChartRenderingInfoTests.java * ---------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Mar-2004 : Version 1 (DG); * 30-Nov-2005 : Updated for removed field in ChartRenderingInfo (DG); * */ package org.jfree.chart.junit; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.StandardEntityCollection; /** * Tests for the {@link ChartRenderingInfo} class. */ public class ChartRenderingInfoTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ChartRenderingInfoTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ChartRenderingInfoTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ChartRenderingInfo i1 = new ChartRenderingInfo(); ChartRenderingInfo i2 = new ChartRenderingInfo(); assertTrue(i1.equals(i2)); i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(i1.equals(i2)); i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(i1.equals(i2)); i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4)); assertFalse(i1.equals(i2)); i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4)); assertTrue(i1.equals(i2)); StandardEntityCollection e1 = new StandardEntityCollection(); e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4))); i1.setEntityCollection(e1); assertFalse(i1.equals(i2)); StandardEntityCollection e2 = new StandardEntityCollection(); e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4))); i2.setEntityCollection(e2); } /** * Confirm that cloning works. */ public void testCloning() { ChartRenderingInfo i1 = new ChartRenderingInfo(); ChartRenderingInfo i2 = null; try { i2 = (ChartRenderingInfo) i1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); // check independence i1.getChartArea().setRect(4.0, 3.0, 2.0, 1.0); assertFalse(i1.equals(i2)); i2.getChartArea().setRect(4.0, 3.0, 2.0, 1.0); assertTrue(i1.equals(i2)); i1.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2, 1))); assertFalse(i1.equals(i2)); i2.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2, 1))); assertTrue(i1.equals(i2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ChartRenderingInfo i1 = new ChartRenderingInfo(); i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); ChartRenderingInfo i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); i2 = (ChartRenderingInfo) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { ChartRenderingInfo i1 = new ChartRenderingInfo(); i1.getPlotInfo().setDataArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); ChartRenderingInfo i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); i2 = (ChartRenderingInfo) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); assertEquals(i2, i2.getPlotInfo().getOwner()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/GanttChartTests.java0000644000175000017500000002735411173030414027364 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * GanttChartTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.Calendar; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; import org.jfree.data.gantt.TaskSeriesCollection; import org.jfree.data.time.SimpleTimePeriod; /** * Some tests for a Gantt chart. */ public class GanttChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GanttChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GanttChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createGanttChart(); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo2() { boolean success = false; try { JFreeChart chart = createGanttChart(); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDataset(createDataset()); /* BufferedImage img =*/ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { success = false; } assertTrue(success); } /** * Replaces the chart's dataset and then checks that the new dataset is OK. */ public void testReplaceDataset() { LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(null); assertEquals(true, l.flag); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a Gantt chart. * * @return The chart. */ private static JFreeChart createGanttChart() { // create the chart... return ChartFactory.createGanttChart( "Gantt Chart", "Domain", "Range", null, true, // include legend true, true ); } /** * Creates a sample dataset for a Gantt chart. * * @return The dataset. */ public static IntervalCategoryDataset createDataset() { TaskSeries s1 = new TaskSeries("Scheduled"); s1.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); s1.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)))); s1.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(5, Calendar.MAY, 2001)))); s1.add(new Task("Design Phase", new SimpleTimePeriod(date(6, Calendar.MAY, 2001), date(30, Calendar.MAY, 2001)))); s1.add(new Task("Design Signoff", new SimpleTimePeriod(date(2, Calendar.JUNE, 2001), date(2, Calendar.JUNE, 2001)))); s1.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(3, Calendar.JUNE, 2001), date(31, Calendar.JULY, 2001)))); s1.add(new Task("Design Review", new SimpleTimePeriod(date(1, Calendar.AUGUST, 2001), date(8, Calendar.AUGUST, 2001)))); s1.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(10, Calendar.AUGUST, 2001), date(10, Calendar.AUGUST, 2001)))); s1.add(new Task("Beta Implementation", new SimpleTimePeriod(date(12, Calendar.AUGUST, 2001), date(12, Calendar.SEPTEMBER, 2001)))); s1.add(new Task("Testing", new SimpleTimePeriod(date(13, Calendar.SEPTEMBER, 2001), date(31, Calendar.OCTOBER, 2001)))); s1.add(new Task("Final Implementation", new SimpleTimePeriod(date(1, Calendar.NOVEMBER, 2001), date(15, Calendar.NOVEMBER, 2001)))); s1.add(new Task("Signoff", new SimpleTimePeriod(date(28, Calendar.NOVEMBER, 2001), date(30, Calendar.NOVEMBER, 2001)))); TaskSeries s2 = new TaskSeries("Actual"); s2.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); s2.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), date(9, Calendar.APRIL, 2001)))); s2.add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), date(15, Calendar.MAY, 2001)))); s2.add(new Task("Design Phase", new SimpleTimePeriod(date(15, Calendar.MAY, 2001), date(17, Calendar.JUNE, 2001)))); s2.add(new Task("Design Signoff", new SimpleTimePeriod(date(30, Calendar.JUNE, 2001), date(30, Calendar.JUNE, 2001)))); s2.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(1, Calendar.JULY, 2001), date(12, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Design Review", new SimpleTimePeriod(date(12, Calendar.SEPTEMBER, 2001), date(22, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Revised Design Signoff", new SimpleTimePeriod(date(25, Calendar.SEPTEMBER, 2001), date(27, Calendar.SEPTEMBER, 2001)))); s2.add(new Task("Beta Implementation", new SimpleTimePeriod(date(27, Calendar.SEPTEMBER, 2001), date(30, Calendar.OCTOBER, 2001)))); s2.add(new Task("Testing", new SimpleTimePeriod(date(31, Calendar.OCTOBER, 2001), date(17, Calendar.NOVEMBER, 2001)))); s2.add(new Task("Final Implementation", new SimpleTimePeriod(date(18, Calendar.NOVEMBER, 2001), date(5, Calendar.DECEMBER, 2001)))); s2.add(new Task("Signoff", new SimpleTimePeriod(date(10, Calendar.DECEMBER, 2001), date(11, Calendar.DECEMBER, 2001)))); TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); collection.add(s2); return collection; } /** * Utility method for creating Date objects. * * @param day the date. * @param month the month. * @param year the year. * * @return a date. */ private static Date date(int day, int month, int year) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); Date result = calendar.getTime(); return result; } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/HashUtilitiesTests.java0000644000175000017500000000515211173030414030074 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * HashUtilitiesTests.java * ----------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.HashUtilities; /** * Tests for the {@link HashUtilities} class. */ public class HashUtilitiesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(HashUtilitiesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public HashUtilitiesTests(String name) { super(name); } /** * Some sanity checks for the hashCodeForDoubleArray() method. */ public void testHashCodeForDoubleArray() { double[] a1 = new double[] {1.0}; double[] a2 = new double[] {1.0}; int h1 = HashUtilities.hashCodeForDoubleArray(a1); int h2 = HashUtilities.hashCodeForDoubleArray(a2); assertTrue(h1 == h2); double[] a3 = new double[] {0.5, 1.0}; int h3 = HashUtilities.hashCodeForDoubleArray(a3); assertFalse(h1 == h3); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/JFreeChartTestSuite.java0000644000175000017500000001242211173030414030117 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * JFreeChartTestSuite.java * ------------------------ * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 30-Sep-2002 : Added tests for com.jrefinery.data (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added tests for new com.jrefinery.data.time package (DG); * 17-Feb-2004 : Added tests for org.jfree.chart.title package (DG); * 20-May-2004 : Added tests for org.jfree.chart.entity package (DG); * 30-Jul-2004 : Added tests for org.jfree.data.gantt package (DG); * 23-Aug-2004 : Restructured org.jfree.data (DG); * 18-Jan-2005 : Added main() method (DG); * 08-Jun-2005 : Added tests for org.jfree.chart.needle package (DG); * 26-Jan-2007 : Added tests for org.jfree.data.time.ohlc package (DG); * 24-Oct-2007 : Added tests for org.jfree.chart.plot.dial package (DG); * 25-Mar-2009 : Added missing test suite (org.jfree.data.general) (DG); * */ package org.jfree.chart.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.annotations.junit.AnnotationsPackageTests; import org.jfree.chart.axis.junit.AxisPackageTests; import org.jfree.chart.block.junit.BlockPackageTests; import org.jfree.chart.entity.junit.EntityPackageTests; import org.jfree.chart.labels.junit.LabelsPackageTests; import org.jfree.chart.needle.junit.NeedlePackageTests; import org.jfree.chart.plot.dial.junit.DialPackageTests; import org.jfree.chart.plot.junit.PlotPackageTests; import org.jfree.chart.renderer.category.junit.RendererCategoryPackageTests; import org.jfree.chart.renderer.junit.RendererPackageTests; import org.jfree.chart.renderer.xy.junit.RendererXYPackageTests; import org.jfree.chart.title.junit.TitlePackageTests; import org.jfree.chart.urls.junit.UrlsPackageTests; import org.jfree.data.category.junit.DataCategoryPackageTests; import org.jfree.data.gantt.junit.DataGanttPackageTests; import org.jfree.data.general.junit.DataGeneralPackageTests; import org.jfree.data.junit.DataPackageTests; import org.jfree.data.statistics.junit.DataStatisticsPackageTests; import org.jfree.data.time.junit.DataTimePackageTests; import org.jfree.data.time.ohlc.junit.OHLCPackageTests; import org.jfree.data.xy.junit.DataXYPackageTests; /** * A test suite for the JFreeChart class library that can be run using * JUnit (http://www.junit.org). */ public class JFreeChartTestSuite extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("JFreeChart"); suite.addTest(ChartPackageTests.suite()); suite.addTest(AnnotationsPackageTests.suite()); suite.addTest(AxisPackageTests.suite()); suite.addTest(BlockPackageTests.suite()); suite.addTest(EntityPackageTests.suite()); suite.addTest(LabelsPackageTests.suite()); suite.addTest(NeedlePackageTests.suite()); suite.addTest(PlotPackageTests.suite()); suite.addTest(DialPackageTests.suite()); suite.addTest(RendererPackageTests.suite()); suite.addTest(RendererCategoryPackageTests.suite()); suite.addTest(RendererXYPackageTests.suite()); suite.addTest(TitlePackageTests.suite()); suite.addTest(UrlsPackageTests.suite()); suite.addTest(DataPackageTests.suite()); suite.addTest(DataCategoryPackageTests.suite()); suite.addTest(DataGanttPackageTests.suite()); suite.addTest(DataGeneralPackageTests.suite()); suite.addTest(DataStatisticsPackageTests.suite()); suite.addTest(DataTimePackageTests.suite()); suite.addTest(OHLCPackageTests.suite()); suite.addTest(DataXYPackageTests.suite()); return suite; } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/JFreeChartTests.java0000644000175000017500000004570611173030414027303 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * JFreeChartTests.java * -------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Sep-2003 : Removed null title test, since TM has added code to ensure * null titles cannot be created (DG); * 24-Nov-2005 : Removed OldLegend (DG); * 16-May-2007 : Added some new tests (DG); * */ package org.jfree.chart.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.RenderingHints; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.RingPlot; import org.jfree.chart.title.LegendTitle; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.time.Day; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.ui.Align; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link JFreeChart} class. */ public class JFreeChartTests extends TestCase implements ChartChangeListener { /** A pie chart. */ private JFreeChart pieChart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(JFreeChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public JFreeChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // create a dataset... DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Java", new Double(43.2)); data.setValue("Visual Basic", new Double(0.0)); data.setValue("C/C++", new Double(17.5)); // create the chart... this.pieChart = ChartFactory.createPieChart( "Pie Chart", // chart title data, // data true, // include legend true, false ); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { JFreeChart chart1 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); JFreeChart chart2 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); assertTrue(chart1.equals(chart2)); assertTrue(chart2.equals(chart1)); // renderingHints chart1.setRenderingHints(new RenderingHints( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); assertFalse(chart1.equals(chart2)); chart2.setRenderingHints(new RenderingHints( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); assertTrue(chart1.equals(chart2)); // borderVisible chart1.setBorderVisible(true); assertFalse(chart1.equals(chart2)); chart2.setBorderVisible(true); assertTrue(chart1.equals(chart2)); // borderStroke BasicStroke s = new BasicStroke(2.0f); chart1.setBorderStroke(s); assertFalse(chart1.equals(chart2)); chart2.setBorderStroke(s); assertTrue(chart1.equals(chart2)); // borderPaint chart1.setBorderPaint(Color.red); assertFalse(chart1.equals(chart2)); chart2.setBorderPaint(Color.red); assertTrue(chart1.equals(chart2)); // padding chart1.setPadding(new RectangleInsets(1, 2, 3, 4)); assertFalse(chart1.equals(chart2)); chart2.setPadding(new RectangleInsets(1, 2, 3, 4)); assertTrue(chart1.equals(chart2)); // title chart1.setTitle("XYZ"); assertFalse(chart1.equals(chart2)); chart2.setTitle("XYZ"); assertTrue(chart1.equals(chart2)); // subtitles chart1.addSubtitle(new TextTitle("Subtitle")); assertFalse(chart1.equals(chart2)); chart2.addSubtitle(new TextTitle("Subtitle")); assertTrue(chart1.equals(chart2)); // plot chart1 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false); chart2 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false); assertFalse(chart1.equals(chart2)); chart2 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false); assertTrue(chart1.equals(chart2)); // backgroundPaint chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(chart1.equals(chart2)); chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(chart1.equals(chart2)); // backgroundImage chart1.setBackgroundImage(JFreeChart.INFO.getLogo()); assertFalse(chart1.equals(chart2)); chart2.setBackgroundImage(JFreeChart.INFO.getLogo()); assertTrue(chart1.equals(chart2)); // backgroundImageAlignment chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT); assertFalse(chart1.equals(chart2)); chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT); assertTrue(chart1.equals(chart2)); // backgroundImageAlpha chart1.setBackgroundImageAlpha(0.1f); assertFalse(chart1.equals(chart2)); chart2.setBackgroundImageAlpha(0.1f); assertTrue(chart1.equals(chart2)); } /** * A test to make sure that the legend is being picked up in the * equals() testing. */ public void testEquals2() { JFreeChart chart1 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); JFreeChart chart2 = new JFreeChart("Title", new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false); assertFalse(chart1.equals(chart2)); assertFalse(chart2.equals(chart1)); } /** * Checks the subtitle count - should be 1 (the legend). */ public void testSubtitleCount() { int count = this.pieChart.getSubtitleCount(); assertEquals(1, count); } /** * Some checks for the getSubtitle() method. */ public void testGetSubtitle() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true, false, false); Title t = chart.getSubtitle(0); assertTrue(t instanceof LegendTitle); boolean pass = false; try { t = chart.getSubtitle(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { t = chart.getSubtitle(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { t = chart.getSubtitle(2); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Serialize a pie chart, restore it, and check for equality. */ public void testSerialization1() { DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Type 1", 54.5); data.setValue("Type 2", 23.9); data.setValue("Type 3", 45.8); JFreeChart c1 = ChartFactory.createPieChart("Test", data, true, true, true); JFreeChart c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); LegendTitle lt2 = c2.getLegend(); assertTrue(lt2.getSources()[0] == c2.getPlot()); } /** * Serialize a 3D pie chart, restore it, and check for equality. */ public void testSerialization2() { DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Type 1", 54.5); data.setValue("Type 2", 23.9); data.setValue("Type 3", 45.8); JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true, true); JFreeChart c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Serialize a bar chart, restore it, and check for equality. */ public void testSerialization3() { // row keys... String series1 = "First"; String series2 = "Second"; String series3 = "Third"; // column keys... String category1 = "Category 1"; String category2 = "Category 2"; String category3 = "Category 3"; String category4 = "Category 4"; String category5 = "Category 5"; String category6 = "Category 6"; String category7 = "Category 7"; String category8 = "Category 8"; // create the dataset... DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, category1); dataset.addValue(4.0, series1, category2); dataset.addValue(3.0, series1, category3); dataset.addValue(5.0, series1, category4); dataset.addValue(5.0, series1, category5); dataset.addValue(7.0, series1, category6); dataset.addValue(7.0, series1, category7); dataset.addValue(8.0, series1, category8); dataset.addValue(5.0, series2, category1); dataset.addValue(7.0, series2, category2); dataset.addValue(6.0, series2, category3); dataset.addValue(8.0, series2, category4); dataset.addValue(4.0, series2, category5); dataset.addValue(4.0, series2, category6); dataset.addValue(2.0, series2, category7); dataset.addValue(1.0, series2, category8); dataset.addValue(4.0, series3, category1); dataset.addValue(3.0, series3, category2); dataset.addValue(2.0, series3, category3); dataset.addValue(3.0, series3, category4); dataset.addValue(6.0, series3, category5); dataset.addValue(3.0, series3, category6); dataset.addValue(4.0, series3, category7); dataset.addValue(3.0, series3, category8); // create the chart... JFreeChart c1 = ChartFactory.createBarChart( "Vertical Bar Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, false ); JFreeChart c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Serialize a time seroes chart, restore it, and check for equality. */ public void testSerialization4() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Series 1"); series.add(t, 36.4); t = t.next(); series.add(t, 63.5); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", "Value", dataset, true, true, true); JFreeChart c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Some checks for the addSubtitle() methods. */ public void testAddSubtitle() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true, false, false); TextTitle t0 = new TextTitle("T0"); chart.addSubtitle(0, t0); assertEquals(t0, chart.getSubtitle(0)); TextTitle t1 = new TextTitle("T1"); chart.addSubtitle(t1); assertEquals(t1, chart.getSubtitle(2)); // subtitle 1 is the legend boolean pass = false; try { chart.addSubtitle(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { chart.addSubtitle(-1, t0); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { chart.addSubtitle(4, t0); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSubtitles() method. */ public void testGetSubtitles() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true, false, false); List subtitles = chart.getSubtitles(); assertEquals(1, chart.getSubtitleCount()); // adding something to the returned list should NOT change the chart subtitles.add(new TextTitle("T")); assertEquals(1, chart.getSubtitleCount()); } /** * Some checks for the default legend firing change events. */ public void testLegendEvents() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true, false, false); chart.addChangeListener(this); this.lastChartChangeEvent = null; LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.TOP); assertNotNull(this.lastChartChangeEvent); } /** * Some checks for title changes and event notification. */ public void testTitleChangeEvent() { DefaultPieDataset dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("title", dataset, true, false, false); chart.addChangeListener(this); this.lastChartChangeEvent = null; TextTitle t = chart.getTitle(); t.setFont(new Font("Dialog", Font.BOLD, 9)); assertNotNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; // now create a new title and replace the existing title, several // things should happen: // (1) Adding the new title should trigger an immediate // ChartChangeEvent; // (2) Modifying the new title should trigger a ChartChangeEvent; // (3) Modifying the old title should NOT trigger a ChartChangeEvent TextTitle t2 = new TextTitle("T2"); chart.setTitle(t2); assertNotNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; t2.setFont(new Font("Dialog", Font.BOLD, 9)); assertNotNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; t.setFont(new Font("Dialog", Font.BOLD, 9)); assertNull(this.lastChartChangeEvent); this.lastChartChangeEvent = null; } /** The last ChartChangeEvent received. */ private ChartChangeEvent lastChartChangeEvent; /** * Records the last chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.lastChartChangeEvent = event; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/LegendItemCollectionTests.java0000644000175000017500000001232311173030414031344 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * LegendItemCollectionTests.java * ------------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Apr-2005 : Version 1 (DG); * 23-Apr-2008 : Extended testCloning() (DG); * */ package org.jfree.chart.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; /** * Tests for the {@link LegendItemCollection} class. */ public class LegendItemCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LegendItemCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LegendItemCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { LegendItemCollection c1 = new LegendItemCollection(); LegendItemCollection c2 = new LegendItemCollection(); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); LegendItem item1 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); LegendItem item2 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); c1.add(item1); c2.add(item2); assertTrue(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LegendItemCollection c1 = new LegendItemCollection(); c1.add(new LegendItem("Item", "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.red)); LegendItemCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (LegendItemCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Confirm that cloning works. */ public void testCloning() { LegendItemCollection c1 = new LegendItemCollection(); LegendItem item1 = new LegendItem("Item 1"); c1.add(item1); LegendItemCollection c2 = null; try { c2 = (LegendItemCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); Rectangle2D item1Shape = (Rectangle2D) item1.getShape(); item1Shape.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(c1.equals(c2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/LegendItemTests.java0000644000175000017500000004362711173030414027343 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * LegendItemTests.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Jun-2004 : Version 1 (DG); * 10-Dec-2005 : Addded new test to cover bug report 1374328 (DG); * 13-Dec-2006 : Extended testEquals() for new fillPaintTransformer * attribute (DG); * 23-Apr-2008 : Implemented Cloneable (DG); * 17-Jun-2008 : Included new fields in existing tests (DG); * */ package org.jfree.chart.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.font.TextAttribute; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.AttributedString; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.LegendItem; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.StandardGradientPaintTransformer; /** * Tests for the {@link LegendItem} class. */ public class LegendItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LegendItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LegendItemTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { LegendItem item1 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); LegendItem item2 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); item1 = new LegendItem("Label2", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.1f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.1f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.green); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.green); assertTrue(item1.equals(item2)); item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.white ); assertFalse(item1.equals(item2)); item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.white); assertTrue(item1.equals(item2)); // fillPaintTransformer item1.setFillPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); assertFalse(item1.equals(item2)); item2.setFillPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); assertTrue(item1.equals(item2)); // labelFont item1.setLabelFont(new Font("Dialog", Font.PLAIN, 13)); assertFalse(item1.equals(item2)); item2.setLabelFont(new Font("Dialog", Font.PLAIN, 13)); assertTrue(item1.equals(item2)); // labelPaint item1.setLabelPaint(Color.red); assertFalse(item1.equals(item2)); item2.setLabelPaint(Color.red); assertTrue(item1.equals(item2)); // fillPaint item1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.blue)); assertFalse(item1.equals(item2)); item2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.blue)); assertTrue(item1.equals(item2)); // outlinePaint item1.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f, 4.4f, Color.blue)); assertFalse(item1.equals(item2)); item2.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f, 4.4f, Color.blue)); assertTrue(item1.equals(item2)); // linePaint item1.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f, 0.4f, Color.blue)); assertFalse(item1.equals(item2)); item2.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f, 0.4f, Color.blue)); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LegendItem item1 = new LegendItem("Item", "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new GradientPaint( 5.0f, 6.0f, Color.blue, 7.0f, 8.0f, Color.gray)); item1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); item1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.green, 2.0f, 1.0f, Color.red)); item1.setLinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red)); LegendItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (LegendItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { AttributedString as = new AttributedString("Test String"); as.addAttribute(TextAttribute.FONT, new Font("Dialog", Font.PLAIN, 12)); LegendItem item1 = new LegendItem(as, "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.red); LegendItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (LegendItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2); } /** * Basic checks for cloning. */ public void testCloning() { LegendItem item1 = new LegendItem("Item"); LegendItem item2 = null; try { item2 = (LegendItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2)); // the clone references the same dataset as the original assertTrue(item1.getDataset() == item2.getDataset()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/LineChart3DTests.java0000644000175000017500000001574011173030414027361 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * LineChart3DTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Some tests for a line chart with a 3D effect. */ public class LineChart3DTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineChart3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineChart3DTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createLineChart3D(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the chart's dataset and then checks that the new dataset is OK. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a line chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createLineChart3D() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createLineChart3D( "Line Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend true, true ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/LineChartTests.java0000644000175000017500000001567511173030414027201 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * LineChartTests.java * ------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Some tests for a line chart. */ public class LineChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createLineChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the chart's dataset and then checks that the new dataset is OK. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a line chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createLineChart() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createLineChart( "Line Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend true, true ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/MeterChartTests.java0000644000175000017500000000621311173030414027352 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * MeterChartTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 29-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.MeterInterval; import org.jfree.chart.plot.MeterPlot; import org.jfree.data.Range; import org.jfree.data.general.DefaultValueDataset; /** * Miscellaneous checks for meter charts. */ public class MeterChartTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MeterChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MeterChartTests(String name) { super(name); } /** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ public void testDrawWithNullInfo() { boolean success = false; MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); try { BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/PaintMapTests.java0000644000175000017500000001536111173030414027031 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * PaintMapTests.java * ------------------ * (C) Copyright 2006, 2007, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 27-Sep-2006 : Version 1 (DG); * 17-Jan-2007 : Added testKeysOfDifferentClasses() (DG); * */ package org.jfree.chart.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.PaintMap; /** * Some tests for the {@link PaintMap} class. */ public class PaintMapTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PaintMapTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PaintMapTests(String name) { super(name); } /** * Some checks for the getPaint() method. */ public void testGetPaint() { PaintMap m1 = new PaintMap(); assertEquals(null, m1.getPaint("A")); m1.put("A", Color.red); assertEquals(Color.red, m1.getPaint("A")); m1.put("A", null); assertEquals(null, m1.getPaint("A")); // a null key should throw an IllegalArgumentException boolean pass = false; try { m1.getPaint(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the put() method. */ public void testPut() { PaintMap m1 = new PaintMap(); m1.put("A", Color.red); assertEquals(Color.red, m1.getPaint("A")); // a null key should throw an IllegalArgumentException boolean pass = false; try { m1.put(null, Color.blue); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the equals() method. */ public void testEquals() { PaintMap m1 = new PaintMap(); PaintMap m2 = new PaintMap(); assertTrue(m1.equals(m1)); assertTrue(m1.equals(m2)); assertFalse(m1.equals(null)); assertFalse(m1.equals("ABC")); m1.put("K1", Color.red); assertFalse(m1.equals(m2)); m2.put("K1", Color.red); assertTrue(m1.equals(m2)); m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(m1.equals(m2)); m2.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertTrue(m1.equals(m2)); m1.put("K2", null); assertFalse(m1.equals(m2)); m2.put("K2", null); assertTrue(m1.equals(m2)); } /** * Some checks for cloning. */ public void testCloning() { PaintMap m1 = new PaintMap(); PaintMap m2 = null; try { m2 = (PaintMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); m1.put("K1", Color.red); m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); try { m2 = (PaintMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); } /** * A check for serialization. */ public void testSerialization1() { PaintMap m1 = new PaintMap(); PaintMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (PaintMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } /** * A check for serialization. */ public void testSerialization2() { PaintMap m1 = new PaintMap(); m1.put("K1", Color.red); m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); PaintMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (PaintMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } /** * This test covers a bug reported in the forum: * * http://www.jfree.org/phpBB2/viewtopic.php?t=19980 */ public void testKeysOfDifferentClasses() { PaintMap m = new PaintMap(); m.put("ABC", Color.red); m.put(new Integer(99), Color.blue); assertEquals(Color.blue, m.getPaint(new Integer(99))); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/PieChart3DTests.java0000644000175000017500000001175311173030414027207 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PieChart3DTests.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 21-May-2004 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; /** * Tests for a pie chart with a 3D effect. */ public class PieChart3DTests extends TestCase { /** A chart. */ private JFreeChart pieChart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PieChart3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PieChart3DTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // create a dataset... DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Java", new Double(43.2)); dataset.setValue("Visual Basic", new Double(0.0)); dataset.setValue("C/C++", new Double(17.5)); this.pieChart = createPieChart3D(dataset); } /** * Using a regular pie chart, we replace the dataset with null. Expect to * receive notification of a chart change event, and (of course) the * dataset should be null. */ public void testReplaceDatasetOnPieChart() { LocalListener l = new LocalListener(); this.pieChart.addChangeListener(l); PiePlot plot = (PiePlot) this.pieChart.getPlot(); plot.setDataset(null); assertEquals(true, l.flag); assertNull(plot.getDataset()); } /** * Tests that no exceptions are thrown when there is a null * value in the dataset. */ public void testNullValueInDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Section 1", 10.0); dataset.setValue("Section 2", 11.0); dataset.setValue("Section 3", null); JFreeChart chart = createPieChart3D(dataset); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Throwable t) { success = false; } assertTrue(success); } /** * Creates a pie chart. * * @param dataset the dataset. * * @return The pie chart. */ private static JFreeChart createPieChart3D(PieDataset dataset) { return ChartFactory.createPieChart3D( "Pie Chart", // chart title dataset, // data true, // include legend true, false ); } /** * A chart change listener. */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/PieChartTests.java0000644000175000017500000001016711173030414027016 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * PieChartTests.java * ------------------ * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.chart.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; /** * Tests for a pie chart. * */ public class PieChartTests extends TestCase { /** A chart. */ private JFreeChart pieChart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PieChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PieChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.pieChart = createPieChart(); } /** * Using a regular pie chart, we replace the dataset with null. Expect to * receive notification of a chart change event, and (of course) the * dataset should be null. */ public void testReplaceDatasetOnPieChart() { LocalListener l = new LocalListener(); this.pieChart.addChangeListener(l); PiePlot plot = (PiePlot) this.pieChart.getPlot(); plot.setDataset(null); assertEquals(true, l.flag); assertNull(plot.getDataset()); } /** * Creates a pie chart. * * @return The pie chart. */ private static JFreeChart createPieChart() { // create a dataset... DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Java", new Double(43.2)); data.setValue("Visual Basic", new Double(0.0)); data.setValue("C/C++", new Double(17.5)); // create the chart... return ChartFactory.createPieChart("Pie Chart", // chart title data, // data true, // include legend true, false ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/ScatterPlotTests.java0000644000175000017500000001436011173030414027562 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ScatterPlotTests.java * --------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Tests for a scatter plot. */ public class ScatterPlotTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ScatterPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ScatterPlotTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createScatterPlot( "Scatter Plot", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/StackedAreaChartTests.java0000644000175000017500000001601211173030414030443 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * StackedAreaChartTests.java * -------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Some tests for a stacked area chart. */ public class StackedAreaChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedAreaChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedAreaChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a stacked bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createStackedAreaChart( "Stacked Area Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.HORIZONTAL, true, // include legend true, true ); } /** * A chart change listener. */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/StackedBarChart3DTests.java0000644000175000017500000001604511173030414030474 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StackedBarChart3DTests.java * --------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Some tests for a stacked bar chart with 3D effect. */ public class StackedBarChart3DTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedBarChart3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedBarChart3DTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a stacked bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createStackedBarChart3D( "Stacked Bar Chart 3D", // chart title "Domain", "Range", dataset, // data PlotOrientation.HORIZONTAL, true, // include legend true, true ); } /** * A chart change listener. */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/StackedBarChartTests.java0000644000175000017500000001632711173030414030310 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * StackedBarChartTests.java * ------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 11-Jun-2002 : Version 1 (DG); * 25-Jun-2002 : Removed unnecessary import (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 29-Jan-2004 : Renamed StackedHorizontalBarChartTests * --> StackedBarChartTests (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Tests for a stacked bar chart. */ public class StackedBarChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedBarChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedBarChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-30), new Integer(-20)}, {new Integer(-10), new Integer(10)}, {new Integer(20), new Integer(30)}}; CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); plot.setDataset(newData); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a stacked bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createStackedBarChart( "Stacked Bar Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.HORIZONTAL, true, // include legend true, true ); } /** * A chart change listener. */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/StandardChartThemeTests.java0000644000175000017500000002752211173030414031027 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * StandardChartThemeTests.java * ---------------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2008 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.StandardChartTheme; import org.jfree.chart.plot.DefaultDrawingSupplier; import org.jfree.chart.plot.PieLabelLinkStyle; import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.chart.renderer.xy.StandardXYBarPainter; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link StandardChartTheme} class. */ public class StandardChartThemeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardChartThemeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardChartThemeTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardChartTheme t1 = new StandardChartTheme("Name"); StandardChartTheme t2 = new StandardChartTheme("Name"); assertTrue(t1.equals(t2)); // name t1 = new StandardChartTheme("t1"); assertFalse(t1.equals(t2)); t2 = new StandardChartTheme("t1"); assertTrue(t1.equals(t2)); //extraLargeFont t1.setExtraLargeFont(new Font("Dialog", Font.PLAIN, 21)); assertFalse(t1.equals(t2)); t2.setExtraLargeFont(new Font("Dialog", Font.PLAIN, 21)); assertTrue(t1.equals(t2)); //largeFont t1.setLargeFont(new Font("Dialog", Font.PLAIN, 19)); assertFalse(t1.equals(t2)); t2.setLargeFont(new Font("Dialog", Font.PLAIN, 19)); assertTrue(t1.equals(t2)); //regularFont; t1.setRegularFont(new Font("Dialog", Font.PLAIN, 17)); assertFalse(t1.equals(t2)); t2.setRegularFont(new Font("Dialog", Font.PLAIN, 17)); assertTrue(t1.equals(t2)); //titlePaint; t1.setTitlePaint(new GradientPaint(0f, 1f, Color.red, 2f, 3f, Color.blue)); assertFalse(t1.equals(t2)); t2.setTitlePaint(new GradientPaint(0f, 1f, Color.red, 2f, 3f, Color.blue)); assertTrue(t1.equals(t2)); //subtitlePaint; t1.setSubtitlePaint(new GradientPaint(1f, 2f, Color.red, 3f, 4f, Color.blue)); assertFalse(t1.equals(t2)); t2.setSubtitlePaint(new GradientPaint(1f, 2f, Color.red, 3f, 4f, Color.blue)); assertTrue(t1.equals(t2)); //chartBackgroundPaint; t1.setChartBackgroundPaint(new GradientPaint(2f, 3f, Color.blue, 4f, 5f, Color.red)); assertFalse(t1.equals(t2)); t2.setChartBackgroundPaint(new GradientPaint(2f, 3f, Color.blue, 4f, 5f, Color.red)); assertTrue(t1.equals(t2)); //legendBackgroundPaint; t1.setLegendBackgroundPaint(new GradientPaint(3f, 4f, Color.gray, 1f, 2f, Color.red)); assertFalse(t1.equals(t2)); t2.setLegendBackgroundPaint(new GradientPaint(3f, 4f, Color.gray, 1f, 2f, Color.red)); assertTrue(t1.equals(t2)); //legendItemPaint; t1.setLegendItemPaint(new GradientPaint(9f, 8f, Color.red, 7f, 6f, Color.blue)); assertFalse(t1.equals(t2)); t2.setLegendItemPaint(new GradientPaint(9f, 8f, Color.red, 7f, 6f, Color.blue)); assertTrue(t1.equals(t2)); //drawingSupplier; t1.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] {Color.red}, new Paint[] {Color.blue}, new Stroke[] {new BasicStroke(1.0f)}, new Stroke[] {new BasicStroke(1.0f)}, new Shape[] {new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)})); assertFalse(t1.equals(t2)); t2.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] {Color.red}, new Paint[] {Color.blue}, new Stroke[] {new BasicStroke(1.0f)}, new Stroke[] {new BasicStroke(1.0f)}, new Shape[] {new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)})); assertTrue(t1.equals(t2)); //plotBackgroundPaint; t1.setPlotBackgroundPaint(new GradientPaint(4f, 3f, Color.red, 6f, 7f, Color.blue)); assertFalse(t1.equals(t2)); t2.setPlotBackgroundPaint(new GradientPaint(4f, 3f, Color.red, 6f, 7f, Color.blue)); assertTrue(t1.equals(t2)); //plotOutlinePaint; t1.setPlotOutlinePaint(new GradientPaint(5f, 2f, Color.blue, 6f, 7f, Color.red)); assertFalse(t1.equals(t2)); t2.setPlotOutlinePaint(new GradientPaint(5f, 2f, Color.blue, 6f, 7f, Color.red)); assertTrue(t1.equals(t2)); //labelLinkStyle; t1.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); assertFalse(t1.equals(t2)); t2.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); assertTrue(t1.equals(t2)); //labelLinkPaint; t1.setLabelLinkPaint(new GradientPaint(4f, 3f, Color.red, 2f, 9f, Color.blue)); assertFalse(t1.equals(t2)); t2.setLabelLinkPaint(new GradientPaint(4f, 3f, Color.red, 2f, 9f, Color.blue)); assertTrue(t1.equals(t2)); //domainGridlinePaint; t1.setDomainGridlinePaint(Color.blue); assertFalse(t1.equals(t2)); t2.setDomainGridlinePaint(Color.blue); assertTrue(t1.equals(t2)); //rangeGridlinePaint; t1.setRangeGridlinePaint(Color.red); assertFalse(t1.equals(t2)); t2.setRangeGridlinePaint(Color.red); assertTrue(t1.equals(t2)); //axisOffset; t1.setAxisOffset(new RectangleInsets(1, 2, 3, 4)); assertFalse(t1.equals(t2)); t2.setAxisOffset(new RectangleInsets(1, 2, 3, 4)); assertTrue(t1.equals(t2)); //axisLabelPaint; t1.setAxisLabelPaint(new GradientPaint(8f, 4f, Color.gray, 2f, 9f, Color.blue)); assertFalse(t1.equals(t2)); t2.setAxisLabelPaint(new GradientPaint(8f, 4f, Color.gray, 2f, 9f, Color.blue)); assertTrue(t1.equals(t2)); //tickLabelPaint; t1.setTickLabelPaint(new GradientPaint(3f, 4f, Color.red, 5f, 6f, Color.yellow)); assertFalse(t1.equals(t2)); t2.setTickLabelPaint(new GradientPaint(3f, 4f, Color.red, 5f, 6f, Color.yellow)); assertTrue(t1.equals(t2)); //itemLabelPaint; t1.setItemLabelPaint(new GradientPaint(2f, 5f, Color.gray, 1f, 2f, Color.blue)); assertFalse(t1.equals(t2)); t2.setItemLabelPaint(new GradientPaint(2f, 5f, Color.gray, 1f, 2f, Color.blue)); assertTrue(t1.equals(t2)); //shadowVisible; t1.setShadowVisible(!t1.isShadowVisible()); assertFalse(t1.equals(t2)); t2.setShadowVisible(t1.isShadowVisible()); assertTrue(t1.equals(t2)); //shadowPaint; t1.setShadowPaint(new GradientPaint(7f, 1f, Color.blue, 4f, 6f, Color.red)); assertFalse(t1.equals(t2)); t2.setShadowPaint(new GradientPaint(7f, 1f, Color.blue, 4f, 6f, Color.red)); assertTrue(t1.equals(t2)); //barPainter; t1.setBarPainter(new StandardBarPainter()); assertFalse(t1.equals(t2)); t2.setBarPainter(new StandardBarPainter()); assertTrue(t1.equals(t2)); //xyBarPainter; t1.setXYBarPainter(new StandardXYBarPainter()); assertFalse(t1.equals(t2)); t2.setXYBarPainter(new StandardXYBarPainter()); assertTrue(t1.equals(t2)); //thermometerPaint; t1.setThermometerPaint(new GradientPaint(9f, 7f, Color.red, 5f, 1f, Color.blue)); assertFalse(t1.equals(t2)); t2.setThermometerPaint(new GradientPaint(9f, 7f, Color.red, 5f, 1f, Color.blue)); assertTrue(t1.equals(t2)); //wallPaint; t1.setWallPaint(new GradientPaint(4f, 5f, Color.red, 1f, 0f, Color.gray)); assertFalse(t1.equals(t2)); t2.setWallPaint(new GradientPaint(4f, 5f, Color.red, 1f, 0f, Color.gray)); assertTrue(t1.equals(t2)); //errorIndicatorPaint; t1.setErrorIndicatorPaint(new GradientPaint(0f, 1f, Color.white, 2f, 3f, Color.blue)); assertFalse(t1.equals(t2)); t2.setErrorIndicatorPaint(new GradientPaint(0f, 1f, Color.white, 2f, 3f, Color.blue)); assertTrue(t1.equals(t2)); //gridBandPaint t1.setGridBandPaint(new GradientPaint(1f, 2f, Color.white, 4f, 8f, Color.red)); assertFalse(t1.equals(t2)); t2.setGridBandPaint(new GradientPaint(1f, 2f, Color.white, 4f, 8f, Color.red)); assertTrue(t1.equals(t2)); //gridBandAlternatePaint t1.setGridBandAlternatePaint(new GradientPaint(1f, 4f, Color.green, 1f, 2f, Color.red)); assertFalse(t1.equals(t2)); t2.setGridBandAlternatePaint(new GradientPaint(1f, 4f, Color.green, 1f, 2f, Color.red)); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardChartTheme t1 = new StandardChartTheme("Name"); StandardChartTheme t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (StandardChartTheme) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(t1.equals(t2)); } /** * Basic checks for cloning. */ public void testCloning() { StandardChartTheme t1 = new StandardChartTheme("Name"); StandardChartTheme t2 = null; try { t2 = (StandardChartTheme) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/StrokeMapTests.java0000644000175000017500000001430411173030414027221 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * StrokeMapTests.java * ------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 27-Sep-2006 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.BasicStroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.StrokeMap; /** * Some tests for the {@link StrokeMap} class. */ public class StrokeMapTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StrokeMapTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StrokeMapTests(String name) { super(name); } /** * Some checks for the getStroke() method. */ public void testGetStroke() { StrokeMap m1 = new StrokeMap(); assertEquals(null, m1.getStroke("A")); m1.put("A", new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m1.getStroke("A")); m1.put("A", null); assertEquals(null, m1.getStroke("A")); // a null key should throw an IllegalArgumentException boolean pass = false; try { m1.getStroke(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the put() method. */ public void testPut() { StrokeMap m1 = new StrokeMap(); m1.put("A", new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m1.getStroke("A")); // a null key should throw an IllegalArgumentException boolean pass = false; try { m1.put(null, new BasicStroke(1.1f)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the equals() method. */ public void testEquals() { StrokeMap m1 = new StrokeMap(); StrokeMap m2 = new StrokeMap(); assertTrue(m1.equals(m1)); assertTrue(m1.equals(m2)); assertFalse(m1.equals(null)); assertFalse(m1.equals("ABC")); m1.put("K1", new BasicStroke(1.1f)); assertFalse(m1.equals(m2)); m2.put("K1", new BasicStroke(1.1f)); assertTrue(m1.equals(m2)); m1.put("K2", new BasicStroke(2.2f)); assertFalse(m1.equals(m2)); m2.put("K2", new BasicStroke(2.2f)); assertTrue(m1.equals(m2)); m1.put("K2", null); assertFalse(m1.equals(m2)); m2.put("K2", null); assertTrue(m1.equals(m2)); } /** * Some checks for cloning. */ public void testCloning() { StrokeMap m1 = new StrokeMap(); StrokeMap m2 = null; try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); try { m2 = (StrokeMap) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1.equals(m2)); } /** * A check for serialization. */ public void testSerialization1() { StrokeMap m1 = new StrokeMap(); StrokeMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (StrokeMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } /** * A check for serialization. */ public void testSerialization2() { StrokeMap m1 = new StrokeMap(); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); StrokeMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (StrokeMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/TestUtilities.java0000644000175000017500000000437511173030414027113 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * TestUtilities.java * ------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 08-Jun-2007 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.util.Collection; import java.util.Iterator; /** * Some utility methods for use by the testing code. */ public class TestUtilities { /** * Returns true if the collections contains any object that * is an instance of the specified class, and false otherwise. * * @param collection the collection. * @param c the class. * * @return A boolean. */ public static boolean containsInstanceOf(Collection collection, Class c) { Iterator iterator = collection.iterator(); while (iterator.hasNext()) { Object obj = iterator.next(); if (obj != null && obj.getClass().equals(c)) { return true; } } return false; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/TimeSeriesChartTests.java0000644000175000017500000001420711173030414030351 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TimeSeriesChartTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some tests for a time series chart. */ public class TimeSeriesChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimeSeriesChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimeSeriesChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createTimeSeriesChart( "XY Line Chart", // chart title "Domain", "Range", dataset, // data true, // include legend true, // tooltips true // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/WaterfallChartTests.java0000644000175000017500000001261411173030414030221 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * WaterfallChartTests.java * ------------------------ * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.labels.CategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.urls.CategoryURLGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; /** * Some tests for a waterfall chart. */ public class WaterfallChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(WaterfallChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public WaterfallChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createWaterfallChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); } /** * Create a bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createWaterfallChart() { // create a dataset... Number[][] data = new Integer[][] {{new Integer(-3), new Integer(-2)}, {new Integer(-1), new Integer(1)}, {new Integer(2), new Integer(3)}}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data); // create the chart... return ChartFactory.createWaterfallChart( "Waterfall Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, true, // include legend true, true ); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/XYAreaChartTests.java0000644000175000017500000001427011173030414027431 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYAreaChartTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some tests for an XY area chart. */ public class XYAreaChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYAreaChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYAreaChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createXYAreaChart( "Area Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/XYBarChartTests.java0000644000175000017500000001447511173030414027274 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYBarChartTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYBarDataset; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some tests for an XY bar chart. */ public class XYBarChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBarChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBarChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); // create the chart... return ChartFactory.createXYBarChart( "XY Bar Chart", // chart title "Domain", false, "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/XYLineChartTests.java0000644000175000017500000001427311173030414027453 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYLineChartTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some tests for an XY line chart. */ public class XYLineChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYLineChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYLineChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createXYLineChart( "XY Line Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/XYStepAreaChartTests.java0000644000175000017500000001433011173030414030262 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYStepAreaChartTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some tests for an XY step area chart. */ public class XYStepAreaChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYStepAreaChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYStepAreaChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createXYStepAreaChart( "Step Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/XYStepChartTests.java0000644000175000017500000001426711173030414027502 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * XYStepChartTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 12-Apr-2005 : Version 1 (DG); * */ package org.jfree.chart.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some tests for an XY step plot. */ public class XYStepChartTests extends TestCase { /** A chart. */ private JFreeChart chart; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYStepChartTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYStepChartTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.chart = createChart(); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown (a problem that was occurring at one point). */ public void testDrawWithNullInfo() { boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; e.printStackTrace(); } assertTrue(success); } /** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); } /** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { XYPlot plot = (XYPlot) this.chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); } /** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createXYStepChart( "Step Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); } /** * A chart change listener. * */ static class LocalListener implements ChartChangeListener { /** A flag. */ private boolean flag = false; /** * Event handler. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.flag = true; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/junit/package.html0000644000175000017500000000026111173030414025704 0ustar vincentvincent Test cases for the JFreeChart class library, based on the JUnit framework. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/0000755000175000017500000000000011173030414023535 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/0000755000175000017500000000000011216245562024700 5ustar vincentvincent././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/BoxAndWhiskerToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/BoxAndWhiskerToolTipGeneratorTests0000644000175000017500000001273311173030414033534 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------- * BoxAndWhiskerToolTipGeneratorTests.java * --------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Jun-2004 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link BoxAndWhiskerToolTipGenerator} class. */ public class BoxAndWhiskerToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BoxAndWhiskerToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BoxAndWhiskerToolTipGeneratorTests(String name) { super(name); } /** * A series of tests for the equals() method. */ public void testEquals() { // standard test BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); // tooltip format g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.0")); g2 = new BoxAndWhiskerToolTipGenerator("{1} {2}", new DecimalFormat("0.0")); assertFalse(g1.equals(g2)); g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.0")); assertTrue(g1.equals(g2)); // Y format g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.0")); g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.00")); assertFalse(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = null; try { g2 = (BoxAndWhiskerToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (BoxAndWhiskerToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/BoxAndWhiskerXYToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/BoxAndWhiskerXYToolTipGeneratorTes0000644000175000017500000001516211173030414033445 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------------- * BoxAndWhiskerXYToolTipGeneratorTests.java * ----------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2003 : Version 1 (DG); * 27-Feb-2004 : Renamed BoxAndWhiskerItemLabelGenerator * --> XYBoxAndWhiskerItemLabelGenerator (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.BoxAndWhiskerXYToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link BoxAndWhiskerXYToolTipGenerator} class. */ public class BoxAndWhiskerXYToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BoxAndWhiskerXYToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BoxAndWhiskerXYToolTipGeneratorTests(String name) { super(name); } /** * A series of tests for the equals() method. */ public void testEquals() { // standard test BoxAndWhiskerXYToolTipGenerator g1 = new BoxAndWhiskerXYToolTipGenerator(); BoxAndWhiskerXYToolTipGenerator g2 = new BoxAndWhiskerXYToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); // tooltip format g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); g2 = new BoxAndWhiskerXYToolTipGenerator("{1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); assertFalse(g1.equals(g2)); g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); assertTrue(g1.equals(g2)); // date format g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.0")); assertFalse(g1.equals(g2)); g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); assertTrue(g1.equals(g2)); // Y format g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.00")); assertFalse(g1.equals(g2)); g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { BoxAndWhiskerXYToolTipGenerator g1 = new BoxAndWhiskerXYToolTipGenerator(); BoxAndWhiskerXYToolTipGenerator g2 = new BoxAndWhiskerXYToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { BoxAndWhiskerXYToolTipGenerator g1 = new BoxAndWhiskerXYToolTipGenerator(); BoxAndWhiskerXYToolTipGenerator g2 = null; try { g2 = (BoxAndWhiskerXYToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { BoxAndWhiskerXYToolTipGenerator g1 = new BoxAndWhiskerXYToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BoxAndWhiskerXYToolTipGenerator g1 = new BoxAndWhiskerXYToolTipGenerator(); BoxAndWhiskerXYToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (BoxAndWhiskerXYToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/BubbleXYItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/BubbleXYItemLabelGeneratorTests.ja0000644000175000017500000001761011173030414033334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * BubbleXYItemLabelGeneratorTests.java * ------------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jan-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.BubbleXYItemLabelGenerator; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link BubbleXYItemLabelGenerator} class. */ public class BubbleXYItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BubbleXYItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BubbleXYItemLabelGeneratorTests(String name) { super(name); } /** * A series of tests for the equals() method. */ public void testEquals() { // some setup... String f1 = "{1}"; String f2 = "{2}"; NumberFormat xnf1 = new DecimalFormat("0.00"); NumberFormat xnf2 = new DecimalFormat("0.000"); NumberFormat ynf1 = new DecimalFormat("0.00"); NumberFormat ynf2 = new DecimalFormat("0.000"); NumberFormat znf1 = new DecimalFormat("0.00"); NumberFormat znf2 = new DecimalFormat("0.000"); BubbleXYItemLabelGenerator g1 = null; BubbleXYItemLabelGenerator g2 = null; g1 = new BubbleXYItemLabelGenerator(f1, xnf1, ynf1, znf1); g2 = new BubbleXYItemLabelGenerator(f1, xnf1, ynf1, znf1); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new BubbleXYItemLabelGenerator(f2, xnf1, ynf1, znf1); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f2, xnf1, ynf1, znf1); assertTrue(g1.equals(g2)); g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf1, znf1); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf1, znf1); assertTrue(g1.equals(g2)); g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf1); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf1); assertTrue(g1.equals(g2)); g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf2); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf2); assertTrue(g1.equals(g2)); DateFormat xdf1 = new SimpleDateFormat("d-MMM"); DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); DateFormat ydf1 = new SimpleDateFormat("d-MMM"); DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); DateFormat zdf1 = new SimpleDateFormat("d-MMM"); DateFormat zdf2 = new SimpleDateFormat("d-MMM-yyyy"); g1 = new BubbleXYItemLabelGenerator(f1, xdf1, ydf1, zdf1); g2 = new BubbleXYItemLabelGenerator(f1, xdf1, ydf1, zdf1); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf1, zdf1); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf1, zdf1); assertTrue(g1.equals(g2)); g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf1); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf1); assertTrue(g1.equals(g2)); g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf2); assertFalse(g1.equals(g2)); g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf2); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); BubbleXYItemLabelGenerator g2 = new BubbleXYItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); BubbleXYItemLabelGenerator g2 = null; try { g2 = (BubbleXYItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); BubbleXYItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (BubbleXYItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Some checks for the testGenerateLabel() method. */ public void testGenerateLabel() { // check handling when the dataset is a regular XYDataset, not an // XYZDataset... XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 2.0); s1.add(2.2, 3.3); XYSeriesCollection dataset = new XYSeriesCollection(s1); BubbleXYItemLabelGenerator g = new BubbleXYItemLabelGenerator(); assertEquals("{3}", g.generateLabel(dataset, 0, 0)); assertEquals("{3}", g.generateLabel(dataset, 0, 1)); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/CustomXYItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/CustomXYItemLabelGeneratorTests.ja0000644000175000017500000001060311173030414033406 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * CustomXYItemLabelGeneratorTests.java * ------------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added cloning tests (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.CustomXYToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CustomXYToolTipGenerator} class. */ public class CustomXYItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CustomXYItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CustomXYItemLabelGeneratorTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator(); CustomXYToolTipGenerator g2 = null; try { g2 = (CustomXYToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { List t1 = new java.util.ArrayList(); t1.add("Tooltip A1"); t1.add("Tooltip A2"); t1.add("Tooltip A3"); List t2 = new java.util.ArrayList(); t2.add("Tooltip B1"); t2.add("Tooltip B2"); t2.add("Tooltip B3"); CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator(); g1.addToolTipSeries(t1); g1.addToolTipSeries(t2); CustomXYToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (CustomXYToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/HighLowItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/HighLowItemLabelGeneratorTests.jav0000644000175000017500000001256411173030414033412 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * HighLowItemLabelGeneratorTests.java * ----------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.HighLowItemLabelGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link HighLowItemLabelGenerator} class. */ public class HighLowItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(HighLowItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public HighLowItemLabelGeneratorTests(String name) { super(name); } /** * Tests that the equals method can distinguish all fields. */ public void testEquals() { HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); HighLowItemLabelGenerator g2 = new HighLowItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), NumberFormat.getInstance()); assertFalse(g1.equals(g2)); g2 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), NumberFormat.getInstance()); assertTrue(g1.equals(g2)); g1 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); HighLowItemLabelGenerator g2 = new HighLowItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); HighLowItemLabelGenerator g2 = null; try { g2 = (HighLowItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); HighLowItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (HighLowItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/IntervalCategoryItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/IntervalCategoryItemLabelGenerator0000644000175000017500000001334211173030414033524 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------- * IntervalCategoryLabelGeneratorTests.java * ---------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added cloning tests, and renamed class (DG); * 23-Apr-2008 : Added testPublicCloneble() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.IntervalCategoryItemLabelGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link IntervalCategoryItemLabelGenerator} class. */ public class IntervalCategoryItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(IntervalCategoryItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public IntervalCategoryItemLabelGeneratorTests(String name) { super(name); } /** * Tests the equals() method. */ public void testEquals() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = null; try { g2 = (IntervalCategoryItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", DateFormat.getInstance()); IntervalCategoryItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (IntervalCategoryItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/IntervalCategoryToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/IntervalCategoryToolTipGeneratorTe0000644000175000017500000001431511173030414033552 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------------ * IntervalCategoryToolTipGeneratorTests.java * ------------------------------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 07-Oct-2008 : Version 1, based on * IntervalCategoryItemLabelGeneratorTests (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.IntervalCategoryToolTipGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link IntervalCategoryToolTipGenerator} class. */ public class IntervalCategoryToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(IntervalCategoryToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public IntervalCategoryToolTipGeneratorTests(String name) { super(name); } /** * Tests the equals() method. */ public void testEquals() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); IntervalCategoryToolTipGenerator g2 = new IntervalCategoryToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new IntervalCategoryToolTipGenerator("{3} - {4}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryToolTipGenerator("{3} - {4}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new IntervalCategoryToolTipGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryToolTipGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertTrue(g1.equals(g2)); } /** * Check that the subclass is not equal to an instance of the superclass. */ public void testEquals2() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); StandardCategoryToolTipGenerator g2 = new StandardCategoryToolTipGenerator( IntervalCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); assertFalse(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); IntervalCategoryToolTipGenerator g2 = new IntervalCategoryToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); IntervalCategoryToolTipGenerator g2 = null; try { g2 = (IntervalCategoryToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getInstance()); IntervalCategoryToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (IntervalCategoryToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/ItemLabelAnchorTests.java0000644000175000017500000000645411173030414031556 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ItemLabelAnchorTests.java * ------------------------- * (C) Copyright 2004, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Feb-2004 : Version 1 (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.ItemLabelAnchor; /** * Tests for the {@link ItemLabelAnchor} class. */ public class ItemLabelAnchorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ItemLabelAnchorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ItemLabelAnchorTests(String name) { super(name); } /** * Test the equals() method. */ public void testEquals() { assertTrue(ItemLabelAnchor.INSIDE1.equals(ItemLabelAnchor.INSIDE1)); assertFalse(ItemLabelAnchor.INSIDE1.equals(ItemLabelAnchor.INSIDE2)); } /** * Serialize an instance, restore it, and check for identity. */ public void testSerialization() { ItemLabelAnchor a1 = ItemLabelAnchor.INSIDE1; ItemLabelAnchor a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (ItemLabelAnchor) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(a1 == a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/ItemLabelPositionTests.java0000644000175000017500000000662011173030414032143 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * ItemLabelPositionTests.java * --------------------------- * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Oct-2003 : Version 1 (DG); * 19-Feb-2004 : Moved to org.jfree.chart.labels.junit (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.ItemLabelPosition; /** * Tests for the {@link ItemLabelPosition} class. */ public class ItemLabelPositionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ItemLabelPositionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ItemLabelPositionTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { ItemLabelPosition p1 = new ItemLabelPosition(); ItemLabelPosition p2 = new ItemLabelPosition(); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ItemLabelPosition p1 = new ItemLabelPosition(); ItemLabelPosition p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (ItemLabelPosition) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/LabelsPackageTests.java0000644000175000017500000001000311173030414031224 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * LabelsPackageTests.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 21-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Renamed class, added tests (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 20-Feb-2007 : Added MultipleXYSeriesLabelGeneratorTests (DG); * */ package org.jfree.chart.labels.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.labels package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class LabelsPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.labels"); suite.addTestSuite(BoxAndWhiskerToolTipGeneratorTests.class); suite.addTestSuite(BoxAndWhiskerXYToolTipGeneratorTests.class); suite.addTestSuite(BubbleXYItemLabelGeneratorTests.class); suite.addTestSuite(CustomXYItemLabelGeneratorTests.class); suite.addTestSuite(HighLowItemLabelGeneratorTests.class); suite.addTestSuite(IntervalCategoryItemLabelGeneratorTests.class); suite.addTestSuite(IntervalCategoryToolTipGeneratorTests.class); suite.addTestSuite(ItemLabelAnchorTests.class); suite.addTestSuite(ItemLabelPositionTests.class); suite.addTestSuite(MultipleXYSeriesLabelGeneratorTests.class); suite.addTestSuite(StandardCategoryItemLabelGeneratorTests.class); suite.addTestSuite(StandardCategorySeriesLabelGeneratorTests.class); suite.addTestSuite(StandardCategoryToolTipGeneratorTests.class); suite.addTestSuite(StandardContourToolTipGeneratorTests.class); suite.addTestSuite(StandardPieSectionLabelGeneratorTests.class); suite.addTestSuite(StandardPieToolTipGeneratorTests.class); suite.addTestSuite(StandardXYItemLabelGeneratorTests.class); suite.addTestSuite(StandardXYSeriesLabelGeneratorTests.class); suite.addTestSuite(StandardXYToolTipGeneratorTests.class); suite.addTestSuite(StandardXYZToolTipGeneratorTests.class); suite.addTestSuite(SymbolicXYItemLabelGeneratorTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public LabelsPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/MultipleXYSeriesLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/MultipleXYSeriesLabelGeneratorTest0000644000175000017500000001300611173030414033507 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------- * MultipleXYSeriesLabelGeneratorTests.java * ---------------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jan-2007 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.MultipleXYSeriesLabelGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link MultipleXYSeriesLabelGenerator} class. */ public class MultipleXYSeriesLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MultipleXYSeriesLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MultipleXYSeriesLabelGeneratorTests(String name) { super(name); } /** * A series of tests for the equals() method. */ public void testEquals() { MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); MultipleXYSeriesLabelGenerator g2 = new MultipleXYSeriesLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new MultipleXYSeriesLabelGenerator("Series {0}"); assertFalse(g1.equals(g2)); g2 = new MultipleXYSeriesLabelGenerator("Series {0}"); assertTrue(g1.equals(g2)); g1.addSeriesLabel(1, "Additional 1"); assertFalse(g1.equals(g2)); g2.addSeriesLabel(1, "Additional 1"); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); MultipleXYSeriesLabelGenerator g2 = new MultipleXYSeriesLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); MultipleXYSeriesLabelGenerator g2 = null; try { g2 = (MultipleXYSeriesLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence g1.addSeriesLabel(3, "Add3"); assertFalse(g1.equals(g2)); g2.addSeriesLabel(3, "Add3"); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); g1.addSeriesLabel(0, "Add0"); g1.addSeriesLabel(0, "Add0b"); g1.addSeriesLabel(1, "Add1"); MultipleXYSeriesLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (MultipleXYSeriesLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardCategoryItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardCategoryItemLabelGenerator0000644000175000017500000001642311173030414033503 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------------- * StandardCategoryItemLabelGeneratorTests.java * -------------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added cloning tests (DG); * 11-May-2004 : Renamed class (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardCategoryItemLabelGenerator} class. */ public class StandardCategoryItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardCategoryItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardCategoryItemLabelGeneratorTests(String name) { super(name); } /** * Some checks for the generalLabel() method. */ public void testGenerateLabel() { StandardCategoryItemLabelGenerator g = new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("0.000")); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "R0", "C0"); dataset.addValue(2.0, "R0", "C1"); dataset.addValue(3.0, "R1", "C0"); dataset.addValue(null, "R1", "C1"); String s = g.generateLabel(dataset, 0, 0); assertTrue(s.startsWith("1")); assertTrue(s.endsWith("000")); // try a null value s = g.generateLabel(dataset, 1, 1); assertEquals("-", s); } /** * Some checks for the equals() method. */ public void testEquals() { StandardCategoryItemLabelGenerator g1 = new StandardCategoryItemLabelGenerator(); StandardCategoryItemLabelGenerator g2 = new StandardCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardCategoryItemLabelGenerator("{0}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new StandardCategoryItemLabelGenerator("{0}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new StandardCategoryItemLabelGenerator("{1}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new StandardCategoryItemLabelGenerator("{1}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new StandardCategoryItemLabelGenerator("{2}", new SimpleDateFormat("d-MMM")); assertFalse(g1.equals(g2)); g2 = new StandardCategoryItemLabelGenerator("{2}", new SimpleDateFormat("d-MMM")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardCategoryItemLabelGenerator g1 = new StandardCategoryItemLabelGenerator(); StandardCategoryItemLabelGenerator g2 = new StandardCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardCategoryItemLabelGenerator g1 = new StandardCategoryItemLabelGenerator(); StandardCategoryItemLabelGenerator g2 = null; try { g2 = (StandardCategoryItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardCategoryItemLabelGenerator g1 = new StandardCategoryItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardCategoryItemLabelGenerator g1 = new StandardCategoryItemLabelGenerator("{2}", DateFormat.getInstance()); StandardCategoryItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardCategoryItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * A test for bug 1481087. */ public void testEquals1481087() { StandardCategoryItemLabelGenerator g1 = new StandardCategoryItemLabelGenerator("{0}", new DecimalFormat("0.00")); StandardCategoryToolTipGenerator g2 = new StandardCategoryToolTipGenerator("{0}", new DecimalFormat("0.00")); assertFalse(g1.equals(g2)); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardCategorySeriesLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardCategorySeriesLabelGenerat0000644000175000017500000001347011173030414033475 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------------- * StandardCategorySeriesLabelGeneratorTests.java * ---------------------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-May-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardCategorySeriesLabelGenerator} class. */ public class StandardCategorySeriesLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardCategorySeriesLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardCategorySeriesLabelGeneratorTests(String name) { super(name); } /** * Some checks for the generalLabel() method. */ public void testGenerateLabel() { StandardCategorySeriesLabelGenerator g = new StandardCategorySeriesLabelGenerator("{0}"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "R0", "C0"); dataset.addValue(2.0, "R0", "C1"); dataset.addValue(3.0, "R1", "C0"); dataset.addValue(null, "R1", "C1"); String s = g.generateLabel(dataset, 0); assertEquals("R0", s); } /** * Some checks for the equals() method. */ public void testEquals() { StandardCategorySeriesLabelGenerator g1 = new StandardCategorySeriesLabelGenerator(); StandardCategorySeriesLabelGenerator g2 = new StandardCategorySeriesLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardCategorySeriesLabelGenerator("{1}"); assertFalse(g1.equals(g2)); g2 = new StandardCategorySeriesLabelGenerator("{1}"); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardCategorySeriesLabelGenerator g1 = new StandardCategorySeriesLabelGenerator(); StandardCategorySeriesLabelGenerator g2 = new StandardCategorySeriesLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardCategorySeriesLabelGenerator g1 = new StandardCategorySeriesLabelGenerator("{1}"); StandardCategorySeriesLabelGenerator g2 = null; try { g2 = (StandardCategorySeriesLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardCategorySeriesLabelGenerator g1 = new StandardCategorySeriesLabelGenerator("{1}"); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardCategorySeriesLabelGenerator g1 = new StandardCategorySeriesLabelGenerator("{2}"); StandardCategorySeriesLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardCategorySeriesLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardCategoryToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardCategoryToolTipGeneratorTe0000644000175000017500000001474011173030414033530 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------------ * StandardCategoryToolTipGeneratorTests.java * ------------------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1 (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Added testEquals1481087() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardCategoryToolTipGenerator} class. */ public class StandardCategoryToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardCategoryToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardCategoryToolTipGeneratorTests(String name) { super(name); } /** * Tests the equals() method. */ public void testEquals() { StandardCategoryToolTipGenerator g1 = new StandardCategoryToolTipGenerator(); StandardCategoryToolTipGenerator g2 = new StandardCategoryToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardCategoryToolTipGenerator("{0}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new StandardCategoryToolTipGenerator("{0}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new StandardCategoryToolTipGenerator("{1}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new StandardCategoryToolTipGenerator("{1}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new StandardCategoryToolTipGenerator("{2}", new SimpleDateFormat("d-MMM")); assertFalse(g1.equals(g2)); g2 = new StandardCategoryToolTipGenerator("{2}", new SimpleDateFormat("d-MMM")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardCategoryToolTipGenerator g1 = new StandardCategoryToolTipGenerator(); StandardCategoryToolTipGenerator g2 = new StandardCategoryToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardCategoryToolTipGenerator g1 = new StandardCategoryToolTipGenerator(); StandardCategoryToolTipGenerator g2 = null; try { g2 = (StandardCategoryToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardCategoryToolTipGenerator g1 = new StandardCategoryToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardCategoryToolTipGenerator g1 = new StandardCategoryToolTipGenerator("{2}", DateFormat.getInstance()); StandardCategoryToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardCategoryToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * A test for bug 1481087. */ public void testEquals1481087() { StandardCategoryToolTipGenerator g1 = new StandardCategoryToolTipGenerator("{0}", new DecimalFormat("0.00")); StandardCategoryItemLabelGenerator g2 = new StandardCategoryItemLabelGenerator("{0}", new DecimalFormat("0.00")); assertFalse(g1.equals(g2)); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardContourToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardContourToolTipGeneratorTes0000644000175000017500000000643611173030414033572 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------------- * StandardContourToolTipGeneratorTests.java * ----------------------------------------- * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2003 : Version 1 (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardContourToolTipGenerator; /** * Tests for the StandardContourToolTipGenerator class. */ public class StandardContourToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardContourToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardContourToolTipGeneratorTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardContourToolTipGenerator g1 = new StandardContourToolTipGenerator(); StandardContourToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); g2 = (StandardContourToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardPieSectionLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardPieSectionLabelGeneratorTe0000644000175000017500000001600711173030414033440 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------------ * StandardPieSectionLabelGeneratorTests.java * ------------------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added clone tests (DG); * 04-Mar-2004 : Added test for equals() method (DG); * 23-Nov-2006 : Extended equals() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.AttributedString; import java.text.DecimalFormat; import java.text.NumberFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardPieSectionLabelGenerator} class. */ public class StandardPieSectionLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardPieSectionLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardPieSectionLabelGeneratorTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StandardPieSectionLabelGenerator g1 = new StandardPieSectionLabelGenerator(); StandardPieSectionLabelGenerator g2 = new StandardPieSectionLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardPieSectionLabelGenerator("{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertFalse(g1.equals(g2)); g2 = new StandardPieSectionLabelGenerator("{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertTrue(g1.equals(g2)); g1 = new StandardPieSectionLabelGenerator("{0} {1}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertFalse(g1.equals(g2)); g2 = new StandardPieSectionLabelGenerator("{0} {1}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertTrue(g1.equals(g2)); g1 = new StandardPieSectionLabelGenerator("{0} {1}", new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); assertFalse(g1.equals(g2)); g2 = new StandardPieSectionLabelGenerator("{0} {1}", new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); assertTrue(g1.equals(g2)); g1 = new StandardPieSectionLabelGenerator("{0} {1}", new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); assertFalse(g1.equals(g2)); g2 = new StandardPieSectionLabelGenerator("{0} {1}", new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); assertTrue(g1.equals(g2)); AttributedString as = new AttributedString("XYZ"); g1.setAttributedLabel(0, as); assertFalse(g1.equals(g2)); g2.setAttributedLabel(0, as); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardPieSectionLabelGenerator g1 = new StandardPieSectionLabelGenerator(); StandardPieSectionLabelGenerator g2 = new StandardPieSectionLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardPieSectionLabelGenerator g1 = new StandardPieSectionLabelGenerator(); StandardPieSectionLabelGenerator g2 = null; try { g2 = (StandardPieSectionLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardPieSectionLabelGenerator g1 = new StandardPieSectionLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardPieSectionLabelGenerator g1 = new StandardPieSectionLabelGenerator(); StandardPieSectionLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); g2 = (StandardPieSectionLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardPieToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardPieToolTipGeneratorTests.j0000644000175000017500000001523611173030414033453 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * StandardPieToolTipGeneratorTests.java * ------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added clone tests (DG); * 04-Mar-2004 : Added test for equals() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 03-May-2006 : Extended test for clone() method (DG); * 03-May-2006 : Renamed StandardPieItemLabelGeneratorTests * --> StandardPieToolTipGeneratorTests (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import java.text.NumberFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardPieToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardPieToolTipGenerator} class. */ public class StandardPieToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardPieToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardPieToolTipGeneratorTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); StandardPieToolTipGenerator g2 = new StandardPieToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardPieToolTipGenerator("{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertFalse(g1.equals(g2)); g2 = new StandardPieToolTipGenerator("{0}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertTrue(g1.equals(g2)); g1 = new StandardPieToolTipGenerator("{0} {1}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertFalse(g1.equals(g2)); g2 = new StandardPieToolTipGenerator("{0} {1}", new DecimalFormat("#,##0.00"), NumberFormat.getPercentInstance()); assertTrue(g1.equals(g2)); g1 = new StandardPieToolTipGenerator("{0} {1}", new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); assertFalse(g1.equals(g2)); g2 = new StandardPieToolTipGenerator("{0} {1}", new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); assertTrue(g1.equals(g2)); g1 = new StandardPieToolTipGenerator("{0} {1}", new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); assertFalse(g1.equals(g2)); g2 = new StandardPieToolTipGenerator("{0} {1}", new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); StandardPieToolTipGenerator g2 = new StandardPieToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Some checks for cloning. */ public void testCloning() { StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); StandardPieToolTipGenerator g2 = null; try { g2 = (StandardPieToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); assertTrue(g1.getNumberFormat() != g2.getNumberFormat()); assertTrue(g1.getPercentFormat() != g2.getPercentFormat()); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); StandardPieToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardPieToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYItemLabelGeneratorTests.0000644000175000017500000002007411173030414033364 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------- * StandardXYItemLabelGeneratorTests.java * -------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Mar-2003 : Version 1 (DG); * 26-Feb-2004 : Updates for new code (DG); * 20-Jan-2006 : Renamed StandardXYItemLabelGeneratorTests.java (DG); * 25-Jan-2007 : Added independence checks to testCloning() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardXYItemLabelGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardXYItemLabelGenerator} class. */ public class StandardXYItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYItemLabelGeneratorTests(String name) { super(name); } /** * A series of tests for the equals() method. */ public void testEquals() { // some setup... String f1 = "{1}"; String f2 = "{2}"; NumberFormat xnf1 = new DecimalFormat("0.00"); NumberFormat xnf2 = new DecimalFormat("0.000"); NumberFormat ynf1 = new DecimalFormat("0.00"); NumberFormat ynf2 = new DecimalFormat("0.000"); StandardXYItemLabelGenerator g1 = null; StandardXYItemLabelGenerator g2 = null; g1 = new StandardXYItemLabelGenerator(f1, xnf1, ynf1); g2 = new StandardXYItemLabelGenerator(f1, xnf1, ynf1); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardXYItemLabelGenerator(f2, xnf1, ynf1); assertFalse(g1.equals(g2)); g2 = new StandardXYItemLabelGenerator(f2, xnf1, ynf1); assertTrue(g1.equals(g2)); g1 = new StandardXYItemLabelGenerator(f2, xnf2, ynf1); assertFalse(g1.equals(g2)); g2 = new StandardXYItemLabelGenerator(f2, xnf2, ynf1); assertTrue(g1.equals(g2)); g1 = new StandardXYItemLabelGenerator(f2, xnf2, ynf2); assertFalse(g1.equals(g2)); g2 = new StandardXYItemLabelGenerator(f2, xnf2, ynf2); assertTrue(g1.equals(g2)); DateFormat xdf1 = new SimpleDateFormat("d-MMM"); DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); DateFormat ydf1 = new SimpleDateFormat("d-MMM"); DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); g1 = new StandardXYItemLabelGenerator(f1, xdf1, ydf1); g2 = new StandardXYItemLabelGenerator(f1, xdf1, ydf1); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardXYItemLabelGenerator(f1, xdf2, ydf1); assertFalse(g1.equals(g2)); g2 = new StandardXYItemLabelGenerator(f1, xdf2, ydf1); assertTrue(g1.equals(g2)); g1 = new StandardXYItemLabelGenerator(f1, xdf2, ydf2); assertFalse(g1.equals(g2)); g2 = new StandardXYItemLabelGenerator(f1, xdf2, ydf2); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); StandardXYItemLabelGenerator g2 = new StandardXYItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); StandardXYItemLabelGenerator g2 = null; try { g2 = (StandardXYItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence g1.getXFormat().setMinimumIntegerDigits(2); assertFalse(g1.equals(g2)); g2.getXFormat().setMinimumIntegerDigits(2); assertTrue(g1.equals(g2)); g1.getYFormat().setMinimumIntegerDigits(2); assertFalse(g1.equals(g2)); g2.getYFormat().setMinimumIntegerDigits(2); assertTrue(g1.equals(g2)); // another test... g1 = new StandardXYItemLabelGenerator("{0} {1} {2}", DateFormat.getInstance(), DateFormat.getInstance()); try { g2 = (StandardXYItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence g1.getXDateFormat().setNumberFormat(new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2.getXDateFormat().setNumberFormat(new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1.getYDateFormat().setNumberFormat(new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2.getYDateFormat().setNumberFormat(new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); StandardXYItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardXYItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYSeriesLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYSeriesLabelGeneratorTest0000644000175000017500000001324511173030414033461 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------- * StandardXYSeriesLabelGeneratorTests.java * ---------------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 24-Nov-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG) * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardXYSeriesLabelGenerator} class. */ public class StandardXYSeriesLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYSeriesLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYSeriesLabelGeneratorTests(String name) { super(name); } /** * Some checks for the generalLabel() method. */ public void testGenerateLabel() { StandardXYSeriesLabelGenerator g = new StandardXYSeriesLabelGenerator("Series {0}"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(new XYSeries("1")); dataset.addSeries(new XYSeries("2")); assertEquals("Series 1", g.generateLabel(dataset, 0)); assertEquals("Series 2", g.generateLabel(dataset, 1)); } /** * Some checks for the equals() method. */ public void testEquals() { StandardXYSeriesLabelGenerator g1 = new StandardXYSeriesLabelGenerator("Series {0}"); StandardXYSeriesLabelGenerator g2 = new StandardXYSeriesLabelGenerator("Series {0}"); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardXYSeriesLabelGenerator("{1}"); assertFalse(g1.equals(g2)); g2 = new StandardXYSeriesLabelGenerator("{1}"); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardXYSeriesLabelGenerator g1 = new StandardXYSeriesLabelGenerator(); StandardXYSeriesLabelGenerator g2 = new StandardXYSeriesLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardXYSeriesLabelGenerator g1 = new StandardXYSeriesLabelGenerator("Series {0}"); StandardXYSeriesLabelGenerator g2 = null; try { g2 = (StandardXYSeriesLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardXYSeriesLabelGenerator g1 = new StandardXYSeriesLabelGenerator("Series {0}"); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYSeriesLabelGenerator g1 = new StandardXYSeriesLabelGenerator("Series {0}"); StandardXYSeriesLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardXYSeriesLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYToolTipGeneratorTests.ja0000644000175000017500000001503211173030414033431 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * StandardXYToolTipGeneratorTests.java * ------------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-May-2004 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardXYToolTipGenerator} class. */ public class StandardXYToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYToolTipGeneratorTests(String name) { super(name); } /** * Tests the equals() method. */ public void testEquals() { // some setup... String f1 = "{1}"; String f2 = "{2}"; NumberFormat xnf1 = new DecimalFormat("0.00"); NumberFormat xnf2 = new DecimalFormat("0.000"); NumberFormat ynf1 = new DecimalFormat("0.00"); NumberFormat ynf2 = new DecimalFormat("0.000"); StandardXYToolTipGenerator g1 = null; StandardXYToolTipGenerator g2 = null; g1 = new StandardXYToolTipGenerator(f1, xnf1, ynf1); g2 = new StandardXYToolTipGenerator(f1, xnf1, ynf1); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardXYToolTipGenerator(f2, xnf1, ynf1); assertFalse(g1.equals(g2)); g2 = new StandardXYToolTipGenerator(f2, xnf1, ynf1); assertTrue(g1.equals(g2)); g1 = new StandardXYToolTipGenerator(f2, xnf2, ynf1); assertFalse(g1.equals(g2)); g2 = new StandardXYToolTipGenerator(f2, xnf2, ynf1); assertTrue(g1.equals(g2)); g1 = new StandardXYToolTipGenerator(f2, xnf2, ynf2); assertFalse(g1.equals(g2)); g2 = new StandardXYToolTipGenerator(f2, xnf2, ynf2); assertTrue(g1.equals(g2)); DateFormat xdf1 = new SimpleDateFormat("d-MMM"); DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); DateFormat ydf1 = new SimpleDateFormat("d-MMM"); DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); g1 = new StandardXYToolTipGenerator(f1, xdf1, ydf1); g2 = new StandardXYToolTipGenerator(f1, xdf1, ydf1); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new StandardXYToolTipGenerator(f1, xdf2, ydf1); assertFalse(g1.equals(g2)); g2 = new StandardXYToolTipGenerator(f1, xdf2, ydf1); assertTrue(g1.equals(g2)); g1 = new StandardXYToolTipGenerator(f1, xdf2, ydf2); assertFalse(g1.equals(g2)); g2 = new StandardXYToolTipGenerator(f1, xdf2, ydf2); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); StandardXYToolTipGenerator g2 = new StandardXYToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); StandardXYToolTipGenerator g2 = null; try { g2 = (StandardXYToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); StandardXYToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardXYToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYZToolTipGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/StandardXYZToolTipGeneratorTests.j0000644000175000017500000001665411173030414033435 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * StandardXYZToolTipGeneratorTests.java * ------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Mar-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardXYZToolTipGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardXYZToolTipGenerator} class. */ public class StandardXYZToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYZToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYZToolTipGeneratorTests(String name) { super(name); } /** * Tests that the equals() method can distinguish all fields. */ public void testEquals() { // some setup... String f1 = "{1}"; String f2 = "{2}"; NumberFormat xnf1 = new DecimalFormat("0.00"); NumberFormat xnf2 = new DecimalFormat("0.000"); NumberFormat ynf1 = new DecimalFormat("0.00"); NumberFormat ynf2 = new DecimalFormat("0.000"); NumberFormat znf1 = new DecimalFormat("0.00"); NumberFormat znf2 = new DecimalFormat("0.000"); DateFormat xdf1 = new SimpleDateFormat("d-MMM"); DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); DateFormat ydf1 = new SimpleDateFormat("d-MMM"); DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); DateFormat zdf1 = new SimpleDateFormat("d-MMM"); DateFormat zdf2 = new SimpleDateFormat("d-MMM-yyyy"); StandardXYZToolTipGenerator g1 = null; StandardXYZToolTipGenerator g2 = null; g1 = new StandardXYZToolTipGenerator(f1, xnf1, ynf1, znf1); g2 = new StandardXYZToolTipGenerator(f1, xnf1, ynf1, znf1); assertTrue(g1.equals(g2)); // format string... g1 = new StandardXYZToolTipGenerator(f2, xnf1, ynf1, znf1); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xnf1, ynf1, znf1); assertTrue(g1.equals(g2)); // x number format g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf1, znf1); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf1, znf1); assertTrue(g1.equals(g2)); // y number format g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf1); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf1); assertTrue(g1.equals(g2)); // z number format g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf2); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf2); assertTrue(g1.equals(g2)); g1 = new StandardXYZToolTipGenerator(f2, xdf1, ydf1, zdf1); g2 = new StandardXYZToolTipGenerator(f2, xdf1, ydf1, zdf1); assertTrue(g1.equals(g2)); // x date format g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf1, zdf1); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf1, zdf1); assertTrue(g1.equals(g2)); // y date format g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf1); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf1); assertTrue(g1.equals(g2)); // z date format g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf2); assertFalse(g1.equals(g2)); g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf2); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); StandardXYZToolTipGenerator g2 = new StandardXYZToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); StandardXYZToolTipGenerator g2 = null; try { g2 = (StandardXYZToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); StandardXYZToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardXYZToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/SymbolicXYItemLabelGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/SymbolicXYItemLabelGeneratorTests.0000644000175000017500000001133611173030414033406 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------- * SymbolicXYItemLabelGeneratorTests.java * -------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.labels.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.SymbolicXYItemLabelGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link SymbolicXYItemLabelGenerator} class. */ public class SymbolicXYItemLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SymbolicXYItemLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SymbolicXYItemLabelGeneratorTests(String name) { super(name); } /** * Tests the equals method. */ public void testEquals() { SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); SymbolicXYItemLabelGenerator g2 = new SymbolicXYItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); SymbolicXYItemLabelGenerator g2 = new SymbolicXYItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); SymbolicXYItemLabelGenerator g2 = null; try { g2 = (SymbolicXYItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); SymbolicXYItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (SymbolicXYItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/labels/junit/package.html0000644000175000017500000000016311173030414027147 0ustar vincentvincent JUnit tests. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/0000755000175000017500000000000011173030414023527 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/0000755000175000017500000000000011216245562024672 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/ArrowNeedleTests.java0000644000175000017500000000765311173030414030770 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ArrowNeedleTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.ArrowNeedle; /** * Tests for the {@link ArrowNeedle} class. */ public class ArrowNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ArrowNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ArrowNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { ArrowNeedle n1 = new ArrowNeedle(false); ArrowNeedle n2 = new ArrowNeedle(false); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); n1 = new ArrowNeedle(true); assertFalse(n1.equals(n2)); n2 = new ArrowNeedle(true); assertTrue(n1.equals(n2)); } /** * Check that cloning works. */ public void testCloning() { ArrowNeedle n1 = new ArrowNeedle(false); ArrowNeedle n2 = null; try { n2 = (ArrowNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ArrowNeedle n1 = new ArrowNeedle(false); ArrowNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (ArrowNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/LineNeedleTests.java0000644000175000017500000000737011173030414030561 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * LineNeedleTests.java * -------------------- * (C) Copyright 2005, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.LineNeedle; /** * Tests for the {@link LineNeedle} class. */ public class LineNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { LineNeedle n1 = new LineNeedle(); LineNeedle n2 = new LineNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { LineNeedle n1 = new LineNeedle(); LineNeedle n2 = null; try { n2 = (LineNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LineNeedle n1 = new LineNeedle(); LineNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (LineNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/LongNeedleTests.java0000644000175000017500000000737011173030414030571 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * LongNeedleTests.java * -------------------- * (C) Copyright 2005, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.LongNeedle; /** * Tests for the {@link LongNeedle} class. */ public class LongNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LongNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LongNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { LongNeedle n1 = new LongNeedle(); LongNeedle n2 = new LongNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { LongNeedle n1 = new LongNeedle(); LongNeedle n2 = null; try { n2 = (LongNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LongNeedle n1 = new LongNeedle(); LongNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (LongNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/MeterNeedleTests.java0000644000175000017500000000745611173030414030753 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * MeterNeedleTests.java * --------------------- * (C) Copyright 2005, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.LineNeedle; import org.jfree.chart.needle.MeterNeedle; /** * Tests for the {@link MeterNeedle} class. */ public class MeterNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MeterNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MeterNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { MeterNeedle n1 = new LineNeedle(); MeterNeedle n2 = new LineNeedle(); assertTrue(n1.equals(n2)); n1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(n1.equals(n2)); n2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(n1.equals(n2)); n1.setOutlinePaint(new GradientPaint(5.0f, 6.0f, Color.red, 7.0f, 8.0f, Color.blue)); assertFalse(n1.equals(n2)); n2.setOutlinePaint(new GradientPaint(5.0f, 6.0f, Color.red, 7.0f, 8.0f, Color.blue)); assertTrue(n1.equals(n2)); n1.setHighlightPaint(new GradientPaint(9.0f, 0.0f, Color.red, 1.0f, 2.0f, Color.blue)); assertFalse(n1.equals(n2)); n2.setHighlightPaint(new GradientPaint(9.0f, 0.0f, Color.red, 1.0f, 2.0f, Color.blue)); assertTrue(n1.equals(n2)); Stroke s = new BasicStroke(1.23f); n1.setOutlineStroke(s); assertFalse(n1.equals(n2)); n2.setOutlineStroke(s); assertTrue(n1.equals(n2)); n1.setRotateX(1.23); assertFalse(n1.equals(n2)); n2.setRotateX(1.23); assertTrue(n1.equals(n2)); n1.setRotateY(4.56); assertFalse(n1.equals(n2)); n2.setRotateY(4.56); assertTrue(n1.equals(n2)); n1.setSize(11); assertFalse(n1.equals(n2)); n2.setSize(11); assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/MiddlePinNeedleTests.java0000644000175000017500000000753411173030414031541 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * MiddlePinNeedleTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.MiddlePinNeedle; /** * Tests for the {@link MiddlePinNeedle} class. */ public class MiddlePinNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MiddlePinNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MiddlePinNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { MiddlePinNeedle n1 = new MiddlePinNeedle(); MiddlePinNeedle n2 = new MiddlePinNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { MiddlePinNeedle n1 = new MiddlePinNeedle(); MiddlePinNeedle n2 = null; try { n2 = (MiddlePinNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MiddlePinNeedle n1 = new MiddlePinNeedle(); MiddlePinNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (MiddlePinNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/NeedlePackageTests.java0000644000175000017500000000564111173030414031224 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * NeedlePackageTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.needle package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class NeedlePackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.needle"); suite.addTestSuite(ArrowNeedleTests.class); suite.addTestSuite(LineNeedleTests.class); suite.addTestSuite(LongNeedleTests.class); suite.addTestSuite(MeterNeedleTests.class); suite.addTestSuite(MiddlePinNeedleTests.class); suite.addTestSuite(PinNeedleTests.class); suite.addTestSuite(PlumNeedleTests.class); suite.addTestSuite(PointerNeedleTests.class); suite.addTestSuite(ShipNeedleTests.class); suite.addTestSuite(WindNeedleTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public NeedlePackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/PinNeedleTests.java0000644000175000017500000000734311173030414030420 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * PinNeedleTests.java * ------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.PinNeedle; /** * Tests for the {@link PinNeedle} class. */ public class PinNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PinNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PinNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { PinNeedle n1 = new PinNeedle(); PinNeedle n2 = new PinNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { PinNeedle n1 = new PinNeedle(); PinNeedle n2 = null; try { n2 = (PinNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PinNeedle n1 = new PinNeedle(); PinNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (PinNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/PlumNeedleTests.java0000644000175000017500000000737011173030414030607 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PlumNeedleTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.PlumNeedle; /** * Tests for the {@link PlumNeedle} class. */ public class PlumNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PlumNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PlumNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = new PlumNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = null; try { n2 = (PlumNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (PlumNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/PointerNeedleTests.java0000644000175000017500000000746311173030414031315 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * PointerNeedleTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.PointerNeedle; /** * Tests for the {@link PointerNeedle} class. */ public class PointerNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PointerNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PointerNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { PointerNeedle n1 = new PointerNeedle(); PointerNeedle n2 = new PointerNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { PointerNeedle n1 = new PointerNeedle(); PointerNeedle n2 = null; try { n2 = (PointerNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PointerNeedle n1 = new PointerNeedle(); PointerNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (PointerNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/ShipNeedleTests.java0000644000175000017500000000737011173030414030575 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ShipNeedleTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.ShipNeedle; /** * Tests for the {@link ShipNeedle} class. */ public class ShipNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ShipNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ShipNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { ShipNeedle n1 = new ShipNeedle(); ShipNeedle n2 = new ShipNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { ShipNeedle n1 = new ShipNeedle(); ShipNeedle n2 = null; try { n2 = (ShipNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ShipNeedle n1 = new ShipNeedle(); ShipNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (ShipNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/needle/junit/WindNeedleTests.java0000644000175000017500000000737011173030414030573 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * WindNeedleTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jun-2005 : Version 1 (DG); * */ package org.jfree.chart.needle.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.needle.WindNeedle; /** * Tests for the {@link WindNeedle} class. */ public class WindNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(WindNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public WindNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { WindNeedle n1 = new WindNeedle(); WindNeedle n2 = new WindNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { WindNeedle n1 = new WindNeedle(); WindNeedle n2 = null; try { n2 = (WindNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { WindNeedle n1 = new WindNeedle(); WindNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (WindNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/panel/0000755000175000017500000000000011173030414023372 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/panel/junit/0000755000175000017500000000000011216245562024535 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/panel/junit/CrosshairOverlayTests.java0000644000175000017500000001067411173030414031720 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * CrosshairOverlayTests.java * -------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.panel.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.panel.CrosshairOverlay; import org.jfree.chart.plot.Crosshair; /** * Tests for the {@link CrosshairOverlay} class. */ public class CrosshairOverlayTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CrosshairOverlayTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CrosshairOverlayTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CrosshairOverlay o1 = new CrosshairOverlay(); CrosshairOverlay o2 = new CrosshairOverlay(); assertEquals(o1, o2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CrosshairOverlay o1 = new CrosshairOverlay(); o1.addDomainCrosshair(new Crosshair(99.9)); o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f))); CrosshairOverlay o2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(o1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); o2 = (CrosshairOverlay) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(o1.equals(o2)); } /** * Basic checks for cloning. */ public void testCloning() { CrosshairOverlay o1 = new CrosshairOverlay(); o1.addDomainCrosshair(new Crosshair(99.9)); o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f))); CrosshairOverlay o2 = null; try { o2 = (CrosshairOverlay) o1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(o1 != o2); assertTrue(o1.getClass() == o2.getClass()); assertTrue(o1.equals(o2)); o1.addDomainCrosshair(new Crosshair(3.21)); o1.addRangeCrosshair(new Crosshair(4.32)); assertFalse(o1.equals(o2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/0000755000175000017500000000000011173030414023251 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/0000755000175000017500000000000011173030414024162 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/0000755000175000017500000000000011216245562025325 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/AbstractDialLayerTests.java0000644000175000017500000001066411173030414032542 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * AbstractDialLayerTests.java * --------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Oct-2007 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.AbstractDialLayer; import org.jfree.chart.plot.dial.DialCap; /** * Tests for the {@link AbstractDialLayer} class. */ public class AbstractDialLayerTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AbstractDialLayerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AbstractDialLayerTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialCap c1 = new DialCap(); DialCap c2 = new DialCap(); assertTrue(c1.equals(c2)); // visible c1.setVisible(false); assertFalse(c1.equals(c2)); c2.setVisible(false); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { // test a default instance DialCap c1 = new DialCap(); DialCap c2 = null; try { c2 = (DialCap) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); c1.addChangeListener(l1); assertTrue(c1.hasListener(l1)); assertFalse(c2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // test a default instance DialCap c1 = new DialCap(); DialCap c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (DialCap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); c1.addChangeListener(l1); assertTrue(c1.hasListener(l1)); assertFalse(c2.hasListener(l1)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/ArcDialFrameTests.java0000644000175000017500000001377611173030414031471 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * ArcDialFrameTests.java * ---------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 24-Oct-2007 : Renamed (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.ArcDialFrame; /** * Tests for the {@link ArcDialFrame} class. */ public class ArcDialFrameTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ArcDialFrameTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ArcDialFrameTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ArcDialFrame f1 = new ArcDialFrame(); ArcDialFrame f2 = new ArcDialFrame(); assertTrue(f1.equals(f2)); // background paint f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(f1.equals(f2)); f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(f1.equals(f2)); // foreground paint f1.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(f1.equals(f2)); f2.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(f1.equals(f2)); // stroke f1.setStroke(new BasicStroke(1.1f)); assertFalse(f1.equals(f2)); f2.setStroke(new BasicStroke(1.1f)); assertTrue(f1.equals(f2)); // inner radius f1.setInnerRadius(0.11); assertFalse(f1.equals(f2)); f2.setInnerRadius(0.11); assertTrue(f1.equals(f2)); // outer radius f1.setOuterRadius(0.88); assertFalse(f1.equals(f2)); f2.setOuterRadius(0.88); assertTrue(f1.equals(f2)); // startAngle f1.setStartAngle(99); assertFalse(f1.equals(f2)); f2.setStartAngle(99); assertTrue(f1.equals(f2)); // extent f1.setExtent(33); assertFalse(f1.equals(f2)); f2.setExtent(33); assertTrue(f1.equals(f2)); // check an inherited attribute f1.setVisible(false); assertFalse(f1.equals(f2)); f2.setVisible(false); assertTrue(f1.equals(f2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { ArcDialFrame f1 = new ArcDialFrame(); ArcDialFrame f2 = new ArcDialFrame(); assertTrue(f1.equals(f2)); int h1 = f1.hashCode(); int h2 = f2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ArcDialFrame f1 = new ArcDialFrame(); ArcDialFrame f2 = null; try { f2 = (ArcDialFrame) f1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); f1.addChangeListener(l1); assertTrue(f1.hasListener(l1)); assertFalse(f2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ArcDialFrame f1 = new ArcDialFrame(); ArcDialFrame f2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); f2 = (ArcDialFrame) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(f1, f2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialBackgroundTests.java0000644000175000017500000001554611173030414032065 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * DialBackgroundTests.java * ------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.DialBackground; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.StandardGradientPaintTransformer; /** * Tests for the {@link DialBackground} class. */ public class DialBackgroundTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DialBackgroundTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DialBackgroundTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialBackground b1 = new DialBackground(); DialBackground b2 = new DialBackground(); assertTrue(b1.equals(b2)); // paint b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(b1.equals(b2)); b2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(b1.equals(b2)); // gradient paint transformer b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); assertFalse(b1.equals(b2)); b2.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); assertTrue(b1.equals(b2)); // check an inherited attribute b1.setVisible(false); assertFalse(b1.equals(b2)); b2.setVisible(false); assertTrue(b1.equals(b2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialBackground b1 = new DialBackground(Color.red); DialBackground b2 = new DialBackground(Color.red); assertTrue(b1.equals(b2)); int h1 = b1.hashCode(); int h2 = b2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { // test default instance DialBackground b1 = new DialBackground(); DialBackground b2 = null; try { b2 = (DialBackground) b1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // test a customised instance b1 = new DialBackground(); b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); b2 = null; try { b2 = (DialBackground) b1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); b1.addChangeListener(l1); assertTrue(b1.hasListener(l1)); assertFalse(b2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // test a default instance DialBackground b1 = new DialBackground(); DialBackground b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (DialBackground) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2); // test a customised instance b1 = new DialBackground(); b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); b2 = (DialBackground) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(b1, b2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialCapTests.java0000644000175000017500000001560211173030414030502 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * DialCapTests.java * ----------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.DialCap; /** * Tests for the {@link DialCap} class. */ public class DialCapTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DialCapTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DialCapTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialCap c1 = new DialCap(); DialCap c2 = new DialCap(); assertTrue(c1.equals(c2)); // radius c1.setRadius(0.5); assertFalse(c1.equals(c2)); c2.setRadius(0.5); assertTrue(c1.equals(c2)); // fill paint c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); assertFalse(c1.equals(c2)); c2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); // outline paint c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.gray)); assertFalse(c1.equals(c2)); c2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.gray)); assertTrue(c1.equals(c2)); // outline stroke c1.setOutlineStroke(new BasicStroke(1.1f)); assertFalse(c1.equals(c2)); c2.setOutlineStroke(new BasicStroke(1.1f)); assertTrue(c1.equals(c2)); // check an inherited attribute c1.setVisible(false); assertFalse(c1.equals(c2)); c2.setVisible(false); assertTrue(c1.equals(c2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialCap c1 = new DialCap(); DialCap c2 = new DialCap(); assertTrue(c1.equals(c2)); int h1 = c1.hashCode(); int h2 = c2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { // test a default instance DialCap c1 = new DialCap(); DialCap c2 = null; try { c2 = (DialCap) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // test a customised instance c1 = new DialCap(); c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.gray)); c1.setOutlineStroke(new BasicStroke(2.0f)); c2 = null; try { c2 = (DialCap) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); c1.addChangeListener(l1); assertTrue(c1.hasListener(l1)); assertFalse(c2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // test a default instance DialCap c1 = new DialCap(); DialCap c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (DialCap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); // test a custom instance c1 = new DialCap(); c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.gray)); c1.setOutlineStroke(new BasicStroke(2.0f)); c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (DialCap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialPackageTests.java0000644000175000017500000000604111173030414031327 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DialPackageTests.java * --------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the * org.jfree.experimental.chart.plot.dial package. These tests * can be run using JUnit (http://www.junit.org). */ public class DialPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite( "org.jfree.experimental.chart.plot.dial"); suite.addTestSuite(AbstractDialLayerTests.class); suite.addTestSuite(DialBackgroundTests.class); suite.addTestSuite(DialCapTests.class); suite.addTestSuite(DialPlotTests.class); suite.addTestSuite(DialPointerTests.class); suite.addTestSuite(DialTextAnnotationTests.class); suite.addTestSuite(DialValueIndicatorTests.class); suite.addTestSuite(StandardDialFrameTests.class); suite.addTestSuite(ArcDialFrameTests.class); suite.addTestSuite(StandardDialRangeTests.class); suite.addTestSuite(StandardDialScaleTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public DialPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialPlotTests.java0000644000175000017500000002272411173030414030720 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * DialPlotTests.java * ------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.chart.plot.dial.ArcDialFrame; import org.jfree.chart.plot.dial.DialBackground; import org.jfree.chart.plot.dial.DialCap; import org.jfree.chart.plot.dial.DialPlot; import org.jfree.chart.plot.dial.StandardDialFrame; import org.jfree.chart.plot.dial.StandardDialScale; /** * Tests for the {@link DialPlot} class. */ public class DialPlotTests extends TestCase implements PlotChangeListener { /** The last plot change event received. */ private PlotChangeEvent lastEvent; /** * Records the last plot change event received. * * @param event the event. */ public void plotChanged(PlotChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DialPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DialPlotTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialPlot p1 = new DialPlot(); DialPlot p2 = new DialPlot(); assertTrue(p1.equals(p2)); // background p1.setBackground(new DialBackground(Color.green)); assertFalse(p1.equals(p2)); p2.setBackground(new DialBackground(Color.green)); assertTrue(p1.equals(p2)); p1.setBackground(null); assertFalse(p1.equals(p2)); p2.setBackground(null); assertTrue(p1.equals(p2)); // dial cap DialCap cap1 = new DialCap(); cap1.setFillPaint(Color.red); p1.setCap(cap1); assertFalse(p1.equals(p2)); DialCap cap2 = new DialCap(); cap2.setFillPaint(Color.red); p2.setCap(cap2); assertTrue(p1.equals(p2)); p1.setCap(null); assertFalse(p1.equals(p2)); p2.setCap(null); assertTrue(p1.equals(p2)); // frame StandardDialFrame f1 = new StandardDialFrame(); f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); p1.setDialFrame(f1); assertFalse(p1.equals(p2)); StandardDialFrame f2 = new StandardDialFrame(); f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); p2.setDialFrame(f2); assertTrue(p1.equals(p2)); // view p1.setView(0.2, 0.0, 0.8, 1.0); assertFalse(p1.equals(p2)); p2.setView(0.2, 0.0, 0.8, 1.0); assertTrue(p1.equals(p2)); // layer p1.addLayer(new StandardDialScale()); assertFalse(p1.equals(p2)); p2.addLayer(new StandardDialScale()); assertTrue(p1.equals(p2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialPlot p1 = new DialPlot(); DialPlot p2 = new DialPlot(); assertTrue(p1.equals(p2)); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DialPlot p1 = new DialPlot(); DialPlot p2 = null; try { p2 = (DialPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DialPlot p1 = new DialPlot(); DialPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (DialPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Check the notification event mechanism for the dial background. */ public void testBackgroundListener() { DialPlot p = new DialPlot(); DialBackground b1 = new DialBackground(Color.red); p.setBackground(b1); p.addChangeListener(this); this.lastEvent = null; b1.setPaint(Color.blue); assertNotNull(this.lastEvent); DialBackground b2 = new DialBackground(Color.green); p.setBackground(b2); this.lastEvent = null; b1.setPaint(Color.red); assertNull(this.lastEvent); b2.setPaint(Color.red); assertNotNull(this.lastEvent); } /** * Check the notification event mechanism for the dial cap. */ public void testCapListener() { DialPlot p = new DialPlot(); DialCap c1 = new DialCap(); p.setCap(c1); p.addChangeListener(this); this.lastEvent = null; c1.setFillPaint(Color.red); assertNotNull(this.lastEvent); DialCap c2 = new DialCap(); p.setCap(c2); this.lastEvent = null; c1.setFillPaint(Color.blue); assertNull(this.lastEvent); c2.setFillPaint(Color.green); assertNotNull(this.lastEvent); } /** * Check the notification event mechanism for the dial frame. */ public void testFrameListener() { DialPlot p = new DialPlot(); ArcDialFrame f1 = new ArcDialFrame(); p.setDialFrame(f1); p.addChangeListener(this); this.lastEvent = null; f1.setBackgroundPaint(Color.gray); assertNotNull(this.lastEvent); ArcDialFrame f2 = new ArcDialFrame(); p.setDialFrame(f2); this.lastEvent = null; f1.setBackgroundPaint(Color.blue); assertNull(this.lastEvent); f2.setBackgroundPaint(Color.green); assertNotNull(this.lastEvent); } /** * Check the notification event mechanism for the dial scales. */ public void testScaleListener() { DialPlot p = new DialPlot(); StandardDialScale s1 = new StandardDialScale(); p.addScale(0, s1); p.addChangeListener(this); this.lastEvent = null; s1.setStartAngle(22.0); assertNotNull(this.lastEvent); StandardDialScale s2 = new StandardDialScale(); p.addScale(0, s2); this.lastEvent = null; s1.setStartAngle(33.0); assertNull(this.lastEvent); s2.setStartAngle(33.0); assertNotNull(this.lastEvent); } /** * Check the notification event mechanism for a layer. */ public void testLayerListener() { DialPlot p = new DialPlot(); DialBackground b1 = new DialBackground(Color.red); p.addLayer(b1); p.addChangeListener(this); this.lastEvent = null; b1.setPaint(Color.blue); assertNotNull(this.lastEvent); DialBackground b2 = new DialBackground(Color.green); p.addLayer(b2); this.lastEvent = null; b1.setPaint(Color.red); assertNotNull(this.lastEvent); b2.setPaint(Color.green); assertNotNull(this.lastEvent); p.removeLayer(b2); this.lastEvent = null; b2.setPaint(Color.red); assertNull(this.lastEvent); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialPointerTests.java0000644000175000017500000001534311173030414031421 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DialPointerTests.java * --------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Apr-2007 : Version 1 (DG); * 23-Nov-2007 : Added testEqualsPointer() and testSerialization2() (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.BasicStroke; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.DialPointer; /** * Tests for the {@link DialPointer} class. */ public class DialPointerTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DialPointerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DialPointerTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = new DialPointer.Pin(1); assertTrue(i1.equals(i2)); // dataset index i1 = new DialPointer.Pin(2); assertFalse(i1.equals(i2)); i2 = new DialPointer.Pin(2); assertTrue(i1.equals(i2)); // check an inherited attribute i1.setVisible(false); assertFalse(i1.equals(i2)); i2.setVisible(false); assertTrue(i1.equals(i2)); } /** * Check the equals() method for the DialPointer.Pin class. */ public void testEqualsPin() { DialPointer.Pin p1 = new DialPointer.Pin(); DialPointer.Pin p2 = new DialPointer.Pin(); assertEquals(p1, p2); p1.setPaint(Color.green); assertFalse(p1.equals(p2)); p2.setPaint(Color.green); assertTrue(p1.equals(p2)); BasicStroke s = new BasicStroke(4.4f); p1.setStroke(s); assertFalse(p1.equals(p2)); p2.setStroke(s); assertTrue(p1.equals(p2)); } /** * Check the equals() method for the DialPointer.Pointer class. */ public void testEqualsPointer() { DialPointer.Pointer p1 = new DialPointer.Pointer(); DialPointer.Pointer p2 = new DialPointer.Pointer(); assertEquals(p1, p2); p1.setFillPaint(Color.green); assertFalse(p1.equals(p2)); p2.setFillPaint(Color.green); assertTrue(p1.equals(p2)); p1.setOutlinePaint(Color.green); assertFalse(p1.equals(p2)); p2.setOutlinePaint(Color.green); assertTrue(p1.equals(p2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = new DialPointer.Pin(1); assertTrue(i1.equals(i2)); int h1 = i1.hashCode(); int h2 = i2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = null; try { i2 = (DialPointer) i1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); i1.addChangeListener(l1); assertTrue(i1.hasListener(l1)); assertFalse(i2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // test a default instance DialPointer i1 = new DialPointer.Pin(1); DialPointer i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (DialPointer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); // test a custom instance } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { // test a default instance DialPointer i1 = new DialPointer.Pointer(1); DialPointer i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (DialPointer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); // test a custom instance } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java0000644000175000017500000001435511173030414032762 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DialTextAnnotationTests.java * ---------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.DialTextAnnotation; /** * Tests for the {@link DialTextAnnotation} class. */ public class DialTextAnnotationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DialTextAnnotationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DialTextAnnotationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = new DialTextAnnotation("A1"); assertTrue(a1.equals(a2)); // angle a1.setAngle(1.1); assertFalse(a1.equals(a2)); a2.setAngle(1.1); assertTrue(a1.equals(a2)); // radius a1.setRadius(9.9); assertFalse(a1.equals(a2)); a2.setRadius(9.9); assertTrue(a1.equals(a2)); // font Font f = new Font("SansSerif", Font.PLAIN, 14); a1.setFont(f); assertFalse(a1.equals(a2)); a2.setFont(f); assertTrue(a1.equals(a2)); // paint a1.setPaint(Color.red); assertFalse(a1.equals(a2)); a2.setPaint(Color.red); assertTrue(a1.equals(a2)); // label a1.setLabel("ABC"); assertFalse(a1.equals(a2)); a2.setLabel("ABC"); assertTrue(a1.equals(a2)); // check an inherited attribute a1.setVisible(false); assertFalse(a1.equals(a2)); a2.setVisible(false); assertTrue(a1.equals(a2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = new DialTextAnnotation("A1"); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { // test a default instance DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = null; try { a2 = (DialTextAnnotation) a1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); assertTrue(a1.equals(a2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); a1.addChangeListener(l1); assertTrue(a1.hasListener(l1)); assertFalse(a2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // test a default instance DialTextAnnotation a1 = new DialTextAnnotation("A1"); DialTextAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DialTextAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); // test a custom instance a1 = new DialTextAnnotation("A1"); a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (DialTextAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/DialValueIndicatorTests.java0000644000175000017500000001726011173030414032712 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DialValueIndicatorTests.java * ---------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 24-Oct-2007 : Updated for API changes (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.DialValueIndicator; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; /** * Tests for the {@link DialValueIndicator} class. */ public class DialValueIndicatorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DialValueIndicatorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DialValueIndicatorTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DialValueIndicator i1 = new DialValueIndicator(0); DialValueIndicator i2 = new DialValueIndicator(0); assertTrue(i1.equals(i2)); // dataset index i1.setDatasetIndex(99); assertFalse(i1.equals(i2)); i2.setDatasetIndex(99); assertTrue(i1.equals(i2)); // angle i1.setAngle(43); assertFalse(i1.equals(i2)); i2.setAngle(43); assertTrue(i1.equals(i2)); // radius i1.setRadius(0.77); assertFalse(i1.equals(i2)); i2.setRadius(0.77); assertTrue(i1.equals(i2)); // frameAnchor i1.setFrameAnchor(RectangleAnchor.TOP_LEFT); assertFalse(i1.equals(i2)); i2.setFrameAnchor(RectangleAnchor.TOP_LEFT); assertTrue(i1.equals(i2)); // templateValue i1.setTemplateValue(new Double(1.23)); assertFalse(i1.equals(i2)); i2.setTemplateValue(new Double(1.23)); assertTrue(i1.equals(i2)); // font i1.setFont(new Font("Dialog", Font.PLAIN, 7)); assertFalse(i1.equals(i2)); i2.setFont(new Font("Dialog", Font.PLAIN, 7)); assertTrue(i1.equals(i2)); // paint i1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertFalse(i1.equals(i2)); i2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertTrue(i1.equals(i2)); // backgroundPaint i1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertFalse(i1.equals(i2)); i2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertTrue(i1.equals(i2)); // outlineStroke i1.setOutlineStroke(new BasicStroke(1.1f)); assertFalse(i1.equals(i2)); i2.setOutlineStroke(new BasicStroke(1.1f)); assertTrue(i1.equals(i2)); // outlinePaint i1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertFalse(i1.equals(i2)); i2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertTrue(i1.equals(i2)); // insets i1.setInsets(new RectangleInsets(1, 2, 3, 4)); assertFalse(i1.equals(i2)); i2.setInsets(new RectangleInsets(1, 2, 3, 4)); assertTrue(i1.equals(i2)); // valueAnchor i1.setValueAnchor(RectangleAnchor.BOTTOM_LEFT); assertFalse(i1.equals(i2)); i2.setValueAnchor(RectangleAnchor.BOTTOM_LEFT); assertTrue(i1.equals(i2)); // textAnchor i1.setTextAnchor(TextAnchor.TOP_LEFT); assertFalse(i1.equals(i2)); i2.setTextAnchor(TextAnchor.TOP_LEFT); assertTrue(i1.equals(i2)); // check an inherited attribute i1.setVisible(false); assertFalse(i1.equals(i2)); i2.setVisible(false); assertTrue(i1.equals(i2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DialValueIndicator i1 = new DialValueIndicator(0); DialValueIndicator i2 = new DialValueIndicator(0); assertTrue(i1.equals(i2)); int h1 = i1.hashCode(); int h2 = i2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { // test a default instance DialValueIndicator i1 = new DialValueIndicator(0); DialValueIndicator i2 = null; try { i2 = (DialValueIndicator) i1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); i1.addChangeListener(l1); assertTrue(i1.hasListener(l1)); assertFalse(i2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // test a default instance DialValueIndicator i1 = new DialValueIndicator(0); DialValueIndicator i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (DialValueIndicator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); // test a custom instance } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/MyDialLayerChangeListener.java0000644000175000017500000000402111173030414033143 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * MyDialLayerChangeListener.java * ------------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Oct-2007 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import org.jfree.chart.plot.dial.DialLayerChangeEvent; import org.jfree.chart.plot.dial.DialLayerChangeListener; /** * A dial layer change listener. */ public class MyDialLayerChangeListener implements DialLayerChangeListener { /** * Creates a new instance. */ public MyDialLayerChangeListener() { } /** * Receives a change event. * * @param event the event. */ public void dialLayerChanged(DialLayerChangeEvent event) { } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/StandardDialFrameTests.java0000644000175000017500000001326311173030414032513 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * StandardDialFrameTests.java * --------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 29-Oct-2007 : Renamed StandardDialFrameTests (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.StandardDialFrame; /** * Tests for the {@link StandardDialFrame} class. */ public class StandardDialFrameTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardDialFrameTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardDialFrameTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardDialFrame f1 = new StandardDialFrame(); StandardDialFrame f2 = new StandardDialFrame(); assertTrue(f1.equals(f2)); // radius f1.setRadius(0.2); assertFalse(f1.equals(f2)); f2.setRadius(0.2); assertTrue(f1.equals(f2)); // backgroundPaint f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow)); assertFalse(f1.equals(f2)); f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow)); assertTrue(f1.equals(f2)); // foregroundPaint f1.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); assertFalse(f1.equals(f2)); f2.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); assertTrue(f1.equals(f2)); // stroke f1.setStroke(new BasicStroke(2.4f)); assertFalse(f1.equals(f2)); f2.setStroke(new BasicStroke(2.4f)); assertTrue(f1.equals(f2)); // check an inherited attribute f1.setVisible(false); assertFalse(f1.equals(f2)); f2.setVisible(false); assertTrue(f1.equals(f2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { StandardDialFrame f1 = new StandardDialFrame(); StandardDialFrame f2 = new StandardDialFrame(); assertTrue(f1.equals(f2)); int h1 = f1.hashCode(); int h2 = f2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StandardDialFrame f1 = new StandardDialFrame(); StandardDialFrame f2 = null; try { f2 = (StandardDialFrame) f1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); f1.addChangeListener(l1); assertTrue(f1.hasListener(l1)); assertFalse(f2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardDialFrame f1 = new StandardDialFrame(); StandardDialFrame f2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); f2 = (StandardDialFrame) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(f1, f2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/StandardDialRangeTests.java0000644000175000017500000001234111173030414032511 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * SimpleDialRangeTests.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.StandardDialRange; /** * Tests for the {@link StandardDialRange} class. */ public class StandardDialRangeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardDialRangeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardDialRangeTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = new StandardDialRange(); assertTrue(r1.equals(r2)); // lowerBound r1.setLowerBound(1.1); assertFalse(r1.equals(r2)); r2.setLowerBound(1.1); assertTrue(r1.equals(r2)); // upperBound r1.setUpperBound(11.1); assertFalse(r1.equals(r2)); r2.setUpperBound(11.1); assertTrue(r1.equals(r2)); // paint r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); // check an inherited attribute r1.setVisible(false); assertFalse(r1.equals(r2)); r2.setVisible(false); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = new StandardDialRange(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = null; try { r2 = (StandardDialRange) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); r1.addChangeListener(l1); assertTrue(r1.hasListener(l1)); assertFalse(r2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StandardDialRange) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java0000644000175000017500000002241211173030414032504 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * SimpleDialScaleTests.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 24-Oct-2007 : Updated for API changes (DG); * */ package org.jfree.chart.plot.dial.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.dial.StandardDialScale; /** * Tests for the {@link StandardDialScale} class. */ public class StandardDialScaleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardDialScaleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardDialScaleTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = new StandardDialScale(); assertTrue(s1.equals(s2)); // lowerBound s1 = new StandardDialScale(10.0, 100.0, 0.0, 270.0, 10.0, 4); assertFalse(s1.equals(s2)); s2 = new StandardDialScale(10.0, 100.0, 0.0, 270.0, 10.0, 4); assertTrue(s1.equals(s2)); // upperBound s1 = new StandardDialScale(10.0, 200.0, 0.0, 270.0, 10.0, 4); assertFalse(s1.equals(s2)); s2 = new StandardDialScale(10.0, 200.0, 0.0, 270.0, 10.0, 4); assertTrue(s1.equals(s2)); // startAngle s1 = new StandardDialScale(10.0, 200.0, 20.0, 270.0, 10.0, 4); assertFalse(s1.equals(s2)); s2 = new StandardDialScale(10.0, 200.0, 20.0, 270.0, 10.0, 4); assertTrue(s1.equals(s2)); // extent s1 = new StandardDialScale(10.0, 200.0, 20.0, 99.0, 10.0, 4); assertFalse(s1.equals(s2)); s2 = new StandardDialScale(10.0, 200.0, 20.0, 99.0, 10.0, 4); assertTrue(s1.equals(s2)); // tickRadius s1.setTickRadius(0.99); assertFalse(s1.equals(s2)); s2.setTickRadius(0.99); assertTrue(s1.equals(s2)); // majorTickIncrement s1.setMajorTickIncrement(11.1); assertFalse(s1.equals(s2)); s2.setMajorTickIncrement(11.1); assertTrue(s1.equals(s2)); // majorTickLength s1.setMajorTickLength(0.09); assertFalse(s1.equals(s2)); s2.setMajorTickLength(0.09); assertTrue(s1.equals(s2)); // majorTickPaint s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(s1.equals(s2)); s2.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(s1.equals(s2)); // majorTickStroke s1.setMajorTickStroke(new BasicStroke(1.1f)); assertFalse(s1.equals(s2)); s2.setMajorTickStroke(new BasicStroke(1.1f)); assertTrue(s1.equals(s2)); // minorTickCount s1.setMinorTickCount(7); assertFalse(s1.equals(s2)); s2.setMinorTickCount(7); assertTrue(s1.equals(s2)); // minorTickLength s1.setMinorTickLength(0.09); assertFalse(s1.equals(s2)); s2.setMinorTickLength(0.09); assertTrue(s1.equals(s2)); // tickLabelOffset s1.setTickLabelOffset(0.11); assertFalse(s1.equals(s2)); s2.setTickLabelOffset(0.11); assertTrue(s1.equals(s2)); // tickLabelFont s1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 15)); assertFalse(s1.equals(s2)); s2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 15)); assertTrue(s1.equals(s2)); // tickLabelPaint s1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.green)); assertFalse(s1.equals(s2)); s2.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.green)); assertTrue(s1.equals(s2)); s1.setTickLabelsVisible(false); assertFalse(s1.equals(s2)); s2.setTickLabelsVisible(false); assertTrue(s1.equals(s2)); // check an inherited attribute s1.setVisible(false); assertFalse(s1.equals(s2)); s2.setVisible(false); assertTrue(s1.equals(s2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = new StandardDialScale(); assertTrue(s1.equals(s2)); int h1 = s1.hashCode(); int h2 = s2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { // try a default instance StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = null; try { s2 = (StandardDialScale) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // try a customised instance s1 = new StandardDialScale(); s1.setExtent(123.4); s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); s1.setMajorTickStroke(new BasicStroke(2.0f)); s2 = null; try { s2 = (StandardDialScale) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); s1.addChangeListener(l1); assertTrue(s1.hasListener(l1)); assertFalse(s2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // try a default instance StandardDialScale s1 = new StandardDialScale(); StandardDialScale s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (StandardDialScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); // try a customised instance s1 = new StandardDialScale(); s1.setExtent(123.4); s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); s1.setMajorTickStroke(new BasicStroke(2.0f)); s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (StandardDialScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/0000755000175000017500000000000011216245562024414 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CategoryMarkerTests.java0000644000175000017500000001760711173030414031222 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CategoryMarkerTests.java * ------------------------ * (C) Copyright 2005-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.plot.CategoryMarker; /** * Some tests for the {@link CategoryMarker} class. */ public class CategoryMarkerTests extends TestCase implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Records the last event. * * @param event the last event. */ public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryMarkerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryMarkerTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryMarker m1 = new CategoryMarker("A"); CategoryMarker m2 = new CategoryMarker("A"); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); //key m1 = new CategoryMarker("B"); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("B"); assertTrue(m1.equals(m2)); //paint m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); assertTrue(m1.equals(m2)); //stroke m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f)); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f)); assertTrue(m1.equals(m2)); //outlinePaint m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, new BasicStroke(1.0f), 1.0f); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, new BasicStroke(1.0f), 1.0f); assertTrue(m1.equals(m2)); //outlineStroke m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, new BasicStroke(3.3f), 1.0f); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, new BasicStroke(3.3f), 1.0f); assertTrue(m1.equals(m2)); //alpha m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, new BasicStroke(1.0f), 0.5f); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, new BasicStroke(1.0f), 0.5f); assertTrue(m1.equals(m2)); } /** * Check cloning. */ public void testCloning() { CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); CategoryMarker m2 = null; try { m2 = (CategoryMarker) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1 != m2); assertTrue(m1.getClass() == m2.getClass()); assertTrue(m1.equals(m2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); CategoryMarker m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (CategoryMarker) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } boolean b = m1.equals(m2); assertTrue(b); } /** * Some checks for the getKey() and setKey() methods. */ public void testGetSetKey() { CategoryMarker m = new CategoryMarker("X"); m.addChangeListener(this); this.lastEvent = null; assertEquals("X", m.getKey()); m.setKey("Y"); assertEquals("Y", m.getKey()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setKey(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getDrawAsLine() and setDrawAsLine() methods. */ public void testGetSetDrawAsLine() { CategoryMarker m = new CategoryMarker("X"); m.addChangeListener(this); this.lastEvent = null; assertEquals(false, m.getDrawAsLine()); m.setDrawAsLine(true); assertEquals(true, m.getDrawAsLine()); assertEquals(m, this.lastEvent.getMarker()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java0000644000175000017500000011541611173030414030714 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * CategoryPlotTests.java * ---------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 15-Sep-2003 : Added a unit test to reproduce a bug in serialization (now * fixed) (DG); * 05-Feb-2007 : Added testAddDomainMarker() and testAddRangeMarker() (DG); * 07-Feb-2007 : Added test1654215() (DG); * 07-Apr-2008 : Added testRemoveDomainMarker() and * testRemoveRangeMarker() (DG); * 23-Apr-2008 : Extended testEquals() and testCloning(), and added * testCloning2() and testCloning3() (DG); * 26-Jun-2008 : Updated testEquals() (DG); * 21-Jan-2009 : Updated testEquals() for new fields (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Arrays; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.annotations.CategoryLineAnnotation; import org.jfree.chart.annotations.CategoryTextAnnotation; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.axis.CategoryAnchor; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.plot.CategoryMarker; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.DatasetRenderingOrder; import org.jfree.chart.plot.IntervalMarker; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.renderer.category.AreaRenderer; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.DefaultCategoryItemRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.Layer; import org.jfree.ui.RectangleInsets; import org.jfree.util.SortOrder; /** * Tests for the {@link CategoryPlot} class. */ public class CategoryPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryPlotTests(String name) { super(name); } /** * Some checks for the constructor. */ public void testConstructor() { CategoryPlot plot = new CategoryPlot(); assertEquals(RectangleInsets.ZERO_INSETS, plot.getAxisOffset()); } /** * A test for a bug reported in the forum. */ public void testAxisRange() { DefaultCategoryDataset datasetA = new DefaultCategoryDataset(); DefaultCategoryDataset datasetB = new DefaultCategoryDataset(); datasetB.addValue(50.0, "R1", "C1"); datasetB.addValue(80.0, "R1", "C1"); CategoryPlot plot = new CategoryPlot(datasetA, new CategoryAxis(null), new NumberAxis(null), new LineAndShapeRenderer()); plot.setDataset(1, datasetB); plot.setRenderer(1, new LineAndShapeRenderer()); Range r = plot.getRangeAxis().getRange(); assertEquals(84.0, r.getUpperBound(), 0.00001); } /** * Test that the equals() method differentiates all the required fields. */ public void testEquals() { CategoryPlot plot1 = new CategoryPlot(); CategoryPlot plot2 = new CategoryPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); // orientation... plot1.setOrientation(PlotOrientation.HORIZONTAL); assertFalse(plot1.equals(plot2)); plot2.setOrientation(PlotOrientation.HORIZONTAL); assertTrue(plot1.equals(plot2)); // axisOffset... plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); assertFalse(plot1.equals(plot2)); plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); assertTrue(plot1.equals(plot2)); // domainAxis - no longer a separate field but test anyway... plot1.setDomainAxis(new CategoryAxis("Category Axis")); assertFalse(plot1.equals(plot2)); plot2.setDomainAxis(new CategoryAxis("Category Axis")); assertTrue(plot1.equals(plot2)); // domainAxes... plot1.setDomainAxis(11, new CategoryAxis("Secondary Axis")); assertFalse(plot1.equals(plot2)); plot2.setDomainAxis(11, new CategoryAxis("Secondary Axis")); assertTrue(plot1.equals(plot2)); // domainAxisLocation - no longer a separate field but test anyway... plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // domainAxisLocations... plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // draw shared domain axis... plot1.setDrawSharedDomainAxis(!plot1.getDrawSharedDomainAxis()); assertFalse(plot1.equals(plot2)); plot2.setDrawSharedDomainAxis(!plot2.getDrawSharedDomainAxis()); assertTrue(plot1.equals(plot2)); // rangeAxis - no longer a separate field but test anyway... plot1.setRangeAxis(new NumberAxis("Range Axis")); assertFalse(plot1.equals(plot2)); plot2.setRangeAxis(new NumberAxis("Range Axis")); assertTrue(plot1.equals(plot2)); // rangeAxes... plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); assertFalse(plot1.equals(plot2)); plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); assertTrue(plot1.equals(plot2)); // rangeAxisLocation - no longer a separate field but test anyway... plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // rangeAxisLocations... plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // datasetToDomainAxisMap... plot1.mapDatasetToDomainAxis(11, 11); assertFalse(plot1.equals(plot2)); plot2.mapDatasetToDomainAxis(11, 11); assertTrue(plot1.equals(plot2)); // datasetToRangeAxisMap... plot1.mapDatasetToRangeAxis(11, 11); assertFalse(plot1.equals(plot2)); plot2.mapDatasetToRangeAxis(11, 11); assertTrue(plot1.equals(plot2)); // renderer - no longer a separate field but test anyway... plot1.setRenderer(new AreaRenderer()); assertFalse(plot1.equals(plot2)); plot2.setRenderer(new AreaRenderer()); assertTrue(plot1.equals(plot2)); // renderers... plot1.setRenderer(11, new AreaRenderer()); assertFalse(plot1.equals(plot2)); plot2.setRenderer(11, new AreaRenderer()); assertTrue(plot1.equals(plot2)); // rendering order... plot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); assertFalse(plot1.equals(plot2)); plot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); assertTrue(plot1.equals(plot2)); // columnRenderingOrder... plot1.setColumnRenderingOrder(SortOrder.DESCENDING); assertFalse(plot1.equals(plot2)); plot2.setColumnRenderingOrder(SortOrder.DESCENDING); assertTrue(plot1.equals(plot2)); // rowRenderingOrder... plot1.setRowRenderingOrder(SortOrder.DESCENDING); assertFalse(plot1.equals(plot2)); plot2.setRowRenderingOrder(SortOrder.DESCENDING); assertTrue(plot1.equals(plot2)); // domainGridlinesVisible plot1.setDomainGridlinesVisible(true); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinesVisible(true); assertTrue(plot1.equals(plot2)); // domainGridlinePosition plot1.setDomainGridlinePosition(CategoryAnchor.END); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinePosition(CategoryAnchor.END); assertTrue(plot1.equals(plot2)); // domainGridlineStroke Stroke stroke = new BasicStroke(2.0f); plot1.setDomainGridlineStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlineStroke(stroke); assertTrue(plot1.equals(plot2)); // domainGridlinePaint plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); // rangeGridlinesVisible plot1.setRangeGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinesVisible(false); assertTrue(plot1.equals(plot2)); // rangeGridlineStroke plot1.setRangeGridlineStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlineStroke(stroke); assertTrue(plot1.equals(plot2)); // rangeGridlinePaint plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); // anchorValue plot1.setAnchorValue(100.0); assertFalse(plot1.equals(plot2)); plot2.setAnchorValue(100.0); assertTrue(plot1.equals(plot2)); // rangeCrosshairVisible plot1.setRangeCrosshairVisible(true); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairVisible(true); assertTrue(plot1.equals(plot2)); // rangeCrosshairValue plot1.setRangeCrosshairValue(100.0); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairValue(100.0); assertTrue(plot1.equals(plot2)); // rangeCrosshairStroke plot1.setRangeCrosshairStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairStroke(stroke); assertTrue(plot1.equals(plot2)); // rangeCrosshairPaint plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); // rangeCrosshairLockedOnData plot1.setRangeCrosshairLockedOnData(false); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairLockedOnData(false); assertTrue(plot1.equals(plot2)); // foreground domain markers plot1.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); assertFalse(plot1.equals(plot2)); plot2.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); assertTrue(plot1.equals(plot2)); // background domain markers plot1.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); assertFalse(plot1.equals(plot2)); plot2.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); assertTrue(plot1.equals(plot2)); // range markers - no longer separate fields but test anyway... plot1.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); assertTrue(plot1.equals(plot2)); plot1.addRangeMarker(new ValueMarker(5.0), Layer.BACKGROUND); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(new ValueMarker(5.0), Layer.BACKGROUND); assertTrue(plot1.equals(plot2)); // foreground range markers... plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); assertTrue(plot1.equals(plot2)); // background range markers... plot1.addRangeMarker(1, new ValueMarker(5.0), Layer.BACKGROUND); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(1, new ValueMarker(5.0), Layer.BACKGROUND); assertTrue(plot1.equals(plot2)); // annotations plot1.addAnnotation(new CategoryTextAnnotation("Text", "Category", 43.0)); assertFalse(plot1.equals(plot2)); plot2.addAnnotation(new CategoryTextAnnotation("Text", "Category", 43.0)); assertTrue(plot1.equals(plot2)); // weight plot1.setWeight(3); assertFalse(plot1.equals(plot2)); plot2.setWeight(3); assertTrue(plot1.equals(plot2)); // fixed domain axis space... plot1.setFixedDomainAxisSpace(new AxisSpace()); assertFalse(plot1.equals(plot2)); plot2.setFixedDomainAxisSpace(new AxisSpace()); assertTrue(plot1.equals(plot2)); // fixed range axis space... plot1.setFixedRangeAxisSpace(new AxisSpace()); assertFalse(plot1.equals(plot2)); plot2.setFixedRangeAxisSpace(new AxisSpace()); assertTrue(plot1.equals(plot2)); // fixed legend items plot1.setFixedLegendItems(new LegendItemCollection()); assertFalse(plot1.equals(plot2)); plot2.setFixedLegendItems(new LegendItemCollection()); assertTrue(plot1.equals(plot2)); // crosshairDatasetIndex plot1.setCrosshairDatasetIndex(99); assertFalse(plot1.equals(plot2)); plot2.setCrosshairDatasetIndex(99); assertTrue(plot1.equals(plot2)); // domainCrosshairColumnKey plot1.setDomainCrosshairColumnKey("A"); assertFalse(plot1.equals(plot2)); plot2.setDomainCrosshairColumnKey("A"); assertTrue(plot1.equals(plot2)); // domainCrosshairRowKey plot1.setDomainCrosshairRowKey("B"); assertFalse(plot1.equals(plot2)); plot2.setDomainCrosshairRowKey("B"); assertTrue(plot1.equals(plot2)); // domainCrosshairVisible plot1.setDomainCrosshairVisible(true); assertFalse(plot1.equals(plot2)); plot2.setDomainCrosshairVisible(true); assertTrue(plot1.equals(plot2)); // domainCrosshairPaint plot1.setDomainCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setDomainCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); // domainCrosshairStroke plot1.setDomainCrosshairStroke(new BasicStroke(1.23f)); assertFalse(plot1.equals(plot2)); plot2.setDomainCrosshairStroke(new BasicStroke(1.23f)); assertTrue(plot1.equals(plot2)); plot1.setRangeMinorGridlinesVisible(true); assertFalse(plot1.equals(plot2)); plot2.setRangeMinorGridlinesVisible(true); assertTrue(plot1.equals(plot2)); plot1.setRangeMinorGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setRangeMinorGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); assertFalse(plot1.equals(plot2)); plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); assertTrue(plot1.equals(plot2)); plot1.setRangeZeroBaselineVisible(!plot1.isRangeZeroBaselineVisible()); assertFalse(plot1.equals(plot2)); plot2.setRangeZeroBaselineVisible(!plot2.isRangeZeroBaselineVisible()); assertTrue(plot1.equals(plot2)); plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); plot1.setRangeZeroBaselineStroke(new BasicStroke(1.23f)); assertFalse(plot1.equals(plot2)); plot2.setRangeZeroBaselineStroke(new BasicStroke(1.23f)); assertTrue(plot1.equals(plot2)); } /** * Confirm that cloning works. */ public void testCloning() { CategoryPlot p1 = new CategoryPlot(); p1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow)); p1.setRangeMinorGridlinePaint(new GradientPaint(2.0f, 3.0f, Color.white, 4.0f, 5.0f, Color.red)); p1.setRangeZeroBaselinePaint(new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.white)); CategoryPlot p2 = null; try { p2 = (CategoryPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence p1.addAnnotation(new CategoryLineAnnotation("C1", 1.0, "C2", 2.0, Color.red, new BasicStroke(1.0f))); assertFalse(p1.equals(p2)); p2.addAnnotation(new CategoryLineAnnotation("C1", 1.0, "C2", 2.0, Color.red, new BasicStroke(1.0f))); assertTrue(p1.equals(p2)); p1.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); assertFalse(p1.equals(p2)); p2.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); assertTrue(p1.equals(p2)); p1.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); assertFalse(p1.equals(p2)); p2.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); assertTrue(p1.equals(p2)); p1.addRangeMarker(new ValueMarker(1.0), Layer.FOREGROUND); assertFalse(p1.equals(p2)); p2.addRangeMarker(new ValueMarker(1.0), Layer.FOREGROUND); assertTrue(p1.equals(p2)); p1.addRangeMarker(new ValueMarker(2.0), Layer.BACKGROUND); assertFalse(p1.equals(p2)); p2.addRangeMarker(new ValueMarker(2.0), Layer.BACKGROUND); assertTrue(p1.equals(p2)); } /** * Some more cloning checks. */ public void testCloning2() { AxisSpace da1 = new AxisSpace(); AxisSpace ra1 = new AxisSpace(); CategoryPlot p1 = new CategoryPlot(); p1.setFixedDomainAxisSpace(da1); p1.setFixedRangeAxisSpace(ra1); CategoryPlot p2 = null; try { p2 = (CategoryPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); da1.setBottom(99.0); assertFalse(p1.equals(p2)); p2.getFixedDomainAxisSpace().setBottom(99.0); assertTrue(p1.equals(p2)); ra1.setBottom(11.0); assertFalse(p1.equals(p2)); p2.getFixedRangeAxisSpace().setBottom(11.0); assertTrue(p1.equals(p2)); } /** * Some more cloning checks. */ public void testCloning3() { LegendItemCollection c1 = new LegendItemCollection(); CategoryPlot p1 = new CategoryPlot(); p1.setFixedLegendItems(c1); CategoryPlot p2 = null; try { p2 = (CategoryPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); c1.add(new LegendItem("X", "XX", "tt", "url", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.yellow, new BasicStroke(1.0f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f), Color.green)); assertFalse(p1.equals(p2)); p2.getFixedLegendItems().add(new LegendItem("X", "XX", "tt", "url", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.yellow, new BasicStroke(1.0f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f), Color.green)); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis domainAxis = new CategoryAxis("Domain"); NumberAxis rangeAxis = new NumberAxis("Range"); BarRenderer renderer = new BarRenderer(); CategoryPlot p1 = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); p1.setOrientation(PlotOrientation.HORIZONTAL); CategoryPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { DefaultCategoryDataset data = new DefaultCategoryDataset(); CategoryAxis domainAxis = new CategoryAxis("Domain"); NumberAxis rangeAxis = new NumberAxis("Range"); BarRenderer renderer = new BarRenderer(); CategoryPlot p1 = new CategoryPlot(data, domainAxis, rangeAxis, renderer); p1.setOrientation(PlotOrientation.VERTICAL); CategoryPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createBarChart( "Test Chart", "Category Axis", "Value Axis", dataset, PlotOrientation.VERTICAL, true, true, false ); JFreeChart chart2 = null; // serialize and deserialize the chart.... try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(chart); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); chart2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } // now check that the chart is usable... boolean passed = true; try { chart2.createBufferedImage(300, 200); } catch (Exception e) { passed = false; e.printStackTrace(); } assertTrue(passed); } /** * This test ensures that a plot with markers is serialized correctly. */ public void testSerialization4() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createBarChart( "Test Chart", "Category Axis", "Value Axis", dataset, PlotOrientation.VERTICAL, true, true, false ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.addRangeMarker(new ValueMarker(1.1), Layer.FOREGROUND); plot.addRangeMarker(new IntervalMarker(2.2, 3.3), Layer.BACKGROUND); JFreeChart chart2 = null; // serialize and deserialize the chart.... try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(chart); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); chart2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(chart, chart2); // now check that the chart is usable... boolean passed = true; try { chart2.createBufferedImage(300, 200); } catch (Exception e) { passed = false; e.printStackTrace(); } assertTrue(passed); } /** * Tests a bug where the plot is no longer registered as a listener * with the dataset(s) and axes after deserialization. See patch 1209475 * at SourceForge. */ public void testSerialization5() { DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); CategoryAxis domainAxis1 = new CategoryAxis("Domain 1"); NumberAxis rangeAxis1 = new NumberAxis("Range 1"); BarRenderer renderer1 = new BarRenderer(); CategoryPlot p1 = new CategoryPlot(dataset1, domainAxis1, rangeAxis1, renderer1); CategoryAxis domainAxis2 = new CategoryAxis("Domain 2"); NumberAxis rangeAxis2 = new NumberAxis("Range 2"); BarRenderer renderer2 = new BarRenderer(); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); p1.setDataset(1, dataset2); p1.setDomainAxis(1, domainAxis2); p1.setRangeAxis(1, rangeAxis2); p1.setRenderer(1, renderer2); CategoryPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2); // now check that all datasets, renderers and axes are being listened // too... CategoryAxis domainAxisA = p2.getDomainAxis(0); NumberAxis rangeAxisA = (NumberAxis) p2.getRangeAxis(0); DefaultCategoryDataset datasetA = (DefaultCategoryDataset) p2.getDataset(0); BarRenderer rendererA = (BarRenderer) p2.getRenderer(0); CategoryAxis domainAxisB = p2.getDomainAxis(1); NumberAxis rangeAxisB = (NumberAxis) p2.getRangeAxis(1); DefaultCategoryDataset datasetB = (DefaultCategoryDataset) p2.getDataset(1); BarRenderer rendererB = (BarRenderer) p2.getRenderer(1); assertTrue(datasetA.hasListener(p2)); assertTrue(domainAxisA.hasListener(p2)); assertTrue(rangeAxisA.hasListener(p2)); assertTrue(rendererA.hasListener(p2)); assertTrue(datasetB.hasListener(p2)); assertTrue(domainAxisB.hasListener(p2)); assertTrue(rangeAxisB.hasListener(p2)); assertTrue(rendererB.hasListener(p2)); } /** * A test for a bug where setting the renderer doesn't register the plot * as a RendererChangeListener. */ public void testSetRenderer() { CategoryPlot plot = new CategoryPlot(); CategoryItemRenderer renderer = new LineAndShapeRenderer(); plot.setRenderer(renderer); // now make a change to the renderer and see if it triggers a plot // change event... MyPlotChangeListener listener = new MyPlotChangeListener(); plot.addChangeListener(listener); renderer.setSeriesPaint(0, Color.black); assertTrue(listener.getEvent() != null); } /** * A test for bug report 1169972. */ public void test1169972() { CategoryPlot plot = new CategoryPlot(null, null, null, null); plot.setDomainAxis(new CategoryAxis("C")); plot.setRangeAxis(new NumberAxis("Y")); plot.setRenderer(new BarRenderer()); plot.setDataset(new DefaultCategoryDataset()); assertTrue(plot != null); } /** * Some tests for the addDomainMarker() method(s). */ public void testAddDomainMarker() { CategoryPlot plot = new CategoryPlot(); CategoryMarker m = new CategoryMarker("C1"); plot.addDomainMarker(m); List listeners = Arrays.asList(m.getListeners( MarkerChangeListener.class)); assertTrue(listeners.contains(plot)); plot.clearDomainMarkers(); listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); assertFalse(listeners.contains(plot)); } /** * Some tests for the addRangeMarker() method(s). */ public void testAddRangeMarker() { CategoryPlot plot = new CategoryPlot(); Marker m = new ValueMarker(1.0); plot.addRangeMarker(m); List listeners = Arrays.asList(m.getListeners( MarkerChangeListener.class)); assertTrue(listeners.contains(plot)); plot.clearRangeMarkers(); listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); assertFalse(listeners.contains(plot)); } /** * A test for bug 1654215 (where a renderer is added to the plot without * a corresponding dataset and it throws an exception at drawing time). */ public void test1654215() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(1, new LineAndShapeRenderer()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Some checks for the getDomainAxisIndex() method. */ public void testGetDomainAxisIndex() { CategoryAxis domainAxis1 = new CategoryAxis("X1"); CategoryAxis domainAxis2 = new CategoryAxis("X2"); NumberAxis rangeAxis1 = new NumberAxis("Y1"); CategoryPlot plot = new CategoryPlot(null, domainAxis1, rangeAxis1, null); assertEquals(0, plot.getDomainAxisIndex(domainAxis1)); assertEquals(-1, plot.getDomainAxisIndex(domainAxis2)); plot.setDomainAxis(1, domainAxis2); assertEquals(1, plot.getDomainAxisIndex(domainAxis2)); assertEquals(-1, plot.getDomainAxisIndex(new CategoryAxis("X2"))); boolean pass = false; try { plot.getDomainAxisIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getRangeAxisIndex() method. */ public void testGetRangeAxisIndex() { CategoryAxis domainAxis1 = new CategoryAxis("X1"); NumberAxis rangeAxis1 = new NumberAxis("Y1"); NumberAxis rangeAxis2 = new NumberAxis("Y2"); CategoryPlot plot = new CategoryPlot(null, domainAxis1, rangeAxis1, null); assertEquals(0, plot.getRangeAxisIndex(rangeAxis1)); assertEquals(-1, plot.getRangeAxisIndex(rangeAxis2)); plot.setRangeAxis(1, rangeAxis2); assertEquals(1, plot.getRangeAxisIndex(rangeAxis2)); assertEquals(-1, plot.getRangeAxisIndex(new NumberAxis("Y2"))); boolean pass = false; try { plot.getRangeAxisIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Check that removing a marker that isn't assigned to the plot returns * false. */ public void testRemoveDomainMarker() { CategoryPlot plot = new CategoryPlot(); assertFalse(plot.removeDomainMarker(new CategoryMarker("Category 1"))); } /** * Check that removing a marker that isn't assigned to the plot returns * false. */ public void testRemoveRangeMarker() { CategoryPlot plot = new CategoryPlot(); assertFalse(plot.removeRangeMarker(new ValueMarker(0.5))); } /** * Some tests for the getDomainAxisForDataset() method. */ public void testGetDomainAxisForDataset() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); assertEquals(xAxis, plot.getDomainAxisForDataset(0)); // should get IllegalArgumentException for negative index boolean pass = false; try { plot.getDomainAxisForDataset(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // if multiple axes are mapped, the first in the list should be // returned... CategoryAxis xAxis2 = new CategoryAxis("X2"); plot.setDomainAxis(1, xAxis2); assertEquals(xAxis, plot.getDomainAxisForDataset(0)); plot.mapDatasetToDomainAxis(0, 1); assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot.mapDatasetToDomainAxes(0, axisIndices); assertEquals(xAxis, plot.getDomainAxisForDataset(0)); axisIndices = Arrays.asList(new Integer[] {new Integer(1), new Integer(2)}); plot.mapDatasetToDomainAxes(0, axisIndices); assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); } /** * Some tests for the getRangeAxisForDataset() method. */ public void testGetRangeAxisForDataset() { CategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis xAxis = new CategoryAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); CategoryItemRenderer renderer = new DefaultCategoryItemRenderer(); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); // should get IllegalArgumentException for negative index boolean pass = false; try { plot.getRangeAxisForDataset(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // if multiple axes are mapped, the first in the list should be // returned... NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); plot.mapDatasetToRangeAxis(0, 1); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); axisIndices = Arrays.asList(new Integer[] {new Integer(1), new Integer(2)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/ColorPaletteTests.java0000644000175000017500000000555711173030414030701 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * ColorPaletteTests.java * ---------------------- * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2003 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.ColorPalette; import org.jfree.chart.plot.GreyPalette; /** * Tests for the ColorPalette class. */ public class ColorPaletteTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ColorPaletteTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ColorPaletteTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { ColorPalette p1 = new GreyPalette(); ColorPalette p2 = null; try { p2 = (ColorPalette) p1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ColorPalette p1 = new GreyPalette(); ColorPalette p2 = new GreyPalette(); assertTrue(p1.equals(p2)); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CombinedDomainCategoryPlotTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CombinedDomainCategoryPlotTests.java0000644000175000017500000002462711173030414033510 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * CombinedDomainCategoryPlotTests.java * ------------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification() (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.CombinedDomainCategoryPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; /** * Tests for the {@link CombinedDomainCategoryPlot} class. */ public class CombinedDomainCategoryPlotTests extends TestCase implements ChartChangeListener { /** A list of the events received. */ private List events = new java.util.ArrayList(); /** * Receives a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CombinedDomainCategoryPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CombinedDomainCategoryPlotTests(String name) { super(name); } /** * This is a test to replicate the bug report 987080. */ public void testRemoveSubplot() { CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); CategoryPlot plot1 = new CategoryPlot(); CategoryPlot plot2 = new CategoryPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertTrue(plots.get(0) == plot1); assertEquals(1, plots.size()); } /** * Some checks for the equals() method. */ public void testEquals() { CombinedDomainCategoryPlot plot1 = createPlot(); CombinedDomainCategoryPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); } /** * Some checks for cloning. */ public void testCloning() { CombinedDomainCategoryPlot plot1 = createPlot(); CombinedDomainCategoryPlot plot2 = null; try { plot2 = (CombinedDomainCategoryPlot) plot1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CombinedDomainCategoryPlot plot1 = createPlot(); CombinedDomainCategoryPlot plot2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); plot2 = (CombinedDomainCategoryPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedDomainCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "First"; String series2 = "Second"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(1.0, series1, type1); result.addValue(4.0, series1, type2); result.addValue(3.0, series1, type3); result.addValue(5.0, series1, type4); result.addValue(5.0, series1, type5); result.addValue(7.0, series1, type6); result.addValue(7.0, series1, type7); result.addValue(8.0, series1, type8); result.addValue(5.0, series2, type1); result.addValue(7.0, series2, type2); result.addValue(6.0, series2, type3); result.addValue(8.0, series2, type4); result.addValue(4.0, series2, type5); result.addValue(4.0, series2, type6); result.addValue(2.0, series2, type7); result.addValue(1.0, series2, type8); return result; } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset2() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "Third"; String series2 = "Fourth"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(11.0, series1, type1); result.addValue(14.0, series1, type2); result.addValue(13.0, series1, type3); result.addValue(15.0, series1, type4); result.addValue(15.0, series1, type5); result.addValue(17.0, series1, type6); result.addValue(17.0, series1, type7); result.addValue(18.0, series1, type8); result.addValue(15.0, series2, type1); result.addValue(17.0, series2, type2); result.addValue(16.0, series2, type3); result.addValue(18.0, series2, type4); result.addValue(14.0, series2, type5); result.addValue(14.0, series2, type6); result.addValue(12.0, series2, type7); result.addValue(11.0, series2, type8); return result; } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedDomainCategoryPlot createPlot() { CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Value"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); CategoryPlot subplot1 = new CategoryPlot( dataset1, null, rangeAxis1, renderer1 ); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(); NumberAxis rangeAxis2 = new NumberAxis("Value"); rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer2 = new BarRenderer(); renderer2.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); CategoryPlot subplot2 = new CategoryPlot( dataset2, null, rangeAxis2, renderer2 ); subplot2.setDomainGridlinesVisible(true); CategoryAxis domainAxis = new CategoryAxis("Category"); CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis); plot.add(subplot1, 2); plot.add(subplot2, 1); return plot; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CombinedDomainXYPlotTests.java0000644000175000017500000002421611173030414032265 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CombinedDomainXYPlotTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification() (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.plot.CombinedDomainXYPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Tests for the {@link CombinedDomainXYPlot} class. */ public class CombinedDomainXYPlotTests extends TestCase implements ChartChangeListener { /** A list of the events received. */ private List events = new java.util.ArrayList(); /** * Receives a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CombinedDomainXYPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CombinedDomainXYPlotTests(String name) { super(name); } /** * Confirm that the constructor will accept a null axis. */ public void testConstructor1() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(null); assertEquals(null, plot.getDomainAxis()); } /** * This is a test to replicate the bug report 987080. */ public void testRemoveSubplot() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(); XYPlot plot1 = new XYPlot(); XYPlot plot2 = new XYPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertTrue(plots.get(0) == plot1); } /** * Tests the equals() method. */ public void testEquals() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); } /** * Confirm that cloning works. */ public void testCloning() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = null; try { plot2 = (CombinedDomainXYPlot) plot1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); plot2 = (CombinedDomainXYPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedDomainXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { // create dataset 1... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; } /** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedDomainXYPlot createPlot() { // create subplot 1... XYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Range 1"); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... XYDataset data2 = createDataset2(); XYItemRenderer renderer2 = new StandardXYItemRenderer(); NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... CombinedDomainXYPlot plot = new CombinedDomainXYPlot( new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); return plot; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CombinedRangeCategoryPlotTests.java0000644000175000017500000002425511173030414033332 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * CombinedRangeCategoryPlotTests.java * ------------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification() (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.CombinedRangeCategoryPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; /** * Tests for the {@link CombinedRangeCategoryPlot} class. */ public class CombinedRangeCategoryPlotTests extends TestCase implements ChartChangeListener { /** A list of the events received. */ private List events = new java.util.ArrayList(); /** * Receives a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CombinedRangeCategoryPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CombinedRangeCategoryPlotTests(String name) { super(name); } /** * Test the equals() method. */ public void testEquals() { CombinedRangeCategoryPlot plot1 = createPlot(); CombinedRangeCategoryPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); } /** * Confirm that cloning works. */ public void testCloning() { CombinedRangeCategoryPlot plot1 = createPlot(); CombinedRangeCategoryPlot plot2 = null; try { plot2 = (CombinedRangeCategoryPlot) plot1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CombinedRangeCategoryPlot plot1 = createPlot(); CombinedRangeCategoryPlot plot2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); plot2 = (CombinedRangeCategoryPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(plot1, plot2); } /** * This is a test to replicate the bug report 1121172. */ public void testRemoveSubplot() { CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot(); CategoryPlot plot1 = new CategoryPlot(); CategoryPlot plot2 = new CategoryPlot(); CategoryPlot plot3 = new CategoryPlot(); plot.add(plot1); plot.add(plot2); plot.add(plot3); plot.remove(plot2); List plots = plot.getSubplots(); assertEquals(2, plots.size()); } /** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedRangeCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "First"; String series2 = "Second"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(1.0, series1, type1); result.addValue(4.0, series1, type2); result.addValue(3.0, series1, type3); result.addValue(5.0, series1, type4); result.addValue(5.0, series1, type5); result.addValue(7.0, series1, type6); result.addValue(7.0, series1, type7); result.addValue(8.0, series1, type8); result.addValue(5.0, series2, type1); result.addValue(7.0, series2, type2); result.addValue(6.0, series2, type3); result.addValue(8.0, series2, type4); result.addValue(4.0, series2, type5); result.addValue(4.0, series2, type6); result.addValue(2.0, series2, type7); result.addValue(1.0, series2, type8); return result; } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset2() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "Third"; String series2 = "Fourth"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(11.0, series1, type1); result.addValue(14.0, series1, type2); result.addValue(13.0, series1, type3); result.addValue(15.0, series1, type4); result.addValue(15.0, series1, type5); result.addValue(17.0, series1, type6); result.addValue(17.0, series1, type7); result.addValue(18.0, series1, type8); result.addValue(15.0, series2, type1); result.addValue(17.0, series2, type2); result.addValue(16.0, series2, type3); result.addValue(18.0, series2, type4); result.addValue(14.0, series2, type5); result.addValue(14.0, series2, type6); result.addValue(12.0, series2, type7); result.addValue(11.0, series2, type8); return result; } /** * Creates a sample plot. * * @return A plot. */ private CombinedRangeCategoryPlot createPlot() { CategoryDataset dataset1 = createDataset1(); CategoryAxis catAxis1 = new CategoryAxis("Category"); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); CategoryPlot subplot1 = new CategoryPlot(dataset1, catAxis1, null, renderer1); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(); CategoryAxis catAxis2 = new CategoryAxis("Category"); BarRenderer renderer2 = new BarRenderer(); renderer2.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator()); CategoryPlot subplot2 = new CategoryPlot(dataset2, catAxis2, null, renderer2); subplot2.setDomainGridlinesVisible(true); NumberAxis rangeAxis = new NumberAxis("Value"); CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot( rangeAxis); plot.add(subplot1, 2); plot.add(subplot2, 1); return plot; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CombinedRangeXYPlotTests.java0000644000175000017500000002354711173030414032120 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * CombinedRangeXYPlotTests.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.plot.CombinedRangeXYPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Tests for the {@link CombinedRangeXYPlot} class. */ public class CombinedRangeXYPlotTests extends TestCase implements ChartChangeListener { /** A list of the events received. */ private List events = new java.util.ArrayList(); /** * Receives a chart change event. * * @param event the event. */ public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CombinedRangeXYPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CombinedRangeXYPlotTests(String name) { super(name); } /** * Test the equals method. */ public void testEquals() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); } /** * This is a test to replicate the bug report 987080. */ public void testRemoveSubplot() { CombinedRangeXYPlot plot = new CombinedRangeXYPlot(); XYPlot plot1 = new XYPlot(); XYPlot plot2 = new XYPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertTrue(plots.get(0) == plot1); } /** * Confirm that cloning works. */ public void testCloning() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = null; try { plot2 = (CombinedRangeXYPlot) plot1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(plot1 != plot2); assertTrue(plot1.getClass() == plot2.getClass()); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); plot2 = (CombinedRangeXYPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedRangeXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis(); xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; } /** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { // create dataset 2... XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedRangeXYPlot createPlot() { // create subplot 1... XYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis xAxis1 = new NumberAxis("X1"); XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... XYDataset data2 = createDataset2(); XYItemRenderer renderer2 = new StandardXYItemRenderer(); NumberAxis xAxis2 = new NumberAxis("X2"); xAxis2.setAutoRangeIncludesZero(false); XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis( "Range")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); return plot; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CompassPlotTests.java0000644000175000017500000001347311173030414030544 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * CompassPlotTests.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * 20-Mar-2007 : Extended serialization tests (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.CompassPlot; import org.jfree.data.general.DefaultValueDataset; /** * Tests for the {@link CompassPlot} class. */ public class CompassPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CompassPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CompassPlotTests(String name) { super(name); } /** * Test the equals() method. */ public void testEquals() { CompassPlot plot1 = new CompassPlot(); CompassPlot plot2 = new CompassPlot(); assertTrue(plot1.equals(plot2)); // labelType... plot1.setLabelType(CompassPlot.VALUE_LABELS); assertFalse(plot1.equals(plot2)); plot2.setLabelType(CompassPlot.VALUE_LABELS); assertTrue(plot1.equals(plot2)); // labelFont plot1.setLabelFont(new Font("Serif", Font.PLAIN, 10)); assertFalse(plot1.equals(plot2)); plot2.setLabelFont(new Font("Serif", Font.PLAIN, 10)); assertTrue(plot1.equals(plot2)); // drawBorder plot1.setDrawBorder(true); assertFalse(plot1.equals(plot2)); plot2.setDrawBorder(true); assertTrue(plot1.equals(plot2)); // rosePaint plot1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); // roseCenterPaint plot1.setRoseCenterPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRoseCenterPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); // roseHighlightPaint plot1.setRoseHighlightPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRoseHighlightPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CompassPlot p1 = new CompassPlot(null); p1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setRoseCenterPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.green)); p1.setRoseHighlightPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.green)); CompassPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CompassPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Confirm that cloning works. */ public void testCloning() { CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0)); CompassPlot p2 = null; try { p2 = (CompassPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/ContourPlotTests.java0000644000175000017500000000606411173030414030566 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ContourPlotTests.java * --------------------- * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.ContourPlot; /** * Tests for the ContourPlot class. */ public class ContourPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ContourPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ContourPlotTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ContourPlot p1 = new ContourPlot(null, null, null, null); ContourPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); p2 = (ContourPlot) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/CrosshairTests.java0000644000175000017500000001617711173030414030241 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * CrosshairTests.java * ------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Apr-2009 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.NumberFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.Crosshair; import org.jfree.chart.labels.StandardCrosshairLabelGenerator; import org.jfree.ui.RectangleAnchor; import org.jfree.util.PublicCloneable; /** * Tests for the {@link Crosshair} class. */ public class CrosshairTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CrosshairTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CrosshairTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { Crosshair c1 = new Crosshair(1.0, Color.blue, new BasicStroke(1.0f)); Crosshair c2 = new Crosshair(1.0, Color.blue, new BasicStroke(1.0f)); assertTrue(c1.equals(c1)); assertTrue(c2.equals(c1)); c1.setVisible(false); assertFalse(c1.equals(c2)); c2.setVisible(false); assertTrue(c1.equals(c2)); c1.setValue(2.0); assertFalse(c1.equals(c2)); c2.setValue(2.0); assertTrue(c1.equals(c2)); c1.setPaint(Color.red); assertFalse(c1.equals(c2)); c2.setPaint(Color.red); assertTrue(c1.equals(c2)); c1.setStroke(new BasicStroke(1.1f)); assertFalse(c1.equals(c2)); c2.setStroke(new BasicStroke(1.1f)); assertTrue(c1.equals(c2)); c1.setLabelVisible(true); assertFalse(c1.equals(c2)); c2.setLabelVisible(true); assertTrue(c1.equals(c2)); c1.setLabelAnchor(RectangleAnchor.TOP_LEFT); assertFalse(c1.equals(c2)); c2.setLabelAnchor(RectangleAnchor.TOP_LEFT); assertTrue(c1.equals(c2)); c1.setLabelGenerator(new StandardCrosshairLabelGenerator("Value = {0}", NumberFormat.getNumberInstance())); assertFalse(c1.equals(c2)); c2.setLabelGenerator(new StandardCrosshairLabelGenerator("Value = {0}", NumberFormat.getNumberInstance())); assertTrue(c1.equals(c2)); c1.setLabelXOffset(11); assertFalse(c1.equals(c2)); c2.setLabelXOffset(11); assertTrue(c1.equals(c2)); c1.setLabelYOffset(22); assertFalse(c1.equals(c2)); c2.setLabelYOffset(22); assertTrue(c1.equals(c2)); c1.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); assertFalse(c1.equals(c2)); c2.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); assertTrue(c1.equals(c2)); c1.setLabelPaint(Color.red); assertFalse(c1.equals(c2)); c2.setLabelPaint(Color.red); assertTrue(c1.equals(c2)); c1.setLabelBackgroundPaint(Color.yellow); assertFalse(c1.equals(c2)); c2.setLabelBackgroundPaint(Color.yellow); assertTrue(c1.equals(c2)); c1.setLabelOutlineVisible(false); assertFalse(c1.equals(c2)); c2.setLabelOutlineVisible(false); assertTrue(c1.equals(c2)); c1.setLabelOutlineStroke(new BasicStroke(2.0f)); assertFalse(c1.equals(c2)); c2.setLabelOutlineStroke(new BasicStroke(2.0f)); assertTrue(c1.equals(c2)); c1.setLabelOutlinePaint(Color.darkGray); assertFalse(c1.equals(c2)); c2.setLabelOutlinePaint(Color.darkGray); assertTrue(c1.equals(c2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { Crosshair c1 = new Crosshair(1.0); Crosshair c2 = new Crosshair(1.0); assertTrue(c1.equals(c2)); assertTrue(c1.hashCode() == c2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { Crosshair c1 = new Crosshair(1.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.BLUE), new BasicStroke(1.0f)); Crosshair c2 = null; try { c2 = (Crosshair) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { Crosshair c1 = new Crosshair(1.0); assertTrue(c1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Crosshair c1 = new Crosshair(1.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.BLUE), new BasicStroke(1.0f)); Crosshair c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (Crosshair) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/DefaultDrawingSupplierTests.java0000644000175000017500000002015511173030414032717 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * DefaultDrawingSupplierTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.DefaultDrawingSupplier; /** * Tests for the {@link DefaultDrawingSupplier} class. */ public class DefaultDrawingSupplierTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultDrawingSupplierTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultDrawingSupplierTests(String name) { super(name); } /** * Check that the equals() method can distinguish all required fields. */ public void testEquals() { DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); DefaultDrawingSupplier r2 = new DefaultDrawingSupplier(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // set up some objects... Paint[] ps1A = new Paint[] {Color.red, Color.blue}; Paint[] ps2A = new Paint[] {Color.green, Color.yellow, Color.white}; Paint[] ops1A = new Paint[] {Color.lightGray, Color.blue}; Paint[] ops2A = new Paint[] {Color.black, Color.yellow, Color.cyan}; Stroke[] ss1A = new Stroke[] {new BasicStroke(1.1f)}; Stroke[] ss2A = new Stroke[] {new BasicStroke(2.2f), new BasicStroke(3.3f)}; Stroke[] oss1A = new Stroke[] {new BasicStroke(4.4f)}; Stroke[] oss2A = new Stroke[] {new BasicStroke(5.5f), new BasicStroke(6.6f)}; Shape[] shapes1A = new Shape[] { new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0) }; Shape[] shapes2A = new Shape[] { new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0), new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0) }; Paint[] ps1B = new Paint[] {Color.red, Color.blue}; Paint[] ps2B = new Paint[] {Color.green, Color.yellow, Color.white}; Paint[] ops1B = new Paint[] {Color.lightGray, Color.blue}; Paint[] ops2B = new Paint[] {Color.black, Color.yellow, Color.cyan}; Stroke[] ss1B = new Stroke[] {new BasicStroke(1.1f)}; Stroke[] ss2B = new Stroke[] {new BasicStroke(2.2f), new BasicStroke(3.3f)}; Stroke[] oss1B = new Stroke[] {new BasicStroke(4.4f)}; Stroke[] oss2B = new Stroke[] {new BasicStroke(5.5f), new BasicStroke(6.6f)}; Shape[] shapes1B = new Shape[] { new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0) }; Shape[] shapes2B = new Shape[] { new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0), new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0) }; r1 = new DefaultDrawingSupplier(ps1A, ops1A, ss1A, oss1A, shapes1A); r2 = new DefaultDrawingSupplier(ps1B, ops1B, ss1B, oss1B, shapes1B); assertTrue(r1.equals(r2)); // paint sequence r1 = new DefaultDrawingSupplier(ps2A, ops1A, ss1A, oss1A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops1B, ss1B, oss1B, shapes1B); assertTrue(r1.equals(r2)); // outline paint sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss1A, oss1A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss1B, oss1B, shapes1B); assertTrue(r1.equals(r2)); // stroke sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss1A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss1B, shapes1B); assertTrue(r1.equals(r2)); // outline stroke sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss2A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss2B, shapes1B); assertTrue(r1.equals(r2)); // shape sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss2A, shapes2A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss2B, shapes2B); assertTrue(r1.equals(r2)); // paint index r1.getNextPaint(); assertFalse(r1.equals(r2)); r2.getNextPaint(); assertTrue(r1.equals(r2)); // outline paint index r1.getNextOutlinePaint(); assertFalse(r1.equals(r2)); r2.getNextOutlinePaint(); assertTrue(r1.equals(r2)); // stroke index r1.getNextStroke(); assertFalse(r1.equals(r2)); r2.getNextStroke(); assertTrue(r1.equals(r2)); // outline stroke index r1.getNextOutlineStroke(); assertFalse(r1.equals(r2)); r2.getNextOutlineStroke(); assertTrue(r1.equals(r2)); // shape index r1.getNextShape(); assertFalse(r1.equals(r2)); r2.getNextShape(); assertTrue(r1.equals(r2)); } /** * Some basic checks for the clone() method. */ public void testCloning() { DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); DefaultDrawingSupplier r2 = null; try { r2 = (DefaultDrawingSupplier) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); DefaultDrawingSupplier r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (DefaultDrawingSupplier) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/FastScatterPlotTests.java0000644000175000017500000002136111173030414031355 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * FastScatterPlotTests.java * ------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 29-Jan-2009 : Updated testEquals() (DG); * 26-Mar-2009 : Updated testEquals() for new panning fields (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.FastScatterPlot; /** * Tests for the {@link FastScatterPlot} class. */ public class FastScatterPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(FastScatterPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public FastScatterPlotTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { FastScatterPlot plot1 = new FastScatterPlot(); FastScatterPlot plot2 = new FastScatterPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); plot1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); plot1.setDomainGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinesVisible(false); assertTrue(plot1.equals(plot2)); plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); Stroke s = new BasicStroke(1.5f); plot1.setDomainGridlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlineStroke(s); assertTrue(plot1.equals(plot2)); plot1.setRangeGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinesVisible(false); assertTrue(plot1.equals(plot2)); plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertTrue(plot1.equals(plot2)); Stroke s2 = new BasicStroke(1.5f); plot1.setRangeGridlineStroke(s2); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlineStroke(s2); assertTrue(plot1.equals(plot2)); plot1.setDomainPannable(true); assertFalse(plot1.equals(plot2)); plot2.setDomainPannable(true); assertTrue(plot1.equals(plot2)); plot1.setRangePannable(true); assertFalse(plot1.equals(plot2)); plot2.setRangePannable(true); assertTrue(plot1.equals(plot2)); } /** * Some tests for the data array equality in the equals() method. */ public void testEquals2() { FastScatterPlot plot1 = new FastScatterPlot(); FastScatterPlot plot2 = new FastScatterPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); float[][] a = new float[2][]; float[][] b = new float[2][]; plot1.setData(a); assertFalse(plot1.equals(plot2)); plot2.setData(b); assertTrue(plot1.equals(plot2)); a[0] = new float[6]; assertFalse(plot1.equals(plot2)); b[0] = new float[6]; assertTrue(plot1.equals(plot2)); a[0][0] = 1.0f; assertFalse(plot1.equals(plot2)); b[0][0] = 1.0f; assertTrue(plot1.equals(plot2)); a[0][1] = Float.NaN; assertFalse(plot1.equals(plot2)); b[0][1] = Float.NaN; assertTrue(plot1.equals(plot2)); a[0][2] = Float.POSITIVE_INFINITY; assertFalse(plot1.equals(plot2)); b[0][2] = Float.POSITIVE_INFINITY; assertTrue(plot1.equals(plot2)); a[0][3] = Float.NEGATIVE_INFINITY; assertFalse(plot1.equals(plot2)); b[0][3] = Float.NEGATIVE_INFINITY; assertTrue(plot1.equals(plot2)); } /** * Confirm that cloning works. */ public void testCloning() { FastScatterPlot p1 = new FastScatterPlot(); FastScatterPlot p2 = null; try { p2 = (FastScatterPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { float[][] data = createData(); ValueAxis domainAxis = new NumberAxis("X"); ValueAxis rangeAxis = new NumberAxis("Y"); FastScatterPlot p1 = new FastScatterPlot(data, domainAxis, rangeAxis); FastScatterPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); p2 = (FastScatterPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown. */ public void testDrawWithNullInfo() { boolean success = false; try { float[][] data = createData(); ValueAxis domainAxis = new NumberAxis("X"); ValueAxis rangeAxis = new NumberAxis("Y"); FastScatterPlot plot = new FastScatterPlot(data, domainAxis, rangeAxis); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Populates the data array with random values. * * @return Random data. */ private float[][] createData() { float[][] result = new float[2][1000]; for (int i = 0; i < result[0].length; i++) { float x = (float) i + 100; result[0][i] = x; result[1][i] = 100 + (float) Math.random() * 1000; } return result; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/IntervalMarkerTests.java0000644000175000017500000001365511173030414031230 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * IntervalMarkerTests.java * ------------------------ * (C) Copyright 2004-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Jun-2004 : Version 1 (DG); * 05-Sep-2006 : Added checks for MarkerChangeEvents (DG); * */ package org.jfree.chart.plot.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.plot.IntervalMarker; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.StandardGradientPaintTransformer; /** * Tests for the {@link IntervalMarker} class. */ public class IntervalMarkerTests extends TestCase implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Records the last event. * * @param event the last event. */ public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(IntervalMarkerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public IntervalMarkerTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { IntervalMarker m1 = new IntervalMarker(45.0, 50.0); IntervalMarker m2 = new IntervalMarker(45.0, 50.0); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); m1 = new IntervalMarker(44.0, 50.0); assertFalse(m1.equals(m2)); m2 = new IntervalMarker(44.0, 50.0); assertTrue(m1.equals(m2)); m1 = new IntervalMarker(44.0, 55.0); assertFalse(m1.equals(m2)); m2 = new IntervalMarker(44.0, 55.0); assertTrue(m1.equals(m2)); GradientPaintTransformer t = new StandardGradientPaintTransformer( GradientPaintTransformType.HORIZONTAL); m1.setGradientPaintTransformer(t); assertFalse(m1.equals(m2)); m2.setGradientPaintTransformer(t); assertTrue(m1.equals(m2)); } /** * Confirm that cloning works. */ public void testCloning() { IntervalMarker m1 = new IntervalMarker(45.0, 50.0); IntervalMarker m2 = null; try { m2 = (IntervalMarker) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1 != m2); assertTrue(m1.getClass() == m2.getClass()); assertTrue(m1.equals(m2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { IntervalMarker m1 = new IntervalMarker(45.0, 50.0); IntervalMarker m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (IntervalMarker) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = m1.equals(m2); assertTrue(b); } private static final double EPSILON = 0.0000000001; /** * Some checks for the getStartValue() and setStartValue() methods. */ public void testGetSetStartValue() { IntervalMarker m = new IntervalMarker(1.0, 2.0); m.addChangeListener(this); this.lastEvent = null; assertEquals(1.0, m.getStartValue(), EPSILON); m.setStartValue(0.5); assertEquals(0.5, m.getStartValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } /** * Some checks for the getEndValue() and setEndValue() methods. */ public void testGetSetEndValue() { IntervalMarker m = new IntervalMarker(1.0, 2.0); m.addChangeListener(this); this.lastEvent = null; assertEquals(2.0, m.getEndValue(), EPSILON); m.setEndValue(0.5); assertEquals(0.5, m.getEndValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/MarkerTests.java0000644000175000017500000003347311173030414027523 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * MarkerTests.java * ---------------- * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Sep-2006 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.util.Arrays; import java.util.EventListener; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.plot.CategoryMarker; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; /** * Tests for the {@link Marker} class. */ public class MarkerTests extends TestCase implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MarkerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MarkerTests(String name) { super(name); } /** * Some checks for the getPaint() and setPaint() methods. */ public void testGetSetPaint() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.gray, m.getPaint()); m.setPaint(Color.blue); assertEquals(Color.blue, m.getPaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setPaint(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getStroke() and setStroke() methods. */ public void testGetSetStroke() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new BasicStroke(0.5f), m.getStroke()); m.setStroke(new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m.getStroke()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setStroke(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getOutlinePaint() and setOutlinePaint() methods. */ public void testGetSetOutlinePaint() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.gray, m.getOutlinePaint()); m.setOutlinePaint(Color.yellow); assertEquals(Color.yellow, m.getOutlinePaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setOutlinePaint(null); assertEquals(null, m.getOutlinePaint()); } /** * Some checks for the getOutlineStroke() and setOutlineStroke() methods. */ public void testGetSetOutlineStroke() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new BasicStroke(0.5f), m.getOutlineStroke()); m.setOutlineStroke(new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m.getOutlineStroke()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setOutlineStroke(null); assertEquals(null, m.getOutlineStroke()); } private static final float EPSILON = 0.000000001f; /** * Some checks for the getAlpha() and setAlpha() methods. */ public void testGetSetAlpha() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(0.8f, m.getAlpha(), EPSILON); m.setAlpha(0.5f); assertEquals(0.5f, m.getAlpha(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } /** * Some checks for the getLabel() and setLabel() methods. */ public void testGetSetLabel() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(null, m.getLabel()); m.setLabel("XYZ"); assertEquals("XYZ", m.getLabel()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setLabel(null); assertEquals(null, m.getLabel()); } /** * Some checks for the getLabelFont() and setLabelFont() methods. */ public void testGetSetLabelFont() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new Font("SansSerif", Font.PLAIN, 9), m.getLabelFont()); m.setLabelFont(new Font("SansSerif", Font.BOLD, 10)); assertEquals(new Font("SansSerif", Font.BOLD, 10), m.getLabelFont()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelFont(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getLabelPaint() and setLabelPaint() methods. */ public void testGetSetLabelPaint() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.black, m.getLabelPaint()); m.setLabelPaint(Color.red); assertEquals(Color.red, m.getLabelPaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelPaint(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getLabelAnchor() and setLabelAnchor() methods. */ public void testGetSetLabelAnchor() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor()); m.setLabelAnchor(RectangleAnchor.TOP); assertEquals(RectangleAnchor.TOP, m.getLabelAnchor()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelAnchor(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getLabelOffset() and setLabelOffset() methods. */ public void testGetSetLabelOffset() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new RectangleInsets(3, 3, 3, 3), m.getLabelOffset()); m.setLabelOffset(new RectangleInsets(1, 2, 3, 4)); assertEquals(new RectangleInsets(1, 2, 3, 4), m.getLabelOffset()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelOffset(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getLabelOffsetType() and setLabelOffsetType() * methods. */ public void testGetSetLabelOffsetType() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType()); m.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelOffsetType(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Some checks for the getLabelTextAnchor() and setLabelTextAnchor() * methods. */ public void testGetSetLabelTextAnchor() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(TextAnchor.CENTER, m.getLabelTextAnchor()); m.setLabelTextAnchor(TextAnchor.BASELINE_LEFT); assertEquals(TextAnchor.BASELINE_LEFT, m.getLabelTextAnchor()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelTextAnchor(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } } /** * Checks that a CategoryPlot deregisters listeners when clearing markers. */ public void testListenersWithCategoryPlot() { CategoryPlot plot = new CategoryPlot(); CategoryMarker marker1 = new CategoryMarker("X"); ValueMarker marker2 = new ValueMarker(1.0); plot.addDomainMarker(marker1); plot.addRangeMarker(marker2); EventListener[] listeners1 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners1).contains(plot)); EventListener[] listeners2 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners2).contains(plot)); plot.clearDomainMarkers(); plot.clearRangeMarkers(); listeners1 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners1).contains(plot)); listeners2 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners2).contains(plot)); } /** * Checks that an XYPlot deregisters listeners when clearing markers. */ public void testListenersWithXYPlot() { XYPlot plot = new XYPlot(); ValueMarker marker1 = new ValueMarker(1.0); ValueMarker marker2 = new ValueMarker(2.0); plot.addDomainMarker(marker1); plot.addRangeMarker(marker2); EventListener[] listeners1 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners1).contains(plot)); EventListener[] listeners2 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners2).contains(plot)); plot.clearDomainMarkers(); plot.clearRangeMarkers(); listeners1 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners1).contains(plot)); listeners2 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners2).contains(plot)); } /** * Records the last event. * * @param event the event. */ public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/MeterIntervalTests.java0000644000175000017500000001041411173030414031051 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * MeterIntervalTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.MeterInterval; import org.jfree.data.Range; /** * Tests for the {@link MeterInterval} class. */ public class MeterIntervalTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MeterIntervalTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MeterIntervalTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MeterInterval m1 = new MeterInterval( "Label 1", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), Color.blue ); MeterInterval m2 = new MeterInterval( "Label 1", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), Color.blue ); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); m1 = new MeterInterval( "Label 2", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), Color.blue ); assertFalse(m1.equals(m2)); m2 = new MeterInterval( "Label 2", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), Color.blue ); assertTrue(m1.equals(m2)); } /** * This class is immutable so cloning isn't required. */ public void testCloning() { MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0)); assertFalse(m1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0)); MeterInterval m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); m2 = (MeterInterval) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } boolean b = m1.equals(m2); assertTrue(b); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/MeterPlotTests.java0000644000175000017500000002451311173030414030210 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * MeterPlotTests.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * 12-May-2004 : Updated testEquals() (DG); * 29-Nov-2007 : Updated testEquals() and testSerialization1() for * dialOutlinePaint (DG) * */ package org.jfree.chart.plot.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.DialShape; import org.jfree.chart.plot.MeterInterval; import org.jfree.chart.plot.MeterPlot; import org.jfree.data.Range; import org.jfree.data.general.DefaultValueDataset; /** * Tests for the {@link MeterPlot} class. */ public class MeterPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MeterPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MeterPlotTests(String name) { super(name); } /** * Test the equals method to ensure that it can distinguish the required * fields. Note that the dataset is NOT considered in the equals test. */ public void testEquals() { MeterPlot plot1 = new MeterPlot(); MeterPlot plot2 = new MeterPlot(); assertTrue(plot1.equals(plot2)); // units plot1.setUnits("mph"); assertFalse(plot1.equals(plot2)); plot2.setUnits("mph"); assertTrue(plot1.equals(plot2)); // range plot1.setRange(new Range(50.0, 70.0)); assertFalse(plot1.equals(plot2)); plot2.setRange(new Range(50.0, 70.0)); assertTrue(plot1.equals(plot2)); // interval plot1.addInterval(new MeterInterval("Normal", new Range(55.0, 60.0))); assertFalse(plot1.equals(plot2)); plot2.addInterval(new MeterInterval("Normal", new Range(55.0, 60.0))); assertTrue(plot1.equals(plot2)); // dial outline paint plot1.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); // dial shape plot1.setDialShape(DialShape.CHORD); assertFalse(plot1.equals(plot2)); plot2.setDialShape(DialShape.CHORD); assertTrue(plot1.equals(plot2)); // dial background paint plot1.setDialBackgroundPaint(new GradientPaint(9.0f, 8.0f, Color.red, 7.0f, 6.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setDialBackgroundPaint(new GradientPaint(9.0f, 8.0f, Color.red, 7.0f, 6.0f, Color.blue)); assertTrue(plot1.equals(plot2)); // dial outline paint plot1.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertFalse(plot1.equals(plot2)); plot2.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertTrue(plot1.equals(plot2)); // needle paint plot1.setNeedlePaint(new GradientPaint(9.0f, 8.0f, Color.red, 7.0f, 6.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setNeedlePaint(new GradientPaint(9.0f, 8.0f, Color.red, 7.0f, 6.0f, Color.blue)); assertTrue(plot1.equals(plot2)); // value font plot1.setValueFont(new Font("Serif", Font.PLAIN, 6)); assertFalse(plot1.equals(plot2)); plot2.setValueFont(new Font("Serif", Font.PLAIN, 6)); assertTrue(plot1.equals(plot2)); // value paint plot1.setValuePaint(new GradientPaint(1.0f, 2.0f, Color.black, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setValuePaint(new GradientPaint(1.0f, 2.0f, Color.black, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // tick labels visible plot1.setTickLabelsVisible(false); assertFalse(plot1.equals(plot2)); plot2.setTickLabelsVisible(false); assertTrue(plot1.equals(plot2)); // tick label font plot1.setTickLabelFont(new Font("Serif", Font.PLAIN, 6)); assertFalse(plot1.equals(plot2)); plot2.setTickLabelFont(new Font("Serif", Font.PLAIN, 6)); assertTrue(plot1.equals(plot2)); // tick label paint plot1.setTickLabelPaint(Color.red); assertFalse(plot1.equals(plot2)); plot2.setTickLabelPaint(Color.red); assertTrue(plot1.equals(plot2)); // tick label format plot1.setTickLabelFormat(new DecimalFormat("0")); assertFalse(plot1.equals(plot2)); plot2.setTickLabelFormat(new DecimalFormat("0")); assertTrue(plot1.equals(plot2)); // tick paint plot1.setTickPaint(Color.green); assertFalse(plot1.equals(plot2)); plot2.setTickPaint(Color.green); assertTrue(plot1.equals(plot2)); // tick size plot1.setTickSize(1.23); assertFalse(plot1.equals(plot2)); plot2.setTickSize(1.23); assertTrue(plot1.equals(plot2)); // draw border plot1.setDrawBorder(!plot1.getDrawBorder()); assertFalse(plot1.equals(plot2)); plot2.setDrawBorder(plot1.getDrawBorder()); assertTrue(plot1.equals(plot2)); // meter angle plot1.setMeterAngle(22); assertFalse(plot1.equals(plot2)); plot2.setMeterAngle(22); assertTrue(plot1.equals(plot2)); } /** * Confirm that cloning works. */ public void testCloning() { MeterPlot p1 = new MeterPlot(); MeterPlot p2 = null; try { p2 = (MeterPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // the clone and the original share a reference to the SAME dataset assertTrue(p1.getDataset() == p2.getDataset()); // try a few checks to ensure that the clone is independent of the // original p1.getTickLabelFormat().setMinimumIntegerDigits(99); assertFalse(p1.equals(p2)); p2.getTickLabelFormat().setMinimumIntegerDigits(99); assertTrue(p1.equals(p2)); p1.addInterval(new MeterInterval("Test", new Range(1.234, 5.678))); assertFalse(p1.equals(p2)); p2.addInterval(new MeterInterval("Test", new Range(1.234, 5.678))); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization1() { MeterPlot p1 = new MeterPlot(null); p1.setDialBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setDialOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); p1.setNeedlePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); MeterPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (MeterPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23)); MeterPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (MeterPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/MultiplePiePlotTests.java0000644000175000017500000001537011173030414031366 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * MultiplePiePlotTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Jun-2005 : Version 1 (DG); * 06-Apr-2006 : Added tests for new fields (DG); * 18-Apr-2008 : Added testConstructor() (DG); * 30-Dec-2008 : Updated for new legendItemShape field (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Color; import java.awt.GradientPaint; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; import org.jfree.chart.plot.MultiplePiePlot; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.TableOrder; /** * Some tests for the {@link MultiplePiePlot} class. */ public class MultiplePiePlotTests extends TestCase implements PlotChangeListener { /** The last event received. */ PlotChangeEvent lastEvent; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MultiplePiePlotTests.class); } /** * Receives a plot change event and records it. Some tests will use this * to check that events have been generated (or not) when required. * * @param event the event. */ public void plotChanged(PlotChangeEvent event) { this.lastEvent = event; } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MultiplePiePlotTests(String name) { super(name); } /** * Some checks for the constructors. */ public void testConstructor() { MultiplePiePlot plot = new MultiplePiePlot(); assertNull(plot.getDataset()); // the following checks that the plot registers itself as a listener // with the dataset passed to the constructor - see patch 1943021 DefaultCategoryDataset dataset = new DefaultCategoryDataset(); plot = new MultiplePiePlot(dataset); assertTrue(dataset.hasListener(plot)); } /** * Check that the equals() method distinguishes the required fields. */ public void testEquals() { MultiplePiePlot p1 = new MultiplePiePlot(); MultiplePiePlot p2 = new MultiplePiePlot(); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); p1.setDataExtractOrder(TableOrder.BY_ROW); assertFalse(p1.equals(p2)); p2.setDataExtractOrder(TableOrder.BY_ROW); assertTrue(p1.equals(p2)); p1.setLimit(1.23); assertFalse(p1.equals(p2)); p2.setLimit(1.23); assertTrue(p1.equals(p2)); p1.setAggregatedItemsKey("Aggregated Items"); assertFalse(p1.equals(p2)); p2.setAggregatedItemsKey("Aggregated Items"); assertTrue(p1.equals(p2)); p1.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(p1.equals(p2)); p2.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(p1.equals(p2)); p1.setPieChart(ChartFactory.createPieChart("Title", null, true, true, true)); assertFalse(p1.equals(p2)); p2.setPieChart(ChartFactory.createPieChart("Title", null, true, true, true)); assertTrue(p1.equals(p2)); p1.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(p1.equals(p2)); p2.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(p1.equals(p2)); } /** * Some basic checks for the clone() method. */ public void testCloning() { MultiplePiePlot p1 = new MultiplePiePlot(); Rectangle2D rect = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); p1.setLegendItemShape(rect); MultiplePiePlot p2 = null; try { p2 = (MultiplePiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence rect.setRect(2.0, 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MultiplePiePlot p1 = new MultiplePiePlot(null); p1.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red)); MultiplePiePlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); p2 = (MultiplePiePlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/MyPlotChangeListener.java0000644000175000017500000000463311173030414031313 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * MyPlotChangeListener.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; /** * A utility class for testing plot events. */ public class MyPlotChangeListener implements PlotChangeListener { private PlotChangeEvent event; /** * Creates a new instance. */ public MyPlotChangeListener() { this.event = null; } /** * Returns the last event received by the listener. * * @return The event. */ public PlotChangeEvent getEvent() { return this.event; } /** * Sets the event for the listener. * * @param e the event. */ public void setEvent(PlotChangeEvent e) { this.event = e; } /** * Receives notification of a plot change event. * * @param e the event. */ public void plotChanged(PlotChangeEvent e) { this.event = e; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PieLabelRecordTests.java0000644000175000017500000001274611173030414031116 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * PieLabelRecordTests.java * ------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Nov-2007 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.CategoryMarker; import org.jfree.chart.plot.PieLabelRecord; import org.jfree.text.TextBox; /** * Some tests for the {@link CategoryMarker} class. */ public class PieLabelRecordTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PieLabelRecordTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PieLabelRecordTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); PieLabelRecord p2 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); p1 = new PieLabelRecord("B", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertTrue(p1.equals(p2)); p1 = new PieLabelRecord("B", 1.1, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertTrue(p1.equals(p2)); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("B"), 3.0, 4.0, 5.0); assertTrue(p1.equals(p2)); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.0, 4.0, 5.0); assertTrue(p1.equals(p2)); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.0, 5.0); assertTrue(p1.equals(p2)); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.0); assertTrue(p1.equals(p2)); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.5); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.5); assertTrue(p1.equals(p2)); } /** * Confirm that cloning is not implemented. */ public void testCloning() { PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); PieLabelRecord p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (PieLabelRecord) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = p1.equals(p2); assertTrue(b); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PiePlot3DTests.java0000644000175000017500000001076311173030414030042 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * Pie3DPlotTests.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 22-Mar-2007 : Added testEquals() (DG); * 05-Oct-2007 : Modified testEquals() for new field (DG); * 19-Mar-2008 : Added test for null dataset (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot3D; /** * Tests for the {@link PiePlot3D} class. */ public class PiePlot3DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PiePlot3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PiePlot3DTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { PiePlot3D p1 = new PiePlot3D(); PiePlot3D p2 = new PiePlot3D(); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); p1.setDepthFactor(1.23); assertFalse(p1.equals(p2)); p2.setDepthFactor(1.23); assertTrue(p1.equals(p2)); p1.setDarkerSides(true); assertFalse(p1.equals(p2)); p2.setDarkerSides(true); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PiePlot3D p1 = new PiePlot3D(null); PiePlot3D p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (PiePlot3D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Draws a pie chart where the label generator returns null. */ public void testDrawWithNullDataset() { JFreeChart chart = ChartFactory.createPieChart3D("Test", null, true, false, false); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PiePlotTests.java0000644000175000017500000005661111173030414027655 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * PiePlotTests.java * ----------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 10-May-2005 : Strengthened equals() test (DG); * 27-Sep-2006 : Added tests for the getBaseSectionPaint() method (DG); * 23-Nov-2006 : Additional equals() and clone() tests (DG); * 17-Apr-2007 : Added check for label generator that returns a null label (DG); * 31-Mar-2008 : Updated testEquals(); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.AttributedString; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.labels.PieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieToolTipGenerator; import org.jfree.chart.plot.PieLabelLinkStyle; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.urls.CustomPieURLGenerator; import org.jfree.chart.urls.StandardPieURLGenerator; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.util.Rotation; /** * Some tests for the {@link PiePlot} class. */ public class PiePlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PiePlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PiePlotTests(String name) { super(name); } /** * Test the equals() method. */ public void testEquals() { PiePlot plot1 = new PiePlot(); PiePlot plot2 = new PiePlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); // pieIndex... plot1.setPieIndex(99); assertFalse(plot1.equals(plot2)); plot2.setPieIndex(99); assertTrue(plot1.equals(plot2)); // interiorGap... plot1.setInteriorGap(0.15); assertFalse(plot1.equals(plot2)); plot2.setInteriorGap(0.15); assertTrue(plot1.equals(plot2)); // circular plot1.setCircular(!plot1.isCircular()); assertFalse(plot1.equals(plot2)); plot2.setCircular(false); assertTrue(plot1.equals(plot2)); // startAngle plot1.setStartAngle(Math.PI); assertFalse(plot1.equals(plot2)); plot2.setStartAngle(Math.PI); assertTrue(plot1.equals(plot2)); // direction plot1.setDirection(Rotation.ANTICLOCKWISE); assertFalse(plot1.equals(plot2)); plot2.setDirection(Rotation.ANTICLOCKWISE); assertTrue(plot1.equals(plot2)); // ignoreZeroValues plot1.setIgnoreZeroValues(true); plot2.setIgnoreZeroValues(false); assertFalse(plot1.equals(plot2)); plot2.setIgnoreZeroValues(true); assertTrue(plot1.equals(plot2)); // ignoreNullValues plot1.setIgnoreNullValues(true); plot2.setIgnoreNullValues(false); assertFalse(plot1.equals(plot2)); plot2.setIgnoreNullValues(true); assertTrue(plot1.equals(plot2)); // sectionPaint plot1.setSectionPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setSectionPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // sectionPaintMap plot1.setSectionPaint("A", new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setSectionPaint("A", new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // baseSectionPaint plot1.setBaseSectionPaint(new GradientPaint(1.0f, 2.0f, Color.black, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setBaseSectionPaint(new GradientPaint(1.0f, 2.0f, Color.black, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // sectionOutlinesVisible plot1.setSectionOutlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlinesVisible(false); assertTrue(plot1.equals(plot2)); // sectionOutlinePaint plot1.setSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // sectionOutlinePaintList plot1.setSectionOutlinePaint("A", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlinePaint("A", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // baseSectionOutlinePaint plot1.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.gray, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.gray, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // sectionOutlineStroke plot1.setSectionOutlineStroke(new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlineStroke(new BasicStroke(1.0f)); assertTrue(plot1.equals(plot2)); // sectionOutlineStrokeList plot1.setSectionOutlineStroke("A", new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlineStroke("A", new BasicStroke(1.0f)); assertTrue(plot1.equals(plot2)); // baseSectionOutlineStroke plot1.setBaseSectionOutlineStroke(new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setBaseSectionOutlineStroke(new BasicStroke(1.0f)); assertTrue(plot1.equals(plot2)); // shadowPaint plot1.setShadowPaint(new GradientPaint(1.0f, 2.0f, Color.orange, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setShadowPaint(new GradientPaint(1.0f, 2.0f, Color.orange, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // shadowXOffset plot1.setShadowXOffset(4.4); assertFalse(plot1.equals(plot2)); plot2.setShadowXOffset(4.4); assertTrue(plot1.equals(plot2)); // shadowYOffset plot1.setShadowYOffset(4.4); assertFalse(plot1.equals(plot2)); plot2.setShadowYOffset(4.4); assertTrue(plot1.equals(plot2)); // labelFont plot1.setLabelFont(new Font("Serif", Font.PLAIN, 18)); assertFalse(plot1.equals(plot2)); plot2.setLabelFont(new Font("Serif", Font.PLAIN, 18)); assertTrue(plot1.equals(plot2)); // labelPaint plot1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.darkGray, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.darkGray, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // labelBackgroundPaint plot1.setLabelBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setLabelBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // labelOutlinePaint plot1.setLabelOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setLabelOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // labelOutlineStroke Stroke s = new BasicStroke(1.1f); plot1.setLabelOutlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setLabelOutlineStroke(s); assertTrue(plot1.equals(plot2)); // labelShadowPaint plot1.setLabelShadowPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setLabelShadowPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // explodePercentages plot1.setExplodePercent("A", 0.33); assertFalse(plot1.equals(plot2)); plot2.setExplodePercent("A", 0.33); assertTrue(plot1.equals(plot2)); // labelGenerator plot1.setLabelGenerator(new StandardPieSectionLabelGenerator( "{2}{1}{0}")); assertFalse(plot1.equals(plot2)); plot2.setLabelGenerator(new StandardPieSectionLabelGenerator( "{2}{1}{0}")); assertTrue(plot1.equals(plot2)); // labelFont Font f = new Font("SansSerif", Font.PLAIN, 20); plot1.setLabelFont(f); assertFalse(plot1.equals(plot2)); plot2.setLabelFont(f); assertTrue(plot1.equals(plot2)); // labelPaint plot1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // maximumLabelWidth plot1.setMaximumLabelWidth(0.33); assertFalse(plot1.equals(plot2)); plot2.setMaximumLabelWidth(0.33); assertTrue(plot1.equals(plot2)); // labelGap plot1.setLabelGap(0.11); assertFalse(plot1.equals(plot2)); plot2.setLabelGap(0.11); assertTrue(plot1.equals(plot2)); // links visible plot1.setLabelLinksVisible(false); assertFalse(plot1.equals(plot2)); plot2.setLabelLinksVisible(false); assertTrue(plot1.equals(plot2)); plot1.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); assertTrue(plot1.equals(plot2)); // linkMargin plot1.setLabelLinkMargin(0.11); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkMargin(0.11); assertTrue(plot1.equals(plot2)); // labelLinkPaint plot1.setLabelLinkPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.white)); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.white)); assertTrue(plot1.equals(plot2)); // labelLinkStroke plot1.setLabelLinkStroke(new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkStroke(new BasicStroke(1.0f)); assertTrue(plot1.equals(plot2)); // toolTipGenerator plot1.setToolTipGenerator( new StandardPieToolTipGenerator("{2}{1}{0}") ); assertFalse(plot1.equals(plot2)); plot2.setToolTipGenerator( new StandardPieToolTipGenerator("{2}{1}{0}") ); assertTrue(plot1.equals(plot2)); // urlGenerator plot1.setURLGenerator(new StandardPieURLGenerator("xx")); assertFalse(plot1.equals(plot2)); plot2.setURLGenerator(new StandardPieURLGenerator("xx")); assertTrue(plot1.equals(plot2)); // minimumArcAngleToDraw plot1.setMinimumArcAngleToDraw(1.0); assertFalse(plot1.equals(plot2)); plot2.setMinimumArcAngleToDraw(1.0); assertTrue(plot1.equals(plot2)); // legendItemShape plot1.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(plot1.equals(plot2)); plot2.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(plot1.equals(plot2)); // legendLabelGenerator plot1.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( "{0} --> {1}")); assertFalse(plot1.equals(plot2)); plot2.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( "{0} --> {1}")); assertTrue(plot1.equals(plot2)); // legendLabelToolTipGenerator plot1.setLegendLabelToolTipGenerator( new StandardPieSectionLabelGenerator("{0} is {1}")); assertFalse(plot1.equals(plot2)); plot2.setLegendLabelToolTipGenerator( new StandardPieSectionLabelGenerator("{0} is {1}")); assertTrue(plot1.equals(plot2)); // legendLabelURLGenerator plot1.setLegendLabelURLGenerator(new StandardPieURLGenerator( "index.html")); assertFalse(plot1.equals(plot2)); plot2.setLegendLabelURLGenerator(new StandardPieURLGenerator( "index.html")); assertTrue(plot1.equals(plot2)); // autoPopulateSectionPaint plot1.setAutoPopulateSectionPaint(false); assertFalse(plot1.equals(plot2)); plot2.setAutoPopulateSectionPaint(false); assertTrue(plot1.equals(plot2)); // autoPopulateSectionOutlinePaint plot1.setAutoPopulateSectionOutlinePaint(true); assertFalse(plot1.equals(plot2)); plot2.setAutoPopulateSectionOutlinePaint(true); assertTrue(plot1.equals(plot2)); // autoPopulateSectionOutlineStroke plot1.setAutoPopulateSectionOutlineStroke(true); assertFalse(plot1.equals(plot2)); plot2.setAutoPopulateSectionOutlineStroke(true); assertTrue(plot1.equals(plot2)); } /** * Some basic checks for the clone() method. */ public void testCloning() { PiePlot p1 = new PiePlot(); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Check cloning of the urlGenerator field. */ public void testCloning_URLGenerator() { CustomPieURLGenerator generator = new CustomPieURLGenerator(); PiePlot p1 = new PiePlot(); p1.setURLGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check that the URL generator has been cloned assertTrue(p1.getURLGenerator() != p2.getURLGenerator()); } /** * Check cloning of the legendItemShape field. */ public void testCloning_LegendItemShape() { Rectangle shape = new Rectangle(-4, -4, 8, 8); PiePlot p1 = new PiePlot(); p1.setLegendItemShape(shape); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // change the shape and make sure it only affects p1 shape.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(p1.equals(p2)); } /** * Check cloning of the legendLabelGenerator field. */ public void testCloning_LegendLabelGenerator() { StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // change the generator and make sure it only affects p1 generator.getNumberFormat().setMinimumFractionDigits(2); assertFalse(p1.equals(p2)); } /** * Check cloning of the legendLabelToolTipGenerator field. */ public void testCloning_LegendLabelToolTipGenerator() { StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelToolTipGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // change the generator and make sure it only affects p1 generator.getNumberFormat().setMinimumFractionDigits(2); assertFalse(p1.equals(p2)); } /** * Check cloning of the legendLabelURLGenerator field. */ public void testCloning_LegendLabelURLGenerator() { CustomPieURLGenerator generator = new CustomPieURLGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelURLGenerator(generator); PiePlot p2 = null; try { p2 = (PiePlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check that the URL generator has been cloned assertTrue(p1.getLegendLabelURLGenerator() != p2.getLegendLabelURLGenerator()); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PiePlot p1 = new PiePlot(null); PiePlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); p2 = (PiePlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Some checks for the getLegendItems() method. */ public void testGetLegendItems() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Item 1", 1.0); dataset.setValue("Item 2", 2.0); dataset.setValue("Item 3", 0.0); dataset.setValue("Item 4", null); PiePlot plot = new PiePlot(dataset); plot.setIgnoreNullValues(false); plot.setIgnoreZeroValues(false); LegendItemCollection items = plot.getLegendItems(); assertEquals(4, items.getItemCount()); // check that null items are ignored if requested plot.setIgnoreNullValues(true); items = plot.getLegendItems(); assertEquals(3, items.getItemCount()); // check that zero items are ignored if requested plot.setIgnoreZeroValues(true); items = plot.getLegendItems(); assertEquals(2, items.getItemCount()); // check that negative items are always ignored dataset.setValue("Item 5", -1.0); items = plot.getLegendItems(); assertEquals(2, items.getItemCount()); } /** * Check that the default base section paint is not null, and that you * can never set it to null. */ public void testGetBaseSectionPaint() { PiePlot plot = new PiePlot(); assertNotNull(plot.getBaseSectionPaint()); boolean pass = false; try { plot.setBaseSectionPaint(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } static class NullLegendLabelGenerator implements PieSectionLabelGenerator { public AttributedString generateAttributedSectionLabel( PieDataset dataset, Comparable key) { return null; } public String generateSectionLabel(PieDataset dataset, Comparable key) { return null; } } /** * Draws a pie chart where the label generator returns null. */ public void testDrawWithNullLegendLabels() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("L1", 12.0); dataset.setValue("L2", 11.0); JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true, false, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLegendLabelGenerator(new NullLegendLabelGenerator()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PlotOrientationTests.java0000644000175000017500000000725511173030414031433 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * PlotOrientationTests.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Apr-2004 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.PlotOrientation; /** * Tests for the {@link PlotOrientation} class. * */ public class PlotOrientationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PlotOrientationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PlotOrientationTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { assertEquals(PlotOrientation.HORIZONTAL, PlotOrientation.HORIZONTAL); assertEquals(PlotOrientation.VERTICAL, PlotOrientation.VERTICAL); assertFalse( PlotOrientation.HORIZONTAL.equals(PlotOrientation.VERTICAL) ); assertFalse( PlotOrientation.VERTICAL.equals(PlotOrientation.HORIZONTAL) ); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PlotOrientation orientation1 = PlotOrientation.HORIZONTAL; PlotOrientation orientation2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(orientation1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); orientation2 = (PlotOrientation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(orientation1, orientation2); boolean same = orientation1 == orientation2; assertEquals(true, same); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PlotPackageTests.java0000644000175000017500000001044511173030414030466 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * PlotPackageTests.java * --------------------- * (C) Copyright 2003-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 18-Mar-2003 : Version 1 (DG); * 09-Nov-2004 : Added tests for DonutPlot (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 06-Jun-2005 : Added PlotTests (DG); * 16-Jun-2005 : Added MultiplePiePlotTests (DG); * 19-Aug-2005 : Added CategoryMarkerTests (DG); * 05-Sep-2006 : Added MarkerTests (DG); * 21-Nov-2007 : Added PieLabelRecordTests (DG); * 09-Apr-2009 : Added CrosshairTests (DG); * */ package org.jfree.chart.plot.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.plot package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class PlotPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.plot"); suite.addTestSuite(CategoryMarkerTests.class); suite.addTestSuite(CategoryPlotTests.class); suite.addTestSuite(ColorPaletteTests.class); suite.addTestSuite(CombinedDomainCategoryPlotTests.class); suite.addTestSuite(CombinedDomainXYPlotTests.class); suite.addTestSuite(CombinedRangeCategoryPlotTests.class); suite.addTestSuite(CombinedRangeXYPlotTests.class); suite.addTestSuite(CompassPlotTests.class); suite.addTestSuite(ContourPlotTests.class); suite.addTestSuite(CrosshairTests.class); suite.addTestSuite(DefaultDrawingSupplierTests.class); suite.addTestSuite(FastScatterPlotTests.class); suite.addTestSuite(IntervalMarkerTests.class); suite.addTestSuite(MarkerTests.class); suite.addTestSuite(MeterIntervalTests.class); suite.addTestSuite(MeterPlotTests.class); suite.addTestSuite(MultiplePiePlotTests.class); suite.addTestSuite(PieLabelRecordTests.class); suite.addTestSuite(PiePlotTests.class); suite.addTestSuite(PiePlot3DTests.class); suite.addTestSuite(PlotOrientationTests.class); suite.addTestSuite(PlotRenderingInfoTests.class); suite.addTestSuite(PlotTests.class); suite.addTestSuite(PolarPlotTests.class); suite.addTestSuite(RingPlotTests.class); suite.addTestSuite(SpiderWebPlotTests.class); suite.addTestSuite(ThermometerPlotTests.class); suite.addTestSuite(ValueMarkerTests.class); suite.addTestSuite(XYPlotTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public PlotPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PlotRenderingInfoTests.java0000644000175000017500000001224311173030414031662 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * PlotRenderingInfoTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.plot.junit; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.plot.PlotRenderingInfo; /** * Tests for the {@link PlotRenderingInfo} class. */ public class PlotRenderingInfoTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PlotRenderingInfoTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PlotRenderingInfoTests(String name) { super(name); } /** * Test the equals() method. */ public void testEquals() { PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); PlotRenderingInfo p2 = new PlotRenderingInfo(new ChartRenderingInfo()); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); p1.setPlotArea(new Rectangle(2, 3, 4, 5)); assertFalse(p1.equals(p2)); p2.setPlotArea(new Rectangle(2, 3, 4, 5)); assertTrue(p1.equals(p2)); p1.setDataArea(new Rectangle(2, 4, 6, 8)); assertFalse(p1.equals(p2)); p2.setDataArea(new Rectangle(2, 4, 6, 8)); assertTrue(p1.equals(p2)); p1.addSubplotInfo(new PlotRenderingInfo(null)); assertFalse(p1.equals(p2)); p2.addSubplotInfo(new PlotRenderingInfo(null)); assertTrue(p1.equals(p2)); p1.getSubplotInfo(0).setDataArea(new Rectangle(1, 2, 3, 4)); assertFalse(p1.equals(p2)); p2.getSubplotInfo(0).setDataArea(new Rectangle(1, 2, 3, 4)); assertTrue(p1.equals(p2)); } /** * Confirm that cloning works. */ public void testCloning() { PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); p1.setPlotArea(new Rectangle2D.Double()); PlotRenderingInfo p2 = null; try { p2 = (PlotRenderingInfo) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence p1.getPlotArea().setRect(1.0, 2.0, 3.0, 4.0); assertFalse(p1.equals(p2)); p2.getPlotArea().setRect(1.0, 2.0, 3.0, 4.0); assertTrue(p1.equals(p2)); p1.getDataArea().setRect(4.0, 3.0, 2.0, 1.0); assertFalse(p1.equals(p2)); p2.getDataArea().setRect(4.0, 3.0, 2.0, 1.0); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); PlotRenderingInfo p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); p2 = (PlotRenderingInfo) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PlotTests.java0000644000175000017500000001536411173030414027217 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * PlotTests.java * -------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jun-2005 : Version 1 (DG); * 30-Jun-2006 : Extended equals() test to cover new field (DG); * 11-May-2007 : Another new field in testEquals() (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.DefaultDrawingSupplier; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.Plot; import org.jfree.ui.Align; import org.jfree.ui.RectangleInsets; /** * Some tests for the {@link Plot} class. */ public class PlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PlotTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields (note that * the dataset is NOT considered in the equals() method). */ public void testEquals() { PiePlot plot1 = new PiePlot(); PiePlot plot2 = new PiePlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); // noDataMessage plot1.setNoDataMessage("No data XYZ"); assertFalse(plot1.equals(plot2)); plot2.setNoDataMessage("No data XYZ"); assertTrue(plot1.equals(plot2)); // noDataMessageFont plot1.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13)); assertFalse(plot1.equals(plot2)); plot2.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13)); assertTrue(plot1.equals(plot2)); // noDataMessagePaint plot1.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); // insets plot1.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(plot1.equals(plot2)); plot2.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(plot1.equals(plot2)); // outlineVisible plot1.setOutlineVisible(false); assertFalse(plot1.equals(plot2)); plot2.setOutlineVisible(false); assertTrue(plot1.equals(plot2)); // outlineStroke BasicStroke s = new BasicStroke(1.23f); plot1.setOutlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setOutlineStroke(s); assertTrue(plot1.equals(plot2)); // outlinePaint plot1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertFalse(plot1.equals(plot2)); plot2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertTrue(plot1.equals(plot2)); // backgroundPaint plot1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertFalse(plot1.equals(plot2)); plot2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertTrue(plot1.equals(plot2)); // backgroundImage plot1.setBackgroundImage(JFreeChart.INFO.getLogo()); assertFalse(plot1.equals(plot2)); plot2.setBackgroundImage(JFreeChart.INFO.getLogo()); assertTrue(plot1.equals(plot2)); // backgroundImageAlignment plot1.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); assertTrue(plot1.equals(plot2)); // backgroundImageAlpha plot1.setBackgroundImageAlpha(0.77f); assertFalse(plot1.equals(plot2)); plot2.setBackgroundImageAlpha(0.77f); assertTrue(plot1.equals(plot2)); // foregroundAlpha plot1.setForegroundAlpha(0.99f); assertFalse(plot1.equals(plot2)); plot2.setForegroundAlpha(0.99f); assertTrue(plot1.equals(plot2)); // backgroundAlpha plot1.setBackgroundAlpha(0.99f); assertFalse(plot1.equals(plot2)); plot2.setBackgroundAlpha(0.99f); assertTrue(plot1.equals(plot2)); // drawingSupplier plot1.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] {Color.blue}, new Paint[] {Color.red}, new Stroke[] {new BasicStroke(1.1f)}, new Stroke[] {new BasicStroke(9.9f)}, new Shape[] {new Rectangle(1, 2, 3, 4)})); assertFalse(plot1.equals(plot2)); plot2.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] {Color.blue}, new Paint[] {Color.red}, new Stroke[] {new BasicStroke(1.1f)}, new Stroke[] {new BasicStroke(9.9f)}, new Shape[] {new Rectangle(1, 2, 3, 4)})); assertTrue(plot1.equals(plot2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/PolarPlotTests.java0000644000175000017500000001756011173030414030215 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * PolarPlotTests.java * ------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Feb-2005 : Version 1 (DG); * 08-Jun-2005 : Extended testEquals() (DG); * 07-Feb-2007 : Extended testEquals() and testCloning() (DG); * 17-Feb-2008 : Tests for new angleTickUnit field (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberTickUnit; import org.jfree.chart.plot.PolarPlot; import org.jfree.chart.renderer.DefaultPolarItemRenderer; import org.jfree.data.xy.DefaultXYDataset; /** * Some tests for the {@link PolarPlot} class. */ public class PolarPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PolarPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PolarPlotTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { PolarPlot plot1 = new PolarPlot(); PolarPlot plot2 = new PolarPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); plot1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); Stroke s = new BasicStroke(1.23f); plot1.setAngleGridlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setAngleGridlineStroke(s); assertTrue(plot1.equals(plot2)); plot1.setAngleTickUnit(new NumberTickUnit(11.0)); assertFalse(plot1.equals(plot2)); plot2.setAngleTickUnit(new NumberTickUnit(11.0)); assertTrue(plot1.equals(plot2)); plot1.setAngleGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setAngleGridlinesVisible(false); assertTrue(plot1.equals(plot2)); plot1.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9)); assertFalse(plot1.equals(plot2)); plot2.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9)); assertTrue(plot1.equals(plot2)); plot1.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.blue, 7.0f, 6.0f, Color.red)); assertFalse(plot1.equals(plot2)); plot2.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.blue, 7.0f, 6.0f, Color.red)); assertTrue(plot1.equals(plot2)); plot1.setAngleLabelsVisible(false); assertFalse(plot1.equals(plot2)); plot2.setAngleLabelsVisible(false); assertTrue(plot1.equals(plot2)); plot1.setAxis(new NumberAxis("Test")); assertFalse(plot1.equals(plot2)); plot2.setAxis(new NumberAxis("Test")); assertTrue(plot1.equals(plot2)); plot1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.black)); assertFalse(plot1.equals(plot2)); plot2.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.black)); assertTrue(plot1.equals(plot2)); plot1.setRadiusGridlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setRadiusGridlineStroke(s); assertTrue(plot1.equals(plot2)); plot1.setRadiusGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRadiusGridlinesVisible(false); assertTrue(plot1.equals(plot2)); plot1.addCornerTextItem("XYZ"); assertFalse(plot1.equals(plot2)); plot2.addCornerTextItem("XYZ"); assertTrue(plot1.equals(plot2)); } /** * Some basic checks for the clone() method. */ public void testCloning() { PolarPlot p1 = new PolarPlot(); PolarPlot p2 = null; try { p2 = (PolarPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence p1.addCornerTextItem("XYZ"); assertFalse(p1.equals(p2)); p2.addCornerTextItem("XYZ"); assertTrue(p1.equals(p2)); p1 = new PolarPlot(new DefaultXYDataset(), new NumberAxis("A1"), new DefaultPolarItemRenderer()); p2 = null; try { p2 = (PolarPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence p1.getAxis().setLabel("ABC"); assertFalse(p1.equals(p2)); p2.getAxis().setLabel("ABC"); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PolarPlot p1 = new PolarPlot(); p1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setAngleLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); p1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); PolarPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (PolarPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/RingPlotTests.java0000644000175000017500000001267311173030414030037 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * RingPlotTests.java * ------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Nov-2004 : Version 1 (DG); * 12-Oct-2006 : Updated testEquals() (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.RingPlot; /** * Tests for the {@link RingPlot} class. */ public class RingPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RingPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RingPlotTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { RingPlot plot1 = new RingPlot(null); RingPlot plot2 = new RingPlot(null); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); // separatorsVisible plot1.setSeparatorsVisible(false); assertFalse(plot1.equals(plot2)); plot2.setSeparatorsVisible(false); assertTrue(plot1.equals(plot2)); // separatorStroke Stroke s = new BasicStroke(1.1f); plot1.setSeparatorStroke(s); assertFalse(plot1.equals(plot2)); plot2.setSeparatorStroke(s); assertTrue(plot1.equals(plot2)); // separatorPaint plot1.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 2.0f, 1.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 2.0f, 1.0f, Color.blue)); assertTrue(plot1.equals(plot2)); // innerSeparatorExtension plot1.setInnerSeparatorExtension(0.01); assertFalse(plot1.equals(plot2)); plot2.setInnerSeparatorExtension(0.01); assertTrue(plot1.equals(plot2)); // outerSeparatorExtension plot1.setOuterSeparatorExtension(0.02); assertFalse(plot1.equals(plot2)); plot2.setOuterSeparatorExtension(0.02); assertTrue(plot1.equals(plot2)); // sectionDepth plot1.setSectionDepth(0.12); assertFalse(plot1.equals(plot2)); plot2.setSectionDepth(0.12); assertTrue(plot1.equals(plot2)); } /** * Confirm that cloning works. */ public void testCloning() { RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red); p1.setSeparatorPaint(gp); RingPlot p2 = null; try { p2 = (RingPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red); p1.setSeparatorPaint(gp); RingPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (RingPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/SpiderWebPlotTests.java0000644000175000017500000003036111173030414031016 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * SpiderWebPlotTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jun-2005 : Version 1 (DG); * 01-Jun-2006 : Added testDrawWithNullInfo() method (DG); * 05-Feb-2007 : Added more checks to testCloning (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.plot.SpiderWebPlot; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.Rotation; import org.jfree.util.TableOrder; /** * Tests for the {@link SpiderWebPlot} class. */ public class SpiderWebPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SpiderWebPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SpiderWebPlotTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); SpiderWebPlot p2 = new SpiderWebPlot(new DefaultCategoryDataset()); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); // dataExtractOrder p1.setDataExtractOrder(TableOrder.BY_COLUMN); assertFalse(p1.equals(p2)); p2.setDataExtractOrder(TableOrder.BY_COLUMN); assertTrue(p1.equals(p2)); // headPercent p1.setHeadPercent(0.321); assertFalse(p1.equals(p2)); p2.setHeadPercent(0.321); assertTrue(p1.equals(p2)); // interiorGap p1.setInteriorGap(0.123); assertFalse(p1.equals(p2)); p2.setInteriorGap(0.123); assertTrue(p1.equals(p2)); // startAngle p1.setStartAngle(0.456); assertFalse(p1.equals(p2)); p2.setStartAngle(0.456); assertTrue(p1.equals(p2)); // direction p1.setDirection(Rotation.ANTICLOCKWISE); assertFalse(p1.equals(p2)); p2.setDirection(Rotation.ANTICLOCKWISE); assertTrue(p1.equals(p2)); // maxValue p1.setMaxValue(123.4); assertFalse(p1.equals(p2)); p2.setMaxValue(123.4); assertTrue(p1.equals(p2)); // legendItemShape p1.setLegendItemShape(new Rectangle(1, 2, 3, 4)); assertFalse(p1.equals(p2)); p2.setLegendItemShape(new Rectangle(1, 2, 3, 4)); assertTrue(p1.equals(p2)); // seriesPaint p1.setSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(p1.equals(p2)); p2.setSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(p1.equals(p2)); // seriesPaintList p1.setSeriesPaint(1, new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.white)); assertFalse(p1.equals(p2)); p2.setSeriesPaint(1, new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.white)); assertTrue(p1.equals(p2)); // baseSeriesPaint p1.setBaseSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.black)); assertFalse(p1.equals(p2)); p2.setBaseSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.black)); assertTrue(p1.equals(p2)); // seriesOutlinePaint p1.setSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.black)); assertFalse(p1.equals(p2)); p2.setSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.black)); assertTrue(p1.equals(p2)); // seriesOutlinePaintList p1.setSeriesOutlinePaint(1, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); assertFalse(p1.equals(p2)); p2.setSeriesOutlinePaint(1, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.green)); assertTrue(p1.equals(p2)); // baseSeriesOutlinePaint p1.setBaseSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertFalse(p1.equals(p2)); p2.setBaseSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertTrue(p1.equals(p2)); // seriesOutlineStroke BasicStroke s = new BasicStroke(1.23f); p1.setSeriesOutlineStroke(s); assertFalse(p1.equals(p2)); p2.setSeriesOutlineStroke(s); assertTrue(p1.equals(p2)); // seriesOutlineStrokeList p1.setSeriesOutlineStroke(1, s); assertFalse(p1.equals(p2)); p2.setSeriesOutlineStroke(1, s); assertTrue(p1.equals(p2)); // baseSeriesOutlineStroke p1.setBaseSeriesOutlineStroke(s); assertFalse(p1.equals(p2)); p2.setBaseSeriesOutlineStroke(s); assertTrue(p1.equals(p2)); // webFilled p1.setWebFilled(false); assertFalse(p1.equals(p2)); p2.setWebFilled(false); assertTrue(p1.equals(p2)); // axisLabelGap p1.setAxisLabelGap(0.11); assertFalse(p1.equals(p2)); p2.setAxisLabelGap(0.11); assertTrue(p1.equals(p2)); // labelFont p1.setLabelFont(new Font("Serif", Font.PLAIN, 9)); assertFalse(p1.equals(p2)); p2.setLabelFont(new Font("Serif", Font.PLAIN, 9)); assertTrue(p1.equals(p2)); // labelPaint p1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(p1.equals(p2)); p2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(p1.equals(p2)); // labelGenerator p1.setLabelGenerator(new StandardCategoryItemLabelGenerator("XYZ: {0}", new DecimalFormat("0.000"))); assertFalse(p1.equals(p2)); p2.setLabelGenerator(new StandardCategoryItemLabelGenerator("XYZ: {0}", new DecimalFormat("0.000"))); assertTrue(p1.equals(p2)); // toolTipGenerator p1.setToolTipGenerator(new StandardCategoryToolTipGenerator()); assertFalse(p1.equals(p2)); p2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); assertTrue(p1.equals(p2)); // urlGenerator p1.setURLGenerator(new StandardCategoryURLGenerator()); assertFalse(p1.equals(p2)); p2.setURLGenerator(new StandardCategoryURLGenerator()); assertTrue(p1.equals(p2)); // axisLinePaint p1.setAxisLinePaint(Color.red); assertFalse(p1.equals(p2)); p2.setAxisLinePaint(Color.red); assertTrue(p1.equals(p2)); // axisLineStroke p1.setAxisLineStroke(new BasicStroke(1.1f)); assertFalse(p1.equals(p2)); p2.setAxisLineStroke(new BasicStroke(1.1f)); assertTrue(p1.equals(p2)); } /** * Confirm that cloning works. */ public void testCloning() { SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); p1.setLegendItemShape(legendShape); SpiderWebPlot p2 = null; try { p2 = (SpiderWebPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // change the legendItemShape legendShape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(p1.equals(p2)); p2.setLegendItemShape(legendShape); assertTrue(p1.equals(p2)); // change a series paint p1.setSeriesPaint(1, Color.black); assertFalse(p1.equals(p2)); p2.setSeriesPaint(1, Color.black); assertTrue(p1.equals(p2)); // change a series outline paint p1.setSeriesOutlinePaint(0, Color.red); assertFalse(p1.equals(p2)); p2.setSeriesOutlinePaint(0, Color.red); assertTrue(p1.equals(p2)); // change a series outline stroke p1.setSeriesOutlineStroke(0, new BasicStroke(1.1f)); assertFalse(p1.equals(p2)); p2.setSeriesOutlineStroke(0, new BasicStroke(1.1f)); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); SpiderWebPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (SpiderWebPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown. */ public void testDrawWithNullInfo() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S1", "C3"); dataset.addValue(15.0, "S1", "C4"); dataset.addValue(25.0, "S1", "C5"); SpiderWebPlot plot = new SpiderWebPlot(dataset); JFreeChart chart = new JFreeChart(plot); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/ThermometerPlotTests.java0000644000175000017500000002131711173030414031426 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ThermometerPlotTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 30-Apr-2007 : Added new serialization test (DG); * 03-May-2007 : Added cloning test (DG); * 08-Oct-2007 : Updated testEquals() for new fields (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.ThermometerPlot; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link ThermometerPlot} class. */ public class ThermometerPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ThermometerPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ThermometerPlotTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { ThermometerPlot p1 = new ThermometerPlot(); ThermometerPlot p2 = new ThermometerPlot(); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); // padding p1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(p1.equals(p2)); p2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(p2.equals(p1)); // thermometerStroke BasicStroke s = new BasicStroke(1.23f); p1.setThermometerStroke(s); assertFalse(p1.equals(p2)); p2.setThermometerStroke(s); assertTrue(p2.equals(p1)); // thermometerPaint p1.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(p1.equals(p2)); p2.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(p2.equals(p1)); // units p1.setUnits(ThermometerPlot.UNITS_KELVIN); assertFalse(p1.equals(p2)); p2.setUnits(ThermometerPlot.UNITS_KELVIN); assertTrue(p2.equals(p1)); // valueLocation p1.setValueLocation(ThermometerPlot.LEFT); assertFalse(p1.equals(p2)); p2.setValueLocation(ThermometerPlot.LEFT); assertTrue(p2.equals(p1)); // axisLocation p1.setAxisLocation(ThermometerPlot.RIGHT); assertFalse(p1.equals(p2)); p2.setAxisLocation(ThermometerPlot.RIGHT); assertTrue(p2.equals(p1)); // valueFont p1.setValueFont(new Font("Serif", Font.PLAIN, 9)); assertFalse(p1.equals(p2)); p2.setValueFont(new Font("Serif", Font.PLAIN, 9)); assertTrue(p2.equals(p1)); // valuePaint p1.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.white)); assertFalse(p1.equals(p2)); p2.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.white)); assertTrue(p2.equals(p1)); // valueFormat p1.setValueFormat(new DecimalFormat("0.0000")); assertFalse(p1.equals(p2)); p2.setValueFormat(new DecimalFormat("0.0000")); assertTrue(p2.equals(p1)); // mercuryPaint p1.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.red, 7.0f, 6.0f, Color.blue)); assertFalse(p1.equals(p2)); p2.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.red, 7.0f, 6.0f, Color.blue)); assertTrue(p2.equals(p1)); // showValueLines p1.setShowValueLines(true); assertFalse(p1.equals(p2)); p2.setShowValueLines(true); assertTrue(p2.equals(p1)); p1.setSubrange(1, 1.0, 2.0); assertFalse(p1.equals(p2)); p2.setSubrange(1, 1.0, 2.0); assertTrue(p2.equals(p1)); p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(p1.equals(p2)); p2.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(p2.equals(p1)); p1.setBulbRadius(9); assertFalse(p1.equals(p2)); p2.setBulbRadius(9); assertTrue(p2.equals(p1)); p1.setColumnRadius(8); assertFalse(p1.equals(p2)); p2.setColumnRadius(8); assertTrue(p2.equals(p1)); p1.setGap(7); assertFalse(p1.equals(p2)); p2.setGap(7); assertTrue(p2.equals(p1)); } /** * Confirm that cloning works. */ public void testCloning() { ThermometerPlot p1 = new ThermometerPlot(); ThermometerPlot p2 = null; try { p2 = (ThermometerPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ThermometerPlot p1 = new ThermometerPlot(); ThermometerPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (ThermometerPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { ThermometerPlot p1 = new ThermometerPlot(); p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); ThermometerPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (ThermometerPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(p1.equals(p2)); } /** * Some checks for the setUnits() method. */ public void testSetUnits() { ThermometerPlot p1 = new ThermometerPlot(); assertEquals(ThermometerPlot.UNITS_CELCIUS, p1.getUnits()); p1.setUnits("FAHRENHEIT"); // this doesn't work assertEquals(ThermometerPlot.UNITS_CELCIUS, p1.getUnits()); p1.setUnits("\u00B0F"); // ...but this does! assertEquals(ThermometerPlot.UNITS_FAHRENHEIT, p1.getUnits()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/ValueMarkerTests.java0000644000175000017500000002227611173030414030517 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * ValueMarkerTests.java * --------------------- * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Aug-2003 : Version 1 (DG); * 14-Jun-2004 : Renamed MarkerTests --> ValueMarkerTests (DG); * 01-Jun-2005 : Strengthened equals() test (DG); * 05-Sep-2006 : Added checks for MarkerChangeEvent generation (DG); * 26-Sep-2007 : Added test1802195() method (DG); * 08-Oct-2007 : Added test1808376() method (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.ValueMarker; import org.jfree.ui.LengthAdjustmentType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; /** * Tests for the {@link ValueMarker} class. */ public class ValueMarkerTests extends TestCase implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ValueMarkerTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ValueMarkerTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Marker m1 = new ValueMarker(45.0); Marker m2 = new ValueMarker(45.0); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); m1.setPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertFalse(m1.equals(m2)); m2.setPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertTrue(m1.equals(m2)); BasicStroke stroke = new BasicStroke(2.2f); m1.setStroke(stroke); assertFalse(m1.equals(m2)); m2.setStroke(stroke); assertTrue(m1.equals(m2)); m1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.yellow, 2.0f, 1.0f, Color.white)); assertFalse(m1.equals(m2)); m2.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.yellow, 2.0f, 1.0f, Color.white)); assertTrue(m1.equals(m2)); m1.setOutlineStroke(stroke); assertFalse(m1.equals(m2)); m2.setOutlineStroke(stroke); assertTrue(m1.equals(m2)); m1.setAlpha(0.1f); assertFalse(m1.equals(m2)); m2.setAlpha(0.1f); assertTrue(m1.equals(m2)); m1.setLabel("New Label"); assertFalse(m1.equals(m2)); m2.setLabel("New Label"); assertTrue(m1.equals(m2)); m1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); assertFalse(m1.equals(m2)); m2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); assertTrue(m1.equals(m2)); m1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertFalse(m1.equals(m2)); m2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.yellow)); assertTrue(m1.equals(m2)); m1.setLabelAnchor(RectangleAnchor.TOP_RIGHT); assertFalse(m1.equals(m2)); m2.setLabelAnchor(RectangleAnchor.TOP_RIGHT); assertTrue(m1.equals(m2)); m1.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); assertFalse(m1.equals(m2)); m2.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); assertTrue(m1.equals(m2)); m1.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertFalse(m1.equals(m2)); m2.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertTrue(m1.equals(m2)); m1.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertFalse(m1.equals(m2)); m2.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertTrue(m1.equals(m2)); m1 = new ValueMarker(12.3); m2 = new ValueMarker(45.6); assertFalse(m1.equals(m2)); m2 = new ValueMarker(12.3); assertTrue(m1.equals(m2)); } /** * Confirm that cloning works. */ public void testCloning() { ValueMarker m1 = new ValueMarker(25.0); ValueMarker m2 = null; try { m2 = (ValueMarker) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1 != m2); assertTrue(m1.getClass() == m2.getClass()); assertTrue(m1.equals(m2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ValueMarker m1 = new ValueMarker(25.0); ValueMarker m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (ValueMarker) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = m1.equals(m2); assertTrue(b); } private static final double EPSILON = 0.000000001; /** * Some checks for the getValue() and setValue() methods. */ public void testGetSetValue() { ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(1.1, m.getValue(), EPSILON); m.setValue(33.3); assertEquals(33.3, m.getValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } /** * Records the last event. * * @param event the last event. */ public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } /** * A test for bug 1802195. */ public void test1802195() { ValueMarker m1 = new ValueMarker(25.0); ValueMarker m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (ValueMarker) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } boolean b = m1.equals(m2); assertTrue(b); boolean pass = true; try { m2.setValue(-10.0); } catch (NullPointerException e) { pass = false; } assertTrue(pass); } /** * A test for bug report 1808376. */ public void test1808376() { Stroke stroke = new BasicStroke(1.0f); Stroke outlineStroke = new BasicStroke(2.0f); ValueMarker m = new ValueMarker(1.0, Color.red, stroke, Color.blue, outlineStroke, 0.5f); assertEquals(1.0, m.getValue(), EPSILON); assertEquals(Color.red, m.getPaint()); assertEquals(stroke, m.getStroke()); assertEquals(Color.blue, m.getOutlinePaint()); assertEquals(outlineStroke, m.getOutlineStroke()); assertEquals(0.5f, m.getAlpha(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/XYPlotTests.java0000644000175000017500000012440611173030414027476 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * XYPlotTests.java * ---------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 22-Mar-2004 : Added new cloning test (DG); * 05-Oct-2004 : Strengthened test for clone independence (DG); * 22-Nov-2006 : Added quadrant fields to equals() and clone() tests (DG); * 09-Jan-2007 : Mark and comment out testGetDatasetCount() (DG); * 05-Feb-2007 : Added testAddDomainMarker() and testAddRangeMarker() (DG); * 07-Feb-2007 : Added test1654215() (DG); * 24-May-2007 : Added testDrawSeriesWithZeroItems() (DG); * 07-Apr-2008 : Added testRemoveDomainMarker() and * testRemoveRangeMarker() (DG); * */ package org.jfree.chart.plot.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Stroke; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Arrays; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItemCollection; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.plot.IntervalMarker; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.time.Day; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.date.MonthConstants; import org.jfree.ui.Layer; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link XYPlot} class. */ public class XYPlotTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYPlotTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYPlotTests(String name) { super(name); } // FIXME: the getDatasetCount() method is returning a count of the slots // available for datasets, rather than the number of datasets actually // specified...see if there is some way to clean this up. // /** // * Added this test in response to a bug report. // */ // public void testGetDatasetCount() { // XYPlot plot = new XYPlot(); // assertEquals(0, plot.getDatasetCount()); // } /** * Some checks for the equals() method. */ public void testEquals() { XYPlot plot1 = new XYPlot(); XYPlot plot2 = new XYPlot(); assertTrue(plot1.equals(plot2)); // orientation... plot1.setOrientation(PlotOrientation.HORIZONTAL); assertFalse(plot1.equals(plot2)); plot2.setOrientation(PlotOrientation.HORIZONTAL); assertTrue(plot1.equals(plot2)); // axisOffset... plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); assertFalse(plot1.equals(plot2)); plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); assertTrue(plot1.equals(plot2)); // domainAxis... plot1.setDomainAxis(new NumberAxis("Domain Axis")); assertFalse(plot1.equals(plot2)); plot2.setDomainAxis(new NumberAxis("Domain Axis")); assertTrue(plot1.equals(plot2)); // domainAxisLocation... plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // secondary DomainAxes... plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis")); assertFalse(plot1.equals(plot2)); plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis")); assertTrue(plot1.equals(plot2)); // secondary DomainAxisLocations... plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // rangeAxis... plot1.setRangeAxis(new NumberAxis("Range Axis")); assertFalse(plot1.equals(plot2)); plot2.setRangeAxis(new NumberAxis("Range Axis")); assertTrue(plot1.equals(plot2)); // rangeAxisLocation... plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // secondary RangeAxes... plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); assertFalse(plot1.equals(plot2)); plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); assertTrue(plot1.equals(plot2)); // secondary RangeAxisLocations... plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); assertTrue(plot1.equals(plot2)); // secondary DatasetDomainAxisMap... plot1.mapDatasetToDomainAxis(11, 11); assertFalse(plot1.equals(plot2)); plot2.mapDatasetToDomainAxis(11, 11); assertTrue(plot1.equals(plot2)); // secondaryDatasetRangeAxisMap... plot1.mapDatasetToRangeAxis(11, 11); assertFalse(plot1.equals(plot2)); plot2.mapDatasetToRangeAxis(11, 11); assertTrue(plot1.equals(plot2)); // renderer plot1.setRenderer(new DefaultXYItemRenderer()); assertFalse(plot1.equals(plot2)); plot2.setRenderer(new DefaultXYItemRenderer()); assertTrue(plot1.equals(plot2)); // secondary renderers plot1.setRenderer(11, new DefaultXYItemRenderer()); assertFalse(plot1.equals(plot2)); plot2.setRenderer(11, new DefaultXYItemRenderer()); assertTrue(plot1.equals(plot2)); // domainGridlinesVisible plot1.setDomainGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinesVisible(false); assertTrue(plot1.equals(plot2)); // domainGridlineStroke Stroke stroke = new BasicStroke(2.0f); plot1.setDomainGridlineStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlineStroke(stroke); assertTrue(plot1.equals(plot2)); // domainGridlinePaint plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(plot1.equals(plot2)); // rangeGridlinesVisible plot1.setRangeGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinesVisible(false); assertTrue(plot1.equals(plot2)); // rangeGridlineStroke plot1.setRangeGridlineStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlineStroke(stroke); assertTrue(plot1.equals(plot2)); // rangeGridlinePaint plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertTrue(plot1.equals(plot2)); // rangeZeroBaselineVisible plot1.setRangeZeroBaselineVisible(true); assertFalse(plot1.equals(plot2)); plot2.setRangeZeroBaselineVisible(true); assertTrue(plot1.equals(plot2)); // rangeZeroBaselineStroke plot1.setRangeZeroBaselineStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setRangeZeroBaselineStroke(stroke); assertTrue(plot1.equals(plot2)); // rangeZeroBaselinePaint plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red)); assertFalse(plot1.equals(plot2)); plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.red)); assertTrue(plot1.equals(plot2)); // rangeCrosshairVisible plot1.setRangeCrosshairVisible(true); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairVisible(true); assertTrue(plot1.equals(plot2)); // rangeCrosshairValue plot1.setRangeCrosshairValue(100.0); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairValue(100.0); assertTrue(plot1.equals(plot2)); // rangeCrosshairStroke plot1.setRangeCrosshairStroke(stroke); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairStroke(stroke); assertTrue(plot1.equals(plot2)); // rangeCrosshairPaint plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, 3.0f, 4.0f, Color.red)); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, 3.0f, 4.0f, Color.red)); assertTrue(plot1.equals(plot2)); // rangeCrosshairLockedOnData plot1.setRangeCrosshairLockedOnData(false); assertFalse(plot1.equals(plot2)); plot2.setRangeCrosshairLockedOnData(false); assertTrue(plot1.equals(plot2)); // range markers plot1.addRangeMarker(new ValueMarker(4.0)); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(new ValueMarker(4.0)); assertTrue(plot1.equals(plot2)); // secondary range markers plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); assertTrue(plot1.equals(plot2)); plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND); assertFalse(plot1.equals(plot2)); plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND); assertTrue(plot1.equals(plot2)); // weight plot1.setWeight(3); assertFalse(plot1.equals(plot2)); plot2.setWeight(3); assertTrue(plot1.equals(plot2)); // quadrant origin plot1.setQuadrantOrigin(new Point2D.Double(12.3, 45.6)); assertFalse(plot1.equals(plot2)); plot2.setQuadrantOrigin(new Point2D.Double(12.3, 45.6)); assertTrue(plot1.equals(plot2)); // quadrant paint plot1.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(plot1.equals(plot2)); plot1.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, 4.0f, 5.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, 4.0f, 5.0f, Color.blue)); assertTrue(plot1.equals(plot2)); plot1.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.blue)); assertTrue(plot1.equals(plot2)); plot1.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.blue)); assertFalse(plot1.equals(plot2)); plot2.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, 6.0f, 7.0f, Color.blue)); assertTrue(plot1.equals(plot2)); plot1.setDomainTickBandPaint(Color.red); assertFalse(plot1.equals(plot2)); plot2.setDomainTickBandPaint(Color.red); assertTrue(plot1.equals(plot2)); plot1.setRangeTickBandPaint(Color.blue); assertFalse(plot1.equals(plot2)); plot2.setRangeTickBandPaint(Color.blue); assertTrue(plot1.equals(plot2)); plot1.setDomainMinorGridlinesVisible(true); assertFalse(plot1.equals(plot2)); plot2.setDomainMinorGridlinesVisible(true); assertTrue(plot1.equals(plot2)); plot1.setDomainMinorGridlinePaint(Color.red); assertFalse(plot1.equals(plot2)); plot2.setDomainMinorGridlinePaint(Color.red); assertTrue(plot1.equals(plot2)); plot1.setDomainGridlineStroke(new BasicStroke(1.1f)); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlineStroke(new BasicStroke(1.1f)); assertTrue(plot1.equals(plot2)); plot1.setRangeMinorGridlinesVisible(true); assertFalse(plot1.equals(plot2)); plot2.setRangeMinorGridlinesVisible(true); assertTrue(plot1.equals(plot2)); plot1.setRangeMinorGridlinePaint(Color.blue); assertFalse(plot1.equals(plot2)); plot2.setRangeMinorGridlinePaint(Color.blue); assertTrue(plot1.equals(plot2)); plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); assertFalse(plot1.equals(plot2)); plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); assertTrue(plot1.equals(plot2)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot1.mapDatasetToDomainAxes(0, axisIndices); assertFalse(plot1.equals(plot2)); plot2.mapDatasetToDomainAxes(0, axisIndices); assertTrue(plot1.equals(plot2)); plot1.mapDatasetToRangeAxes(0, axisIndices); assertFalse(plot1.equals(plot2)); plot2.mapDatasetToRangeAxes(0, axisIndices); assertTrue(plot1.equals(plot2)); } /** * Confirm that basic cloning works. */ public void testCloning() { XYPlot p1 = new XYPlot(); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Tests cloning for a more complex plot. */ public void testCloning2() { XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer()); p1.setRangeAxis(1, new NumberAxis("Range Axis 2")); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); p1.mapDatasetToDomainAxes(0, axisIndices); p1.mapDatasetToRangeAxes(0, axisIndices); p1.setRenderer(1, new XYBarRenderer()); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); } /** * Confirm that cloning captures the quadrantOrigin field. */ public void testCloning_QuadrantOrigin() { XYPlot p1 = new XYPlot(); Point2D p = new Point2D.Double(1.2, 3.4); p1.setQuadrantOrigin(p); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); assertTrue(p2.getQuadrantOrigin() != p); } /** * Confirm that cloning captures the quadrantOrigin field. */ public void testCloning_QuadrantPaint() { XYPlot p1 = new XYPlot(); p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check for independence p1.setQuadrantPaint(1, Color.red); assertFalse(p1.equals(p2)); p2.setQuadrantPaint(1, Color.red); assertTrue(p1.equals(p2)); } /** * Tests the independence of the clones. */ public void testCloneIndependence() { XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer()); p1.setDomainAxis(1, new NumberAxis("Domain Axis 2")); p1.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); p1.setRangeAxis(1, new NumberAxis("Range Axis 2")); p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT); p1.setRenderer(1, new XYBarRenderer()); XYPlot p2 = null; try { p2 = (XYPlot) p1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(p1.equals(p2)); p1.getDomainAxis().setLabel("Label"); assertFalse(p1.equals(p2)); p2.getDomainAxis().setLabel("Label"); assertTrue(p1.equals(p2)); p1.getDomainAxis(1).setLabel("S1"); assertFalse(p1.equals(p2)); p2.getDomainAxis(1).setLabel("S1"); assertTrue(p1.equals(p2)); p1.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT); assertFalse(p1.equals(p2)); p2.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT); assertTrue(p1.equals(p2)); p1.mapDatasetToDomainAxis(2, 1); assertFalse(p1.equals(p2)); p2.mapDatasetToDomainAxis(2, 1); assertTrue(p1.equals(p2)); p1.getRangeAxis().setLabel("Label"); assertFalse(p1.equals(p2)); p2.getRangeAxis().setLabel("Label"); assertTrue(p1.equals(p2)); p1.getRangeAxis(1).setLabel("S1"); assertFalse(p1.equals(p2)); p2.getRangeAxis(1).setLabel("S1"); assertTrue(p1.equals(p2)); p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); assertFalse(p1.equals(p2)); p2.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); assertTrue(p1.equals(p2)); p1.mapDatasetToRangeAxis(2, 1); assertFalse(p1.equals(p2)); p2.mapDatasetToRangeAxis(2, 1); assertTrue(p1.equals(p2)); p1.getRenderer().setOutlinePaint(Color.cyan); assertFalse(p1.equals(p2)); p2.getRenderer().setOutlinePaint(Color.cyan); assertTrue(p1.equals(p2)); p1.getRenderer(1).setOutlinePaint(Color.red); assertFalse(p1.equals(p2)); p2.getRenderer(1).setOutlinePaint(Color.red); assertTrue(p1.equals(p2)); } /** * Setting a null renderer should be allowed, but is generating a null * pointer exception in 0.9.7. */ public void testSetNullRenderer() { boolean failed = false; try { XYPlot plot = new XYPlot(null, new NumberAxis("X"), new NumberAxis("Y"), null); plot.setRenderer(null); } catch (Exception e) { failed = true; } assertTrue(!failed); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization1() { XYDataset data = new XYSeriesCollection(); NumberAxis domainAxis = new NumberAxis("Domain"); NumberAxis rangeAxis = new NumberAxis("Range"); StandardXYItemRenderer renderer = new StandardXYItemRenderer(); XYPlot p1 = new XYPlot(data, domainAxis, rangeAxis, renderer); XYPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); p2 = (XYPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. This test * uses a {@link DateAxis} and a {@link StandardXYToolTipGenerator}. */ public void testSerialization2() { IntervalXYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setBaseToolTipGenerator( StandardXYToolTipGenerator.getTimeSeriesInstance()); XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1); XYPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (XYPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2); } /** * Problem to reproduce a bug in serialization. The bug (first reported * against the {@link org.jfree.chart.plot.CategoryPlot} class) is a null * pointer exception that occurs when drawing a plot after deserialization. * It is caused by four temporary storage structures (axesAtTop, * axesAtBottom, axesAtLeft and axesAtRight - all initialized as empty * lists in the constructor) not being initialized by the readObject() * method following deserialization. This test has been written to * reproduce the bug (now fixed). */ public void testSerialization3() { XYSeriesCollection dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart( "Test Chart", "Domain Axis", "Range Axis", dataset, PlotOrientation.VERTICAL, true, true, false ); JFreeChart chart2 = null; // serialize and deserialize the chart.... try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(chart); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); chart2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(chart, chart2); boolean passed = true; try { chart2.createBufferedImage(300, 200); } catch (Exception e) { passed = false; e.printStackTrace(); } assertTrue(passed); } /** * A test to reproduce a bug in serialization: the domain and/or range * markers for a plot are not being serialized. */ public void testSerialization4() { XYSeriesCollection dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart( "Test Chart", "Domain Axis", "Range Axis", dataset, PlotOrientation.VERTICAL, true, true, false ); XYPlot plot = (XYPlot) chart.getPlot(); plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND); plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND); plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND); JFreeChart chart2 = null; // serialize and deserialize the chart.... try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(chart); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); chart2 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(chart, chart2); boolean passed = true; try { chart2.createBufferedImage(300, 200); } catch (Exception e) { passed = false; e.printStackTrace(); } assertTrue(passed); } /** * Tests a bug where the plot is no longer registered as a listener * with the dataset(s) and axes after deserialization. See patch 1209475 * at SourceForge. */ public void testSerialization5() { XYSeriesCollection dataset1 = new XYSeriesCollection(); NumberAxis domainAxis1 = new NumberAxis("Domain 1"); NumberAxis rangeAxis1 = new NumberAxis("Range 1"); StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(); XYPlot p1 = new XYPlot(dataset1, domainAxis1, rangeAxis1, renderer1); NumberAxis domainAxis2 = new NumberAxis("Domain 2"); NumberAxis rangeAxis2 = new NumberAxis("Range 2"); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); XYSeriesCollection dataset2 = new XYSeriesCollection(); p1.setDataset(1, dataset2); p1.setDomainAxis(1, domainAxis2); p1.setRangeAxis(1, rangeAxis2); p1.setRenderer(1, renderer2); XYPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); p2 = (XYPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2); // now check that all datasets, renderers and axes are being listened // too... NumberAxis domainAxisA = (NumberAxis) p2.getDomainAxis(0); NumberAxis rangeAxisA = (NumberAxis) p2.getRangeAxis(0); XYSeriesCollection datasetA = (XYSeriesCollection) p2.getDataset(0); StandardXYItemRenderer rendererA = (StandardXYItemRenderer) p2.getRenderer(0); NumberAxis domainAxisB = (NumberAxis) p2.getDomainAxis(1); NumberAxis rangeAxisB = (NumberAxis) p2.getRangeAxis(1); XYSeriesCollection datasetB = (XYSeriesCollection) p2.getDataset(1); StandardXYItemRenderer rendererB = (StandardXYItemRenderer) p2.getRenderer(1); assertTrue(datasetA.hasListener(p2)); assertTrue(domainAxisA.hasListener(p2)); assertTrue(rangeAxisA.hasListener(p2)); assertTrue(rendererA.hasListener(p2)); assertTrue(datasetB.hasListener(p2)); assertTrue(domainAxisB.hasListener(p2)); assertTrue(rangeAxisB.hasListener(p2)); assertTrue(rendererB.hasListener(p2)); } /** * Some checks for the getRendererForDataset() method. */ public void testGetRendererForDataset() { XYDataset d0 = new XYSeriesCollection(); XYDataset d1 = new XYSeriesCollection(); XYDataset d2 = new XYSeriesCollection(); XYDataset d3 = new XYSeriesCollection(); // not used by plot XYItemRenderer r0 = new XYLineAndShapeRenderer(); XYItemRenderer r2 = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(); plot.setDataset(0, d0); plot.setDataset(1, d1); plot.setDataset(2, d2); plot.setRenderer(0, r0); // no renderer 1 plot.setRenderer(2, r2); assertEquals(r0, plot.getRendererForDataset(d0)); assertEquals(r0, plot.getRendererForDataset(d1)); assertEquals(r2, plot.getRendererForDataset(d2)); assertEquals(null, plot.getRendererForDataset(d3)); assertEquals(null, plot.getRendererForDataset(null)); } /** * Some checks for the getLegendItems() method. */ public void testGetLegendItems() { // check the case where there is a secondary dataset that doesn't // have a renderer (i.e. falls back to renderer 0) XYDataset d0 = createDataset1(); XYDataset d1 = createDataset2(); XYItemRenderer r0 = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(); plot.setDataset(0, d0); plot.setDataset(1, d1); plot.setRenderer(0, r0); LegendItemCollection items = plot.getLegendItems(); assertEquals(2, items.getItemCount()); } /** * Creates a sample dataset. * * @return Series 1. */ private IntervalXYDataset createDataset1() { // create dataset 1... TimeSeries series1 = new TimeSeries("Series 1", Day.class); series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); TimeSeriesCollection collection = new TimeSeriesCollection(series1); return collection; } /** * Creates a sample dataset. * * @return A sample dataset. */ private XYDataset createDataset2() { // create dataset 1... XYSeries series = new XYSeries("Series 2"); XYSeriesCollection collection = new XYSeriesCollection(series); return collection; } /** * A test for a bug where setting the renderer doesn't register the plot * as a RendererChangeListener. */ public void testSetRenderer() { XYPlot plot = new XYPlot(); XYItemRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); // now make a change to the renderer and see if it triggers a plot // change event... MyPlotChangeListener listener = new MyPlotChangeListener(); plot.addChangeListener(listener); renderer.setSeriesPaint(0, Color.black); assertTrue(listener.getEvent() != null); } /** * Some checks for the removeAnnotation() method. */ public void testRemoveAnnotation() { XYPlot plot = new XYPlot(); XYTextAnnotation a1 = new XYTextAnnotation("X", 1.0, 2.0); XYTextAnnotation a2 = new XYTextAnnotation("X", 3.0, 4.0); XYTextAnnotation a3 = new XYTextAnnotation("X", 1.0, 2.0); plot.addAnnotation(a1); plot.addAnnotation(a2); plot.addAnnotation(a3); plot.removeAnnotation(a2); XYTextAnnotation x = (XYTextAnnotation) plot.getAnnotations().get(0); assertEquals(x, a1); // now remove a3, but since a3.equals(a1), this will in fact remove // a1... assertTrue(a1.equals(a3)); plot.removeAnnotation(a3); // actually removes a1 x = (XYTextAnnotation) plot.getAnnotations().get(0); assertEquals(x, a3); } /** * Some tests for the addDomainMarker() method(s). */ public void testAddDomainMarker() { XYPlot plot = new XYPlot(); Marker m = new ValueMarker(1.0); plot.addDomainMarker(m); List listeners = Arrays.asList(m.getListeners( MarkerChangeListener.class)); assertTrue(listeners.contains(plot)); plot.clearDomainMarkers(); listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); assertFalse(listeners.contains(plot)); } /** * Some tests for the addRangeMarker() method(s). */ public void testAddRangeMarker() { XYPlot plot = new XYPlot(); Marker m = new ValueMarker(1.0); plot.addRangeMarker(m); List listeners = Arrays.asList(m.getListeners( MarkerChangeListener.class)); assertTrue(listeners.contains(plot)); plot.clearRangeMarkers(); listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); assertFalse(listeners.contains(plot)); } /** * A test for bug 1654215 (where a renderer is added to the plot without * a corresponding dataset and it throws an exception at drawing time). */ public void test1654215() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(1, new XYLineAndShapeRenderer()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A test for drawing range grid lines when there is no primary renderer. * In 1.0.4, this is throwing a NullPointerException. */ public void testDrawRangeGridlines() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(null); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A test for drawing a plot where a series has zero items. With * JFreeChart 1.0.5+cvs this was throwing an exception at one point. */ public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Check that removing a marker that isn't assigned to the plot returns * false. */ public void testRemoveDomainMarker() { XYPlot plot = new XYPlot(); assertFalse(plot.removeDomainMarker(new ValueMarker(0.5))); } /** * Check that removing a marker that isn't assigned to the plot returns * false. */ public void testRemoveRangeMarker() { XYPlot plot = new XYPlot(); assertFalse(plot.removeRangeMarker(new ValueMarker(0.5))); } /** * Some tests for the getDomainAxisForDataset() method. */ public void testGetDomainAxisForDataset() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); assertEquals(xAxis, plot.getDomainAxisForDataset(0)); // should get IllegalArgumentException for negative index boolean pass = false; try { plot.getDomainAxisForDataset(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // should get IllegalArgumentException for index too high pass = false; try { plot.getDomainAxisForDataset(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // if multiple axes are mapped, the first in the list should be // returned... NumberAxis xAxis2 = new NumberAxis("X2"); plot.setDomainAxis(1, xAxis2); assertEquals(xAxis, plot.getDomainAxisForDataset(0)); plot.mapDatasetToDomainAxis(0, 1); assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot.mapDatasetToDomainAxes(0, axisIndices); assertEquals(xAxis, plot.getDomainAxisForDataset(0)); axisIndices = Arrays.asList(new Integer[] {new Integer(1), new Integer(2)}); plot.mapDatasetToDomainAxes(0, axisIndices); assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); } /** * Some tests for the getRangeAxisForDataset() method. */ public void testGetRangeAxisForDataset() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); // should get IllegalArgumentException for negative index boolean pass = false; try { plot.getRangeAxisForDataset(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // should get IllegalArgumentException for index too high pass = false; try { plot.getRangeAxisForDataset(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // if multiple axes are mapped, the first in the list should be // returned... NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); plot.mapDatasetToRangeAxis(0, 1); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); List axisIndices = Arrays.asList(new Integer[] {new Integer(0), new Integer(1)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis, plot.getRangeAxisForDataset(0)); axisIndices = Arrays.asList(new Integer[] {new Integer(1), new Integer(2)}); plot.mapDatasetToRangeAxes(0, axisIndices); assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/plot/junit/package.html0000644000175000017500000000021011173030414026654 0ustar vincentvincent JUnit tests for the plot classes. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/0000755000175000017500000000000011173030414024101 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/0000755000175000017500000000000011173030414025716 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/0000755000175000017500000000000011216245562027061 5ustar vincentvincent././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRen0000644000175000017500000003046311173030414033525 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------- * AbstractCategoryItemRendererTests.java * -------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-Feb-2004 : Version 1 (DG); * 24-Nov-2006 : New cloning tests (DG); * 07-Dec-2006 : Added testEquals() method (DG); * 25-Nov-2008 : Added testFindRangeBounds() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.text.NumberFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.IntervalCategoryItemLabelGenerator; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; /** * Tests for the {@link AbstractCategoryItemRenderer} class. */ public class AbstractCategoryItemRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AbstractCategoryItemRendererTests.class); } /** * Checks that all fields are distinguished. */ public void testEquals() { BarRenderer r1 = new BarRenderer(); BarRenderer r2 = new BarRenderer(); assertEquals(r1, r2); // the plot field is NOT tested // toolTipGenerator r1.setToolTipGenerator(new StandardCategoryToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); assertTrue(r1.equals(r2)); // toolTipGeneratorList r1.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); assertTrue(r1.equals(r2)); // baseToolTipGenerator r1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", NumberFormat.getInstance())); assertFalse(r1.equals(r2)); r2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", NumberFormat.getInstance())); assertTrue(r1.equals(r2)); // itemLabelGenerator r1.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); assertTrue(r1.equals(r2)); // itemLabelGeneratorList r1.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); assertTrue(r1.equals(r2)); // baseItemLabelGenerator r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( "{2}", NumberFormat.getInstance())); assertFalse(r1.equals(r2)); r2.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( "{2}", NumberFormat.getInstance())); assertTrue(r1.equals(r2)); // urlGenerator r1.setItemURLGenerator(new StandardCategoryURLGenerator()); assertFalse(r1.equals(r2)); r2.setItemURLGenerator(new StandardCategoryURLGenerator()); assertTrue(r1.equals(r2)); // urlGeneratorList r1.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator()); assertTrue(r1.equals(r2)); // baseItemURLGenerator r1.setBaseItemURLGenerator(new StandardCategoryURLGenerator( "abc.html")); assertFalse(r1.equals(r2)); r2.setBaseItemURLGenerator(new StandardCategoryURLGenerator( "abc.html")); assertTrue(r1.equals(r2)); // legendItemLabelGenerator r1.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( "XYZ")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( "XYZ")); assertTrue(r1.equals(r2)); // legendItemToolTipGenerator r1.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("ToolTip")); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator( new StandardCategorySeriesLabelGenerator("ToolTip")); assertTrue(r1.equals(r2)); // legendItemURLGenerator r1.setLegendItemURLGenerator( new StandardCategorySeriesLabelGenerator("URL")); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator( new StandardCategorySeriesLabelGenerator("URL")); assertTrue(r1.equals(r2)); } /** * Confirm that cloning works. */ public void testCloning1() { AbstractCategoryItemRenderer r1 = new BarRenderer(); r1.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); AbstractCategoryItemRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1 = new BarRenderer(); r1.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1 = new BarRenderer(); r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Confirm that cloning works. */ public void testCloning2() { BarRenderer r1 = new BarRenderer(); r1.setItemLabelGenerator(new IntervalCategoryItemLabelGenerator()); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1 = new BarRenderer(); r1.setSeriesItemLabelGenerator(0, new IntervalCategoryItemLabelGenerator()); r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1 = new BarRenderer(); r1.setBaseItemLabelGenerator(new IntervalCategoryItemLabelGenerator()); r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that the legendItemLabelGenerator is cloned. */ public void testCloning_LegendItemLabelGenerator() { StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}"); BarRenderer r1 = new BarRenderer(); r1.setLegendItemLabelGenerator(generator); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator()); } /** * Check that the legendItemToolTipGenerator is cloned. */ public void testCloning_LegendItemToolTipGenerator() { StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}"); BarRenderer r1 = new BarRenderer(); r1.setLegendItemToolTipGenerator(generator); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemToolTipGenerator() != r2.getLegendItemToolTipGenerator()); } /** * Check that the legendItemURLGenerator is cloned. */ public void testCloning_LegendItemURLGenerator() { StandardCategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("Series {0}"); BarRenderer r1 = new BarRenderer(); r1.setLegendItemURLGenerator(generator); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemURLGenerator() != r2.getLegendItemURLGenerator()); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { AbstractCategoryItemRenderer r = new LineAndShapeRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/AreaRendererTests.java0000644000175000017500000001371711173030414033305 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * AreaRendererTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode() test (DG); * 11-Oct-2006 : Strengthened the testEquals() method (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.AreaRendererEndType; import org.jfree.chart.renderer.category.AreaRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link AreaRenderer} class. */ public class AreaRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AreaRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AreaRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { AreaRenderer r1 = new AreaRenderer(); AreaRenderer r2 = new AreaRenderer(); assertEquals(r1, r2); r1.setEndType(AreaRendererEndType.LEVEL); assertFalse(r1.equals(r2)); r2.setEndType(AreaRendererEndType.LEVEL); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { AreaRenderer r1 = new AreaRenderer(); AreaRenderer r2 = new AreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { AreaRenderer r1 = new AreaRenderer(); AreaRenderer r2 = null; try { r2 = (AreaRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { AreaRenderer r1 = new AreaRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { AreaRenderer r1 = new AreaRenderer(); AreaRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (AreaRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); AreaRenderer r = new AreaRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/BarRenderer3DTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/BarRenderer3DTests.java0000644000175000017500000001233411173030414033322 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * BarRenderer3DTests.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 07-Dec-2006 : Improved testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.BarRenderer3D; import org.jfree.util.PublicCloneable; /** * Tests for the {@link BarRenderer3D} class. */ public class BarRenderer3DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BarRenderer3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BarRenderer3DTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { BarRenderer3D r1 = new BarRenderer3D(1.0, 2.0); BarRenderer3D r2 = new BarRenderer3D(1.0, 2.0); assertEquals(r1, r2); r1 = new BarRenderer3D(1.1, 2.0); assertFalse(r1.equals(r2)); r2 = new BarRenderer3D(1.1, 2.0); assertTrue(r1.equals(r2)); r1 = new BarRenderer3D(1.1, 2.2); assertFalse(r1.equals(r2)); r2 = new BarRenderer3D(1.1, 2.2); assertTrue(r1.equals(r2)); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 4.0f, 3.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 4.0f, 3.0f, Color.blue)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { BarRenderer3D r1 = new BarRenderer3D(); BarRenderer3D r2 = new BarRenderer3D(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { BarRenderer3D r1 = new BarRenderer3D(); BarRenderer3D r2 = null; try { r2 = (BarRenderer3D) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { BarRenderer3D r1 = new BarRenderer3D(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BarRenderer3D r1 = new BarRenderer3D(); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 4.0f, 3.0f, Color.blue)); BarRenderer3D r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (BarRenderer3D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java0000644000175000017500000002635011173030414033136 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * BarRendererTests.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 19-Aug-2003 : Renamed HorizontalBarRendererTests --> BarRendererTests (DG); * 22-Oct-2003 : Added hashCode test (DG); * 18-May-2005 : Added field to equals() test (DG); * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); * 11-May-2007 : Added testGetLegendItem() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 25-Nov-2008 : Added testFindRangeBounds (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.GradientBarPainter; import org.jfree.chart.renderer.junit.RendererChangeDetector; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.ui.TextAnchor; import org.jfree.util.PublicCloneable; /** * Tests for the {@link BarRenderer} class. */ public class BarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BarRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { BarRenderer r1 = new BarRenderer(); BarRenderer r2 = new BarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // base value r1.setBase(0.123); assertFalse(r1.equals(r2)); r2.setBase(0.123); assertTrue(r1.equals(r2)); // itemMargin r1.setItemMargin(0.22); assertFalse(r1.equals(r2)); r2.setItemMargin(0.22); assertTrue(r1.equals(r2)); // drawBarOutline r1.setDrawBarOutline(!r1.isDrawBarOutline()); assertFalse(r1.equals(r2)); r2.setDrawBarOutline(!r2.isDrawBarOutline()); assertTrue(r1.equals(r2)); // maximumBarWidth r1.setMaximumBarWidth(0.11); assertFalse(r1.equals(r2)); r2.setMaximumBarWidth(0.11); assertTrue(r1.equals(r2)); // minimumBarLength r1.setMinimumBarLength(0.04); assertFalse(r1.equals(r2)); r2.setMinimumBarLength(0.04); assertTrue(r1.equals(r2)); // gradientPaintTransformer r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); assertFalse(r1.equals(r2)); r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_VERTICAL)); assertTrue(r1.equals(r2)); // positiveItemLabelPositionFallback r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); assertFalse(r1.equals(r2)); r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); assertTrue(r1.equals(r2)); // negativeItemLabelPositionFallback r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); assertFalse(r1.equals(r2)); r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); assertTrue(r1.equals(r2)); // barPainter r1.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3)); assertFalse(r1.equals(r2)); r2.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3)); assertTrue(r1.equals(r2)); // shadowsVisible r1.setShadowVisible(false); assertFalse(r1.equals(r2)); r2.setShadowVisible(false); assertTrue(r1.equals(r2)); r1.setShadowPaint(Color.red); assertFalse(r1.equals(r2)); r2.setShadowPaint(Color.red); assertTrue(r1.equals(r2)); // shadowXOffset r1.setShadowXOffset(3.3); assertFalse(r1.equals(r2)); r2.setShadowXOffset(3.3); assertTrue(r1.equals(r2)); // shadowYOffset r1.setShadowYOffset(3.3); assertFalse(r1.equals(r2)); r2.setShadowYOffset(3.3); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { BarRenderer r1 = new BarRenderer(); BarRenderer r2 = new BarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { BarRenderer r1 = new BarRenderer(); r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); r1.setBarPainter(new GradientBarPainter(0.11, 0.22, 0.33)); BarRenderer r2 = null; try { r2 = (BarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { BarRenderer r1 = new BarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BarRenderer r1 = new BarRenderer(); BarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); r2 = (BarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Tests each setter method to ensure that it sends an event notification. */ public void testEventNotification() { RendererChangeDetector detector = new RendererChangeDetector(); BarRenderer r1 = new BarRenderer(); r1.addChangeListener(detector); detector.setNotified(false); r1.setBasePaint(Color.red); assertTrue(detector.getNotified()); } /** * Some checks for the getLegendItem() method. */ public void testGetLegendItem() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(21.0, "R1", "C1"); BarRenderer r = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), r); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(0, 0); assertNotNull(li); r.setSeriesVisibleInLegend(0, Boolean.FALSE); li = r.getLegendItem(0, 0); assertNull(li); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); BarRenderer r = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { BarRenderer r = new BarRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); r.setIncludeBaseInRange(false); assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); r.setIncludeBaseInRange(true); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTe0000644000175000017500000005161311173030414033470 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * BoxAndWhiskerRendererTests.java * ------------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2003 : Version 1 (DG); * 23-Apr-2004 : Extended testEquals() method (DG); * 12-Oct-2006 : Added new checks for bug 1572478 (DG); * 11-May-2007 : Added testGetLegendItem() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 08-Oct-2007 : Added tests for null items in dataset (DG); * 15-Jan-2008 : Updated testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 21-Jan-2009 : Updated testEquals() for new fields (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.statistics.BoxAndWhiskerItem; import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link BoxAndWhiskerRenderer} class. */ public class BoxAndWhiskerRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BoxAndWhiskerRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BoxAndWhiskerRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer(); assertEquals(r1, r2); r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.blue)); assertEquals(r1, r2); r1.setFillBox(!r1.getFillBox()); assertFalse(r1.equals(r2)); r2.setFillBox(!r2.getFillBox()); assertEquals(r1, r2); r1.setItemMargin(0.11); assertFalse(r1.equals(r2)); r2.setItemMargin(0.11); assertEquals(r1, r2); r1.setMaximumBarWidth(0.99); assertFalse(r1.equals(r2)); r2.setMaximumBarWidth(0.99); assertTrue(r1.equals(r2)); r1.setMeanVisible(false); assertFalse(r1.equals(r2)); r2.setMeanVisible(false); assertTrue(r1.equals(r2)); r1.setMedianVisible(false); assertFalse(r1.equals(r2)); r2.setMedianVisible(false); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); BoxAndWhiskerRenderer r2 = null; try { r2 = (BoxAndWhiskerRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); BoxAndWhiskerRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (BoxAndWhiskerRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(0.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { success = false; } assertTrue(success); } /** * A check for bug 1572478 (for the vertical orientation). */ public void testBug1572478Vertical() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() { public Number getQ1Value(int row, int column) { return null; } public Number getQ1Value(Comparable rowKey, Comparable columnKey) { return null; } }; List values = new ArrayList(); values.add(new Double(1.0)); values.add(new Double(10.0)); values.add(new Double(100.0)); dataset.add(values, "row", "column"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer()); JFreeChart chart = new JFreeChart(plot); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, new ChartRenderingInfo()); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * A check for bug 1572478 (for the horizontal orientation). */ public void testBug1572478Horizontal() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() { public Number getQ1Value(int row, int column) { return null; } public Number getQ1Value(Comparable rowKey, Comparable columnKey) { return null; } }; List values = new ArrayList(); values.add(new Double(1.0)); values.add(new Double(10.0)); values.add(new Double(100.0)); dataset.add(values, "row", "column"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(plot); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, new ChartRenderingInfo()); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Some checks for the getLegendItem() method. */ public void testGetLegendItem() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); List values = new ArrayList(); values.add(new Double(1.10)); values.add(new Double(1.45)); values.add(new Double(1.33)); values.add(new Double(1.23)); dataset.add(values, "R1", "C1"); BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), r); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(0, 0); assertNotNull(li); r.setSeriesVisibleInLegend(0, Boolean.FALSE); li = r.getLegendItem(0, 0); assertNull(li); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } /** * Draws a chart where the dataset contains a null mean value. */ public void testDrawWithNullMean() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(null, new Double(2.0), new Double(0.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null median value. */ public void testDrawWithNullMedian() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), null, new Double(0.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null Q1 value. */ public void testDrawWithNullQ1() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), null, new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null Q3 value. */ public void testDrawWithNullQ3() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), null, new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null min regular value. */ public void testDrawWithNullMinRegular() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), null, new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null max regular value. */ public void testDrawWithNullMaxRegular() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), null, new Double(-0.5), new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null min outlier value. */ public void testDrawWithNullMinOutlier() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), null, new Double(5.5), null), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Draws a chart where the dataset contains a null max outlier value. */ public void testDrawWithNullMaxOutlier() { boolean success = false; try { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), null, new java.util.ArrayList()), "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer()); ChartRenderingInfo info = new ChartRenderingInfo(); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, info); success = true; } catch (Exception e) { success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/CategoryStepRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/CategoryStepRendererTes0000644000175000017500000001330011173030414033543 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CategoryStepRendererTests.java * ------------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Mar-2005 : Version 1 (DG); * 22-Feb-2007 : Minor updates (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.CategoryStepRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CategoryStepRenderer} class. */ public class CategoryStepRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryStepRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryStepRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { CategoryStepRenderer r1 = new CategoryStepRenderer(false); CategoryStepRenderer r2 = new CategoryStepRenderer(false); assertEquals(r1, r2); r1 = new CategoryStepRenderer(true); assertFalse(r1.equals(r2)); r2 = new CategoryStepRenderer(true); assertTrue(r1.equals(r2)); } /** * Confirm that cloning works. */ public void testCloning() { CategoryStepRenderer r1 = new CategoryStepRenderer(false); CategoryStepRenderer r2 = null; try { r2 = (CategoryStepRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { CategoryStepRenderer r1 = new CategoryStepRenderer(false); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryStepRenderer r1 = new CategoryStepRenderer(); CategoryStepRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (CategoryStepRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); CategoryStepRenderer r = new CategoryStepRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/DefaultCategoryItemRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/DefaultCategoryItemRend0000644000175000017500000001150211173030414033503 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * DefaultCategoryItemRendererTests.java * ------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.DefaultCategoryItemRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link DefaultCategoryItemRenderer} class. */ public class DefaultCategoryItemRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultCategoryItemRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultCategoryItemRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); assertEquals(r1, r2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = null; try { r2 = (DefaultCategoryItemRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); DefaultCategoryItemRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (DefaultCategoryItemRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/GanttRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/GanttRendererTests.java0000644000175000017500000001242711173030414033507 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * GanttRendererTests.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2003 : Version 1 (DG); * 20-Mar-2007 : Extended testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.GanttRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link GanttRenderer} class. */ public class GanttRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GanttRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GanttRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { GanttRenderer r1 = new GanttRenderer(); GanttRenderer r2 = new GanttRenderer(); assertEquals(r1, r2); r1.setCompletePaint(Color.yellow); assertFalse(r1.equals(r2)); r2.setCompletePaint(Color.yellow); assertTrue(r1.equals(r2)); r1.setIncompletePaint(Color.green); assertFalse(r1.equals(r2)); r2.setIncompletePaint(Color.green); assertTrue(r1.equals(r2)); r1.setStartPercent(0.11); assertFalse(r1.equals(r2)); r2.setStartPercent(0.11); assertTrue(r1.equals(r2)); r1.setEndPercent(0.88); assertFalse(r1.equals(r2)); r2.setEndPercent(0.88); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { GanttRenderer r1 = new GanttRenderer(); GanttRenderer r2 = new GanttRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { GanttRenderer r1 = new GanttRenderer(); GanttRenderer r2 = null; try { r2 = (GanttRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { GanttRenderer r1 = new GanttRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GanttRenderer r1 = new GanttRenderer(); r1.setCompletePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); r1.setIncompletePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); GanttRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (GanttRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/GradientBarPainterTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/GradientBarPainterTests0000644000175000017500000001130511173030414033522 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * GradientBarPainterTests.java * ---------------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.GradientBarPainter; import org.jfree.util.PublicCloneable; /** * Tests for the {@link GradientBarPainter} class. */ public class GradientBarPainterTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GradientBarPainterTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GradientBarPainterTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); GradientBarPainter p2 = new GradientBarPainter(0.1, 0.2, 0.3); assertEquals(p1, p2); p1 = new GradientBarPainter(0.11, 0.2, 0.3); assertFalse(p1.equals(p2)); p2 = new GradientBarPainter(0.11, 0.2, 0.3); assertTrue(p1.equals(p2)); p1 = new GradientBarPainter(0.11, 0.22, 0.3); assertFalse(p1.equals(p2)); p2 = new GradientBarPainter(0.11, 0.22, 0.3); assertTrue(p1.equals(p2)); p1 = new GradientBarPainter(0.11, 0.22, 0.33); assertFalse(p1.equals(p2)); p2 = new GradientBarPainter(0.11, 0.22, 0.33); assertTrue(p1.equals(p2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); GradientBarPainter p2 = new GradientBarPainter(0.1, 0.2, 0.3); assertTrue(p1.equals(p2)); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning isn't implemented (it isn't required, because * instances of the class are immutable). */ public void testCloning() { GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); assertFalse(p1 instanceof Cloneable); assertFalse(p1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); GradientBarPainter p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (GradientBarPainter) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/GroupedStackedBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/GroupedStackedBarRender0000644000175000017500000001627511173030414033476 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * GroupedStackedBarRendererTests.java * ----------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Jul-2004 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.GroupedStackedBarRenderer; import org.jfree.data.KeyToGroupMap; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link GroupedStackedBarRenderer} class. */ public class GroupedStackedBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GroupedStackedBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GroupedStackedBarRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); GroupedStackedBarRenderer r2 = new GroupedStackedBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // map KeyToGroupMap m1 = new KeyToGroupMap("G1"); m1.mapKeyToGroup("S1", "G2"); r1.setSeriesToGroupMap(m1); assertFalse(r1.equals(r2)); KeyToGroupMap m2 = new KeyToGroupMap("G1"); m2.mapKeyToGroup("S1", "G2"); r2.setSeriesToGroupMap(m2); assertTrue(r1.equals(r2)); } /** * Confirm that cloning works. */ public void testCloning() { GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); GroupedStackedBarRenderer r2 = null; try { r2 = (GroupedStackedBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); GroupedStackedBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); r2 = (GroupedStackedBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); dataset.addValue(2.0, "S1", "C2"); dataset.addValue(3.0, "S2", "C1"); dataset.addValue(4.0, "S2", "C2"); GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), renderer); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { GroupedStackedBarRenderer r = new GroupedStackedBarRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); KeyToGroupMap m = new KeyToGroupMap("G1"); m.mapKeyToGroup("R1", "G1"); m.mapKeyToGroup("R2", "G1"); m.mapKeyToGroup("R3", "G2"); r.setSeriesToGroupMap(m); dataset.addValue(0.5, "R3", "C1"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(5.0, "R3", "C2"); assertEquals(new Range(-2.0, 5.0), r.findRangeBounds(dataset)); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/IntervalBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/IntervalBarRendererTest0000644000175000017500000001407511173030414033541 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * IntervalBarRendererTests.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.IntervalBarRenderer; import org.jfree.data.category.DefaultIntervalCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link IntervalBarRenderer} class. */ public class IntervalBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(IntervalBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public IntervalBarRendererTests(String name) { super(name); } /** * Problem that the equals() method distinguishes all fields. */ public void testEquals() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = new IntervalBarRenderer(); assertEquals(r1, r2); // the renderer should not be equal to a BarRenderer BarRenderer br = new BarRenderer(); assertFalse(r1.equals(br)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = new IntervalBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = null; try { r2 = (IntervalBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { IntervalBarRenderer r1 = new IntervalBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { IntervalBarRenderer r1 = new IntervalBarRenderer(); IntervalBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); r2 = (IntervalBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { double[][] starts = new double[][] {{0.1, 0.2, 0.3}, {0.3, 0.4, 0.5}}; double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}}; DefaultIntervalCategoryDataset dataset = new DefaultIntervalCategoryDataset(starts, ends); IntervalBarRenderer renderer = new IntervalBarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), renderer); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LayeredBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LayeredBarRendererTests0000644000175000017500000001320611173030414033520 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * LayeredBarRendererTests.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.LayeredBarRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link LayeredBarRenderer} class. */ public class LayeredBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LayeredBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LayeredBarRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = new LayeredBarRenderer(); assertEquals(r1, r2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = new LayeredBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = null; try { r2 = (LayeredBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { LayeredBarRenderer r1 = new LayeredBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LayeredBarRenderer r1 = new LayeredBarRenderer(); LayeredBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (LayeredBarRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new LayeredBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LevelRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LevelRendererTests.java0000644000175000017500000001674111173030414033504 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * LevelRendererTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Mar-2005 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.LevelRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link LevelRenderer} class. */ public class LevelRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LevelRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LevelRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { LevelRenderer r1 = new LevelRenderer(); LevelRenderer r2 = new LevelRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setItemMargin(0.123); assertFalse(r1.equals(r2)); r2.setItemMargin(0.123); assertTrue(r1.equals(r2)); r1.setMaximumItemWidth(0.234); assertFalse(r1.equals(r2)); r2.setMaximumItemWidth(0.234); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LevelRenderer r1 = new LevelRenderer(); LevelRenderer r2 = new LevelRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { LevelRenderer r1 = new LevelRenderer(); r1.setItemMargin(0.123); r1.setMaximumItemWidth(0.234); LevelRenderer r2 = null; try { r2 = (LevelRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); assertTrue(checkIndependence(r1, r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { LevelRenderer r1 = new LevelRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Checks that the two renderers are equal but independent of one another. * * @param r1 renderer 1. * @param r2 renderer 2. * * @return A boolean. */ private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) { // should be equal... boolean b0 = r1.equals(r2); // and independent... r1.setItemMargin(0.0); boolean b1 = !r1.equals(r2); r2.setItemMargin(0.0); boolean b2 = r1.equals(r2); return b0 && b1 && b2; } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LevelRenderer r1 = new LevelRenderer(); LevelRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (LevelRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new LevelRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); LevelRenderer r = new LevelRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LineAndShapeRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LineAndShapeRendererTes0000644000175000017500000002474511173030414033444 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * LineAndShapeRendererTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Sep-2003 : Version 1 (DG); * 17-May-2007 : Added check for getLegendItem() method (DG); * 27-Sep-2007 : Extended equals() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link LineAndShapeRenderer} class. */ public class LineAndShapeRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineAndShapeRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineAndShapeRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); LineAndShapeRenderer r2 = new LineAndShapeRenderer(); assertEquals(r1, r2); r1.setBaseLinesVisible(!r1.getBaseLinesVisible()); assertFalse(r1.equals(r2)); r2.setBaseLinesVisible(r1.getBaseLinesVisible()); assertTrue(r1.equals(r2)); r1.setSeriesLinesVisible(1, true); assertFalse(r1.equals(r2)); r2.setSeriesLinesVisible(1, true); assertTrue(r1.equals(r2)); r1.setLinesVisible(false); assertFalse(r1.equals(r2)); r2.setLinesVisible(false); assertTrue(r1.equals(r2)); r1.setBaseShapesVisible(!r1.getBaseShapesVisible()); assertFalse(r1.equals(r2)); r2.setBaseShapesVisible(r1.getBaseShapesVisible()); assertTrue(r1.equals(r2)); r1.setSeriesShapesVisible(1, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesVisible(1, true); assertTrue(r1.equals(r2)); r1.setShapesVisible(false); assertFalse(r1.equals(r2)); r2.setShapesVisible(false); assertTrue(r1.equals(r2)); r1.setShapesFilled(false); assertFalse(r1.equals(r2)); r2.setShapesFilled(false); assertTrue(r1.equals(r2)); r1.setSeriesShapesFilled(1, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesFilled(1, true); assertTrue(r1.equals(r2)); r1.setBaseShapesFilled(false); assertFalse(r1.equals(r2)); r2.setBaseShapesFilled(false); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(true); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(true); assertTrue(r1.equals(r2)); r1.setUseSeriesOffset(true); assertFalse(r1.equals(r2)); r2.setUseSeriesOffset(true); assertTrue(r1.equals(r2)); r1.setItemMargin(0.14); assertFalse(r1.equals(r2)); r2.setItemMargin(0.14); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); LineAndShapeRenderer r2 = new LineAndShapeRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); assertTrue(checkIndependence(r1, r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Checks that the two renderers are equal but independent of one another. * * @param r1 renderer 1. * @param r2 renderer 2. * * @return A boolean. */ private boolean checkIndependence(LineAndShapeRenderer r1, LineAndShapeRenderer r2) { // should be equal... if (!r1.equals(r2)) { return false; } // and independent... r1.setBaseLinesVisible(!r1.getBaseLinesVisible()); if (r1.equals(r2)) { return false; } r2.setBaseLinesVisible(r1.getBaseLinesVisible()); if (!r1.equals(r2)) { return false; } r1.setSeriesLinesVisible(1, true); if (r1.equals(r2)) { return false; } r2.setSeriesLinesVisible(1, true); if (!r1.equals(r2)) { return false; } r1.setLinesVisible(false); if (r1.equals(r2)) { return false; } r2.setLinesVisible(false); if (!r1.equals(r2)) { return false; } r1.setBaseShapesVisible(!r1.getBaseShapesVisible()); if (r1.equals(r2)) { return false; } r2.setBaseShapesVisible(r1.getBaseShapesVisible()); if (!r1.equals(r2)) { return false; } r1.setSeriesShapesVisible(1, true); if (r1.equals(r2)) { return false; } r2.setSeriesShapesVisible(1, true); if (!r1.equals(r2)) { return false; } r1.setShapesVisible(false); if (r1.equals(r2)) { return false; } r2.setShapesVisible(false); if (!r1.equals(r2)) { return false; } boolean flag = true; Boolean existing = r1.getShapesFilled(); if (existing != null) { flag = !existing.booleanValue(); } r1.setShapesFilled(flag); if (r1.equals(r2)) { return false; } r2.setShapesFilled(flag); if (!r1.equals(r2)) { return false; } r1.setShapesFilled(false); r2.setShapesFilled(false); r1.setSeriesShapesFilled(0, false); r2.setSeriesShapesFilled(0, true); if (r1.equals(r2)) { return false; } r2.setSeriesShapesFilled(0, false); if (!r1.equals(r2)) { return false; } r1.setBaseShapesFilled(false); r2.setBaseShapesFilled(true); if (r1.equals(r2)) { return false; } r2.setBaseShapesFilled(false); if (!r1.equals(r2)) { return false; } return true; } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); LineAndShapeRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (LineAndShapeRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); dataset0.addValue(21.0, "R1", "C1"); dataset0.addValue(22.0, "R2", "C1"); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(23.0, "R3", "C1"); dataset1.addValue(24.0, "R4", "C1"); dataset1.addValue(25.0, "R5", "C1"); LineAndShapeRenderer r = new LineAndShapeRenderer(); CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, dataset1); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("R5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LineRenderer3DTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/LineRenderer3DTests.jav0000644000175000017500000001704111173030414033344 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * LineRenderer3DTests.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Oct-2004 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.LineRenderer3D; import org.jfree.util.PublicCloneable; /** * Tests for the {@link LineRenderer3D} class. */ public class LineRenderer3DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineRenderer3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineRenderer3DTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { LineRenderer3D r1 = new LineRenderer3D(); LineRenderer3D r2 = new LineRenderer3D(); assertEquals(r1, r2); r1.setXOffset(99.9); assertFalse(r1.equals(r2)); r2.setXOffset(99.9); assertTrue(r1.equals(r2)); r1.setYOffset(111.1); assertFalse(r1.equals(r2)); r2.setYOffset(111.1); assertTrue(r1.equals(r2)); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LineRenderer3D r1 = new LineRenderer3D(); LineRenderer3D r2 = new LineRenderer3D(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { LineRenderer3D r1 = new LineRenderer3D(); LineRenderer3D r2 = null; try { r2 = (LineRenderer3D) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); assertTrue(checkIndependence(r1, r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { LineRenderer3D r1 = new LineRenderer3D(); assertTrue(r1 instanceof PublicCloneable); } /** * Checks that the two renderers are equal but independent of one another. * * @param r1 renderer 1. * @param r2 renderer 2. * * @return A boolean. */ private boolean checkIndependence(LineRenderer3D r1, LineRenderer3D r2) { // should be equal... boolean b0 = r1.equals(r2); // and independent... r1.setBaseLinesVisible(!r1.getBaseLinesVisible()); if (r1.equals(r2)) { return false; } r2.setBaseLinesVisible(r1.getBaseLinesVisible()); if (!r1.equals(r2)) { return false; } r1.setSeriesLinesVisible(1, true); if (r1.equals(r2)) { return false; } r2.setSeriesLinesVisible(1, true); if (!r1.equals(r2)) { return false; } r1.setLinesVisible(false); if (r1.equals(r2)) { return false; } r2.setLinesVisible(false); if (!r1.equals(r2)) { return false; } r1.setBaseShapesVisible(!r1.getBaseShapesVisible()); if (r1.equals(r2)) { return false; } r2.setBaseShapesVisible(r1.getBaseShapesVisible()); if (!r1.equals(r2)) { return false; } r1.setSeriesShapesVisible(1, true); if (r1.equals(r2)) { return false; } r2.setSeriesShapesVisible(1, true); if (!r1.equals(r2)) { return false; } r1.setShapesVisible(false); if (r1.equals(r2)) { return false; } r2.setShapesVisible(false); if (!r1.equals(r2)) { return false; } boolean flag = true; Boolean existing = r1.getShapesFilled(); if (existing != null) { flag = !existing.booleanValue(); } r1.setShapesFilled(flag); boolean b5 = !r1.equals(r2); r2.setShapesFilled(flag); boolean b6 = r1.equals(r2); r1.setShapesFilled(false); r2.setShapesFilled(false); r1.setSeriesShapesFilled(0, false); r2.setSeriesShapesFilled(0, true); boolean b7 = !r1.equals(r2); r2.setSeriesShapesFilled(0, false); boolean b8 = (r1.equals(r2)); r1.setBaseShapesFilled(false); r2.setBaseShapesFilled(true); boolean b9 = !r1.equals(r2); r2.setBaseShapesFilled(false); boolean b10 = (r1.equals(r2)); return b0 && b5 && b6 && b7 && b8 && b9 && b10; } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LineRenderer3D r1 = new LineRenderer3D(); LineRenderer3D r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); r2 = (LineRenderer3D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/MinMaxCategoryRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/MinMaxCategoryRendererT0000644000175000017500000001470311173030414033501 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * MinMaxCategoryRendererTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2003 : Version 1 (DG); * 28-Sep-2007 : Added testEquals() method (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.MinMaxCategoryRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link MinMaxCategoryRenderer} class. */ public class MinMaxCategoryRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MinMaxCategoryRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MinMaxCategoryRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer(); assertEquals(r1, r2); r1.setDrawLines(true); assertFalse(r1.equals(r2)); r2.setDrawLines(true); assertTrue(r1.equals(r2)); r1.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(r1.equals(r2)); r2.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(r1.equals(r2)); r1.setGroupStroke(new BasicStroke(1.2f)); assertFalse(r1.equals(r2)); r2.setGroupStroke(new BasicStroke(1.2f)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); MinMaxCategoryRenderer r2 = null; try { r2 = (MinMaxCategoryRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); MinMaxCategoryRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (MinMaxCategoryRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "S1", "C1"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new MinMaxCategoryRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/RendererCategoryPackageTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/RendererCategoryPackage0000644000175000017500000001003311173030414033507 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * RendererCategoryPackageTests.java * --------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 23-Aug-2004 : Restructured org.jfree.chart.renderer package (DG); * 18-Jan-2005 : Added main() method. * 15-Jun-2005 : Added new tests for StatisticalLineAndShapeRendererTests (DG); * */ package org.jfree.chart.renderer.category.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.renderer.category package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class RendererCategoryPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.renderer.category"); suite.addTestSuite(AbstractCategoryItemRendererTests.class); suite.addTestSuite(AreaRendererTests.class); suite.addTestSuite(BarRendererTests.class); suite.addTestSuite(BarRenderer3DTests.class); suite.addTestSuite(BoxAndWhiskerRendererTests.class); suite.addTestSuite(CategoryStepRendererTests.class); suite.addTestSuite(DefaultCategoryItemRendererTests.class); suite.addTestSuite(GanttRendererTests.class); suite.addTestSuite(GradientBarPainterTests.class); suite.addTestSuite(GroupedStackedBarRendererTests.class); suite.addTestSuite(IntervalBarRendererTests.class); suite.addTestSuite(LayeredBarRendererTests.class); suite.addTestSuite(LevelRendererTests.class); suite.addTestSuite(LineAndShapeRendererTests.class); suite.addTestSuite(LineRenderer3DTests.class); suite.addTestSuite(MinMaxCategoryRendererTests.class); suite.addTestSuite(ScatterRendererTests.class); suite.addTestSuite(StackedAreaRendererTests.class); suite.addTestSuite(StackedBarRendererTests.class); suite.addTestSuite(StackedBarRenderer3DTests.class); suite.addTestSuite(StandardBarPainterTests.class); suite.addTestSuite(StatisticalBarRendererTests.class); suite.addTestSuite(StatisticalLineAndShapeRendererTests.class); suite.addTestSuite(WaterfallBarRendererTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public RendererCategoryPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/ScatterRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/ScatterRendererTests.ja0000644000175000017500000001442611173030414033511 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * ScatterRendererTests.java * ------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Oct-2007 : Version 1 (DG); * 11-Oct-2007 : Renamed ScatterRenderer (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.ScatterRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link ScatterRenderer} class. */ public class ScatterRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ScatterRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ScatterRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { ScatterRenderer r1 = new ScatterRenderer(); ScatterRenderer r2 = new ScatterRenderer(); assertEquals(r1, r2); r1.setSeriesShapesFilled(1, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesFilled(1, true); assertTrue(r1.equals(r2)); r1.setBaseShapesFilled(false); assertFalse(r1.equals(r2)); r2.setBaseShapesFilled(false); assertTrue(r1.equals(r2)); r1.setUseFillPaint(true); assertFalse(r1.equals(r2)); r2.setUseFillPaint(true); assertTrue(r1.equals(r2)); r1.setDrawOutlines(true); assertFalse(r1.equals(r2)); r2.setDrawOutlines(true); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(true); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(true); assertTrue(r1.equals(r2)); r1.setUseSeriesOffset(false); assertFalse(r1.equals(r2)); r2.setUseSeriesOffset(false); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { ScatterRenderer r1 = new ScatterRenderer(); ScatterRenderer r2 = new ScatterRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ScatterRenderer r1 = new ScatterRenderer(); ScatterRenderer r2 = null; try { r2 = (ScatterRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); assertTrue(checkIndependence(r1, r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { ScatterRenderer r1 = new ScatterRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Checks that the two renderers are equal but independent of one another. * * @param r1 renderer 1. * @param r2 renderer 2. * * @return A boolean. */ private boolean checkIndependence(ScatterRenderer r1, ScatterRenderer r2) { // should be equal... if (!r1.equals(r2)) { return false; } // and independent... r1.setSeriesShapesFilled(1, true); if (r1.equals(r2)) { return false; } r2.setSeriesShapesFilled(1, true); if (!r1.equals(r2)) { return false; } r1.setBaseShapesFilled(false); r2.setBaseShapesFilled(true); if (r1.equals(r2)) { return false; } r2.setBaseShapesFilled(false); if (!r1.equals(r2)) { return false; } return true; } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ScatterRenderer r1 = new ScatterRenderer(); ScatterRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (ScatterRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StackedAreaRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StackedAreaRendererTest0000644000175000017500000001342411173030414033474 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * StackedAreaRendererTests.java * ----------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 04-Feb-2009 : Added testFindRangeBounds (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.StackedAreaRenderer; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StackedAreaRendererTests} class. */ public class StackedAreaRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedAreaRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedAreaRendererTests(String name) { super(name); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { StackedAreaRenderer r = new StackedAreaRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(2.0, "R2", "C1"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R2", "C2"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StackedAreaRenderer r1 = new StackedAreaRenderer(); StackedAreaRenderer r2 = new StackedAreaRenderer(); assertEquals(r1, r2); r1.setRenderAsPercentages(true); assertFalse(r1.equals(r2)); r2.setRenderAsPercentages(true); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedAreaRenderer r1 = new StackedAreaRenderer(); StackedAreaRenderer r2 = new StackedAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StackedAreaRenderer r1 = new StackedAreaRenderer(); StackedAreaRenderer r2 = null; try { r2 = (StackedAreaRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { StackedAreaRenderer r1 = new StackedAreaRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedAreaRenderer r1 = new StackedAreaRenderer(); StackedAreaRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedAreaRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StackedBarRenderer3DTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StackedBarRenderer3DTes0000644000175000017500000003566711173030414033350 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * StackedBarRenderer3DTests.java * ------------------------------ * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 18-Jan-2007 : Added many new tests (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 03-Feb-2009 : Added testFindRangeBounds() (DG); */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.StackedBarRenderer3D; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StackedBarRenderer3D} class. */ public class StackedBarRenderer3DTests extends TestCase { /** * Provide access to protected method. */ static class MyRenderer extends StackedBarRenderer3D { public static List createStackedValueList(CategoryDataset dataset, Comparable category, double base, boolean asPercentages) { return StackedBarRenderer3D.createStackedValueList(dataset, category, base, asPercentages); } } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedBarRenderer3DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedBarRenderer3DTests(String name) { super(name); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { StackedBarRenderer3D r = new StackedBarRenderer3D(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(2.0, "R2", "C1"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R2", "C2"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StackedBarRenderer3D r1 = new StackedBarRenderer3D(); StackedBarRenderer3D r2 = new StackedBarRenderer3D(); assertEquals(r1, r2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedBarRenderer3D r1 = new StackedBarRenderer3D(); StackedBarRenderer3D r2 = new StackedBarRenderer3D(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StackedBarRenderer3D r1 = new StackedBarRenderer3D(); StackedBarRenderer3D r2 = null; try { r2 = (StackedBarRenderer3D) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { StackedBarRenderer3D r1 = new StackedBarRenderer3D(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedBarRenderer3D r1 = new StackedBarRenderer3D(); StackedBarRenderer3D r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedBarRenderer3D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList1() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList2() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(-1.0, "s0", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList3() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(0.0, "s0", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList4() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(null, "s0", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(0, l.size()); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList1a() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(1.1, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(2.1), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList1b() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(-1.1, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(-1.1), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList1c() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(0.0, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList1d() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(null, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList2a() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(-1.0, "s0", "c0"); d.addValue(1.1, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(1.1), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList2b() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(-1.0, "s0", "c0"); d.addValue(-1.1, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(-2.1), ((Object[]) l.get(0))[1]); assertEquals(new Double(-1.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList2c() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(-1.0, "s0", "c0"); d.addValue(0.0, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList2d() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(-1.0, "s0", "c0"); d.addValue(null, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList3a() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(0.0, "s0", "c0"); d.addValue(1.1, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(1.1), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList3b() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(0.0, "s0", "c0"); d.addValue(-1.1, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(-1.1), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList3c() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(0.0, "s0", "c0"); d.addValue(0.0, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList3d() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(0.0, "s0", "c0"); d.addValue(null, "s1", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(2, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); } /** * A test for the createStackedValueList() method. */ public void testCreateStackedValueList5() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "s0", "c0"); d.addValue(null, "s1", "c0"); d.addValue(2.0, "s2", "c0"); List l = MyRenderer.createStackedValueList(d, "c0", 0.0, false); assertEquals(3, l.size()); assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); assertEquals(new Double(3.0), ((Object[]) l.get(2))[1]); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StackedBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StackedBarRendererTests0000644000175000017500000001341111173030414033507 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * StackedBarRendererTests.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.StackedBarRenderer; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StackedBarRenderer} class. */ public class StackedBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedBarRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StackedBarRenderer r1 = new StackedBarRenderer(); StackedBarRenderer r2 = new StackedBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setRenderAsPercentages(true); assertFalse(r1.equals(r2)); r2.setRenderAsPercentages(true); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { StackedBarRenderer r1 = new StackedBarRenderer(); StackedBarRenderer r2 = new StackedBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StackedBarRenderer r1 = new StackedBarRenderer(); StackedBarRenderer r2 = null; try { r2 = (StackedBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { StackedBarRenderer r1 = new StackedBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedBarRenderer r1 = new StackedBarRenderer(); StackedBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedBarRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { StackedBarRenderer r = new StackedBarRenderer(); assertNull(r.findRangeBounds(null)); // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); assertNull(r.findRangeBounds(dataset)); dataset.addValue(1.0, "R1", "C1"); assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(-2.0, "R1", "C2"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R1", "C3"); assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); dataset.addValue(2.0, "R2", "C1"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); dataset.addValue(null, "R2", "C2"); assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StandardBarPainterTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StandardBarPainterTests0000644000175000017500000001013311173030414033523 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * StandardBarPainterTests.java * ---------------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardBarPainter} class. */ public class StandardBarPainterTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardBarPainterTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardBarPainterTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StandardBarPainter p1 = new StandardBarPainter(); StandardBarPainter p2 = new StandardBarPainter(); assertEquals(p1, p2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StandardBarPainter p1 = new StandardBarPainter(); StandardBarPainter p2 = new StandardBarPainter(); assertTrue(p1.equals(p2)); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning isn't implemented (it isn't required, because * instances of the class are immutable). */ public void testCloning() { StandardBarPainter p1 = new StandardBarPainter(); assertFalse(p1 instanceof Cloneable); assertFalse(p1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardBarPainter p1 = new StandardBarPainter(); StandardBarPainter p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (StandardBarPainter) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StatisticalBarRendererT0000644000175000017500000002506711173030414033530 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * StatisticalBarRendererTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 28-Aug-2007 : Added tests for bug 1779941 (DG); * 14-Nov-2007 : Updated testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.BasicStroke; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.StatisticalBarRenderer; import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StatisticalBarRenderer} class. */ public class StatisticalBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StatisticalBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StatisticalBarRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = new StatisticalBarRenderer(); assertEquals(r1, r2); r1.setErrorIndicatorPaint(Color.red); assertFalse(r1.equals(r2)); r2.setErrorIndicatorPaint(Color.red); assertTrue(r2.equals(r1)); r1.setErrorIndicatorStroke(new BasicStroke(1.5f)); assertFalse(r1.equals(r2)); r2.setErrorIndicatorStroke(new BasicStroke(1.5f)); assertTrue(r2.equals(r1)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = new StatisticalBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = null; try { r2 = (StatisticalBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); r2 = (StatisticalBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(3.0, 4.0, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws the chart with a null mean value to make sure that * no exceptions are thrown (particularly by code in the renderer). See * bug report 1779941. */ public void testDrawWithNullMeanVertical() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(null, new Double(4.0), "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws the chart with a null mean value to make sure that * no exceptions are thrown (particularly by code in the renderer). See * bug report 1779941. */ public void testDrawWithNullMeanHorizontal() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(null, new Double(4.0), "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws the chart with a null standard deviation to make sure * that no exceptions are thrown (particularly by code in the renderer). * See bug report 1779941. */ public void testDrawWithNullDeviationVertical() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(new Double(4.0), null, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws the chart with a null standard deviation to make sure * that no exceptions are thrown (particularly by code in the renderer). * See bug report 1779941. */ public void testDrawWithNullDeviationHorizontal() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(new Double(4.0), null, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StatisticalLineAndShapeRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/StatisticalLineAndShape0000644000175000017500000001555511173030414033505 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------------- * StatisticalLineAndShapeRendererTests.java * ----------------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Jun-2005 : Version 1 (DG); * 25-Sep-2006 : Added test1562759() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.renderer.category.StatisticalLineAndShapeRenderer; import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StatisticalLineAndShapeRenderer} class. */ public class StatisticalLineAndShapeRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StatisticalLineAndShapeRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StatisticalLineAndShapeRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StatisticalLineAndShapeRenderer r1 = new StatisticalLineAndShapeRenderer(); StatisticalLineAndShapeRenderer r2 = new StatisticalLineAndShapeRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setErrorIndicatorPaint(Color.red); assertFalse(r1.equals(r2)); r2.setErrorIndicatorPaint(Color.red); assertTrue(r2.equals(r1)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StatisticalLineAndShapeRenderer r1 = new StatisticalLineAndShapeRenderer(); StatisticalLineAndShapeRenderer r2 = new StatisticalLineAndShapeRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StatisticalLineAndShapeRenderer r1 = new StatisticalLineAndShapeRenderer(); StatisticalLineAndShapeRenderer r2 = null; try { r2 = (StatisticalLineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { StatisticalLineAndShapeRenderer r1 = new StatisticalLineAndShapeRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StatisticalLineAndShapeRenderer r1 = new StatisticalLineAndShapeRenderer(); StatisticalLineAndShapeRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StatisticalLineAndShapeRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(3.0, 4.0, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalLineAndShapeRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A simple test for bug report 1562759. */ public void test1562759() { StatisticalLineAndShapeRenderer r = new StatisticalLineAndShapeRenderer(true, false); assertTrue(r.getBaseLinesVisible()); assertFalse(r.getBaseShapesVisible()); r = new StatisticalLineAndShapeRenderer(false, true); assertFalse(r.getBaseLinesVisible()); assertTrue(r.getBaseShapesVisible()); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/WaterfallBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/category/junit/WaterfallBarRendererTes0000644000175000017500000001347411173030414033514 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * WaterfallBarRendererTests.java * ------------------------------ * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Oct-2003 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 04-Feb-2009 : Added testFindRangeBounds() (DG); * */ package org.jfree.chart.renderer.category.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.category.WaterfallBarRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link WaterfallBarRenderer} class. */ public class WaterfallBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(WaterfallBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public WaterfallBarRendererTests(String name) { super(name); } /** * Some tests for the findRangeBounds() method. */ public void testFindRangeBounds() { WaterfallBarRenderer r = new WaterfallBarRenderer(); assertNull(r.findRangeBounds(null)); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { WaterfallBarRenderer r1 = new WaterfallBarRenderer(); WaterfallBarRenderer r2 = new WaterfallBarRenderer(); assertEquals(r1, r2); // firstBarPaint; r1.setFirstBarPaint(Color.cyan); assertFalse(r1.equals(r2)); r2.setFirstBarPaint(Color.cyan); assertTrue(r1.equals(r2)); // lastBarPaint; r1.setLastBarPaint(Color.cyan); assertFalse(r1.equals(r2)); r2.setLastBarPaint(Color.cyan); assertTrue(r1.equals(r2)); // positiveBarPaint; r1.setPositiveBarPaint(Color.cyan); assertFalse(r1.equals(r2)); r2.setPositiveBarPaint(Color.cyan); assertTrue(r1.equals(r2)); //private Paint negativeBarPaint; r1.setNegativeBarPaint(Color.cyan); assertFalse(r1.equals(r2)); r2.setNegativeBarPaint(Color.cyan); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { WaterfallBarRenderer r1 = new WaterfallBarRenderer(); WaterfallBarRenderer r2 = new WaterfallBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { WaterfallBarRenderer r1 = new WaterfallBarRenderer(); WaterfallBarRenderer r2 = null; try { r2 = (WaterfallBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // quick check for independence r1.setFirstBarPaint(Color.yellow); assertFalse(r1.equals(r2)); r2.setFirstBarPaint(Color.yellow); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { WaterfallBarRenderer r1 = new WaterfallBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { WaterfallBarRenderer r1 = new WaterfallBarRenderer(); WaterfallBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (WaterfallBarRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/0000755000175000017500000000000011216245562025244 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/AbstractRendererTests.java0000644000175000017500000010534511173030414032362 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * AbstractRendererTests.java * -------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Oct-2003 : Version 1 (DG); * 01-Mar-2004 : Added serialization test (DG); * 19-Feb-2007 : Added testCloning (DG); * 28-Feb-2007 : Added checks for cloning (DG); * 17-Jun-2008 : Added new fields to testEquals() and testCloning() (DG); * 28-Jan-2009 : Updated testEquals() (DG); * */ package org.jfree.chart.renderer.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.DefaultDrawingSupplier; import org.jfree.chart.renderer.AbstractRenderer; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.ui.TextAnchor; /** * Tests for the {@link AbstractRenderer} class. */ public class AbstractRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AbstractRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AbstractRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // have to use a concrete subclass... BarRenderer r1 = new BarRenderer(); BarRenderer r2 = new BarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // seriesVisible r1.setSeriesVisible(Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesVisible(Boolean.TRUE); assertTrue(r1.equals(r2)); // seriesVisibleList r1.setSeriesVisible(2, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesVisible(2, Boolean.TRUE); assertTrue(r1.equals(r2)); // baseSeriesVisible r1.setBaseSeriesVisible(false); assertFalse(r1.equals(r2)); r2.setBaseSeriesVisible(false); assertTrue(r1.equals(r2)); // seriesVisibleInLegend r1.setSeriesVisibleInLegend(Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesVisibleInLegend(Boolean.TRUE); assertTrue(r1.equals(r2)); // seriesVisibleInLegendList r1.setSeriesVisibleInLegend(1, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesVisibleInLegend(1, Boolean.TRUE); assertTrue(r1.equals(r2)); // baseSeriesVisibleInLegend r1.setBaseSeriesVisibleInLegend(false); assertFalse(r1.equals(r2)); r2.setBaseSeriesVisibleInLegend(false); assertTrue(r1.equals(r2)); // paint r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // paintList r1.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(r1.equals(r2)); r2.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(r1.equals(r2)); // basePaint r1.setBasePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setBasePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // fillPaint r1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // fillPaintList r1.setSeriesFillPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setSeriesFillPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // baseFillPaint r1.setBaseFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setBaseFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // outlinePaint r1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // outlinePaintList r1.setSeriesOutlinePaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setSeriesOutlinePaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // baseOutlinePaint r1.setBaseOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setBaseOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // stroke Stroke s = new BasicStroke(3.21f); r1.setStroke(s); assertFalse(r1.equals(r2)); r2.setStroke(s); assertTrue(r1.equals(r2)); // strokeList r1.setSeriesStroke(1, s); assertFalse(r1.equals(r2)); r2.setSeriesStroke(1, s); assertTrue(r1.equals(r2)); // baseStroke r1.setBaseStroke(s); assertFalse(r1.equals(r2)); r2.setBaseStroke(s); assertTrue(r1.equals(r2)); // outlineStroke r1.setOutlineStroke(s); assertFalse(r1.equals(r2)); r2.setOutlineStroke(s); assertTrue(r1.equals(r2)); // outlineStrokeList r1.setSeriesOutlineStroke(0, s); assertFalse(r1.equals(r2)); r2.setSeriesOutlineStroke(0, s); assertTrue(r1.equals(r2)); // baseOutlineStroke r1.setBaseOutlineStroke(s); assertFalse(r1.equals(r2)); r2.setBaseOutlineStroke(s); assertTrue(r1.equals(r2)); // shape r1.setShape(new Ellipse2D.Double(1, 2, 3, 4)); assertFalse(r1.equals(r2)); r2.setShape(new Ellipse2D.Double(1, 2, 3, 4)); assertTrue(r1.equals(r2)); // shapeList r1.setSeriesShape(1, new Ellipse2D.Double(1, 2, 3, 4)); assertFalse(r1.equals(r2)); r2.setSeriesShape(1, new Ellipse2D.Double(1, 2, 3, 4)); assertTrue(r1.equals(r2)); // baseShape r1.setBaseShape(new Ellipse2D.Double(1, 2, 3, 4)); assertFalse(r1.equals(r2)); r2.setBaseShape(new Ellipse2D.Double(1, 2, 3, 4)); assertTrue(r1.equals(r2)); // itemLabelsVisible r1.setItemLabelsVisible(true); assertFalse(r1.equals(r2)); r2.setItemLabelsVisible(true); assertTrue(r1.equals(r2)); // itemLabelsVisibleList r1.setSeriesItemLabelsVisible(1, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelsVisible(1, Boolean.TRUE); assertTrue(r1.equals(r2)); // baseItemLabelsVisible r1.setBaseItemLabelsVisible(true); assertFalse(r1.equals(r2)); r2.setBaseItemLabelsVisible(true); assertTrue(r1.equals(r2)); // itemLabelFont r1.setItemLabelFont(new Font("Serif", Font.PLAIN, 10)); assertFalse(r1.equals(r2)); r2.setItemLabelFont(new Font("Serif", Font.PLAIN, 10)); assertTrue(r1.equals(r2)); // itemLabelFontList r1.setSeriesItemLabelFont(1, new Font("Serif", Font.BOLD, 9)); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelFont(1, new Font("Serif", Font.BOLD, 9)); assertTrue(r1.equals(r2)); // baseItemLabelFont r1.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10)); assertFalse(r1.equals(r2)); r2.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10)); assertTrue(r1.equals(r2)); // itemLabelPaint r1.setItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.gray)); assertFalse(r1.equals(r2)); r2.setItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.gray)); assertTrue(r1.equals(r2)); // itemLabelPaintList r1.setSeriesItemLabelPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.gray)); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.gray)); assertTrue(r1.equals(r2)); // baseItemLabelPaint r1.setBaseItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.gray)); assertFalse(r1.equals(r2)); r2.setBaseItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.gray)); assertTrue(r1.equals(r2)); // positiveItemLabelPosition; r1.setPositiveItemLabelPosition(new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setPositiveItemLabelPosition(new ItemLabelPosition()); assertTrue(r1.equals(r2)); // positiveItemLabelPositionList; r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); // basePositiveItemLabelPosition; r1.setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertFalse(r1.equals(r2)); r2.setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertTrue(r1.equals(r2)); // negativeItemLabelPosition; r1.setNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertFalse(r1.equals(r2)); r2.setNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertTrue(r1.equals(r2)); // negativeItemLabelPositionList; r1.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertFalse(r1.equals(r2)); r2.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertTrue(r1.equals(r2)); // baseNegativeItemLabelPosition; r1.setBaseNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertFalse(r1.equals(r2)); r2.setBaseNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); assertTrue(r1.equals(r2)); // itemLabelAnchorOffset r1.setItemLabelAnchorOffset(3.0); assertFalse(r1.equals(r2)); r2.setItemLabelAnchorOffset(3.0); assertTrue(r1.equals(r2)); // createEntities; r1.setCreateEntities(Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setCreateEntities(Boolean.TRUE); assertTrue(r1.equals(r2)); // createEntitiesList; r1.setSeriesCreateEntities(0, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesCreateEntities(0, Boolean.TRUE); assertTrue(r1.equals(r2)); // baseCreateEntities; r1.setBaseCreateEntities(false); assertFalse(r1.equals(r2)); r2.setBaseCreateEntities(false); assertTrue(r1.equals(r2)); // legendShape r1.setLegendShape(0, new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendShape(0, new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); // baseLegendShape r1.setBaseLegendShape(new Ellipse2D.Double(5.0, 6.0, 7.0, 8.0)); assertFalse(r1.equals(r2)); r2.setBaseLegendShape(new Ellipse2D.Double(5.0, 6.0, 7.0, 8.0)); assertTrue(r1.equals(r2)); // legendTextFont r1.setLegendTextFont(0, new Font("Dialog", Font.PLAIN, 7)); assertFalse(r1.equals(r2)); r2.setLegendTextFont(0, new Font("Dialog", Font.PLAIN, 7)); assertTrue(r1.equals(r2)); // baseLegendTextFont r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 7)); assertFalse(r1.equals(r2)); r2.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 7)); assertTrue(r1.equals(r2)); // legendTextPaint r1.setLegendTextPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setLegendTextPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); // baseOutlinePaint r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); } /** * Confirm that cloning works. */ public void testCloning() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); Rectangle2D shape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); Rectangle2D baseShape = new Rectangle2D.Double(11.0, 12.0, 13.0, 14.0); r1.setShape(shape); r1.setBaseShape(baseShape); r1.setBaseLegendShape(new Rectangle(4, 3, 2, 1)); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 3)); r1.setBaseLegendTextPaint(new Color(1, 2, 3)); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1.setSeriesVisible(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesVisible(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setSeriesVisibleInLegend(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesVisibleInLegend(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setSeriesPaint(0, Color.black); assertFalse(r1.equals(r2)); r2.setSeriesPaint(0, Color.black); assertTrue(r1.equals(r2)); r1.setSeriesFillPaint(0, Color.yellow); assertFalse(r1.equals(r2)); r2.setSeriesFillPaint(0, Color.yellow); assertTrue(r1.equals(r2)); r1.setSeriesOutlinePaint(0, Color.yellow); assertFalse(r1.equals(r2)); r2.setSeriesOutlinePaint(0, Color.yellow); assertTrue(r1.equals(r2)); r1.setSeriesStroke(0, new BasicStroke(2.2f)); assertFalse(r1.equals(r2)); r2.setSeriesStroke(0, new BasicStroke(2.2f)); assertTrue(r1.equals(r2)); r1.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); assertFalse(r1.equals(r2)); r2.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); assertTrue(r1.equals(r2)); shape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); baseShape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setBaseShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); r1.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelPaint(0, Color.red); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelPaint(0, Color.red); assertTrue(r1.equals(r2)); r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); assertTrue(r1.equals(r2)); r1.setSeriesCreateEntities(0, Boolean.FALSE); assertFalse(r1.equals(r2)); r2.setSeriesCreateEntities(0, Boolean.FALSE); assertTrue(r1.equals(r2)); r1.setLegendShape(0, new Rectangle(9, 7, 3, 4)); assertFalse(r1.equals(r2)); r2.setLegendShape(0, new Rectangle(9, 7, 3, 4)); assertTrue(r1.equals(r2)); r1.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); assertFalse(r1.equals(r2)); r2.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); assertTrue(r1.equals(r2)); r1.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); assertFalse(r1.equals(r2)); r2.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); assertTrue(r1.equals(r2)); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); assertFalse(r1.equals(r2)); r2.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); assertTrue(r1.equals(r2)); r1.setLegendTextPaint(3, Color.red); assertFalse(r1.equals(r2)); r2.setLegendTextPaint(3, Color.red); assertTrue(r1.equals(r2)); r1.setBaseLegendTextPaint(Color.green); assertFalse(r1.equals(r2)); r2.setBaseLegendTextPaint(Color.green); assertTrue(r1.equals(r2)); } /** * A utility class for listening to changes to a renderer. */ static class MyRendererChangeListener implements RendererChangeListener { /** The last event received. */ public RendererChangeEvent lastEvent; /** * Creates a new instance. */ public MyRendererChangeListener() { this.lastEvent = null; } public void rendererChanged(RendererChangeEvent event) { this.lastEvent = event; } } /** * A check for cloning. */ public void testCloning2() { LineAndShapeRenderer r1 = new LineAndShapeRenderer(); r1.setBasePaint(Color.blue); r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); LineAndShapeRenderer r2 = null; try { r2 = (LineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); MyRendererChangeListener listener = new MyRendererChangeListener(); r2.addChangeListener(listener); r2.setBasePaint(Color.red); assertTrue(listener.lastEvent.getRenderer() == r2); assertFalse(r1.hasListener(listener)); } /** * Test that setting the series visibility for ALL series does in fact work. */ public void testSetSeriesVisible() { BarRenderer r = new BarRenderer(); r.setSeriesVisible(Boolean.TRUE); assertTrue(r.getItemVisible(0, 0)); } /** * Test that setting the paint for ALL series does in fact work. */ public void testSetPaint() { BarRenderer r = new BarRenderer(); r.setPaint(Color.orange); assertEquals(Color.orange, r.getItemPaint(0, 0)); } /** * Test that setting the outline paint for ALL series does in fact work. */ public void testSetOutlinePaint() { BarRenderer r = new BarRenderer(); r.setOutlinePaint(Color.orange); assertEquals(Color.orange, r.getItemOutlinePaint(0, 0)); } /** * Test that setting the stroke for ALL series does in fact work. */ public void testSetStroke() { BarRenderer r = new BarRenderer(); Stroke s = new BasicStroke(10.0f); r.setStroke(s); assertEquals(s, r.getItemStroke(0, 0)); } /** * Test that setting the outline stroke for ALL series does in fact work. */ public void testSetOutlineStroke() { BarRenderer r = new BarRenderer(); Stroke s = new BasicStroke(10.0f); r.setOutlineStroke(s); assertEquals(s, r.getItemOutlineStroke(0, 0)); } /** * Test that setting the shape for ALL series does in fact work. */ public void testSetShape() { BarRenderer r = new BarRenderer(); Shape s = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); r.setShape(s); assertEquals(s, r.getItemShape(0, 0)); } /** * Test that setting the item label visibility for ALL series does in fact * work. */ public void testSetItemLabelsVisible() { BarRenderer r = new BarRenderer(); r.setItemLabelsVisible(true); assertTrue(r.isItemLabelVisible(0, 0)); } /** * Test that setting the font for ALL series does in fact work (it was * broken at one point). */ public void testSetItemLabelFont() { BarRenderer r = new BarRenderer(); r.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 33)); assertEquals(new Font("SansSerif", Font.PLAIN, 33), r.getItemLabelFont(0, 0)); } /** * Test that setting the paint for ALL series does in fact work (it was * broken at one point). */ public void testSetItemLabelPaint() { BarRenderer r = new BarRenderer(); r.setItemLabelPaint(Color.green); assertEquals(Color.green, r.getItemLabelPaint(0, 0)); } /** * Test that setting the positive item label position for ALL series does * in fact work. */ public void testSetPositiveItemLabelPosition() { BarRenderer r = new BarRenderer(); r.setPositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT)); assertEquals(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT), r.getPositiveItemLabelPosition(0, 0)); } /** * Test that setting the negative item label position for ALL series does * in fact work. */ public void testSetNegativeItemLabelPosition() { BarRenderer r = new BarRenderer(); r.setNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT)); assertEquals(new ItemLabelPosition( ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT), r.getNegativeItemLabelPosition(0, 0)); } /** * Tests each setter method to ensure that it sends an event notification. */ public void testEventNotification() { RendererChangeDetector detector = new RendererChangeDetector(); BarRenderer r1 = new BarRenderer(); // have to use a subclass of // AbstractRenderer r1.addChangeListener(detector); // PAINT detector.setNotified(false); r1.setPaint(Color.red); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesPaint(0, Color.red); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBasePaint(Color.red); assertTrue(detector.getNotified()); // OUTLINE PAINT detector.setNotified(false); r1.setOutlinePaint(Color.red); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesOutlinePaint(0, Color.red); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseOutlinePaint(Color.red); assertTrue(detector.getNotified()); // STROKE detector.setNotified(false); r1.setStroke(new BasicStroke(1.0f)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesStroke(0, new BasicStroke(1.0f)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseStroke(new BasicStroke(1.0f)); assertTrue(detector.getNotified()); // OUTLINE STROKE detector.setNotified(false); r1.setOutlineStroke(new BasicStroke(1.0f)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseOutlineStroke(new BasicStroke(1.0f)); assertTrue(detector.getNotified()); // SHAPE detector.setNotified(false); r1.setShape(new Rectangle2D.Float()); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesShape(0, new Rectangle2D.Float()); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseShape(new Rectangle2D.Float()); assertTrue(detector.getNotified()); // ITEM_LABELS_VISIBLE detector.setNotified(false); r1.setItemLabelsVisible(Boolean.TRUE); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesItemLabelsVisible(0, Boolean.TRUE); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseItemLabelsVisible(Boolean.TRUE); assertTrue(detector.getNotified()); // ITEM_LABEL_FONT detector.setNotified(false); r1.setItemLabelFont(new Font("Serif", Font.PLAIN, 12)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 12)); assertTrue(detector.getNotified()); // ITEM_LABEL_PAINT detector.setNotified(false); r1.setItemLabelPaint(Color.blue); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesItemLabelPaint(0, Color.blue); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseItemLabelPaint(Color.blue); assertTrue(detector.getNotified()); // POSITIVE ITEM LABEL POSITION detector.setNotified(false); r1.setPositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); assertTrue(detector.getNotified()); // NEGATIVE ITEM LABEL ANCHOR detector.setNotified(false); r1.setNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER) ); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); assertTrue(detector.getNotified()); detector.setNotified(false); r1.setBaseNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); assertTrue(detector.getNotified()); } /** * Serialize an instance, restore it, and check for equality. In addition, * test for a bug that was reported where the listener list is 'null' after * deserialization. */ public void testSerialization() { BarRenderer r1 = new BarRenderer(); r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 4)); r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); r1.setBaseLegendShape(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); BarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (BarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); try { r2.notifyListeners(new RendererChangeEvent(r2)); } catch (NullPointerException e) { assertTrue(false); // failed } } /** * Some checks for the autoPopulate flag default values. */ public void testAutoPopulateFlagDefaults() { BarRenderer r = new BarRenderer(); assertEquals(true, r.getAutoPopulateSeriesPaint()); assertEquals(false, r.getAutoPopulateSeriesFillPaint()); assertEquals(false, r.getAutoPopulateSeriesOutlinePaint()); assertEquals(true, r.getAutoPopulateSeriesStroke()); assertEquals(false, r.getAutoPopulateSeriesOutlineStroke()); assertEquals(true, r.getAutoPopulateSeriesShape()); } /** * Some checks for the paint lookup mechanism. */ public void testPaintLookup() { BarRenderer r = new BarRenderer(); assertEquals(Color.blue, r.getBasePaint()); // first check that autoPopulate==false works as expected r.setAutoPopulateSeriesPaint(false); assertEquals(Color.blue, r.lookupSeriesPaint(0)); assertNull(r.getSeriesPaint(0)); // now check autoPopulate==true r.setAutoPopulateSeriesPaint(true); /*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis( "Category"), new NumberAxis("Value"), r); assertEquals(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[0], r.lookupSeriesPaint(0)); assertNotNull(r.getSeriesPaint(0)); } /** * Some checks for the fill paint lookup mechanism. */ public void testFillPaintLookup() { BarRenderer r = new BarRenderer(); assertEquals(Color.white, r.getBaseFillPaint()); // first check that autoPopulate==false works as expected r.setAutoPopulateSeriesFillPaint(false); assertEquals(Color.white, r.lookupSeriesFillPaint(0)); assertNull(r.getSeriesFillPaint(0)); // now check autoPopulate==true r.setAutoPopulateSeriesFillPaint(true); /*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis( "Category"), new NumberAxis("Value"), r); assertEquals(DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE[0], r.lookupSeriesFillPaint(0)); assertNotNull(r.getSeriesFillPaint(0)); } /** * Some checks for the outline paint lookup mechanism. */ public void testOutlinePaintLookup() { BarRenderer r = new BarRenderer(); assertEquals(Color.gray, r.getBaseOutlinePaint()); // first check that autoPopulate==false works as expected r.setAutoPopulateSeriesOutlinePaint(false); assertEquals(Color.gray, r.lookupSeriesOutlinePaint(0)); assertNull(r.getSeriesOutlinePaint(0)); // now check autoPopulate==true r.setAutoPopulateSeriesOutlinePaint(true); /*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis( "Category"), new NumberAxis("Value"), r); assertEquals(DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE[0], r.lookupSeriesOutlinePaint(0)); assertNotNull(r.getSeriesOutlinePaint(0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/AreaRendererEndTypeTests.java0000644000175000017500000000704011173030414032751 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * AreaRendererEndTypeTests.java * ----------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2004 : Version 1 (DG); * */ package org.jfree.chart.renderer.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.AreaRendererEndType; /** * Tests for the {@link AreaRendererEndType} class. */ public class AreaRendererEndTypeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AreaRendererEndTypeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AreaRendererEndTypeTests(String name) { super(name); } /** * A test for the equals() method. */ public void testEquals() { assertEquals(AreaRendererEndType.LEVEL, AreaRendererEndType.LEVEL); assertEquals(AreaRendererEndType.TAPER, AreaRendererEndType.TAPER); assertEquals( AreaRendererEndType.TRUNCATE, AreaRendererEndType.TRUNCATE ); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { AreaRendererEndType t1 = AreaRendererEndType.TAPER; AreaRendererEndType t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); t2 = (AreaRendererEndType) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(t1, t2); boolean same = t1 == t2; assertEquals(true, same); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/DefaultPolarItemRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/DefaultPolarItemRendererTests.ja0000644000175000017500000001124611173030414033465 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * DefaultPolarItemRendererTests.java * ---------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Aug-2006 : Version 1 (DG); * 15-Mar-2007 : Added independence check to testCloning() (DG); * */ package org.jfree.chart.renderer.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.DefaultPolarItemRenderer; /** * Tests for the {@link DefaultPolarItemRenderer} class. */ public class DefaultPolarItemRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultPolarItemRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultPolarItemRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer(); assertEquals(r1, r2); r1.setSeriesFilled(1, true); assertFalse(r1.equals(r2)); r2.setSeriesFilled(1, true); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); DefaultPolarItemRenderer r2 = null; try { r2 = (DefaultPolarItemRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1.setSeriesFilled(1, true); assertFalse(r1.equals(r2)); r2.setSeriesFilled(1, true); assertTrue(r1.equals(r2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); DefaultPolarItemRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (DefaultPolarItemRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java0000644000175000017500000001265211173030414031774 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * GrayPaintScaleTests.java * ------------------------ * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 26-Sep-2007 : Added testConstructor() and testGetPaint() (DG); * 29-Jan-2009 : Extended testEquals() for new alpha field (DG); * */ package org.jfree.chart.renderer.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.GrayPaintScale; /** * Tests for the {@link GrayPaintScale} class. */ public class GrayPaintScaleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GrayPaintScaleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GrayPaintScaleTests(String name) { super(name); } private static final double EPSILON = 0.000000001; /** * Simple check for the default constructor. */ public void testConstructor() { GrayPaintScale gps = new GrayPaintScale(); assertEquals(0.0, gps.getLowerBound(), EPSILON); assertEquals(1.0, gps.getUpperBound(), EPSILON); assertEquals(255, gps.getAlpha()); } /** * Some checks for the getPaint() method. */ public void testGetPaint() { GrayPaintScale gps = new GrayPaintScale(); Color c = (Color) gps.getPaint(0.0); assertTrue(c.equals(Color.black)); c = (Color) gps.getPaint(1.0); assertTrue(c.equals(Color.white)); // check lookup values that are outside the bounds - see bug report // 1767315 c = (Color) gps.getPaint(-0.5); assertTrue(c.equals(Color.black)); c = (Color) gps.getPaint(1.5); assertTrue(c.equals(Color.white)); } /** * A test for the equals() method. */ public void testEquals() { GrayPaintScale g1 = new GrayPaintScale(); GrayPaintScale g2 = new GrayPaintScale(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new GrayPaintScale(0.0, 1.0); g2 = new GrayPaintScale(0.0, 1.0); assertTrue(g1.equals(g2)); g1 = new GrayPaintScale(0.1, 1.0); assertFalse(g1.equals(g2)); g2 = new GrayPaintScale(0.1, 1.0); assertTrue(g1.equals(g2)); g1 = new GrayPaintScale(0.1, 0.9); assertFalse(g1.equals(g2)); g2 = new GrayPaintScale(0.1, 0.9); assertTrue(g1.equals(g2)); g1 = new GrayPaintScale(0.1, 0.9, 128); assertFalse(g1.equals(g2)); g2 = new GrayPaintScale(0.1, 0.9, 128); assertTrue(g1.equals(g2)); } /** * Confirm that cloning works. */ public void testCloning() { GrayPaintScale g1 = new GrayPaintScale(); GrayPaintScale g2 = null; try { g2 = (GrayPaintScale) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GrayPaintScale g1 = new GrayPaintScale(); GrayPaintScale g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (GrayPaintScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java0000644000175000017500000002066411173030414032345 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * LookupPaintScaleTests.java * -------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 31-Jan-2007 : Additional serialization tests (DG); * 07-Mar-2007 : Added new tests (DG); * 09-Mar-2007 : Check independence in testCloning() (DG); * */ package org.jfree.chart.renderer.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.LookupPaintScale; /** * Tests for the {@link LookupPaintScale} class. */ public class LookupPaintScaleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LookupPaintScaleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LookupPaintScaleTests(String name) { super(name); } /** * A test for the equals() method. */ public void testEquals() { LookupPaintScale g1 = new LookupPaintScale(); LookupPaintScale g2 = new LookupPaintScale(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new LookupPaintScale(1.0, 2.0, Color.red); assertFalse(g1.equals(g2)); g2 = new LookupPaintScale(1.0, 2.0, Color.red); assertTrue(g1.equals(g2)); g1.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(g1.equals(g2)); g2.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(g1.equals(g2)); } /** * Confirm that cloning works. */ public void testCloning() { LookupPaintScale g1 = new LookupPaintScale(); LookupPaintScale g2 = null; try { g2 = (LookupPaintScale) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence g1.add(new Double(0.5), Color.red); assertFalse(g1.equals(g2)); g2.add(new Double(0.5), Color.red); assertTrue(g1.equals(g2)); // try with gradient paint g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); g1.add(new Double(1.5), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); g2 = null; try { g2 = (LookupPaintScale) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LookupPaintScale g1 = new LookupPaintScale(); LookupPaintScale g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (LookupPaintScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); g1.add(new Double(1.5), new GradientPaint(1.1f, 2.2f, Color.red, 3.3f, 4.4f, Color.blue)); g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (LookupPaintScale) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } private static final double EPSILON = 0.0000000001; /** * Some checks for the default constructor. */ public void testConstructor1() { LookupPaintScale s = new LookupPaintScale(); assertEquals(0.0, s.getLowerBound(), EPSILON); assertEquals(1.0, s.getUpperBound(), EPSILON); } /** * Some checks for the other constructor. */ public void testConstructor2() { LookupPaintScale s = new LookupPaintScale(1.0, 2.0, Color.red); assertEquals(1.0, s.getLowerBound(), EPSILON); assertEquals(2.0, s.getUpperBound(), EPSILON); assertEquals(Color.red, s.getDefaultPaint()); } /** * Some general checks for the lookup table. */ public void testGeneral() { LookupPaintScale s = new LookupPaintScale(0.0, 100.0, Color.black); assertEquals(Color.black, s.getPaint(-1.0)); assertEquals(Color.black, s.getPaint(0.0)); assertEquals(Color.black, s.getPaint(50.0)); assertEquals(Color.black, s.getPaint(100.0)); assertEquals(Color.black, s.getPaint(101.0)); s.add(new Double(50.0), Color.blue); assertEquals(Color.black, s.getPaint(-1.0)); assertEquals(Color.black, s.getPaint(0.0)); assertEquals(Color.blue, s.getPaint(50.0)); assertEquals(Color.blue, s.getPaint(100.0)); assertEquals(Color.black, s.getPaint(101.0)); s.add(new Double(50.0), Color.red); assertEquals(Color.black, s.getPaint(-1.0)); assertEquals(Color.black, s.getPaint(0.0)); assertEquals(Color.red, s.getPaint(50.0)); assertEquals(Color.red, s.getPaint(100.0)); assertEquals(Color.black, s.getPaint(101.0)); s.add(new Double(25.0), Color.green); assertEquals(Color.black, s.getPaint(-1.0)); assertEquals(Color.black, s.getPaint(0.0)); assertEquals(Color.green, s.getPaint(25.0)); assertEquals(Color.red, s.getPaint(50.0)); assertEquals(Color.red, s.getPaint(100.0)); assertEquals(Color.black, s.getPaint(101.0)); s.add(new Double(75.0), Color.yellow); assertEquals(Color.black, s.getPaint(-1.0)); assertEquals(Color.black, s.getPaint(0.0)); assertEquals(Color.green, s.getPaint(25.0)); assertEquals(Color.red, s.getPaint(50.0)); assertEquals(Color.yellow, s.getPaint(75.0)); assertEquals(Color.yellow, s.getPaint(100.0)); assertEquals(Color.black, s.getPaint(101.0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/OutlierTests.java0000644000175000017500000000726011173030414030550 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * OutlierTests.java * ----------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Nov-2007 : Version 1 (DG); * */ package org.jfree.chart.renderer.junit; import java.awt.geom.Point2D; import java.io.Serializable; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.Outlier; /** * Tests for the {@link Outlier} class. */ public class OutlierTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OutlierTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OutlierTests(String name) { super(name); } private static final double EPSILON = 0.000000001; /** * Simple check for the default constructor. */ public void testConstructor() { Outlier out = new Outlier(1.0, 2.0, 3.0); assertEquals(-2.0, out.getX(), EPSILON); assertEquals(-1.0, out.getY(), EPSILON); assertEquals(3.0, out.getRadius(), EPSILON); } /** * A test for the equals() method. */ public void testEquals() { Outlier out1 = new Outlier(1.0, 2.0, 3.0); Outlier out2 = new Outlier(1.0, 2.0, 3.0); assertTrue(out1.equals(out2)); assertTrue(out2.equals(out1)); out1.setPoint(new Point2D.Double(2.0, 2.0)); assertFalse(out1.equals(out2)); out2.setPoint(new Point2D.Double(2.0, 2.0)); assertTrue(out1.equals(out2)); out1.setPoint(new Point2D.Double(2.0, 3.0)); assertFalse(out1.equals(out2)); out2.setPoint(new Point2D.Double(2.0, 3.0)); assertTrue(out1.equals(out2)); out1.setRadius(4.0); assertFalse(out1.equals(out2)); out2.setRadius(4.0); assertTrue(out1.equals(out2)); } /** * Confirm that cloning is not implemented. */ public void testCloning() { Outlier out1 = new Outlier(1.0, 2.0, 3.0); assertFalse(out1 instanceof Cloneable); } /** * Confirm that serialization is not implemented. */ public void testSerialization() { Outlier out1 = new Outlier(1.0, 2.0, 3.0); assertFalse(out1 instanceof Serializable); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/RendererChangeDetector.java0000644000175000017500000000533511173030414032451 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * RendererChangeDetector.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Oct-2003 : Version 1 (DG); * */ package org.jfree.chart.renderer.junit; import org.jfree.chart.event.RendererChangeEvent; import org.jfree.chart.event.RendererChangeListener; /** * A simple class for detecting whether or not a renderer has generated * a {@link RendererChangeEvent}. */ public class RendererChangeDetector implements RendererChangeListener { /** A flag that records whether or not a change event has been received. */ private boolean notified; /** * Creates a new detector. */ public RendererChangeDetector() { this.notified = false; } /** * Returns the flag that indicates whether or not a change event has been * received. * * @return The flag. */ public boolean getNotified() { return this.notified; } /** * Sets the flag that indicates whether or not a change event has been * received. * * @param notified the new value of the flag. */ public void setNotified(boolean notified) { this.notified = notified; } /** * Receives a {@link RendererChangeEvent} from a renderer. * * @param event the event. */ public void rendererChanged(RendererChangeEvent event) { this.notified = true; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/RendererPackageTests.java0000644000175000017500000000554611173030414032154 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * RendererPackageTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 21-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added BoxAndWhiskerRendererTests (DG); * 04-Aug-2006 : Added DefaultPolarItemRendererTests (DG); * 31-Jan-2007 : Added GrayPaintScaleTests and LookupPaintScaleTests (DG); * 21-Nov-2007 : Added OutlierTests and missing RendererUtilitiesTests (DG); * */ package org.jfree.chart.renderer.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.renderer package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class RendererPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.renderer"); suite.addTestSuite(AbstractRendererTests.class); suite.addTestSuite(AreaRendererEndTypeTests.class); suite.addTestSuite(DefaultPolarItemRendererTests.class); suite.addTestSuite(GrayPaintScaleTests.class); suite.addTestSuite(LookupPaintScaleTests.class); suite.addTestSuite(OutlierTests.class); suite.addTestSuite(RendererUtilitiesTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public RendererPackageTests(String name) { super(name); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/RendererUtilitiesTests.java0000644000175000017500000004770611173030414032600 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * RendererUtilitiesTests.java * --------------------------- * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Apr-2007 : Version 1 (DG); * */ package org.jfree.chart.renderer.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.RendererUtilities; import org.jfree.data.DomainOrder; import org.jfree.data.xy.DefaultXYDataset; /** * Some checks for the {@link RendererUtilities} class. */ public class RendererUtilitiesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RendererUtilitiesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RendererUtilitiesTests(String name) { super(name); } /** * Some checks for the findLiveItemsLowerBound() method when the dataset is * unordered. */ public void testFindLiveItemsLowerBound_Unordered() { DefaultXYDataset d = new DefaultXYDataset(); // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{0.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, 3.3)); // check a series with two items d.addSeries("S3", new double[][] {{0.0, 1.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, 5.5)); } /** * Some checks for the findLiveItemsLowerBound() method when the dataset is * ASCENDING. */ public void testFindLiveItemsLowerBound_Ascending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in ascending order by x-value return DomainOrder.ASCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.1)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, 2.2)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, 5.5)); // check a series with repeating items d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 4.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 4.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.0)); } /** * Some checks for the findLiveItemsLowerBound() method when the dataset is * DESCENDING. */ public void testFindLiveItemsLowerBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 3.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 1.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 0.5)); } /** * Some checks for the findLiveItemsUpperBound() method when the dataset is * unordered. */ public void testFindLiveItemsUpperBound_Unordered() { DefaultXYDataset d = new DefaultXYDataset(); // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 3.3)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5)); } /** * Some checks for the findLiveItemsUpperBound() method when the dataset is * ASCENDING. */ public void testFindLiveItemsUpperBound_Ascending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in ascending order by x-value return DomainOrder.ASCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.1)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 2.2)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5)); // check a series with repeating items d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.0)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 3.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 4.0)); } /** * Some checks for the findLiveItemsUpperBound() method when the dataset is * DESCENDING. */ public void testFindLiveItemsUpperBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 0.0, 5.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 1.0, 5.0)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 5, 2.0, 5.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 5, 3.0, 5.0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/junit/package.html0000644000175000017500000000016311173030414027513 0ustar vincentvincent JUnit tests. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/0000755000175000017500000000000011173030414024541 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/0000755000175000017500000000000011216245562025704 5ustar vincentvincent././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/AbstractXYItemRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/AbstractXYItemRendererTests.j0000644000175000017500000001440711173030414033430 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * AbstractXYItemRendererTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Oct-2004 : Version 1 (DG); * 24-Nov-2006 : Added cloning tests (DG); * */ package org.jfree.chart.renderer.xy.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; import org.jfree.chart.renderer.xy.AbstractXYItemRenderer; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Tests for the {@link AbstractXYItemRenderer} class. */ public class AbstractXYItemRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(AbstractXYItemRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public AbstractXYItemRendererTests(String name) { super(name); } /** * Creates a test dataset. * * @return A test dataset. */ private XYDataset createDataset1() { XYSeries series = new XYSeries("Series"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); return dataset; } private static final double EPSILON = 0.0000000001; /** * Some checks for the findDomainBounds() method. */ public void testFindDomainBounds() { AbstractXYItemRenderer renderer = new StandardXYItemRenderer(); // check the bounds of a simple dataset XYDataset dataset = createDataset1(); Range r = renderer.findDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); // check that a null dataset returns null bounds assertTrue(renderer.findDomainBounds(null) == null); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { AbstractXYItemRenderer renderer = new StandardXYItemRenderer(); // check that a null dataset returns null bounds assertTrue(renderer.findRangeBounds(null) == null); } /** * Check that the legendItemLabelGenerator is cloned. */ public void testCloning_LegendItemLabelGenerator() { StandardXYSeriesLabelGenerator generator = new StandardXYSeriesLabelGenerator("Series {0}"); XYBarRenderer r1 = new XYBarRenderer(); r1.setLegendItemLabelGenerator(generator); XYBarRenderer r2 = null; try { r2 = (XYBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemLabelGenerator() != r2.getLegendItemLabelGenerator()); } /** * Check that the legendItemToolTipGenerator is cloned. */ public void testCloning_LegendItemToolTipGenerator() { StandardXYSeriesLabelGenerator generator = new StandardXYSeriesLabelGenerator("Series {0}"); XYBarRenderer r1 = new XYBarRenderer(); r1.setLegendItemToolTipGenerator(generator); XYBarRenderer r2 = null; try { r2 = (XYBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemToolTipGenerator() != r2.getLegendItemToolTipGenerator()); } /** * Check that the legendItemURLGenerator is cloned. */ public void testCloning_LegendItemURLGenerator() { StandardXYSeriesLabelGenerator generator = new StandardXYSeriesLabelGenerator("Series {0}"); XYBarRenderer r1 = new XYBarRenderer(); r1.setLegendItemURLGenerator(generator); XYBarRenderer r2 = null; try { r2 = (XYBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the generator has been cloned assertTrue(r1.getLegendItemURLGenerator() != r2.getLegendItemURLGenerator()); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java0000644000175000017500000002121411173030414033473 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * CandlestickRendererTests.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 17-Aug-2006 : Strengthened testEquals() and added testFindRangeBounds() * method (DG); * 05-Mar-2007 : Added new field to testEquals() (DG); * 08-Oct-2007 : Added tests for new volumePaint field (DG); * 22-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.CandlestickRenderer; import org.jfree.data.Range; import org.jfree.data.xy.DefaultOHLCDataset; import org.jfree.data.xy.OHLCDataItem; import org.jfree.data.xy.OHLCDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CandlestickRenderer} class. */ public class CandlestickRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CandlestickRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CandlestickRendererTests(String name) { super(name); } private static final double EPSILON = 0.0000000001; /** * Some checks for the constructor. */ public void testConstructor() { CandlestickRenderer r1 = new CandlestickRenderer(); // check defaults assertEquals(Color.green, r1.getUpPaint()); assertEquals(Color.red, r1.getDownPaint()); assertFalse(r1.getUseOutlinePaint()); assertTrue(r1.getDrawVolume()); assertEquals(Color.gray, r1.getVolumePaint()); assertEquals(-1.0, r1.getCandleWidth(), EPSILON); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = new CandlestickRenderer(); assertEquals(r1, r2); // upPaint r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertFalse(r1.equals(r2)); r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); assertTrue(r1.equals(r2)); // downPaint r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, Color.yellow)); assertFalse(r1.equals(r2)); r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, Color.yellow)); assertTrue(r1.equals(r2)); // drawVolume r1.setDrawVolume(false); assertFalse(r1.equals(r2)); r2.setDrawVolume(false); assertTrue(r1.equals(r2)); // candleWidth r1.setCandleWidth(3.3); assertFalse(r1.equals(r2)); r2.setCandleWidth(3.3); assertTrue(r1.equals(r2)); // maxCandleWidthInMilliseconds r1.setMaxCandleWidthInMilliseconds(123); assertFalse(r1.equals(r2)); r2.setMaxCandleWidthInMilliseconds(123); assertTrue(r1.equals(r2)); // autoWidthMethod r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); assertFalse(r1.equals(r2)); r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); assertTrue(r1.equals(r2)); // autoWidthFactor r1.setAutoWidthFactor(0.22); assertFalse(r1.equals(r2)); r2.setAutoWidthFactor(0.22); assertTrue(r1.equals(r2)); // autoWidthGap r1.setAutoWidthGap(1.1); assertFalse(r1.equals(r2)); r2.setAutoWidthGap(1.1); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(true); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(true); assertTrue(r1.equals(r2)); r1.setVolumePaint(Color.blue); assertFalse(r1.equals(r2)); r2.setVolumePaint(Color.blue); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = new CandlestickRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = null; try { r2 = (CandlestickRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { CandlestickRenderer r1 = new CandlestickRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CandlestickRenderer r1 = new CandlestickRenderer(); CandlestickRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (CandlestickRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { CandlestickRenderer renderer = new CandlestickRenderer(); OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 2.0, 4.0, 1.0, 3.0, 100); OHLCDataset dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1}); Range range = renderer.findRangeBounds(dataset); assertEquals(new Range(1.0, 4.0), range); OHLCDataItem item2 = new OHLCDataItem(new Date(1L), -1.0, 3.0, -1.0, 3.0, 100); dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1, item2}); range = renderer.findRangeBounds(dataset); assertEquals(new Range(-1.0, 4.0), range); // try an empty dataset - should return a null range dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {}); range = renderer.findRangeBounds(dataset); assertNull(range); // try a null dataset - should return a null range range = renderer.findRangeBounds(null); assertNull(range); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/ClusteredXYBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/ClusteredXYBarRendererTests.j0000644000175000017500000001644711173030414033433 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * ClusteredXYBarRendererTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 10-Jul-2007 : Fixed compile errors (DG); * 22-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.AbstractXYItemRenderer; import org.jfree.chart.renderer.xy.ClusteredXYBarRenderer; import org.jfree.data.Range; import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link ClusteredXYBarRenderer} class. */ public class ClusteredXYBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ClusteredXYBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ClusteredXYBarRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); ClusteredXYBarRenderer r2 = new ClusteredXYBarRenderer(); assertEquals(r1, r2); assertEquals(r2, r1); r1 = new ClusteredXYBarRenderer(1.2, false); assertFalse(r1.equals(r2)); r2 = new ClusteredXYBarRenderer(1.2, false); assertTrue(r1.equals(r2)); r1 = new ClusteredXYBarRenderer(1.2, true); assertFalse(r1.equals(r2)); r2 = new ClusteredXYBarRenderer(1.2, true); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); ClusteredXYBarRenderer r2 = new ClusteredXYBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); ClusteredXYBarRenderer r2 = null; try { r2 = (ClusteredXYBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); ClusteredXYBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (ClusteredXYBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } private static final double EPSILON = 0.0000000001; /** * Some checks for the findDomainBounds() method (which requires special * handling when the centerBarAtStartValue flag is set to true). */ public void testFindDomainBounds() { AbstractXYItemRenderer renderer = new ClusteredXYBarRenderer(); XYDataset dataset = createSampleDataset1(); Range r = renderer.findDomainBounds(dataset); assertEquals(0.9, r.getLowerBound(), EPSILON); assertEquals(13.1, r.getUpperBound(), EPSILON); renderer = new ClusteredXYBarRenderer(0.0, true); r = renderer.findDomainBounds(dataset); assertEquals(0.8, r.getLowerBound(), EPSILON); assertEquals(13.0, r.getUpperBound(), EPSILON); // check that a null dataset returns null bounds assertTrue(renderer.findDomainBounds(null) == null); } /** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultIntervalXYDataset createSampleDataset1() { DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] x1Start = new double[] {0.9, 1.9, 2.9}; double[] x1End = new double[] {1.1, 2.1, 3.1}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; d.addSeries("S1", data1); double[] x2 = new double[] {11.0, 12.0, 13.0}; double[] x2Start = new double[] {10.9, 11.9, 12.9}; double[] x2End = new double[] {11.1, 12.1, 13.1}; double[] y2 = new double[] {14.0, 15.0, 16.0}; double[] y2Start = new double[] {11.09, 12.09, 13.09}; double[] y2End = new double[] {11.11, 12.11, 13.11}; double[][] data2 = new double[][] {x2, x2Start, x2End, y2, y2Start, y2End}; d.addSeries("S2", data2); return d; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/DeviationRendererTests.java0000644000175000017500000001131211173030414033167 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * DeviationRendererTests.java * --------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Feb-2007 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.DeviationRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link DeviationRenderer} class. */ public class DeviationRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DeviationRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DeviationRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances DeviationRenderer r1 = new DeviationRenderer(); DeviationRenderer r2 = new DeviationRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setAlpha(0.1f); assertFalse(r1.equals(r2)); r2.setAlpha(0.1f); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { DeviationRenderer r1 = new DeviationRenderer(); DeviationRenderer r2 = new DeviationRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DeviationRenderer r1 = new DeviationRenderer(); DeviationRenderer r2 = null; try { r2 = (DeviationRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DeviationRenderer r1 = new DeviationRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DeviationRenderer r1 = new DeviationRenderer(); DeviationRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (DeviationRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/GradientXYBarPainterTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/GradientXYBarPainterTests.jav0000644000175000017500000001136111173030414033407 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * GradientXYBarPainterTests.java * ------------------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.GradientXYBarPainter; import org.jfree.util.PublicCloneable; /** * Tests for the {@link GradientXYBarPainter} class. */ public class GradientXYBarPainterTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GradientXYBarPainterTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GradientXYBarPainterTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); GradientXYBarPainter p2 = new GradientXYBarPainter(0.1, 0.2, 0.3); assertEquals(p1, p2); p1 = new GradientXYBarPainter(0.11, 0.2, 0.3); assertFalse(p1.equals(p2)); p2 = new GradientXYBarPainter(0.11, 0.2, 0.3); assertTrue(p1.equals(p2)); p1 = new GradientXYBarPainter(0.11, 0.22, 0.3); assertFalse(p1.equals(p2)); p2 = new GradientXYBarPainter(0.11, 0.22, 0.3); assertTrue(p1.equals(p2)); p1 = new GradientXYBarPainter(0.11, 0.22, 0.33); assertFalse(p1.equals(p2)); p2 = new GradientXYBarPainter(0.11, 0.22, 0.33); assertTrue(p1.equals(p2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); GradientXYBarPainter p2 = new GradientXYBarPainter(0.1, 0.2, 0.3); assertTrue(p1.equals(p2)); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning isn't implemented (it isn't required, because * instances of the class are immutable). */ public void testCloning() { GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); assertFalse(p1 instanceof Cloneable); assertFalse(p1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); GradientXYBarPainter p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (GradientXYBarPainter) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/HighLowRendererTests.java0000644000175000017500000001555411173030414032622 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * HighLowRendererTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 01-Nov-2005 : Added tests for new fields (DG); * 17-Aug-2006 : Added testFindRangeBounds() method (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * 29-Apr-2008 : Extended testEquals() for new field (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.HighLowRenderer; import org.jfree.data.Range; import org.jfree.data.xy.DefaultOHLCDataset; import org.jfree.data.xy.OHLCDataItem; import org.jfree.data.xy.OHLCDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link HighLowRenderer} class. */ public class HighLowRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(HighLowRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public HighLowRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { HighLowRenderer r1 = new HighLowRenderer(); HighLowRenderer r2 = new HighLowRenderer(); assertEquals(r1, r2); // drawOpenTicks r1.setDrawOpenTicks(false); assertFalse(r1.equals(r2)); r2.setDrawOpenTicks(false); assertTrue(r1.equals(r2)); // drawCloseTicks r1.setDrawCloseTicks(false); assertFalse(r1.equals(r2)); r2.setDrawCloseTicks(false); assertTrue(r1.equals(r2)); // openTickPaint r1.setOpenTickPaint(Color.red); assertFalse(r1.equals(r2)); r2.setOpenTickPaint(Color.red); assertTrue(r1.equals(r2)); // closeTickPaint r1.setCloseTickPaint(Color.blue); assertFalse(r1.equals(r2)); r2.setCloseTickPaint(Color.blue); assertTrue(r1.equals(r2)); // tickLength r1.setTickLength(99.9); assertFalse(r1.equals(r2)); r2.setTickLength(99.9); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { HighLowRenderer r1 = new HighLowRenderer(); HighLowRenderer r2 = new HighLowRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { HighLowRenderer r1 = new HighLowRenderer(); r1.setCloseTickPaint(Color.green); HighLowRenderer r2 = null; try { r2 = (HighLowRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { HighLowRenderer r1 = new HighLowRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { HighLowRenderer r1 = new HighLowRenderer(); r1.setCloseTickPaint(Color.green); HighLowRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (HighLowRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Some checks for the findRangeBounds() method. */ public void testFindRangeBounds() { HighLowRenderer renderer = new HighLowRenderer(); OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 2.0, 4.0, 1.0, 3.0, 100); OHLCDataset dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1}); Range range = renderer.findRangeBounds(dataset); assertEquals(new Range(1.0, 4.0), range); OHLCDataItem item2 = new OHLCDataItem(new Date(1L), -1.0, 3.0, -1.0, 3.0, 100); dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1, item2}); range = renderer.findRangeBounds(dataset); assertEquals(new Range(-1.0, 4.0), range); // try an empty dataset - should return a null range dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {}); range = renderer.findRangeBounds(dataset); assertNull(range); // try a null dataset - should return a null range range = renderer.findRangeBounds(null); assertNull(range); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java0000644000175000017500000001375411173030414033075 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * RendererXYPackageTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 23-Aug-2004 : Restructured org.jfree.chart.renderer package (DG); * 06-Jan-2005 : Added method to create test dataset (DG); * 07-Jan-2005 : Added a second method to create a test dataset (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 25-Oct-2006 : Added tests for XYErrorRenderer class (DG); * 31-Jan-2007 : Added XYBlockRendererTests (DG); * 26-Feb-2007 : Added DeviationRendererTests (DG); * 30-Apr-2007 : Added XYLine3DRendererTests (DG); * 25-May-2007 : Added VectorRendererTests (DG); * 25-Jul-2007 : Added XYSplineAndRendererTests (DG); * */ package org.jfree.chart.renderer.xy.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * A collection of tests for the org.jfree.chart.renderer.xy package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class RendererXYPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.renderer.xy"); suite.addTestSuite(AbstractXYItemRendererTests.class); suite.addTestSuite(CandlestickRendererTests.class); suite.addTestSuite(ClusteredXYBarRendererTests.class); suite.addTestSuite(DeviationRendererTests.class); suite.addTestSuite(GradientXYBarPainterTests.class); suite.addTestSuite(HighLowRendererTests.class); suite.addTestSuite(StackedXYAreaRendererTests.class); suite.addTestSuite(StackedXYAreaRenderer2Tests.class); suite.addTestSuite(StackedXYBarRendererTests.class); suite.addTestSuite(StandardXYBarPainterTests.class); suite.addTestSuite(StandardXYItemRendererTests.class); suite.addTestSuite(VectorRendererTests.class); suite.addTestSuite(WindItemRendererTests.class); suite.addTestSuite(XYAreaRendererTests.class); suite.addTestSuite(XYAreaRenderer2Tests.class); suite.addTestSuite(XYBarRendererTests.class); suite.addTestSuite(XYBlockRendererTests.class); suite.addTestSuite(XYBoxAndWhiskerRendererTests.class); suite.addTestSuite(XYBubbleRendererTests.class); suite.addTestSuite(XYDifferenceRendererTests.class); suite.addTestSuite(XYDotRendererTests.class); suite.addTestSuite(XYErrorRendererTests.class); suite.addTestSuite(XYLineAndShapeRendererTests.class); suite.addTestSuite(XYLine3DRendererTests.class); suite.addTestSuite(XYShapeRendererTests.class); suite.addTestSuite(XYSplineRendererTests.class); suite.addTestSuite(XYStepRendererTests.class); suite.addTestSuite(XYStepAreaRendererTests.class); suite.addTestSuite(YIntervalRendererTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public RendererXYPackageTests(String name) { super(name); } /** * Creates and returns a sample dataset for testing purposes. * * @return A sample dataset. */ public static XYSeriesCollection createTestXYSeriesCollection() { XYSeriesCollection result = new XYSeriesCollection(); XYSeries series1 = new XYSeries("Series 1", false, false); series1.add(1.0, 2.0); series1.add(2.0, 5.0); XYSeries series2 = new XYSeries("Series 2", false, false); series2.add(1.0, 4.0); series2.add(2.0, 3.0); result.addSeries(series1); result.addSeries(series2); return result; } /** * Creates and returns a sample dataset for testing purposes. * * @return A sample dataset. */ public static TableXYDataset createTestTableXYDataset() { DefaultTableXYDataset result = new DefaultTableXYDataset(); XYSeries series1 = new XYSeries("Series 1", false, false); series1.add(1.0, 2.0); series1.add(2.0, 5.0); XYSeries series2 = new XYSeries("Series 2", false, false); series2.add(1.0, 4.0); series2.add(2.0, 3.0); result.addSeries(series1); result.addSeries(series2); return result; } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRenderer2Tests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRenderer2Tests.j0000644000175000017500000001624611173030414033302 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * StackedXYAreaRenderer2Tests.java * ------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jan-2005 : Version 1 (DG); * 22-Aug-2006 : Added testDrawWithEmptyDataset() method (DG); * 30-Nov-2006 : Extended testEquals() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; import org.jfree.data.Range; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StackedXYAreaRenderer2} class. */ public class StackedXYAreaRenderer2Tests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedXYAreaRenderer2Tests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedXYAreaRenderer2Tests(String name) { super(name); } /** * Test chart drawing with an empty dataset to ensure that this special * case doesn't cause any exceptions. */ public void testDrawWithEmptyDataset() { boolean success = false; JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x", "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StackedXYAreaRenderer2()); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2(); assertEquals(r1, r2); assertEquals(r2, r1); r1.setRoundXCoordinates(!r1.getRoundXCoordinates()); assertFalse(r1.equals(r2)); r2.setRoundXCoordinates(r1.getRoundXCoordinates()); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); StackedXYAreaRenderer2 r2 = null; try { r2 = (StackedXYAreaRenderer2) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); StackedXYAreaRenderer2 r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedXYAreaRenderer2) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Check that the renderer is calculating the range bounds correctly. */ public void testFindRangeBounds() { TableXYDataset dataset = RendererXYPackageTests.createTestTableXYDataset(); JFreeChart chart = ChartFactory.createStackedXYAreaChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); Range bounds = rangeAxis.getRange(); assertTrue(bounds.contains(6.0)); assertTrue(bounds.contains(8.0)); // try null argument assertNull(renderer.findRangeBounds(null)); // try empty dataset assertNull(renderer.findRangeBounds(new DefaultTableXYDataset())); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.ja0000644000175000017500000002175611173030414033363 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * StackedXYAreaRendererTests.java * ------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 06-Jan-2005 : Renamed StackedAreaXYRendererTests --> * StackedXYAreaRendererTests, improved testEquals() method, * added check for auto range calculation (DG); * 10-Nov-2006 : Added testBug1593156() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StackedXYAreaRenderer; import org.jfree.chart.renderer.xy.XYAreaRenderer; import org.jfree.data.Range; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StackedXYAreaRenderer} class. */ public class StackedXYAreaRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedXYAreaRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedXYAreaRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); StackedXYAreaRenderer r2 = new StackedXYAreaRenderer(); assertEquals(r1, r2); assertEquals(r2, r1); r1.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertFalse(r1.equals(r2)); r2.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertTrue(r1.equals(r2)); Stroke s = new BasicStroke(1.23f); r1.setShapeStroke(s); assertFalse(r1.equals(r2)); r2.setShapeStroke(s); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); StackedXYAreaRenderer r2 = new StackedXYAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); StackedXYAreaRenderer r2 = null; try { r2 = (StackedXYAreaRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); r1.setShapePaint(Color.red); r1.setShapeStroke(new BasicStroke(1.23f)); StackedXYAreaRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedXYAreaRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Check that the renderer is calculating the range bounds correctly. */ public void testFindRangeBounds() { TableXYDataset dataset = RendererXYPackageTests.createTestTableXYDataset(); JFreeChart chart = ChartFactory.createStackedXYAreaChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); Range bounds = rangeAxis.getRange(); assertTrue(bounds.contains(6.0)); assertTrue(bounds.contains(8.0)); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new StackedXYAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A test for bug 1593156. */ public void testBug1593156() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); StackedXYAreaRenderer renderer = new StackedXYAreaRenderer( XYAreaRenderer.LINES); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), renderer); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StackedXYBarRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StackedXYBarRendererTests.jav0000644000175000017500000001567311173030414033406 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * StackedXYBarRendererTests.java * ------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Sep-2004 : Version 1 (DG); * 06-Jan-2005 : Added test for auto range calculation (DG); * 06-Dec-2006 : Confirm serialization of GradientPaint (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StackedXYBarRenderer; import org.jfree.data.Range; import org.jfree.data.xy.TableXYDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StackedXYBarRenderer} class. */ public class StackedXYBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StackedXYBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StackedXYBarRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = new StackedXYBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setRenderAsPercentages(true); assertFalse(r1.equals(r2)); r2.setRenderAsPercentages(true); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = new StackedXYBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); r1.setRenderAsPercentages(true); h1 = r1.hashCode(); h2 = r2.hashCode(); assertFalse(h1 == h2); } /** * Confirm that cloning works. */ public void testCloning() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = null; try { r2 = (StackedXYBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); r1.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); StackedXYBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedXYBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Check that the renderer is calculating the domain bounds correctly. */ public void testFindDomainBounds() { TableXYDataset dataset = RendererXYPackageTests.createTestTableXYDataset(); JFreeChart chart = ChartFactory.createStackedXYAreaChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StackedXYBarRenderer()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); Range bounds = domainAxis.getRange(); assertFalse(bounds.contains(0.3)); assertTrue(bounds.contains(0.5)); assertTrue(bounds.contains(2.5)); assertFalse(bounds.contains(2.8)); } /** * Check that the renderer is calculating the range bounds correctly. */ public void testFindRangeBounds() { TableXYDataset dataset = RendererXYPackageTests.createTestTableXYDataset(); JFreeChart chart = ChartFactory.createStackedXYAreaChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StackedXYBarRenderer()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); Range bounds = rangeAxis.getRange(); assertTrue(bounds.contains(6.0)); assertTrue(bounds.contains(8.0)); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StandardXYBarPainterTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StandardXYBarPainterTests.jav0000644000175000017500000001017311173030414033412 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * StandardXYBarPainterTests.java * ------------------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Jun-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.StandardXYBarPainter; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardXYBarPainter} class. */ public class StandardXYBarPainterTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYBarPainterTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYBarPainterTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StandardXYBarPainter p1 = new StandardXYBarPainter(); StandardXYBarPainter p2 = new StandardXYBarPainter(); assertEquals(p1, p2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StandardXYBarPainter p1 = new StandardXYBarPainter(); StandardXYBarPainter p2 = new StandardXYBarPainter(); assertTrue(p1.equals(p2)); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning isn't implemented (it isn't required, because * instances of the class are immutable). */ public void testCloning() { StandardXYBarPainter p1 = new StandardXYBarPainter(); assertFalse(p1 instanceof Cloneable); assertFalse(p1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYBarPainter p1 = new StandardXYBarPainter(); StandardXYBarPainter p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (StandardXYBarPainter) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.j0000644000175000017500000002413211173030414033421 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * StandardXYItemRendererTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 08-Oct-2004 : Strengthened test for equals() method (DG); * 14-Mar-2007 : Added new checks in testEquals() and testCloning() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 08-Jun-2007 : Added testNoDisplayedItem() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Graphics2D; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.XYItemEntity; import org.jfree.chart.junit.TestUtilities; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; import org.jfree.util.UnitType; /** * Tests for the {@link StandardXYItemRenderer} class. */ public class StandardXYItemRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYItemRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYItemRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StandardXYItemRenderer r1 = new StandardXYItemRenderer(); StandardXYItemRenderer r2 = new StandardXYItemRenderer(); assertEquals(r1, r2); r1.setBaseShapesVisible(true); assertFalse(r1.equals(r2)); r2.setBaseShapesVisible(true); assertTrue(r1.equals(r2)); r1.setPlotLines(false); assertFalse(r1.equals(r2)); r2.setPlotLines(false); assertTrue(r1.equals(r2)); r1.setPlotImages(true); assertFalse(r1.equals(r2)); r2.setPlotImages(true); assertTrue(r1.equals(r2)); r1.setPlotDiscontinuous(true); assertFalse(r1.equals(r2)); r2.setPlotDiscontinuous(true); assertTrue(r1.equals(r2)); r1.setGapThresholdType(UnitType.ABSOLUTE); assertFalse(r1.equals(r2)); r2.setGapThresholdType(UnitType.ABSOLUTE); assertTrue(r1.equals(r2)); r1.setGapThreshold(1.23); assertFalse(r1.equals(r2)); r2.setGapThreshold(1.23); assertTrue(r1.equals(r2)); r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); r1.setShapesFilled(false); assertFalse(r1.equals(r2)); r2.setShapesFilled(false); assertTrue(r1.equals(r2)); r1.setSeriesShapesFilled(1, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesShapesFilled(1, Boolean.TRUE); assertTrue(r1.equals(r2)); r1.setBaseShapesFilled(false); assertFalse(r1.equals(r2)); r2.setBaseShapesFilled(false); assertTrue(r1.equals(r2)); r1.setDrawSeriesLineAsPath(true); assertFalse(r1.equals(r2)); r2.setDrawSeriesLineAsPath(true); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StandardXYItemRenderer r1 = new StandardXYItemRenderer(); StandardXYItemRenderer r2 = new StandardXYItemRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StandardXYItemRenderer r1 = new StandardXYItemRenderer(); Rectangle2D rect1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); r1.setLegendLine(rect1); StandardXYItemRenderer r2 = null; try { r2 = (StandardXYItemRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence rect1.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setLegendLine(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); r1.setSeriesShapesFilled(1, Boolean.TRUE); assertFalse(r1.equals(r2)); r2.setSeriesShapesFilled(1, Boolean.TRUE); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { StandardXYItemRenderer r1 = new StandardXYItemRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYItemRenderer r1 = new StandardXYItemRenderer(); StandardXYItemRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StandardXYItemRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); StandardXYItemRenderer r = new StandardXYItemRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } /** * A check to ensure that an item that falls outside the plot's data area * does NOT generate an item entity. */ public void testNoDisplayedItem() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(10.0, 10.0); dataset.addSeries(s1); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StandardXYItemRenderer()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setRange(0.0, 5.0); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setRange(0.0, 5.0); BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); ChartRenderingInfo info = new ChartRenderingInfo(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info); g2.dispose(); EntityCollection ec = info.getEntityCollection(); assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), XYItemEntity.class)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/VectorRendererTests.java0000644000175000017500000001132611173030414032514 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * VectorRendererTests.java * ------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.VectorRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link VectorRenderer} class. */ public class VectorRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(VectorRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public VectorRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances VectorRenderer r1 = new VectorRenderer(); VectorRenderer r2 = new VectorRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // check that super class fields are being looked at... r1.setSeriesFillPaint(0, Color.green); assertFalse(r1.equals(r2)); r2.setSeriesFillPaint(0, Color.green); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { VectorRenderer r1 = new VectorRenderer(); VectorRenderer r2 = new VectorRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { VectorRenderer r1 = new VectorRenderer(); VectorRenderer r2 = null; try { r2 = (VectorRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { VectorRenderer r1 = new VectorRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { VectorRenderer r1 = new VectorRenderer(); VectorRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (VectorRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/WindItemRendererTests.java0000644000175000017500000001075311173030414032775 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * WindItemRendererTests.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.WindItemRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link WindItemRenderer} class. */ public class WindItemRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(WindItemRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public WindItemRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { WindItemRenderer r1 = new WindItemRenderer(); WindItemRenderer r2 = new WindItemRenderer(); assertEquals(r1, r2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { WindItemRenderer r1 = new WindItemRenderer(); WindItemRenderer r2 = new WindItemRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { WindItemRenderer r1 = new WindItemRenderer(); WindItemRenderer r2 = null; try { r2 = (WindItemRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { WindItemRenderer r1 = new WindItemRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { WindItemRenderer r1 = new WindItemRenderer(); WindItemRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (WindItemRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java0000644000175000017500000001737111173030414032473 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * AreaXYRenderer2Tests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 24-May-2005 : Version 1 (DG); * 30-Nov-2006 : Extended testEquals() and testCloning() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Rectangle; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYAreaRenderer2; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYAreaRenderer2} class. */ public class XYAreaRenderer2Tests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYAreaRenderer2Tests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYAreaRenderer2Tests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYAreaRenderer2 r1 = new XYAreaRenderer2(); XYAreaRenderer2 r2 = new XYAreaRenderer2(); assertEquals(r1, r2); r1.setOutline(!r1.isOutline()); assertFalse(r1.equals(r2)); r2.setOutline(r1.isOutline()); assertTrue(r1.equals(r2)); r1.setLegendArea(new Rectangle(1, 2, 3, 4)); assertFalse(r1.equals(r2)); r2.setLegendArea(new Rectangle(1, 2, 3, 4)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYAreaRenderer2 r1 = new XYAreaRenderer2(); XYAreaRenderer2 r2 = new XYAreaRenderer2(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYAreaRenderer2 r1 = new XYAreaRenderer2(); Rectangle rect = new Rectangle(1, 2, 3, 4); r1.setLegendArea(rect); XYAreaRenderer2 r2 = null; try { r2 = (XYAreaRenderer2) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence rect.setBounds(99, 99, 99, 99); assertFalse(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYAreaRenderer2 r1 = new XYAreaRenderer2(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYAreaRenderer2 r1 = new XYAreaRenderer2(); XYAreaRenderer2 r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYAreaRenderer2) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer2()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYAreaRenderer2 r = new XYAreaRenderer2(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java0000644000175000017500000002154111173030414032403 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYAreaRendererTests.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 14-Feb-2007 : Updated testCloning() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYAreaRenderer; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYAreaRenderer} class. */ public class XYAreaRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYAreaRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYAreaRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = new XYAreaRenderer(); assertEquals(r1, r2); r1 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.AREA); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.AREA); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.LINES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.LINES); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES); assertTrue(r1.equals(r2)); r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES); assertFalse(r1.equals(r2)); r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES); assertTrue(r1.equals(r2)); r1.setOutline(true); assertFalse(r1.equals(r2)); r2.setOutline(true); assertTrue(r1.equals(r2)); r1.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = new XYAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYAreaRenderer r1 = new XYAreaRenderer(); Rectangle2D rect1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); r1.setLegendArea(rect1); XYAreaRenderer r2 = null; try { r2 = (XYAreaRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence rect1.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setLegendArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYAreaRenderer r1 = new XYAreaRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYAreaRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYAreaRenderer r = new XYAreaRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java0000644000175000017500000002777311173030414032254 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYBarRendererTests.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 22-Oct-2003 : Added hashCode test (DG); * 09-Feb-2007 : Added to testCloning() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * 19-Jun-2008 : Added testFindRangeBounds() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.GradientXYBarPainter; import org.jfree.chart.renderer.xy.XYBarRenderer; import org.jfree.data.Range; import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.data.xy.XYBarDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYBarRenderer} class. */ public class XYBarRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBarRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBarRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances XYBarRenderer r1 = new XYBarRenderer(); XYBarRenderer r2 = new XYBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // setBase() r1.setBase(1.0); assertFalse(r1.equals(r2)); r2.setBase(1.0); assertTrue(r1.equals(r2)); // setUseYInterval r1.setUseYInterval(!r1.getUseYInterval()); assertFalse(r1.equals(r2)); r2.setUseYInterval(!r2.getUseYInterval()); assertTrue(r1.equals(r2)); // setMargin() r1.setMargin(0.10); assertFalse(r1.equals(r2)); r2.setMargin(0.10); assertTrue(r1.equals(r2)); // setDrawBarOutline() r1.setDrawBarOutline(!r1.isDrawBarOutline()); assertFalse(r1.equals(r2)); r2.setDrawBarOutline(!r2.isDrawBarOutline()); assertTrue(r1.equals(r2)); // setGradientPaintTransformer() r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_HORIZONTAL)); assertFalse(r1.equals(r2)); r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_HORIZONTAL)); assertTrue(r1.equals(r2)); // legendBar r1.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); // positiveItemLabelFallbackPosition r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); assertTrue(r1.equals(r2)); // negativeItemLabelFallbackPosition r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition()); assertFalse(r1.equals(r2)); r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition()); assertTrue(r1.equals(r2)); // barPainter r1.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33)); assertFalse(r1.equals(r2)); r2.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33)); assertTrue(r1.equals(r2)); // shadowsVisible r1.setShadowVisible(false); assertFalse(r1.equals(r2)); r2.setShadowVisible(false); assertTrue(r1.equals(r2)); // shadowXOffset r1.setShadowXOffset(3.3); assertFalse(r1.equals(r2)); r2.setShadowXOffset(3.3); assertTrue(r1.equals(r2)); // shadowYOffset r1.setShadowYOffset(3.3); assertFalse(r1.equals(r2)); r2.setShadowYOffset(3.3); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYBarRenderer r1 = new XYBarRenderer(); XYBarRenderer r2 = new XYBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYBarRenderer r1 = new XYBarRenderer(); Rectangle2D rect = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); r1.setLegendBar(rect); XYBarRenderer r2 = null; try { r2 = (XYBarRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence rect.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setLegendBar(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYBarRenderer r1 = new XYBarRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYBarRenderer r1 = new XYBarRenderer(); XYBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { XYBarRenderer r1 = new XYBarRenderer(); r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); XYBarRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYBarRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Check that the renderer is calculating the domain bounds correctly. */ public void testFindDomainBounds() { XYSeriesCollection dataset = RendererXYPackageTests.createTestXYSeriesCollection(); JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X", false, "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); Range bounds = domainAxis.getRange(); assertFalse(bounds.contains(0.3)); assertTrue(bounds.contains(0.5)); assertTrue(bounds.contains(2.5)); assertFalse(bounds.contains(2.8)); } private static final double EPSILON = 0.0000000001; /** * A simple test for the findRangeBounds() method. */ public void testFindRangeBounds() { DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); double[] x = {1.0, 2.0, 3.0, 4.0}; double[] startx = {0.9, 1.8, 2.7, 3.6}; double[] endx = {1.1, 2.2, 3.3, 4.4}; double[] y = {1.0, 2.0, 3.0, 4.0}; double[] starty = {0.9, 1.8, 2.7, 3.6}; double[] endy = {1.1, 2.2, 3.3, 4.4}; double[][] data = new double[][] {x, startx, endx, y, starty, endy}; dataset.addSeries("Series 1", data); XYBarRenderer renderer = new XYBarRenderer(); renderer.setUseYInterval(true); Range r = renderer.findRangeBounds(dataset); assertEquals(0.9, r.getLowerBound(), EPSILON); assertEquals(4.4, r.getUpperBound(), EPSILON); renderer.setUseYInterval(false); r = renderer.findRangeBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(4.0, r.getUpperBound(), EPSILON); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYBlockRendererTests.java0000644000175000017500000001451311173030414032566 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYBlockRendererTests.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Jul-2006 : Version 1 (DG); * 09-Mar-2007 : Added independence check to testCloning (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.GrayPaintScale; import org.jfree.chart.renderer.LookupPaintScale; import org.jfree.chart.renderer.xy.XYBlockRenderer; import org.jfree.data.Range; import org.jfree.data.xy.DefaultXYZDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYBlockRenderer} class. */ public class XYBlockRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBlockRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBlockRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances XYBlockRenderer r1 = new XYBlockRenderer(); XYBlockRenderer r2 = new XYBlockRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); // blockHeight r1.setBlockHeight(2.0); assertFalse(r1.equals(r2)); r2.setBlockHeight(2.0); assertTrue(r1.equals(r2)); // blockWidth r1.setBlockWidth(2.0); assertFalse(r1.equals(r2)); r2.setBlockWidth(2.0); assertTrue(r1.equals(r2)); // paintScale r1.setPaintScale(new GrayPaintScale(0.0, 1.0)); assertFalse(r1.equals(r2)); r2.setPaintScale(new GrayPaintScale(0.0, 1.0)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYBlockRenderer r1 = new XYBlockRenderer(); XYBlockRenderer r2 = new XYBlockRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYBlockRenderer r1 = new XYBlockRenderer(); LookupPaintScale scale1 = new LookupPaintScale(); r1.setPaintScale(scale1); XYBlockRenderer r2 = null; try { r2 = (XYBlockRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence scale1.add(0.5, Color.red); assertFalse(r1.equals(r2)); LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale(); scale2.add(0.5, Color.red); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYBlockRenderer r1 = new XYBlockRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYBlockRenderer r1 = new XYBlockRenderer(); XYBlockRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYBlockRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A simple test for bug 1766646. */ public void testBug1766646A() { XYBlockRenderer r = new XYBlockRenderer(); Range range = r.findDomainBounds(null); assertTrue(range == null); DefaultXYZDataset emptyDataset = new DefaultXYZDataset(); range = r.findDomainBounds(emptyDataset); assertTrue(range == null); } /** * A simple test for bug 1766646. */ public void testBug1766646B() { XYBlockRenderer r = new XYBlockRenderer(); Range range = r.findRangeBounds(null); assertTrue(range == null); DefaultXYZDataset emptyDataset = new DefaultXYZDataset(); range = r.findRangeBounds(emptyDataset); assertTrue(range == null); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYBoxAndWhiskerRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYBoxAndWhiskerRendererTests.0000644000175000017500000001371411173030414033404 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * XYBoxAndWhiskerRendererTests.java * --------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2003 : Version 1 (DG); * 23-Apr-2004 : Extended testEquals() method (DG); * 27-Mar-2008 : Extended testEquals() some more (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYBoxAndWhiskerRenderer} class. */ public class XYBoxAndWhiskerRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBoxAndWhiskerRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBoxAndWhiskerRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer(); assertEquals(r1, r2); r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red)); assertEquals(r1, r2); r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertFalse(r1.equals(r2)); r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.red)); assertEquals(r1, r2); r1.setBoxWidth(0.55); assertFalse(r1.equals(r2)); r2.setBoxWidth(0.55); assertEquals(r1, r2); r1.setFillBox(!r1.getFillBox()); assertFalse(r1.equals(r2)); r2.setFillBox(!r2.getFillBox()); assertEquals(r1, r2); r1.setBoxPaint(Color.yellow); assertFalse(r1.equals(r2)); r2.setBoxPaint(Color.yellow); assertEquals(r1, r2); // check boxPaint null also r1.setBoxPaint(null); assertFalse(r1.equals(r2)); r2.setBoxPaint(null); assertEquals(r1, r2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); XYBoxAndWhiskerRenderer r2 = null; try { r2 = (XYBoxAndWhiskerRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); XYBoxAndWhiskerRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (XYBoxAndWhiskerRenderer) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYBubbleRendererTests.java0000644000175000017500000001525111173030414032727 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYBubbleRendererTests.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 24-Jan-2007 : Added more checks to testEquals() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYBubbleRenderer; import org.jfree.data.xy.DefaultXYZDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYBubbleRenderer} class. */ public class XYBubbleRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBubbleRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBubbleRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYBubbleRenderer r1 = new XYBubbleRenderer(); XYBubbleRenderer r2 = new XYBubbleRenderer(); assertEquals(r1, r2); r1 = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); assertFalse(r1.equals(r2)); r2 = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYBubbleRenderer r1 = new XYBubbleRenderer(); XYBubbleRenderer r2 = new XYBubbleRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYBubbleRenderer r1 = new XYBubbleRenderer(); XYBubbleRenderer r2 = null; try { r2 = (XYBubbleRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYBubbleRenderer r1 = new XYBubbleRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYBubbleRenderer r1 = new XYBubbleRenderer(); XYBubbleRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYBubbleRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { DefaultXYZDataset d1 = new DefaultXYZDataset(); double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8}; double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25}; double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4}; double[][] s1 = new double[][] {x, y, z}; d1.addSeries("S1", s1); x = new double[] {2.1}; y = new double[] {14.1}; z = new double[] {2.4}; double[][] s2 = new double[][] {x, y, z}; d1.addSeries("S2", s2); DefaultXYZDataset d2 = new DefaultXYZDataset(); x = new double[] {2.1}; y = new double[] {14.1}; z = new double[] {2.4}; double[][] s3 = new double[][] {x, y, z}; d2.addSeries("S3", s3); x = new double[] {2.1}; y = new double[] {14.1}; z = new double[] {2.4}; double[][] s4 = new double[][] {x, y, z}; d2.addSeries("S4", s4); x = new double[] {2.1}; y = new double[] {14.1}; z = new double[] {2.4}; double[][] s5 = new double[][] {x, y, z}; d2.addSeries("S5", s5); XYBubbleRenderer r = new XYBubbleRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYDifferenceRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYDifferenceRendererTests.jav0000644000175000017500000002005411173030414033422 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * XYDifferenceRendererTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2003 : Version 1 (DG); * 04-May-2005 : Improved equals() test (DG); * 24-Jan-2007 : Added 'roundXCoordinates' to testEquals(), and improved * testClone() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Shape; import java.awt.geom.Line2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYDifferenceRenderer; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYDifferenceRenderer} class. */ public class XYDifferenceRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYDifferenceRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYDifferenceRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYDifferenceRenderer r1 = new XYDifferenceRenderer( Color.red, Color.blue, false); XYDifferenceRenderer r2 = new XYDifferenceRenderer( Color.red, Color.blue, false); assertEquals(r1, r2); // positive paint r1.setPositivePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setPositivePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); // negative paint r1.setNegativePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setNegativePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); // shapesVisible r1 = new XYDifferenceRenderer(Color.green, Color.yellow, true); assertFalse(r1.equals(r2)); r2 = new XYDifferenceRenderer(Color.green, Color.yellow, true); assertTrue(r1.equals(r2)); // legendLine r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); // roundXCoordinates r1.setRoundXCoordinates(true); assertFalse(r1.equals(r2)); r2.setRoundXCoordinates(true); assertTrue(r1.equals(r2)); assertFalse(r1.equals(null)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, Color.blue, false); XYDifferenceRenderer r2 = new XYDifferenceRenderer(Color.red, Color.blue, false); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, Color.blue, false); XYDifferenceRenderer r2 = null; try { r2 = (XYDifferenceRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence Shape s = r1.getLegendLine(); if (s instanceof Line2D) { Line2D l = (Line2D) s; l.setLine(1.0, 2.0, 3.0, 4.0); assertFalse(r1.equals(r2)); } } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYDifferenceRenderer r1 = new XYDifferenceRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, Color.blue, false); XYDifferenceRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYDifferenceRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYDifferenceRenderer r = new XYDifferenceRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYDotRendererTests.java0000644000175000017500000001504311173030414032261 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYDotRendererTests.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 09-Nov-2007 : Updated testEquals() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYDotRenderer; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYDotRenderer} class. */ public class XYDotRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYDotRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYDotRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = new XYDotRenderer(); assertEquals(r1, r2); r1.setDotWidth(11); assertFalse(r1.equals(r2)); r2.setDotWidth(11); assertTrue(r1.equals(r2)); r1.setDotHeight(12); assertFalse(r1.equals(r2)); r2.setDotHeight(12); assertTrue(r1.equals(r2)); r1.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = new XYDotRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); r1.setDotHeight(12); r2.setDotHeight(12); assertTrue(r1.equals(r2)); h1 = r1.hashCode(); h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = null; try { r2 = (XYDotRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYDotRenderer r1 = new XYDotRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYDotRenderer r1 = new XYDotRenderer(); XYDotRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYDotRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYDotRenderer r = new XYDotRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYErrorRendererTests.java0000644000175000017500000001576211173030414032634 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYErrorRendererTests.java * ------------------------- * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Oct-2006 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * 28-Jan-2009 : Updated tests for new errorStroke field (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.XYErrorRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYErrorRenderer} class. */ public class XYErrorRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYErrorRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYErrorRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYErrorRenderer r1 = new XYErrorRenderer(); XYErrorRenderer r2 = new XYErrorRenderer(); assertEquals(r1, r2); // drawXError r1.setDrawXError(false); assertFalse(r1.equals(r2)); r2.setDrawXError(false); assertTrue(r1.equals(r2)); // drawYError r1.setDrawYError(false); assertFalse(r1.equals(r2)); r2.setDrawYError(false); assertTrue(r1.equals(r2)); // capLength r1.setCapLength(9.0); assertFalse(r1.equals(r2)); r2.setCapLength(9.0); assertTrue(r1.equals(r2)); // errorPaint r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertFalse(r1.equals(r2)); r2.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertTrue(r1.equals(r2)); // errorStroke r1.setErrorStroke(new BasicStroke(1.5f)); assertFalse(r1.equals(r2)); r2.setErrorStroke(new BasicStroke(1.5f)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYErrorRenderer r1 = new XYErrorRenderer(); XYErrorRenderer r2 = new XYErrorRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYErrorRenderer r1 = new XYErrorRenderer(); r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); XYErrorRenderer r2 = null; try { r2 = (XYErrorRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * A test for cloning. */ public void testCloning2() { XYErrorRenderer r1 = new XYErrorRenderer(); r1.setErrorStroke(new BasicStroke(1.5f)); XYErrorRenderer r2 = null; try { r2 = (XYErrorRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYErrorRenderer r1 = new XYErrorRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYErrorRenderer r1 = new XYErrorRenderer(); r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); XYErrorRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYErrorRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization2() { XYErrorRenderer r1 = new XYErrorRenderer(); r1.setErrorStroke(new BasicStroke(1.5f)); XYErrorRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYErrorRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYLine3DRendererTests.java0000644000175000017500000001235111173030414032610 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYLine3DRendererTests.java * -------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Apr-2007 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.XYLine3DRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYLine3DRenderer} class. */ public class XYLine3DRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYLine3DRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYLine3DRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYLine3DRenderer r1 = new XYLine3DRenderer(); XYLine3DRenderer r2 = new XYLine3DRenderer(); assertEquals(r1, r2); r1.setXOffset(11.1); assertFalse(r1.equals(r2)); r2.setXOffset(11.1); assertTrue(r1.equals(r2)); r1.setYOffset(11.1); assertFalse(r1.equals(r2)); r2.setYOffset(11.1); assertTrue(r1.equals(r2)); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYLine3DRenderer r1 = new XYLine3DRenderer(); XYLine3DRenderer r2 = new XYLine3DRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYLine3DRenderer r1 = new XYLine3DRenderer(); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); XYLine3DRenderer r2 = null; try { r2 = (XYLine3DRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYLine3DRenderer r1 = new XYLine3DRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYLine3DRenderer r1 = new XYLine3DRenderer(); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); XYLine3DRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYLine3DRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYLineAndShapeRendererTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYLineAndShapeRendererTests.j0000644000175000017500000002664711173030414033352 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * XYLineAndShapeRendererTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Jan-2004 : Version 1 (DG); * 07-Jan-2005 : Added check for findRangeBounds() method (DG); * 21-Feb-2007 : Check independence in testCloning() (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.urls.TimeSeriesURLGenerator; import org.jfree.data.Range; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYLineAndShapeRenderer} class. */ public class XYLineAndShapeRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYLineAndShapeRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYLineAndShapeRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); assertEquals(r1, r2); assertEquals(r2, r1); r1.setLinesVisible(true); assertFalse(r1.equals(r2)); r2.setLinesVisible(true); assertTrue(r1.equals(r2)); r1.setSeriesLinesVisible(3, true); assertFalse(r1.equals(r2)); r2.setSeriesLinesVisible(3, true); assertTrue(r1.equals(r2)); r1.setBaseLinesVisible(false); assertFalse(r1.equals(r2)); r2.setBaseLinesVisible(false); assertTrue(r1.equals(r2)); r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(r1.equals(r2)); r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(r1.equals(r2)); r1.setShapesVisible(true); assertFalse(r1.equals(r2)); r2.setShapesVisible(true); assertTrue(r1.equals(r2)); r1.setSeriesShapesVisible(3, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesVisible(3, true); assertTrue(r1.equals(r2)); r1.setBaseShapesVisible(false); assertFalse(r1.equals(r2)); r2.setBaseShapesVisible(false); assertTrue(r1.equals(r2)); r1.setShapesFilled(true); assertFalse(r1.equals(r2)); r2.setShapesFilled(true); assertTrue(r1.equals(r2)); r1.setSeriesShapesFilled(3, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesFilled(3, true); assertTrue(r1.equals(r2)); r1.setBaseShapesFilled(false); assertFalse(r1.equals(r2)); r2.setBaseShapesFilled(false); assertTrue(r1.equals(r2)); r1.setDrawOutlines(!r1.getDrawOutlines()); assertFalse(r1.equals(r2)); r2.setDrawOutlines(r1.getDrawOutlines()); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(true); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(true); assertTrue(r1.equals(r2)); r1.setUseFillPaint(true); assertFalse(r1.equals(r2)); r2.setUseFillPaint(true); assertTrue(r1.equals(r2)); r1.setDrawSeriesLineAsPath(true); assertFalse(r1.equals(r2)); r2.setDrawSeriesLineAsPath(true); assertTrue(r1.equals(r2)); } /** * Test that the equals() method works for a TimeSeriesURLGenerator. */ public void testEquals2() { XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); assertEquals(r1, r2); assertEquals(r2, r1); r1.setURLGenerator(new TimeSeriesURLGenerator()); assertFalse(r1.equals(r2)); r2.setURLGenerator(new TimeSeriesURLGenerator()); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); r1.setLegendLine(legendShape); XYLineAndShapeRenderer r2 = null; try { r2 = (XYLineAndShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); r1.setSeriesLinesVisible(0, false); assertFalse(r1.equals(r2)); r2.setSeriesLinesVisible(0, false); assertTrue(r1.equals(r2)); legendShape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(r1.equals(r2)); r2.setLegendLine(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(r1.equals(r2)); r1.setSeriesShapesVisible(1, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesVisible(1, true); assertTrue(r1.equals(r2)); r1.setSeriesShapesFilled(1, true); assertFalse(r1.equals(r2)); r2.setSeriesShapesFilled(1, true); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); XYLineAndShapeRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYLineAndShapeRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Check that the renderer is calculating the domain bounds correctly. */ public void testFindDomainBounds() { XYSeriesCollection dataset = RendererXYPackageTests.createTestXYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); Range bounds = domainAxis.getRange(); assertFalse(bounds.contains(0.9)); assertTrue(bounds.contains(1.0)); assertTrue(bounds.contains(2.0)); assertFalse(bounds.contains(2.10)); } /** * Check that the renderer is calculating the range bounds correctly. */ public void testFindRangeBounds() { TableXYDataset dataset = RendererXYPackageTests.createTestTableXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); Range bounds = rangeAxis.getRange(); assertFalse(bounds.contains(1.0)); assertTrue(bounds.contains(2.0)); assertTrue(bounds.contains(5.0)); assertFalse(bounds.contains(6.0)); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java0000644000175000017500000001137311173030414032575 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XYShapeRendererTests.java * ------------------------- * (C) Copyright 2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Sep-2008 : Version 1 (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.LookupPaintScale; import org.jfree.chart.renderer.xy.XYShapeRenderer; /** * Tests for the {@link XYShapeRenderer} class. */ public class XYShapeRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYShapeRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYShapeRendererTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { XYShapeRenderer r1 = new XYShapeRenderer(); XYShapeRenderer r2 = new XYShapeRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.white)); assertFalse(r1.equals(r2)); r2.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.white)); assertTrue(r1.equals(r2)); r1.setDrawOutlines(true); assertFalse(r1.equals(r2)); r2.setDrawOutlines(true); assertTrue(r1.equals(r2)); r1.setUseOutlinePaint(false); assertFalse(r1.equals(r2)); r2.setUseOutlinePaint(false); assertTrue(r1.equals(r2)); r1.setUseFillPaint(true); assertFalse(r1.equals(r2)); r2.setUseFillPaint(true); assertTrue(r1.equals(r2)); r1.setGuideLinesVisible(true); assertFalse(r1.equals(r2)); r2.setGuideLinesVisible(true); assertTrue(r1.equals(r2)); r1.setGuideLinePaint(Color.red); assertFalse(r1.equals(r2)); r2.setGuideLinePaint(Color.red); assertTrue(r1.equals(r2)); } /** * Confirm that cloning works. */ public void testCloning() { XYShapeRenderer r1 = new XYShapeRenderer(); XYShapeRenderer r2 = null; try { r2 = (XYShapeRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYShapeRenderer r1 = new XYShapeRenderer(); XYShapeRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYShapeRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYSplineRendererTests.java0000644000175000017500000001140211173030414032760 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYSplineRendererTests.java * -------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Jul-2007 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.renderer.xy.XYSplineRenderer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYSplineRenderer} class. */ public class XYSplineRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYSplineRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYSplineRendererTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { XYSplineRenderer r1 = new XYSplineRenderer(); XYSplineRenderer r2 = new XYSplineRenderer(); assertEquals(r1, r2); assertEquals(r2, r1); r1.setPrecision(9); assertFalse(r1.equals(r2)); r2.setPrecision(9); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYSplineRenderer r1 = new XYSplineRenderer(); XYSplineRenderer r2 = new XYSplineRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); XYSplineRenderer r1 = new XYSplineRenderer(); r1.setLegendLine(legendShape); XYSplineRenderer r2 = null; try { r2 = (XYSplineRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYSplineRenderer r1 = new XYSplineRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYSplineRenderer r1 = new XYSplineRenderer(); XYSplineRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYSplineRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYStepAreaRendererTests.java0000644000175000017500000001541411173030414033241 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * XYStepAreaRendererTests.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Matthias Rose; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 26-Sep-2003 : copied XYStepRendererTests.java and used for * testing XYStepAreaRenderer (MR); * 14-Feb-2007 : Extended testEquals() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYStepAreaRenderer; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYStepAreaRenderer} class. */ public class XYStepAreaRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYStepAreaRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYStepAreaRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYStepAreaRenderer r1 = new XYStepAreaRenderer(); XYStepAreaRenderer r2 = new XYStepAreaRenderer(); assertEquals(r1, r2); r1.setOutline(true); assertFalse(r1.equals(r2)); r2.setOutline(true); assertTrue(r1.equals(r2)); r1.setShapesVisible(true); assertFalse(r1.equals(r2)); r2.setShapesVisible(true); assertTrue(r1.equals(r2)); r1.setShapesFilled(true); assertFalse(r1.equals(r2)); r2.setShapesFilled(true); assertTrue(r1.equals(r2)); r1.setPlotArea(false); assertFalse(r1.equals(r2)); r2.setPlotArea(false); assertTrue(r1.equals(r2)); r1.setRangeBase(-1.0); assertFalse(r1.equals(r2)); r2.setRangeBase(-1.0); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYStepAreaRenderer r1 = new XYStepAreaRenderer(); XYStepAreaRenderer r2 = new XYStepAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYStepAreaRenderer r1 = new XYStepAreaRenderer(); XYStepAreaRenderer r2 = null; try { r2 = (XYStepAreaRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYStepAreaRenderer r1 = new XYStepAreaRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYStepAreaRenderer r1 = new XYStepAreaRenderer(); XYStepAreaRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYStepAreaRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/XYStepRendererTests.java0000644000175000017500000001703411173030414032450 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * XYStepRendererTests.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 14-Feb-2008 : Added checks for new code (DG); * 22-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYStepRenderer; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYStepRenderer} class. */ public class XYStepRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYStepRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYStepRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYStepRenderer r1 = new XYStepRenderer(); XYStepRenderer r2 = new XYStepRenderer(); assertEquals(r1, r2); r1.setStepPoint(0.44); assertFalse(r1.equals(r2)); r2.setStepPoint(0.44); assertTrue(r1.equals(r2)); // try something from the base class r1.setBaseCreateEntities(false); assertFalse(r1.equals(r2)); r2.setBaseCreateEntities(false); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYStepRenderer r1 = new XYStepRenderer(); r1.setStepPoint(0.123); XYStepRenderer r2 = new XYStepRenderer(); r2.setStepPoint(0.123); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYStepRenderer r1 = new XYStepRenderer(); XYStepRenderer r2 = null; try { r2 = (XYStepRenderer) r1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYStepRenderer r1 = new XYStepRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYStepRenderer r1 = new XYStepRenderer(); r1.setStepPoint(0.123); XYStepRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (XYStepRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * Draws the chart with a null info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } /** * Draws the chart with a null value in the dataset to make * sure that no exceptions are thrown. */ public void testDrawWithNullValue() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, null); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, null); s2.add(20.0, null); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/renderer/xy/junit/YIntervalRendererTests.java0000644000175000017500000002520611173030414033171 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * YIntervalRendererTests.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2003 : Version 1 (DG); * 20-Feb-2007 : Extended the testEquals() checks (DG); * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); * 22-Apr-2008 : Added testPublicCloneable() (DG); * 26-May-2008 : Extended testEquals() (DG); * */ package org.jfree.chart.renderer.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.IntervalXYItemLabelGenerator; import org.jfree.chart.labels.StandardXYItemLabelGenerator; import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; import org.jfree.chart.labels.StandardXYToolTipGenerator; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.YIntervalRenderer; import org.jfree.chart.urls.StandardXYURLGenerator; import org.jfree.data.xy.YIntervalSeries; import org.jfree.data.xy.YIntervalSeriesCollection; import org.jfree.ui.Layer; import org.jfree.util.PublicCloneable; /** * Tests for the {@link YIntervalRenderer} class. */ public class YIntervalRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YIntervalRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YIntervalRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = new YIntervalRenderer(); assertEquals(r1, r2); // the following fields are inherited from the AbstractXYItemRenderer r1.setItemLabelGenerator(new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setItemLabelGenerator(new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setToolTipGenerator(new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setToolTipGenerator(new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.setURLGenerator(new StandardXYURLGenerator()); assertFalse(r1.equals(r2)); r2.setURLGenerator(new StandardXYURLGenerator()); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); r1.setDefaultEntityRadius(99); assertFalse(r1.equals(r2)); r2.setDefaultEntityRadius(99); assertTrue(r1.equals(r2)); r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertFalse(r1.equals(r2)); r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( "{0} {1}")); assertTrue(r1.equals(r2)); r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertFalse(r1.equals(r2)); r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); assertTrue(r1.equals(r2)); r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = new YIntervalRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = null; try { r2 = (YIntervalRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check independence r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); assertTrue(r1.equals(r2)); r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertFalse(r1.equals(r2)); r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.FOREGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.FOREGROUND); assertTrue(r1.equals(r2)); r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.BACKGROUND); assertFalse(r1.equals(r2)); r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), Layer.BACKGROUND); assertTrue(r1.equals(r2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { YIntervalRenderer r1 = new YIntervalRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YIntervalRenderer r1 = new YIntervalRenderer(); YIntervalRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (YIntervalRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { YIntervalSeriesCollection d1 = new YIntervalSeriesCollection(); YIntervalSeries s1 = new YIntervalSeries("S1"); s1.add(1.0, 1.1, 1.2, 1.3); YIntervalSeries s2 = new YIntervalSeries("S2"); s2.add(1.0, 1.1, 1.2, 1.3); d1.addSeries(s1); d1.addSeries(s2); YIntervalSeriesCollection d2 = new YIntervalSeriesCollection(); YIntervalSeries s3 = new YIntervalSeries("S3"); s3.add(1.0, 1.1, 1.2, 1.3); YIntervalSeries s4 = new YIntervalSeries("S4"); s4.add(1.0, 1.1, 1.2, 1.3); YIntervalSeries s5 = new YIntervalSeries("S5"); s5.add(1.0, 1.1, 1.2, 1.3); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); YIntervalRenderer r = new YIntervalRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/0000755000175000017500000000000011173030414023414 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/0000755000175000017500000000000011216245562024557 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/CompositeTitleTests.java0000644000175000017500000001432211173030414031401 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * CompositeTitleTests.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * 09-Jul-2008 : Added new field into testEquals() (DG); * */ package org.jfree.chart.title.junit; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.block.BlockBorder; import org.jfree.chart.block.BlockContainer; import org.jfree.chart.title.CompositeTitle; import org.jfree.chart.title.TextTitle; import org.jfree.ui.RectangleInsets; /** * Tests for the {@link CompositeTitle} class. */ public class CompositeTitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CompositeTitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CompositeTitleTests(String name) { super(name); } /** * Some checks for the constructor. */ public void testConstructor() { CompositeTitle t = new CompositeTitle(); assertNull(t.getBackgroundPaint()); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { CompositeTitle t1 = new CompositeTitle(new BlockContainer()); CompositeTitle t2 = new CompositeTitle(new BlockContainer()); assertEquals(t1, t2); assertEquals(t2, t1); // margin t1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(t1.equals(t2)); t2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(t1.equals(t2)); // border t1.setBorder(new BlockBorder(Color.red)); assertFalse(t1.equals(t2)); t2.setBorder(new BlockBorder(Color.red)); assertTrue(t1.equals(t2)); // padding t1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(t1.equals(t2)); t2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(t1.equals(t2)); // contained titles t1.getContainer().add(new TextTitle("T1")); assertFalse(t1.equals(t2)); t2.getContainer().add(new TextTitle("T1")); assertTrue(t1.equals(t2)); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertFalse(t1.equals(t2)); t2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { CompositeTitle t1 = new CompositeTitle(new BlockContainer()); t1.getContainer().add(new TextTitle("T1")); CompositeTitle t2 = new CompositeTitle(new BlockContainer()); t2.getContainer().add(new TextTitle("T1")); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { CompositeTitle t1 = new CompositeTitle(new BlockContainer()); t1.getContainer().add(new TextTitle("T1")); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); CompositeTitle t2 = null; try { t2 = (CompositeTitle) t1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CompositeTitle t1 = new CompositeTitle(new BlockContainer()); t1.getContainer().add(new TextTitle("T1")); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); CompositeTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (CompositeTitle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/DateTitleTests.java0000644000175000017500000001121411173030414030311 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * DateTitleTests.java * ------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Feb-2004 : Version 1 (DG); * */ package org.jfree.chart.title.junit; import java.awt.Color; import java.awt.Font; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.title.DateTitle; /** * Tests for the {@link DateTitle} class. */ public class DateTitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DateTitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DateTitleTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { DateTitle t1 = new DateTitle(); DateTitle t2 = new DateTitle(); assertEquals(t1, t2); t1.setText("Test 1"); assertFalse(t1.equals(t2)); t2.setText("Test 1"); assertTrue(t1.equals(t2)); Font f = new Font("SansSerif", Font.PLAIN, 15); t1.setFont(f); assertFalse(t1.equals(t2)); t2.setFont(f); assertTrue(t1.equals(t2)); t1.setPaint(Color.blue); assertFalse(t1.equals(t2)); t2.setPaint(Color.blue); assertTrue(t1.equals(t2)); t1.setBackgroundPaint(Color.blue); assertFalse(t1.equals(t2)); t2.setBackgroundPaint(Color.blue); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { DateTitle t1 = new DateTitle(); DateTitle t2 = new DateTitle(); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { DateTitle t1 = new DateTitle(); DateTitle t2 = null; try { t2 = (DateTitle) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("DateTitleTests.testCloning: failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateTitle t1 = new DateTitle(); DateTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (DateTitle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/ImageTitleTests.java0000644000175000017500000001177511173030414030472 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * ImageTitleTests.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Feb-2004 : Version 1 (DG); * 21-Mar-2008 : Added tests for arrange method (DG); * */ package org.jfree.chart.title.junit; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.JFreeChart; import org.jfree.chart.title.ImageTitle; import org.jfree.ui.Size2D; /** * Tests for the {@link ImageTitle} class. */ public class ImageTitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ImageTitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ImageTitleTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); assertEquals(t1, t2); t1.setImage(new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB)); assertFalse(t1.equals(t2)); t2.setImage(new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB)); // images considered equal only if they're the SAME object // TODO: is there a way to do a better test? assertFalse(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); ImageTitle t2 = null; try { t2 = (ImageTitle) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { // TODO: add serialization support for images } private static final double EPSILON = 0.00000001; /** * Check the width and height. */ public void testWidthAndHeight() { ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); assertEquals(100, t1.getWidth(), EPSILON); assertEquals(100, t1.getHeight(), EPSILON); } /** * Some checks for the arrange method. */ public void testArrangeNN() { BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); ImageTitle t = new ImageTitle(JFreeChart.INFO.getLogo()); Size2D s = t.arrange(g2); assertEquals(102.0, s.getWidth(), EPSILON); assertEquals(102.0, s.getHeight(), EPSILON); t.setPadding(1.0, 2.0, 3.0, 4.0); s = t.arrange(g2); assertEquals(106.0, s.getWidth(), EPSILON); assertEquals(104.0, s.getHeight(), EPSILON); t.setMargin(5.0, 6.0, 7.0, 8.0); s = t.arrange(g2); assertEquals(120.0, s.getWidth(), EPSILON); assertEquals(116.0, s.getHeight(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/LegendGraphicTests.java0000644000175000017500000002110111173030414031122 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * LegendGraphicTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Sep-2005 : Version 1 (DG); * */ package org.jfree.chart.title.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Rectangle; import java.awt.Stroke; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.title.LegendGraphic; import org.jfree.ui.GradientPaintTransformType; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.StandardGradientPaintTransformer; /** * Tests for the {@link LegendGraphic} class. */ public class LegendGraphicTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LegendGraphicTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LegendGraphicTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); LegendGraphic g2 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); assertEquals(g1, g2); assertEquals(g2, g1); // shapeVisible g1.setShapeVisible(!g1.isShapeVisible()); assertFalse(g1.equals(g2)); g2.setShapeVisible(!g2.isShapeVisible()); assertTrue(g1.equals(g2)); // shape g1.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(g1.equals(g2)); g2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertTrue(g1.equals(g2)); // shapeFilled g1.setShapeFilled(!g1.isShapeFilled()); assertFalse(g1.equals(g2)); g2.setShapeFilled(!g2.isShapeFilled()); assertTrue(g1.equals(g2)); // fillPaint g1.setFillPaint(Color.green); assertFalse(g1.equals(g2)); g2.setFillPaint(Color.green); assertTrue(g1.equals(g2)); // shapeOutlineVisible g1.setShapeOutlineVisible(!g1.isShapeOutlineVisible()); assertFalse(g1.equals(g2)); g2.setShapeOutlineVisible(!g2.isShapeOutlineVisible()); assertTrue(g1.equals(g2)); // outlinePaint g1.setOutlinePaint(Color.green); assertFalse(g1.equals(g2)); g2.setOutlinePaint(Color.green); assertTrue(g1.equals(g2)); // outlineStroke g1.setOutlineStroke(new BasicStroke(1.23f)); assertFalse(g1.equals(g2)); g2.setOutlineStroke(new BasicStroke(1.23f)); assertTrue(g1.equals(g2)); // shapeAnchor g1.setShapeAnchor(RectangleAnchor.BOTTOM_RIGHT); assertFalse(g1.equals(g2)); g2.setShapeAnchor(RectangleAnchor.BOTTOM_RIGHT); assertTrue(g1.equals(g2)); // shapeLocation g1.setShapeLocation(RectangleAnchor.BOTTOM_RIGHT); assertFalse(g1.equals(g2)); g2.setShapeLocation(RectangleAnchor.BOTTOM_RIGHT); assertTrue(g1.equals(g2)); // lineVisible g1.setLineVisible(!g1.isLineVisible()); assertFalse(g1.equals(g2)); g2.setLineVisible(!g2.isLineVisible()); assertTrue(g1.equals(g2)); // line g1.setLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(g1.equals(g2)); g2.setLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); assertTrue(g1.equals(g2)); // linePaint g1.setLinePaint(Color.green); assertFalse(g1.equals(g2)); g2.setLinePaint(Color.green); assertTrue(g1.equals(g2)); // lineStroke g1.setLineStroke(new BasicStroke(1.23f)); assertFalse(g1.equals(g2)); g2.setLineStroke(new BasicStroke(1.23f)); assertTrue(g1.equals(g2)); // fillPaintTransformer g1.setFillPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_HORIZONTAL)); assertFalse(g1.equals(g2)); g2.setFillPaintTransformer(new StandardGradientPaintTransformer( GradientPaintTransformType.CENTER_HORIZONTAL)); assertTrue(g1.equals(g2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); LegendGraphic g2 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); assertTrue(g1.equals(g2)); int h1 = g1.hashCode(); int h2 = g2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { Rectangle r = new Rectangle(1, 2, 3, 4); LegendGraphic g1 = new LegendGraphic(r, Color.black); LegendGraphic g2 = null; try { g2 = (LegendGraphic) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence r.setBounds(4, 3, 2, 1); assertFalse(g1.equals(g2)); } /** * A test for cloning - checks that the line shape is cloned correctly. */ public void testCloning2() { Rectangle r = new Rectangle(1, 2, 3, 4); LegendGraphic g1 = new LegendGraphic(r, Color.black); Line2D l = new Line2D.Double(1.0, 2.0, 3.0, 4.0); g1.setLine(l); LegendGraphic g2 = null; try { g2 = (LegendGraphic) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence l.setLine(4.0, 3.0, 2.0, 1.0); assertFalse(g1.equals(g2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Stroke s = new BasicStroke(1.23f); LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.black); g1.setOutlineStroke(s); LegendGraphic g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (LegendGraphic) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertTrue(g1.equals(g2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/LegendTitleTests.java0000644000175000017500000001402411173030414030634 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * LegendTitleTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Feb-2005 : Version 1 (DG); * 16-Mar-2005 : Extended testEquals() (DG); * */ package org.jfree.chart.title.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.geom.Rectangle2D; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.title.LegendTitle; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RectangleEdge; /** * Some tests for the {@link LegendTitle} class. */ public class LegendTitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LegendTitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LegendTitleTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYPlot plot1 = new XYPlot(); LegendTitle t1 = new LegendTitle(plot1); LegendTitle t2 = new LegendTitle(plot1); assertEquals(t1, t2); t1.setBackgroundPaint( new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow) ); assertFalse(t1.equals(t2)); t2.setBackgroundPaint( new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow) ); assertTrue(t1.equals(t2)); t1.setLegendItemGraphicEdge(RectangleEdge.BOTTOM); assertFalse(t1.equals(t2)); t2.setLegendItemGraphicEdge(RectangleEdge.BOTTOM); assertTrue(t1.equals(t2)); t1.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT); assertFalse(t1.equals(t2)); t2.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT); assertTrue(t1.equals(t2)); t1.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT); assertFalse(t1.equals(t2)); t2.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT); assertTrue(t1.equals(t2)); t1.setItemFont(new Font("Dialog", Font.PLAIN, 19)); assertFalse(t1.equals(t2)); t2.setItemFont(new Font("Dialog", Font.PLAIN, 19)); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYPlot plot1 = new XYPlot(); LegendTitle t1 = new LegendTitle(plot1); LegendTitle t2 = new LegendTitle(plot1); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { XYPlot plot = new XYPlot(); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); LegendTitle t1 = new LegendTitle(plot); t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow)); t1.setBounds(bounds1); LegendTitle t2 = null; try { t2 = (LegendTitle) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); // check independence bounds1.setFrame(40.0, 30.0, 20.0, 10.0); assertFalse(t1.equals(t2)); t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0)); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYPlot plot = new XYPlot(); LegendTitle t1 = new LegendTitle(plot); LegendTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); t2 = (LegendTitle) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertTrue(t1.equals(t2)); assertTrue(t2.getSources()[0].equals(plot)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/PaintScaleLegendTests.java0000644000175000017500000001566311173030414031610 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * PaintScaleLegendTests.java * -------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Jan-2007 : Version 1 (DG); * 18-Jun-2008 : Extended testEquals() for new field (DG); * */ package org.jfree.chart.title.junit; import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.renderer.GrayPaintScale; import org.jfree.chart.renderer.LookupPaintScale; import org.jfree.chart.title.PaintScaleLegend; /** * Tests for the {@link PaintScaleLegend} class. */ public class PaintScaleLegendTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PaintScaleLegendTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PaintScaleLegendTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); assertTrue(l1.equals(l2)); assertTrue(l2.equals(l1)); // paintScale l1.setScale(new LookupPaintScale()); assertFalse(l1.equals(l2)); l2.setScale(new LookupPaintScale()); assertTrue(l1.equals(l2)); // axis l1.setAxis(new NumberAxis("Axis 2")); assertFalse(l1.equals(l2)); l2.setAxis(new NumberAxis("Axis 2")); assertTrue(l1.equals(l2)); // axisLocation l1.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); assertFalse(l1.equals(l2)); l2.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); assertTrue(l1.equals(l2)); // axisOffset l1.setAxisOffset(99.0); assertFalse(l1.equals(l2)); l2.setAxisOffset(99.0); assertTrue(l1.equals(l2)); // stripWidth l1.setStripWidth(99.0); assertFalse(l1.equals(l2)); l2.setStripWidth(99.0); assertTrue(l1.equals(l2)); // stripOutlineVisible l1.setStripOutlineVisible(!l1.isStripOutlineVisible()); assertFalse(l1.equals(l2)); l2.setStripOutlineVisible(l1.isStripOutlineVisible()); assertTrue(l1.equals(l2)); // stripOutlinePaint l1.setStripOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(l1.equals(l2)); l2.setStripOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(l1.equals(l2)); // stripOutlineStroke l1.setStripOutlineStroke(new BasicStroke(1.1f)); assertFalse(l1.equals(l2)); l2.setStripOutlineStroke(new BasicStroke(1.1f)); assertTrue(l1.equals(l2)); // backgroundPaint l1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(l1.equals(l2)); l2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(l1.equals(l2)); l1.setSubdivisionCount(99); assertFalse(l1.equals(l2)); l2.setSubdivisionCount(99); assertTrue(l1.equals(l2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); assertTrue(l1.equals(l2)); int h1 = l1.hashCode(); int h2 = l2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = null; try { l2 = (PaintScaleLegend) l1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(l1 != l2); assertTrue(l1.getClass() == l2.getClass()); assertTrue(l1.equals(l2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), new NumberAxis("X")); PaintScaleLegend l2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(l1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); l2 = (PaintScaleLegend) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(l1, l2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/ShortTextTitleTests.java0000644000175000017500000001035211173030414031402 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * ShortTextTitleTests.java * ------------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-May-2008 : Version 1 (DG); * */ package org.jfree.chart.title.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.title.ShortTextTitle; /** * Tests for the {@link ShortTextTitle} class. */ public class ShortTextTitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ShortTextTitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ShortTextTitleTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { ShortTextTitle t1 = new ShortTextTitle("ABC"); ShortTextTitle t2 = new ShortTextTitle("ABC"); assertEquals(t1, t2); t1.setText("Test 1"); assertFalse(t1.equals(t2)); t2.setText("Test 1"); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { ShortTextTitle t1 = new ShortTextTitle("ABC"); ShortTextTitle t2 = new ShortTextTitle("ABC"); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { ShortTextTitle t1 = new ShortTextTitle("ABC"); ShortTextTitle t2 = null; try { t2 = (ShortTextTitle) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ShortTextTitle t1 = new ShortTextTitle("ABC"); ShortTextTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (ShortTextTitle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/TextTitleTests.java0000644000175000017500000001401311173030414030360 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * TextTitleTests.java * ------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Feb-2004 : Version 1 (DG); * 06-Jun-2005 : Use GradientPaint in equals() test (DG); * 07-Oct-2005 : Updated testEquals() (DG); * 28-Apr-2008 : Extended testEquals() (DG); * */ package org.jfree.chart.title.junit; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.title.TextTitle; import org.jfree.ui.HorizontalAlignment; /** * Tests for the {@link TextTitle} class. */ public class TextTitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TextTitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TextTitleTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { TextTitle t1 = new TextTitle(); TextTitle t2 = new TextTitle(); assertEquals(t1, t2); t1.setText("Test 1"); assertFalse(t1.equals(t2)); t2.setText("Test 1"); assertTrue(t1.equals(t2)); Font f = new Font("SansSerif", Font.PLAIN, 15); t1.setFont(f); assertFalse(t1.equals(t2)); t2.setFont(f); assertTrue(t1.equals(t2)); t1.setTextAlignment(HorizontalAlignment.RIGHT); assertFalse(t1.equals(t2)); t2.setTextAlignment(HorizontalAlignment.RIGHT); assertTrue(t1.equals(t2)); // paint t1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(t1.equals(t2)); t2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(t1.equals(t2)); // backgroundPaint t1.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); assertFalse(t1.equals(t2)); t2.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); assertTrue(t1.equals(t2)); // maximumLinesToDisplay t1.setMaximumLinesToDisplay(3); assertFalse(t1.equals(t2)); t2.setMaximumLinesToDisplay(3); assertTrue(t1.equals(t2)); // toolTipText t1.setToolTipText("TTT"); assertFalse(t1.equals(t2)); t2.setToolTipText("TTT"); assertTrue(t1.equals(t2)); // urlText t1.setURLText(("URL")); assertFalse(t1.equals(t2)); t2.setURLText(("URL")); assertTrue(t1.equals(t2)); // expandToFitSpace t1.setExpandToFitSpace(!t1.getExpandToFitSpace()); assertFalse(t1.equals(t2)); t2.setExpandToFitSpace(!t2.getExpandToFitSpace()); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { TextTitle t1 = new TextTitle(); TextTitle t2 = new TextTitle(); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { TextTitle t1 = new TextTitle(); TextTitle t2 = null; try { t2 = (TextTitle) t1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TextTitle t1 = new TextTitle("Test"); TextTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); t2 = (TextTitle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(t1, t2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/TitlePackageTests.java0000644000175000017500000000607111173030414030774 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * TitlePackageTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 17-Feb-2004 : Version 1 (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 01-Sep-2005 : Added tests for LegendGraphic (DG); * 31-Jan-2007 : Added PaintScaleLegendTests (DG); * 05-May-2008 : Added ShortTextTitleTests (DG); * */ package org.jfree.chart.title.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.title package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class TitlePackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.title"); suite.addTestSuite(CompositeTitleTests.class); suite.addTestSuite(DateTitleTests.class); suite.addTestSuite(ImageTitleTests.class); suite.addTestSuite(LegendGraphicTests.class); suite.addTestSuite(LegendTitleTests.class); suite.addTestSuite(PaintScaleLegendTests.class); suite.addTestSuite(ShortTextTitleTests.class); suite.addTestSuite(TextTitleTests.class); suite.addTestSuite(TitleTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public TitlePackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/title/junit/TitleTests.java0000644000175000017500000000702611173030414027521 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * TitleTests.java * --------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Feb-2004 : Version 1 (DG); * 18-Sep-2008 : Updated testEquals() (DG); * */ package org.jfree.chart.title.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.title.TextTitle; import org.jfree.chart.title.Title; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.VerticalAlignment; /** * Tests for the abstract {@link Title} class. */ public class TitleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TitleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TitleTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { // use the TextTitle class because it is a concrete subclass Title t1 = new TextTitle(); Title t2 = new TextTitle(); assertEquals(t1, t2); t1.setPosition(RectangleEdge.LEFT); assertFalse(t1.equals(t2)); t2.setPosition(RectangleEdge.LEFT); assertTrue(t1.equals(t2)); t1.setHorizontalAlignment(HorizontalAlignment.RIGHT); assertFalse(t1.equals(t2)); t2.setHorizontalAlignment(HorizontalAlignment.RIGHT); assertTrue(t1.equals(t2)); t1.setVerticalAlignment(VerticalAlignment.BOTTOM); assertFalse(t1.equals(t2)); t2.setVerticalAlignment(VerticalAlignment.BOTTOM); assertTrue(t1.equals(t2)); t1.setVisible(false); assertFalse(t1.equals(t2)); t2.setVisible(false); assertTrue(t1.equals(t2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { TextTitle t1 = new TextTitle(); TextTitle t2 = new TextTitle(); assertTrue(t1.equals(t2)); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/0000755000175000017500000000000011173030414023260 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/0000755000175000017500000000000011216245562024423 5ustar vincentvincent././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/CustomCategoryURLGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/CustomCategoryURLGeneratorTests.java0000644000175000017500000001427511173030414033512 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * CustomCategoryURLGeneratorTests.java * ------------------------------------ * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Apr-2008 : Version 1, based on CustomXYURLGeneratorTests.java (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.CustomCategoryURLGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CustomCategoryURLGenerator} class. */ public class CustomCategoryURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CustomCategoryURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CustomCategoryURLGeneratorTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); CustomCategoryURLGenerator g2 = new CustomCategoryURLGenerator(); assertTrue(g1.equals(g2)); List u1 = new java.util.ArrayList(); u1.add("URL A1"); u1.add("URL A2"); u1.add("URL A3"); g1.addURLSeries(u1); assertFalse(g1.equals(g2)); List u2 = new java.util.ArrayList(); u2.add("URL A1"); u2.add("URL A2"); u2.add("URL A3"); g2.addURLSeries(u2); assertTrue(g1.equals(g2)); } /** * Confirm that cloning works. */ public void testCloning() { CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); List u1 = new java.util.ArrayList(); u1.add("URL A1"); u1.add("URL A2"); u1.add("URL A3"); g1.addURLSeries(u1); CustomCategoryURLGenerator g2 = null; try { g2 = (CustomCategoryURLGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence List u2 = new java.util.ArrayList(); u2.add("URL XXX"); g1.addURLSeries(u2); assertFalse(g1.equals(g2)); g2.addURLSeries(new java.util.ArrayList(u2)); assertTrue(g1.equals(g2)); } /** * Checks that the class implements PublicCloneable. */ public void testPublicCloneable() { CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { List u1 = new java.util.ArrayList(); u1.add("URL A1"); u1.add("URL A2"); u1.add("URL A3"); List u2 = new java.util.ArrayList(); u2.add("URL B1"); u2.add("URL B2"); u2.add("URL B3"); CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); CustomCategoryURLGenerator g2 = null; g1.addURLSeries(u1); g1.addURLSeries(u2); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (CustomCategoryURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Some checks for the addURLSeries() method. */ public void testAddURLSeries() { CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); // you can add a null list - it would have been better if this // required EMPTY_LIST g1.addURLSeries(null); assertEquals(1, g1.getListCount()); assertEquals(0, g1.getURLCount(0)); List list1 = new java.util.ArrayList(); list1.add("URL1"); g1.addURLSeries(list1); assertEquals(2, g1.getListCount()); assertEquals(0, g1.getURLCount(0)); assertEquals(1, g1.getURLCount(1)); assertEquals("URL1", g1.getURL(1, 0)); // if we modify the original list, it's best if the URL generator is // not affected list1.clear(); assertEquals("URL1", g1.getURL(1, 0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/CustomPieURLGeneratorTests.java0000644000175000017500000001136411173030414032446 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * CustomPieURLGeneratorTests.java * ------------------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Apr-2008 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Map; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.CustomPieURLGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CustomPieURLGenerator} class. */ public class CustomPieURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CustomPieURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CustomPieURLGeneratorTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { CustomPieURLGenerator g1 = new CustomPieURLGenerator(); CustomPieURLGenerator g2 = new CustomPieURLGenerator(); assertTrue(g1.equals(g2)); Map m1 = new HashMap(); m1.put("A", "http://www.jfree.org/"); g1.addURLs(m1); assertFalse(g1.equals(g2)); g2.addURLs(m1); assertTrue(g1.equals(g2)); } /** * Confirm that cloning works. */ public void testCloning() { CustomPieURLGenerator g1 = new CustomPieURLGenerator(); Map m1 = new HashMap(); m1.put("A", "http://www.jfree.org/"); g1.addURLs(m1); CustomPieURLGenerator g2 = null; try { g2 = (CustomPieURLGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence Map m2 = new HashMap(); m2.put("B", "XYZ"); g1.addURLs(m2); assertFalse(g1.equals(g2)); } /** * Checks that the class implements PublicCloneable. */ public void testPublicCloneable() { CustomPieURLGenerator g1 = new CustomPieURLGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CustomPieURLGenerator g1 = new CustomPieURLGenerator(); Map m1 = new HashMap(); m1.put("A", "http://www.jfree.org/"); g1.addURLs(m1); CustomPieURLGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (CustomPieURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/CustomXYURLGeneratorTests.java0000644000175000017500000001424411173030414032271 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CustomXYURLGeneratorTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2003 : Version 1 (DG); * 11-Apr-2008 : Added testCloning() and testEquals() (DG); * 21-Apr-2008 : Enhanced testCloning() (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.CustomXYURLGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CustomXYURLGenerator} class. */ public class CustomXYURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CustomXYURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CustomXYURLGeneratorTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { CustomXYURLGenerator g1 = new CustomXYURLGenerator(); CustomXYURLGenerator g2 = new CustomXYURLGenerator(); assertTrue(g1.equals(g2)); List u1 = new java.util.ArrayList(); u1.add("URL A1"); u1.add("URL A2"); u1.add("URL A3"); g1.addURLSeries(u1); assertFalse(g1.equals(g2)); List u2 = new java.util.ArrayList(); u2.add("URL A1"); u2.add("URL A2"); u2.add("URL A3"); g2.addURLSeries(u2); assertTrue(g1.equals(g2)); } /** * Confirm that cloning works. */ public void testCloning() { CustomXYURLGenerator g1 = new CustomXYURLGenerator(); List u1 = new java.util.ArrayList(); u1.add("URL A1"); u1.add("URL A2"); u1.add("URL A3"); g1.addURLSeries(u1); CustomXYURLGenerator g2 = null; try { g2 = (CustomXYURLGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); // check independence List u2 = new java.util.ArrayList(); u2.add("URL XXX"); g1.addURLSeries(u2); assertFalse(g1.equals(g2)); g2.addURLSeries(new java.util.ArrayList(u2)); assertTrue(g1.equals(g2)); } /** * Checks that the class implements PublicCloneable. */ public void testPublicCloneable() { CustomXYURLGenerator g1 = new CustomXYURLGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { List u1 = new java.util.ArrayList(); u1.add("URL A1"); u1.add("URL A2"); u1.add("URL A3"); List u2 = new java.util.ArrayList(); u2.add("URL B1"); u2.add("URL B2"); u2.add("URL B3"); CustomXYURLGenerator g1 = new CustomXYURLGenerator(); CustomXYURLGenerator g2 = null; g1.addURLSeries(u1); g1.addURLSeries(u2); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (CustomXYURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Some checks for the addURLSeries() method. */ public void testAddURLSeries() { CustomXYURLGenerator g1 = new CustomXYURLGenerator(); // you can add a null list - it would have been better if this // required EMPTY_LIST g1.addURLSeries(null); assertEquals(1, g1.getListCount()); assertEquals(0, g1.getURLCount(0)); List list1 = new java.util.ArrayList(); list1.add("URL1"); g1.addURLSeries(list1); assertEquals(2, g1.getListCount()); assertEquals(0, g1.getURLCount(0)); assertEquals(1, g1.getURLCount(1)); assertEquals("URL1", g1.getURL(1, 0)); // if we modify the original list, it's best if the URL generator is // not affected list1.clear(); assertEquals("URL1", g1.getURL(1, 0)); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/StandardCategoryURLGeneratorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/StandardCategoryURLGeneratorTests.ja0000644000175000017500000001272011173030414033442 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------------- * StandardCategoryURLGeneratorTests.java * -------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2003 : Version 1 (DG); * 13-Dec-2007 : Added testGenerateURL() and testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardCategoryURLGenerator} class. */ public class StandardCategoryURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardCategoryURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardCategoryURLGeneratorTests(String name) { super(name); } /** * Some tests for the generateURL() method. */ public void testGenerateURL() { StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "R1", "C1"); dataset.addValue(2.0, "R2", "C2"); dataset.addValue(3.0, "R&", "C&"); assertEquals("index.html?series=R1&category=C1", g1.generateURL(dataset, 0, 0)); assertEquals("index.html?series=R1&category=C2", g1.generateURL(dataset, 0, 1)); assertEquals("index.html?series=R2&category=C2", g1.generateURL(dataset, 1, 1)); assertEquals("index.html?series=R%26&category=C%26", g1.generateURL(dataset, 2, 2)); } /** * Checks that the class does not implement PublicCloneable (the generator * is immutable, so cloning is not necessary). */ public void testPublicCloneable() { StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(); assertFalse(g1 instanceof PublicCloneable); } /** * Some tests for the equals() method. */ public void testEquals() { StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(); StandardCategoryURLGenerator g2 = new StandardCategoryURLGenerator(); assertTrue(g1.equals(g2)); g1 = new StandardCategoryURLGenerator("index2.html?"); assertFalse(g1.equals(g2)); g2 = new StandardCategoryURLGenerator("index2.html?"); assertTrue(g1.equals(g2)); g1 = new StandardCategoryURLGenerator("index2.html?", "A", "B"); assertFalse(g1.equals(g2)); g2 = new StandardCategoryURLGenerator("index2.html?", "A", "B"); assertTrue(g1.equals(g2)); g1 = new StandardCategoryURLGenerator("index2.html?", "A", "C"); assertFalse(g1.equals(g2)); g2 = new StandardCategoryURLGenerator("index2.html?", "A", "C"); assertTrue(g1.equals(g2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator( "index.html?"); StandardCategoryURLGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); g2 = (StandardCategoryURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/StandardPieURLGeneratorTests.java0000644000175000017500000001336311173030414032735 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * StandardPieURLGeneratorTests.java * --------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2003 : Version 1 (DG); * 06-Jan-2003 : Added a test for URL generation (DG); * 24-Nov-2006 : New equals() test (DG); * 17-Apr-2007 : Added additional check to testURL() (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.StandardPieURLGenerator; import org.jfree.data.general.DefaultPieDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardPieURLGenerator} class. */ public class StandardPieURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardPieURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardPieURLGeneratorTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { StandardPieURLGenerator g1 = new StandardPieURLGenerator(); StandardPieURLGenerator g2 = new StandardPieURLGenerator(); assertTrue(g1.equals(g2)); g1 = new StandardPieURLGenerator("prefix", "category", "index"); assertFalse(g1.equals(g2)); g2 = new StandardPieURLGenerator("prefix", "category", "index"); assertTrue(g1.equals(g2)); g1 = new StandardPieURLGenerator("prefix2", "category", "index"); assertFalse(g1.equals(g2)); g2 = new StandardPieURLGenerator("prefix2", "category", "index"); assertTrue(g1.equals(g2)); g1 = new StandardPieURLGenerator("prefix2", "category2", "index"); assertFalse(g1.equals(g2)); g2 = new StandardPieURLGenerator("prefix2", "category2", "index"); assertTrue(g1.equals(g2)); g1 = new StandardPieURLGenerator("prefix2", "category2", "index2"); assertFalse(g1.equals(g2)); g2 = new StandardPieURLGenerator("prefix2", "category2", "index2"); assertTrue(g1.equals(g2)); g1 = new StandardPieURLGenerator("prefix2", "category2", null); assertFalse(g1.equals(g2)); g2 = new StandardPieURLGenerator("prefix2", "category2", null); assertTrue(g1.equals(g2)); } /** * Checks that the class does not implement PublicCloneable (the generator * is immutable). */ public void testPublicCloneable() { StandardPieURLGenerator g1 = new StandardPieURLGenerator( "index.html?", "cat"); assertFalse(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardPieURLGenerator g1 = new StandardPieURLGenerator( "index.html?", "cat"); StandardPieURLGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (StandardPieURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Test that the generated URL is as expected. */ public void testURL() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Alpha '1'", new Double(5.0)); dataset.setValue("Beta", new Double(5.5)); StandardPieURLGenerator g1 = new StandardPieURLGenerator( "chart.jsp", "category"); String url = g1.generateURL(dataset, "Beta", 0); assertEquals("chart.jsp?category=Beta&pieIndex=0", url); url = g1.generateURL(dataset, "Alpha '1'", 0); assertEquals("chart.jsp?category=Alpha+%271%27&pieIndex=0", url); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/StandardXYURLGeneratorTests.java0000644000175000017500000000702411173030414032555 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * StandardXYURLGeneratorTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.StandardXYURLGenerator; import org.jfree.util.PublicCloneable; /** * Tests for the {@link StandardXYURLGenerator} class. */ public class StandardXYURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardXYURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardXYURLGeneratorTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?"); StandardXYURLGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); g2 = (StandardXYURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Checks that the class does not implement PublicCloneable (the generator * is immutable). */ public void testPublicCloneable() { StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?"); assertFalse(g1 instanceof PublicCloneable); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/TimeSeriesURLGeneratorTests.java0000644000175000017500000001342611173030414032610 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * TimeSeriesURLGeneratorTests.java * -------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Apr-2007 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.chart.urls.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.SimpleDateFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.urls.TimeSeriesURLGenerator; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link TimeSeriesURLGenerator} class. */ public class TimeSeriesURLGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimeSeriesURLGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimeSeriesURLGeneratorTests(String name) { super(name); } /** * A basic check for the generateURL() method. */ public void testGenerateURL() { TimeSeriesURLGenerator g = new TimeSeriesURLGenerator(); DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series '1'", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); String s = g.generateURL(dataset, 0, 0); assertTrue(s.startsWith("index.html?series=Series+%271%27&item=")); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator(); TimeSeriesURLGenerator g2 = new TimeSeriesURLGenerator(); assertTrue(g1.equals(g2)); g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yyyy"), "prefix", "series", "item"); assertFalse(g1.equals(g2)); g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yyyy"), "prefix", "series", "item"); assertTrue(g1.equals(g2)); g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix", "series", "item"); assertFalse(g1.equals(g2)); g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix", "series", "item"); assertTrue(g1.equals(g2)); g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", "series", "item"); assertFalse(g1.equals(g2)); g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", "series", "item"); assertTrue(g1.equals(g2)); g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", "series1", "item"); assertFalse(g1.equals(g2)); g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", "series1", "item"); assertTrue(g1.equals(g2)); g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", "series1", "item1"); assertFalse(g1.equals(g2)); g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", "series1", "item1"); assertTrue(g1.equals(g2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator(); TimeSeriesURLGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); g2 = (TimeSeriesURLGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2); } /** * Checks that the class does not implement PublicCloneable (the generator * is immutable). */ public void testPublicCloneable() { TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator(); assertFalse(g1 instanceof PublicCloneable); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/UrlsPackageTests.java0000644000175000017500000000620011173030414030476 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * UrlsPackageTests.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 21-Mar-2003 : Version 1 (DG); * 13-Aug-2003 : Added new tests (DG); * 01-Mar-2004 : Added StandardXYURLGeneratorTests (DG); * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); * 17-Apr-2007 : Added TimeSeriesURLGeneratorTests (DG); * 11-Apr-2008 : Added new tests (DG); * 23-Apr-2008 : Added CustomCategoryURLGeneratorTests (DG); * */ package org.jfree.chart.urls.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.urls package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class UrlsPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.urls"); suite.addTestSuite(CustomCategoryURLGeneratorTests.class); suite.addTestSuite(CustomPieURLGeneratorTests.class); suite.addTestSuite(CustomXYURLGeneratorTests.class); suite.addTestSuite(StandardCategoryURLGeneratorTests.class); suite.addTestSuite(StandardPieURLGeneratorTests.class); suite.addTestSuite(StandardXYURLGeneratorTests.class); suite.addTestSuite(TimeSeriesURLGeneratorTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public UrlsPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/urls/junit/package.html0000644000175000017500000000016311173030414026672 0ustar vincentvincent JUnit tests. libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/util/0000755000175000017500000000000011173030414023250 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/util/junit/0000755000175000017500000000000011216245562024413 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/chart/util/junit/LineUtilitiesTests.java0000644000175000017500000001177011173030414031060 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * LineUtilitiesTests.java * ----------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Nov-2008 : Version 1 (DG); * */ package org.jfree.chart.util.junit; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.util.LineUtilities; /** * Tests for the {@link LineUtilities} class. */ public class LineUtilitiesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LineUtilitiesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LineUtilitiesTests(String name) { super(name); } private boolean lineEquals(Line2D line, double x1, double y1, double x2, double y2) { boolean result = true; double epsilon = 0.0000000001; if (Math.abs(line.getX1() - x1) > epsilon) result = false; if (Math.abs(line.getY1() - y1) > epsilon) result = false; if (Math.abs(line.getX2() - x2) > epsilon) result = false; if (Math.abs(line.getY2() - y2) > epsilon) result = false; if (result == false) { System.out.println(line.getX1() + ", " + line.getY1() + ", " + line.getX2() + ", " + line.getY2()); } return result; } public void testClipLine() { Rectangle2D rect = new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0); Line2D line = new Line2D.Double(); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.0, 0.0, 0.0, 0.0)); line.setLine(0.5, 0.5, 0.6, 0.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 0.6)); line.setLine(0.5, 0.5, 1.6, 0.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 1.6, 0.6)); line.setLine(0.5, 0.5, 2.6, 0.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 2.6, 0.6)); line.setLine(0.5, 0.5, 0.6, 1.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 1.6)); line.setLine(0.5, 0.5, 1.6, 1.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.0, 1.6, 1.6)); line.setLine(0.5, 0.5, 2.6, 1.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.4545454545454546, 1.0, 2.0, 1.2857142857142858)); line.setLine(0.5, 0.5, 0.5, 2.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 0.5, 2.6)); line.setLine(0.5, 0.5, 1.5, 2.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.55, 1.2142857142857142, 2.0)); line.setLine(0.5, 0.5, 2.5, 2.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.025, 1.9285714285714284, 2.0)); line.setLine(0.5, 0.5, 1.5, 1.5); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.0, 1.5, 1.5)); line.setLine(2.5, 1.0, 1.5, 1.5); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 2.0, 1.25, 1.5, 1.5)); line.setLine(1.5, 1.5, 2.5, 1.0); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.5, 1.5, 2.0, 1.25)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/util/junit/LogFormatTests.java0000644000175000017500000001144411173030414030165 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * LogFormatTests.java * ------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Feb-2008 : Version 1 (DG); * 14-Jan-2009 : Updated testEquals() for new field (DG); * */ package org.jfree.chart.util.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.DecimalFormat; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.util.LogFormat; /** * Tests for the {@link LogFormat} class. */ public class LogFormatTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(LogFormatTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public LogFormatTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = new LogFormat(10.0, "10", true); assertEquals(f1, f2); f1 = new LogFormat(11.0, "10", true); assertFalse(f1.equals(f2)); f2 = new LogFormat(11.0, "10", true); assertTrue(f1.equals(f2)); f1 = new LogFormat(11.0, "11", true); assertFalse(f1.equals(f2)); f2 = new LogFormat(11.0, "11", true); assertTrue(f1.equals(f2)); f1 = new LogFormat(11.0, "11", false); assertFalse(f1.equals(f2)); f2 = new LogFormat(11.0, "11", false); assertTrue(f1.equals(f2)); f1.setExponentFormat(new DecimalFormat("0.000")); assertFalse(f1.equals(f2)); f2.setExponentFormat(new DecimalFormat("0.000")); assertTrue(f1.equals(f2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = new LogFormat(10.0, "10", true); assertTrue(f1.equals(f2)); int h1 = f1.hashCode(); int h2 = f2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = null; try { f2 = (LogFormat) f1.clone(); } catch (Exception e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); f2 = (LogFormat) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(f1, f2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/util/junit/RelativeDateFormatTests.java0000644000175000017500000001572711173030414032025 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * RelativeDateFormatTests.java * ---------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Nov-2006 : Version 1 (DG); * 15-Feb-2008 : Added tests for negative dates (DG); * 01-Sep-2008 : Added a test for hours and minutes with leading zeroes (DG); * */ package org.jfree.chart.util.junit; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.chart.util.RelativeDateFormat; /** * Tests for the {@link RelativeDateFormat} class. */ public class RelativeDateFormatTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RelativeDateFormatTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RelativeDateFormatTests(String name) { super(name); } /** * Some checks for the formatting. */ public void testFormat() { RelativeDateFormat rdf = new RelativeDateFormat(); String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); assertEquals("2h2m2.500s", s); } /** * Test that we can configure the RelativeDateFormat to show * hh:mm:ss. */ public void test2033092() { RelativeDateFormat rdf = new RelativeDateFormat(); rdf.setShowZeroDays(false); rdf.setShowZeroHours(false); rdf.setMinuteSuffix(":"); rdf.setHourSuffix(":"); rdf.setSecondSuffix(""); DecimalFormat hoursFormatter = new DecimalFormat(); hoursFormatter.setMaximumFractionDigits(0); hoursFormatter.setMaximumIntegerDigits(2); hoursFormatter.setMinimumIntegerDigits(2); rdf.setHourFormatter(hoursFormatter); DecimalFormat minsFormatter = new DecimalFormat(); minsFormatter.setMaximumFractionDigits(0); minsFormatter.setMaximumIntegerDigits(2); minsFormatter.setMinimumIntegerDigits(2); rdf.setMinuteFormatter(minsFormatter); DecimalFormat secondsFormatter = new DecimalFormat(); secondsFormatter.setMaximumFractionDigits(0); secondsFormatter.setMaximumIntegerDigits(2); secondsFormatter.setMinimumIntegerDigits(2); rdf.setSecondFormatter(secondsFormatter); String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); assertEquals("02:02:02", s); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { RelativeDateFormat df1 = new RelativeDateFormat(); RelativeDateFormat df2 = new RelativeDateFormat(); assertEquals(df1, df2); df1.setBaseMillis(123L); assertFalse(df1.equals(df2)); df2.setBaseMillis(123L); assertTrue(df1.equals(df2)); df1.setDayFormatter(new DecimalFormat("0%")); assertFalse(df1.equals(df2)); df2.setDayFormatter(new DecimalFormat("0%")); assertTrue(df1.equals(df2)); df1.setDaySuffix("D"); assertFalse(df1.equals(df2)); df2.setDaySuffix("D"); assertTrue(df1.equals(df2)); df1.setHourFormatter(new DecimalFormat("0%")); assertFalse(df1.equals(df2)); df2.setHourFormatter(new DecimalFormat("0%")); assertTrue(df1.equals(df2)); df1.setHourSuffix("H"); assertFalse(df1.equals(df2)); df2.setHourSuffix("H"); assertTrue(df1.equals(df2)); df1.setMinuteFormatter(new DecimalFormat("0%")); assertFalse(df1.equals(df2)); df2.setMinuteFormatter(new DecimalFormat("0%")); assertTrue(df1.equals(df2)); df1.setMinuteSuffix("M"); assertFalse(df1.equals(df2)); df2.setMinuteSuffix("M"); assertTrue(df1.equals(df2)); df1.setSecondSuffix("S"); assertFalse(df1.equals(df2)); df2.setSecondSuffix("S"); assertTrue(df1.equals(df2)); df1.setShowZeroDays(!df1.getShowZeroDays()); assertFalse(df1.equals(df2)); df2.setShowZeroDays(!df2.getShowZeroDays()); assertTrue(df1.equals(df2)); df1.setSecondFormatter(new DecimalFormat("0.0")); assertFalse(df1.equals(df2)); df2.setSecondFormatter(new DecimalFormat("0.0")); assertTrue(df1.equals(df2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { RelativeDateFormat df1 = new RelativeDateFormat(123L); RelativeDateFormat df2 = new RelativeDateFormat(123L); assertTrue(df1.equals(df2)); int h1 = df1.hashCode(); int h2 = df2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { NumberFormat nf = new DecimalFormat("0"); RelativeDateFormat df1 = new RelativeDateFormat(); df1.setSecondFormatter(nf); RelativeDateFormat df2 = null; df2 = (RelativeDateFormat) df1.clone(); assertTrue(df1 != df2); assertTrue(df1.getClass() == df2.getClass()); assertTrue(df1.equals(df2)); // is the clone independent nf.setMinimumFractionDigits(2); assertFalse(df1.equals(df2)); } /** * Some tests for negative dates. */ public void testNegative() { NumberFormat nf = new DecimalFormat("0"); RelativeDateFormat df1 = new RelativeDateFormat(); df1.setSecondFormatter(nf); assertEquals("-0h0m1s", df1.format(new Date(-1000L))); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/chart/util/junit/UtilPackageTests.java0000644000175000017500000000517411173030414030467 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * UtilPackageTests.java * --------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 23-Nov-2006 : Version 1 (DG); * 08-Apr-2008 : Added LogFormatTests (DG); * 05-Nov-2008 : Added LineUtilitiesTests (DG); * */ package org.jfree.chart.util.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * A collection of tests for the org.jfree.chart.util package. *

      * These tests can be run using JUnit (http://www.junit.org). */ public class UtilPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.util"); suite.addTestSuite(LineUtilitiesTests.class); suite.addTestSuite(LogFormatTests.class); suite.addTestSuite(RelativeDateFormatTests.class); return suite; } /** * Constructs the test suite. * * @param name the suite name. */ public UtilPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/0000755000175000017500000000000011173030414022103 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/0000755000175000017500000000000011173030414023720 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/0000755000175000017500000000000011216245562025063 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/CategoryToPieDatasetTests.java0000644000175000017500000002025311173030414032765 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * CategoryToPieDatasetTests.java * ------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Jul-2006 : Version 1 (DG); * 01-Aug-2006 : Added testGetIndex() method (DG); * */ package org.jfree.data.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.category.CategoryToPieDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DefaultPieDataset; import org.jfree.util.TableOrder; /** * Tests for the {@link CategoryToPieDataset} class. */ public class CategoryToPieDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryToPieDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryToPieDatasetTests(String name) { super(name); } /** * Some tests for the constructor. */ public void testConstructor() { // try a null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); assertNull(p1.getUnderlyingDataset()); assertEquals(p1.getItemCount(), 0); assertTrue(p1.getKeys().isEmpty()); assertNull(p1.getValue("R1")); } /** * Some checks for the getValue() method. */ public void testGetValue() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(d1.getValue("C1"), new Double(1.1)); assertEquals(d1.getValue("C2"), new Double(2.2)); // check negative index throws exception try { /* Number n = */ d1.getValue(-1); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // check index == getItemCount() throws exception try { /* Number n = */ d1.getValue(d1.getItemCount()); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // test null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); try { /* Number n = */ p1.getValue(0); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } } /** * Some checks for the getKey(int) method. */ public void testGetKey() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(d1.getKey(0), "C1"); assertEquals(d1.getKey(1), "C2"); // check negative index throws exception try { /* Number n = */ d1.getKey(-1); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // check index == getItemCount() throws exception try { /* Number n = */ d1.getKey(d1.getItemCount()); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // test null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); try { /* Number n = */ p1.getKey(0); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } } /** * Some checks for the getIndex() method. */ public void testGetIndex() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(0, d1.getIndex("C1")); assertEquals(1, d1.getIndex("C2")); assertEquals(-1, d1.getIndex("XX")); // try null boolean pass = false; try { d1.getIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * For datasets, the equals() method just checks keys and values. */ public void testEquals() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_COLUMN, 1); DefaultPieDataset d2 = new DefaultPieDataset(); d2.setValue("R1", 2.2); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_COLUMN, 1); CategoryToPieDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (CategoryToPieDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // regular equality for the datasets doesn't check the fields, just // the data values...so let's check some more things... assertEquals(d1.getUnderlyingDataset(), d2.getUnderlyingDataset()); assertEquals(d1.getExtractType(), d2.getExtractType()); assertEquals(d1.getExtractIndex(), d2.getExtractIndex()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/DataCategoryPackageTests.java0000644000175000017500000000613711173030414032571 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------- * DataCategoryPackageTests.java * ----------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * * Changes * ------- * 23-Aug-2004 : Restructured org.jfree.data package (DG); * 18-Jan-2005 : Added main() method (DG); * ------------- JFREECHART 1.0.x --------------------------------------------- * 26-Jul-2006 : Added CategoryToPieDatasetTests (DG); * 08-Mar-2007 : Added DefaultIntervalCategoryDatasetTests (DG); * 09-May-2008 : Added SlidingCategoryDatasetTests (DG); * */ package org.jfree.data.category.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data.category package that can * be run using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataCategoryPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.category"); suite.addTestSuite(CategoryToPieDatasetTests.class); suite.addTestSuite(DefaultCategoryDatasetTests.class); suite.addTestSuite(DefaultIntervalCategoryDatasetTests.class); suite.addTestSuite(SlidingCategoryDatasetTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataCategoryPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java0000644000175000017500000002767211173030414033345 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * DefaultCategoryDatasetTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Mar-2004 : Version 1 (DG); * 08-Mar-2007 : Added testCloning() (DG); * 21-Nov-2007 : Added testBug1835955() method (DG); * 09-May-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.data.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.UnknownKeyException; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link DefaultCategoryDataset} class. */ public class DefaultCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultCategoryDatasetTests(String name) { super(name); } /** * Some checks for the getValue() method. */ public void testGetValue() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); assertEquals(new Double(1.0), d.getValue("R1", "C1")); boolean pass = false; try { d.getValue("XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.getValue("R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * A simple check for the getValue(int, int) method. */ public void testGetValue2() { DefaultCategoryDataset d = new DefaultCategoryDataset(); boolean pass = false; try { /* Number n =*/ d.getValue(0, 0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some checks for the incrementValue() method. */ public void testIncrementValue() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.incrementValue(2.0, "R1", "C1"); assertEquals(new Double(3.0), d.getValue("R1", "C1")); // increment a null value d.addValue(null, "R2", "C1"); d.incrementValue(2.0, "R2", "C1"); assertEquals(new Double(2.0), d.getValue("R2", "C1")); // increment an unknown row boolean pass = false; try { d.incrementValue(1.0, "XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // increment an unknown column pass = false; try { d.incrementValue(1.0, "R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Some tests for the getRowCount() method. */ public void testGetRowCount() { DefaultCategoryDataset d = new DefaultCategoryDataset(); assertTrue(d.getRowCount() == 0); d.addValue(1.0, "R1", "C1"); assertTrue(d.getRowCount() == 1); d.addValue(1.0, "R2", "C1"); assertTrue(d.getRowCount() == 2); d.addValue(2.0, "R2", "C1"); assertTrue(d.getRowCount() == 2); // a row of all null values is still counted... d.setValue(null, "R2", "C1"); assertTrue(d.getRowCount() == 2); } /** * Some tests for the getColumnCount() method. */ public void testGetColumnCount() { DefaultCategoryDataset d = new DefaultCategoryDataset(); assertTrue(d.getColumnCount() == 0); d.addValue(1.0, "R1", "C1"); assertTrue(d.getColumnCount() == 1); d.addValue(1.0, "R1", "C2"); assertTrue(d.getColumnCount() == 2); d.addValue(2.0, "R1", "C2"); assertTrue(d.getColumnCount() == 2); // a column of all null values is still counted... d.setValue(null, "R1", "C2"); assertTrue(d.getColumnCount() == 2); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultCategoryDataset d1 = new DefaultCategoryDataset(); d1.setValue(23.4, "R1", "C1"); DefaultCategoryDataset d2 = new DefaultCategoryDataset(); d2.setValue(23.4, "R1", "C1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.setValue(36.5, "R1", "C2"); assertFalse(d1.equals(d2)); d2.setValue(36.5, "R1", "C2"); assertTrue(d1.equals(d2)); d1.setValue(null, "R1", "C1"); assertFalse(d1.equals(d2)); d2.setValue(null, "R1", "C1"); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultCategoryDataset d1 = new DefaultCategoryDataset(); d1.setValue(23.4, "R1", "C1"); DefaultCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Some checks for the addValue() method. */ public void testAddValue() { DefaultCategoryDataset d1 = new DefaultCategoryDataset(); d1.addValue(null, "R1", "C1"); assertNull(d1.getValue("R1", "C1")); d1.addValue(new Double(1.0), "R2", "C1"); assertEquals(new Double(1.0), d1.getValue("R2", "C1")); boolean pass = false; try { d1.addValue(new Double(1.1), null, "C2"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some basic checks for the removeValue() method. */ public void testRemoveValue() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.removeValue("R1", "C1"); d.addValue(new Double(1.0), "R1", "C1"); d.removeValue("R1", "C1"); assertEquals(0, d.getRowCount()); assertEquals(0, d.getColumnCount()); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(2.0), "R2", "C1"); d.removeValue("R1", "C1"); assertEquals(new Double(2.0), d.getValue(0, 0)); boolean pass = false; try { d.removeValue(null, "C1"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { d.removeValue("R1", null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Confirm that cloning works. */ public void testCloning() { DefaultCategoryDataset d1 = new DefaultCategoryDataset(); DefaultCategoryDataset d2 = null; try { d2 = (DefaultCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // try a dataset with some content... d1.addValue(1.0, "R1", "C1"); d1.addValue(2.0, "R1", "C2"); try { d2 = (DefaultCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.addValue(3.0, "R1", "C1"); assertFalse(d1.equals(d2)); d2.addValue(3.0, "R1", "C1"); assertTrue(d1.equals(d2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { DefaultCategoryDataset d = new DefaultCategoryDataset(); assertTrue(d instanceof PublicCloneable); } private static final double EPSILON = 0.0000000001; /** * A test for bug 1835955. */ public void testBug1835955() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R2", "C2"); d.removeColumn("C2"); d.addValue(3.0, "R2", "C2"); assertEquals(3.0, d.getValue("R2", "C2").doubleValue(), EPSILON); } /** * Some checks for the removeColumn(Comparable) method. */ public void testRemoveColumn() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R2", "C2"); assertEquals(2, d.getColumnCount()); d.removeColumn("C2"); assertEquals(1, d.getColumnCount()); boolean pass = false; try { d.removeColumn("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.removeColumn(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeRow(Comparable) method. */ public void testRemoveRow() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R2", "C2"); assertEquals(2, d.getRowCount()); d.removeRow("R2"); assertEquals(1, d.getRowCount()); boolean pass = false; try { d.removeRow("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.removeRow(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/DefaultIntervalCategoryDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/DefaultIntervalCategoryDatasetTes0000644000175000017500000004314211173030414033551 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------------- * DefaultIntervalCategoryDatasetTests.java * ---------------------------------------- * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Mar-2007 : Version 1 (DG); * 25-Feb-2008 : Added new tests to check behaviour of an empty dataset (DG); * 11-Feb-2009 : Fixed locale-sensitive failures (DG); * */ package org.jfree.data.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.DataUtilities; import org.jfree.data.UnknownKeyException; import org.jfree.data.category.DefaultIntervalCategoryDataset; /** * Tests for the {@link DefaultIntervalCategoryDataset} class. */ public class DefaultIntervalCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultIntervalCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultIntervalCategoryDatasetTests(String name) { super(name); } /** * Some checks for the getValue() method. */ public void testGetValue() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); assertEquals(new Double(0.1), d.getStartValue("Series 1", "Category 1")); assertEquals(new Double(0.2), d.getStartValue("Series 1", "Category 2")); assertEquals(new Double(0.3), d.getStartValue("Series 1", "Category 3")); assertEquals(new Double(0.3), d.getStartValue("Series 2", "Category 1")); assertEquals(new Double(0.4), d.getStartValue("Series 2", "Category 2")); assertEquals(new Double(0.5), d.getStartValue("Series 2", "Category 3")); assertEquals(new Double(0.5), d.getEndValue("Series 1", "Category 1")); assertEquals(new Double(0.6), d.getEndValue("Series 1", "Category 2")); assertEquals(new Double(0.7), d.getEndValue("Series 1", "Category 3")); assertEquals(new Double(0.7), d.getEndValue("Series 2", "Category 1")); assertEquals(new Double(0.8), d.getEndValue("Series 2", "Category 2")); assertEquals(new Double(0.9), d.getEndValue("Series 2", "Category 3")); boolean pass = false; try { d.getValue("XX", "Category 1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.getValue("Series 1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Some tests for the getRowCount() method. */ public void testGetRowAndColumnCount() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset(starts, ends); assertEquals(2, d.getRowCount()); assertEquals(3, d.getColumnCount()); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { double[] starts_S1A = new double[] {0.1, 0.2, 0.3}; double[] starts_S2A = new double[] {0.3, 0.4, 0.5}; double[] ends_S1A = new double[] {0.5, 0.6, 0.7}; double[] ends_S2A = new double[] {0.7, 0.8, 0.9}; double[][] startsA = new double[][] {starts_S1A, starts_S2A}; double[][] endsA = new double[][] {ends_S1A, ends_S2A}; DefaultIntervalCategoryDataset dA = new DefaultIntervalCategoryDataset(startsA, endsA); double[] starts_S1B = new double[] {0.1, 0.2, 0.3}; double[] starts_S2B = new double[] {0.3, 0.4, 0.5}; double[] ends_S1B = new double[] {0.5, 0.6, 0.7}; double[] ends_S2B = new double[] {0.7, 0.8, 0.9}; double[][] startsB = new double[][] {starts_S1B, starts_S2B}; double[][] endsB = new double[][] {ends_S1B, ends_S2B}; DefaultIntervalCategoryDataset dB = new DefaultIntervalCategoryDataset(startsB, endsB); assertTrue(dA.equals(dB)); assertTrue(dB.equals(dA)); // check that two empty datasets are equal DefaultIntervalCategoryDataset empty1 = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); DefaultIntervalCategoryDataset empty2 = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertTrue(empty1.equals(empty2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset(starts, ends); DefaultIntervalCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultIntervalCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Confirm that cloning works. */ public void testCloning() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); DefaultIntervalCategoryDataset d2 = null; try { d2 = (DefaultIntervalCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. d1.setStartValue(0, "Category 1", new Double(0.99)); assertFalse(d1.equals(d2)); d2.setStartValue(0, "Category 1", new Double(0.99)); assertTrue(d1.equals(d2)); } /** * A check to ensure that an empty dataset can be cloned. */ public void testCloning2() { DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); DefaultIntervalCategoryDataset d2 = null; try { d2 = (DefaultIntervalCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Some basic checks for the setStartValue() method. */ public void testSetStartValue() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); d1.setStartValue(0, "Category 2", new Double(99.9)); assertEquals(new Double(99.9), d1.getStartValue("Series 1", "Category 2")); boolean pass = false; try { d1.setStartValue(-1, "Category 2", new Double(99.9)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { d1.setStartValue(2, "Category 2", new Double(99.9)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some basic checks for the setEndValue() method. */ public void testSetEndValue() { double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; double[][] starts = new double[][] {starts_S1, starts_S2}; double[][] ends = new double[][] {ends_S1, ends_S2}; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( new Comparable[] {"Series 1", "Series 2"}, new Comparable[] {"Category 1", "Category 2", "Category 3"}, DataUtilities.createNumberArray2D(starts), DataUtilities.createNumberArray2D(ends)); d1.setEndValue(0, "Category 2", new Double(99.9)); assertEquals(new Double(99.9), d1.getEndValue("Series 1", "Category 2")); boolean pass = false; try { d1.setEndValue(-1, "Category 2", new Double(99.9)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { d1.setEndValue(2, "Category 2", new Double(99.9)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSeriesCount() method. */ public void testGetSeriesCount() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(0, empty.getSeriesCount()); } /** * Some checks for the getCategoryCount() method. */ public void testGetCategoryCount() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(0, empty.getCategoryCount()); } /** * Some checks for the getSeriesIndex() method. */ public void testGetSeriesIndex() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(-1, empty.getSeriesIndex("ABC")); } /** * Some checks for the getRowIndex() method. */ public void testGetRowIndex() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(-1, empty.getRowIndex("ABC")); } /** * Some checks for the setSeriesKeys() method. */ public void testSetSeriesKeys() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); boolean pass = true; try { empty.setSeriesKeys(new String[0]); } catch (RuntimeException e) { pass = false; } assertTrue(pass); } /** * Some checks for the getCategoryIndex() method. */ public void testGetCategoryIndex() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(-1, empty.getCategoryIndex("ABC")); } /** * Some checks for the getColumnIndex() method. */ public void testGetColumnIndex() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(-1, empty.getColumnIndex("ABC")); } /** * Some checks for the setCategoryKeys() method. */ public void testSetCategoryKeys() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); boolean pass = true; try { empty.setCategoryKeys(new String[0]); } catch (RuntimeException e) { pass = false; } assertTrue(pass); } /** * Some checks for the getColumnKeys() method. */ public void testGetColumnKeys() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); List keys = empty.getColumnKeys(); assertEquals(0, keys.size()); } /** * Some checks for the getRowKeys() method. */ public void testGetRowKeys() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); List keys = empty.getRowKeys(); assertEquals(0, keys.size()); } /** * Some checks for the getColumnCount() method. */ public void testGetColumnCount() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(0, empty.getColumnCount()); } /** * Some checks for the getRowCount() method. */ public void testGetRowCount() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(0, empty.getColumnCount()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/category/junit/SlidingCategoryDatasetTests.java0000644000175000017500000002412511173030414033340 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * SlidingCategoryDatasetTests.java * -------------------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-May-2008 : Version 1 (DG); * 15-Mar-2009 : Added testGetColumnKeys() (DG); * */ package org.jfree.data.category.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.UnknownKeyException; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.SlidingCategoryDataset; /** * Tests for the {@link SlidingCategoryDataset} class. */ public class SlidingCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SlidingCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SlidingCategoryDatasetTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { DefaultCategoryDataset u1 = new DefaultCategoryDataset(); u1.addValue(1.0, "R1", "C1"); u1.addValue(2.0, "R1", "C2"); SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5); DefaultCategoryDataset u2 = new DefaultCategoryDataset(); u2.addValue(1.0, "R1", "C1"); u2.addValue(2.0, "R1", "C2"); SlidingCategoryDataset d2 = new SlidingCategoryDataset(u2, 0, 5); assertTrue(d1.equals(d2)); d1.setFirstCategoryIndex(1); assertFalse(d1.equals(d2)); d2.setFirstCategoryIndex(1); assertTrue(d1.equals(d2)); d1.setMaximumCategoryCount(99); assertFalse(d1.equals(d2)); d2.setMaximumCategoryCount(99); assertTrue(d1.equals(d2)); u1.addValue(3.0, "R1", "C3"); assertFalse(d1.equals(d2)); u2.addValue(3.0, "R1", "C3"); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultCategoryDataset u1 = new DefaultCategoryDataset(); u1.addValue(1.0, "R1", "C1"); u1.addValue(2.0, "R1", "C2"); SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5); SlidingCategoryDataset d2 = null; try { d2 = (SlidingCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // basic check for independence u1.addValue(3.0, "R1", "C3"); assertFalse(d1.equals(d2)); DefaultCategoryDataset u2 = (DefaultCategoryDataset) d2.getUnderlyingDataset(); u2.addValue(3.0, "R1", "C3"); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultCategoryDataset u1 = new DefaultCategoryDataset(); u1.addValue(1.0, "R1", "C1"); u1.addValue(2.0, "R1", "C2"); SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5); SlidingCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (SlidingCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // basic check for independence u1.addValue(3.0, "R1", "C3"); assertFalse(d1.equals(d2)); DefaultCategoryDataset u2 = (DefaultCategoryDataset) d2.getUnderlyingDataset(); u2.addValue(3.0, "R1", "C3"); assertTrue(d1.equals(d2)); } /** * Some checks for the getColumnCount() method. */ public void testGetColumnCount() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 10, 2); assertEquals(0, dataset.getColumnCount()); underlying.addValue(1.0, "R1", "C1"); assertEquals(0, dataset.getColumnCount()); underlying.addValue(1.0, "R1", "C2"); assertEquals(0, dataset.getColumnCount()); dataset.setFirstCategoryIndex(0); assertEquals(2, dataset.getColumnCount()); underlying.addValue(1.0, "R1", "C3"); assertEquals(2, dataset.getColumnCount()); dataset.setFirstCategoryIndex(2); assertEquals(1, dataset.getColumnCount()); underlying.clear(); assertEquals(0, dataset.getColumnCount()); } /** * Some checks for the getRowCount() method. */ public void testGetRowCount() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 10, 5); assertEquals(0, dataset.getRowCount()); underlying.addValue(1.0, "R1", "C1"); assertEquals(1, dataset.getRowCount()); underlying.clear(); assertEquals(0, dataset.getRowCount()); } /** * Some checks for the getColumnIndex() method. */ public void testGetColumnIndex() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.0, "R1", "C1"); underlying.addValue(2.0, "R1", "C2"); underlying.addValue(3.0, "R1", "C3"); underlying.addValue(4.0, "R1", "C4"); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 1, 2); assertEquals(-1, dataset.getColumnIndex("C1")); assertEquals(0, dataset.getColumnIndex("C2")); assertEquals(1, dataset.getColumnIndex("C3")); assertEquals(-1, dataset.getColumnIndex("C4")); } /** * Some checks for the getRowIndex() method. */ public void testGetRowIndex() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.0, "R1", "C1"); underlying.addValue(2.0, "R2", "C1"); underlying.addValue(3.0, "R3", "C1"); underlying.addValue(4.0, "R4", "C1"); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 1, 2); assertEquals(0, dataset.getRowIndex("R1")); assertEquals(1, dataset.getRowIndex("R2")); assertEquals(2, dataset.getRowIndex("R3")); assertEquals(3, dataset.getRowIndex("R4")); } /** * Some checks for the getValue() method. */ public void testGetValue() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.0, "R1", "C1"); underlying.addValue(2.0, "R1", "C2"); underlying.addValue(3.0, "R1", "C3"); underlying.addValue(4.0, "R1", "C4"); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 1, 2); assertEquals(new Double(2.0), dataset.getValue("R1", "C2")); assertEquals(new Double(3.0), dataset.getValue("R1", "C3")); boolean pass = false; try { dataset.getValue("R1", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { dataset.getValue("R1", "C4"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getColumnKeys() method. */ public void testGetColumnKeys() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.0, "R1", "C1"); underlying.addValue(2.0, "R1", "C2"); underlying.addValue(3.0, "R1", "C3"); underlying.addValue(4.0, "R1", "C4"); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 1, 2); List keys = dataset.getColumnKeys(); assertTrue(keys.contains("C2")); assertTrue(keys.contains("C3")); assertEquals(2, keys.size()); dataset.setFirstCategoryIndex(3); keys = dataset.getColumnKeys(); assertTrue(keys.contains("C4")); assertEquals(1, keys.size()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/0000755000175000017500000000000011173030414023220 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/0000755000175000017500000000000011216245562024363 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java0000644000175000017500000000570611173030414031372 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * GanttPackageTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jul-2004 : Version 1 (DG); * 12-Jan-2005 : Merged TaskSeriesCollectionTests2.java into * TaskSeriesCollectionTests.java (DG); * 18-Jan-2005 : Added main() method (DG); * 09-May-2008 : Added SlidingGanttCategoryDatasetTests (DG); * */ package org.jfree.data.gantt.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data.gantt package that can be * run using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataGanttPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.gantt"); suite.addTestSuite(SlidingGanttCategoryDatasetTests.class); suite.addTestSuite(TaskTests.class); suite.addTestSuite(TaskSeriesTests.class); suite.addTestSuite(TaskSeriesCollectionTests.class); suite.addTestSuite(XYTaskDatasetTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataGanttPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/SlidingGanttCategoryDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/SlidingGanttCategoryDatasetTests.jav0000644000175000017500000001474411173030414033503 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * SlidingGanttCategoryDatasetTests.java * ------------------------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-May-2008 : Version 1 (DG); * */ package org.jfree.data.gantt.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.gantt.SlidingGanttCategoryDataset; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; import org.jfree.data.gantt.TaskSeriesCollection; /** * Tests for the {@link SlidingGanttCategoryDataset} class. */ public class SlidingGanttCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SlidingGanttCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SlidingGanttCategoryDatasetTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); s1.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset( u1, 0, 5); TaskSeries s2 = new TaskSeries("Series"); s2.add(new Task("Task 1", new Date(0L), new Date(1L))); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); s2.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u2 = new TaskSeriesCollection(); u2.add(s2); SlidingGanttCategoryDataset d2 = new SlidingGanttCategoryDataset( u2, 0, 5); assertTrue(d1.equals(d2)); d1.setFirstCategoryIndex(1); assertFalse(d1.equals(d2)); d2.setFirstCategoryIndex(1); assertTrue(d1.equals(d2)); d1.setMaximumCategoryCount(99); assertFalse(d1.equals(d2)); d2.setMaximumCategoryCount(99); assertTrue(d1.equals(d2)); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset( u1, 0, 5); SlidingGanttCategoryDataset d2 = null; try { d2 = (SlidingGanttCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // basic check for independence s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); TaskSeriesCollection u2 = (TaskSeriesCollection) d2.getUnderlyingDataset(); TaskSeries s2 = u2.getSeries("Series"); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset( u1, 0, 5); SlidingGanttCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (SlidingGanttCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // basic check for independence s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); TaskSeriesCollection u2 = (TaskSeriesCollection) d2.getUnderlyingDataset(); TaskSeries s2 = u2.getSeries("Series"); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/TaskSeriesCollectionTests.java0000644000175000017500000005712211173030414032337 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * TaskSeriesCollectionTests.java * ------------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jul-2004 : Version 1 (DG); * 12-Jan-2005 : Added tests from TaskSeriesCollectionTests2.java (DG); * 08-Mar-2007 : Added testRemove() (DG); * */ package org.jfree.data.gantt.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; import org.jfree.data.gantt.TaskSeriesCollection; import org.jfree.data.time.SimpleTimePeriod; /** * Tests for the {@link TaskSeriesCollection} class. */ public class TaskSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TaskSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TaskSeriesCollectionTests(String name) { super(name); } /** * Creates a sample collection for testing purposes. * * @return A sample collection. */ private TaskSeriesCollection createCollection1() { TaskSeriesCollection result = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("S1"); s1.add(new Task("Task 1", new Date(1), new Date(2))); s1.add(new Task("Task 2", new Date(3), new Date(4))); result.add(s1); TaskSeries s2 = new TaskSeries("S2"); s2.add(new Task("Task 3", new Date(5), new Date(6))); result.add(s2); return result; } /** * Creates a sample collection for testing purposes. * * @return A sample collection. */ private TaskSeriesCollection createCollection2() { TaskSeriesCollection result = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("S1"); Task t1 = new Task("Task 1", new Date(10), new Date(20)); t1.addSubtask(new Task("Task 1A", new Date(10), new Date(15))); t1.addSubtask(new Task("Task 1B", new Date(16), new Date(20))); t1.setPercentComplete(0.10); s1.add(t1); Task t2 = new Task("Task 2", new Date(30), new Date(40)); t2.addSubtask(new Task("Task 2A", new Date(30), new Date(35))); t2.addSubtask(new Task("Task 2B", new Date(36), new Date(40))); t2.setPercentComplete(0.20); s1.add(t2); result.add(s1); TaskSeries s2 = new TaskSeries("S2"); Task t3 = new Task("Task 3", new Date(50), new Date(60)); t3.addSubtask(new Task("Task 3A", new Date(50), new Date(55))); t3.addSubtask(new Task("Task 3B", new Date(56), new Date(60))); t3.setPercentComplete(0.30); s2.add(t3); result.add(s2); return result; } /** * Creates a sample collection for testing purposes. * * @return A sample collection. */ private TaskSeriesCollection createCollection3() { // define subtasks Task sub1 = new Task("Sub1", new Date(11), new Date(111)); Task sub2 = new Task("Sub2", new Date(22), new Date(222)); Task sub3 = new Task("Sub3", new Date(33), new Date(333)); Task sub4 = new Task("Sub4", new Date(44), new Date(444)); Task sub5 = new Task("Sub5", new Date(55), new Date(555)); Task sub6 = new Task("Sub6", new Date(66), new Date(666)); sub1.setPercentComplete(0.111); sub2.setPercentComplete(0.222); sub3.setPercentComplete(0.333); sub4.setPercentComplete(0.444); sub5.setPercentComplete(0.555); sub6.setPercentComplete(0.666); TaskSeries seriesA = new TaskSeries("Series A"); Task taskA1 = new Task("Task 1", new SimpleTimePeriod(new Date(100), new Date(200))); taskA1.setPercentComplete(0.1); taskA1.addSubtask(sub1); Task taskA2 = new Task("Task 2", new SimpleTimePeriod(new Date(220), new Date(350))); taskA2.setPercentComplete(0.2); taskA2.addSubtask(sub2); taskA2.addSubtask(sub3); seriesA.add(taskA1); seriesA.add(taskA2); TaskSeries seriesB = new TaskSeries("Series B"); // note that we don't define taskB1 Task taskB2 = new Task("Task 2", new SimpleTimePeriod(new Date(2220), new Date(3350))); taskB2.setPercentComplete(0.3); taskB2.addSubtask(sub4); taskB2.addSubtask(sub5); taskB2.addSubtask(sub6); seriesB.add(taskB2); TaskSeriesCollection tsc = new TaskSeriesCollection(); tsc.add(seriesA); tsc.add(seriesB); return tsc; } /** * A test for the getSeriesCount() method. */ public void testGetSeriesCount() { TaskSeriesCollection c = createCollection1(); assertEquals(2, c.getSeriesCount()); } /** * Some tests for the getSeriesKey() method. */ public void testGetSeriesKey() { TaskSeriesCollection c = createCollection1(); assertEquals("S1", c.getSeriesKey(0)); assertEquals("S2", c.getSeriesKey(1)); } /** * A test for the getRowCount() method. */ public void testGetRowCount() { TaskSeriesCollection c = createCollection1(); assertEquals(2, c.getRowCount()); } /** * Some tests for the getRowKey() method. */ public void testGetRowKey() { TaskSeriesCollection c = createCollection1(); assertEquals("S1", c.getRowKey(0)); assertEquals("S2", c.getRowKey(1)); } /** * Some tests for the getRowIndex() method. */ public void testGetRowIndex() { TaskSeriesCollection c = createCollection1(); assertEquals(0, c.getRowIndex("S1")); assertEquals(1, c.getRowIndex("S2")); } /** * Some tests for the getValue() method. */ public void testGetValue() { TaskSeriesCollection c = createCollection1(); assertEquals(new Long(1L), c.getValue("S1", "Task 1")); assertEquals(new Long(3L), c.getValue("S1", "Task 2")); assertEquals(new Long(5L), c.getValue("S2", "Task 3")); assertEquals(new Long(1L), c.getValue(0, 0)); assertEquals(new Long(3L), c.getValue(0, 1)); assertEquals(null, c.getValue(0, 2)); assertEquals(null, c.getValue(1, 0)); assertEquals(null, c.getValue(1, 1)); assertEquals(new Long(5L), c.getValue(1, 2)); } /** * Some tests for the getStartValue() method. */ public void testGetStartValue() { TaskSeriesCollection c = createCollection1(); assertEquals(new Long(1L), c.getStartValue("S1", "Task 1")); assertEquals(new Long(3L), c.getStartValue("S1", "Task 2")); assertEquals(new Long(5L), c.getStartValue("S2", "Task 3")); assertEquals(new Long(1L), c.getStartValue(0, 0)); assertEquals(new Long(3L), c.getStartValue(0, 1)); assertEquals(null, c.getStartValue(0, 2)); assertEquals(null, c.getStartValue(1, 0)); assertEquals(null, c.getStartValue(1, 1)); assertEquals(new Long(5L), c.getStartValue(1, 2)); // test collection 3, which doesn't define all tasks in all series TaskSeriesCollection c3 = createCollection3(); assertEquals(new Long(100), c3.getStartValue(0, 0)); assertEquals(new Long(220), c3.getStartValue(0, 1)); assertTrue(c3.getStartValue(1, 0) == null); assertEquals(new Long(2220), c3.getStartValue(1, 1)); } /** * Some tests for the getStartValue() method for sub-intervals. */ public void testGetStartValue2() { TaskSeriesCollection c = createCollection2(); assertEquals(new Long(10L), c.getStartValue("S1", "Task 1", 0)); assertEquals(new Long(16L), c.getStartValue("S1", "Task 1", 1)); assertEquals(new Long(30L), c.getStartValue("S1", "Task 2", 0)); assertEquals(new Long(36L), c.getStartValue("S1", "Task 2", 1)); assertEquals(new Long(50L), c.getStartValue("S2", "Task 3", 0)); assertEquals(new Long(56L), c.getStartValue("S2", "Task 3", 1)); assertEquals(new Long(10L), c.getStartValue(0, 0, 0)); assertEquals(new Long(16L), c.getStartValue(0, 0, 1)); assertEquals(new Long(30L), c.getStartValue(0, 1, 0)); assertEquals(new Long(36L), c.getStartValue(0, 1, 1)); assertEquals(new Long(50L), c.getStartValue(1, 2, 0)); assertEquals(new Long(56L), c.getStartValue(1, 2, 1)); TaskSeriesCollection c3 = createCollection3(); assertEquals(new Long(11), c3.getStartValue(0, 0, 0)); assertEquals(new Long(22), c3.getStartValue(0, 1, 0)); assertEquals(new Long(33), c3.getStartValue(0, 1, 1)); assertTrue(c3.getStartValue(1, 0, 0) == null); assertEquals(new Long(44), c3.getStartValue(1, 1, 0)); assertEquals(new Long(55), c3.getStartValue(1, 1, 1)); assertEquals(new Long(66), c3.getStartValue(1, 1, 2)); } /** * A check for a null task duration. */ public void testGetStartValue3() { TaskSeriesCollection c = new TaskSeriesCollection(); TaskSeries s = new TaskSeries("Series 1"); s.add(new Task("Task with null duration", null)); c.add(s); Number millis = c.getStartValue("Series 1", "Task with null duration"); assertTrue(millis == null); } /** * Some tests for the getEndValue() method. */ public void testGetEndValue() { TaskSeriesCollection c = createCollection1(); assertEquals(new Long(2L), c.getEndValue("S1", "Task 1")); assertEquals(new Long(4L), c.getEndValue("S1", "Task 2")); assertEquals(new Long(6L), c.getEndValue("S2", "Task 3")); assertEquals(new Long(2L), c.getEndValue(0, 0)); assertEquals(new Long(4L), c.getEndValue(0, 1)); assertEquals(null, c.getEndValue(0, 2)); assertEquals(null, c.getEndValue(1, 0)); assertEquals(null, c.getEndValue(1, 1)); assertEquals(new Long(6L), c.getEndValue(1, 2)); // test collection 3, which doesn't define all tasks in all series TaskSeriesCollection c3 = createCollection3(); assertEquals(new Long(200), c3.getEndValue(0, 0)); assertEquals(new Long(350), c3.getEndValue(0, 1)); assertTrue(c3.getEndValue(1, 0) == null); assertEquals(new Long(3350), c3.getEndValue(1, 1)); } /** * Some tests for the getEndValue() method for sub-intervals. */ public void testGetEndValue2() { TaskSeriesCollection c = createCollection2(); assertEquals(new Long(15L), c.getEndValue("S1", "Task 1", 0)); assertEquals(new Long(20L), c.getEndValue("S1", "Task 1", 1)); assertEquals(new Long(35L), c.getEndValue("S1", "Task 2", 0)); assertEquals(new Long(40L), c.getEndValue("S1", "Task 2", 1)); assertEquals(new Long(55L), c.getEndValue("S2", "Task 3", 0)); assertEquals(new Long(60L), c.getEndValue("S2", "Task 3", 1)); assertEquals(new Long(15L), c.getEndValue(0, 0, 0)); assertEquals(new Long(20L), c.getEndValue(0, 0, 1)); assertEquals(new Long(35L), c.getEndValue(0, 1, 0)); assertEquals(new Long(40L), c.getEndValue(0, 1, 1)); assertEquals(new Long(55L), c.getEndValue(1, 2, 0)); assertEquals(new Long(60L), c.getEndValue(1, 2, 1)); TaskSeriesCollection c3 = createCollection3(); assertEquals(new Long(111), c3.getEndValue(0, 0, 0)); assertEquals(new Long(222), c3.getEndValue(0, 1, 0)); assertEquals(new Long(333), c3.getEndValue(0, 1, 1)); assertTrue(c3.getEndValue(1, 0, 0) == null); assertEquals(new Long(444), c3.getEndValue(1, 1, 0)); assertEquals(new Long(555), c3.getEndValue(1, 1, 1)); assertEquals(new Long(666), c3.getEndValue(1, 1, 2)); } /** * A check for a null task duration. */ public void testGetEndValue3() { TaskSeriesCollection c = new TaskSeriesCollection(); TaskSeries s = new TaskSeries("Series 1"); s.add(new Task("Task with null duration", null)); c.add(s); Number millis = c.getEndValue("Series 1", "Task with null duration"); assertTrue(millis == null); } /** * Some tests for the getPercentComplete() method. */ public void testGetPercentComplete() { TaskSeriesCollection c = createCollection2(); assertEquals(new Double(0.10), c.getPercentComplete("S1", "Task 1")); assertEquals(new Double(0.20), c.getPercentComplete("S1", "Task 2")); assertEquals(new Double(0.30), c.getPercentComplete("S2", "Task 3")); assertEquals(new Double(0.10), c.getPercentComplete(0, 0)); assertEquals(new Double(0.20), c.getPercentComplete(0, 1)); assertEquals(null, c.getPercentComplete(0, 2)); assertEquals(null, c.getPercentComplete(1, 0)); assertEquals(null, c.getPercentComplete(1, 1)); assertEquals(new Double(0.30), c.getPercentComplete(1, 2)); // test collection 3, which doesn't define all tasks in all series TaskSeriesCollection c3 = createCollection3(); assertEquals(new Double(0.1), c3.getPercentComplete(0, 0)); assertEquals(new Double(0.2), c3.getPercentComplete(0, 1)); assertTrue(c3.getPercentComplete(1, 0) == null); assertEquals(new Double(0.3), c3.getPercentComplete(1, 1)); assertEquals(new Double(0.111), c3.getPercentComplete(0, 0, 0)); assertEquals(new Double(0.222), c3.getPercentComplete(0, 1, 0)); assertEquals(new Double(0.333), c3.getPercentComplete(0, 1, 1)); assertEquals(new Double(0.444), c3.getPercentComplete(1, 1, 0)); assertEquals(new Double(0.555), c3.getPercentComplete(1, 1, 1)); assertEquals(new Double(0.666), c3.getPercentComplete(1, 1, 2)); } /** * A test for the getColumnCount() method. */ public void testGetColumnCount() { TaskSeriesCollection c = createCollection1(); assertEquals(3, c.getColumnCount()); } /** * Some tests for the getColumnKey() method. */ public void testGetColumnKey() { TaskSeriesCollection c = createCollection1(); assertEquals("Task 1", c.getColumnKey(0)); assertEquals("Task 2", c.getColumnKey(1)); assertEquals("Task 3", c.getColumnKey(2)); } /** * Some tests for the getColumnIndex() method. */ public void testGetColumnIndex() { TaskSeriesCollection c = createCollection1(); assertEquals(0, c.getColumnIndex("Task 1")); assertEquals(1, c.getColumnIndex("Task 2")); assertEquals(2, c.getColumnIndex("Task 3")); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = new TaskSeries("S"); s2.add(new Task("T1", new Date(1), new Date(2))); s2.add(new Task("T2", new Date(11), new Date(22))); TaskSeriesCollection c1 = new TaskSeriesCollection(); c1.add(s1); c1.add(s2); TaskSeries s1b = new TaskSeries("S"); s1b.add(new Task("T1", new Date(1), new Date(2))); s1b.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2b = new TaskSeries("S"); s2b.add(new Task("T1", new Date(1), new Date(2))); s2b.add(new Task("T2", new Date(11), new Date(22))); TaskSeriesCollection c2 = new TaskSeriesCollection(); c2.add(s1b); c2.add(s2b); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); } /** * Confirm that cloning works. */ public void testCloning() { TaskSeries s1 = new TaskSeries("S1"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = new TaskSeries("S2"); s2.add(new Task("T1", new Date(33), new Date(44))); s2.add(new Task("T2", new Date(55), new Date(66))); TaskSeriesCollection c1 = new TaskSeriesCollection(); c1.add(s1); c1.add(s2); TaskSeriesCollection c2 = null; try { c2 = (TaskSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // basic check for independence s1.add(new Task("T3", new Date(21), new Date(33))); assertFalse(c1.equals(c2)); TaskSeries series = c2.getSeries("S1"); series.add(new Task("T3", new Date(21), new Date(33))); assertTrue(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = new TaskSeries("S"); s2.add(new Task("T1", new Date(1), new Date(2))); s2.add(new Task("T2", new Date(11), new Date(22))); TaskSeriesCollection c1 = new TaskSeriesCollection(); c1.add(s1); c1.add(s2); TaskSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); c2 = (TaskSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(c1, c2); } /** * A test for bug report 697153. */ public void test697153() { TaskSeries s1 = new TaskSeries("S1"); s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(), new Date()))); s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(), new Date()))); s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(), new Date()))); TaskSeries s2 = new TaskSeries("S2"); s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(), new Date()))); s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(), new Date()))); s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(), new Date()))); TaskSeriesCollection tsc = new TaskSeriesCollection(); tsc.add(s1); tsc.add(s2); s1.removeAll(); int taskCount = tsc.getColumnCount(); assertEquals(3, taskCount); } /** * A test for bug report 800324. */ public void test800324() { TaskSeries s1 = new TaskSeries("S1"); s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(), new Date()))); s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(), new Date()))); s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(), new Date()))); TaskSeriesCollection tsc = new TaskSeriesCollection(); tsc.add(s1); // these methods should throw an IndexOutOfBoundsException since the // column is too high... try { /* Number start = */ tsc.getStartValue(0, 3); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } try { /* Number end = */ tsc.getEndValue(0, 3); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } try { /* int count = */ tsc.getSubIntervalCount(0, 3); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } } /** * Some tests for the bug report 1099331. We create a TaskSeriesCollection * with two series - the first series has two tasks, but the second has * only one. The key is to ensure that the methods in TaskSeriesCollection * translate the index values to key values *before* accessing the tasks * in the series. */ public void testGetSubIntervalCount() { TaskSeriesCollection tsc = createCollection3(); assertEquals(1, tsc.getSubIntervalCount(0, 0)); assertEquals(2, tsc.getSubIntervalCount(0, 1)); assertEquals(0, tsc.getSubIntervalCount(1, 0)); assertEquals(3, tsc.getSubIntervalCount(1, 1)); } /** * Some basic tests for the getSeries() methods. */ public void testGetSeries() { TaskSeries s1 = new TaskSeries("S1"); TaskSeries s2 = new TaskSeries("S2"); TaskSeriesCollection c = new TaskSeriesCollection(); c.add(s1); assertEquals(c.getSeries(0), s1); assertEquals(c.getSeries("S1"), s1); assertEquals(c.getSeries("XX"), null); c.add(s2); assertEquals(c.getSeries(1), s2); assertEquals(c.getSeries("S2"), s2); boolean pass = false; try { c.getSeries(null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some basic checks for the remove() method. */ public void testRemove() { TaskSeriesCollection c = new TaskSeriesCollection(); TaskSeries s1 = new TaskSeries("S1"); c.add(s1); assertEquals("S1", c.getSeries(0).getKey()); c.remove(0); assertEquals(0, c.getSeriesCount()); c.add(s1); boolean pass = false; try { c.remove(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.remove(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/TaskSeriesTests.java0000644000175000017500000001240411173030414030315 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * TaskSeriesTests.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jul-2004 : Version 1 (DG); * 09-May-2008 : Added independence check in testCloning() (DG); * */ package org.jfree.data.gantt.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; /** * Tests for the {@link TaskSeries} class. */ public class TaskSeriesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TaskSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TaskSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = new TaskSeries("S"); s2.add(new Task("T1", new Date(1), new Date(2))); s2.add(new Task("T2", new Date(11), new Date(22))); assertTrue(s1.equals(s2)); assertTrue(s2.equals(s1)); s1.add(new Task("T3", new Date(22), new Date(33))); assertFalse(s1.equals(s2)); s2.add(new Task("T3", new Date(22), new Date(33))); assertTrue(s1.equals(s2)); } /** * Confirm that cloning works. */ public void testCloning() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = null; try { s2 = (TaskSeries) s1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // basic check for independence s1.add(new Task("T3", new Date(22), new Date(33))); assertFalse(s1.equals(s2)); s2.add(new Task("T3", new Date(22), new Date(33))); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); TaskSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); s2 = (TaskSeries) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(s1, s2); } /** * Some checks for the getTask() method. */ public void testGetTask() { TaskSeries s1 = new TaskSeries("S"); s1.add(new Task("T1", new Date(1), new Date(2))); s1.add(new Task("T2", new Date(11), new Date(22))); Task t1 = s1.get("T1"); assertTrue(t1.equals(new Task("T1", new Date(1), new Date(2)))); Task t2 = s1.get("T2"); assertTrue(t2.equals(new Task("T2", new Date(11), new Date(22)))); Task t3 = s1.get("T3"); assertTrue(t3 == null); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/TaskTests.java0000644000175000017500000001216711173030414027150 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * TaskTests.java * -------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jul-2004 : Version 1 (DG); * */ package org.jfree.data.gantt.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.gantt.Task; import org.jfree.data.time.SimpleTimePeriod; /** * Tests for the {@link Task} class. */ public class TaskTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TaskTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TaskTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Task t1 = new Task("T", new Date(1), new Date(2)); Task t2 = new Task("T", new Date(1), new Date(2)); assertTrue(t1.equals(t2)); assertTrue(t2.equals(t1)); t1.setDescription("X"); assertFalse(t1.equals(t2)); t2.setDescription("X"); assertTrue(t1.equals(t2)); t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3))); assertFalse(t1.equals(t2)); t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3))); assertTrue(t1.equals(t2)); t1.setPercentComplete(0.5); assertFalse(t1.equals(t2)); t2.setPercentComplete(0.5); assertTrue(t1.equals(t2)); t1.addSubtask(new Task("T", new Date(22), new Date(33))); assertFalse(t1.equals(t2)); t2.addSubtask(new Task("T", new Date(22), new Date(33))); assertTrue(t1.equals(t2)); } /** * Confirm that cloning works. */ public void testCloning() { Task t1 = new Task("T", new Date(1), new Date(2)); Task t2 = null; try { t2 = (Task) t1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(t1 != t2); assertTrue(t1.getClass() == t2.getClass()); assertTrue(t1.equals(t2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Task t1 = new Task("T", new Date(1), new Date(2)); Task t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); t2 = (Task) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(t1, t2); } /** * Check the getSubTaskCount() method. */ public void testGetSubTaskCount() { Task t1 = new Task("T", new Date(100), new Date(200)); assertEquals(0, t1.getSubtaskCount()); t1.addSubtask(new Task("S1", new Date(100), new Date(110))); assertEquals(1, t1.getSubtaskCount()); Task s2 = new Task("S2", new Date(111), new Date(120)); t1.addSubtask(s2); assertEquals(2, t1.getSubtaskCount()); t1.addSubtask(new Task("S3", new Date(121), new Date(130))); assertEquals(3, t1.getSubtaskCount()); t1.removeSubtask(s2); assertEquals(2, t1.getSubtaskCount()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java0000644000175000017500000001376411173030414030743 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * XYTaskDatasetTests.java * ----------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Sep-2008 : Version 1 (DG); * */ package org.jfree.data.gantt.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.gantt.Task; import org.jfree.data.gantt.TaskSeries; import org.jfree.data.gantt.TaskSeriesCollection; import org.jfree.data.gantt.XYTaskDataset; /** * Tests for the {@link XYTaskDataset} class. */ public class XYTaskDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYTaskDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYTaskDatasetTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); s1.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); XYTaskDataset d1 = new XYTaskDataset(u1); TaskSeries s2 = new TaskSeries("Series"); s2.add(new Task("Task 1", new Date(0L), new Date(1L))); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); s2.add(new Task("Task 3", new Date(20L), new Date(21L))); TaskSeriesCollection u2 = new TaskSeriesCollection(); u2.add(s2); XYTaskDataset d2 = new XYTaskDataset(u2); assertTrue(d1.equals(d2)); d1.setSeriesWidth(0.123); assertFalse(d1.equals(d2)); d2.setSeriesWidth(0.123); assertTrue(d1.equals(d2)); d1.setTransposed(true); assertFalse(d1.equals(d2)); d2.setTransposed(true); assertTrue(d1.equals(d2)); s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); XYTaskDataset d1 = new XYTaskDataset(u1); XYTaskDataset d2 = null; try { d2 = (XYTaskDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // basic check for independence s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); TaskSeriesCollection u2 = d2.getTasks(); TaskSeries s2 = u2.getSeries("Series"); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); XYTaskDataset d1 = new XYTaskDataset(u1); XYTaskDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (XYTaskDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // basic check for independence s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); TaskSeriesCollection u2 = d2.getTasks(); TaskSeries s2 = u2.getSeries("Series"); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/0000755000175000017500000000000011173030414023520 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/0000755000175000017500000000000011216245562024663 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DataGeneralPackageTests.java0000644000175000017500000000604211173030414032164 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DataGeneralPackageTests.java * ---------------------------- * (C) Copyright 2004-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Aug-2004 : Restructured org.jfree.data package (DG); * 18-Jan-2005 : Added main() method (DG); * 04-Feb-2009 : Added DefaultHeatMapDatasetTests (DG); * */ package org.jfree.data.general.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data package that can be run * using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataGeneralPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.general"); suite.addTestSuite(DatasetGroupTests.class); suite.addTestSuite(DatasetUtilitiesTests.class); suite.addTestSuite(DefaultHeatMapDatasetTests.class); suite.addTestSuite(DefaultKeyedValueDatasetTests.class); suite.addTestSuite(DefaultKeyedValuesDatasetTests.class); suite.addTestSuite(DefaultKeyedValues2DDatasetTests.class); suite.addTestSuite(DefaultPieDatasetTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataGeneralPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DatasetGroupTests.java0000644000175000017500000000605111173030414031143 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DatasetGroupTests.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Jan-2005 : Version 1 (DG); * */ package org.jfree.data.general.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.DatasetGroup; /** * Tests for the {@link DatasetGroup} class. */ public class DatasetGroupTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DatasetGroupTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DatasetGroupTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DatasetGroup g1 = new DatasetGroup(); DatasetGroup g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); g2 = (DatasetGroup) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(g1, g2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java0000644000175000017500000012645611173030414032036 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DatasetUtilitiesTests.java * -------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Sep-2003 : Version 1 (DG); * 23-Mar-2004 : Added test for maximumStackedRangeValue() method (DG); * 04-Oct-2004 : Eliminated NumberUtils usage (DG); * 07-Jan-2005 : Updated for method name changes (DG); * 03-Feb-2005 : Added testFindStackedRangeBounds2() method (DG); * 26-Sep-2007 : Added testIsEmptyOrNullXYDataset() method (DG); * 28-Mar-2008 : Added and renamed various tests (DG); * 08-Oct-2008 : New tests to support patch 2131001 and related * changes (DG); * 25-Mar-2009 : Added tests for new iterateToFindRangeBounds() method (DG); * */ package org.jfree.data.general.junit; import java.util.ArrayList; import java.util.Date; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.KeyToGroupMap; import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.DefaultIntervalCategoryDataset; import org.jfree.data.function.Function2D; import org.jfree.data.function.LineFunction2D; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.data.statistics.BoxAndWhiskerItem; import org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset; import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.data.xy.YIntervalSeries; import org.jfree.data.xy.YIntervalSeriesCollection; /** * Tests for the {@link DatasetUtilities} class. */ public class DatasetUtilitiesTests extends TestCase { private static final double EPSILON = 0.0000000001; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DatasetUtilitiesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DatasetUtilitiesTests(String name) { super(name); } /** * Some tests to verify that Java does what I think it does! */ public void testJava() { assertTrue(Double.isNaN(Math.min(1.0, Double.NaN))); assertTrue(Double.isNaN(Math.max(1.0, Double.NaN))); } /** * Some tests for the calculatePieDatasetTotal() method. */ public void testCalculatePieDatasetTotal() { DefaultPieDataset d = new DefaultPieDataset(); assertEquals(0.0, DatasetUtilities.calculatePieDatasetTotal(d), EPSILON); d.setValue("A", 1.0); assertEquals(1.0, DatasetUtilities.calculatePieDatasetTotal(d), EPSILON); d.setValue("B", 3.0); assertEquals(4.0, DatasetUtilities.calculatePieDatasetTotal(d), EPSILON); } /** * Some tests for the findDomainBounds() method. */ public void testFindDomainBounds() { XYDataset dataset = createXYDataset1(); Range r = DatasetUtilities.findDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); } /** * This test checks that the standard method has 'includeInterval' * defaulting to true. */ public void testFindDomainBounds2() { DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] x1Start = new double[] {0.9, 1.9, 2.9}; double[] x1End = new double[] {1.1, 2.1, 3.1}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; dataset.addSeries("S1", data1); Range r = DatasetUtilities.findDomainBounds(dataset); assertEquals(0.9, r.getLowerBound(), EPSILON); assertEquals(3.1, r.getUpperBound(), EPSILON); } /** * This test checks that when the 'includeInterval' flag is false, the * bounds come from the regular x-values. */ public void testFindDomainBounds3() { DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] x1Start = new double[] {0.9, 1.9, 2.9}; double[] x1End = new double[] {1.1, 2.1, 3.1}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; dataset.addSeries("S1", data1); Range r = DatasetUtilities.findDomainBounds(dataset, false); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); } /** * This test checks that NaN values are ignored. */ public void testFindDomainBounds_NaN() { DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); double[] x1 = new double[] {1.0, 2.0, Double.NaN}; double[] x1Start = new double[] {0.9, 1.9, Double.NaN}; double[] x1End = new double[] {1.1, 2.1, Double.NaN}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; dataset.addSeries("S1", data1); Range r = DatasetUtilities.findDomainBounds(dataset); assertEquals(0.9, r.getLowerBound(), EPSILON); assertEquals(2.1, r.getUpperBound(), EPSILON); r = DatasetUtilities.findDomainBounds(dataset, false); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(2.0, r.getUpperBound(), EPSILON); } /** * Some tests for the iterateDomainBounds() method. */ public void testIterateDomainBounds() { XYDataset dataset = createXYDataset1(); Range r = DatasetUtilities.iterateDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); } /** * Check that NaN values in the dataset are ignored. */ public void testIterateDomainBounds_NaN() { DefaultXYDataset dataset = new DefaultXYDataset(); double[] x = new double[] {1.0, 2.0, Double.NaN, 3.0}; double[] y = new double[] {9.0, 8.0, 7.0, 6.0}; dataset.addSeries("S1", new double[][] {x, y}); Range r = DatasetUtilities.iterateDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); } /** * Check that NaN values in the IntervalXYDataset are ignored. */ public void testIterateDomainBounds_NaN2() { DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); double[] x1 = new double[] {Double.NaN, 2.0, 3.0}; double[] x1Start = new double[] {0.9, Double.NaN, 2.9}; double[] x1End = new double[] {1.1, Double.NaN, 3.1}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; dataset.addSeries("S1", data1); Range r = DatasetUtilities.iterateDomainBounds(dataset, false); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); r = DatasetUtilities.iterateDomainBounds(dataset, true); assertEquals(0.9, r.getLowerBound(), EPSILON); assertEquals(3.1, r.getUpperBound(), EPSILON); } /** * Some tests for the findRangeBounds() for a CategoryDataset method. */ public void testFindRangeBounds_CategoryDataset() { CategoryDataset dataset = createCategoryDataset1(); Range r = DatasetUtilities.findRangeBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(6.0, r.getUpperBound(), EPSILON); } /** * Some tests for the findRangeBounds() method on an XYDataset. */ public void testFindRangeBounds() { XYDataset dataset = createXYDataset1(); Range r = DatasetUtilities.findRangeBounds(dataset); assertEquals(100.0, r.getLowerBound(), EPSILON); assertEquals(105.0, r.getUpperBound(), EPSILON); } /** * A test for the findRangeBounds(XYDataset) method using * an IntervalXYDataset. */ public void testFindRangeBounds2() { YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); Range r = DatasetUtilities.findRangeBounds(dataset); assertNull(r); YIntervalSeries s1 = new YIntervalSeries("S1"); dataset.addSeries(s1); r = DatasetUtilities.findRangeBounds(dataset); assertNull(r); // try a single item s1.add(1.0, 2.0, 1.5, 2.5); r = DatasetUtilities.findRangeBounds(dataset); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); r = DatasetUtilities.findRangeBounds(dataset, false); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(2.0, r.getUpperBound(), EPSILON); // another item s1.add(2.0, 2.0, 1.4, 2.1); r = DatasetUtilities.findRangeBounds(dataset); assertEquals(1.4, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); // another empty series YIntervalSeries s2 = new YIntervalSeries("S2"); dataset.addSeries(s2); r = DatasetUtilities.findRangeBounds(dataset); assertEquals(1.4, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); // an item in series 2 s2.add(1.0, 2.0, 1.9, 2.6); r = DatasetUtilities.findRangeBounds(dataset); assertEquals(1.4, r.getLowerBound(), EPSILON); assertEquals(2.6, r.getUpperBound(), EPSILON); // what if we don't want the interval? r = DatasetUtilities.findRangeBounds(dataset, false); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(2.0, r.getUpperBound(), EPSILON); } /** * Some tests for the iterateRangeBounds() method. */ public void testIterateRangeBounds_CategoryDataset() { CategoryDataset dataset = createCategoryDataset1(); Range r = DatasetUtilities.iterateRangeBounds(dataset, false); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(6.0, r.getUpperBound(), EPSILON); } /** * Some checks for the iterateRangeBounds() method. */ public void testIterateRangeBounds2_CategoryDataset() { // an empty dataset should return a null range DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Range r = DatasetUtilities.iterateRangeBounds(dataset, false); assertNull(r); // a dataset with a single value dataset.addValue(1.23, "R1", "C1"); r = DatasetUtilities.iterateRangeBounds(dataset, false); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); // null is ignored dataset.addValue(null, "R2", "C1"); r = DatasetUtilities.iterateRangeBounds(dataset, false); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); // a Double.NaN should be ignored dataset.addValue(Double.NaN, "R2", "C1"); r = DatasetUtilities.iterateRangeBounds(dataset, false); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); } /** * Some checks for the iterateRangeBounds() method using an * IntervalCategoryDataset. */ public void testIterateRangeBounds3_CategoryDataset() { Number[][] starts = new Double[2][3]; Number[][] ends = new Double[2][3]; starts[0][0] = new Double(1.0); starts[0][1] = new Double(2.0); starts[0][2] = new Double(3.0); starts[1][0] = new Double(11.0); starts[1][1] = new Double(12.0); starts[1][2] = new Double(13.0); ends[0][0] = new Double(4.0); ends[0][1] = new Double(5.0); ends[0][2] = new Double(6.0); ends[1][0] = new Double(16.0); ends[1][1] = new Double(15.0); ends[1][2] = new Double(14.0); DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset( starts, ends); Range r = DatasetUtilities.iterateRangeBounds(d, false); assertEquals(4.0, r.getLowerBound(), EPSILON); assertEquals(16.0, r.getUpperBound(), EPSILON); r = DatasetUtilities.iterateRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(16.0, r.getUpperBound(), EPSILON); } /** * Some tests for the iterateRangeBounds() method. */ public void testIterateRangeBounds() { XYDataset dataset = createXYDataset1(); Range r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(100.0, r.getLowerBound(), EPSILON); assertEquals(105.0, r.getUpperBound(), EPSILON); } /** * Check the range returned when a series contains a null value. */ public void testIterateRangeBounds2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, null); s1.add(3.0, 3.3); XYSeriesCollection dataset = new XYSeriesCollection(s1); Range r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.1, r.getLowerBound(), EPSILON); assertEquals(3.3, r.getUpperBound(), EPSILON); } /** * Some checks for the iterateRangeBounds() method. */ public void testIterateRangeBounds3() { // an empty dataset should return a null range XYSeriesCollection dataset = new XYSeriesCollection(); Range r = DatasetUtilities.iterateRangeBounds(dataset); assertNull(r); XYSeries s1 = new XYSeries("S1"); dataset.addSeries(s1); r = DatasetUtilities.iterateRangeBounds(dataset); assertNull(r); // a dataset with a single value s1.add(1.0, 1.23); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); // null is ignored s1.add(2.0, null); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); // Double.NaN DOESN'T mess things up s1.add(3.0, Double.NaN); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); } /** * Some checks for the range bounds of a dataset that implements the * {@link IntervalXYDataset} interface. */ public void testIterateRangeBounds4() { YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); Range r = DatasetUtilities.iterateRangeBounds(dataset); assertNull(r); YIntervalSeries s1 = new YIntervalSeries("S1"); dataset.addSeries(s1); r = DatasetUtilities.iterateRangeBounds(dataset); assertNull(r); // try a single item s1.add(1.0, 2.0, 1.5, 2.5); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); // another item s1.add(2.0, 2.0, 1.4, 2.1); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.4, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); // another empty series YIntervalSeries s2 = new YIntervalSeries("S2"); dataset.addSeries(s2); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.4, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); // an item in series 2 s2.add(1.0, 2.0, 1.9, 2.6); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.4, r.getLowerBound(), EPSILON); assertEquals(2.6, r.getUpperBound(), EPSILON); } /** * Some tests for the findMinimumDomainValue() method. */ public void testFindMinimumDomainValue() { XYDataset dataset = createXYDataset1(); Number minimum = DatasetUtilities.findMinimumDomainValue(dataset); assertEquals(new Double(1.0), minimum); } /** * Some tests for the findMaximumDomainValue() method. */ public void testFindMaximumDomainValue() { XYDataset dataset = createXYDataset1(); Number maximum = DatasetUtilities.findMaximumDomainValue(dataset); assertEquals(new Double(3.0), maximum); } /** * Some tests for the findMinimumRangeValue() method. */ public void testFindMinimumRangeValue() { CategoryDataset d1 = createCategoryDataset1(); Number min1 = DatasetUtilities.findMinimumRangeValue(d1); assertEquals(new Double(1.0), min1); XYDataset d2 = createXYDataset1(); Number min2 = DatasetUtilities.findMinimumRangeValue(d2); assertEquals(new Double(100.0), min2); } /** * Some tests for the findMaximumRangeValue() method. */ public void testFindMaximumRangeValue() { CategoryDataset d1 = createCategoryDataset1(); Number max1 = DatasetUtilities.findMaximumRangeValue(d1); assertEquals(new Double(6.0), max1); XYDataset dataset = createXYDataset1(); Number maximum = DatasetUtilities.findMaximumRangeValue(dataset); assertEquals(new Double(105.0), maximum); } /** * A quick test of the min and max range value methods. */ public void testMinMaxRange() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(100.0, "Series 1", "Type 1"); dataset.addValue(101.1, "Series 1", "Type 2"); Number min = DatasetUtilities.findMinimumRangeValue(dataset); assertTrue(min.doubleValue() < 100.1); Number max = DatasetUtilities.findMaximumRangeValue(dataset); assertTrue(max.doubleValue() > 101.0); } /** * A test to reproduce bug report 803660. */ public void test803660() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(100.0, "Series 1", "Type 1"); dataset.addValue(101.1, "Series 1", "Type 2"); Number n = DatasetUtilities.findMaximumRangeValue(dataset); assertTrue(n.doubleValue() > 101.0); } /** * A simple test for the cumulative range calculation. The sequence of * "cumulative" values are considered to be { 0.0, 10.0, 25.0, 18.0 } so * the range should be 0.0 -> 25.0. */ public void testCumulativeRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(10.0, "Series 1", "Start"); dataset.addValue(15.0, "Series 1", "Delta 1"); dataset.addValue(-7.0, "Series 1", "Delta 2"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); assertEquals(0.0, range.getLowerBound(), 0.00000001); assertEquals(25.0, range.getUpperBound(), 0.00000001); } /** * A further test for the cumulative range calculation. */ public void testCumulativeRange2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(-21.4, "Series 1", "Start Value"); dataset.addValue(11.57, "Series 1", "Delta 1"); dataset.addValue(3.51, "Series 1", "Delta 2"); dataset.addValue(-12.36, "Series 1", "Delta 3"); dataset.addValue(3.39, "Series 1", "Delta 4"); dataset.addValue(38.68, "Series 1", "Delta 5"); dataset.addValue(-43.31, "Series 1", "Delta 6"); dataset.addValue(-29.59, "Series 1", "Delta 7"); dataset.addValue(35.30, "Series 1", "Delta 8"); dataset.addValue(5.0, "Series 1", "Delta 9"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); assertEquals(-49.51, range.getLowerBound(), 0.00000001); assertEquals(23.39, range.getUpperBound(), 0.00000001); } /** * A further test for the cumulative range calculation. */ public void testCumulativeRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(15.76, "Product 1", "Labour"); dataset.addValue(8.66, "Product 1", "Administration"); dataset.addValue(4.71, "Product 1", "Marketing"); dataset.addValue(3.51, "Product 1", "Distribution"); dataset.addValue(32.64, "Product 1", "Total Expense"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); assertEquals(0.0, range.getLowerBound(), EPSILON); assertEquals(65.28, range.getUpperBound(), EPSILON); } /** * Check that the findCumulativeRangeBounds() method ignores Double.NaN * values. */ public void testCumulativeRange_NaN() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(10.0, "Series 1", "Start"); dataset.addValue(15.0, "Series 1", "Delta 1"); dataset.addValue(Double.NaN, "Series 1", "Delta 2"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); assertEquals(0.0, range.getLowerBound(), EPSILON); assertEquals(25.0, range.getUpperBound(), EPSILON); } /** * Test the creation of a dataset from an array. */ public void testCreateCategoryDataset1() { String[] rowKeys = {"R1", "R2", "R3"}; String[] columnKeys = {"C1", "C2"}; double[][] data = new double[3][]; data[0] = new double[] {1.1, 1.2}; data[1] = new double[] {2.1, 2.2}; data[2] = new double[] {3.1, 3.2}; CategoryDataset dataset = DatasetUtilities.createCategoryDataset( rowKeys, columnKeys, data); assertTrue(dataset.getRowCount() == 3); assertTrue(dataset.getColumnCount() == 2); } /** * Test the creation of a dataset from an array. This time is should fail * because the array dimensions are around the wrong way. */ public void testCreateCategoryDataset2() { boolean pass = false; String[] rowKeys = {"R1", "R2", "R3"}; String[] columnKeys = {"C1", "C2"}; double[][] data = new double[2][]; data[0] = new double[] {1.1, 1.2, 1.3}; data[1] = new double[] {2.1, 2.2, 2.3}; CategoryDataset dataset = null; try { dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data); } catch (IllegalArgumentException e) { pass = true; // got it! } assertTrue(pass); assertTrue(dataset == null); } /** * Test for a bug reported in the forum: * * http://www.jfree.org/phpBB2/viewtopic.php?t=7903 */ public void testMaximumStackedRangeValue() { double v1 = 24.3; double v2 = 14.2; double v3 = 33.2; double v4 = 32.4; double v5 = 26.3; double v6 = 22.6; Number answer = new Double(Math.max(v1 + v2 + v3, v4 + v5 + v6)); DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(v1, "Row 0", "Column 0"); d.addValue(v2, "Row 1", "Column 0"); d.addValue(v3, "Row 2", "Column 0"); d.addValue(v4, "Row 0", "Column 1"); d.addValue(v5, "Row 1", "Column 1"); d.addValue(v6, "Row 2", "Column 1"); Number max = DatasetUtilities.findMaximumStackedRangeValue(d); assertTrue(max.equals(answer)); } /** * Some checks for the findStackedRangeBounds() method. */ public void testFindStackedRangeBounds_CategoryDataset1() { CategoryDataset d1 = createCategoryDataset1(); Range r = DatasetUtilities.findStackedRangeBounds(d1); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(15.0, r.getUpperBound(), EPSILON); d1 = createCategoryDataset2(); r = DatasetUtilities.findStackedRangeBounds(d1); assertEquals(-2.0, r.getLowerBound(), EPSILON); assertEquals(2.0, r.getUpperBound(), EPSILON); } /** * Some checks for the findStackedRangeBounds() method. */ public void testFindStackedRangeBounds_CategoryDataset2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Range r = DatasetUtilities.findStackedRangeBounds(dataset); assertTrue(r == null); dataset.addValue(5.0, "R1", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); assertEquals(3.0, r.getLowerBound(), EPSILON); assertEquals(8.0, r.getUpperBound(), EPSILON); dataset.addValue(-1.0, "R2", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(8.0, r.getUpperBound(), EPSILON); dataset.addValue(null, "R3", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(8.0, r.getUpperBound(), EPSILON); dataset.addValue(Double.NaN, "R4", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(8.0, r.getUpperBound(), EPSILON); } /** * Some checks for the findStackedRangeBounds(CategoryDataset, * KeyToGroupMap) method. */ public void testFindStackedRangeBounds_CategoryDataset3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); KeyToGroupMap map = new KeyToGroupMap("Group A"); Range r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertTrue(r == null); dataset.addValue(1.0, "R1", "C1"); dataset.addValue(2.0, "R2", "C1"); dataset.addValue(3.0, "R3", "C1"); dataset.addValue(4.0, "R4", "C1"); map.mapKeyToGroup("R1", "Group A"); map.mapKeyToGroup("R2", "Group A"); map.mapKeyToGroup("R3", "Group B"); map.mapKeyToGroup("R4", "Group B"); r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(7.0, r.getUpperBound(), EPSILON); dataset.addValue(null, "R5", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(7.0, r.getUpperBound(), EPSILON); dataset.addValue(Double.NaN, "R6", "C1"); r = DatasetUtilities.findStackedRangeBounds(dataset, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(7.0, r.getUpperBound(), EPSILON); } /** * Some checks for the findStackedRangeBounds() method. */ public void testFindStackedRangeBoundsForTableXYDataset1() { TableXYDataset d2 = createTableXYDataset1(); Range r = DatasetUtilities.findStackedRangeBounds(d2); assertEquals(-2.0, r.getLowerBound(), EPSILON); assertEquals(2.0, r.getUpperBound(), EPSILON); } /** * Some checks for the findStackedRangeBounds() method. */ public void testFindStackedRangeBoundsForTableXYDataset2() { DefaultTableXYDataset d = new DefaultTableXYDataset(); Range r = DatasetUtilities.findStackedRangeBounds(d); assertEquals(r, new Range(0.0, 0.0)); } /** * Tests the stacked range extent calculation. */ public void testStackedRangeWithMap() { CategoryDataset d = createCategoryDataset1(); KeyToGroupMap map = new KeyToGroupMap("G0"); map.mapKeyToGroup("R2", "G1"); Range r = DatasetUtilities.findStackedRangeBounds(d, map); assertEquals(0.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON); } /** * Some checks for the isEmptyOrNull(XYDataset) method. */ public void testIsEmptyOrNullXYDataset() { XYSeriesCollection dataset = null; assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); dataset = new XYSeriesCollection(); assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); XYSeries s1 = new XYSeries("S1"); dataset.addSeries(s1); assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); s1.add(1.0, 2.0); assertFalse(DatasetUtilities.isEmptyOrNull(dataset)); s1.clear(); assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); } /** * Some checks for the limitPieDataset() methods. */ public void testLimitPieDataset() { // check that empty dataset is handled OK DefaultPieDataset d1 = new DefaultPieDataset(); PieDataset d2 = DatasetUtilities.createConsolidatedPieDataset(d1, "Other", 0.05); assertEquals(0, d2.getItemCount()); // check that minItem limit is observed d1.setValue("Item 1", 1.0); d1.setValue("Item 2", 49.50); d1.setValue("Item 3", 49.50); d2 = DatasetUtilities.createConsolidatedPieDataset(d1, "Other", 0.05); assertEquals(3, d2.getItemCount()); assertEquals("Item 1", d2.getKey(0)); assertEquals("Item 2", d2.getKey(1)); assertEquals("Item 3", d2.getKey(2)); // check that minItem limit is observed d1.setValue("Item 4", 1.0); d2 = DatasetUtilities.createConsolidatedPieDataset(d1, "Other", 0.05, 2); // and that simple aggregation works assertEquals(3, d2.getItemCount()); assertEquals("Item 2", d2.getKey(0)); assertEquals("Item 3", d2.getKey(1)); assertEquals("Other", d2.getKey(2)); assertEquals(new Double(2.0), d2.getValue("Other")); } /** * Some checks for the sampleFunction2D() method. */ public void testSampleFunction2D() { Function2D f = new LineFunction2D(0, 1); XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, "S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals("S1", dataset.getSeriesKey(0)); assertEquals(2, dataset.getItemCount(0)); assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); } /** * A simple check for the findMinimumStackedRangeValue() method. */ public void testFindMinimumStackedRangeValue() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // an empty dataset should return a null max Number min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertNull(min); dataset.addValue(1.0, "R1", "C1"); min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertEquals(0.0, min.doubleValue(), EPSILON); dataset.addValue(2.0, "R2", "C1"); min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertEquals(0.0, min.doubleValue(), EPSILON); dataset.addValue(-3.0, "R3", "C1"); min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertEquals(-3.0, min.doubleValue(), EPSILON); dataset.addValue(Double.NaN, "R4", "C1"); min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertEquals(-3.0, min.doubleValue(), EPSILON); } /** * A simple check for the findMaximumStackedRangeValue() method. */ public void testFindMinimumStackedRangeValue2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(-1.0, "R1", "C1"); Number min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertEquals(-1.0, min.doubleValue(), EPSILON); dataset.addValue(-2.0, "R2", "C1"); min = DatasetUtilities.findMinimumStackedRangeValue(dataset); assertEquals(-3.0, min.doubleValue(), EPSILON); } /** * A simple check for the findMaximumStackedRangeValue() method. */ public void testFindMaximumStackedRangeValue() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // an empty dataset should return a null max Number max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertNull(max); dataset.addValue(1.0, "R1", "C1"); max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertEquals(1.0, max.doubleValue(), EPSILON); dataset.addValue(2.0, "R2", "C1"); max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertEquals(3.0, max.doubleValue(), EPSILON); dataset.addValue(-3.0, "R3", "C1"); max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertEquals(3.0, max.doubleValue(), EPSILON); dataset.addValue(Double.NaN, "R4", "C1"); max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertEquals(3.0, max.doubleValue(), EPSILON); } /** * A simple check for the findMaximumStackedRangeValue() method. */ public void testFindMaximumStackedRangeValue2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(-1.0, "R1", "C1"); Number max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertEquals(0.0, max.doubleValue(), EPSILON); dataset.addValue(-2.0, "R2", "C1"); max = DatasetUtilities.findMaximumStackedRangeValue(dataset); assertEquals(0.0, max.doubleValue(), EPSILON); } /** * Creates a dataset for testing. * * @return A dataset. */ private CategoryDataset createCategoryDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); result.addValue(1.0, "R0", "C0"); result.addValue(1.0, "R1", "C0"); result.addValue(1.0, "R2", "C0"); result.addValue(4.0, "R0", "C1"); result.addValue(5.0, "R1", "C1"); result.addValue(6.0, "R2", "C1"); return result; } /** * Creates a dataset for testing. * * @return A dataset. */ private CategoryDataset createCategoryDataset2() { DefaultCategoryDataset result = new DefaultCategoryDataset(); result.addValue(1.0, "R0", "C0"); result.addValue(-2.0, "R1", "C0"); result.addValue(2.0, "R0", "C1"); result.addValue(-1.0, "R1", "C1"); return result; } /** * Creates a dataset for testing. * * @return A dataset. */ private XYDataset createXYDataset1() { XYSeries series1 = new XYSeries("S1"); series1.add(1.0, 100.0); series1.add(2.0, 101.0); series1.add(3.0, 102.0); XYSeries series2 = new XYSeries("S2"); series2.add(1.0, 103.0); series2.add(2.0, null); series2.add(3.0, 105.0); XYSeriesCollection result = new XYSeriesCollection(); result.addSeries(series1); result.addSeries(series2); result.setIntervalWidth(0.0); return result; } /** * Creates a sample dataset for testing purposes. * * @return A sample dataset. */ private TableXYDataset createTableXYDataset1() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.0); s1.add(2.0, 2.0); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(1.0, -2.0); s2.add(2.0, -1.0); dataset.addSeries(s2); return dataset; } /** * Some checks for the iteratorToFindRangeBounds(XYDataset...) method. */ public void testIterateToFindRangeBounds1_XYDataset() { // null dataset throws IllegalArgumentException boolean pass = false; try { DatasetUtilities.iterateToFindRangeBounds(null, new ArrayList(), new Range(0.0, 1.0), true); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // null list throws IllegalArgumentException pass = false; try { DatasetUtilities.iterateToFindRangeBounds(new XYSeriesCollection(), null, new Range(0.0, 1.0), true); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // null range throws IllegalArgumentException pass = false; try { DatasetUtilities.iterateToFindRangeBounds(new XYSeriesCollection(), new ArrayList(), null, true); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some tests for the iterateToFindRangeBounds() method. */ public void testIterateToFindRangeBounds2_XYDataset() { List visibleSeriesKeys = new ArrayList(); Range xRange = new Range(0.0, 10.0); // empty dataset returns null XYSeriesCollection dataset = new XYSeriesCollection(); Range r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertNull(r); // add an empty series XYSeries s1 = new XYSeries("A"); dataset.addSeries(s1); visibleSeriesKeys.add("A"); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertNull(r); // check a null value s1.add(1.0, null); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertNull(r); // check a NaN s1.add(2.0, Double.NaN); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertNull(r); // check a regular value s1.add(3.0, 5.0); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertEquals(new Range(5.0, 5.0), r); // check another regular value s1.add(4.0, 6.0); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertEquals(new Range(5.0, 6.0), r); // add a second series XYSeries s2 = new XYSeries("B"); dataset.addSeries(s2); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertEquals(new Range(5.0, 6.0), r); visibleSeriesKeys.add("B"); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertEquals(new Range(5.0, 6.0), r); // add a value to the second series s2.add(5.0, 15.0); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertEquals(new Range(5.0, 15.0), r); // add a value that isn't in the xRange s2.add(15.0, 150.0); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false); assertEquals(new Range(5.0, 15.0), r); r = DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, new Range(0.0, 20.0), false); assertEquals(new Range(5.0, 150.0), r); } /** * Some checks for the iterateToFindRangeBounds() method when applied to * a BoxAndWhiskerXYDataset. */ public void testIterateToFindRangeBounds_BoxAndWhiskerXYDataset() { DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("Series 1"); List visibleSeriesKeys = new ArrayList(); visibleSeriesKeys.add("Series 1"); Range xRange = new Range(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); assertNull(DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false)); dataset.add(new Date(50L), new BoxAndWhiskerItem(5.0, 4.9, 2.0, 8.0, 1.0, 9.0, 0.0, 10.0, new ArrayList())); assertEquals(new Range(5.0, 5.0), DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, false)); assertEquals(new Range(1.0, 9.0), DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, xRange, true)); } /** * Some checks for the iterateToFindRangeBounds(CategoryDataset...) * method. */ public void testIterateToFindRangeBounds_StatisticalCategoryDataset() { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); List visibleSeriesKeys = new ArrayList(); assertNull(DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, false)); dataset.add(1.0, 0.5, "R1", "C1"); visibleSeriesKeys.add("R1"); assertEquals(new Range(1.0, 1.0), DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, false)); assertEquals(new Range(0.5, 1.5), DatasetUtilities.iterateToFindRangeBounds(dataset, visibleSeriesKeys, true)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultHeatMapDatasetTests.java0000644000175000017500000001760511173030414032702 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * DefaultHeatMapDatasetTests.java * ------------------------------- * (C) Copyright 2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes: * -------- * 28-Jan-2009 : Version 1 (DG); * */ package org.jfree.data.general.junit; import org.jfree.data.general.DefaultHeatMapDataset; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; /** * Somes tests for the {@link DefaultHeatMapDataset} class. * * @since 1.0.13 */ public class DefaultHeatMapDatasetTests extends TestCase implements DatasetChangeListener { /** The last event received. */ private DatasetChangeEvent lastEvent; /** * Records the last event. * * @param event the last event. */ public void datasetChanged(DatasetChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultHeatMapDatasetTests.class); } private static final double EPSILON = 0.0000000001; /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultHeatMapDatasetTests(String name) { super(name); } /** * Some general tests. */ public void testGeneral() { DefaultHeatMapDataset d = new DefaultHeatMapDataset(10, 5, 0.0, 9.0, 0.0, 5.0); assertEquals(10, d.getXSampleCount()); assertEquals(5, d.getYSampleCount()); assertEquals(0.0, d.getMinimumXValue(), EPSILON); assertEquals(9.0, d.getMaximumXValue(), EPSILON); assertEquals(0.0, d.getMinimumYValue(), EPSILON); assertEquals(5.0, d.getMaximumYValue(), EPSILON); assertEquals(0.0, d.getZValue(0, 0), EPSILON); d.addChangeListener(this); d.setZValue(0, 0, 1.0, false); assertEquals(1.0, d.getZValue(0, 0), EPSILON); assertNull(this.lastEvent); d.setZValue(1, 2, 2.0); assertEquals(2.0, d.getZValue(1, 2), EPSILON); assertNotNull(this.lastEvent); } /** * Some tests for the equals() method. */ public void testEquals() { DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, 3.0, 4.0); DefaultHeatMapDataset d2 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, 3.0, 4.0); assertEquals(d1, d2); d1 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0); assertFalse(d1.equals(d2)); d2 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0); assertTrue(d1.equals(d2)); d1 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0); assertFalse(d1.equals(d2)); d2 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0); assertTrue(d1.equals(d2)); d1 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0); assertFalse(d1.equals(d2)); d2 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0); assertTrue(d1.equals(d2)); d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0); assertFalse(d1.equals(d2)); d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0); assertTrue(d1.equals(d2)); d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0); assertFalse(d1.equals(d2)); d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0); assertTrue(d1.equals(d2)); d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0); assertFalse(d1.equals(d2)); d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0); assertTrue(d1.equals(d2)); d1.setZValue(1, 2, 3.0); assertFalse(d1.equals(d2)); d2.setZValue(1, 2, 3.0); assertTrue(d1.equals(d2)); d1.setZValue(0, 0, Double.NEGATIVE_INFINITY); assertFalse(d1.equals(d2)); d2.setZValue(0, 0, Double.NEGATIVE_INFINITY); assertTrue(d1.equals(d2)); d1.setZValue(0, 1, Double.POSITIVE_INFINITY); assertFalse(d1.equals(d2)); d2.setZValue(0, 1, Double.POSITIVE_INFINITY); assertTrue(d1.equals(d2)); d1.setZValue(0, 2, Double.NaN); assertFalse(d1.equals(d2)); d2.setZValue(0, 2, Double.NaN); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, -2.0, 5.0); d1.setZValue(0, 0, 10.0); d1.setZValue(0, 1, Double.NEGATIVE_INFINITY); d1.setZValue(0, 2, Double.POSITIVE_INFINITY); d1.setZValue(1, 0, Double.NaN); DefaultHeatMapDataset d2 = null; try { d2 = (DefaultHeatMapDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // simple check for independence d1.setZValue(0, 0, 11.0); assertFalse(d1.equals(d2)); d2.setZValue(0, 0, 11.0); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, -2.0, 5.0); d1.setZValue(0, 0, 10.0); d1.setZValue(0, 1, Double.NEGATIVE_INFINITY); d1.setZValue(0, 2, Double.POSITIVE_INFINITY); d1.setZValue(1, 0, Double.NaN); DefaultHeatMapDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultHeatMapDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultKeyedValueDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultKeyedValueDatasetTests.java0000644000175000017500000001222011173030414033405 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * DefaultKeyedValueDatasetTests.java * ---------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Aug-2003 : Version 1 (DG); * */ package org.jfree.data.general.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.DefaultKeyedValueDataset; /** * Tests for the {@link DefaultKeyedValueDataset} class. */ public class DefaultKeyedValueDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultKeyedValueDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultKeyedValueDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(45.5)); DefaultKeyedValueDataset d2 = new DefaultKeyedValueDataset("Test", new Double(45.5)); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = new DefaultKeyedValueDataset("Test 1", new Double(45.5)); d2 = new DefaultKeyedValueDataset("Test 2", new Double(45.5)); assertFalse(d1.equals(d2)); d1 = new DefaultKeyedValueDataset("Test", new Double(45.5)); d2 = new DefaultKeyedValueDataset("Test", new Double(45.6)); assertFalse(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(45.5)); DefaultKeyedValueDataset d2 = null; try { d2 = (DefaultKeyedValueDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Confirm that the clone is independent of the original. */ public void testCloneIndependence() { DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0)); DefaultKeyedValueDataset d2 = null; try { d2 = (DefaultKeyedValueDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1.equals(d2)); d2.updateValue(new Double(99.9)); assertFalse(d1.equals(d2)); d2.updateValue(new Double(10.0)); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Test", new Double(25.3)); DefaultKeyedValueDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultKeyedValueDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultKeyedValues2DDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultKeyedValues2DDatasetTests.j0000644000175000017500000001010411173030414033265 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------- * DefaultKeyedValues2DDatasetTests.java * ------------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (DG); * */ package org.jfree.data.general.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.DefaultKeyedValues2DDataset; /** * Tests for the {@link DefaultKeyedValues2DDataset} class. */ public class DefaultKeyedValues2DDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultKeyedValues2DDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultKeyedValues2DDatasetTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); d1.setValue(new Integer(1), "V1", "C1"); d1.setValue(null, "V2", "C1"); d1.setValue(new Integer(3), "V3", "C2"); DefaultKeyedValues2DDataset d2 = null; try { d2 = (DefaultKeyedValues2DDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); d1.addValue(new Double(234.2), "Row1", "Col1"); d1.addValue(null, "Row1", "Col2"); d1.addValue(new Double(345.9), "Row2", "Col1"); d1.addValue(new Double(452.7), "Row2", "Col2"); DefaultKeyedValues2DDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultKeyedValues2DDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultKeyedValuesDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultKeyedValuesDatasetTests.jav0000644000175000017500000001001611173030414033430 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * DefaultKeyedValuesDatasetTests.java * ----------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (DG); * */ package org.jfree.data.general.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.DefaultKeyedValuesDataset; import org.jfree.data.general.KeyedValuesDataset; /** * Tests for the {@link DefaultKeyedValuesDataset} class. */ public class DefaultKeyedValuesDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultKeyedValuesDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultKeyedValuesDatasetTests(String name) { super(name); } /** * Confirm that cloning works. */ public void testCloning() { DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); d1.setValue("V1", new Integer(1)); d1.setValue("V2", null); d1.setValue("V3", new Integer(3)); DefaultKeyedValuesDataset d2 = null; try { d2 = (DefaultKeyedValuesDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); d1.setValue("C1", new Double(234.2)); d1.setValue("C2", null); d1.setValue("C3", new Double(345.9)); d1.setValue("C4", new Double(452.7)); KeyedValuesDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (KeyedValuesDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/general/junit/DefaultPieDatasetTests.java0000644000175000017500000001400411173030414032066 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * PieDatasetTests.java * -------------------- * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Aug-2003 : Version 1 (DG); * 31-Jul-2006 : Added test for new clear() method (DG); * 01-Aug-2006 : Added testGetKey() and testGetIndex() methods (DG); * */ package org.jfree.data.general.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.general.DefaultPieDataset; /** * Tests for the {@link org.jfree.data.general.PieDataset} class. */ public class DefaultPieDatasetTests extends TestCase implements DatasetChangeListener { private DatasetChangeEvent lastEvent; /** * Records the last event. * * @param event the last event. */ public void datasetChanged(DatasetChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultPieDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultPieDatasetTests(String name) { super(name); } /** * Some tests for the clear() method. */ public void testClear() { DefaultPieDataset d = new DefaultPieDataset(); d.addChangeListener(this); // no event is generated if the dataset is already empty d.clear(); assertNull(this.lastEvent); d.setValue("A", 1.0); assertEquals(1, d.getItemCount()); this.lastEvent = null; d.clear(); assertNotNull(this.lastEvent); assertEquals(0, d.getItemCount()); } /** * Some checks for the getKey(int) method. */ public void testGetKey() { DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals("A", d.getKey(0)); assertEquals("B", d.getKey(1)); boolean pass = false; try { d.getKey(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { d.getKey(2); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getIndex() method. */ public void testGetIndex() { DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals(0, d.getIndex("A")); assertEquals(1, d.getIndex("B")); assertEquals(-1, d.getIndex("XX")); boolean pass = false; try { d.getIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Confirm that cloning works. */ public void testCloning() { DefaultPieDataset d1 = new DefaultPieDataset(); d1.setValue("V1", new Integer(1)); d1.setValue("V2", null); d1.setValue("V3", new Integer(3)); DefaultPieDataset d2 = null; try { d2 = (DefaultPieDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultPieDataset d1 = new DefaultPieDataset(); d1.setValue("C1", new Double(234.2)); d1.setValue("C2", null); d1.setValue("C3", new Double(345.9)); d1.setValue("C4", new Double(452.7)); DefaultPieDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultPieDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/0000755000175000017500000000000011216245562023246 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/ComparableObjectItemTests.java0000644000175000017500000001313111173030414031134 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * ComparableObjectItemTests.java * ------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.ComparableObjectItem; /** * Tests for the {@link ComparableObjectItem} class. */ public class ComparableObjectItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ComparableObjectItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ComparableObjectItemTests(String name) { super(name); } /** * Some checks for the constructor. */ public void testConstructor() { // check null argument 1 boolean pass = false; try { /* ComparableObjectItem item1 = */ new ComparableObjectItem(null, "XYZ"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), "XYZ"); ComparableObjectItem item2 = new ComparableObjectItem(new Integer(1), "XYZ"); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); item1 = new ComparableObjectItem(new Integer(2), "XYZ"); assertFalse(item1.equals(item2)); item2 = new ComparableObjectItem(new Integer(2), "XYZ"); assertTrue(item1.equals(item2)); item1 = new ComparableObjectItem(new Integer(2), null); assertFalse(item1.equals(item2)); item2 = new ComparableObjectItem(new Integer(2), null); assertTrue(item1.equals(item2)); } /** * Some checks for the clone() method. */ public void testCloning() { ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), "XYZ"); ComparableObjectItem item2 = null; try { item2 = (ComparableObjectItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), "XYZ"); ComparableObjectItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (ComparableObjectItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2); } /** * Some checks for the compareTo() method. */ public void testCompareTo() { ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), "XYZ"); ComparableObjectItem item2 = new ComparableObjectItem(new Integer(2), "XYZ"); ComparableObjectItem item3 = new ComparableObjectItem(new Integer(3), "XYZ"); ComparableObjectItem item4 = new ComparableObjectItem(new Integer(1), "XYZ"); assertTrue(item2.compareTo(item1) > 0); assertTrue(item3.compareTo(item1) > 0); assertTrue(item4.compareTo(item1) == 0); assertTrue(item1.compareTo(item2) < 0); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/ComparableObjectSeriesTests.java0000644000175000017500000001724311173030414031500 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * ComparableObjectSeriesTests.java * -------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 31-Oct-2007 : New hashCode() test (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.ComparableObjectItem; import org.jfree.data.ComparableObjectSeries; /** * Tests for the {@link ComparableObjectSeries} class. */ public class ComparableObjectSeriesTests extends TestCase { static class MyComparableObjectSeries extends ComparableObjectSeries { /** * Creates a new instance. * * @param key the series key. */ public MyComparableObjectSeries(Comparable key) { super(key); } /** * Creates a new instance. * * @param key the series key. * @param autoSort automatically sort by x-value? * @param allowDuplicateXValues allow duplicate values? */ public MyComparableObjectSeries(Comparable key, boolean autoSort, boolean allowDuplicateXValues) { super(key, autoSort, allowDuplicateXValues); } public void add(Comparable x, Object y) { super.add(x, y); } public ComparableObjectItem remove(Comparable x) { return super.remove(x); } } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ComparableObjectSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ComparableObjectSeriesTests(String name) { super(name); } /** * Some checks for the constructor. */ public void testConstructor1() { ComparableObjectSeries s1 = new ComparableObjectSeries("s1"); assertEquals("s1", s1.getKey()); assertNull(s1.getDescription()); assertTrue(s1.getAllowDuplicateXValues()); assertTrue(s1.getAutoSort()); assertEquals(0, s1.getItemCount()); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); // try null key boolean pass = false; try { /*s1 = */new ComparableObjectSeries(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MyComparableObjectSeries s1 = new MyComparableObjectSeries("A"); MyComparableObjectSeries s2 = new MyComparableObjectSeries("A"); assertTrue(s1.equals(s2)); assertTrue(s2.equals(s1)); // key s1 = new MyComparableObjectSeries("B"); assertFalse(s1.equals(s2)); s2 = new MyComparableObjectSeries("B"); assertTrue(s1.equals(s2)); // autoSort s1 = new MyComparableObjectSeries("B", false, true); assertFalse(s1.equals(s2)); s2 = new MyComparableObjectSeries("B", false, true); assertTrue(s1.equals(s2)); // allowDuplicateXValues s1 = new MyComparableObjectSeries("B", false, false); assertFalse(s1.equals(s2)); s2 = new MyComparableObjectSeries("B", false, false); assertTrue(s1.equals(s2)); // add a value s1.add(new Integer(1), "ABC"); assertFalse(s1.equals(s2)); s2.add(new Integer(1), "ABC"); assertTrue(s1.equals(s2)); // add another value s1.add(new Integer(0), "DEF"); assertFalse(s1.equals(s2)); s2.add(new Integer(0), "DEF"); assertTrue(s1.equals(s2)); // remove an item s1.remove(new Integer(1)); assertFalse(s1.equals(s2)); s2.remove(new Integer(1)); assertTrue(s1.equals(s2)); } /** * Some checks for the clone() method. */ public void testCloning() { MyComparableObjectSeries s1 = new MyComparableObjectSeries("A"); s1.add(new Integer(1), "ABC"); MyComparableObjectSeries s2 = null; try { s2 = (MyComparableObjectSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MyComparableObjectSeries s1 = new MyComparableObjectSeries("A"); s1.add(new Integer(1), "ABC"); MyComparableObjectSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (MyComparableObjectSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Some simple checks for the hashCode() method. */ public void testHashCode() { MyComparableObjectSeries s1 = new MyComparableObjectSeries("Test"); MyComparableObjectSeries s2 = new MyComparableObjectSeries("Test"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add("A", "1"); s2.add("A", "1"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add("B", null); s2.add("B", null); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add("C", "3"); s2.add("C", "3"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add("D", "4"); s2.add("D", "4"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/DataPackageTests.java0000644000175000017500000000733711173030414027261 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DataPackageTests.java * --------------------- * (C) Copyright 2001-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; * * Changes * ------- * 16-Nov-2001 : Version 1 (DG); * 30-Sep-2002 : Added tests for the Regression class (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 05-Mar-2003 : Added tests for the DefaultKeyedValues class (DG); * 13-Mar-2003 : Added tests for the DefaultKeyedValue class (DG); * 12-Aug-2003 : Added tests for TableXYDataset class (RA); * 23-Dec-2003 : Added tests for XYDataItem, XYSeries and * DefaultTableXYDataset (DG); * 23-Mar-2004 : Added tests for DateRange class (DG); * 23-Aug-2004 : Restructured org.jfree.data package (DG); * 18-Jan-2005 : Added main() method (DG); * */ package org.jfree.data.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data package that can be run using * JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data"); suite.addTestSuite(ComparableObjectItemTests.class); suite.addTestSuite(ComparableObjectSeriesTests.class); suite.addTestSuite(DataUtilitiesTests.class); suite.addTestSuite(DefaultKeyedValueTests.class); suite.addTestSuite(DefaultKeyedValuesTests.class); suite.addTestSuite(DefaultKeyedValues2DTests.class); suite.addTestSuite(DomainOrderTests.class); suite.addTestSuite(KeyedObjectTests.class); suite.addTestSuite(KeyedObjectsTests.class); suite.addTestSuite(KeyedObjects2DTests.class); suite.addTestSuite(KeyToGroupMapTests.class); suite.addTestSuite(RangeTests.class); suite.addTestSuite(RangeTypeTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/DataUtilitiesTests.java0000644000175000017500000002260711173030414027676 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DataUtilitiesTests.java * ----------------------- * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 03-Mar-2005 : Version 1 (DG); * 28-Jan-2009 : Added tests for equal(double[][], double[][]) method (DG); * 28-Jan-2009 : Added tests for clone(double[][]) (DG); * 04-Feb-2009 : Added tests for new calculateColumnTotal/RowTotal methods (DG); * */ package org.jfree.data.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.DataUtilities; import org.jfree.data.DefaultKeyedValues2D; /** * Some tests for the {@link DataUtilities} class. */ public class DataUtilitiesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DataUtilitiesTests.class); } /** * Tests the createNumberArray2D() method. */ public void testCreateNumberArray2D() { double[][] d = new double[2][]; d[0] = new double[] {1.1, 2.2, 3.3, 4.4}; d[1] = new double[] {1.1, 2.2, 3.3, 4.4, 5.5}; Number[][] n = DataUtilities.createNumberArray2D(d); assertEquals(2, n.length); assertEquals(4, n[0].length); assertEquals(5, n[1].length); } private static final double EPSILON = 0.000000001; /** * Some checks for the calculateColumnTotal() method. */ public void testCalculateColumnTotal() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON); assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); } /** * Some checks for the calculateColumnTotal() method. */ public void testCalculateColumnTotal2() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {0, 1}), EPSILON); assertEquals(1.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {0}), EPSILON); assertEquals(3.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {1}), EPSILON); assertEquals(0.0, DataUtilities.calculateColumnTotal(table, 0, new int[] {}), EPSILON); assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {0}), EPSILON); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {1}), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(0.0, DataUtilities.calculateColumnTotal(table, 1, new int[] {1}), EPSILON); } /** * Some checks for the calculateRowTotal() method. */ public void testCalculateRowTotal() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON); assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); } /** * Some checks for the calculateRowTotal() method. */ public void testCalculateRowTotal2() { DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0, new int[] {0, 1}), EPSILON); assertEquals(1.0, DataUtilities.calculateRowTotal(table, 0, new int[] {0}), EPSILON); assertEquals(2.0, DataUtilities.calculateRowTotal(table, 0, new int[] {1}), EPSILON); assertEquals(0.0, DataUtilities.calculateRowTotal(table, 0, new int[] {}), EPSILON); assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1, new int[] {0}), EPSILON); assertEquals(4.0, DataUtilities.calculateRowTotal(table, 1, new int[] {1}), EPSILON); assertEquals(0.0, DataUtilities.calculateRowTotal(table, 1, new int[] {}), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1, new int[] {0, 1}), EPSILON); assertEquals(0.0, DataUtilities.calculateRowTotal(table, 1, new int[] {1}), EPSILON); } /** * Some tests for the equal(double[][], double[][]) method. */ public void testEqual() { assertTrue(DataUtilities.equal(null, null)); double[][] a = new double[5][]; double[][] b = new double[5][]; assertTrue(DataUtilities.equal(a, b)); a = new double[4][]; assertFalse(DataUtilities.equal(a, b)); b = new double[4][]; assertTrue(DataUtilities.equal(a, b)); a[0] = new double[6]; assertFalse(DataUtilities.equal(a, b)); b[0] = new double[6]; assertTrue(DataUtilities.equal(a, b)); a[0][0] = 1.0; assertFalse(DataUtilities.equal(a, b)); b[0][0] = 1.0; assertTrue(DataUtilities.equal(a, b)); a[0][1] = Double.NaN; assertFalse(DataUtilities.equal(a, b)); b[0][1] = Double.NaN; assertTrue(DataUtilities.equal(a, b)); a[0][2] = Double.NEGATIVE_INFINITY; assertFalse(DataUtilities.equal(a, b)); b[0][2] = Double.NEGATIVE_INFINITY; assertTrue(DataUtilities.equal(a, b)); a[0][3] = Double.POSITIVE_INFINITY; assertFalse(DataUtilities.equal(a, b)); b[0][3] = Double.POSITIVE_INFINITY; assertTrue(DataUtilities.equal(a, b)); a[0][4] = Double.POSITIVE_INFINITY; assertFalse(DataUtilities.equal(a, b)); b[0][4] = Double.NEGATIVE_INFINITY; assertFalse(DataUtilities.equal(a, b)); b[0][4] = Double.POSITIVE_INFINITY; assertTrue(DataUtilities.equal(a, b)); } /** * Some tests for the clone() method. */ public void testClone() { double[][] a = new double[1][]; double[][] b = DataUtilities.clone(a); assertTrue(DataUtilities.equal(a, b)); a[0] = new double[] { 3.0, 4.0 }; assertFalse(DataUtilities.equal(a, b)); b[0] = new double[] { 3.0, 4.0 }; assertTrue(DataUtilities.equal(a, b)); a = new double[2][3]; a[0][0] = 1.23; a[1][1] = Double.NaN; b = DataUtilities.clone(a); assertTrue(DataUtilities.equal(a, b)); a[0][0] = 99.9; assertFalse(DataUtilities.equal(a, b)); b[0][0] = 99.9; assertTrue(DataUtilities.equal(a, b)); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/DefaultKeyedValueTests.java0000644000175000017500000001201211173030414030461 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * DefaultKeyedValueTests.java * --------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.DefaultKeyedValue; /** * Tests for the {@link DefaultKeyedValue} class. */ public class DefaultKeyedValueTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultKeyedValueTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultKeyedValueTests(String name) { super(name); } /** * Simple checks for the constructor. */ public void testConstructor() { DefaultKeyedValue v = new DefaultKeyedValue("A", new Integer(1)); assertEquals("A", v.getKey()); assertEquals(new Integer(1), v.getValue()); // try null key boolean pass = false; try { /*v =*/ new DefaultKeyedValue(null, new Integer(1)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // try a null value v = new DefaultKeyedValue("A", null); assertNull(v.getValue()); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); DefaultKeyedValue v2 = new DefaultKeyedValue("Test", new Double(45.5)); assertTrue(v1.equals(v2)); assertTrue(v2.equals(v1)); v1 = new DefaultKeyedValue("Test 1", new Double(45.5)); v2 = new DefaultKeyedValue("Test 2", new Double(45.5)); assertFalse(v1.equals(v2)); v1 = new DefaultKeyedValue("Test", new Double(45.5)); v2 = new DefaultKeyedValue("Test", new Double(45.6)); assertFalse(v1.equals(v2)); } /** * Some checks for the clone() method. */ public void testCloning() { DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); DefaultKeyedValue v2 = null; try { v2 = (DefaultKeyedValue) v1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); // confirm that the clone is independent of the original v2.setValue(new Double(12.3)); assertFalse(v1.equals(v2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(25.3)); DefaultKeyedValue v2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); v2 = (DefaultKeyedValue) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(v1, v2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java0000644000175000017500000002631711173030414031047 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * DefaultKeyedValues2DTests.java * ------------------------------ * (C) Copyright 2003-2008 by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (DG); * 15-Sep-2004 : Updated cloning test (DG); * 06-Oct-2005 : Added testEquals() (DG); * 18-Jan-2007 : Added testSparsePopulation() (DG); * 26-Feb-2007 : Added some basic tests (DG); * 30-Mar-2007 : Added a test for bug 1690654 (DG); * 21-Nov-2007 : Added testRemoveColumnByKey() method (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.DefaultKeyedValues2D; import org.jfree.data.UnknownKeyException; /** * Tests for the {@link DefaultKeyedValues2D} class. */ public class DefaultKeyedValues2DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultKeyedValues2DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultKeyedValues2DTests(String name) { super(name); } /** * Some checks for the getValue() method. */ public void testGetValue() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); d.addValue(new Double(1.0), "R1", "C1"); assertEquals(new Double(1.0), d.getValue("R1", "C1")); boolean pass = false; try { d.getValue("XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.getValue("R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Some checks for the clone() method. */ public void testCloning() { DefaultKeyedValues2D v1 = new DefaultKeyedValues2D(); v1.setValue(new Integer(1), "V1", "C1"); v1.setValue(null, "V2", "C1"); v1.setValue(new Integer(3), "V3", "C2"); DefaultKeyedValues2D v2 = null; try { v2 = (DefaultKeyedValues2D) v1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); // check that clone is independent of the original v2.setValue(new Integer(2), "V2", "C1"); assertFalse(v1.equals(v2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValues2D kv2D1 = new DefaultKeyedValues2D(); kv2D1.addValue(new Double(234.2), "Row1", "Col1"); kv2D1.addValue(null, "Row1", "Col2"); kv2D1.addValue(new Double(345.9), "Row2", "Col1"); kv2D1.addValue(new Double(452.7), "Row2", "Col2"); DefaultKeyedValues2D kv2D2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(kv2D1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); kv2D2 = (DefaultKeyedValues2D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(kv2D1, kv2D2); } /** * Some checks for the equals() method. */ public void testEquals() { DefaultKeyedValues2D d1 = new DefaultKeyedValues2D(); DefaultKeyedValues2D d2 = new DefaultKeyedValues2D(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.addValue(new Double(1.0), new Double(2.0), "S1"); assertFalse(d1.equals(d2)); d2.addValue(new Double(1.0), new Double(2.0), "S1"); assertTrue(d1.equals(d2)); } /** * Populates a data structure with sparse entries, then checks that * the unspecified entries return null. */ public void testSparsePopulation() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); d.addValue(new Integer(11), "R1", "C1"); d.addValue(new Integer(22), "R2", "C2"); assertEquals(new Integer(11), d.getValue("R1", "C1")); assertNull(d.getValue("R1", "C2")); assertEquals(new Integer(22), d.getValue("R2", "C2")); assertNull(d.getValue("R2", "C1")); } /** * Some basic checks for the getRowCount() method. */ public void testRowCount() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); assertEquals(0, d.getRowCount()); d.addValue(new Double(1.0), "R1", "C1"); assertEquals(1, d.getRowCount()); d.addValue(new Double(2.0), "R2", "C1"); assertEquals(2, d.getRowCount()); } /** * Some basic checks for the getColumnCount() method. */ public void testColumnCount() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); assertEquals(0, d.getColumnCount()); d.addValue(new Double(1.0), "R1", "C1"); assertEquals(1, d.getColumnCount()); d.addValue(new Double(2.0), "R1", "C2"); assertEquals(2, d.getColumnCount()); } private static final double EPSILON = 0.0000000001; /** * Some basic checks for the getValue(int, int) method. */ public void testGetValue2() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); boolean pass = false; try { d.getValue(0, 0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); d.addValue(new Double(1.0), "R1", "C1"); assertEquals(1.0, d.getValue(0, 0).doubleValue(), EPSILON); d.addValue(new Double(2.0), "R2", "C2"); assertEquals(2.0, d.getValue(1, 1).doubleValue(), EPSILON); assertNull(d.getValue(1, 0)); assertNull(d.getValue(0, 1)); pass = false; try { d.getValue(2, 0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some basic checks for the getRowKey() method. */ public void testGetRowKey() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); boolean pass = false; try { d.getRowKey(0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(1.0), "R2", "C1"); assertEquals("R1", d.getRowKey(0)); assertEquals("R2", d.getRowKey(1)); // check sorted rows d = new DefaultKeyedValues2D(true); d.addValue(new Double(1.0), "R1", "C1"); assertEquals("R1", d.getRowKey(0)); d.addValue(new Double(0.0), "R0", "C1"); assertEquals("R0", d.getRowKey(0)); assertEquals("R1", d.getRowKey(1)); } /** * Some basic checks for the getColumnKey() method. */ public void testGetColumnKey() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); boolean pass = false; try { d.getColumnKey(0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(1.0), "R1", "C2"); assertEquals("C1", d.getColumnKey(0)); assertEquals("C2", d.getColumnKey(1)); } /** * Some basic checks for the removeValue() method. */ public void testRemoveValue() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); d.removeValue("R1", "C1"); d.addValue(new Double(1.0), "R1", "C1"); d.removeValue("R1", "C1"); assertEquals(0, d.getRowCount()); assertEquals(0, d.getColumnCount()); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(2.0), "R2", "C1"); d.removeValue("R1", "C1"); assertEquals(new Double(2.0), d.getValue(0, 0)); } /** * A test for bug 1690654. */ public void testRemoveValueBug1690654() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(2.0), "R2", "C2"); assertEquals(2, d.getColumnCount()); assertEquals(2, d.getRowCount()); d.removeValue("R2", "C2"); assertEquals(1, d.getColumnCount()); assertEquals(1, d.getRowCount()); assertEquals(new Double(1.0), d.getValue(0, 0)); } /** * Some basic checks for the removeRow() method. */ public void testRemoveRow() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); boolean pass = false; try { d.removeRow(0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some basic checks for the removeColumn(Comparable) method. */ public void testRemoveColumnByKey() { DefaultKeyedValues2D d = new DefaultKeyedValues2D(); d.addValue(new Double(1.0), "R1", "C1"); d.addValue(new Double(2.0), "R2", "C2"); d.removeColumn("C2"); d.addValue(new Double(3.0), "R2", "C2"); assertEquals(3.0, d.getValue("R2", "C2").doubleValue(), EPSILON); // check for unknown column boolean pass = false; try { d.removeColumn("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java0000644000175000017500000004064311173030414030657 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DefaultKeyedValuesTests.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Mar-2003 : Version 1 (DG); * 27-Aug-2003 : Moved SortOrder from org.jfree.data --> org.jfree.util (DG); * 31-Jul-2006 : Added test for new clear() method (DG); * 01-Aug-2006 : Extended testGetIndex() method (DG); * 30-Apr-2007 : Added some new tests (DG); * 03-Oct-2007 : Updated testRemoveValue() (DG); * 21-Nov-2007 : Added testGetIndex2() method (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.DefaultKeyedValues; import org.jfree.data.UnknownKeyException; import org.jfree.util.SortOrder; /** * Tests for the {@link DefaultKeyedValues} class. */ public class DefaultKeyedValuesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultKeyedValuesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultKeyedValuesTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup required } /** * Checks that a new instance is empty. */ public void testConstructor() { DefaultKeyedValues d = new DefaultKeyedValues(); assertEquals(0, d.getItemCount()); } /** * Some checks for the getItemCount() method. */ public void testGetItemCount() { DefaultKeyedValues d = new DefaultKeyedValues(); assertEquals(0, d.getItemCount()); d.addValue("A", 1.0); assertEquals(1, d.getItemCount()); d.addValue("B", 2.0); assertEquals(2, d.getItemCount()); d.clear(); assertEquals(0, d.getItemCount()); } /** * Some checks for the getKeys() method. */ public void testGetKeys() { DefaultKeyedValues d = new DefaultKeyedValues(); List keys = d.getKeys(); assertTrue(keys.isEmpty()); d.addValue("A", 1.0); keys = d.getKeys(); assertEquals(1, keys.size()); assertTrue(keys.contains("A")); d.addValue("B", 2.0); keys = d.getKeys(); assertEquals(2, keys.size()); assertTrue(keys.contains("A")); assertTrue(keys.contains("B")); d.clear(); keys = d.getKeys(); assertEquals(0, keys.size()); } /** * A simple test for the clear() method. */ public void testClear() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("A", 1.0); v1.addValue("B", 2.0); assertEquals(2, v1.getItemCount()); v1.clear(); assertEquals(0, v1.getItemCount()); } /** * Some checks for the getValue() methods. */ public void testGetValue() { DefaultKeyedValues v1 = new DefaultKeyedValues(); try { /* Number n = */ v1.getValue(-1); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } try { /* Number n = */ v1.getValue(0); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } DefaultKeyedValues v2 = new DefaultKeyedValues(); v2.addValue("K1", new Integer(1)); v2.addValue("K2", new Integer(2)); v2.addValue("K3", new Integer(3)); assertEquals(new Integer(3), v2.getValue(2)); boolean pass = false; try { /* Number n = */ v2.getValue("KK"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getKey() methods. */ public void testGetKey() { DefaultKeyedValues v1 = new DefaultKeyedValues(); try { /* Comparable k = */ v1.getKey(-1); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } try { /* Comparable k = */ v1.getKey(0); assertTrue(false); } catch (IndexOutOfBoundsException e) { // expected } DefaultKeyedValues v2 = new DefaultKeyedValues(); v2.addValue("K1", new Integer(1)); v2.addValue("K2", new Integer(2)); v2.addValue("K3", new Integer(3)); assertEquals("K2", v2.getKey(1)); } /** * Some checks for the getIndex() methods. */ public void testGetIndex() { DefaultKeyedValues v1 = new DefaultKeyedValues(); assertEquals(-1, v1.getIndex("K1")); DefaultKeyedValues v2 = new DefaultKeyedValues(); v2.addValue("K1", new Integer(1)); v2.addValue("K2", new Integer(2)); v2.addValue("K3", new Integer(3)); assertEquals(2, v2.getIndex("K3")); // try null boolean pass = false; try { v2.getIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Another check for the getIndex(Comparable) method. */ public void testGetIndex2() { DefaultKeyedValues v = new DefaultKeyedValues(); assertEquals(-1, v.getIndex("K1")); v.addValue("K1", 1.0); assertEquals(0, v.getIndex("K1")); v.removeValue("K1"); assertEquals(-1, v.getIndex("K1")); } /** * Some checks for the addValue() method. */ public void testAddValue() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("A", 1.0); assertEquals(new Double(1.0), v1.getValue("A")); v1.addValue("B", 2.0); assertEquals(new Double(2.0), v1.getValue("B")); v1.addValue("B", 3.0); assertEquals(new Double(3.0), v1.getValue("B")); assertEquals(2, v1.getItemCount()); v1.addValue("A", null); assertNull(v1.getValue("A")); assertEquals(2, v1.getItemCount()); boolean pass = false; try { v1.addValue(null, 99.9); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the insertValue() method. */ public void testInsertValue() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.insertValue(0, "A", 1.0); assertEquals(new Double(1.0), v1.getValue(0)); v1.insertValue(0, "B", 2.0); assertEquals(new Double(2.0), v1.getValue(0)); assertEquals(new Double(1.0), v1.getValue(1)); // it's OK to use an index equal to the size of the list v1.insertValue(2, "C", 3.0); assertEquals(new Double(2.0), v1.getValue(0)); assertEquals(new Double(1.0), v1.getValue(1)); assertEquals(new Double(3.0), v1.getValue(2)); // try replacing an existing value v1.insertValue(2, "B", 4.0); assertEquals(new Double(1.0), v1.getValue(0)); assertEquals(new Double(3.0), v1.getValue(1)); assertEquals(new Double(4.0), v1.getValue(2)); } /** * Some checks for the clone() method. */ public void testCloning() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("V1", new Integer(1)); v1.addValue("V2", null); v1.addValue("V3", new Integer(3)); DefaultKeyedValues v2 = null; try { v2 = (DefaultKeyedValues) v1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); // confirm that the clone is independent of the original v2.setValue("V1", new Integer(44)); assertFalse(v1.equals(v2)); } /** * Check that inserting and retrieving values works as expected. */ public void testInsertAndRetrieve() { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("A", new Double(1.0)); data.addValue("B", new Double(2.0)); data.addValue("C", new Double(3.0)); data.addValue("D", null); // check key order assertEquals(data.getKey(0), "A"); assertEquals(data.getKey(1), "B"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "D"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(1.0)); assertEquals(data.getValue("B"), new Double(2.0)); assertEquals(data.getValue("C"), new Double(3.0)); assertEquals(data.getValue("D"), null); // check retrieve value by index assertEquals(data.getValue(0), new Double(1.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(3.0)); assertEquals(data.getValue(3), null); } /** * Some tests for the removeValue() method. */ public void testRemoveValue() { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("A", new Double(1.0)); data.addValue("B", null); data.addValue("C", new Double(3.0)); data.addValue("D", new Double(2.0)); assertEquals(1, data.getIndex("B")); data.removeValue("B"); assertEquals(-1, data.getIndex("B")); boolean pass = false; try { data.removeValue("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Tests sorting of data by key (ascending). */ public void testSortByKeyAscending() { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByKeys(SortOrder.ASCENDING); // check key order assertEquals(data.getKey(0), "A"); assertEquals(data.getKey(1), "B"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "D"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(2.0)); assertEquals(data.getValue(1), null); assertEquals(data.getValue(2), new Double(1.0)); assertEquals(data.getValue(3), new Double(3.0)); } /** * Tests sorting of data by key (descending). */ public void testSortByKeyDescending() { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByKeys(SortOrder.DESCENDING); // check key order assertEquals(data.getKey(0), "D"); assertEquals(data.getKey(1), "C"); assertEquals(data.getKey(2), "B"); assertEquals(data.getKey(3), "A"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(3.0)); assertEquals(data.getValue(1), new Double(1.0)); assertEquals(data.getValue(2), null); assertEquals(data.getValue(3), new Double(2.0)); } /** * Tests sorting of data by value (ascending). */ public void testSortByValueAscending() { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByValues(SortOrder.ASCENDING); // check key order assertEquals(data.getKey(0), "C"); assertEquals(data.getKey(1), "A"); assertEquals(data.getKey(2), "D"); assertEquals(data.getKey(3), "B"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(1.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(3.0)); assertEquals(data.getValue(3), null); } /** * Tests sorting of data by key (descending). */ public void testSortByValueDescending() { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("C", new Double(1.0)); data.addValue("B", null); data.addValue("D", new Double(3.0)); data.addValue("A", new Double(2.0)); data.sortByValues(SortOrder.DESCENDING); // check key order assertEquals(data.getKey(0), "D"); assertEquals(data.getKey(1), "A"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "B"); // check retrieve value by key assertEquals(data.getValue("A"), new Double(2.0)); assertEquals(data.getValue("B"), null); assertEquals(data.getValue("C"), new Double(1.0)); assertEquals(data.getValue("D"), new Double(3.0)); // check retrieve value by index assertEquals(data.getValue(0), new Double(3.0)); assertEquals(data.getValue(1), new Double(2.0)); assertEquals(data.getValue(2), new Double(1.0)); assertEquals(data.getValue(3), null); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("Key 1", new Double(23)); v1.addValue("Key 2", null); v1.addValue("Key 3", new Double(42)); DefaultKeyedValues v2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); v2 = (DefaultKeyedValues) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(v1, v2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/DomainOrderTests.java0000644000175000017500000001045711173030414027334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * DomainOrderTests.java * --------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-May-2005 : Version 1 (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.DomainOrder; /** * Tests for the {@link DomainOrder} class. */ public class DomainOrderTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DomainOrderTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DomainOrderTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { assertEquals(DomainOrder.NONE, DomainOrder.NONE); assertEquals(DomainOrder.ASCENDING, DomainOrder.ASCENDING); assertEquals(DomainOrder.DESCENDING, DomainOrder.DESCENDING); assertFalse(DomainOrder.NONE.equals(DomainOrder.ASCENDING)); assertFalse(DomainOrder.NONE.equals(DomainOrder.DESCENDING)); assertFalse(DomainOrder.NONE.equals(null)); assertFalse(DomainOrder.ASCENDING.equals(DomainOrder.NONE)); assertFalse(DomainOrder.ASCENDING.equals(DomainOrder.DESCENDING)); assertFalse(DomainOrder.ASCENDING.equals(null)); assertFalse(DomainOrder.DESCENDING.equals(DomainOrder.NONE)); assertFalse(DomainOrder.DESCENDING.equals(DomainOrder.ASCENDING)); assertFalse(DomainOrder.DESCENDING.equals(null)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { DomainOrder d1 = DomainOrder.ASCENDING; DomainOrder d2 = DomainOrder.ASCENDING; assertTrue(d1.equals(d2)); int h1 = d1.hashCode(); int h2 = d2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DomainOrder d1 = DomainOrder.ASCENDING; DomainOrder d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DomainOrder) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); boolean same = d1 == d2; assertEquals(true, same); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/KeyToGroupMapTests.java0000644000175000017500000002163611173030414027640 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * KeyToGroupMapTests.java * ----------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2004 : Version 1 (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.KeyToGroupMap; /** * Tests for the {@link KeyToGroupMap} class. */ public class KeyToGroupMapTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(KeyToGroupMapTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public KeyToGroupMapTests(String name) { super(name); } /** * Tests the mapKeyToGroup() method. */ public void testMapKeyToGroup() { KeyToGroupMap m1 = new KeyToGroupMap("G1"); // map a key to the default group m1.mapKeyToGroup("K1", "G1"); assertEquals("G1", m1.getGroup("K1")); // map a key to a new group m1.mapKeyToGroup("K2", "G2"); assertEquals("G2", m1.getGroup("K2")); // clear a mapping m1.mapKeyToGroup("K2", null); assertEquals("G1", m1.getGroup("K2")); // after clearing, reverts to // default group // check handling of null key boolean pass = false; try { m1.mapKeyToGroup(null, "G1"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Tests that the getGroupCount() method returns the correct values under * various circumstances. */ public void testGroupCount() { KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); // a new map always has 1 group (the default group) assertEquals(1, m1.getGroupCount()); // if the default group is not mapped to, it should still count towards // the group count... m1.mapKeyToGroup("C1", "G1"); assertEquals(2, m1.getGroupCount()); // now when the default group is mapped to, it shouldn't increase the // group count... m1.mapKeyToGroup("C2", "Default Group"); assertEquals(2, m1.getGroupCount()); // complicate things a little... m1.mapKeyToGroup("C3", "Default Group"); m1.mapKeyToGroup("C4", "G2"); m1.mapKeyToGroup("C5", "G2"); m1.mapKeyToGroup("C6", "Default Group"); assertEquals(3, m1.getGroupCount()); // now overwrite group "G2"... m1.mapKeyToGroup("C4", "G1"); m1.mapKeyToGroup("C5", "G1"); assertEquals(2, m1.getGroupCount()); } /** * Tests that the getKeyCount() method returns the correct values under * various circumstances. */ public void testKeyCount() { KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); // a new map always has 1 group (the default group) assertEquals(0, m1.getKeyCount("Default Group")); // simple case m1.mapKeyToGroup("K1", "G1"); assertEquals(1, m1.getKeyCount("G1")); m1.mapKeyToGroup("K1", null); assertEquals(0, m1.getKeyCount("G1")); // if there is an explicit mapping to the default group, it is counted m1.mapKeyToGroup("K2", "Default Group"); assertEquals(1, m1.getKeyCount("Default Group")); // complicate things a little... m1.mapKeyToGroup("K3", "Default Group"); m1.mapKeyToGroup("K4", "G2"); m1.mapKeyToGroup("K5", "G2"); m1.mapKeyToGroup("K6", "Default Group"); assertEquals(3, m1.getKeyCount("Default Group")); assertEquals(2, m1.getKeyCount("G2")); // now overwrite group "G2"... m1.mapKeyToGroup("K4", "G1"); m1.mapKeyToGroup("K5", "G1"); assertEquals(2, m1.getKeyCount("G1")); assertEquals(0, m1.getKeyCount("G2")); } /** * Tests the getGroupIndex() method. */ public void testGetGroupIndex() { KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); // the default group is always at index 0 assertEquals(0, m1.getGroupIndex("Default Group")); // a non-existent group should return -1 assertEquals(-1, m1.getGroupIndex("G3")); // indices are assigned in the order that groups are originally mapped m1.mapKeyToGroup("K3", "G3"); m1.mapKeyToGroup("K1", "G1"); m1.mapKeyToGroup("K2", "G2"); assertEquals(1, m1.getGroupIndex("G3")); assertEquals(2, m1.getGroupIndex("G1")); assertEquals(3, m1.getGroupIndex("G2")); } /** * Tests the getGroup() method. */ public void testGetGroup() { KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); // a key that hasn't been mapped should return the default group assertEquals("Default Group", m1.getGroup("K1")); m1.mapKeyToGroup("K1", "G1"); assertEquals("G1", m1.getGroup("K1")); m1.mapKeyToGroup("K1", "G2"); assertEquals("G2", m1.getGroup("K1")); m1.mapKeyToGroup("K1", null); assertEquals("Default Group", m1.getGroup("K1")); // a null argument should throw an exception boolean pass = false; try { Comparable g = m1.getGroup(null); System.out.println(g); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); KeyToGroupMap m2 = new KeyToGroupMap("Default Group"); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); m1.mapKeyToGroup("K1", "G1"); assertFalse(m1.equals(m2)); m2.mapKeyToGroup("K1", "G1"); assertTrue(m1.equals(m2)); } /** * Confirm that cloning works. */ public void testCloning() { KeyToGroupMap m1 = new KeyToGroupMap("Test"); m1.mapKeyToGroup("K1", "G1"); KeyToGroupMap m2 = null; try { m2 = (KeyToGroupMap) m1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(m1 != m2); assertTrue(m1.getClass() == m2.getClass()); assertTrue(m1.equals(m2)); // a small check for independence m1.mapKeyToGroup("K1", "G2"); assertFalse(m1.equals(m2)); m2.mapKeyToGroup("K1", "G2"); assertTrue(m1.equals(m2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { KeyToGroupMap m1 = new KeyToGroupMap("Test"); KeyToGroupMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); m2 = (KeyToGroupMap) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(m1, m2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/KeyedObjectTests.java0000644000175000017500000001262711173030414027322 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * KeyedObjectTests.java * --------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Jan-2004 : Version 1 (DG); * 28-Sep-2007 : Added testCloning2() (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.KeyedObject; import org.jfree.data.general.DefaultPieDataset; /** * Tests for the {@link KeyedObject} class. */ public class KeyedObjectTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(KeyedObjectTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public KeyedObjectTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { KeyedObject ko1 = new KeyedObject("Test", "Object"); KeyedObject ko2 = new KeyedObject("Test", "Object"); assertTrue(ko1.equals(ko2)); assertTrue(ko2.equals(ko1)); ko1 = new KeyedObject("Test 1", "Object"); ko2 = new KeyedObject("Test 2", "Object"); assertFalse(ko1.equals(ko2)); ko1 = new KeyedObject("Test", "Object 1"); ko2 = new KeyedObject("Test", "Object 2"); assertFalse(ko1.equals(ko2)); } /** * Confirm that cloning works. */ public void testCloning() { KeyedObject ko1 = new KeyedObject("Test", "Object"); KeyedObject ko2 = null; try { ko2 = (KeyedObject) ko1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2)); } /** * Confirm special features of cloning. */ public void testCloning2() { // case 1 - object is mutable but not PublicCloneable Object obj1 = new ArrayList(); KeyedObject ko1 = new KeyedObject("Test", obj1); KeyedObject ko2 = null; try { ko2 = (KeyedObject) ko1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2)); // the clone contains a reference to the original object assertTrue(ko2.getObject() == obj1); // CASE 2 - object is mutable AND PublicCloneable obj1 = new DefaultPieDataset(); ko1 = new KeyedObject("Test", obj1); ko2 = null; try { ko2 = (KeyedObject) ko1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2)); // the clone contains a reference to a CLONE of the original object assertTrue(ko2.getObject() != obj1); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { KeyedObject ko1 = new KeyedObject("Test", "Object"); KeyedObject ko2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); ko2 = (KeyedObject) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko1, ko2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/KeyedObjects2DTests.java0000644000175000017500000002737511173030414027701 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * KeyedObjects2DTests.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * 28-Sep-2007 : Added testEquals() and enhanced testClone() (DG); * 03-Oct-2007 : Added new tests (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.KeyedObjects2D; import org.jfree.data.UnknownKeyException; /** * Tests for the {@link KeyedObjects2D} class. */ public class KeyedObjects2DTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(KeyedObjects2DTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public KeyedObjects2DTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { KeyedObjects2D k1 = new KeyedObjects2D(); KeyedObjects2D k2 = new KeyedObjects2D(); assertTrue(k1.equals(k2)); assertTrue(k2.equals(k1)); k1.addObject(new Integer(99), "R1", "C1"); assertFalse(k1.equals(k2)); k2.addObject(new Integer(99), "R1", "C1"); assertTrue(k1.equals(k2)); } /** * Confirm that cloning works. */ public void testCloning() { KeyedObjects2D o1 = new KeyedObjects2D(); o1.setObject(new Integer(1), "V1", "C1"); o1.setObject(null, "V2", "C1"); o1.setObject(new Integer(3), "V3", "C2"); KeyedObjects2D o2 = null; try { o2 = (KeyedObjects2D) o1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(o1 != o2); assertTrue(o1.getClass() == o2.getClass()); assertTrue(o1.equals(o2)); // check independence o1.addObject("XX", "R1", "C1"); assertFalse(o1.equals(o2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { KeyedObjects2D ko2D1 = new KeyedObjects2D(); ko2D1.addObject(new Double(234.2), "Row1", "Col1"); ko2D1.addObject(null, "Row1", "Col2"); ko2D1.addObject(new Double(345.9), "Row2", "Col1"); ko2D1.addObject(new Double(452.7), "Row2", "Col2"); KeyedObjects2D ko2D2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko2D1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ko2D2 = (KeyedObjects2D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko2D1, ko2D2); } /** * Some checks for the getValue(int, int) method. */ public void testGetValueByIndex() { KeyedObjects2D data = new KeyedObjects2D(); data.addObject("Obj1", "R1", "C1"); data.addObject("Obj2", "R2", "C2"); assertEquals("Obj1", data.getObject(0, 0)); assertEquals("Obj2", data.getObject(1, 1)); assertNull(data.getObject(0, 1)); assertNull(data.getObject(1, 0)); // check invalid indices boolean pass = false; try { data.getObject(-1, 0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { data.getObject(0, -1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { data.getObject(2, 0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { data.getObject(0, 2); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getValue(Comparable, Comparable) method. */ public void testGetValueByKey() { KeyedObjects2D data = new KeyedObjects2D(); data.addObject("Obj1", "R1", "C1"); data.addObject("Obj2", "R2", "C2"); assertEquals("Obj1", data.getObject("R1", "C1")); assertEquals("Obj2", data.getObject("R2", "C2")); assertNull(data.getObject("R1", "C2")); assertNull(data.getObject("R2", "C1")); // check invalid indices boolean pass = false; try { data.getObject("XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { data.getObject("R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { data.getObject("XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { data.getObject("R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * Some checks for the setObject(Object, Comparable, Comparable) method. */ public void testSetObject() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); assertEquals("Obj1", data.getObject("R1", "C1")); assertEquals("Obj2", data.getObject("R2", "C2")); assertNull(data.getObject("R1", "C2")); assertNull(data.getObject("R2", "C1")); // confirm overwriting an existing value data.setObject("ABC", "R2", "C2"); assertEquals("ABC", data.getObject("R2", "C2")); // try null keys boolean pass = false; try { data.setObject("X", null, "C1"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { data.setObject("X", "R1", null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeRow(int) method. */ public void testRemoveRowByIndex() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeRow(0); assertEquals(1, data.getRowCount()); assertEquals("Obj2", data.getObject(0, 1)); // try negative row index boolean pass = false; try { data.removeRow(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try row index too high pass = false; try { data.removeRow(data.getRowCount()); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeColumn(int) method. */ public void testRemoveColumnByIndex() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn(0); assertEquals(1, data.getColumnCount()); assertEquals("Obj2", data.getObject(1, 0)); // try negative column index boolean pass = false; try { data.removeColumn(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try column index too high pass = false; try { data.removeColumn(data.getColumnCount()); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeRow(Comparable) method. */ public void testRemoveRowByKey() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeRow("R2"); assertEquals(1, data.getRowCount()); assertEquals("Obj1", data.getObject(0, 0)); // try unknown row key boolean pass = false; try { data.removeRow("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // try null row key pass = false; try { data.removeRow(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeColumn(Comparable) method. */ public void testRemoveColumnByKey() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn("C2"); assertEquals(1, data.getColumnCount()); assertEquals("Obj1", data.getObject(0, 0)); // try unknown column key boolean pass = false; try { data.removeColumn("XXX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // try null column key pass = false; try { data.removeColumn(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * A simple check for the removeValue() method. */ public void testRemoveValue() { KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeObject("R2", "C2"); assertEquals(1, data.getRowCount()); assertEquals(1, data.getColumnCount()); assertEquals("Obj1", data.getObject(0, 0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/KeyedObjectsTests.java0000644000175000017500000002723311173030414027504 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * KeyedObjectsTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Jan-2004 : Version 1 (DG); * 28-Sep-2007 : Added testCloning2() (DG); * 03-Oct-2007 : New tests (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.KeyedObjects; import org.jfree.data.UnknownKeyException; import org.jfree.data.general.DefaultPieDataset; /** * Tests for the {@link KeyedObjects} class. */ public class KeyedObjectsTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(KeyedObjectsTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public KeyedObjectsTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup required } /** * Confirm that cloning works. */ public void testCloning() { KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("V1", new Integer(1)); ko1.addObject("V2", null); ko1.addObject("V3", new Integer(3)); KeyedObjects ko2 = null; try { ko2 = (KeyedObjects) ko1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2)); } /** * Confirm special features of cloning. */ public void testCloning2() { // case 1 - object is mutable but not PublicCloneable Object obj1 = new ArrayList(); KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("K1", obj1); KeyedObjects ko2 = null; try { ko2 = (KeyedObjects) ko1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2)); // the clone contains a reference to the original object assertTrue(ko2.getObject("K1") == obj1); // CASE 2 - object is mutable AND PublicCloneable obj1 = new DefaultPieDataset(); ko1 = new KeyedObjects(); ko1.addObject("K1", obj1); ko2 = null; try { ko2 = (KeyedObjects) ko1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(ko1 != ko2); assertTrue(ko1.getClass() == ko2.getClass()); assertTrue(ko1.equals(ko2)); // the clone contains a reference to a CLONE of the original object assertTrue(ko2.getObject("K1") != obj1); } /** * Check that inserting and retrieving values works as expected. */ public void testInsertAndRetrieve() { KeyedObjects data = new KeyedObjects(); data.addObject("A", new Double(1.0)); data.addObject("B", new Double(2.0)); data.addObject("C", new Double(3.0)); data.addObject("D", null); // check key order assertEquals(data.getKey(0), "A"); assertEquals(data.getKey(1), "B"); assertEquals(data.getKey(2), "C"); assertEquals(data.getKey(3), "D"); // check retrieve value by key assertEquals(data.getObject("A"), new Double(1.0)); assertEquals(data.getObject("B"), new Double(2.0)); assertEquals(data.getObject("C"), new Double(3.0)); assertEquals(data.getObject("D"), null); boolean pass = false; try { data.getObject("Not a key"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // check retrieve value by index assertEquals(data.getObject(0), new Double(1.0)); assertEquals(data.getObject(1), new Double(2.0)); assertEquals(data.getObject(2), new Double(3.0)); assertEquals(data.getObject(3), null); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); KeyedObjects ko2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ko2 = (KeyedObjects) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko1, ko2); } /** * Simple checks for the getObject(int) method. */ public void testGetObject() { // retrieve an item KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals("Object 1", ko1.getObject(0)); assertNull(ko1.getObject(1)); assertEquals("Object 2", ko1.getObject(2)); // request with a negative index boolean pass = false; try { ko1.getObject(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // request width index == itemCount pass = false; try { ko1.getObject(3); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Simple checks for the getKey(int) method. */ public void testGetKey() { // retrieve an item KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals("Key 1", ko1.getKey(0)); assertEquals("Key 2", ko1.getKey(1)); assertEquals("Key 3", ko1.getKey(2)); // request with a negative index boolean pass = false; try { ko1.getKey(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // request width index == itemCount pass = false; try { ko1.getKey(3); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Simple checks for the getIndex(Comparable) method. */ public void testGetIndex() { KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); assertEquals(0, ko1.getIndex("Key 1")); assertEquals(1, ko1.getIndex("Key 2")); assertEquals(2, ko1.getIndex("Key 3")); // check null argument boolean pass = false; try { ko1.getIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the setObject(Comparable, Object) method. */ public void testSetObject() { KeyedObjects ko1 = new KeyedObjects(); ko1.setObject("Key 1", "Object 1"); ko1.setObject("Key 2", null); ko1.setObject("Key 3", "Object 2"); assertEquals("Object 1", ko1.getObject("Key 1")); assertEquals(null, ko1.getObject("Key 2")); assertEquals("Object 2", ko1.getObject("Key 3")); // replace an existing value ko1.setObject("Key 2", "AAA"); ko1.setObject("Key 3", "BBB"); assertEquals("AAA", ko1.getObject("Key 2")); assertEquals("BBB", ko1.getObject("Key 3")); // try a null key - should throw an exception boolean pass = false; try { ko1.setObject(null, "XX"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeValue() methods. */ public void testRemoveValue() { KeyedObjects ko1 = new KeyedObjects(); ko1.setObject("Key 1", "Object 1"); ko1.setObject("Key 2", null); ko1.setObject("Key 3", "Object 2"); ko1.removeValue(1); assertEquals(2, ko1.getItemCount()); assertEquals(1, ko1.getIndex("Key 3")); ko1.removeValue("Key 1"); assertEquals(1, ko1.getItemCount()); assertEquals(0, ko1.getIndex("Key 3")); // try unknown key boolean pass = false; try { ko1.removeValue("UNKNOWN"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); // try null argument pass = false; try { ko1.removeValue(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeValue(int) method. */ public void testRemoveValueInt() { KeyedObjects ko1 = new KeyedObjects(); ko1.setObject("Key 1", "Object 1"); ko1.setObject("Key 2", null); ko1.setObject("Key 3", "Object 2"); ko1.removeValue(1); assertEquals(2, ko1.getItemCount()); assertEquals(1, ko1.getIndex("Key 3")); // try negative key index boolean pass = false; try { ko1.removeValue(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try key index == itemCount pass = false; try { ko1.removeValue(2); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/RangeTests.java0000644000175000017500000002310011173030414026152 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * RangeTests.java * --------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Sergei Ivanov; * * Changes * ------- * 14-Aug-2003 : Version 1 (DG); * 18-Dec-2007 : Additional tests from Sergei Ivanov (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; /** * Tests for the {@link Range} class. */ public class RangeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RangeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RangeTests(String name) { super(name); } /** * Confirm that the constructor initializes all the required fields. */ public void testConstructor() { Range r1 = new Range(0.1, 1000.0); assertEquals(r1.getLowerBound(), 0.1, 0.0d); assertEquals(r1.getUpperBound(), 1000.0, 0.0d); try { /*Range r2 =*/ new Range(10.0, 0.0); fail("Lower bound cannot be greater than the upper"); } catch (Exception e) { // ignore } } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { Range r1 = new Range(0.0, 1.0); Range r2 = new Range(0.0, 1.0); assertEquals(r1, r2); assertEquals(r2, r1); r1 = new Range(0.0, 1.0); r2 = new Range(0.5, 1.0); assertFalse(r1.equals(r2)); r1 = new Range(0.0, 1.0); r2 = new Range(0.0, 2.0); assertFalse(r1.equals(r2)); assertFalse(r1.equals(new Double(0.0))); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { Range a1 = new Range(1.0, 100.0); Range a2 = new Range(1.0, 100.0); assertEquals(a1.hashCode(), a2.hashCode()); a1 = new Range(-100.0, 2.0); a2 = new Range(-100.0, 2.0); assertEquals(a1.hashCode(), a2.hashCode()); } /** * Simple tests for the contains() method. */ public void testContains() { Range r1 = new Range(0.0, 1.0); assertFalse(r1.contains(Double.NaN)); assertFalse(r1.contains(Double.NEGATIVE_INFINITY)); assertFalse(r1.contains(-1.0)); assertTrue(r1.contains(0.0)); assertTrue(r1.contains(0.5)); assertTrue(r1.contains(1.0)); assertFalse(r1.contains(2.0)); assertFalse(r1.contains(Double.POSITIVE_INFINITY)); } /** * Tests the constrain() method for various values. */ public void testConstrain() { Range r1 = new Range(0.0, 1.0); double d = r1.constrain(0.5); assertEquals(0.5, d, 0.0000001); d = r1.constrain(0.0); assertEquals(0.0, d, 0.0000001); d = r1.constrain(1.0); assertEquals(1.0, d, 0.0000001); d = r1.constrain(-1.0); assertEquals(0.0, d, 0.0000001); d = r1.constrain(2.0); assertEquals(1.0, d, 0.0000001); d = r1.constrain(Double.POSITIVE_INFINITY); assertEquals(1.0, d, 0.0000001); d = r1.constrain(Double.NEGATIVE_INFINITY); assertEquals(0.0, d, 0.0000001); d = r1.constrain(Double.NaN); assertTrue(Double.isNaN(d)); } /** * Simple tests for the intersects() method. */ public void testIntersects() { Range r1 = new Range(0.0, 1.0); assertFalse(r1.intersects(-2.0, -1.0)); assertFalse(r1.intersects(-2.0, 0.0)); assertTrue(r1.intersects(-2.0, 0.5)); assertTrue(r1.intersects(-2.0, 1.0)); assertTrue(r1.intersects(-2.0, 1.5)); assertTrue(r1.intersects(0.0, 0.5)); assertTrue(r1.intersects(0.0, 1.0)); assertTrue(r1.intersects(0.0, 1.5)); assertTrue(r1.intersects(0.5, 0.6)); assertTrue(r1.intersects(0.5, 1.0)); assertTrue(r1.intersects(0.5, 1.5)); assertFalse(r1.intersects(1.0, 1.1)); assertFalse(r1.intersects(1.5, 2.0)); } /** * A simple test for the expand() method. */ public void testExpand() { Range r1 = new Range(0.0, 100.0); Range r2 = Range.expand(r1, 0.10, 0.10); assertEquals(-10.0, r2.getLowerBound(), 0.001); assertEquals(110.0, r2.getUpperBound(), 0.001); // Expand by 0% does not change the range r2 = Range.expand(r1, 0.0, 0.0); assertEquals(r1, r2); try { Range.expand(null, 0.1, 0.1); fail("Null value is accepted"); } catch (Exception e) { } // Lower > upper: mid point is used r2 = Range.expand(r1, -0.8, -0.5); assertEquals(65.0, r2.getLowerBound(), 0.001); assertEquals(65.0, r2.getUpperBound(), 0.001); } /** * A simple test for the scale() method. */ public void testShift() { Range r1 = new Range(10.0, 20.0); Range r2 = Range.shift(r1, 20.0); assertEquals(30.0, r2.getLowerBound(), 0.001); assertEquals(40.0, r2.getUpperBound(), 0.001); r1 = new Range(0.0, 100.0); r2 = Range.shift(r1, -50.0, true); assertEquals(-50.0, r2.getLowerBound(), 0.001); assertEquals(50.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, 20.0, true); assertEquals(10.0, r2.getLowerBound(), 0.001); assertEquals(40.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, -30.0, true); assertEquals(-40.0, r2.getLowerBound(), 0.001); assertEquals(-10.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, 20.0, false); assertEquals(0.0, r2.getLowerBound(), 0.001); assertEquals(40.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, -30.0, false); assertEquals(-40.0, r2.getLowerBound(), 0.001); assertEquals(0.0, r2.getUpperBound(), 0.001); // Shifting with a delta of 0 does not change the range r2 = Range.shift(r1, 0.0); assertEquals(r1, r2); try { Range.shift(null, 0.1); fail("Null value is accepted"); } catch (Exception e) { } } /** * A simple test for the scale() method. */ public void testScale() { Range r1 = new Range(0.0, 100.0); Range r2 = Range.scale(r1, 0.10); assertEquals(0.0, r2.getLowerBound(), 0.001); assertEquals(10.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 100.0); r2 = Range.scale(r1, 2.0); assertEquals(-20.0, r2.getLowerBound(), 0.001); assertEquals(200.0, r2.getUpperBound(), 0.001); // Scaling with a factor of 1 does not change the range r2 = Range.scale(r1, 1.0); assertEquals(r1, r2); try { Range.scale(null, 0.1); fail("Null value is accepted"); } catch (Exception e) { } try { Range.scale(r1, -0.5); fail("Negative factor accepted"); } catch (Exception e) { } } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Range r1 = new Range(25.0, 133.42); Range r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (Range) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); fail("Serialization is not supported"); } assertEquals(r1, r2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/RangeTypeTests.java0000644000175000017500000001030111173030414027013 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * RangeTypeTests.java * ------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-May-2005 : Version 1 (DG); * */ package org.jfree.data.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.RangeType; /** * Tests for the {@link RangeType} class. */ public class RangeTypeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RangeTypeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RangeTypeTests(String name) { super(name); } /** * Some checks for the equals() method. */ public void testEquals() { assertEquals(RangeType.FULL, RangeType.FULL); assertEquals(RangeType.NEGATIVE, RangeType.NEGATIVE); assertEquals(RangeType.POSITIVE, RangeType.POSITIVE); assertFalse(RangeType.FULL.equals(RangeType.NEGATIVE)); assertFalse(RangeType.FULL.equals(RangeType.POSITIVE)); assertFalse(RangeType.FULL.equals(null)); assertFalse(RangeType.NEGATIVE.equals(RangeType.FULL)); assertFalse(RangeType.NEGATIVE.equals(RangeType.POSITIVE)); assertFalse(RangeType.NEGATIVE.equals(null)); assertFalse(RangeType.POSITIVE.equals(RangeType.NEGATIVE)); assertFalse(RangeType.POSITIVE.equals(RangeType.FULL)); assertFalse(RangeType.POSITIVE.equals(null)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { RangeType r1 = RangeType.FULL; RangeType r2 = RangeType.FULL; assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { RangeType r1 = RangeType.FULL; RangeType r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); r2 = (RangeType) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(r1, r2); boolean same = r1 == r2; assertEquals(true, same); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/junit/package.html0000644000175000017500000000023211173030414025512 0ustar vincentvincent Test cases for the classes in com.jrefinery.data.*. libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/0000755000175000017500000000000011173030414024275 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/0000755000175000017500000000000011216245562025440 5ustar vincentvincent././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/BoxAndWhiskerCalculatorTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/BoxAndWhiskerCalculatorTests.ja0000644000175000017500000001357111173030414033516 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------- * BoxAndWhiskerCalculatorTests.java * --------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Aug-2003 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.BoxAndWhiskerCalculator; import org.jfree.data.statistics.BoxAndWhiskerItem; /** * Tests for the {@link BoxAndWhiskerCalculator} class. */ public class BoxAndWhiskerCalculatorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BoxAndWhiskerCalculatorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BoxAndWhiskerCalculatorTests(String name) { super(name); } /** * Some checks for the calculateBoxAndWhiskerStatistics() method. */ public void testCalculateBoxAndWhiskerStatistics() { // try null list boolean pass = false; try { BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // try a list containing a single value List values = new ArrayList(); values.add(new Double(1.1)); BoxAndWhiskerItem item = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values); assertEquals(1.1, item.getMean().doubleValue(), EPSILON); assertEquals(1.1, item.getMedian().doubleValue(), EPSILON); assertEquals(1.1, item.getQ1().doubleValue(), EPSILON); assertEquals(1.1, item.getQ3().doubleValue(), EPSILON); } private static final double EPSILON = 0.000000001; /** * Tests the Q1 calculation. */ public void testCalculateQ1() { // try null argument boolean pass = false; try { BoxAndWhiskerCalculator.calculateQ1(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); List values = new ArrayList(); double q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertTrue(Double.isNaN(q1)); values.add(new Double(1.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.0, EPSILON); values.add(new Double(2.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.0, EPSILON); values.add(new Double(3.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.5, EPSILON); values.add(new Double(4.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.5, EPSILON); } /** * Tests the Q3 calculation. */ public void testCalculateQ3() { // try null argument boolean pass = false; try { BoxAndWhiskerCalculator.calculateQ3(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); List values = new ArrayList(); double q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertTrue(Double.isNaN(q3)); values.add(new Double(1.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 1.0, EPSILON); values.add(new Double(2.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 2.0, EPSILON); values.add(new Double(3.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 2.5, EPSILON); values.add(new Double(4.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 3.5, EPSILON); } /** * The test case included in bug report 1593149. */ public void test1593149() { ArrayList theList = new ArrayList(5); theList.add(0, new Double(1.0)); theList.add(1, new Double(2.0)); theList.add(2, new Double(Double.NaN)); theList.add(3, new Double(3.0)); theList.add(4, new Double(4.0)); BoxAndWhiskerItem theItem = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(theList); assertEquals(1.0, theItem.getMinRegularValue().doubleValue(), EPSILON); assertEquals(4.0, theItem.getMaxRegularValue().doubleValue(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/BoxAndWhiskerItemTests.java0000644000175000017500000001002311173030414032637 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * BoxAndWhiskerItemTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.BoxAndWhiskerItem; /** * Tests for the {@link BoxAndWhiskerItem} class. */ public class BoxAndWhiskerItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BoxAndWhiskerItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BoxAndWhiskerItemTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { BoxAndWhiskerItem i1 = new BoxAndWhiskerItem( new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList() ); BoxAndWhiskerItem i2 = new BoxAndWhiskerItem( new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList() ); assertTrue(i1.equals(i2)); assertTrue(i2.equals(i1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BoxAndWhiskerItem i1 = new BoxAndWhiskerItem( new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList() ); BoxAndWhiskerItem i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); i2 = (BoxAndWhiskerItem) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(i1, i2); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DataStatisticsPackageTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DataStatisticsPackageTests.java0000644000175000017500000000712111173030414033515 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * DataStatisticsPackageTests.java * ------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Aug-2003 : Version 1 (DG); * 01-Mar-2004 : Added tests for BoxAndWhiskerItem class (DG); * 25-Mar-2004 : Added tests for Statistics class (DG); * 10-Jan-2005 : Added tests for new SimpleHistogramDataset and * SimpleHistogramBin classes (DG); * 18-Jan-2005 : Added main() method (DG); * 12-Nov-2007 : Added DefaultBoxAndWhiskerXYDatasetTests (DG); * */ package org.jfree.data.statistics.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data.statistics package that can * be run using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataStatisticsPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.statistics"); suite.addTestSuite(BoxAndWhiskerCalculatorTests.class); suite.addTestSuite(BoxAndWhiskerItemTests.class); suite.addTestSuite(DefaultBoxAndWhiskerCategoryDatasetTests.class); suite.addTestSuite(DefaultBoxAndWhiskerXYDatasetTests.class); suite.addTestSuite(DefaultStatisticalCategoryDatasetTests.class); suite.addTestSuite(HistogramBinTests.class); suite.addTestSuite(HistogramDatasetTests.class); suite.addTestSuite(MeanAndStandardDeviationTests.class); suite.addTestSuite(RegressionTests.class); suite.addTestSuite(SimpleHistogramBinTests.class); suite.addTestSuite(SimpleHistogramDatasetTests.class); suite.addTestSuite(StatisticsTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataStatisticsPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDat0000644000175000017500000003111211173030414033513 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------------- * DefaultBoxAndWhiskerCategoryDatasetTests.java * --------------------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * 17-Apr-2007 : Added a test for bug 1701822 (DG); * 28-Sep-2007 : Enhanced testClone() (DG); * 02-Oct-2007 : Added new tests (DG); * 03-Oct-2007 : Added getTestRangeBounds() and testRemove() (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; import org.jfree.data.UnknownKeyException; import org.jfree.data.statistics.BoxAndWhiskerItem; import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset; /** * Tests for the {@link DefaultBoxAndWhiskerCategoryDataset} class. */ public class DefaultBoxAndWhiskerCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultBoxAndWhiskerCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultBoxAndWhiskerCategoryDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset(); d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); DefaultBoxAndWhiskerCategoryDataset d2 = new DefaultBoxAndWhiskerCategoryDataset(); d2.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset(); d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); DefaultBoxAndWhiskerCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultBoxAndWhiskerCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Confirm that cloning works. */ public void testCloning() { DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset(); d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); DefaultBoxAndWhiskerCategoryDataset d2 = null; try { d2 = (DefaultBoxAndWhiskerCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // test independence d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), new Double(8.0), new ArrayList()), "ROW2", "COLUMN1"); assertFalse(d1.equals(d2)); } /** * A simple test for bug report 1701822. */ public void test1701822() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); try { dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), null, new Double(8.0), new ArrayList()), "ROW1", "COLUMN1"); dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), new Double(7.0), null, new ArrayList()), "ROW1", "COLUMN2"); } catch (NullPointerException e) { assertTrue(false); } } private static final double EPSILON = 0.0000000001; /** * Some checks for the add() method. */ public void testAdd() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()); dataset.add(item1, "R1", "C1"); assertEquals(2.0, dataset.getValue("R1", "C1").doubleValue(), EPSILON); assertEquals(1.0, dataset.getMeanValue("R1", "C1").doubleValue(), EPSILON); assertEquals(2.0, dataset.getMedianValue("R1", "C1").doubleValue(), EPSILON); assertEquals(3.0, dataset.getQ1Value("R1", "C1").doubleValue(), EPSILON); assertEquals(4.0, dataset.getQ3Value("R1", "C1").doubleValue(), EPSILON); assertEquals(5.0, dataset.getMinRegularValue("R1", "C1").doubleValue(), EPSILON); assertEquals(6.0, dataset.getMaxRegularValue("R1", "C1").doubleValue(), EPSILON); assertEquals(7.0, dataset.getMinOutlier("R1", "C1").doubleValue(), EPSILON); assertEquals(8.0, dataset.getMaxOutlier("R1", "C1").doubleValue(), EPSILON); assertEquals(new Range(7.0, 8.0), dataset.getRangeBounds(false)); } /** * Some checks for the add() method. */ public void testAddUpdatesCachedRange() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()); dataset.add(item1, "R1", "C1"); // now overwrite this item with another BoxAndWhiskerItem item2 = new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList()); dataset.add(item2, "R1", "C1"); assertEquals(2.5, dataset.getValue("R1", "C1").doubleValue(), EPSILON); assertEquals(1.5, dataset.getMeanValue("R1", "C1").doubleValue(), EPSILON); assertEquals(2.5, dataset.getMedianValue("R1", "C1").doubleValue(), EPSILON); assertEquals(3.5, dataset.getQ1Value("R1", "C1").doubleValue(), EPSILON); assertEquals(4.5, dataset.getQ3Value("R1", "C1").doubleValue(), EPSILON); assertEquals(5.5, dataset.getMinRegularValue("R1", "C1").doubleValue(), EPSILON); assertEquals(6.5, dataset.getMaxRegularValue("R1", "C1").doubleValue(), EPSILON); assertEquals(7.5, dataset.getMinOutlier("R1", "C1").doubleValue(), EPSILON); assertEquals(8.5, dataset.getMaxOutlier("R1", "C1").doubleValue(), EPSILON); assertEquals(new Range(7.5, 8.5), dataset.getRangeBounds(false)); } /** * Some basic checks for the constructor. */ public void testConstructor() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); assertEquals(0, dataset.getColumnCount()); assertEquals(0, dataset.getRowCount()); assertTrue(Double.isNaN(dataset.getRangeLowerBound(false))); assertTrue(Double.isNaN(dataset.getRangeUpperBound(false))); } /** * Some checks for the getRangeBounds() method. */ public void testGetRangeBounds() { DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset(); d1.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()), "R1", "C1"); assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(false)); assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(true)); d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList()), "R1", "C1"); assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(false)); assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(true)); d1.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList()), "R2", "C1"); assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(false)); assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(true)); // this replaces the entry with the current minimum value, but the new // minimum value is now in a different item d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 8.6, 9.6, new ArrayList()), "R1", "C1"); assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(false)); assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(true)); } /** * Some checks for the remove method. */ public void testRemove() { DefaultBoxAndWhiskerCategoryDataset data = new DefaultBoxAndWhiskerCategoryDataset(); boolean pass = false; try { data.remove("R1", "R2"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); data.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()), "R1", "C1"); assertEquals(new Range(7.0, 8.0), data.getRangeBounds(false)); assertEquals(new Range(7.0, 8.0), data.getRangeBounds(true)); data.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList()), "R2", "C1"); assertEquals(new Range(7.0, 9.5), data.getRangeBounds(false)); assertEquals(new Range(7.0, 9.5), data.getRangeBounds(true)); data.remove("R1", "C1"); assertEquals(new Range(8.5, 9.5), data.getRangeBounds(false)); assertEquals(new Range(8.5, 9.5), data.getRangeBounds(true)); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerXYDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerXYDatasetTe0000644000175000017500000001753211173030414033456 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------------------- * DefaultBoxAndWhiskerXYDatasetTests.java * --------------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-Nov-2007 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; import org.jfree.data.statistics.BoxAndWhiskerItem; import org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset; /** * Tests for the {@link DefaultBoxAndWhiskerXYDataset} class. */ public class DefaultBoxAndWhiskerXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultBoxAndWhiskerXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultBoxAndWhiskerXYDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( "Series"); DefaultBoxAndWhiskerXYDataset d2 = new DefaultBoxAndWhiskerXYDataset( "Series"); assertTrue(d1.equals(d2)); d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); assertFalse(d1.equals(d2)); d2.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( "Series"); d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); DefaultBoxAndWhiskerXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultBoxAndWhiskerXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // test independence d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); assertFalse(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( "Series"); d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); DefaultBoxAndWhiskerXYDataset d2 = null; try { d2 = (DefaultBoxAndWhiskerXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // test independence d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); assertFalse(d1.equals(d2)); } private static final double EPSILON = 0.0000000001; /** * Some checks for the add() method. */ public void testAdd() { DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("S1"); BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()); dataset.add(new Date(33L), item1); assertEquals(1.0, dataset.getY(0, 0).doubleValue(), EPSILON); assertEquals(1.0, dataset.getMeanValue(0, 0).doubleValue(), EPSILON); assertEquals(2.0, dataset.getMedianValue(0, 0).doubleValue(), EPSILON); assertEquals(3.0, dataset.getQ1Value(0, 0).doubleValue(), EPSILON); assertEquals(4.0, dataset.getQ3Value(0, 0).doubleValue(), EPSILON); assertEquals(5.0, dataset.getMinRegularValue(0, 0).doubleValue(), EPSILON); assertEquals(6.0, dataset.getMaxRegularValue(0, 0).doubleValue(), EPSILON); assertEquals(7.0, dataset.getMinOutlier(0, 0).doubleValue(), EPSILON); assertEquals(8.0, dataset.getMaxOutlier(0, 0).doubleValue(), EPSILON); assertEquals(new Range(5.0, 6.0), dataset.getRangeBounds(false)); } /** * Some basic checks for the constructor. */ public void testConstructor() { DefaultBoxAndWhiskerXYDataset dataset = new DefaultBoxAndWhiskerXYDataset("S1"); assertEquals(1, dataset.getSeriesCount()); assertEquals(0, dataset.getItemCount(0)); assertTrue(Double.isNaN(dataset.getRangeLowerBound(false))); assertTrue(Double.isNaN(dataset.getRangeUpperBound(false))); } /** * Some checks for the getRangeBounds() method. */ public void testGetRangeBounds() { DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset("S"); d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); assertEquals(new Range(5.0, 6.0), d1.getRangeBounds(false)); assertEquals(new Range(5.0, 6.0), d1.getRangeBounds(true)); d1.add(new Date(1L), new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList())); assertEquals(new Range(5.0, 6.5), d1.getRangeBounds(false)); assertEquals(new Range(5.0, 6.5), d1.getRangeBounds(true)); d1.add(new Date(2L), new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList())); assertEquals(new Range(5.0, 7.5), d1.getRangeBounds(false)); assertEquals(new Range(5.0, 7.5), d1.getRangeBounds(true)); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultMultiValueCategoryDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultMultiValueCategoryDatase0000644000175000017500000002104211173030414033564 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------------ * DefaultMultiValueCategoryDatasetTests.java * ------------------------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Sep-2007 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.UnknownKeyException; import org.jfree.data.statistics.DefaultMultiValueCategoryDataset; /** * Tests for the {@link DefaultMultiValueCategoryDataset} class. */ public class DefaultMultiValueCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultMultiValueCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultMultiValueCategoryDatasetTests(String name) { super(name); } /** * Some checks for the getValue() method. */ public void testGetValue() { DefaultMultiValueCategoryDataset d = new DefaultMultiValueCategoryDataset(); List values = new ArrayList(); values.add(new Integer(1)); values.add(new Integer(2)); d.add(values, "R1", "C1"); assertEquals(new Double(1.5), d.getValue("R1", "C1")); boolean pass = false; try { d.getValue("XX", "C1"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { d.getValue("R1", "XX"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); } /** * A simple check for the getValue(int, int) method. */ public void testGetValue2() { DefaultMultiValueCategoryDataset d = new DefaultMultiValueCategoryDataset(); boolean pass = false; try { /* Number n =*/ d.getValue(0, 0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some tests for the getRowCount() method. */ public void testGetRowCount() { DefaultMultiValueCategoryDataset d = new DefaultMultiValueCategoryDataset(); assertTrue(d.getRowCount() == 0); List values = new ArrayList(); d.add(values, "R1", "C1"); assertTrue(d.getRowCount() == 1); d.add(values, "R2", "C1"); assertTrue(d.getRowCount() == 2); d.add(values, "R2", "C1"); assertTrue(d.getRowCount() == 2); } /** * Some tests for the getColumnCount() method. */ public void testGetColumnCount() { DefaultMultiValueCategoryDataset d = new DefaultMultiValueCategoryDataset(); assertTrue(d.getColumnCount() == 0); List values = new ArrayList(); d.add(values, "R1", "C1"); assertTrue(d.getColumnCount() == 1); d.add(values, "R1", "C2"); assertTrue(d.getColumnCount() == 2); d.add(values, "R1", "C2"); assertTrue(d.getColumnCount() == 2); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultMultiValueCategoryDataset d1 = new DefaultMultiValueCategoryDataset(); DefaultMultiValueCategoryDataset d2 = new DefaultMultiValueCategoryDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); List values = new ArrayList(); d1.add(values, "R1", "C1"); assertFalse(d1.equals(d2)); d2.add(values, "R1", "C1"); assertTrue(d1.equals(d2)); values.add(new Integer(99)); d1.add(values, "R1", "C1"); assertFalse(d1.equals(d2)); d2.add(values, "R1", "C1"); assertTrue(d1.equals(d2)); values.add(new Integer(99)); d1.add(values, "R1", "C2"); assertFalse(d1.equals(d2)); d2.add(values, "R1", "C2"); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultMultiValueCategoryDataset d1 = new DefaultMultiValueCategoryDataset(); DefaultMultiValueCategoryDataset d2 = new DefaultMultiValueCategoryDataset(); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultMultiValueCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Some checks for the add() method. */ public void testAddValue() { DefaultMultiValueCategoryDataset d1 = new DefaultMultiValueCategoryDataset(); boolean pass = false; try { d1.add(null, "R1", "C1"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); List values = new ArrayList(); d1.add(values, "R2", "C1"); assertEquals(values, d1.getValues("R2", "C1")); pass = false; try { d1.add(values, null, "C2"); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Confirm that cloning works. */ public void testCloning() { DefaultMultiValueCategoryDataset d1 = new DefaultMultiValueCategoryDataset(); DefaultMultiValueCategoryDataset d2 = null; try { d2 = (DefaultMultiValueCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // try a dataset with some content... List values = new ArrayList(); values.add(new Integer(99)); d1.add(values, "R1", "C1"); try { d2 = (DefaultMultiValueCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. List values2 = new ArrayList(); values2.add(new Integer(111)); d1.add(values2, "R2", "C2"); assertFalse(d1.equals(d2)); d2.add(values2, "R2", "C2"); assertTrue(d1.equals(d2)); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatas0000644000175000017500000002472211173030414033624 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------------- * DefaultStatisticalCategoryDatasetTests.java * ------------------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Feb-2005 : Version 1 (DG); * 03-Aug-2006 : Added testGetRangeBounds() method (DG); * 28-Sep-2007 : Enhanced testCloning() method (DG); * 02-Oct-2007 : Added new bounds tests (DG); * 03-Oct-2007 : Added testRemove() method (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; import org.jfree.data.UnknownKeyException; import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; /** * Tests for the {@link DefaultStatisticalCategoryDataset} class. */ public class DefaultStatisticalCategoryDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultStatisticalCategoryDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultStatisticalCategoryDatasetTests(String name) { super(name); } /** * Some checks for the getRangeBounds() method. */ public void testGetRangeBounds() { DefaultStatisticalCategoryDataset d = new DefaultStatisticalCategoryDataset(); // an empty dataset should return null for bounds assertNull(d.getRangeBounds(true)); // try a dataset with a single value d.add(4.5, 1.0, "R1", "C1"); assertEquals(new Range(4.5, 4.5), d.getRangeBounds(false)); assertEquals(new Range(3.5, 5.5), d.getRangeBounds(true)); // try a dataset with two values d.add(0.5, 2.0, "R1", "C2"); assertEquals(new Range(0.5, 4.5), d.getRangeBounds(false)); assertEquals(new Range(-1.5, 5.5), d.getRangeBounds(true)); // try a Double.NaN d.add(Double.NaN, 0.0, "R1", "C3"); assertEquals(new Range(0.5, 4.5), d.getRangeBounds(false)); assertEquals(new Range(-1.5, 5.5), d.getRangeBounds(true)); // try a Double.NEGATIVE_INFINITY d.add(Double.NEGATIVE_INFINITY, 0.0, "R1", "C3"); assertEquals(new Range(Double.NEGATIVE_INFINITY, 4.5), d.getRangeBounds(false)); assertEquals(new Range(Double.NEGATIVE_INFINITY, 5.5), d.getRangeBounds(true)); // try a Double.POSITIVE_INFINITY d.add(Double.POSITIVE_INFINITY, 0.0, "R1", "C3"); assertEquals(new Range(0.5, Double.POSITIVE_INFINITY), d.getRangeBounds(false)); assertEquals(new Range(-1.5, Double.POSITIVE_INFINITY), d.getRangeBounds(true)); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); DefaultStatisticalCategoryDataset d2 = new DefaultStatisticalCategoryDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); } /** * Some checks for cloning. */ public void testCloning() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.1, 2.2, "R1", "C1"); d1.add(3.3, 4.4, "R1", "C2"); d1.add(null, new Double(5.5), "R1", "C3"); d1.add(new Double(6.6), null, "R2", "C3"); DefaultStatisticalCategoryDataset d2 = null; try { d2 = (DefaultStatisticalCategoryDataset) d1.clone(); } catch (CloneNotSupportedException e) { fail(e.toString()); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check independence d1.add(1.1, 2.2, "R3", "C1"); assertFalse(d1.equals(d2)); } /** * Check serialization of a default instance. */ public void testSerialization1() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.1, 2.2, "R1", "C1"); d1.add(3.3, 4.4, "R1", "C2"); d1.add(null, new Double(5.5), "R1", "C3"); d1.add(new Double(6.6), null, "R2", "C3"); DefaultStatisticalCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultStatisticalCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(d1, d2); } /** * Check serialization of a more complex instance. */ public void testSerialization2() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.2, 3.4, "Row 1", "Column 1"); DefaultStatisticalCategoryDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultStatisticalCategoryDataset) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(d1, d2); } private static final double EPSILON = 0.0000000001; /** * Some checks for the add() method. */ public void testAdd() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.0, 2.0, "R1", "C1"); assertEquals(1.0, d1.getValue("R1", "C1").doubleValue(), EPSILON); assertEquals(2.0, d1.getStdDevValue("R1", "C1").doubleValue(), EPSILON); // overwrite the value d1.add(10.0, 20.0, "R1", "C1"); assertEquals(10.0, d1.getValue("R1", "C1").doubleValue(), EPSILON); assertEquals(20.0, d1.getStdDevValue("R1", "C1").doubleValue(), EPSILON); } /** * Some checks for the getRangeLowerBound() method. */ public void testGetRangeLowerBound() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.0, 2.0, "R1", "C1"); assertEquals(1.0, d1.getRangeLowerBound(false), EPSILON); assertEquals(-1.0, d1.getRangeLowerBound(true), EPSILON); } /** * Some checks for the getRangeUpperBound() method. */ public void testGetRangeUpperBound() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.0, 2.0, "R1", "C1"); assertEquals(1.0, d1.getRangeUpperBound(false), EPSILON); assertEquals(3.0, d1.getRangeUpperBound(true), EPSILON); } /** * Some checks for the getRangeBounds() method. */ public void testGetRangeBounds2() { DefaultStatisticalCategoryDataset d1 = new DefaultStatisticalCategoryDataset(); d1.add(1.0, 2.0, "R1", "C1"); assertEquals(new Range(1.0, 1.0), d1.getRangeBounds(false)); assertEquals(new Range(-1.0, 3.0), d1.getRangeBounds(true)); d1.add(10.0, 20.0, "R1", "C1"); assertEquals(new Range(10.0, 10.0), d1.getRangeBounds(false)); assertEquals(new Range(-10.0, 30.0), d1.getRangeBounds(true)); } /** * Some checks for the remove method. */ public void testRemove() { DefaultStatisticalCategoryDataset data = new DefaultStatisticalCategoryDataset(); boolean pass = false; try { data.remove("R1", "R2"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); data.add(1.0, 0.5, "R1", "C1"); assertEquals(new Range(1.0, 1.0), data.getRangeBounds(false)); assertEquals(new Range(0.5, 1.5), data.getRangeBounds(true)); data.add(1.4, 0.2, "R2", "C1"); assertEquals(1.0, data.getRangeLowerBound(false), EPSILON); assertEquals(1.4, data.getRangeUpperBound(false), EPSILON); assertEquals(0.5, data.getRangeLowerBound(true), EPSILON); assertEquals(1.6, data.getRangeUpperBound(true), EPSILON); data.remove("R1", "C1"); assertEquals(1.4, data.getRangeLowerBound(false), EPSILON); assertEquals(1.4, data.getRangeUpperBound(false), EPSILON); assertEquals(1.2, data.getRangeLowerBound(true), EPSILON); assertEquals(1.6, data.getRangeUpperBound(true), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/HistogramBinTests.java0000644000175000017500000000774611173030414031720 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * HistogramBinTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.HistogramBin; /** * Tests for the {@link HistogramBin} class. */ public class HistogramBinTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(HistogramBinTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public HistogramBinTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { double start = 10.0; double end = 20.0; HistogramBin b1 = new HistogramBin(start, end); HistogramBin b2 = new HistogramBin(start, end); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b1)); } /** * Confirm that cloning works. */ public void testCloning() { double start = 10.0; double end = 20.0; HistogramBin b1 = new HistogramBin(start, end); HistogramBin b2 = null; try { b2 = (HistogramBin) b1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { double start = 10.0; double end = 20.0; HistogramBin b1 = new HistogramBin(start, end); HistogramBin b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); b2 = (HistogramBin) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(b1, b2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/HistogramDatasetTests.java0000644000175000017500000002226011173030414032561 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * HistogramDatasetTests.java * -------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * 08-Jun-2005 : Added test for getSeriesKey(int) bug (DG); * 03-Aug-2006 : Added testAddSeries() and testBinBoundaries() method (DG); * 22-May-2008 : Added testAddSeries2() and enhanced testCloning() (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.HistogramDataset; /** * Tests for the {@link HistogramDataset} class. */ public class HistogramDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(HistogramDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public HistogramDatasetTests(String name) { super(name); } private static final double EPSILON = 0.0000000001; /** * Some checks that the correct values are assigned to bins. */ public void testBins() { double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; HistogramDataset hd = new HistogramDataset(); hd.addSeries("Series 1", values, 5); assertEquals(hd.getYValue(0, 0), 3.0, EPSILON); assertEquals(hd.getYValue(0, 1), 3.0, EPSILON); assertEquals(hd.getYValue(0, 2), 2.0, EPSILON); assertEquals(hd.getYValue(0, 3), 0.0, EPSILON); assertEquals(hd.getYValue(0, 4), 1.0, EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; HistogramDataset d1 = new HistogramDataset(); d1.addSeries("Series 1", values, 5); HistogramDataset d2 = new HistogramDataset(); d2.addSeries("Series 1", values, 5); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); assertFalse(d1.equals(d2)); d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; HistogramDataset d1 = new HistogramDataset(); d1.addSeries("Series 1", values, 5); HistogramDataset d2 = null; try { d2 = (HistogramDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // simple check for independence d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); assertFalse(d1.equals(d2)); d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; HistogramDataset d1 = new HistogramDataset(); d1.addSeries("Series 1", values, 5); HistogramDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (HistogramDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // simple check for independence d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); assertFalse(d1.equals(d2)); d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); assertTrue(d1.equals(d2)); } /** * A test for a bug reported in the forum where the series name isn't being * returned correctly. */ public void testGetSeriesKey() { double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; HistogramDataset d1 = new HistogramDataset(); d1.addSeries("Series 1", values, 5); assertEquals("Series 1", d1.getSeriesKey(0)); } /** * Some checks for the addSeries() method. */ public void testAddSeries() { double[] values = {-1.0, 0.0, 0.1, 0.9, 1.0, 1.1, 1.9, 2.0, 3.0}; HistogramDataset d = new HistogramDataset(); d.addSeries("S1", values, 2, 0.0, 2.0); assertEquals(0.0, d.getStartXValue(0, 0), EPSILON); assertEquals(1.0, d.getEndXValue(0, 0), EPSILON); assertEquals(4.0, d.getYValue(0, 0), EPSILON); assertEquals(1.0, d.getStartXValue(0, 1), EPSILON); assertEquals(2.0, d.getEndXValue(0, 1), EPSILON); assertEquals(5.0, d.getYValue(0, 1), EPSILON); } /** * Another check for the addSeries() method. */ public void testAddSeries2() { double[] values = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; HistogramDataset hd = new HistogramDataset(); hd.addSeries("S1", values, 5); assertEquals(0.0, hd.getStartXValue(0, 0), EPSILON); assertEquals(1.0, hd.getEndXValue(0, 0), EPSILON); assertEquals(1.0, hd.getYValue(0, 0), EPSILON); assertEquals(1.0, hd.getStartXValue(0, 1), EPSILON); assertEquals(2.0, hd.getEndXValue(0, 1), EPSILON); assertEquals(1.0, hd.getYValue(0, 1), EPSILON); assertEquals(2.0, hd.getStartXValue(0, 2), EPSILON); assertEquals(3.0, hd.getEndXValue(0, 2), EPSILON); assertEquals(1.0, hd.getYValue(0, 2), EPSILON); assertEquals(3.0, hd.getStartXValue(0, 3), EPSILON); assertEquals(4.0, hd.getEndXValue(0, 3), EPSILON); assertEquals(1.0, hd.getYValue(0, 3), EPSILON); assertEquals(4.0, hd.getStartXValue(0, 4), EPSILON); assertEquals(5.0, hd.getEndXValue(0, 4), EPSILON); assertEquals(2.0, hd.getYValue(0, 4), EPSILON); } /** * This test is derived from a reported bug. */ public void testBinBoundaries() { double[] values = {-5.000000000000286E-5}; int bins = 1260; double minimum = -0.06307522528160199; double maximum = 0.06297522528160199; HistogramDataset d = new HistogramDataset(); d.addSeries("S1", values, bins, minimum, maximum); assertEquals(0.0, d.getYValue(0, 629), EPSILON); assertEquals(1.0, d.getYValue(0, 630), EPSILON); assertEquals(0.0, d.getYValue(0, 631), EPSILON); assertTrue(values[0] > d.getStartXValue(0, 630)); assertTrue(values[0] < d.getEndXValue(0, 630)); } /** * Some checks for bug 1553088. An IndexOutOfBoundsException is thrown * when a data value is *very* close to the upper limit of the last bin. */ public void test1553088() { double[] values = {-1.0, 0.0, -Double.MIN_VALUE, 3.0}; HistogramDataset d = new HistogramDataset(); d.addSeries("S1", values, 2, -1.0, 0.0); assertEquals(-1.0, d.getStartXValue(0, 0), EPSILON); assertEquals(-0.5, d.getEndXValue(0, 0), EPSILON); assertEquals(1.0, d.getYValue(0, 0), EPSILON); assertEquals(-0.5, d.getStartXValue(0, 1), EPSILON); assertEquals(0.0, d.getEndXValue(0, 1), EPSILON); assertEquals(3.0, d.getYValue(0, 1), EPSILON); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/MeanAndStandardDeviationTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/MeanAndStandardDeviationTests.j0000644000175000017500000001016511173030414033456 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * MeanAndStandardDeviationTests.java * ---------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Feb-2005 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.MeanAndStandardDeviation; /** * Tests for the {@link MeanAndStandardDeviation} class. */ public class MeanAndStandardDeviationTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MeanAndStandardDeviationTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MeanAndStandardDeviationTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4); MeanAndStandardDeviation m2 = new MeanAndStandardDeviation(1.2, 3.4); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); m1 = new MeanAndStandardDeviation(1.0, 3.4); assertFalse(m1.equals(m2)); m2 = new MeanAndStandardDeviation(1.0, 3.4); assertTrue(m1.equals(m2)); m1 = new MeanAndStandardDeviation(1.0, 3.0); assertFalse(m1.equals(m2)); m2 = new MeanAndStandardDeviation(1.0, 3.0); assertTrue(m1.equals(m2)); } /** * Immutable class - should not be cloneable. */ public void testCloning() { MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4); assertFalse(m1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4); MeanAndStandardDeviation m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); m2 = (MeanAndStandardDeviation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(m1, m2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/RegressionTests.java0000644000175000017500000001740611173030414031444 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * RegressionTests.java * -------------------- * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Sep-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */ package org.jfree.data.statistics.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.Regression; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Tests for the {@link Regression} class. */ public class RegressionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(RegressionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public RegressionTests(String name) { super(name); } /** * Checks the results of an OLS regression on sample dataset 1. */ public void testOLSRegression1a() { double[][] data = createSampleData1(); double[] result1 = Regression.getOLSRegression(data); assertEquals(.25680930, result1[0], 0.0000001); assertEquals(0.72792106, result1[1], 0.0000001); } /** * Checks the results of an OLS regression on sample dataset 1 AFTER * converting it to an XYSeries. */ public void testOLSRegression1b() { double[][] data = createSampleData1(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 11; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result2 = Regression.getOLSRegression(ds, 0); assertEquals(.25680930, result2[0], 0.0000001); assertEquals(0.72792106, result2[1], 0.0000001); } /** * Checks the results of a power regression on sample dataset 1. */ public void testPowerRegression1a() { double[][] data = createSampleData1(); double[] result = Regression.getPowerRegression(data); assertEquals(0.91045813, result[0], 0.0000001); assertEquals(0.88918346, result[1], 0.0000001); } /** * Checks the results of a power regression on sample dataset 1 AFTER * converting it to an XYSeries. */ public void testPowerRegression1b() { double[][] data = createSampleData1(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 11; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getPowerRegression(ds, 0); assertEquals(0.91045813, result[0], 0.0000001); assertEquals(0.88918346, result[1], 0.0000001); } /** * Checks the results of an OLS regression on sample dataset 2. */ public void testOLSRegression2a() { double[][] data = createSampleData2(); double[] result = Regression.getOLSRegression(data); assertEquals(53.9729697, result[0], 0.0000001); assertEquals(-4.1823030, result[1], 0.0000001); } /** * Checks the results of an OLS regression on sample dataset 2 AFTER * converting it to an XYSeries. */ public void testOLSRegression2b() { double[][] data = createSampleData2(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 10; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getOLSRegression(ds, 0); assertEquals(53.9729697, result[0], 0.0000001); assertEquals(-4.1823030, result[1], 0.0000001); } /** * Checks the results of a power regression on sample dataset 2. */ public void testPowerRegression2a() { double[][] data = createSampleData2(); double[] result = Regression.getPowerRegression(data); assertEquals(106.1241681, result[0], 0.0000001); assertEquals(-0.8466615, result[1], 0.0000001); } /** * Checks the results of a power regression on sample dataset 2 AFTER * converting it to an XYSeries. */ public void testPowerRegression2b() { double[][] data = createSampleData2(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 10; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getPowerRegression(ds, 0); assertEquals(106.1241681, result[0], 0.0000001); assertEquals(-0.8466615, result[1], 0.0000001); } /** * Creates and returns a sample dataset. *

      * The data is taken from Table 11.2, page 313 of "Understanding Statistics" * by Ott and Mendenhall (Duxbury Press). * * @return The sample data. */ private double[][] createSampleData1() { double[][] result = new double[11][2]; result[0][0] = 2.00; result[0][1] = 1.60; result[1][0] = 2.25; result[1][1] = 2.00; result[2][0] = 2.60; result[2][1] = 1.80; result[3][0] = 2.65; result[3][1] = 2.80; result[4][0] = 2.80; result[4][1] = 2.10; result[5][0] = 3.10; result[5][1] = 2.00; result[6][0] = 2.90; result[6][1] = 2.65; result[7][0] = 3.25; result[7][1] = 2.25; result[8][0] = 3.30; result[8][1] = 2.60; result[9][0] = 3.60; result[9][1] = 3.00; result[10][0] = 3.25; result[10][1] = 3.10; return result; } /** * Creates a sample data set. * * @return The sample data. */ private double[][] createSampleData2() { double[][] result = new double[10][2]; result[0][0] = 2; result[0][1] = 56.27; result[1][0] = 3; result[1][1] = 41.32; result[2][0] = 4; result[2][1] = 31.45; result[3][0] = 5; result[3][1] = 30.05; result[4][0] = 6; result[4][1] = 24.69; result[5][0] = 7; result[5][1] = 19.78; result[6][0] = 8; result[6][1] = 20.94; result[7][0] = 9; result[7][1] = 16.73; result[8][0] = 10; result[8][1] = 14.21; result[9][0] = 11; result[9][1] = 12.44; return result; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/SimpleHistogramBinTests.java0000644000175000017500000001525411173030414033063 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * SimpleHistogramBinTests.java * ---------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jan-2005 : Version 1 (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.SimpleHistogramBin; /** * Tests for the {@link SimpleHistogramBin} class. */ public class SimpleHistogramBinTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SimpleHistogramBinTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SimpleHistogramBinTests(String name) { super(name); } /** * Some checks for the accepts() method. */ public void testAccepts() { SimpleHistogramBin bin1 = new SimpleHistogramBin(1.0, 2.0); assertFalse(bin1.accepts(0.0)); assertTrue(bin1.accepts(1.0)); assertTrue(bin1.accepts(1.5)); assertTrue(bin1.accepts(2.0)); assertFalse(bin1.accepts(2.1)); assertFalse(bin1.accepts(Double.NaN)); SimpleHistogramBin bin2 = new SimpleHistogramBin(1.0, 2.0, false, false); assertFalse(bin2.accepts(0.0)); assertFalse(bin2.accepts(1.0)); assertTrue(bin2.accepts(1.5)); assertFalse(bin2.accepts(2.0)); assertFalse(bin2.accepts(2.1)); assertFalse(bin2.accepts(Double.NaN)); } /** * Some checks for the overlapsWith() method. */ public void testOverlapsWidth() { SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0); SimpleHistogramBin b2 = new SimpleHistogramBin(2.0, 3.0); SimpleHistogramBin b3 = new SimpleHistogramBin(3.0, 4.0); SimpleHistogramBin b4 = new SimpleHistogramBin(0.0, 5.0); SimpleHistogramBin b5 = new SimpleHistogramBin(2.0, 3.0, false, true); SimpleHistogramBin b6 = new SimpleHistogramBin(2.0, 3.0, true, false); assertTrue(b1.overlapsWith(b2)); assertTrue(b2.overlapsWith(b1)); assertFalse(b1.overlapsWith(b3)); assertFalse(b3.overlapsWith(b1)); assertTrue(b1.overlapsWith(b4)); assertTrue(b4.overlapsWith(b1)); assertFalse(b1.overlapsWith(b5)); assertFalse(b5.overlapsWith(b1)); assertTrue(b1.overlapsWith(b6)); assertTrue(b6.overlapsWith(b1)); } /** * Ensure that the equals() method can distinguish all fields. */ public void testEquals() { SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0); SimpleHistogramBin b2 = new SimpleHistogramBin(1.0, 2.0); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b1)); b1 = new SimpleHistogramBin(1.1, 2.0, true, true); assertFalse(b1.equals(b2)); b2 = new SimpleHistogramBin(1.1, 2.0, true, true); assertTrue(b1.equals(b2)); b1 = new SimpleHistogramBin(1.1, 2.2, true, true); assertFalse(b1.equals(b2)); b2 = new SimpleHistogramBin(1.1, 2.2, true, true); assertTrue(b1.equals(b2)); b1 = new SimpleHistogramBin(1.1, 2.2, false, true); assertFalse(b1.equals(b2)); b2 = new SimpleHistogramBin(1.1, 2.2, false, true); assertTrue(b1.equals(b2)); b1 = new SimpleHistogramBin(1.1, 2.2, false, false); assertFalse(b1.equals(b2)); b2 = new SimpleHistogramBin(1.1, 2.2, false, false); assertTrue(b1.equals(b2)); b1.setItemCount(99); assertFalse(b1.equals(b2)); b2.setItemCount(99); assertTrue(b1.equals(b2)); } /** * Some checks for the clone() method. */ public void testCloning() { SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true); b1.setItemCount(99); SimpleHistogramBin b2 = null; try { b2 = (SimpleHistogramBin) b1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(b1 != b2); assertTrue(b1.getClass() == b2.getClass()); assertTrue(b1.equals(b2)); // check that clone is independent of the original b2.setItemCount(111); assertFalse(b1.equals(b2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0, false, true); b1.setItemCount(123); SimpleHistogramBin b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); b2 = (SimpleHistogramBin) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(b1, b2); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.javalibjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.jav0000644000175000017500000001242311173030414033572 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * SimpleHistogramDatasetTests.java * -------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jan-2005 : Version 1 (DG); * 21-May-2007 : Added testClearObservations (DG); * */ package org.jfree.data.statistics.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.SimpleHistogramBin; import org.jfree.data.statistics.SimpleHistogramDataset; /** * Tests for the {@link SimpleHistogramDataset} class. */ public class SimpleHistogramDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SimpleHistogramDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SimpleHistogramDatasetTests(String name) { super(name); } /** * Ensure that the equals() method can distinguish all fields. */ public void testEquals() { SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); SimpleHistogramDataset d2 = new SimpleHistogramDataset("Dataset 1"); assertTrue(d1.equals(d2)); d1.addBin(new SimpleHistogramBin(1.0, 2.0)); assertFalse(d1.equals(d2)); d2.addBin(new SimpleHistogramBin(1.0, 2.0)); assertTrue(d1.equals(d2)); } /** * Some checks for the clone() method. */ public void testCloning() { SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); SimpleHistogramDataset d2 = null; try { d2 = (SimpleHistogramDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that clone is independent of the original d2.addBin(new SimpleHistogramBin(2.0, 3.0)); d2.addObservation(2.3); assertFalse(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1"); SimpleHistogramDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (SimpleHistogramDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } private static final double EPSILON = 0.0000000001; /** * Some checks for the clearObservations() method. */ public void testClearObservations() { SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1"); d1.clearObservations(); assertEquals(0, d1.getItemCount(0)); d1.addBin(new SimpleHistogramBin(0.0, 1.0)); d1.addObservation(0.5); assertEquals(1.0, d1.getYValue(0, 0), EPSILON); } /** * Some checks for the removeAllBins() method. */ public void testRemoveAllBins() { SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1"); d1.addBin(new SimpleHistogramBin(0.0, 1.0)); d1.addObservation(0.5); d1.addBin(new SimpleHistogramBin(2.0, 3.0)); assertEquals(2, d1.getItemCount(0)); d1.removeAllBins(); assertEquals(0, d1.getItemCount(0)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/StatisticsTests.java0000644000175000017500000003736111173030414031460 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * StatisticsTests.java * -------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2004 : Version 1 (DG); * 04-Oct-2004 : Eliminated NumberUtils usage (DG); * */ package org.jfree.data.statistics.junit; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.statistics.Statistics; /** * Tests for the {@link Statistics} class. */ public class StatisticsTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StatisticsTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StatisticsTests(String name) { super(name); } /** * Some checks for the calculateMean(Number[]) and * calculateMean(Number[], boolean) methods. */ public void testCalculateMean_Array() { // try null array boolean pass = false; try { Statistics.calculateMean((Number[]) null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { Statistics.calculateMean((Number[]) null, false); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // try an array containing no items assertTrue(Double.isNaN(Statistics.calculateMean(new Number[0]))); assertTrue(Double.isNaN(Statistics.calculateMean(new Number[0], false))); // try an array containing a single Number Number[] values = new Number[] {new Double(1.0)}; assertEquals(1.0, Statistics.calculateMean(values), EPSILON); assertEquals(1.0, Statistics.calculateMean(values, true), EPSILON); assertEquals(1.0, Statistics.calculateMean(values, false), EPSILON); // try an array containing a single Number and a null values = new Number[] {new Double(1.0), null}; assertTrue(Double.isNaN(Statistics.calculateMean(values))); assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); assertEquals(1.0, Statistics.calculateMean(values, false), EPSILON); // try an array containing a single Number and a NaN values = new Number[] {new Double(1.0), new Double(Double.NaN)}; assertTrue(Double.isNaN(Statistics.calculateMean(values))); assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); assertEquals(1.0, Statistics.calculateMean(values, false), EPSILON); } /** * Some checks for the calculateMean(Collection) and * calculateMean(Collection, boolean) methods. */ public void testCalculateMean_Collection() { // try a null collection boolean pass = false; try { Statistics.calculateMean((Collection) null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { Statistics.calculateMean((Collection) null, false); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // try an empty collection List values = new ArrayList(); assertTrue(Double.isNaN(Statistics.calculateMean(values))); assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); assertTrue(Double.isNaN(Statistics.calculateMean(values, false))); // try a collection with a single number values.add(new Double(9.0)); assertEquals(9.0, Statistics.calculateMean(values), EPSILON); assertEquals(9.0, Statistics.calculateMean(values, true), EPSILON); assertEquals(9.0, Statistics.calculateMean(values, false), EPSILON); // try a collection with a single number plus a null values.add(null); assertTrue(Double.isNaN(Statistics.calculateMean(values))); assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); assertEquals(9.0, Statistics.calculateMean(values, false), EPSILON); // try a collection with a single number plus a NaN values.clear(); values.add(new Double(9.0)); values.add(new Double(Double.NaN)); assertTrue(Double.isNaN(Statistics.calculateMean(values))); assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); assertEquals(9.0, Statistics.calculateMean(values, false), EPSILON); // try a collection with several numbers values = new ArrayList(); values.add(new Double(9.0)); values.add(new Double(3.0)); values.add(new Double(2.0)); values.add(new Double(2.0)); double mean = Statistics.calculateMean(values); assertEquals(4.0, mean, EPSILON); // a Collection containing a NaN will return Double.NaN for the result values.add(new Double(Double.NaN)); assertTrue(Double.isNaN(Statistics.calculateMean(values))); } static final double EPSILON = 0.0000000001; /** * Some checks for the calculateMedian(List, boolean) method. */ public void testCalculateMedian() { // check null list assertTrue(Double.isNaN(Statistics.calculateMedian(null, false))); assertTrue(Double.isNaN(Statistics.calculateMedian(null, true))); // check empty list List list = new ArrayList(); assertTrue(Double.isNaN(Statistics.calculateMedian(list, false))); assertTrue(Double.isNaN(Statistics.calculateMedian(list, true))); // check list containing null list.add(null); boolean pass = false; try { Statistics.calculateMedian(list, false); } catch (NullPointerException e) { pass = true; } assertTrue(pass); pass = false; try { Statistics.calculateMedian(list, true); } catch (NullPointerException e) { pass = true; } assertTrue(pass); // check a list containing a non-Number object list.clear(); list.add("Not a number"); pass = false; try { Statistics.calculateMedian(list, false); } catch (ClassCastException e) { pass = true; } assertTrue(pass); pass = false; try { Statistics.calculateMedian(list, true); } catch (ClassCastException e) { pass = true; } assertTrue(pass); } /** * A test for the calculateMedian() method. */ public void testCalculateMedian1() { List values = new ArrayList(); values.add(new Double(1.0)); double median = Statistics.calculateMedian(values); assertEquals(1.0, median, 0.0000001); } /** * A test for the calculateMedian() method. */ public void testCalculateMedian2() { List values = new ArrayList(); values.add(new Double(2.0)); values.add(new Double(1.0)); double median = Statistics.calculateMedian(values); assertEquals(1.5, median, 0.0000001); } /** * A test for the calculateMedian() method. */ public void testCalculateMedian3() { List values = new ArrayList(); values.add(new Double(1.0)); values.add(new Double(2.0)); values.add(new Double(3.0)); values.add(new Double(6.0)); values.add(new Double(5.0)); values.add(new Double(4.0)); double median = Statistics.calculateMedian(values); assertEquals(3.5, median, 0.0000001); } /** * A test for the calculateMedian() method. */ public void testCalculateMedian4() { List values = new ArrayList(); values.add(new Double(7.0)); values.add(new Double(2.0)); values.add(new Double(3.0)); values.add(new Double(5.0)); values.add(new Double(4.0)); values.add(new Double(6.0)); values.add(new Double(1.0)); double median = Statistics.calculateMedian(values); assertEquals(4.0, median, 0.0000001); } /** * A test using some real data that caused a problem at one point. */ public void testCalculateMedian5() { List values = new ArrayList(); values.add(new Double(11.228692993861783)); values.add(new Double(11.30823353859889)); values.add(new Double(11.75312904769314)); values.add(new Double(11.825102897465314)); values.add(new Double(10.184252778401783)); values.add(new Double(12.207951828057766)); values.add(new Double(10.68841994040566)); values.add(new Double(12.099522004479438)); values.add(new Double(11.508874945056881)); values.add(new Double(12.052517729558513)); values.add(new Double(12.401481645578734)); values.add(new Double(12.185377793028543)); values.add(new Double(10.666372951930315)); values.add(new Double(11.680978041499548)); values.add(new Double(11.06528277406718)); values.add(new Double(11.36876492904596)); values.add(new Double(11.927565516175939)); values.add(new Double(11.39307785978655)); values.add(new Double(11.989603679523857)); values.add(new Double(12.009834360354864)); values.add(new Double(10.653351822461559)); values.add(new Double(11.851776254376754)); values.add(new Double(11.045441544755946)); values.add(new Double(11.993674040560624)); values.add(new Double(12.898219965238944)); values.add(new Double(11.97095782819647)); values.add(new Double(11.73234406745488)); values.add(new Double(11.649006017243991)); values.add(new Double(12.20549704915365)); values.add(new Double(11.799723639384919)); values.add(new Double(11.896208658005628)); values.add(new Double(12.164149111823424)); values.add(new Double(12.042795103513766)); values.add(new Double(12.114839532596426)); values.add(new Double(12.166609097075824)); values.add(new Double(12.183017546225935)); values.add(new Double(11.622009125845342)); values.add(new Double(11.289365786738633)); values.add(new Double(12.462984323671568)); values.add(new Double(11.573494921030598)); values.add(new Double(10.862867940485804)); values.add(new Double(12.018186939664872)); values.add(new Double(10.418046849313018)); values.add(new Double(11.326344465881341)); double median = Statistics.calculateMedian(values, true); assertEquals(11.812413268425116, median, 0.000001); Collections.sort(values); double median2 = Statistics.calculateMedian(values, false); assertEquals(11.812413268425116, median2, 0.000001); } /** * A test for the calculateMedian() method. */ public void testCalculateMedian6() { List values = new ArrayList(); values.add(new Double(7.0)); values.add(new Double(2.0)); values.add(new Double(3.0)); values.add(new Double(5.0)); values.add(new Double(4.0)); values.add(new Double(6.0)); values.add(new Double(1.0)); double median = Statistics.calculateMedian(values, 0, 2); assertEquals(3.0, median, 0.0000001); } /** * A simple test for the correlation calculation. */ public void testCorrelation1() { Number[] data1 = new Number[3]; data1[0] = new Double(1); data1[1] = new Double(2); data1[2] = new Double(3); Number[] data2 = new Number[3]; data2[0] = new Double(1); data2[1] = new Double(2); data2[2] = new Double(3); double r = Statistics.getCorrelation(data1, data2); assertEquals(1.0, r, 0.00000001); } /** * A simple test for the correlation calculation. * * http://trochim.human.cornell.edu/kb/statcorr.htm */ public void testCorrelation2() { Number[] data1 = new Number[20]; data1[0] = new Double(68); data1[1] = new Double(71); data1[2] = new Double(62); data1[3] = new Double(75); data1[4] = new Double(58); data1[5] = new Double(60); data1[6] = new Double(67); data1[7] = new Double(68); data1[8] = new Double(71); data1[9] = new Double(69); data1[10] = new Double(68); data1[11] = new Double(67); data1[12] = new Double(63); data1[13] = new Double(62); data1[14] = new Double(60); data1[15] = new Double(63); data1[16] = new Double(65); data1[17] = new Double(67); data1[18] = new Double(63); data1[19] = new Double(61); Number[] data2 = new Number[20]; data2[0] = new Double(4.1); data2[1] = new Double(4.6); data2[2] = new Double(3.8); data2[3] = new Double(4.4); data2[4] = new Double(3.2); data2[5] = new Double(3.1); data2[6] = new Double(3.8); data2[7] = new Double(4.1); data2[8] = new Double(4.3); data2[9] = new Double(3.7); data2[10] = new Double(3.5); data2[11] = new Double(3.2); data2[12] = new Double(3.7); data2[13] = new Double(3.3); data2[14] = new Double(3.4); data2[15] = new Double(4.0); data2[16] = new Double(4.1); data2[17] = new Double(3.8); data2[18] = new Double(3.4); data2[19] = new Double(3.6); double r = Statistics.getCorrelation(data1, data2); assertEquals(0.7306356862792885, r, 0.000000000001); } /** * Some checks for the getStdDev() method. */ public void testGetStdDev() { // try null argument boolean pass = false; try { Statistics.getStdDev(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // try zero length array pass = false; try { Statistics.getStdDev(new Double[0]); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); // try single value assertTrue(Double.isNaN(Statistics.getStdDev(new Double[] {new Double(1.0)}))); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/statistics/junit/package.html0000644000175000017500000000026311173030414027710 0ustar vincentvincent Tests for the classes in the org.jfree.data.statistics package. libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/0000755000175000017500000000000011173030414023041 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/0000755000175000017500000000000011216245562024204 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/DataTimePackageTests.java0000644000175000017500000000715111173030414031030 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * DataTimePackageTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2001 : Version 1 (DG); * 23-Aug-2004 : Restructured org.jfree.data package (DG); * 18-Jan-2005 : Added main() method (DG); * */ package org.jfree.data.time.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data.time package that can be run * using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataTimePackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.time"); suite.addTestSuite(DateRangeTests.class); suite.addTestSuite(DayTests.class); suite.addTestSuite(FixedMillisecondTests.class); suite.addTestSuite(HourTests.class); suite.addTestSuite(MinuteTests.class); suite.addTestSuite(MillisecondTests.class); suite.addTestSuite(MonthTests.class); suite.addTestSuite(MovingAverageTests.class); suite.addTestSuite(QuarterTests.class); suite.addTestSuite(SecondTests.class); suite.addTestSuite(SimpleTimePeriodTests.class); suite.addTestSuite(TimePeriodAnchorTests.class); suite.addTestSuite(TimePeriodValueTests.class); suite.addTestSuite(TimePeriodValuesTests.class); suite.addTestSuite(TimePeriodValuesCollectionTests.class); suite.addTestSuite(TimeSeriesCollectionTests.class); suite.addTestSuite(TimeSeriesTests.class); suite.addTestSuite(TimeSeriesDataItemTests.class); suite.addTestSuite(TimeTableXYDatasetTests.class); suite.addTestSuite(WeekTests.class); suite.addTestSuite(YearTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataTimePackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/DateRangeTests.java0000644000175000017500000001073211173030414027715 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * DateRangeTests.java * ------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Mar-2004 : Version 1 (DG); * 11-Jan-2005 : Added test to ensure Cloneable is not implemented (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.DateRange; /** * Some tests for the {@link DateRange} class. */ public class DateRangeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DateRangeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DateRangeTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DateRange r1 = new DateRange(new Date(1000L), new Date(2000L)); DateRange r2 = new DateRange(new Date(1000L), new Date(2000L)); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1 = new DateRange(new Date(1111L), new Date(2000L)); assertFalse(r1.equals(r2)); r2 = new DateRange(new Date(1111L), new Date(2000L)); assertTrue(r1.equals(r2)); r1 = new DateRange(new Date(1111L), new Date(2222L)); assertFalse(r1.equals(r2)); r2 = new DateRange(new Date(1111L), new Date(2222L)); assertTrue(r1.equals(r2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DateRange r1 = new DateRange(new Date(1000L), new Date(2000L)); DateRange r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (DateRange) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); } /** * The {@link DateRange} class is immutable, so it doesn't need to * be cloneable. */ public void testClone() { DateRange r1 = new DateRange(new Date(1000L), new Date(2000L)); assertFalse(r1 instanceof Cloneable); } /** * Confirm that a DateRange is immutable. */ public void testImmutable() { Date d1 = new Date(10L); Date d2 = new Date(20L); DateRange r = new DateRange(d1, d2); d1.setTime(11L); assertEquals(new Date(10L), r.getLowerDate()); r.getUpperDate().setTime(22L); assertEquals(new Date(20L), r.getUpperDate()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/DayTests.java0000644000175000017500000003170611173030414026604 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------- * DayTests.java * ------------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 15-Nov-2001 : Version 1 (DG); * 20-Mar-2002 : Added new tests for Day constructor and getStart() and * getEnd() in different time zones (DG); * 26-Jun-2002 : Removed unnecessary imports (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 21-Oct-2003 : Added hashCode test (DG); * 11-Jan-2005 : Added test for non-clonability (DG); * 03-Oct-2006 : Added testGetSerialIndex() (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.date.MonthConstants; /** * Tests for the {@link Day} class. */ public class DayTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DayTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DayTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup required } /** * Check that a Day instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Day day = new Day(); assertTrue(day.equals(day)); } /** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Day day2 = new Day(29, MonthConstants.MARCH, 2002); assertTrue(day1.equals(day2)); } /** * In GMT, the end of 29 Feb 2004 is java.util.Date(1,078,099,199,999L). * Use this to check the day constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Locale locale = Locale.UK; Day d1 = new Day(new Date(1078099199999L), zone, locale); Day d2 = new Day(new Date(1078099200000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078099199999L, d1.getLastMillisecond(zone)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078099200000L, d2.getFirstMillisecond(zone)); } /** * In Helsinki, the end of 29 Feb 2004 is * java.util.Date(1,078,091,999,999L). Use this to check the Day * constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Helsinki"); Locale locale = Locale.getDefault(); // locale shouldn't matter here Day d1 = new Day(new Date(1078091999999L), zone, locale); Day d2 = new Day(new Date(1078092000000L), zone, locale); assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); assertEquals(1078091999999L, d1.getLastMillisecond(zone)); assertEquals(MonthConstants.MARCH, d2.getMonth()); assertEquals(1078092000000L, d2.getFirstMillisecond(zone)); } /** * Set up a day equal to 1 January 1900. Request the previous day, it * should be null. */ public void test1Jan1900Previous() { Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900); Day previous = (Day) jan1st1900.previous(); assertNull(previous); } /** * Set up a day equal to 1 January 1900. Request the next day, it should * be 2 January 1900. */ public void test1Jan1900Next() { Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900); Day next = (Day) jan1st1900.next(); assertEquals(2, next.getDayOfMonth()); } /** * Set up a day equal to 31 December 9999. Request the previous day, it * should be 30 December 9999. */ public void test31Dec9999Previous() { Day dec31st9999 = new Day(31, MonthConstants.DECEMBER, 9999); Day previous = (Day) dec31st9999.previous(); assertEquals(30, previous.getDayOfMonth()); } /** * Set up a day equal to 31 December 9999. Request the next day, it should * be null. */ public void test31Dec9999Next() { Day dec31st9999 = new Day(31, MonthConstants.DECEMBER, 9999); Day next = (Day) dec31st9999.next(); assertNull(next); } /** * Problem for date parsing. *

      * This test works only correct if the short pattern of the date * format is "dd/MM/yyyy". If not, this test will result in a * false negative. * * @throws ParseException on parsing errors. */ public void testParseDay() throws ParseException { GregorianCalendar gc = new GregorianCalendar(2001, 12, 31); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); Date reference = format.parse("31/12/2001"); if (reference.equals(gc.getTime())) { // test 1... Day d = Day.parseDay("31/12/2001"); assertEquals(37256, d.getSerialDate().toSerial()); } // test 2... Day d = Day.parseDay("2001-12-31"); assertEquals(37256, d.getSerialDate().toSerial()); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Day d1 = new Day(15, 4, 2000); Day d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (Day) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Day d1 = new Day(1, 2, 2003); Day d2 = new Day(1, 2, 2003); assertTrue(d1.equals(d2)); int h1 = d1.hashCode(); int h2 = d2.hashCode(); assertEquals(h1, h2); } /** * The {@link Day} class is immutable, so should not be {@link Cloneable}. */ public void testNotCloneable() { Day d = new Day(1, 2, 2003); assertFalse(d instanceof Cloneable); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Day d = new Day(1, 1, 1900); assertEquals(2, d.getSerialIndex()); d = new Day(15, 4, 2000); assertEquals(36631, d.getSerialIndex()); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Day d = new Day(1, 3, 1970); assertEquals(5094000000L, d.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Day d = new Day(26, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-621187200000L, d.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { d.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Day d = new Day(1, 12, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1007164800000L, d.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { d.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Day d = new Day(1, 1, 1970); assertEquals(82799999L, d.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Day d = new Day(1, 2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-628358400001L, d.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { d.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Day d = new Day(4, 5, 2001); Calendar calendar = Calendar.getInstance( TimeZone.getTimeZone("Europe/London"), Locale.UK); assertEquals(989017199999L, d.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { d.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the testNext() method. */ public void testNext() { Day d = new Day(25, 12, 2000); d = (Day) d.next(); assertEquals(2000, d.getYear()); assertEquals(12, d.getMonth()); assertEquals(26, d.getDayOfMonth()); d = new Day(31, 12, 9999); assertNull(d.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.NOVEMBER, 3, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Day d = new Day(3, 11, 2006); assertEquals(cal.getTime(), d.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(1900, Calendar.JANUARY, 1, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Day d = new Day(1, 1, 1900); assertEquals(cal.getTime(), d.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/FixedMillisecondTests.java0000644000175000017500000001014311173030414031301 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * FixedMillisecondTests.java * -------------------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jan-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 21-Oct-2003 : Added hashCode test (DG); * 28-May-2008 : Added test for immutability (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.FixedMillisecond; /** * Tests for the {@link FixedMillisecond} class. */ public class FixedMillisecondTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(FixedMillisecondTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public FixedMillisecondTests(String name) { super(name); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { FixedMillisecond m1 = new FixedMillisecond(); FixedMillisecond m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (FixedMillisecond) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { FixedMillisecond m1 = new FixedMillisecond(500000L); FixedMillisecond m2 = new FixedMillisecond(500000L); assertTrue(m1.equals(m2)); int h1 = m1.hashCode(); int h2 = m2.hashCode(); assertEquals(h1, h2); } /** * The {@link FixedMillisecond} class is immutable, so should not be * {@link Cloneable}. */ public void testNotCloneable() { FixedMillisecond m = new FixedMillisecond(500000L); assertFalse(m instanceof Cloneable); } /** * A check for immutability. */ public void testImmutability() { Date d = new Date(20L); FixedMillisecond fm = new FixedMillisecond(d); d.setTime(22L); assertEquals(20L, fm.getFirstMillisecond()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/HourTests.java0000644000175000017500000003057711173030414027011 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * HourTests.java * -------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jan-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 21-Oct-2003 : Added hashCode test (DG); * 11-Jan-2005 : Added test for non-clonability (DG); * 05-Oct-2006 : Added new tests (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.Hour; import org.jfree.date.MonthConstants; /** * Tests for the {@link Hour} class. */ public class HourTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(HourTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public HourTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Check that an Hour instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Hour hour = new Hour(); assertTrue(hour.equals(hour)); } /** * Tests the equals method. */ public void testEquals() { Hour hour1 = new Hour(15, new Day(29, MonthConstants.MARCH, 2002)); Hour hour2 = new Hour(15, new Day(29, MonthConstants.MARCH, 2002)); assertTrue(hour1.equals(hour2)); } /** * In GMT, the 4pm on 21 Mar 2002 is java.util.Date(1,014,307,200,000L). * Use this to check the hour constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Locale locale = Locale.getDefault(); // locale should not matter here Hour h1 = new Hour(new Date(1014307199999L), zone, locale); Hour h2 = new Hour(new Date(1014307200000L), zone, locale); assertEquals(15, h1.getHour()); assertEquals(1014307199999L, h1.getLastMillisecond(zone)); assertEquals(16, h2.getHour()); assertEquals(1014307200000L, h2.getFirstMillisecond(zone)); } /** * In Sydney, the 4pm on 21 Mar 2002 is java.util.Date(1,014,267,600,000L). * Use this to check the hour constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Australia/Sydney"); Locale locale = Locale.getDefault(); // locale should not matter here Hour h1 = new Hour(new Date(1014267599999L), zone, locale); Hour h2 = new Hour (new Date(1014267600000L), zone, locale); assertEquals(15, h1.getHour()); assertEquals(1014267599999L, h1.getLastMillisecond(zone)); assertEquals(16, h2.getHour()); assertEquals(1014267600000L, h2.getFirstMillisecond(zone)); } /** * Set up an hour equal to hour zero, 1 January 1900. Request the * previous hour, it should be null. */ public void testFirstHourPrevious() { Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900)); Hour previous = (Hour) first.previous(); assertNull(previous); } /** * Set up an hour equal to hour zero, 1 January 1900. Request the next * hour, it should be null. */ public void testFirstHourNext() { Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900)); Hour next = (Hour) first.next(); assertEquals(1, next.getHour()); assertEquals(1900, next.getYear()); } /** * Set up an hour equal to hour zero, 1 January 1900. Request the previous * hour, it should be null. */ public void testLastHourPrevious() { Hour last = new Hour(23, new Day(31, MonthConstants.DECEMBER, 9999)); Hour previous = (Hour) last.previous(); assertEquals(22, previous.getHour()); assertEquals(9999, previous.getYear()); } /** * Set up an hour equal to hour zero, 1 January 1900. Request the next * hour, it should be null. */ public void testLastHourNext() { Hour last = new Hour(23, new Day(31, MonthConstants.DECEMBER, 9999)); Hour next = (Hour) last.next(); assertNull(next); } /** * Problem for date parsing. */ public void testParseHour() { // test 1... Hour h = Hour.parseHour("2002-01-29 13"); assertEquals(13, h.getHour()); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Hour h1 = new Hour(); Hour h2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(h1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); h2 = (Hour) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(h1, h2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Hour h1 = new Hour(7, 9, 10, 1999); Hour h2 = new Hour(7, 9, 10, 1999); assertTrue(h1.equals(h2)); int hash1 = h1.hashCode(); int hash2 = h2.hashCode(); assertEquals(hash1, hash2); } /** * The {@link Hour} class is immutable, so should not be {@link Cloneable}. */ public void testNotCloneable() { Hour h = new Hour(7, 9, 10, 1999); assertFalse(h instanceof Cloneable); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Hour h = new Hour(15, 1, 4, 2006); assertEquals(1143900000000L, h.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Hour h = new Hour(15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623293200000L, h.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { h.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Hour h = new Hour(2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955764000000L, h.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Hour h = new Hour(1, 1, 1, 1970); assertEquals(3599999L, h.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Hour h = new Hour(2, 7, 7, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-614959200001L, h.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { h.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Hour h = new Hour(21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987890399999L, h.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { h.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Hour h = new Hour(1, 1, 1, 2000); assertEquals(876625L, h.getSerialIndex()); h = new Hour(1, 1, 1, 1900); assertEquals(49L, h.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Hour h = new Hour(1, 12, 12, 2000); h = (Hour) h.next(); assertEquals(2000, h.getYear()); assertEquals(12, h.getMonth()); assertEquals(12, h.getDayOfMonth()); assertEquals(2, h.getHour()); h = new Hour(23, 31, 12, 9999); assertNull(h.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 0, 0); cal.set(Calendar.MILLISECOND, 0); Hour h = new Hour(3, 16, 1, 2006); assertEquals(cal.getTime(), h.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59); cal.set(Calendar.MILLISECOND, 999); Hour h = new Hour(1, 8, 1, 2006); assertEquals(cal.getTime(), h.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/MillisecondTests.java0000644000175000017500000003166511173030414030335 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * MillisecondTests.java * --------------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jan-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 21-Oct-2003 : Added hashCode tests (DG); * 29-Apr-2004 : Added test for getMiddleMillisecond() method (DG); * 11-Jan-2005 : Added test for non-clonability (DG); * 05-Oct-2006 : Added some tests (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.Hour; import org.jfree.data.time.Millisecond; import org.jfree.data.time.Minute; import org.jfree.data.time.Second; import org.jfree.date.MonthConstants; /** * Tests for the {@link Millisecond} class. */ public class MillisecondTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MillisecondTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MillisecondTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Check that a {@link Millisecond} instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Millisecond millisecond = new Millisecond(); assertTrue(millisecond.equals(millisecond)); } /** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Second second1 = new Second(34, minute1); Millisecond milli1 = new Millisecond(999, second1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); Second second2 = new Second(34, minute2); Millisecond milli2 = new Millisecond(999, second2); assertTrue(milli1.equals(milli2)); } /** * In GMT, the 4.55:59.123pm on 21 Mar 2002 is * java.util.Date(1016729759123L). Use this to check the Millisecond * constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Locale locale = Locale.getDefault(); // locale should not matter here Millisecond m1 = new Millisecond(new Date(1016729759122L), zone, locale); Millisecond m2 = new Millisecond(new Date(1016729759123L), zone, locale); assertEquals(122, m1.getMillisecond()); assertEquals(1016729759122L, m1.getLastMillisecond(zone)); assertEquals(123, m2.getMillisecond()); assertEquals(1016729759123L, m2.getFirstMillisecond(zone)); } /** * In Tallinn, the 4.55:59.123pm on 21 Mar 2002 is * java.util.Date(1016722559123L). Use this to check the Millisecond * constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Tallinn"); Locale locale = Locale.getDefault(); // locale should not matter here Millisecond m1 = new Millisecond(new Date(1016722559122L), zone, locale); Millisecond m2 = new Millisecond(new Date(1016722559123L), zone, locale); assertEquals(122, m1.getMillisecond()); assertEquals(1016722559122L, m1.getLastMillisecond(zone)); assertEquals(123, m2.getMillisecond()); assertEquals(1016722559123L, m2.getFirstMillisecond(zone)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Millisecond m1 = new Millisecond(); Millisecond m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (Millisecond) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Millisecond m1 = new Millisecond(599, 23, 45, 7, 9, 10, 2007); Millisecond m2 = new Millisecond(599, 23, 45, 7, 9, 10, 2007); assertTrue(m1.equals(m2)); int hash1 = m1.hashCode(); int hash2 = m2.hashCode(); assertEquals(hash1, hash2); } /** * A test for bug report 943985 - the calculation for the middle * millisecond is incorrect for odd milliseconds. */ public void test943985() { Millisecond ms = new Millisecond(new java.util.Date(4)); assertEquals(ms.getFirstMillisecond(), ms.getMiddleMillisecond()); assertEquals(ms.getMiddleMillisecond(), ms.getLastMillisecond()); ms = new Millisecond(new java.util.Date(5)); assertEquals(ms.getFirstMillisecond(), ms.getMiddleMillisecond()); assertEquals(ms.getMiddleMillisecond(), ms.getLastMillisecond()); } /** * The {@link Millisecond} class is immutable, so should not be * {@link Cloneable}. */ public void testNotCloneable() { Millisecond m = new Millisecond(599, 23, 45, 7, 9, 10, 2007); assertFalse(m instanceof Cloneable); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Millisecond m = new Millisecond(500, 15, 43, 15, 1, 4, 2006); assertEquals(1143902595500L, m.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Millisecond m = new Millisecond(500, 50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623289609500L, m.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455500L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Millisecond m = new Millisecond(750, 1, 1, 1, 1, 1, 1970); assertEquals(61750L, m.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Millisecond m = new Millisecond(750, 55, 1, 2, 7, 7, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-614962684250L, m.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { m.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550250L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Millisecond m = new Millisecond(500, 1, 1, 1, 1, 1, 2000); assertEquals(3155850061500L, m.getSerialIndex()); m = new Millisecond(500, 1, 1, 1, 1, 1, 1900); // TODO: this must be wrong... assertEquals(176461500L, m.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Millisecond m = new Millisecond(555, 55, 30, 1, 12, 12, 2000); m = (Millisecond) m.next(); assertEquals(2000, m.getSecond().getMinute().getHour().getYear()); assertEquals(12, m.getSecond().getMinute().getHour().getMonth()); assertEquals(12, m.getSecond().getMinute().getHour().getDayOfMonth()); assertEquals(1, m.getSecond().getMinute().getHour().getHour()); assertEquals(30, m.getSecond().getMinute().getMinute()); assertEquals(55, m.getSecond().getSecond()); assertEquals(556, m.getMillisecond()); m = new Millisecond(999, 59, 59, 23, 31, 12, 9999); assertNull(m.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 555); Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 555); Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/MinuteTests.java0000644000175000017500000002760611173030414027334 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * MinuteTests.java * ---------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jan-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 21-Oct-2003 : Added hashCode test (DG); * 11-Jan-2005 : Added test for non-clonability (DG); * 05-Oct-2006 : Added new tests (DG); * 11-Dec-2006 : Added test1611872() (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.Hour; import org.jfree.data.time.Minute; import org.jfree.date.MonthConstants; /** * Tests for the {@link Minute} class. */ public class MinuteTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MinuteTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MinuteTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Check that a Minute instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Minute minute = new Minute(); assertTrue(minute.equals(minute)); } /** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); assertTrue(minute1.equals(minute2)); } /** * In GMT, the 4.55pm on 21 Mar 2002 is java.util.Date(1016729700000L). * Use this to check the Minute constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Locale locale = Locale.getDefault(); // locale should not matter here Minute m1 = new Minute(new Date(1016729699999L), zone, locale); Minute m2 = new Minute(new Date(1016729700000L), zone, locale); assertEquals(54, m1.getMinute()); assertEquals(1016729699999L, m1.getLastMillisecond(zone)); assertEquals(55, m2.getMinute()); assertEquals(1016729700000L, m2.getFirstMillisecond(zone)); } /** * In Singapore, the 4.55pm on 21 Mar 2002 is * java.util.Date(1,014,281,700,000L). Use this to check the Minute * constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Asia/Singapore"); Locale locale = Locale.getDefault(); // locale should not matter here Minute m1 = new Minute(new Date(1016700899999L), zone, locale); Minute m2 = new Minute(new Date(1016700900000L), zone, locale); assertEquals(54, m1.getMinute()); assertEquals(1016700899999L, m1.getLastMillisecond(zone)); assertEquals(55, m2.getMinute()); assertEquals(1016700900000L, m2.getFirstMillisecond(zone)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Minute m1 = new Minute(); Minute m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (Minute) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(m1, m2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Minute m1 = new Minute(45, 5, 1, 2, 2003); Minute m2 = new Minute(45, 5, 1, 2, 2003); assertTrue(m1.equals(m2)); int h1 = m1.hashCode(); int h2 = m2.hashCode(); assertEquals(h1, h2); } /** * The {@link Minute} class is immutable, so should not be * {@link Cloneable}. */ public void testNotCloneable() { Minute m = new Minute(45, 5, 1, 2, 2003); assertFalse(m instanceof Cloneable); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Minute m = new Minute(43, 15, 1, 4, 2006); assertEquals(1143902580000L, m.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Minute m = new Minute(59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623289660000L, m.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Minute m = new Minute(40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766400000L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Minute m = new Minute(1, 1, 1, 1, 1970); assertEquals(119999L, m.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Minute m = new Minute(1, 2, 7, 7, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-614962680001L, m.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { m.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Minute m = new Minute(45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889559999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Minute m = new Minute(1, 1, 1, 1, 2000); assertEquals(52597501L, m.getSerialIndex()); m = new Minute(1, 1, 1, 1, 1900); assertEquals(2941L, m.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Minute m = new Minute(30, 1, 12, 12, 2000); m = (Minute) m.next(); assertEquals(2000, m.getHour().getYear()); assertEquals(12, m.getHour().getMonth()); assertEquals(12, m.getHour().getDayOfMonth()); assertEquals(1, m.getHour().getHour()); assertEquals(31, m.getMinute()); m = new Minute(59, 23, 31, 12, 9999); assertNull(m.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 0); cal.set(Calendar.MILLISECOND, 0); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 59); cal.set(Calendar.MILLISECOND, 999); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Test for bug 1611872 - previous() fails for first minute in hour. */ public void test1611872() { Minute m1 = new Minute(0, 10, 15, 4, 2000); Minute m2 = (Minute) m1.previous(); assertEquals(m2, new Minute(59, 9, 15, 4, 2000)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/MonthTests.java0000644000175000017500000003215611173030414027154 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------- * MonthTests.java * --------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Nov-2001 : Version 1 (DG); * 14-Feb-2002 : Order of parameters in Month(int, int) constructor * changed (DG); * 26-Jun-2002 : Removed unnecessary import (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 21-Oct-2003 : Added hashCode test (DG); * 11-Jan-2005 : Added non-clonability test (DG); * 05-Oct-2006 : Added some new tests (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Month; import org.jfree.data.time.TimePeriodFormatException; import org.jfree.data.time.Year; import org.jfree.date.MonthConstants; /** * Tests for the {@link Month} class. */ public class MonthTests extends TestCase { /** A month. */ private Month jan1900; /** A month. */ private Month feb1900; /** A month. */ private Month nov9999; /** A month. */ private Month dec9999; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MonthTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MonthTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.jan1900 = new Month(MonthConstants.JANUARY, 1900); this.feb1900 = new Month(MonthConstants.FEBRUARY, 1900); this.nov9999 = new Month(MonthConstants.NOVEMBER, 9999); this.dec9999 = new Month(MonthConstants.DECEMBER, 9999); } /** * Check that a Month instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Month month = new Month(); assertTrue(month.equals(month)); } /** * Tests the equals method. */ public void testEquals() { Month m1 = new Month(MonthConstants.MAY, 2002); Month m2 = new Month(MonthConstants.MAY, 2002); assertTrue(m1.equals(m2)); } /** * In GMT, the end of Feb 2000 is java.util.Date(951,868,799,999L). Use * this to check the Month constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Month m1 = new Month(new Date(951868799999L), zone); Month m2 = new Month(new Date(951868800000L), zone); assertEquals(MonthConstants.FEBRUARY, m1.getMonth()); assertEquals(951868799999L, m1.getLastMillisecond(zone)); assertEquals(MonthConstants.MARCH, m2.getMonth()); assertEquals(951868800000L, m2.getFirstMillisecond(zone)); } /** * In Auckland, the end of Feb 2000 is java.util.Date(951,821,999,999L). * Use this to check the Month constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Pacific/Auckland"); Month m1 = new Month(new Date(951821999999L), zone); Month m2 = new Month(new Date(951822000000L), zone); assertEquals(MonthConstants.FEBRUARY, m1.getMonth()); assertEquals(951821999999L, m1.getLastMillisecond(zone)); assertEquals(MonthConstants.MARCH, m2.getMonth()); assertEquals(951822000000L, m2.getFirstMillisecond(zone)); } /** * Set up a month equal to Jan 1900. Request the previous month, it should * be null. */ public void testJan1900Previous() { Month previous = (Month) this.jan1900.previous(); assertNull(previous); } /** * Set up a month equal to Jan 1900. Request the next month, it should be * Feb 1900. */ public void testJan1900Next() { Month next = (Month) this.jan1900.next(); assertEquals(this.feb1900, next); } /** * Set up a month equal to Dec 9999. Request the previous month, it should * be Nov 9999. */ public void testDec9999Previous() { Month previous = (Month) this.dec9999.previous(); assertEquals(this.nov9999, previous); } /** * Set up a month equal to Dec 9999. Request the next month, it should be * null. */ public void testDec9999Next() { Month next = (Month) this.dec9999.next(); assertNull(next); } /** * Tests the string parsing code... */ public void testParseMonth() { Month month = null; // test 1... try { month = Month.parseMonth("1990-01"); } catch (TimePeriodFormatException e) { month = new Month(1, 1900); } assertEquals(1, month.getMonth()); assertEquals(1990, month.getYear().getYear()); // test 2... try { month = Month.parseMonth("02-1991"); } catch (TimePeriodFormatException e) { month = new Month(1, 1900); } assertEquals(2, month.getMonth()); assertEquals(1991, month.getYear().getYear()); // test 3... try { month = Month.parseMonth("March 1993"); } catch (TimePeriodFormatException e) { month = new Month(1, 1900); } assertEquals(3, month.getMonth()); assertEquals(1993, month.getYear().getYear()); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Month m1 = new Month(12, 1999); Month m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); m2 = (Month) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(m1, m2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Month m1 = new Month(2, 2003); Month m2 = new Month(2, 2003); assertTrue(m1.equals(m2)); int h1 = m1.hashCode(); int h2 = m2.hashCode(); assertEquals(h1, h2); } /** * The {@link Month} class is immutable, so should not be {@link Cloneable}. */ public void testNotCloneable() { Month m = new Month(2, 2003); assertFalse(m instanceof Cloneable); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Month m = new Month(3, 1970); assertEquals(5094000000L, m.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Month m = new Month(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-628444800000L, m.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Month m = new Month(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, m.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Month m = new Month(3, 1970); assertEquals(7772399999L, m.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Month m = new Month(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-626025600001L, m.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { m.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Month m = new Month(3, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(986083199999L, m.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { m.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Month m = new Month(1, 2000); assertEquals(24001L, m.getSerialIndex()); m = new Month(1, 1900); assertEquals(22801L, m.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Month m = new Month(12, 2000); m = (Month) m.next(); assertEquals(new Year(2001), m.getYear()); assertEquals(1, m.getMonth()); m = new Month(12, 9999); assertNull(m.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.MARCH, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Month m = new Month(3, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Month m = new Month(1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/MovingAverageTests.java0000644000175000017500000001043711173030414030617 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * MovingAverageTests.java * ----------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2003 : Version 1 (DG); * 04-Oct-2004 : Eliminated NumberUtils usage (DG); * */ package org.jfree.data.time.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.MovingAverage; import org.jfree.data.time.TimeSeries; import org.jfree.date.MonthConstants; /** * Tests for the {@link MovingAverage} class. */ public class MovingAverageTests extends TestCase { private static final double EPSILON = 0.0000000001; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MovingAverageTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MovingAverageTests(String name) { super(name); } /** * A test for the values calculated from a time series. */ public void test1() { TimeSeries source = createDailyTimeSeries1(); TimeSeries maverage = MovingAverage.createMovingAverage( source, "Moving Average", 3, 3 ); // the moving average series has 7 items, the first three // days (11, 12, 13 August are skipped) assertEquals(7, maverage.getItemCount()); double value = maverage.getValue(0).doubleValue(); assertEquals(14.1, value, EPSILON); value = maverage.getValue(1).doubleValue(); assertEquals(13.4, value, EPSILON); value = maverage.getValue(2).doubleValue(); assertEquals(14.433333333333, value, EPSILON); value = maverage.getValue(3).doubleValue(); assertEquals(14.933333333333, value, EPSILON); value = maverage.getValue(4).doubleValue(); assertEquals(19.8, value, EPSILON); value = maverage.getValue(5).doubleValue(); assertEquals(15.25, value, EPSILON); value = maverage.getValue(6).doubleValue(); assertEquals(12.5, value, EPSILON); } /** * Creates a sample series. * * @return A sample series. */ private TimeSeries createDailyTimeSeries1() { TimeSeries series = new TimeSeries("Series 1", Day.class); series.add(new Day(11, MonthConstants.AUGUST, 2003), 11.2); series.add(new Day(13, MonthConstants.AUGUST, 2003), 13.8); series.add(new Day(17, MonthConstants.AUGUST, 2003), 14.1); series.add(new Day(18, MonthConstants.AUGUST, 2003), 12.7); series.add(new Day(19, MonthConstants.AUGUST, 2003), 16.5); series.add(new Day(20, MonthConstants.AUGUST, 2003), 15.6); series.add(new Day(25, MonthConstants.AUGUST, 2003), 19.8); series.add(new Day(27, MonthConstants.AUGUST, 2003), 10.7); series.add(new Day(28, MonthConstants.AUGUST, 2003), 14.3); return series; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/QuarterTests.java0000644000175000017500000003275311173030414027515 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------- * QuarterTests.java * ----------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Nov-2001 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 11-Jan-2005 : Added check for non-clonability (DG); * 05-Oct-2006 : Added some new tests (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Quarter; import org.jfree.data.time.TimePeriodFormatException; import org.jfree.data.time.Year; /** * Tests for the {link Quarter} class. */ public class QuarterTests extends TestCase { /** A quarter. */ private Quarter q1Y1900; /** A quarter. */ private Quarter q2Y1900; /** A quarter. */ private Quarter q3Y9999; /** A quarter. */ private Quarter q4Y9999; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(QuarterTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public QuarterTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.q1Y1900 = new Quarter(1, 1900); this.q2Y1900 = new Quarter(2, 1900); this.q3Y9999 = new Quarter(3, 9999); this.q4Y9999 = new Quarter(4, 9999); } /** * Check that a Quarter instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Quarter quarter = new Quarter(); assertTrue(quarter.equals(quarter)); } /** * Tests the equals method. */ public void testEquals() { Quarter q1 = new Quarter(2, 2002); Quarter q2 = new Quarter(2, 2002); assertTrue(q1.equals(q2)); } /** * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L). Use this * to check the quarter constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Quarter q1 = new Quarter(new Date(1017619199999L), zone); Quarter q2 = new Quarter(new Date(1017619200000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017619199999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017619200000L, q2.getFirstMillisecond(zone)); } /** * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L). Use * this to check the quarter constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul"); Quarter q1 = new Quarter(new Date(1017608399999L), zone); Quarter q2 = new Quarter(new Date(1017608400000L), zone); assertEquals(1, q1.getQuarter()); assertEquals(1017608399999L, q1.getLastMillisecond(zone)); assertEquals(2, q2.getQuarter()); assertEquals(1017608400000L, q2.getFirstMillisecond(zone)); } /** * Set up a quarter equal to Q1 1900. Request the previous quarter, it * should be null. */ public void testQ1Y1900Previous() { Quarter previous = (Quarter) this.q1Y1900.previous(); assertNull(previous); } /** * Set up a quarter equal to Q1 1900. Request the next quarter, it should * be Q2 1900. */ public void testQ1Y1900Next() { Quarter next = (Quarter) this.q1Y1900.next(); assertEquals(this.q2Y1900, next); } /** * Set up a quarter equal to Q4 9999. Request the previous quarter, it * should be Q3 9999. */ public void testQ4Y9999Previous() { Quarter previous = (Quarter) this.q4Y9999.previous(); assertEquals(this.q3Y9999, previous); } /** * Set up a quarter equal to Q4 9999. Request the next quarter, it should * be null. */ public void testQ4Y9999Next() { Quarter next = (Quarter) this.q4Y9999.next(); assertNull(next); } /** * Test the string parsing code... */ public void testParseQuarter() { Quarter quarter = null; // test 1... try { quarter = Quarter.parseQuarter("Q1-2000"); } catch (TimePeriodFormatException e) { quarter = new Quarter(1, 1900); } assertEquals(1, quarter.getQuarter()); assertEquals(2000, quarter.getYear().getYear()); // test 2... try { quarter = Quarter.parseQuarter("2001-Q2"); } catch (TimePeriodFormatException e) { quarter = new Quarter(1, 1900); } assertEquals(2, quarter.getQuarter()); assertEquals(2001, quarter.getYear().getYear()); // test 3... try { quarter = Quarter.parseQuarter("Q3, 2002"); } catch (TimePeriodFormatException e) { quarter = new Quarter(1, 1900); } assertEquals(3, quarter.getQuarter()); assertEquals(2002, quarter.getYear().getYear()); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Quarter q1 = new Quarter(4, 1999); Quarter q2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(q1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); q2 = (Quarter) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(q1, q2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Quarter q1 = new Quarter(2, 2003); Quarter q2 = new Quarter(2, 2003); assertTrue(q1.equals(q2)); int h1 = q1.hashCode(); int h2 = q2.hashCode(); assertEquals(h1, h2); } /** * The {@link Quarter} class is immutable, so should not be * {@link Cloneable}. */ public void testNotCloneable() { Quarter q = new Quarter(2, 2003); assertFalse(q instanceof Cloneable); } /** * Some tests for the constructor with (int, int) arguments. Covers bug * report 1377239. */ public void testConstructor() { boolean pass = false; try { /*Quarter q =*/ new Quarter(0, 2005); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { /*Quarter q =*/ new Quarter(5, 2005); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Quarter q = new Quarter(3, 1970); assertEquals(15634800000L, q.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Quarter q = new Quarter(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623347200000L, q.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { q.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Quarter q = new Quarter(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, q.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { q.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Quarter q = new Quarter(3, 1970); assertEquals(23583599999L, q.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Quarter q = new Quarter(2, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-615488400001L, q.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { q.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Quarter q = new Quarter(3, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1001894399999L, q.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { q.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Quarter q = new Quarter(1, 2000); assertEquals(8001L, q.getSerialIndex()); q = new Quarter(1, 1900); assertEquals(7601L, q.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Quarter q = new Quarter(1, 2000); q = (Quarter) q.next(); assertEquals(new Year(2000), q.getYear()); assertEquals(2, q.getQuarter()); q = new Quarter(4, 9999); assertNull(q.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JULY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Quarter q = new Quarter(3, 2006); assertEquals(cal.getTime(), q.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.MARCH, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Quarter q = new Quarter(1, 2006); assertEquals(cal.getTime(), q.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/SecondTests.java0000644000175000017500000002676311173030414027311 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * SecondTests.java * ---------------- * (C) Copyright 2002-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jan-2002 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Oct-2003 : Added serialization test (DG); * 11-Jan-2005 : Added test for non-clonability (DG); * 06-Oct-2006 : Added some new tests (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.Hour; import org.jfree.data.time.Minute; import org.jfree.data.time.Second; import org.jfree.date.MonthConstants; /** * Tests for the {@link Second} class. */ public class SecondTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SecondTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SecondTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Test that a Second instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Second second = new Second(); assertTrue(second.equals(second)); } /** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Second second1 = new Second(34, minute1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); Second second2 = new Second(34, minute2); assertTrue(second1.equals(second2)); } /** * In GMT, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016729759000L). * Use this to check the Second constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Locale locale = Locale.getDefault(); // locale shouldn't matter here Second s1 = new Second(new Date(1016729758999L), zone, locale); Second s2 = new Second(new Date(1016729759000L), zone, locale); assertEquals(58, s1.getSecond()); assertEquals(1016729758999L, s1.getLastMillisecond(zone)); assertEquals(59, s2.getSecond()); assertEquals(1016729759000L, s2.getFirstMillisecond(zone)); } /** * In Chicago, the 4.55:59pm on 21 Mar 2002 is * java.util.Date(1016751359000L). Use this to check the Second constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("America/Chicago"); Locale locale = Locale.getDefault(); // locale shouldn't matter here Second s1 = new Second(new Date(1016751358999L), zone, locale); Second s2 = new Second(new Date(1016751359000L), zone, locale); assertEquals(58, s1.getSecond()); assertEquals(1016751358999L, s1.getLastMillisecond(zone)); assertEquals(59, s2.getSecond()); assertEquals(1016751359000L, s2.getFirstMillisecond(zone)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Second s1 = new Second(); Second s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); s2 = (Second) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Second s1 = new Second(13, 45, 5, 1, 2, 2003); Second s2 = new Second(13, 45, 5, 1, 2, 2003); assertTrue(s1.equals(s2)); int h1 = s1.hashCode(); int h2 = s2.hashCode(); assertEquals(h1, h2); } /** * The {@link Second} class is immutable, so should not be * {@link Cloneable}. */ public void testNotCloneable() { Second s = new Second(13, 45, 5, 1, 2, 2003); assertFalse(s instanceof Cloneable); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Second s = new Second(15, 43, 15, 1, 4, 2006); assertEquals(1143902595000L, s.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Second s = new Second(50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623289610000L, s.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Second s = new Second(55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455000L, s.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Second s = new Second(1, 1, 1, 1, 1, 1970); assertEquals(61999L, s.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Second s = new Second(55, 1, 2, 7, 7, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-614962684001L, s.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { s.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Second s = new Second(50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550999L, s.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Second s = new Second(1, 1, 1, 1, 1, 2000); assertEquals(3155850061L, s.getSerialIndex()); s = new Second(1, 1, 1, 1, 1, 1900); assertEquals(176461L, s.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Second s = new Second(55, 30, 1, 12, 12, 2000); s = (Second) s.next(); assertEquals(2000, s.getMinute().getHour().getYear()); assertEquals(12, s.getMinute().getHour().getMonth()); assertEquals(12, s.getMinute().getHour().getDayOfMonth()); assertEquals(1, s.getMinute().getHour().getHour()); assertEquals(30, s.getMinute().getMinute()); assertEquals(56, s.getSecond()); s = new Second(59, 59, 23, 31, 12, 9999); assertNull(s.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 0); Second s = new Second(55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), s.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 999); Second s = new Second(55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), s.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/SimpleTimePeriodTests.java0000644000175000017500000001573411173030414031305 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * SimpleTimePeriodTests.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (DG); * 21-Oct-2003 : Added hashCode() test (DG); * 02-Jun-2008 : Added a test for immutability (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.SimpleTimePeriod; /** * Tests for the {@link SimpleTimePeriod} class. */ public class SimpleTimePeriodTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(SimpleTimePeriodTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public SimpleTimePeriodTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Check that an instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { SimpleTimePeriod p = new SimpleTimePeriod(new Date(1000L), new Date(1001L)); assertTrue(p.equals(p)); } /** * Test the equals() method. */ public void testEquals() { SimpleTimePeriod p1 = new SimpleTimePeriod(new Date(1000L), new Date(1004L)); SimpleTimePeriod p2 = new SimpleTimePeriod(new Date(1000L), new Date(1004L)); assertTrue(p1.equals(p2)); assertTrue(p2.equals(p1)); p1 = new SimpleTimePeriod(new Date(1002L), new Date(1004L)); assertFalse(p1.equals(p2)); p2 = new SimpleTimePeriod(new Date(1002L), new Date(1004L)); assertTrue(p1.equals(p2)); p1 = new SimpleTimePeriod(new Date(1002L), new Date(1003L)); assertFalse(p1.equals(p2)); p2 = new SimpleTimePeriod(new Date(1002L), new Date(1003L)); assertTrue(p1.equals(p2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { SimpleTimePeriod p1 = new SimpleTimePeriod(new Date(1000L), new Date(1001L)); SimpleTimePeriod p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (SimpleTimePeriod) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), new Date(20L)); SimpleTimePeriod s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertTrue(s1.equals(s2)); int h1 = s1.hashCode(); int h2 = s2.hashCode(); assertEquals(h1, h2); } /** * This class is immutable, so it should not implement Cloneable. */ public void testClone() { SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), new Date(20)); assertFalse(s1 instanceof Cloneable); } /** * Some simple checks for immutability. */ public void testImmutable() { SimpleTimePeriod p1 = new SimpleTimePeriod(new Date(10L), new Date(20L)); SimpleTimePeriod p2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(p1, p2); p1.getStart().setTime(11L); assertEquals(p1, p2); Date d1 = new Date(10L); Date d2 = new Date(20L); p1 = new SimpleTimePeriod(d1, d2); d1.setTime(11L); assertEquals(new Date(10L), p1.getStart()); } /** * Some checks for the compareTo() method. */ public void testCompareTo() { SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), new Date(20L)); SimpleTimePeriod s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(0, s1.compareTo(s2)); s1 = new SimpleTimePeriod(new Date(9L), new Date(21L)); s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(-1, s1.compareTo(s2)); s1 = new SimpleTimePeriod(new Date(11L), new Date(19L)); s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(1, s1.compareTo(s2)); s1 = new SimpleTimePeriod(new Date(9L), new Date(19L)); s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(-1, s1.compareTo(s2)); s1 = new SimpleTimePeriod(new Date(11L), new Date(21)); s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(1, s1.compareTo(s2)); s1 = new SimpleTimePeriod(new Date(10L), new Date(18)); s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(-1, s1.compareTo(s2)); s1 = new SimpleTimePeriod(new Date(10L), new Date(22)); s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); assertEquals(1, s1.compareTo(s2)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimePeriodAnchorTests.java0000644000175000017500000000661111173030414031260 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * TimePeriodAnchorTests.java * -------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Mar-2004 : Version 1 (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.TimePeriodAnchor; /** * Tests for the {@link TimePeriodAnchor} class. */ public class TimePeriodAnchorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimePeriodAnchorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimePeriodAnchorTests(String name) { super(name); } /** * Test the equals() method. */ public void testEquals() { assertTrue(TimePeriodAnchor.START.equals(TimePeriodAnchor.START)); assertTrue(TimePeriodAnchor.MIDDLE.equals(TimePeriodAnchor.MIDDLE)); assertTrue(TimePeriodAnchor.END.equals(TimePeriodAnchor.END)); } /** * Serialize an instance, restore it, and check for identity. */ public void testSerialization() { TimePeriodAnchor a1 = TimePeriodAnchor.START; TimePeriodAnchor a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); a2 = (TimePeriodAnchor) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertTrue(a1 == a2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimePeriodValueTests.java0000644000175000017500000000737411173030414031131 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TimePeriodValueTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jul-2003 : Version 1 (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.TimePeriodValue; /** * Tests for the {@link TimePeriodValue} class. */ public class TimePeriodValueTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimePeriodValueTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimePeriodValueTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Test that an instance is equal to itself. */ public void testEqualsSelf() { TimePeriodValue tpv = new TimePeriodValue(new Day(), 55.75); assertTrue(tpv.equals(tpv)); } /** * Tests the equals() method. */ public void testEquals() { TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); TimePeriodValue tpv2 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); assertTrue(tpv1.equals(tpv2)); assertTrue(tpv2.equals(tpv1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); TimePeriodValue tpv2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(tpv1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); tpv2 = (TimePeriodValue) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(tpv1, tpv2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java0000644000175000017500000002114211173030414033315 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * TimePeriodValuesCollectionTests.java * ------------------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Mar-2005 : Version 1 (DG); * 08-Mar-2007 : Added testGetSeries() (DG); * 11-Jun-2007 : Added tests for getDomainBounds() (DG); * 10-Jul-2007 : Fixed compile errors (DG); * 07-Apr-2008 : Added more checks to * testGetDomainBoundsWithInterval() (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; import org.jfree.data.time.Day; import org.jfree.data.time.SimpleTimePeriod; import org.jfree.data.time.TimePeriodAnchor; import org.jfree.data.time.TimePeriodValues; import org.jfree.data.time.TimePeriodValuesCollection; /** * Some tests for the {@link TimePeriodValuesCollection} class. */ public class TimePeriodValuesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimePeriodValuesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimePeriodValuesCollectionTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * A test for bug report 1161340. I wasn't able to reproduce the problem * with this test. */ public void test1161340() { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); TimePeriodValues v1 = new TimePeriodValues("V1"); v1.add(new Day(11, 3, 2005), 1.2); v1.add(new Day(12, 3, 2005), 3.4); dataset.addSeries(v1); assertEquals(1, dataset.getSeriesCount()); dataset.removeSeries(v1); assertEquals(0, dataset.getSeriesCount()); TimePeriodValues v2 = new TimePeriodValues("V2"); v1.add(new Day(5, 3, 2005), 1.2); v1.add(new Day(6, 3, 2005), 3.4); dataset.addSeries(v2); assertEquals(1, dataset.getSeriesCount()); } /** * Tests the equals() method. */ public void testEquals() { TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); TimePeriodValuesCollection c2 = new TimePeriodValuesCollection(); assertTrue(c1.equals(c2)); c1.setDomainIsPointsInTime(!c1.getDomainIsPointsInTime()); assertFalse(c1.equals(c2)); c2.setDomainIsPointsInTime(c1.getDomainIsPointsInTime()); assertTrue(c1.equals(c2)); c1.setXPosition(TimePeriodAnchor.END); assertFalse(c1.equals(c2)); c2.setXPosition(TimePeriodAnchor.END); assertTrue(c1.equals(c2)); TimePeriodValues v1 = new TimePeriodValues("Test"); TimePeriodValues v2 = new TimePeriodValues("Test"); c1.addSeries(v1); assertFalse(c1.equals(c2)); c2.addSeries(v2); assertTrue(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); TimePeriodValuesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (TimePeriodValuesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Some basic checks for the getSeries() method. */ public void testGetSeries() { TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); TimePeriodValues s1 = new TimePeriodValues("Series 1"); c1.addSeries(s1); assertEquals("Series 1", c1.getSeries(0).getKey()); boolean pass = false; try { c1.getSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c1.getSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } private static final double EPSILON = 0.0000000001; /** * Some checks for the getDomainBounds() method. */ public void testGetDomainBoundsWithoutInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); dataset.setDomainIsPointsInTime(false); Range r = dataset.getDomainBounds(false); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(false); assertEquals(1500.0, r.getLowerBound(), EPSILON); assertEquals(1500.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(false); assertEquals(1500.0, r.getLowerBound(), EPSILON); assertEquals(2250.0, r.getUpperBound(), EPSILON); } /** * Some more checks for the getDomainBounds() method. * * @see #testGetDomainBoundsWithoutInterval() */ public void testGetDomainBoundsWithInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Range r = dataset.getDomainBounds(true); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(2000.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(3000.0, r.getUpperBound(), EPSILON); // add a third time period s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(7000.0, r.getUpperBound(), EPSILON); // add a fourth time period s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(7000.0, r.getUpperBound(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimePeriodValuesTests.java0000644000175000017500000003355211173030414031311 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * TimePeriodValueTests.java * ------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jul-2003 : Version 1 (DG); * 07-Apr-2008 : Added new tests for min/max-start/middle/end * index updates (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.general.SeriesException; import org.jfree.data.time.Day; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.SimpleTimePeriod; import org.jfree.data.time.TimePeriodValue; import org.jfree.data.time.TimePeriodValues; import org.jfree.data.time.Year; import org.jfree.date.MonthConstants; /** * A collection of test cases for the {@link TimePeriodValues} class. */ public class TimePeriodValuesTests extends TestCase { /** Series A. */ private TimePeriodValues seriesA; /** Series B. */ private TimePeriodValues seriesB; /** Series C. */ private TimePeriodValues seriesC; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimePeriodValuesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimePeriodValuesTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.seriesA = new TimePeriodValues("Series A"); try { this.seriesA.add(new Year(2000), new Integer(102000)); this.seriesA.add(new Year(2001), new Integer(102001)); this.seriesA.add(new Year(2002), new Integer(102002)); this.seriesA.add(new Year(2003), new Integer(102003)); this.seriesA.add(new Year(2004), new Integer(102004)); this.seriesA.add(new Year(2005), new Integer(102005)); } catch (SeriesException e) { System.err.println("Problem creating series."); } this.seriesB = new TimePeriodValues("Series B"); try { this.seriesB.add(new Year(2006), new Integer(202006)); this.seriesB.add(new Year(2007), new Integer(202007)); this.seriesB.add(new Year(2008), new Integer(202008)); } catch (SeriesException e) { System.err.println("Problem creating series."); } this.seriesC = new TimePeriodValues("Series C"); try { this.seriesC.add(new Year(1999), new Integer(301999)); this.seriesC.add(new Year(2000), new Integer(302000)); this.seriesC.add(new Year(2002), new Integer(302002)); } catch (SeriesException e) { System.err.println("Problem creating series."); } } /** * Set up a quarter equal to Q1 1900. Request the previous quarter, it * should be null. */ public void testClone() { TimePeriodValues series = new TimePeriodValues("Test Series"); RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002); try { series.add(jan1st2002, new Integer(42)); } catch (SeriesException e) { System.err.println("Problem adding to collection."); } TimePeriodValues clone = null; try { clone = (TimePeriodValues) series.clone(); clone.setKey("Clone Series"); try { clone.update(0, new Integer(10)); } catch (SeriesException e) { System.err.println("Problem updating series."); } } catch (CloneNotSupportedException e) { assertTrue(false); } int seriesValue = series.getValue(0).intValue(); int cloneValue = clone.getValue(0).intValue(); assertEquals(42, seriesValue); assertEquals(10, cloneValue); assertEquals("Test Series", series.getKey()); assertEquals("Clone Series", clone.getKey()); } /** * Add a value to series A for 1999. It should be added at index 0. */ public void testAddValue() { TimePeriodValues tpvs = new TimePeriodValues("Test"); try { tpvs.add(new Year(1999), new Integer(1)); } catch (SeriesException e) { System.err.println("Problem adding to series."); } int value = tpvs.getValue(0).intValue(); assertEquals(1, value); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimePeriodValues s1 = new TimePeriodValues("A test"); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); TimePeriodValues s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (TimePeriodValues) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(s1.equals(s2)); } /** * Tests the equals method. */ public void testEquals() { TimePeriodValues s1 = new TimePeriodValues("Time Series 1"); TimePeriodValues s2 = new TimePeriodValues("Time Series 2"); boolean b1 = s1.equals(s2); assertFalse("b1", b1); s2.setKey("Time Series 1"); boolean b2 = s1.equals(s2); assertTrue("b2", b2); // domain description s1.setDomainDescription("XYZ"); assertFalse(s1.equals(s2)); s2.setDomainDescription("XYZ"); assertTrue(s1.equals(s2)); // domain description - null s1.setDomainDescription(null); assertFalse(s1.equals(s2)); s2.setDomainDescription(null); assertTrue(s1.equals(s2)); // range description s1.setRangeDescription("XYZ"); assertFalse(s1.equals(s2)); s2.setRangeDescription("XYZ"); assertTrue(s1.equals(s2)); // range description - null s1.setRangeDescription(null); assertFalse(s1.equals(s2)); s2.setRangeDescription(null); assertTrue(s1.equals(s2)); RegularTimePeriod p1 = new Day(); RegularTimePeriod p2 = p1.next(); s1.add(p1, 100.0); s1.add(p2, 200.0); boolean b3 = s1.equals(s2); assertFalse("b3", b3); s2.add(p1, 100.0); s2.add(p2, 200.0); boolean b4 = s1.equals(s2); assertTrue("b4", b4); } /** * A test for bug report 1161329. */ public void test1161329() { TimePeriodValues tpv = new TimePeriodValues("Test"); RegularTimePeriod t = new Day(); tpv.add(t, 1.0); t = t.next(); tpv.add(t, 2.0); tpv.delete(0, 1); assertEquals(0, tpv.getItemCount()); tpv.add(t, 2.0); assertEquals(1, tpv.getItemCount()); } static final double EPSILON = 0.0000000001; /** * Some checks for the add() methods. */ public void testAdd() { TimePeriodValues tpv = new TimePeriodValues("Test"); MySeriesChangeListener listener = new MySeriesChangeListener(); tpv.addChangeListener(listener); tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), new Date(3L)), 99.0)); assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON); assertEquals(tpv, listener.getLastEvent().getSource()); // a null item should throw an IllegalArgumentException boolean pass = false; try { tpv.add((TimePeriodValue) null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some tests for the getMinStartIndex() method. */ public void testGetMinStartIndex() { TimePeriodValues s = new TimePeriodValues("Test"); assertEquals(-1, s.getMinStartIndex()); s.add(new SimpleTimePeriod(100L, 200L), 1.0); assertEquals(0, s.getMinStartIndex()); s.add(new SimpleTimePeriod(300L, 400L), 2.0); assertEquals(0, s.getMinStartIndex()); s.add(new SimpleTimePeriod(0L, 50L), 3.0); assertEquals(2, s.getMinStartIndex()); } /** * Some tests for the getMaxStartIndex() method. */ public void testGetMaxStartIndex() { TimePeriodValues s = new TimePeriodValues("Test"); assertEquals(-1, s.getMaxStartIndex()); s.add(new SimpleTimePeriod(100L, 200L), 1.0); assertEquals(0, s.getMaxStartIndex()); s.add(new SimpleTimePeriod(300L, 400L), 2.0); assertEquals(1, s.getMaxStartIndex()); s.add(new SimpleTimePeriod(0L, 50L), 3.0); assertEquals(1, s.getMaxStartIndex()); } /** * Some tests for the getMinMiddleIndex() method. */ public void testGetMinMiddleIndex() { TimePeriodValues s = new TimePeriodValues("Test"); assertEquals(-1, s.getMinMiddleIndex()); s.add(new SimpleTimePeriod(100L, 200L), 1.0); assertEquals(0, s.getMinMiddleIndex()); s.add(new SimpleTimePeriod(300L, 400L), 2.0); assertEquals(0, s.getMinMiddleIndex()); s.add(new SimpleTimePeriod(0L, 50L), 3.0); assertEquals(2, s.getMinMiddleIndex()); } /** * Some tests for the getMaxMiddleIndex() method. */ public void testGetMaxMiddleIndex() { TimePeriodValues s = new TimePeriodValues("Test"); assertEquals(-1, s.getMaxMiddleIndex()); s.add(new SimpleTimePeriod(100L, 200L), 1.0); assertEquals(0, s.getMaxMiddleIndex()); s.add(new SimpleTimePeriod(300L, 400L), 2.0); assertEquals(1, s.getMaxMiddleIndex()); s.add(new SimpleTimePeriod(0L, 50L), 3.0); assertEquals(1, s.getMaxMiddleIndex()); s.add(new SimpleTimePeriod(150L, 200L), 4.0); assertEquals(1, s.getMaxMiddleIndex()); } /** * Some tests for the getMinEndIndex() method. */ public void getMinEndIndex() { TimePeriodValues s = new TimePeriodValues("Test"); assertEquals(-1, s.getMinEndIndex()); s.add(new SimpleTimePeriod(100L, 200L), 1.0); assertEquals(0, s.getMinEndIndex()); s.add(new SimpleTimePeriod(300L, 400L), 2.0); assertEquals(0, s.getMinEndIndex()); s.add(new SimpleTimePeriod(0L, 50L), 3.0); assertEquals(2, s.getMinEndIndex()); } /** * Some tests for the getMaxEndIndex() method. */ public void getMaxEndIndex() { TimePeriodValues s = new TimePeriodValues("Test"); assertEquals(-1, s.getMaxEndIndex()); s.add(new SimpleTimePeriod(100L, 200L), 1.0); assertEquals(0, s.getMaxEndIndex()); s.add(new SimpleTimePeriod(300L, 400L), 2.0); assertEquals(1, s.getMaxEndIndex()); s.add(new SimpleTimePeriod(0L, 50L), 3.0); assertEquals(1, s.getMaxEndIndex()); } /** * A listener used for detecting series change events. */ static class MySeriesChangeListener implements SeriesChangeListener { SeriesChangeEvent lastEvent; /** * Creates a new listener. */ public MySeriesChangeListener() { this.lastEvent = null; } /** * Returns the last event. * * @return The last event (possibly null). */ public SeriesChangeEvent getLastEvent() { return this.lastEvent; } /** * Clears the last event (sets it to null). */ public void clearLastEvent() { this.lastEvent = null; } /** * Callback method for series change events. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.lastEvent = event; } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimeSeriesCollectionTests.java0000644000175000017500000002267511173030414032161 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * TimeSeriesCollectionTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-May-2003 : Version 1 (DG); * 04-Dec-2003 : Added a test for the getSurroundingItems() method (DG); * 08-May-2007 : Added testIndexOf() method (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimePeriodAnchor; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; /** * A collection of test cases for the {@link TimeSeriesCollection} class. */ public class TimeSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimeSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimeSeriesCollectionTests(String name) { super(name); } /** * Some tests for the equals() method. */ public void testEquals() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeriesCollection c2 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); // newly created collections should be equal boolean b1 = c1.equals(c2); assertTrue("b1", b1); // add series to collection 1, should be not equal c1.addSeries(s1); c1.addSeries(s2); boolean b2 = c1.equals(c2); assertFalse("b2", b2); // now add the same series to collection 2 to make them equal again... c2.addSeries(s1); c2.addSeries(s2); boolean b3 = c1.equals(c2); assertTrue("b3", b3); // now remove series 2 from collection 2 c2.removeSeries(s2); boolean b4 = c1.equals(c2); assertFalse("b4", b4); // now remove series 2 from collection 1 to make them equal again c1.removeSeries(s2); boolean b5 = c1.equals(c2); assertTrue("b5", b5); } /** * Tests the remove series method. */ public void testRemoveSeries() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); TimeSeries s3 = new TimeSeries("Series 3"); TimeSeries s4 = new TimeSeries("Series 4"); c1.addSeries(s1); c1.addSeries(s2); c1.addSeries(s3); c1.addSeries(s4); c1.removeSeries(s3); TimeSeries s = c1.getSeries(2); boolean b1 = s.equals(s4); assertTrue(b1); } /** * Test the getSurroundingItems() method to ensure it is returning the * values we expect. */ public void testGetSurroundingItems() { TimeSeries series = new TimeSeries("Series 1", Day.class); TimeSeriesCollection collection = new TimeSeriesCollection(series); collection.setXPosition(TimePeriodAnchor.MIDDLE); // for a series with no data, we expect {-1, -1}... int[] result = collection.getSurroundingItems(0, 1000L); assertTrue(result[0] == -1); assertTrue(result[1] == -1); // now test with a single value in the series... Day today = new Day(); long start1 = today.getFirstMillisecond(); long middle1 = today.getMiddleMillisecond(); long end1 = today.getLastMillisecond(); series.add(today, 99.9); result = collection.getSurroundingItems(0, start1); assertTrue(result[0] == -1); assertTrue(result[1] == 0); result = collection.getSurroundingItems(0, middle1); assertTrue(result[0] == 0); assertTrue(result[1] == 0); result = collection.getSurroundingItems(0, end1); assertTrue(result[0] == 0); assertTrue(result[1] == -1); // now add a second value to the series... Day tomorrow = (Day) today.next(); long start2 = tomorrow.getFirstMillisecond(); long middle2 = tomorrow.getMiddleMillisecond(); long end2 = tomorrow.getLastMillisecond(); series.add(tomorrow, 199.9); result = collection.getSurroundingItems(0, start2); assertTrue(result[0] == 0); assertTrue(result[1] == 1); result = collection.getSurroundingItems(0, middle2); assertTrue(result[0] == 1); assertTrue(result[1] == 1); result = collection.getSurroundingItems(0, end2); assertTrue(result[0] == 1); assertTrue(result[1] == -1); // now add a third value to the series... Day yesterday = (Day) today.previous(); long start3 = yesterday.getFirstMillisecond(); long middle3 = yesterday.getMiddleMillisecond(); long end3 = yesterday.getLastMillisecond(); series.add(yesterday, 1.23); result = collection.getSurroundingItems(0, start3); assertTrue(result[0] == -1); assertTrue(result[1] == 0); result = collection.getSurroundingItems(0, middle3); assertTrue(result[0] == 0); assertTrue(result[1] == 0); result = collection.getSurroundingItems(0, end3); assertTrue(result[0] == 0); assertTrue(result[1] == 1); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimeSeriesCollection c1 = new TimeSeriesCollection(createSeries()); TimeSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); c2 = (TimeSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(c1, c2); } /** * Creates a time series for testing. * * @return A time series. */ private TimeSeries createSeries() { RegularTimePeriod t = new Day(); TimeSeries series = new TimeSeries("Test"); series.add(t, 1.0); t = t.next(); series.add(t, 2.0); t = t.next(); series.add(t, null); t = t.next(); series.add(t, 4.0); return series; } /** * A test for bug report 1170825. */ public void test1170825() { TimeSeries s1 = new TimeSeries("Series1"); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1); try { /* TimeSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } } /** * Some tests for the indexOf() method. */ public void testIndexOf() { TimeSeries s1 = new TimeSeries("S1"); TimeSeries s2 = new TimeSeries("S2"); TimeSeriesCollection dataset = new TimeSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); TimeSeries s2b = new TimeSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimeSeriesDataItemTests.java0000644000175000017500000001015511173030414031544 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * TimeSeriesDataItemTests.java * ---------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Mar-2003 : Version 1 (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.TimeSeriesDataItem; /** * Tests for the {@link TimeSeriesDataItem} class. */ public class TimeSeriesDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimeSeriesDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimeSeriesDataItemTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Test that an instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { TimeSeriesDataItem item = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); assertTrue(item.equals(item)); } /** * Test the equals() method. */ public void testEquals() { TimeSeriesDataItem item1 = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); TimeSeriesDataItem item2 = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); item1.setValue(new Integer(5)); assertFalse(item1.equals(item2)); item2.setValue(new Integer(5)); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimeSeriesDataItem item1 = new TimeSeriesDataItem( new Day(23, 9, 2001), 99.7 ); TimeSeriesDataItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); item2 = (TimeSeriesDataItem) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(item1, item2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimeSeriesTests.java0000644000175000017500000006757011173030414030150 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * TimeSeriesTests.java * -------------------- * (C) Copyright 2001-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Nov-2001 : Version 1 (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 15-Oct-2003 : Added test for setMaximumItemCount method (DG); * 23-Aug-2004 : Added test that highlights a bug where the addOrUpdate() * method can lead to more than maximumItemCount items in the * dataset (DG); * 24-May-2006 : Added new tests (DG); * 31-Oct-2007 : New hashCode() test (DG); * 21-Nov-2007 : Added testBug1832432() and testClone2() (DG); * 10-Jan-2008 : Added testBug1864222() (DG); * 13-Jan-2009 : Added testEquals3() and testRemoveAgedItems3() (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.general.SeriesException; import org.jfree.data.time.Day; import org.jfree.data.time.FixedMillisecond; import org.jfree.data.time.Month; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesDataItem; import org.jfree.data.time.Year; import org.jfree.date.MonthConstants; /** * A collection of test cases for the {@link TimeSeries} class. */ public class TimeSeriesTests extends TestCase implements SeriesChangeListener { /** A time series. */ private TimeSeries seriesA; /** A time series. */ private TimeSeries seriesB; /** A time series. */ private TimeSeries seriesC; /** A flag that indicates whether or not a change event was fired. */ private boolean gotSeriesChangeEvent = false; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimeSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimeSeriesTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.seriesA = new TimeSeries("Series A", Year.class); try { this.seriesA.add(new Year(2000), new Integer(102000)); this.seriesA.add(new Year(2001), new Integer(102001)); this.seriesA.add(new Year(2002), new Integer(102002)); this.seriesA.add(new Year(2003), new Integer(102003)); this.seriesA.add(new Year(2004), new Integer(102004)); this.seriesA.add(new Year(2005), new Integer(102005)); } catch (SeriesException e) { System.err.println("Problem creating series."); } this.seriesB = new TimeSeries("Series B", Year.class); try { this.seriesB.add(new Year(2006), new Integer(202006)); this.seriesB.add(new Year(2007), new Integer(202007)); this.seriesB.add(new Year(2008), new Integer(202008)); } catch (SeriesException e) { System.err.println("Problem creating series."); } this.seriesC = new TimeSeries("Series C", Year.class); try { this.seriesC.add(new Year(1999), new Integer(301999)); this.seriesC.add(new Year(2000), new Integer(302000)); this.seriesC.add(new Year(2002), new Integer(302002)); } catch (SeriesException e) { System.err.println("Problem creating series."); } } /** * Sets the flag to indicate that a {@link SeriesChangeEvent} has been * received. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.gotSeriesChangeEvent = true; } /** * Check that cloning works. */ public void testClone() { TimeSeries series = new TimeSeries("Test Series"); RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002); try { series.add(jan1st2002, new Integer(42)); } catch (SeriesException e) { System.err.println("Problem adding to series."); } TimeSeries clone = null; try { clone = (TimeSeries) series.clone(); clone.setKey("Clone Series"); try { clone.update(jan1st2002, new Integer(10)); } catch (SeriesException e) { e.printStackTrace(); } } catch (CloneNotSupportedException e) { assertTrue(false); } int seriesValue = series.getValue(jan1st2002).intValue(); int cloneValue = Integer.MAX_VALUE; if (clone != null) { cloneValue = clone.getValue(jan1st2002).intValue(); } assertEquals(42, seriesValue); assertEquals(10, cloneValue); assertEquals("Test Series", series.getKey()); if (clone != null) { assertEquals("Clone Series", clone.getKey()); } else { assertTrue(false); } } /** * Another test of the clone() method. */ public void testClone2() { TimeSeries s1 = new TimeSeries("S1", Year.class); s1.add(new Year(2007), 100.0); s1.add(new Year(2008), null); s1.add(new Year(2009), 200.0); TimeSeries s2 = null; try { s2 = (TimeSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1.equals(s2)); // check independence s2.addOrUpdate(new Year(2009), 300.0); assertFalse(s1.equals(s2)); s1.addOrUpdate(new Year(2009), 300.0); assertTrue(s1.equals(s2)); } /** * Add a value to series A for 1999. It should be added at index 0. */ public void testAddValue() { try { this.seriesA.add(new Year(1999), new Integer(1)); } catch (SeriesException e) { System.err.println("Problem adding to series."); } int value = this.seriesA.getValue(0).intValue(); assertEquals(1, value); } /** * Tests the retrieval of values. */ public void testGetValue() { Number value1 = this.seriesA.getValue(new Year(1999)); assertNull(value1); int value2 = this.seriesA.getValue(new Year(2000)).intValue(); assertEquals(102000, value2); } /** * Tests the deletion of values. */ public void testDelete() { this.seriesA.delete(0, 0); assertEquals(5, this.seriesA.getItemCount()); Number value = this.seriesA.getValue(new Year(2000)); assertNull(value); } /** * Basic tests for the delete() method. */ public void testDelete2() { TimeSeries s1 = new TimeSeries("Series", Year.class); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.addChangeListener(this); this.gotSeriesChangeEvent = false; s1.delete(new Year(2001)); assertTrue(this.gotSeriesChangeEvent); assertEquals(2, s1.getItemCount()); assertEquals(null, s1.getValue(new Year(2001))); // try deleting a time period that doesn't exist... this.gotSeriesChangeEvent = false; s1.delete(new Year(2006)); assertFalse(this.gotSeriesChangeEvent); // try deleting null try { s1.delete(null); fail("Expected IllegalArgumentException."); } catch (IllegalArgumentException e) { // expected } } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimeSeries s1 = new TimeSeries("A test", Year.class); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); TimeSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); s2 = (TimeSeries) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertTrue(s1.equals(s2)); } /** * Tests the equals method. */ public void testEquals() { TimeSeries s1 = new TimeSeries("Time Series 1"); TimeSeries s2 = new TimeSeries("Time Series 2"); boolean b1 = s1.equals(s2); assertFalse("b1", b1); s2.setKey("Time Series 1"); boolean b2 = s1.equals(s2); assertTrue("b2", b2); RegularTimePeriod p1 = new Day(); RegularTimePeriod p2 = p1.next(); s1.add(p1, 100.0); s1.add(p2, 200.0); boolean b3 = s1.equals(s2); assertFalse("b3", b3); s2.add(p1, 100.0); s2.add(p2, 200.0); boolean b4 = s1.equals(s2); assertTrue("b4", b4); s1.setMaximumItemCount(100); boolean b5 = s1.equals(s2); assertFalse("b5", b5); s2.setMaximumItemCount(100); boolean b6 = s1.equals(s2); assertTrue("b6", b6); s1.setMaximumItemAge(100); boolean b7 = s1.equals(s2); assertFalse("b7", b7); s2.setMaximumItemAge(100); boolean b8 = s1.equals(s2); assertTrue("b8", b8); } /** * Tests a specific bug report where null arguments in the constructor * cause the equals() method to fail. Fixed for 0.9.21. */ public void testEquals2() { TimeSeries s1 = new TimeSeries("Series", null, null, Day.class); TimeSeries s2 = new TimeSeries("Series", null, null, Day.class); assertTrue(s1.equals(s2)); } /** * Two classes with different period classes are NOT the same. */ public void testEquals3() { TimeSeries s1 = new TimeSeries("Series", Day.class); TimeSeries s2 = new TimeSeries("Series", Month.class); assertFalse(s1.equals(s2)); } /** * Some tests to ensure that the createCopy(RegularTimePeriod, * RegularTimePeriod) method is functioning correctly. */ public void testCreateCopy1() { TimeSeries series = new TimeSeries("Series", Month.class); series.add(new Month(MonthConstants.JANUARY, 2003), 45.0); series.add(new Month(MonthConstants.FEBRUARY, 2003), 55.0); series.add(new Month(MonthConstants.JUNE, 2003), 35.0); series.add(new Month(MonthConstants.NOVEMBER, 2003), 85.0); series.add(new Month(MonthConstants.DECEMBER, 2003), 75.0); try { // copy a range before the start of the series data... TimeSeries result1 = series.createCopy( new Month(MonthConstants.NOVEMBER, 2002), new Month(MonthConstants.DECEMBER, 2002)); assertEquals(0, result1.getItemCount()); // copy a range that includes only the first item in the series... TimeSeries result2 = series.createCopy( new Month(MonthConstants.NOVEMBER, 2002), new Month(MonthConstants.JANUARY, 2003)); assertEquals(1, result2.getItemCount()); // copy a range that begins before and ends in the middle of the // series... TimeSeries result3 = series.createCopy( new Month(MonthConstants.NOVEMBER, 2002), new Month(MonthConstants.APRIL, 2003)); assertEquals(2, result3.getItemCount()); TimeSeries result4 = series.createCopy( new Month(MonthConstants.NOVEMBER, 2002), new Month(MonthConstants.DECEMBER, 2003)); assertEquals(5, result4.getItemCount()); TimeSeries result5 = series.createCopy( new Month(MonthConstants.NOVEMBER, 2002), new Month(MonthConstants.MARCH, 2004)); assertEquals(5, result5.getItemCount()); TimeSeries result6 = series.createCopy( new Month(MonthConstants.JANUARY, 2003), new Month(MonthConstants.JANUARY, 2003)); assertEquals(1, result6.getItemCount()); TimeSeries result7 = series.createCopy( new Month(MonthConstants.JANUARY, 2003), new Month(MonthConstants.APRIL, 2003)); assertEquals(2, result7.getItemCount()); TimeSeries result8 = series.createCopy( new Month(MonthConstants.JANUARY, 2003), new Month(MonthConstants.DECEMBER, 2003)); assertEquals(5, result8.getItemCount()); TimeSeries result9 = series.createCopy( new Month(MonthConstants.JANUARY, 2003), new Month(MonthConstants.MARCH, 2004)); assertEquals(5, result9.getItemCount()); TimeSeries result10 = series.createCopy( new Month(MonthConstants.MAY, 2003), new Month(MonthConstants.DECEMBER, 2003)); assertEquals(3, result10.getItemCount()); TimeSeries result11 = series.createCopy( new Month(MonthConstants.MAY, 2003), new Month(MonthConstants.MARCH, 2004)); assertEquals(3, result11.getItemCount()); TimeSeries result12 = series.createCopy( new Month(MonthConstants.DECEMBER, 2003), new Month(MonthConstants.DECEMBER, 2003)); assertEquals(1, result12.getItemCount()); TimeSeries result13 = series.createCopy( new Month(MonthConstants.DECEMBER, 2003), new Month(MonthConstants.MARCH, 2004)); assertEquals(1, result13.getItemCount()); TimeSeries result14 = series.createCopy( new Month(MonthConstants.JANUARY, 2004), new Month(MonthConstants.MARCH, 2004)); assertEquals(0, result14.getItemCount()); } catch (CloneNotSupportedException e) { assertTrue(false); } } /** * Some tests to ensure that the createCopy(int, int) method is * functioning correctly. */ public void testCreateCopy2() { TimeSeries series = new TimeSeries("Series", Month.class); series.add(new Month(MonthConstants.JANUARY, 2003), 45.0); series.add(new Month(MonthConstants.FEBRUARY, 2003), 55.0); series.add(new Month(MonthConstants.JUNE, 2003), 35.0); series.add(new Month(MonthConstants.NOVEMBER, 2003), 85.0); series.add(new Month(MonthConstants.DECEMBER, 2003), 75.0); try { // copy just the first item... TimeSeries result1 = series.createCopy(0, 0); assertEquals(new Month(1, 2003), result1.getTimePeriod(0)); // copy the first two items... result1 = series.createCopy(0, 1); assertEquals(new Month(2, 2003), result1.getTimePeriod(1)); // copy the middle three items... result1 = series.createCopy(1, 3); assertEquals(new Month(2, 2003), result1.getTimePeriod(0)); assertEquals(new Month(11, 2003), result1.getTimePeriod(2)); // copy the last two items... result1 = series.createCopy(3, 4); assertEquals(new Month(11, 2003), result1.getTimePeriod(0)); assertEquals(new Month(12, 2003), result1.getTimePeriod(1)); // copy the last item... result1 = series.createCopy(4, 4); assertEquals(new Month(12, 2003), result1.getTimePeriod(0)); } catch (CloneNotSupportedException e) { assertTrue(false); } // check negative first argument boolean pass = false; try { /* TimeSeries result = */ series.createCopy(-1, 1); } catch (IllegalArgumentException e) { pass = true; } catch (CloneNotSupportedException e) { pass = false; } assertTrue(pass); // check second argument less than first argument pass = false; try { /* TimeSeries result = */ series.createCopy(1, 0); } catch (IllegalArgumentException e) { pass = true; } catch (CloneNotSupportedException e) { pass = false; } assertTrue(pass); TimeSeries series2 = new TimeSeries("Series 2"); try { TimeSeries series3 = series2.createCopy(99, 999); assertEquals(0, series3.getItemCount()); } catch (CloneNotSupportedException e) { assertTrue(false); } } /** * Test the setMaximumItemCount() method to ensure that it removes items * from the series if necessary. */ public void testSetMaximumItemCount() { TimeSeries s1 = new TimeSeries("S1", Year.class); s1.add(new Year(2000), 13.75); s1.add(new Year(2001), 11.90); s1.add(new Year(2002), null); s1.add(new Year(2005), 19.32); s1.add(new Year(2007), 16.89); assertTrue(s1.getItemCount() == 5); s1.setMaximumItemCount(3); assertTrue(s1.getItemCount() == 3); TimeSeriesDataItem item = s1.getDataItem(0); assertTrue(item.getPeriod().equals(new Year(2002))); } /** * Some checks for the addOrUpdate() method. */ public void testAddOrUpdate() { TimeSeries s1 = new TimeSeries("S1", Year.class); s1.setMaximumItemCount(2); s1.addOrUpdate(new Year(2000), 100.0); assertEquals(1, s1.getItemCount()); s1.addOrUpdate(new Year(2001), 101.0); assertEquals(2, s1.getItemCount()); s1.addOrUpdate(new Year(2001), 102.0); assertEquals(2, s1.getItemCount()); s1.addOrUpdate(new Year(2002), 103.0); assertEquals(2, s1.getItemCount()); } /** * A test for the bug report 1075255. */ public void testBug1075255() { TimeSeries ts = new TimeSeries("dummy", FixedMillisecond.class); ts.add(new FixedMillisecond(0L), 0.0); TimeSeries ts2 = new TimeSeries("dummy2", FixedMillisecond.class); ts2.add(new FixedMillisecond(0L), 1.0); try { ts.addAndOrUpdate(ts2); } catch (Exception e) { e.printStackTrace(); assertTrue(false); } assertEquals(1, ts.getItemCount()); } /** * A test for bug 1832432. */ public void testBug1832432() { TimeSeries s1 = new TimeSeries("Series"); TimeSeries s2 = null; try { s2 = (TimeSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); // test independence s1.add(new Day(1, 1, 2007), 100.0); assertFalse(s1.equals(s2)); } /** * Some checks for the getIndex() method. */ public void testGetIndex() { TimeSeries series = new TimeSeries("Series", Month.class); assertEquals(-1, series.getIndex(new Month(1, 2003))); series.add(new Month(1, 2003), 45.0); assertEquals(0, series.getIndex(new Month(1, 2003))); assertEquals(-1, series.getIndex(new Month(12, 2002))); assertEquals(-2, series.getIndex(new Month(2, 2003))); series.add(new Month(3, 2003), 55.0); assertEquals(-1, series.getIndex(new Month(12, 2002))); assertEquals(0, series.getIndex(new Month(1, 2003))); assertEquals(-2, series.getIndex(new Month(2, 2003))); assertEquals(1, series.getIndex(new Month(3, 2003))); assertEquals(-3, series.getIndex(new Month(4, 2003))); } /** * Some checks for the getDataItem(int) method. */ public void testGetDataItem1() { TimeSeries series = new TimeSeries("S", Year.class); // can't get anything yet...just an exception boolean pass = false; try { /*TimeSeriesDataItem item =*/ series.getDataItem(0); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); series.add(new Year(2006), 100.0); TimeSeriesDataItem item = series.getDataItem(0); assertEquals(new Year(2006), item.getPeriod()); pass = false; try { /*item = */series.getDataItem(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { /*item = */series.getDataItem(1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getDataItem(RegularTimePeriod) method. */ public void testGetDataItem2() { TimeSeries series = new TimeSeries("S", Year.class); assertNull(series.getDataItem(new Year(2006))); // try a null argument boolean pass = false; try { /* TimeSeriesDataItem item = */ series.getDataItem(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the removeAgedItems() method. */ public void testRemoveAgedItems() { TimeSeries series = new TimeSeries("Test Series", Year.class); series.addChangeListener(this); assertEquals(Long.MAX_VALUE, series.getMaximumItemAge()); assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount()); this.gotSeriesChangeEvent = false; // test empty series series.removeAgedItems(true); assertEquals(0, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); // test series with one item series.add(new Year(1999), 1.0); series.setMaximumItemAge(0); this.gotSeriesChangeEvent = false; series.removeAgedItems(true); assertEquals(1, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); // test series with two items series.setMaximumItemAge(10); series.add(new Year(2001), 2.0); this.gotSeriesChangeEvent = false; series.setMaximumItemAge(2); assertEquals(2, series.getItemCount()); assertEquals(0, series.getIndex(new Year(1999))); assertFalse(this.gotSeriesChangeEvent); series.setMaximumItemAge(1); assertEquals(1, series.getItemCount()); assertEquals(0, series.getIndex(new Year(2001))); assertTrue(this.gotSeriesChangeEvent); } /** * Some checks for the removeAgedItems(long, boolean) method. */ public void testRemoveAgedItems2() { long y2006 = 1157087372534L; // milliseconds somewhere in 2006 TimeSeries series = new TimeSeries("Test Series", Year.class); series.addChangeListener(this); assertEquals(Long.MAX_VALUE, series.getMaximumItemAge()); assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount()); this.gotSeriesChangeEvent = false; // test empty series series.removeAgedItems(y2006, true); assertEquals(0, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); // test a series with 1 item series.add(new Year(2004), 1.0); series.setMaximumItemAge(1); this.gotSeriesChangeEvent = false; series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true); assertEquals(1, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); series.removeAgedItems(y2006, true); assertEquals(0, series.getItemCount()); assertTrue(this.gotSeriesChangeEvent); // test a series with two items series.setMaximumItemAge(2); series.add(new Year(2003), 1.0); series.add(new Year(2005), 2.0); assertEquals(2, series.getItemCount()); this.gotSeriesChangeEvent = false; assertEquals(2, series.getItemCount()); series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true); assertEquals(2, series.getItemCount()); assertFalse(this.gotSeriesChangeEvent); series.removeAgedItems(y2006, true); assertEquals(1, series.getItemCount()); assertTrue(this.gotSeriesChangeEvent); } /** * Calling removeAgedItems() on an empty series should not throw any * exception. */ public void testRemoveAgedItems3() { TimeSeries s = new TimeSeries("Test"); boolean pass = true; try { s.removeAgedItems(0L, true); } catch (Exception e) { pass = false; } assertTrue(pass); } /** * Some simple checks for the hashCode() method. */ public void testHashCode() { TimeSeries s1 = new TimeSeries("Test"); TimeSeries s2 = new TimeSeries("Test"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(1, 1, 2007), 500.0); s2.add(new Day(1, 1, 2007), 500.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(2, 1, 2007), null); s2.add(new Day(2, 1, 2007), null); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(5, 1, 2007), 111.0); s2.add(new Day(5, 1, 2007), 111.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(new Day(9, 1, 2007), 1.0); s2.add(new Day(9, 1, 2007), 1.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); } /** * Test for bug report 1864222. */ public void testBug1864222() { TimeSeries s = new TimeSeries("S"); s.add(new Day(19, 8, 2005), 1); s.add(new Day(31, 1, 2006), 1); boolean pass = true; try { s.createCopy(new Day(1, 12, 2005), new Day(18, 1, 2006)); } catch (CloneNotSupportedException e) { pass = false; } assertTrue(pass); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/TimeTableXYDatasetTests.java0000644000175000017500000001444211173030414031522 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * TimeTableXYDatasetTests.java * ---------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Rob Eden; * * Changes * ------- * 15-Sep-2004 : Version 1 (DG); * 25-Jul-2007 : Added test for clear() method, by Rob Eden (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.TimeTableXYDataset; import org.jfree.data.time.Year; /** * A collection of test cases for the {@link TimeTableXYDataset} class. */ public class TimeTableXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TimeTableXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TimeTableXYDatasetTests(String name) { super(name); } private static final double DELTA = 0.0000000001; /** * Some checks for a simple dataset. */ public void testStandard() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 1.0, "Series 1"); assertEquals(d.getItemCount(), 1); assertEquals(d.getSeriesCount(), 1); d.add(new Year(2000), 2.0, "Series 2"); assertEquals(d.getItemCount(), 2); assertEquals(d.getSeriesCount(), 2); assertEquals(d.getYValue(0, 0), 1.0, DELTA); assertTrue(Double.isNaN(d.getYValue(0, 1))); assertTrue(Double.isNaN(d.getYValue(1, 0))); assertEquals(d.getYValue(1, 1), 2.0, DELTA); } /** * Some checks for the getTimePeriod() method. */ public void testGetTimePeriod() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 1.0, "Series 1"); d.add(new Year(1998), 2.0, "Series 1"); d.add(new Year(1996), 3.0, "Series 1"); assertEquals(d.getTimePeriod(0), new Year(1996)); assertEquals(d.getTimePeriod(1), new Year(1998)); assertEquals(d.getTimePeriod(2), new Year(1999)); } /** * Some checks for the equals() method. */ public void testEquals() { TimeTableXYDataset d1 = new TimeTableXYDataset(); TimeTableXYDataset d2 = new TimeTableXYDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.add(new Year(1999), 123.4, "S1"); assertFalse(d1.equals(d2)); d2.add(new Year(1999), 123.4, "S1"); assertTrue(d1.equals(d2)); d1.setDomainIsPointsInTime(!d1.getDomainIsPointsInTime()); assertFalse(d1.equals(d2)); d2.setDomainIsPointsInTime(!d2.getDomainIsPointsInTime()); assertTrue(d1.equals(d2)); d1 = new TimeTableXYDataset(TimeZone.getTimeZone("GMT")); d2 = new TimeTableXYDataset(TimeZone.getTimeZone( "America/Los_Angeles")); assertFalse(d1.equals(d2)); } /** * Some checks for cloning. */ public void testClone() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 25.0, "Series"); TimeTableXYDataset clone = null; try { clone = (TimeTableXYDataset) d.clone(); } catch (CloneNotSupportedException e) { assertTrue(false); } assertTrue(clone.equals(d)); // now test that the clone is independent of the original clone.add(new Year(2004), 1.2, "SS"); assertFalse(clone.equals(d)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { TimeTableXYDataset d1 = new TimeTableXYDataset(); d1.add(new Year(1999), 123.4, "S1"); TimeTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (TimeTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(d1.equals(d2)); } /** * Test clearing data. */ public void testClear() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 1.0, "Series 1"); assertEquals(d.getItemCount(), 1); assertEquals(d.getSeriesCount(), 1); d.add(new Year(2000), 2.0, "Series 2"); d.clear(); // Make sure there's nothing left assertEquals(0, d.getItemCount()); assertEquals(0, d.getSeriesCount()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/WeekTests.java0000644000175000017500000004264511173030414026766 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * WeekTests.java * -------------- * (C) Copyright 2002-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Apr-2002 : Version 1 (DG); * 26-Jun-2002 : Removed unnecessary imports (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 21-Oct-2003 : Added hashCode test (DG); * 06-Apr-2006 : Added testBug1448828() method (DG); * 01-Jun-2006 : Added testBug1498805() method (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * 28-Aug-2007 : Added test for constructor problem (DG); * 19-Dec-2007 : Set default locale for tests that are sensitive * to the locale (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Week; import org.jfree.data.time.Year; /** * Tests for the {@link Week} class. */ public class WeekTests extends TestCase { /** A week. */ private Week w1Y1900; /** A week. */ private Week w2Y1900; /** A week. */ private Week w51Y9999; /** A week. */ private Week w52Y9999; /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(WeekTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public WeekTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { this.w1Y1900 = new Week(1, 1900); this.w2Y1900 = new Week(2, 1900); this.w51Y9999 = new Week(51, 9999); this.w52Y9999 = new Week(52, 9999); } /** * Tests the equals method. */ public void testEquals() { Week w1 = new Week(1, 2002); Week w2 = new Week(1, 2002); assertTrue(w1.equals(w2)); assertTrue(w2.equals(w1)); w1 = new Week(2, 2002); assertFalse(w1.equals(w2)); w2 = new Week(2, 2002); assertTrue(w1.equals(w2)); w1 = new Week(2, 2003); assertFalse(w1.equals(w2)); w2 = new Week(2, 2003); assertTrue(w1.equals(w2)); } /** * Request the week before week 1, 1900: it should be null. */ public void testW1Y1900Previous() { Week previous = (Week) this.w1Y1900.previous(); assertNull(previous); } /** * Request the week after week 1, 1900: it should be week 2, 1900. */ public void testW1Y1900Next() { Week next = (Week) this.w1Y1900.next(); assertEquals(this.w2Y1900, next); } /** * Request the week before w52, 9999: it should be week 51, 9999. */ public void testW52Y9999Previous() { Week previous = (Week) this.w52Y9999.previous(); assertEquals(this.w51Y9999, previous); } /** * Request the week after w52, 9999: it should be null. */ public void testW52Y9999Next() { Week next = (Week) this.w52Y9999.next(); assertNull(next); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Week w1 = new Week(24, 1999); Week w2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(w1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); w2 = (Week) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(w1, w2); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Week w1 = new Week(2, 2003); Week w2 = new Week(2, 2003); assertTrue(w1.equals(w2)); int h1 = w1.hashCode(); int h2 = w2.hashCode(); assertEquals(h1, h2); } /** * The {@link Week} class is immutable, so should not be {@link Cloneable}. */ public void testNotCloneable() { Week w = new Week(1, 1999); assertFalse(w instanceof Cloneable); } /** * The first week in 2005 should span the range: * * TimeZone | Start Millis | End Millis | Start Date | End Date * -----------------+---------------+---------------+-------------+------------ * Europe/London | 1104710400000 | 1105315199999 | 3-Jan-2005 | 9-Jan-2005 * Europe/Paris | 1104706800000 | 1105311599999 | 3-Jan-2005 | 2-Jan-2005 * America/New_York | 1104037200000 | 1104641999999 | 26-Dec-2004 | 1-Jan-2005 * * In London and Paris, Monday is the first day of the week, while in the * US it is Sunday. * * Previously, we were using these values, but see Java Bug ID 4960215: * * TimeZone | Start Millis | End Millis | Start Date | End Date * -----------------+---------------+---------------+-------------+------------ * Europe/London | 1104105600000 | 1104710399999 | 27-Dec-2004 | 2-Jan-2005 * Europe/Paris | 1104102000000 | 1104706799999 | 27-Dec-2004 | 2-Jan-2005 * America/New_York | 1104037200000 | 1104641999999 | 26-Dec-2004 | 1-Jan-2005 */ public void testWeek12005() { Week w1 = new Week(1, 2005); Calendar c1 = Calendar.getInstance( TimeZone.getTimeZone("Europe/London"), Locale.UK); c1.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 assertEquals(1104710400000L, w1.getFirstMillisecond(c1)); assertEquals(1105315199999L, w1.getLastMillisecond(c1)); Calendar c2 = Calendar.getInstance( TimeZone.getTimeZone("Europe/Paris"), Locale.FRANCE); c2.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 assertEquals(1104706800000L, w1.getFirstMillisecond(c2)); assertEquals(1105311599999L, w1.getLastMillisecond(c2)); Calendar c3 = Calendar.getInstance( TimeZone.getTimeZone("America/New_York"), Locale.US); assertEquals(1104037200000L, w1.getFirstMillisecond(c3)); assertEquals(1104641999999L, w1.getLastMillisecond(c3)); } /** * The 53rd week in 2004 in London and Paris should span the range: * * TimeZone | Start Millis | End Millis | Start Date | End Date * -----------------+---------------+---------------+-------------+------------ * Europe/London | 1104105600000 | 1104710399999 | 27-Dec-2004 | 02-Jan-2005 * Europe/Paris | 1104102000000 | 1104706799999 | 27-Dec-2004 | 02-Jan-2005 * * The 53rd week in 2005 in New York should span the range: * * TimeZone | Start Millis | End Millis | Start Date | End Date * -----------------+---------------+---------------+-------------+------------ * America/New_York | 1135486800000 | 1136091599999 | 25-Dec-2005 | 31-Dec-2005 * * In London and Paris, Monday is the first day of the week, while in the * US it is Sunday. */ public void testWeek532005() { Week w1 = new Week(53, 2004); Calendar c1 = Calendar.getInstance( TimeZone.getTimeZone("Europe/London"), Locale.UK); c1.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 assertEquals(1104105600000L, w1.getFirstMillisecond(c1)); assertEquals(1104710399999L, w1.getLastMillisecond(c1)); Calendar c2 = Calendar.getInstance( TimeZone.getTimeZone("Europe/Paris"), Locale.FRANCE); c2.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 assertEquals(1104102000000L, w1.getFirstMillisecond(c2)); assertEquals(1104706799999L, w1.getLastMillisecond(c2)); w1 = new Week(53, 2005); Calendar c3 = Calendar.getInstance( TimeZone.getTimeZone("America/New_York"), Locale.US); assertEquals(1135486800000L, w1.getFirstMillisecond(c3)); assertEquals(1136091599999L, w1.getLastMillisecond(c3)); } /** * A test case for bug 1448828. */ public void testBug1448828() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); try { Week w = new Week(new Date(1136109830000l), TimeZone.getTimeZone("GMT")); assertEquals(2005, w.getYearValue()); assertEquals(52, w.getWeek()); } finally { Locale.setDefault(saved); } } /** * A test case for bug 1498805. */ public void testBug1498805() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); try { TimeZone zone = TimeZone.getTimeZone("GMT"); GregorianCalendar gc = new GregorianCalendar(zone); gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0); Week w = new Week(gc.getTime(), zone); assertEquals(53, w.getWeek()); assertEquals(new Year(2004), w.getYear()); } finally { Locale.setDefault(saved); } } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Week w = new Week(3, 1970); assertEquals(946800000L, w.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Week w = new Week(47, 1950); Locale saved = Locale.getDefault(); Locale.setDefault(Locale.US); try { TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-603302400000L, w.getFirstMillisecond(zone)); } finally { Locale.setDefault(saved); } // try null calendar boolean pass = false; try { w.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Week w = new Week(1, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, w.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { w.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Week w = new Week(31, 1970); assertEquals(18485999999L, w.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Week w = new Week(2, 1950); Locale saved = Locale.getDefault(); Locale.setDefault(Locale.US); try { TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-629913600001L, w.getLastMillisecond(zone)); } finally { Locale.setDefault(saved); } // try null zone boolean pass = false; try { w.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Week w = new Week(52, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1009756799999L, w.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { w.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Week w = new Week(1, 2000); assertEquals(106001L, w.getSerialIndex()); w = new Week(1, 1900); assertEquals(100701L, w.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Week w = new Week(12, 2000); w = (Week) w.next(); assertEquals(new Year(2000), w.getYear()); assertEquals(13, w.getWeek()); w = new Week(53, 9999); assertNull(w.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Week w = new Week(3, 2006); assertEquals(cal.getTime(), w.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 8, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Week w = new Week(1, 2006); assertEquals(cal.getTime(), w.getEnd()); Locale.setDefault(saved); } /** * A test for a problem in constructing a new Week instance. */ public void testConstructor() { Locale savedLocale = Locale.getDefault(); TimeZone savedZone = TimeZone.getDefault(); Locale.setDefault(new Locale("da", "DK")); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen")); GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance( TimeZone.getDefault(), Locale.getDefault()); // first day of week is monday assertEquals(Calendar.MONDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); Date t = cal.getTime(); Week w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(34, w.getWeek()); Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("US/Detroit")); cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault()); // first day of week is Sunday assertEquals(Calendar.SUNDAY, cal.getFirstDayOfWeek()); cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); cal.set(Calendar.MILLISECOND, 0); t = cal.getTime(); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); assertEquals(35, w.getWeek()); w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen"), new Locale("da", "DK")); assertEquals(34, w.getWeek()); Locale.setDefault(savedLocale); TimeZone.setDefault(savedZone); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/YearTests.java0000644000175000017500000003063311173030414026765 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * YearTests.java * -------------- * (C) Copyright 2001-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Nov-2001 : Version 1 (DG); * 19-Mar-2002 : Added tests for constructor that uses java.util.Date to ensure * it is consistent with the getStart() and getEnd() methods (DG); * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 13-Mar-2003 : Added serialization test (DG); * 11-Jan-2005 : Added test for non-clonability (DG); * 05-Oct-2006 : Added some new tests (DG); * 11-Jul-2007 : Fixed bad time zone assumption (DG); * */ package org.jfree.data.time.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.TimePeriodFormatException; import org.jfree.data.time.Year; /** * Tests for the {@link Year} class. */ public class YearTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YearTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YearTests(String name) { super(name); } /** * Common test setup. */ protected void setUp() { // no setup } /** * Check that a Year instance is equal to itself. * * SourceForge Bug ID: 558850. */ public void testEqualsSelf() { Year year = new Year(); assertTrue(year.equals(year)); } /** * Tests the equals method. */ public void testEquals() { Year year1 = new Year(2002); Year year2 = new Year(2002); assertTrue(year1.equals(year2)); year1 = new Year(1999); assertFalse(year1.equals(year2)); year2 = new Year(1999); assertTrue(year1.equals(year2)); } /** * In GMT, the end of 2001 is java.util.Date(1009843199999L). Use this to * check the year constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Date d1 = new Date(1009843199999L); Date d2 = new Date(1009843200000L); Year y1 = new Year(d1, zone); Year y2 = new Year(d2, zone); assertEquals(2001, y1.getYear()); assertEquals(1009843199999L, y1.getLastMillisecond(zone)); assertEquals(2002, y2.getYear()); assertEquals(1009843200000L, y2.getFirstMillisecond(zone)); } /** * In Los Angeles, the end of 2001 is java.util.Date(1009871999999L). Use * this to check the year constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Year y1 = new Year(new Date(1009871999999L), zone); Year y2 = new Year(new Date(1009872000000L), zone); assertEquals(2001, y1.getYear()); assertEquals(1009871999999L, y1.getLastMillisecond(zone)); assertEquals(2002, y2.getYear()); assertEquals(1009872000000L, y2.getFirstMillisecond(zone)); } /** * Set up a year equal to 1900. Request the previous year, it should be * null. */ public void testMinuss9999Previous() { Year current = new Year(-9999); Year previous = (Year) current.previous(); assertNull(previous); } /** * Set up a year equal to 1900. Request the next year, it should be 1901. */ public void test1900Next() { Year current = new Year(1900); Year next = (Year) current.next(); assertEquals(1901, next.getYear()); } /** * Set up a year equal to 9999. Request the previous year, it should be * 9998. */ public void test9999Previous() { Year current = new Year(9999); Year previous = (Year) current.previous(); assertEquals(9998, previous.getYear()); } /** * Set up a year equal to 9999. Request the next year, it should be null. */ public void test9999Next() { Year current = new Year(9999); Year next = (Year) current.next(); assertNull(next); } /** * Tests the year string parser. */ public void testParseYear() { Year year = null; // test 1... try { year = Year.parseYear("2000"); } catch (TimePeriodFormatException e) { year = new Year(1900); } assertEquals(2000, year.getYear()); // test 2... try { year = Year.parseYear(" 2001 "); } catch (TimePeriodFormatException e) { year = new Year(1900); } assertEquals(2001, year.getYear()); // test 3... try { year = Year.parseYear("99"); } catch (TimePeriodFormatException e) { year = new Year(1900); } assertEquals(99, year.getYear()); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Year y1 = new Year(1999); Year y2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(y1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); y2 = (Year) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(y1, y2); } /** * The {@link Year} class is immutable, so should not be {@link Cloneable}. */ public void testNotCloneable() { Year y = new Year(1999); assertFalse(y instanceof Cloneable); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Year y1 = new Year(1988); Year y2 = new Year(1988); assertTrue(y1.equals(y2)); int h1 = y1.hashCode(); int h2 = y2.hashCode(); assertEquals(h1, h2); } /** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Year y = new Year(1970); // TODO: Check this result... assertEquals(-3600000L, y.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Year y = new Year(1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-631123200000L, y.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { y.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Year y = new Year(2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(978307200000L, y.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { y.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Year y = new Year(1970); // TODO: Check this result... assertEquals(31532399999L, y.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Year y = new Year(1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-599587200001L, y.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { y.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Year y = new Year(2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(1009843199999L, y.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { y.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSerialIndex() method. */ public void testGetSerialIndex() { Year y = new Year(2000); assertEquals(2000L, y.getSerialIndex()); } /** * Some checks for the testNext() method. */ public void testNext() { Year y = new Year(2000); y = (Year) y.next(); assertEquals(2001, y.getYear()); y = new Year(9999); assertNull(y.next()); } /** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Year y = new Year(2006); assertEquals(cal.getTime(), y.getStart()); Locale.setDefault(saved); } /** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.DECEMBER, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Year y = new Year(2006); assertEquals(cal.getTime(), y.getEnd()); Locale.setDefault(saved); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/junit/package.html0000644000175000017500000000016311173030414026453 0ustar vincentvincent JUnit tests. libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/0000755000175000017500000000000011173030414023766 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/junit/0000755000175000017500000000000011216245562025131 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/junit/OHLCItemTests.java0000644000175000017500000001305611173030414030356 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * OHLCItemTests.java * ------------------ * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * */ package org.jfree.data.time.ohlc.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Year; import org.jfree.data.time.ohlc.OHLCItem; /** * Tests for the {@link OHLCItem} class. */ public class OHLCItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OHLCItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OHLCItemTests(String name) { super(name); } private static final double EPSILON = 0.00000000001; /** * Some checks for the constructor. */ public void testConstructor1() { OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); assertEquals(new Year(2006), item1.getPeriod()); assertEquals(2.0, item1.getOpenValue(), EPSILON); assertEquals(4.0, item1.getHighValue(), EPSILON); assertEquals(1.0, item1.getLowValue(), EPSILON); assertEquals(3.0, item1.getCloseValue(), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCItem item2 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); // period item1 = new OHLCItem(new Year(2007), 2.0, 4.0, 1.0, 3.0); assertFalse(item1.equals(item2)); item2 = new OHLCItem(new Year(2007), 2.0, 4.0, 1.0, 3.0); assertTrue(item1.equals(item2)); // open item1 = new OHLCItem(new Year(2007), 2.2, 4.0, 1.0, 3.0); assertFalse(item1.equals(item2)); item2 = new OHLCItem(new Year(2007), 2.2, 4.0, 1.0, 3.0); assertTrue(item1.equals(item2)); // high item1 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.0, 3.0); assertFalse(item1.equals(item2)); item2 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.0, 3.0); assertTrue(item1.equals(item2)); // low item1 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.0); assertFalse(item1.equals(item2)); item2 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.0); assertTrue(item1.equals(item2)); // close item1 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.3); assertFalse(item1.equals(item2)); item2 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.3); assertTrue(item1.equals(item2)); } /** * Some checks for the clone() method. */ public void testCloning() { OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCItem item2 = null; try { item2 = (OHLCItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (OHLCItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/junit/OHLCPackageTests.java0000644000175000017500000000524011173030414031007 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * OHLCPackageTests.java * --------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * */ package org.jfree.data.time.ohlc.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data.time.ohlc package that can * be run using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class OHLCPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.time.ohlc"); suite.addTestSuite(OHLCItemTests.class); suite.addTestSuite(OHLCSeriesCollectionTests.class); suite.addTestSuite(OHLCSeriesTests.class); suite.addTestSuite(OHLCTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public OHLCPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/junit/OHLCSeriesCollectionTests.java0000644000175000017500000001325511173030414032727 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * OHLCSeriesCollectionTests.java * ------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * 10-Jul-2008 : Updated testEquals() method (DG); * */ package org.jfree.data.time.ohlc.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.TimePeriodAnchor; import org.jfree.data.time.Year; import org.jfree.data.time.ohlc.OHLCSeries; import org.jfree.data.time.ohlc.OHLCSeriesCollection; /** * Tests for the {@link OHLCSeriesCollectionTests} class. */ public class OHLCSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OHLCSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OHLCSeriesCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { OHLCSeriesCollection c1 = new OHLCSeriesCollection(); OHLCSeriesCollection c2 = new OHLCSeriesCollection(); assertEquals(c1, c2); // add a series OHLCSeries s1 = new OHLCSeries("Series"); s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); assertFalse(c1.equals(c2)); OHLCSeries s2 = new OHLCSeries("Series"); s2.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); c2.addSeries(s2); assertTrue(c1.equals(c2)); // add an empty series c1.addSeries(new OHLCSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new OHLCSeries("Empty Series")); assertTrue(c1.equals(c2)); c1.setXPosition(TimePeriodAnchor.END); assertFalse(c1.equals(c2)); c2.setXPosition(TimePeriodAnchor.END); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { OHLCSeriesCollection c1 = new OHLCSeriesCollection(); OHLCSeries s1 = new OHLCSeries("Series"); s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); OHLCSeriesCollection c2 = null; try { c2 = (OHLCSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { OHLCSeriesCollection c1 = new OHLCSeriesCollection(); OHLCSeries s1 = new OHLCSeries("Series"); s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); OHLCSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (OHLCSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * A test for bug report 1170825 (originally affected XYSeriesCollection, * this test is just copied over). */ public void test1170825() { OHLCSeries s1 = new OHLCSeries("Series1"); OHLCSeriesCollection dataset = new OHLCSeriesCollection(); dataset.addSeries(s1); try { /* XYSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/junit/OHLCSeriesTests.java0000644000175000017500000001763611173030414030722 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * OHLCSeriesTests.java * -------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1, based on XYSeriesTests (DG); * 27-Nov-2007 : Added testClear() method (DG); * */ package org.jfree.data.time.ohlc.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.general.SeriesException; import org.jfree.data.time.Year; import org.jfree.data.time.ohlc.OHLCSeries; /** * Tests for the {@link OHLCSeries} class. */ public class OHLCSeriesTests extends TestCase implements SeriesChangeListener { SeriesChangeEvent lastEvent; /** * Records a change event. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OHLCSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OHLCSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { OHLCSeries s1 = new OHLCSeries("s1"); OHLCSeries s2 = new OHLCSeries("s1"); assertTrue(s1.equals(s2)); // seriesKey s1 = new OHLCSeries("s2"); assertFalse(s1.equals(s2)); s2 = new OHLCSeries("s2"); assertTrue(s1.equals(s2)); // add a value s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); assertFalse(s1.equals(s2)); s2.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); assertTrue(s2.equals(s1)); // add another value s1.add(new Year(2008), 2.0, 4.0, 1.0, 3.0); assertFalse(s1.equals(s2)); s2.add(new Year(2008), 2.0, 4.0, 1.0, 3.0); assertTrue(s2.equals(s1)); // remove a value s1.remove(new Year(2008)); assertFalse(s1.equals(s2)); s2.remove(new Year(2008)); assertTrue(s2.equals(s1)); } /** * Confirm that cloning works. */ public void testCloning() { OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCSeries s2 = null; try { s2 = (OHLCSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); OHLCSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (OHLCSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Simple test for the indexOf() method. */ public void testIndexOf() { OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); s1.add(new Year(2011), 2.0, 4.0, 1.0, 3.0); s1.add(new Year(2010), 2.0, 4.0, 1.0, 3.0); assertEquals(0, s1.indexOf(new Year(2006))); assertEquals(1, s1.indexOf(new Year(2010))); assertEquals(2, s1.indexOf(new Year(2011))); } /** * Simple test for the remove() method. */ public void testRemove() { OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); s1.add(new Year(2011), 2.1, 4.1, 1.1, 3.1); s1.add(new Year(2010), 2.2, 4.2, 1.2, 3.2); assertEquals(3, s1.getItemCount()); s1.remove(new Year(2010)); assertEquals(new Year(2011), s1.getPeriod(1)); s1.remove(new Year(2006)); assertEquals(new Year(2011), s1.getPeriod(0)); } /** * If you add a duplicate period, an exception should be thrown. */ public void testAdditionOfDuplicatePeriod() { OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 1.0, 1.0, 1.0, 1.0); boolean pass = false; try { s1.add(new Year(2006), 1.0, 1.0, 1.0, 1.0); } catch (SeriesException e) { pass = true; } assertTrue(pass); } /** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { OHLCSeries s1 = new OHLCSeries("s1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(new Year(2006), 1.0, 1.1, 1.1, 1.1); s1.add(new Year(2007), 2.0, 2.2, 2.2, 2.2); s1.add(new Year(2008), 3.0, 3.3, 3.3, 3.3); assertEquals(new Year(2007), s1.getPeriod(0)); assertEquals(new Year(2008), s1.getPeriod(1)); } /** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { OHLCSeries s1 = new OHLCSeries("s1"); s1.add(new Year(2006), 1.0, 1.1, 1.1, 1.1); s1.add(new Year(2007), 2.0, 2.2, 2.2, 2.2); s1.add(new Year(2008), 3.0, 3.3, 3.3, 3.3); s1.setMaximumItemCount(2); assertEquals(new Year(2007), s1.getPeriod(0)); assertEquals(new Year(2008), s1.getPeriod(1)); } /** * Some checks for the clear() method. */ public void testClear() { OHLCSeries s1 = new OHLCSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(new Year(2006), 1.0, 1.1, 1.1, 1.1); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/time/ohlc/junit/OHLCTests.java0000644000175000017500000000777011173030414027545 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------- * OHLCTests.java * -------------- * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Dec-2006 : Version 1 (DG); * */ package org.jfree.data.time.ohlc.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.ohlc.OHLC; /** * Tests for the {@link OHLC} class. */ public class OHLCTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OHLCTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OHLCTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); OHLC i2 = new OHLC(2.0, 4.0, 1.0, 3.0); assertEquals(i1, i2); i1 = new OHLC(2.2, 4.0, 1.0, 3.0); assertFalse(i1.equals(i2)); i2 = new OHLC(2.2, 4.0, 1.0, 3.0); assertTrue(i1.equals(i2)); i1 = new OHLC(2.2, 4.4, 1.0, 3.0); assertFalse(i1.equals(i2)); i2 = new OHLC(2.2, 4.4, 1.0, 3.0); assertTrue(i1.equals(i2)); i1 = new OHLC(2.2, 4.4, 1.1, 3.0); assertFalse(i1.equals(i2)); i2 = new OHLC(2.2, 4.4, 1.1, 3.0); assertTrue(i1.equals(i2)); i1 = new OHLC(2.2, 4.4, 1.1, 3.3); assertFalse(i1.equals(i2)); i2 = new OHLC(2.2, 4.4, 1.1, 3.3); assertTrue(i1.equals(i2)); } /** * This class is immutable. */ public void testCloning() { OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); assertFalse(i1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); OHLC i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (OHLC) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/0000755000175000017500000000000011173030414022543 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/0000755000175000017500000000000011216245562023706 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/CategoryTableXYDatasetTests.java0000644000175000017500000001713711173030414032107 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * CategoryTableXYDatasetTests.java * -------------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Oct-2005 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.CategoryTableXYDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link CategoryTableXYDataset} class. */ public class CategoryTableXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(CategoryTableXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public CategoryTableXYDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); CategoryTableXYDataset d2 = new CategoryTableXYDataset(); d2.add(1.0, 1.1, "Series 1"); d2.add(2.0, 2.2, "Series 1"); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.add(3.0, 3.3, "Series 1"); assertFalse(d1.equals(d2)); d2.add(3.0, 3.3, "Series 1"); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); CategoryTableXYDataset d2 = null; try { d2 = (CategoryTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); d1.add(3.0, 3.3, "Series 1"); assertFalse(d1.equals(d2)); d2.add(3.0, 3.3, "Series 1"); assertTrue(d1.equals(d2)); d1.setIntervalPositionFactor(0.33); assertFalse(d1.equals(d2)); d2.setIntervalPositionFactor(0.33); assertTrue(d1.equals(d2)); } /** * Another check for cloning - making sure it works for a customised * interval delegate. */ public void testCloning2() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); d1.setIntervalWidth(1.23); CategoryTableXYDataset d2 = null; try { d2 = (CategoryTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); d1.add(3.0, 3.3, "Series 1"); assertFalse(d1.equals(d2)); d2.add(3.0, 3.3, "Series 1"); assertTrue(d1.equals(d2)); d1.setIntervalPositionFactor(0.33); assertFalse(d1.equals(d2)); d2.setIntervalPositionFactor(0.33); assertTrue(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); CategoryTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (CategoryTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } private static final double EPSILON = 0.0000000001; /** * This is a test for bug 1312066 - adding a new series should trigger a * recalculation of the interval width, if it is being automatically * calculated. */ public void testAddSeries() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.setAutoWidth(true); d1.add(3.0, 1.1, "Series 1"); d1.add(7.0, 2.2, "Series 1"); assertEquals(3.0, d1.getXValue(0, 0), EPSILON); assertEquals(7.0, d1.getXValue(0, 1), EPSILON); assertEquals(1.0, d1.getStartXValue(0, 0), EPSILON); assertEquals(5.0, d1.getStartXValue(0, 1), EPSILON); assertEquals(5.0, d1.getEndXValue(0, 0), EPSILON); assertEquals(9.0, d1.getEndXValue(0, 1), EPSILON); // now add some more data d1.add(7.5, 1.1, "Series 2"); d1.add(9.0, 2.2, "Series 2"); assertEquals(3.0, d1.getXValue(1, 0), EPSILON); assertEquals(7.0, d1.getXValue(1, 1), EPSILON); assertEquals(7.5, d1.getXValue(1, 2), EPSILON); assertEquals(9.0, d1.getXValue(1, 3), EPSILON); assertEquals(7.25, d1.getStartXValue(1, 2), EPSILON); assertEquals(8.75, d1.getStartXValue(1, 3), EPSILON); assertEquals(7.75, d1.getEndXValue(1, 2), EPSILON); assertEquals(9.25, d1.getEndXValue(1, 3), EPSILON); // and check the first series too... assertEquals(2.75, d1.getStartXValue(0, 0), EPSILON); assertEquals(6.75, d1.getStartXValue(0, 1), EPSILON); assertEquals(3.25, d1.getEndXValue(0, 0), EPSILON); assertEquals(7.25, d1.getEndXValue(0, 1), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DataXYPackageTests.java0000644000175000017500000001163211173030414030173 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DataXYPackageTests.java * ----------------------- * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Aug-2004 : Restructured org.jfree.data package (DG); * 18-Jan-2005 : Added main() method (DG); * 21-Jan-2005 : Added IntervalXYDelegateTests (DG); * 29-Apr-2005 : Added DefaultOHLCDatasetTests and OHLCDataItemTests (DG); * 06-Oct-2005 : Added CategoryTableXYDatasetTests (DG); * 06-Jul-2006 : Added new DefaultXYDatasetTests (DG); * 12-Jul-2006 : Added new DefaultXYZDatasetTests and * DefaultWindDatasetTests (DG); * 27-Nov-2006 : Added MatrixSeriesCollectionTests (DG); * 25-Jan-2007 : Added XYBarDatasetTests (DG); * 25-May-2007 : Added VectorXXX tests (DG); * */ package org.jfree.data.xy.junit; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Some tests for the org.jfree.data.category package that can * be run using JUnit. You can find more information about JUnit at * http://www.junit.org. */ public class DataXYPackageTests extends TestCase { /** * Returns a test suite to the JUnit test runner. * * @return The test suite. */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.data.xy"); suite.addTestSuite(CategoryTableXYDatasetTests.class); suite.addTestSuite(DefaultHighLowDatasetTests.class); suite.addTestSuite(DefaultIntervalXYDatasetTests.class); suite.addTestSuite(DefaultOHLCDatasetTests.class); suite.addTestSuite(DefaultTableXYDatasetTests.class); suite.addTestSuite(DefaultWindDatasetTests.class); suite.addTestSuite(DefaultXYDatasetTests.class); suite.addTestSuite(DefaultXYZDatasetTests.class); suite.addTestSuite(IntervalXYDelegateTests.class); suite.addTestSuite(MatrixSeriesCollectionTests.class); suite.addTestSuite(MatrixSeriesTests.class); suite.addTestSuite(OHLCDataItemTests.class); suite.addTestSuite(TableXYDatasetTests.class); suite.addTestSuite(VectorDataItemTests.class); suite.addTestSuite(VectorSeriesCollectionTests.class); suite.addTestSuite(VectorSeriesTests.class); suite.addTestSuite(VectorTests.class); suite.addTestSuite(XIntervalDataItemTests.class); suite.addTestSuite(XIntervalSeriesCollectionTests.class); suite.addTestSuite(XIntervalSeriesTests.class); suite.addTestSuite(XYBarDatasetTests.class); suite.addTestSuite(XYCoordinateTests.class); suite.addTestSuite(XYDataItemTests.class); suite.addTestSuite(XYIntervalDataItemTests.class); suite.addTestSuite(XYIntervalSeriesCollectionTests.class); suite.addTestSuite(XYIntervalSeriesTests.class); suite.addTestSuite(XYIntervalTests.class); suite.addTestSuite(XYSeriesCollectionTests.class); suite.addTestSuite(XYSeriesTests.class); suite.addTestSuite(YIntervalDataItemTests.class); suite.addTestSuite(YIntervalSeriesCollectionTests.class); suite.addTestSuite(YIntervalSeriesTests.class); suite.addTestSuite(YIntervalTests.class); suite.addTestSuite(YWithXIntervalTests.class); return suite; } /** * Constructs the test suite. * * @param name the test suite name. */ public DataXYPackageTests(String name) { super(name); } /** * Runs the test suite using JUnit's text-based runner. * * @param args ignored. */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultHighLowDatasetTests.java0000644000175000017500000002046711173030414031747 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * DefaultHighLowDatasetTests.java * ------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 28-Nov-2006 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultHighLowDataset; import org.jfree.util.PublicCloneable; /** * Tests for the {@link DefaultHighLowDataset} class. */ public class DefaultHighLowDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultHighLowDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultHighLowDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]); DefaultHighLowDataset d2 = new DefaultHighLowDataset("Series 1", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = new DefaultHighLowDataset("Series 2", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]); assertTrue(d1.equals(d2)); d1 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[1], new double[1], new double[1], new double[1], new double[1]); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[1], new double[1], new double[1], new double[1], new double[1]); assertTrue(d1.equals(d2)); d1 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[1], new double[1], new double[1], new double[1]); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[1], new double[1], new double[1], new double[1]); assertTrue(d1.equals(d2)); d1 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[1], new double[1], new double[1]); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[1], new double[1], new double[1]); assertTrue(d1.equals(d2)); d1 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[1], new double[1]); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[1], new double[1]); assertTrue(d1.equals(d2)); d1 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[1]); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[1]); assertTrue(d1.equals(d2)); d1 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9}); assertFalse(d1.equals(d2)); d2 = new DefaultHighLowDataset("Series 2", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9}); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9}); DefaultHighLowDataset d2 = null; try { d2 = (DefaultHighLowDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[0], new double[0], new double[0], new double[0], new double[0], new double[0]); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", new Date[] {new Date(123L)}, new double[] {1.2}, new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, new double[] {99.9}); DefaultHighLowDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultHighLowDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java0000644000175000017500000003303711173030414032450 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------------- * DefaultIntervalXYDatasetTests.java * ---------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Oct-2006 : Version 1 (DG); * 02-Nov-2006 : Added testAddSeries() method (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.util.PublicCloneable; /** * Some tests for the {@link DefaultIntervalXYDataset} class. */ public class DefaultIntervalXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultIntervalXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultIntervalXYDatasetTests(String name) { super(name); } /** * Some checks for the getSeriesCount() method. */ public void testGetSeriesCount() { DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); assertEquals(0, d.getSeriesCount()); d = createSampleDataset1(); assertEquals(2, d.getSeriesCount()); } /** * Some checks for the getSeriesKey(int) method. */ public void testGetSeriesKey() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals("S1", d.getSeriesKey(0)); assertEquals("S2", d.getSeriesKey(1)); // check for series key out of bounds boolean pass = false; try { /*Comparable k =*/ d.getSeriesKey(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { /*Comparable k =*/ d.getSeriesKey(2); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getItemCount() method. */ public void testGetItemCount() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(3, d.getItemCount(0)); assertEquals(3, d.getItemCount(1)); // try an index out of bounds boolean pass = false; try { d.getItemCount(2); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } private static final double EPSILON = 0.0000000001; /** * Some checks for the getXValue() method. */ public void testGetXValue() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(1.0, d.getXValue(0, 0), EPSILON); assertEquals(2.0, d.getXValue(0, 1), EPSILON); assertEquals(3.0, d.getXValue(0, 2), EPSILON); assertEquals(11.0, d.getXValue(1, 0), EPSILON); assertEquals(12.0, d.getXValue(1, 1), EPSILON); assertEquals(13.0, d.getXValue(1, 2), EPSILON); } /** * Some checks for the getYValue() method. */ public void testGetYValue() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(4.0, d.getYValue(0, 0), EPSILON); assertEquals(5.0, d.getYValue(0, 1), EPSILON); assertEquals(6.0, d.getYValue(0, 2), EPSILON); assertEquals(14.0, d.getYValue(1, 0), EPSILON); assertEquals(15.0, d.getYValue(1, 1), EPSILON); assertEquals(16.0, d.getYValue(1, 2), EPSILON); } /** * Some checks for the getStartXValue() method. */ public void testGetStartXValue() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(0.9, d.getStartXValue(0, 0), EPSILON); assertEquals(1.9, d.getStartXValue(0, 1), EPSILON); assertEquals(2.9, d.getStartXValue(0, 2), EPSILON); assertEquals(10.9, d.getStartXValue(1, 0), EPSILON); assertEquals(11.9, d.getStartXValue(1, 1), EPSILON); assertEquals(12.9, d.getStartXValue(1, 2), EPSILON); } /** * Some checks for the getEndXValue() method. */ public void testGetEndXValue() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(1.1, d.getEndXValue(0, 0), EPSILON); assertEquals(2.1, d.getEndXValue(0, 1), EPSILON); assertEquals(3.1, d.getEndXValue(0, 2), EPSILON); assertEquals(11.1, d.getEndXValue(1, 0), EPSILON); assertEquals(12.1, d.getEndXValue(1, 1), EPSILON); assertEquals(13.1, d.getEndXValue(1, 2), EPSILON); } /** * Some checks for the getStartYValue() method. */ public void testGetStartYValue() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(1.09, d.getStartYValue(0, 0), EPSILON); assertEquals(2.09, d.getStartYValue(0, 1), EPSILON); assertEquals(3.09, d.getStartYValue(0, 2), EPSILON); assertEquals(11.09, d.getStartYValue(1, 0), EPSILON); assertEquals(12.09, d.getStartYValue(1, 1), EPSILON); assertEquals(13.09, d.getStartYValue(1, 2), EPSILON); } /** * Some checks for the getEndYValue() method. */ public void testGetEndYValue() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(1.11, d.getEndYValue(0, 0), EPSILON); assertEquals(2.11, d.getEndYValue(0, 1), EPSILON); assertEquals(3.11, d.getEndYValue(0, 2), EPSILON); assertEquals(11.11, d.getEndYValue(1, 0), EPSILON); assertEquals(12.11, d.getEndYValue(1, 1), EPSILON); assertEquals(13.11, d.getEndYValue(1, 2), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); DefaultIntervalXYDataset d2 = new DefaultIntervalXYDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = createSampleDataset1(); assertFalse(d1.equals(d2)); d2 = createSampleDataset1(); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); DefaultIntervalXYDataset d2 = null; try { d2 = (DefaultIntervalXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // try a dataset with some content... d1 = createSampleDataset1(); try { d2 = (DefaultIntervalXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Another test for cloning. */ public void testCloning2() { DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] x1Start = new double[] {0.9, 1.9, 2.9}; double[] x1End = new double[] {1.1, 2.1, 3.1}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; d1.addSeries("S1", data1); DefaultIntervalXYDataset d2 = null; try { d2 = (DefaultIntervalXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check independence x1[0] = 111.1; assertFalse(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); DefaultIntervalXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultIntervalXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // try a dataset with some content... d1 = createSampleDataset1(); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultIntervalXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Some checks for the indexOf(Comparable) method. */ public void testIndexOf() { DefaultIntervalXYDataset d = createSampleDataset1(); assertEquals(0, d.indexOf("S1")); assertEquals(1, d.indexOf("S2")); assertEquals(-1, d.indexOf("Green Eggs and Ham")); assertEquals(-1, d.indexOf(null)); } /** * Some tests for the addSeries() method. */ public void testAddSeries() { DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); d.addSeries("S1", new double[][] {{1.0}, {0.5}, {1.5}, {2.0}, {2.5}, {1.5}}); assertEquals(1, d.getSeriesCount()); assertEquals("S1", d.getSeriesKey(0)); // check that adding a series will overwrite the old series d.addSeries("S1", new double[][] {{1.1}, {0.6}, {1.6}, {2.1}, {2.6}, {1.6}}); assertEquals(1, d.getSeriesCount()); assertEquals(2.1, d.getYValue(0, 0), EPSILON); // check null key boolean pass = false; try { d.addSeries(null, new double[][] {{1.1}, {0.6}, {1.6}, {2.1}, {2.6}, {1.6}}); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultIntervalXYDataset createSampleDataset1() { DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] x1Start = new double[] {0.9, 1.9, 2.9}; double[] x1End = new double[] {1.1, 2.1, 3.1}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] y1Start = new double[] {1.09, 2.09, 3.09}; double[] y1End = new double[] {1.11, 2.11, 3.11}; double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, y1End}; d.addSeries("S1", data1); double[] x2 = new double[] {11.0, 12.0, 13.0}; double[] x2Start = new double[] {10.9, 11.9, 12.9}; double[] x2End = new double[] {11.1, 12.1, 13.1}; double[] y2 = new double[] {14.0, 15.0, 16.0}; double[] y2Start = new double[] {11.09, 12.09, 13.09}; double[] y2End = new double[] {11.11, 12.11, 13.11}; double[][] data2 = new double[][] {x2, x2Start, x2End, y2, y2Start, y2End}; d.addSeries("S2", data2); return d; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultOHLCDatasetTests.java0000644000175000017500000001531711173030414031131 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DefaultOHLCDatasetTests.java * ---------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2005 : Version 1 (DG); * 28-Nov-2006 : Extended equals() test (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; import org.jfree.data.general.DatasetUtilities; import org.jfree.data.xy.DefaultOHLCDataset; import org.jfree.data.xy.OHLCDataItem; import org.jfree.util.PublicCloneable; /** * Tests for the {@link DefaultOHLCDataset} class. */ public class DefaultOHLCDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultOHLCDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultOHLCDatasetTests(String name) { super(name); } private static final double EPSILON = 0.0000000001; /** * A small test for the data range calculated on this dataset. */ public void testDataRange() { OHLCDataItem[] data = new OHLCDataItem[3]; data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data); Range r = DatasetUtilities.findRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(9.0, r.getUpperBound(), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset d2 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); assertFalse(d1.equals(d2)); d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); assertTrue(d1.equals(d2)); d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9)}); assertFalse(d1.equals(d2)); d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9)}); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset d2 = null; try { d2 = (DefaultOHLCDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning2() { OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0); OHLCDataItem item2 = new OHLCDataItem(new Date(2L), 6.0, 7.0, 8.0, 9.0, 10.0); // create an array of items in reverse order OHLCDataItem[] items = new OHLCDataItem[] {item2, item1}; DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", items); DefaultOHLCDataset d2 = null; try { d2 = (DefaultOHLCDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); d1.sortDataByDate(); assertFalse(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultOHLCDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java0000644000175000017500000001706111173030414031712 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------- * DefaultTableXYDatasetTests.java * ------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Dec-2003 : Version 1 (DG); * 06-Oct-2005 : Added test for new data updating interval width (DG); * 08-Mar-2007 : Added testGetSeries() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.util.PublicCloneable; /** * Tests for the {@link DefaultTableXYDataset} class. */ public class DefaultTableXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultTableXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultTableXYDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.1); s1.add(2.0, 2.2); d1.addSeries(s1); DefaultTableXYDataset d2 = new DefaultTableXYDataset(); XYSeries s2 = new XYSeries("Series 1", true, false); s2.add(1.0, 1.1); s2.add(2.0, 2.2); d2.addSeries(s2); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); s1.add(3.0, 3.3); assertFalse(d1.equals(d2)); s2.add(3.0, 3.3); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.1); s1.add(2.0, 2.2); d1.addSeries(s1); DefaultTableXYDataset d2 = null; try { d2 = (DefaultTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); s1.add(3.0, 3.3); assertFalse(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.1); s1.add(2.0, 2.2); d1.addSeries(s1); DefaultTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } private static final double EPSILON = 0.0000000001; /** * This is a test for bug 1312066 - adding a new series should trigger a * recalculation of the interval width, if it is being automatically * calculated. */ public void testAddSeries() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); d1.setAutoWidth(true); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(3.0, 1.1); s1.add(7.0, 2.2); d1.addSeries(s1); assertEquals(3.0, d1.getXValue(0, 0), EPSILON); assertEquals(7.0, d1.getXValue(0, 1), EPSILON); assertEquals(1.0, d1.getStartXValue(0, 0), EPSILON); assertEquals(5.0, d1.getStartXValue(0, 1), EPSILON); assertEquals(5.0, d1.getEndXValue(0, 0), EPSILON); assertEquals(9.0, d1.getEndXValue(0, 1), EPSILON); // now add another series XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(7.5, 1.1); s2.add(9.0, 2.2); d1.addSeries(s2); assertEquals(3.0, d1.getXValue(1, 0), EPSILON); assertEquals(7.0, d1.getXValue(1, 1), EPSILON); assertEquals(7.5, d1.getXValue(1, 2), EPSILON); assertEquals(9.0, d1.getXValue(1, 3), EPSILON); assertEquals(7.25, d1.getStartXValue(1, 2), EPSILON); assertEquals(8.75, d1.getStartXValue(1, 3), EPSILON); assertEquals(7.75, d1.getEndXValue(1, 2), EPSILON); assertEquals(9.25, d1.getEndXValue(1, 3), EPSILON); // and check the first series too... assertEquals(2.75, d1.getStartXValue(0, 0), EPSILON); assertEquals(6.75, d1.getStartXValue(0, 1), EPSILON); assertEquals(3.25, d1.getEndXValue(0, 0), EPSILON); assertEquals(7.25, d1.getEndXValue(0, 1), EPSILON); } /** * Some basic checks for the getSeries() method. */ public void testGetSeries() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); d1.addSeries(s1); assertEquals("Series 1", d1.getSeries(0).getKey()); boolean pass = false; try { d1.getSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { d1.getSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultWindDatasetTests.java0000644000175000017500000001714111173030414031302 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DefaultWindDatasetTests.java * ---------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-Jul-2006 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.time.Day; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.xy.DefaultWindDataset; import org.jfree.util.PublicCloneable; /** * Tests for {@link DefaultWindDataset}. */ public class DefaultWindDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultWindDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultWindDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultWindDataset d1 = new DefaultWindDataset(); DefaultWindDataset d2 = new DefaultWindDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1 = createSampleDataset1(); assertFalse(d1.equals(d2)); d2 = createSampleDataset1(); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultWindDataset d1 = new DefaultWindDataset(); DefaultWindDataset d2 = null; try { d2 = (DefaultWindDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // try a dataset with some content... d1 = createSampleDataset1(); d2 = null; try { d2 = (DefaultWindDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultWindDataset d1 = new DefaultWindDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultWindDataset d1 = new DefaultWindDataset(); DefaultWindDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultWindDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // try a dataset with some content... d1 = createSampleDataset1(); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultWindDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Some checks for the getSeriesKey(int) method. */ public void testGetSeriesKey() { DefaultWindDataset d = createSampleDataset1(); assertEquals("Series 1", d.getSeriesKey(0)); assertEquals("Series 2", d.getSeriesKey(1)); // check for series key out of bounds boolean pass = false; try { /*Comparable k =*/ d.getSeriesKey(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { /*Comparable k =*/ d.getSeriesKey(2); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the indexOf(Comparable) method. */ public void testIndexOf() { DefaultWindDataset d = createSampleDataset1(); assertEquals(0, d.indexOf("Series 1")); assertEquals(1, d.indexOf("Series 2")); assertEquals(-1, d.indexOf("Green Eggs and Ham")); assertEquals(-1, d.indexOf(null)); } /** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultWindDataset createSampleDataset1() { Day t = new Day(1, 4, 2006); Object[] item1 = createItem(t, 3, 7); Object[] item2 = createItem(t.next(), 4, 8); Object[] item3 = createItem(t.next(), 5, 9); Object[][] series1 = new Object[][] {item1, item2, item3}; Object[] item1b = createItem(t, 6, 10); Object[] item2b = createItem(t.next(), 7, 11); Object[] item3b = createItem(t.next(), 8, 12); Object[][] series2 = new Object[][] {item1b, item2b, item3b}; Object[][][] data = new Object[][][] {series1, series2}; return new DefaultWindDataset(data); } /** * Creates an array representing one item in a series. * * @param t the time period. * @param dir the wind direction. * @param force the wind force. * * @return An array containing the specified items. */ private Object[] createItem(RegularTimePeriod t, int dir, int force) { return new Object[] {new Long(t.getMiddleMillisecond()), new Integer(dir), new Integer(force)}; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultXYDatasetTests.java0000644000175000017500000002102711173030414030737 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultXYDatasetTests.java * -------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jul-2006 : Version 1 (DG); * 02-Nov-2006 : Added testAddSeries() method (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.util.PublicCloneable; /** * Tests for {@link DefaultXYDataset}. */ public class DefaultXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultXYDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultXYDataset d1 = new DefaultXYDataset(); DefaultXYDataset d2 = new DefaultXYDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d1.addSeries("S1", data1); assertFalse(d1.equals(d2)); d2.addSeries("S1", data2); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultXYDataset d1 = new DefaultXYDataset(); DefaultXYDataset d2 = null; try { d2 = (DefaultXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // try a dataset with some content... double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); try { d2 = (DefaultXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. x1[1] = 2.2; assertFalse(d1.equals(d2)); x1[1] = 2.0; assertTrue(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultXYDataset d1 = new DefaultXYDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultXYDataset d1 = new DefaultXYDataset(); DefaultXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // try a dataset with some content... double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Some checks for the getSeriesKey(int) method. */ public void testGetSeriesKey() { DefaultXYDataset d = createSampleDataset1(); assertEquals("S1", d.getSeriesKey(0)); assertEquals("S2", d.getSeriesKey(1)); // check for series key out of bounds boolean pass = false; try { /*Comparable k =*/ d.getSeriesKey(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { /*Comparable k =*/ d.getSeriesKey(2); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the indexOf(Comparable) method. */ public void testIndexOf() { DefaultXYDataset d = createSampleDataset1(); assertEquals(0, d.indexOf("S1")); assertEquals(1, d.indexOf("S2")); assertEquals(-1, d.indexOf("Green Eggs and Ham")); assertEquals(-1, d.indexOf(null)); } static final double EPSILON = 0.0000000001; /** * Some tests for the addSeries() method. */ public void testAddSeries() { DefaultXYDataset d = new DefaultXYDataset(); d.addSeries("S1", new double[][] {{1.0}, {2.0}}); assertEquals(1, d.getSeriesCount()); assertEquals("S1", d.getSeriesKey(0)); // check that adding a series will overwrite the old series d.addSeries("S1", new double[][] {{11.0}, {12.0}}); assertEquals(1, d.getSeriesCount()); assertEquals(12.0, d.getYValue(0, 0), EPSILON); // check null key boolean pass = false; try { d.addSeries(null, new double[][] {{1.0}, {2.0}}); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultXYDataset createSampleDataset1() { DefaultXYDataset d = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d.addSeries("S1", data1); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d.addSeries("S2", data2); return d; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/DefaultXYZDatasetTests.java0000644000175000017500000002160211173030414031070 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * DefaultXYZDatasetTests.java * --------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-Jul-2006 : Version 1 (DG); * 02-Nov-2006 : Added testAddSeries() method (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultXYZDataset; import org.jfree.util.PublicCloneable; /** * Tests for {@link DefaultXYZDataset}. */ public class DefaultXYZDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(DefaultXYZDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public DefaultXYZDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultXYZDataset d1 = new DefaultXYZDataset(); DefaultXYZDataset d2 = new DefaultXYZDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] z1 = new double[] {7.0, 8.0, 9.0}; double[][] data1 = new double[][] {x1, y1, z1}; double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[] z2 = new double[] {7.0, 8.0, 9.0}; double[][] data2 = new double[][] {x2, y2, z2}; d1.addSeries("S1", data1); assertFalse(d1.equals(d2)); d2.addSeries("S1", data2); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultXYZDataset d1 = new DefaultXYZDataset(); DefaultXYZDataset d2 = null; try { d2 = (DefaultXYZDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // try a dataset with some content... double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] z1 = new double[] {7.0, 8.0, 9.0}; double[][] data1 = new double[][] {x1, y1, z1}; d1.addSeries("S1", data1); try { d2 = (DefaultXYZDataset) d1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); // check that the clone doesn't share the same underlying arrays. x1[1] = 2.2; assertFalse(d1.equals(d2)); x1[1] = 2.0; assertTrue(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultXYZDataset d1 = new DefaultXYZDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultXYZDataset d1 = new DefaultXYZDataset(); DefaultXYZDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultXYZDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // try a dataset with some content... double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] z1 = new double[] {7.0, 8.0, 9.0}; double[][] data1 = new double[][] {x1, y1, z1}; d1.addSeries("S1", data1); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); d2 = (DefaultXYZDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); } /** * Some checks for the getSeriesKey(int) method. */ public void testGetSeriesKey() { DefaultXYZDataset d = createSampleDataset1(); assertEquals("S1", d.getSeriesKey(0)); assertEquals("S2", d.getSeriesKey(1)); // check for series key out of bounds boolean pass = false; try { /*Comparable k =*/ d.getSeriesKey(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { /*Comparable k =*/ d.getSeriesKey(2); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the indexOf(Comparable) method. */ public void testIndexOf() { DefaultXYZDataset d = createSampleDataset1(); assertEquals(0, d.indexOf("S1")); assertEquals(1, d.indexOf("S2")); assertEquals(-1, d.indexOf("Green Eggs and Ham")); assertEquals(-1, d.indexOf(null)); } static final double EPSILON = 0.0000000001; /** * Some tests for the addSeries() method. */ public void testAddSeries() { DefaultXYZDataset d = new DefaultXYZDataset(); d.addSeries("S1", new double[][] {{1.0}, {2.0}, {3.0}}); assertEquals(1, d.getSeriesCount()); assertEquals("S1", d.getSeriesKey(0)); // check that adding a series will overwrite the old series d.addSeries("S1", new double[][] {{11.0}, {12.0}, {13.0}}); assertEquals(1, d.getSeriesCount()); assertEquals(12.0, d.getYValue(0, 0), EPSILON); // check null key boolean pass = false; try { d.addSeries(null, new double[][] {{1.0}, {2.0}, {3.0}}); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultXYZDataset createSampleDataset1() { DefaultXYZDataset d = new DefaultXYZDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[] z1 = new double[] {7.0, 8.0, 9.0}; double[][] data1 = new double[][] {x1, y1, z1}; d.addSeries("S1", data1); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[] z2 = new double[] {7.0, 8.0, 9.0}; double[][] data2 = new double[][] {x2, y2, z2}; d.addSeries("S2", data2); return d; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/IntervalXYDelegateTests.java0000644000175000017500000001211411173030414031261 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * IntervalXYDelegateTests.java * ---------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Feb-2005 : Version 1 (DG); * 06-Oct-2005 : Updated for testEquals() for method name change (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.IntervalXYDelegate; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** * Some checks for the {@link IntervalXYDelegate} class. */ public class IntervalXYDelegateTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(IntervalXYDelegateTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public IntervalXYDelegateTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); XYSeries s2 = new XYSeries("Series"); XYSeriesCollection c2 = new XYSeriesCollection(); s2.add(1.2, 3.4); c2.addSeries(s2); IntervalXYDelegate d2 = new IntervalXYDelegate(c2); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.setAutoWidth(false); assertFalse(d1.equals(d2)); d2.setAutoWidth(false); assertTrue(d1.equals(d2)); d1.setIntervalPositionFactor(0.123); assertFalse(d1.equals(d2)); d2.setIntervalPositionFactor(0.123); assertTrue(d1.equals(d2)); d1.setFixedIntervalWidth(1.23); assertFalse(d1.equals(d2)); d2.setFixedIntervalWidth(1.23); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); IntervalXYDelegate d2 = null; try { d2 = (IntervalXYDelegate) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYSeries s1 = new XYSeries("Series"); s1.add(1.2, 3.4); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); IntervalXYDelegate d1 = new IntervalXYDelegate(c1); IntervalXYDelegate d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (IntervalXYDelegate) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/MatrixSeriesCollectionTests.java0000644000175000017500000001204011173030414032212 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * MatrixSeriesCollectionTests.java * -------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Nov-2006 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.MatrixSeries; import org.jfree.data.xy.MatrixSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link MatrixSeriesCollection} class. */ public class MatrixSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MatrixSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MatrixSeriesCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeries s2 = new MatrixSeries("Series", 2, 3); s2.update(0, 0, 1.1); MatrixSeriesCollection c2 = new MatrixSeriesCollection(); c2.addSeries(s2); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); c1.addSeries(new MatrixSeries("Empty Series", 1, 1)); assertFalse(c1.equals(c2)); c2.addSeries(new MatrixSeries("Empty Series", 1, 1)); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeriesCollection c2 = null; try { c2 = (MatrixSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { MatrixSeriesCollection c1 = new MatrixSeriesCollection(); assertTrue(c1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (MatrixSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/MatrixSeriesTests.java0000644000175000017500000001417711173030414030213 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * MatrixSeriesTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-May-2004 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.MatrixSeries; /** * Tests for the {@link MatrixSeries} class. */ public class MatrixSeriesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(MatrixSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public MatrixSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MatrixSeries m1 = new MatrixSeries("Test", 8, 3); m1.update(0, 0, 11.0); m1.update(7, 2, 22.0); MatrixSeries m2 = new MatrixSeries("Test", 8, 3); m2.update(0, 0, 11.0); m2.update(7, 2, 22.0); assertTrue(m1.equals(m2)); assertTrue(m2.equals(m1)); m1 = new MatrixSeries("Test 2", 8, 3); assertFalse(m1.equals(m2)); m2 = new MatrixSeries("Test 2", 8, 3); assertTrue(m1.equals(m2)); m1 = new MatrixSeries("Test 2", 10, 3); assertFalse(m1.equals(m2)); m2 = new MatrixSeries("Test 2", 10, 3); assertTrue(m1.equals(m2)); m1 = new MatrixSeries("Test 2", 10, 5); assertFalse(m1.equals(m2)); m2 = new MatrixSeries("Test 2", 10, 5); assertTrue(m1.equals(m2)); m1.update(0, 0, 99); assertFalse(m1.equals(m2)); m2.update(0, 0, 99); assertTrue(m1.equals(m2)); } /** * Confirm that cloning works. */ public void testCloning() { MatrixSeries m1 = new MatrixSeries("Test", 8, 3); m1.update(0, 0, 11.0); m1.update(7, 2, 22.0); MatrixSeries m2 = null; try { m2 = (MatrixSeries) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1 != m2); assertTrue(m1.getClass() == m2.getClass()); assertTrue(m1.equals(m2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { MatrixSeries m1 = new MatrixSeries("Test", 8, 3); m1.update(0, 0, 11.0); m1.update(7, 2, 22.0); MatrixSeries m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); m2 = (MatrixSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2); } /** * Tests the getItemColumn() method. */ public void testGetItemColumn() { MatrixSeries m = new MatrixSeries("Test", 3, 2); assertEquals(0, m.getItemColumn(0)); assertEquals(1, m.getItemColumn(1)); assertEquals(0, m.getItemColumn(2)); assertEquals(1, m.getItemColumn(3)); assertEquals(0, m.getItemColumn(4)); assertEquals(1, m.getItemColumn(5)); } /** * Tests the getItemRow() method. */ public void testGetItemRow() { MatrixSeries m = new MatrixSeries("Test", 3, 2); assertEquals(0, m.getItemRow(0)); assertEquals(0, m.getItemRow(1)); assertEquals(1, m.getItemRow(2)); assertEquals(1, m.getItemRow(3)); assertEquals(2, m.getItemRow(4)); assertEquals(2, m.getItemRow(5)); } /** * Tests the getItem() method. */ public void testGetItem() { MatrixSeries m = new MatrixSeries("Test", 3, 2); m.update(0, 0, 0.0); m.update(0, 1, 1.0); m.update(1, 0, 2.0); m.update(1, 1, 3.0); m.update(2, 0, 4.0); m.update(2, 1, 5.0); assertEquals(0.0, m.getItem(0).doubleValue(), 0.001); assertEquals(1.0, m.getItem(1).doubleValue(), 0.001); assertEquals(2.0, m.getItem(2).doubleValue(), 0.001); assertEquals(3.0, m.getItem(3).doubleValue(), 0.001); assertEquals(4.0, m.getItem(4).doubleValue(), 0.001); assertEquals(5.0, m.getItem(5).doubleValue(), 0.001); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/OHLCDataItemTests.java0000644000175000017500000000742211173030414027725 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * OHLCDataItemTests.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Apr-2005 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.OHLCDataItem; /** * Tests for the {@link OHLCDataItem} class. */ public class OHLCDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(OHLCDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public OHLCDataItemTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { OHLCDataItem i1 = new OHLCDataItem( new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0 ); OHLCDataItem i2 = new OHLCDataItem( new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0 ); assertTrue(i1.equals(i2)); assertTrue(i2.equals(i1)); } /** * Instances of this class are immutable - cloning not required. */ public void testCloning() { OHLCDataItem i1 = new OHLCDataItem( new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0 ); assertFalse(i1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { OHLCDataItem i1 = new OHLCDataItem( new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0 ); OHLCDataItem i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); i2 = (OHLCDataItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/TableXYDatasetTests.java0000644000175000017500000002335111173030414030404 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * TableXYDatasetTests.java * ------------------------ * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. * * Original Author: Richard Atkinson; * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 11-Aug-2003 : Version 1 (RA); * 18-Aug-2003 : Added tests for event notification when removing and updating * series (RA); * 22-Sep-2003 : Changed to recognise that empty values are now null rather * than zero (RA); * 16-Feb-2004 : Added some additional tests (DG); * 15-Jul-2004 : Switched getX() with getXValue() and getY() with * getYValue() (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.util.PublicCloneable; /** * Tests for {@link DefaultTableXYDataset}. */ public class TableXYDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(TableXYDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public TableXYDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); DefaultTableXYDataset d2 = new DefaultTableXYDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); d1.addSeries(createSeries1()); assertFalse(d1.equals(d2)); d2.addSeries(createSeries1()); assertTrue(d1.equals(d2)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); d1.addSeries(createSeries1()); DefaultTableXYDataset d2 = null; try { d2 = (DefaultTableXYDataset) d1.clone(); } catch (CloneNotSupportedException e) { System.err.println("Failed to clone."); } assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); d1.addSeries(createSeries2()); DefaultTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2); } /** * Assorted tests. */ public void testTableXYDataset() { XYSeries series1 = createSeries1(); XYSeries series2 = createSeries2(); DefaultTableXYDataset dataset = new DefaultTableXYDataset(); dataset.addSeries(series1); dataset.addSeries(series2); // Test that there are 6 X points and some specific values assertEquals(6, dataset.getItemCount()); assertEquals(6, dataset.getX(0, 5).intValue()); assertEquals(null, dataset.getY(0, 5)); assertEquals(6, dataset.getX(1, 5).intValue()); assertEquals(2, dataset.getY(1, 5).intValue()); // after adding a point to a series, check that there are now 7 // items in each series series2.add(7, 2); assertEquals(7, dataset.getItemCount()); assertEquals(null, dataset.getY(0, 6)); assertEquals(2, dataset.getY(1, 6).intValue()); // Remove series 1 dataset.removeSeries(series1); // Test that there are still 7 X points assertEquals(7, dataset.getItemCount()); // Remove series 2 and add new series dataset.removeSeries(series2); series1 = createSeries1(); dataset.addSeries(series1); // Test that there are now 4 X points assertEquals(4, dataset.getItemCount()); } /** * A test for bug report 788597. */ public void test788597() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); dataset.addSeries(createSeries1()); assertEquals(4, dataset.getItemCount()); dataset.removeAllSeries(); assertEquals(0, dataset.getItemCount()); } /** * Test that removing all values for a given x works. */ public void testRemoveAllValuesForX() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); dataset.addSeries(createSeries1()); dataset.addSeries(createSeries2()); dataset.removeAllValuesForX(new Double(2.0)); assertEquals(5, dataset.getItemCount()); assertEquals(new Double(1.0), dataset.getX(0, 0)); assertEquals(new Double(3.0), dataset.getX(0, 1)); assertEquals(new Double(4.0), dataset.getX(0, 2)); assertEquals(new Double(5.0), dataset.getX(0, 3)); assertEquals(new Double(6.0), dataset.getX(0, 4)); } /** * Tests to see that pruning removes unwanted x values. */ public void testPrune() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); dataset.addSeries(createSeries1()); dataset.addSeries(createSeries2()); dataset.removeSeries(1); dataset.prune(); assertEquals(4, dataset.getItemCount()); } /** * Tests the auto-pruning feature. */ public void testAutoPrune() { // WITH AUTOPRUNING DefaultTableXYDataset dataset = new DefaultTableXYDataset(true); dataset.addSeries(createSeriesA()); assertEquals(2, dataset.getItemCount()); // should be 2 items dataset.addSeries(createSeriesB()); assertEquals(2, dataset.getItemCount()); // still 2 dataset.removeSeries(1); assertEquals(1, dataset.getItemCount()); // 1 value pruned. // WITHOUT AUTOPRUNING DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true); dataset2.addSeries(createSeriesA()); assertEquals(2, dataset2.getItemCount()); // should be 2 items dataset2.addSeries(createSeriesB()); assertEquals(2, dataset2.getItemCount()); // still 2 dataset2.removeSeries(1); assertEquals(1, dataset2.getItemCount()); // still 2. } /** * Creates a series for testing. * * @return A series. */ private XYSeries createSeriesA() { XYSeries s = new XYSeries("A", true, false); s.add(1.0, 1.1); s.add(2.0, null); return s; } /** * Creates a series for testing. * * @return A series. */ private XYSeries createSeriesB() { XYSeries s = new XYSeries("B", true, false); s.add(1.0, null); s.add(2.0, 2.2); return s; } /** * Creates a series for testing. * * @return A series. */ private XYSeries createSeries1() { XYSeries series1 = new XYSeries("Series 1", true, false); series1.add(1.0, 1.0); series1.add(2.0, 1.0); series1.add(4.0, 1.0); series1.add(5.0, 1.0); return series1; } /** * Creates a series for testing. * * @return A series. */ private XYSeries createSeries2() { XYSeries series2 = new XYSeries("Series 2", true, false); series2.add(2.0, 2.0); series2.add(3.0, 2.0); series2.add(4.0, 2.0); series2.add(5.0, 2.0); series2.add(6.0, 2.0); return series2; } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/VectorDataItemTests.java0000644000175000017500000001165611173030414030446 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * VectorDataItemTests.java * ------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.VectorDataItem; /** * Tests for the {@link VectorDataItem} class. */ public class VectorDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(VectorDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public VectorDataItemTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); VectorDataItem v2 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); assertTrue(v1.equals(v2)); assertTrue(v2.equals(v1)); v1 = new VectorDataItem(1.1, 2.0, 3.0, 4.0); assertFalse(v1.equals(v2)); v2 = new VectorDataItem(1.1, 2.0, 3.0, 4.0); assertTrue(v1.equals(v2)); v1 = new VectorDataItem(1.1, 2.2, 3.0, 4.0); assertFalse(v1.equals(v2)); v2 = new VectorDataItem(1.1, 2.2, 3.0, 4.0); assertTrue(v1.equals(v2)); v1 = new VectorDataItem(1.1, 2.2, 3.3, 4.0); assertFalse(v1.equals(v2)); v2 = new VectorDataItem(1.1, 2.2, 3.3, 4.0); assertTrue(v1.equals(v2)); v1 = new VectorDataItem(1.1, 2.2, 3.3, 4.4); assertFalse(v1.equals(v2)); v2 = new VectorDataItem(1.1, 2.2, 3.3, 4.4); assertTrue(v1.equals(v2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); VectorDataItem v2 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); assertTrue(v1.equals(v2)); int h1 = v1.hashCode(); int h2 = v2.hashCode(); assertEquals(h1, h2); } /** * Check cloning. */ public void testCloning() { VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); VectorDataItem v2 = null; try { v2 = (VectorDataItem) v1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(v1 != v2); assertTrue(v1.getClass() == v2.getClass()); assertTrue(v1.equals(v2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); VectorDataItem v2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); v2 = (VectorDataItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(v1, v2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/VectorSeriesCollectionTests.java0000644000175000017500000001351711173030414032222 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------------- * VectorSeriesCollectionTests.java * -------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * 24-May-2007 : Added testRemoveSeries() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.VectorSeries; import org.jfree.data.xy.VectorSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link VectorSeriesCollection} class. */ public class VectorSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(VectorSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public VectorSeriesCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { VectorSeries s1 = new VectorSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); VectorSeriesCollection c1 = new VectorSeriesCollection(); c1.addSeries(s1); VectorSeries s2 = new VectorSeries("Series"); s2.add(1.0, 1.1, 1.2, 1.3); VectorSeriesCollection c2 = new VectorSeriesCollection(); c2.addSeries(s2); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); c1.addSeries(new VectorSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new VectorSeries("Empty Series")); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { VectorSeries s1 = new VectorSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); VectorSeriesCollection c1 = new VectorSeriesCollection(); c1.addSeries(s1); VectorSeriesCollection c2 = null; try { c2 = (VectorSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { VectorSeriesCollection d1 = new VectorSeriesCollection(); assertTrue(d1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { VectorSeries s1 = new VectorSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); VectorSeriesCollection c1 = new VectorSeriesCollection(); c1.addSeries(s1); VectorSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (VectorSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Some checks for the removeSeries() method. */ public void testRemoveSeries() { VectorSeries s1 = new VectorSeries("S1"); VectorSeries s2 = new VectorSeries("S2"); VectorSeriesCollection vsc = new VectorSeriesCollection(); vsc.addSeries(s1); vsc.addSeries(s2); assertEquals(2, vsc.getSeriesCount()); boolean b = vsc.removeSeries(s1); assertTrue(b); assertEquals(1, vsc.getSeriesCount()); assertEquals("S2", vsc.getSeriesKey(0)); b = vsc.removeSeries(new VectorSeries("NotInDataset")); assertFalse(b); assertEquals(1, vsc.getSeriesCount()); b = vsc.removeSeries(s2); assertTrue(b); assertEquals(0, vsc.getSeriesCount()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/VectorSeriesTests.java0000644000175000017500000002330411173030414030201 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * VectorSeriesTests.java * ---------------------- * (C) Copyright 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1, based on XYSeriesTests (DG); * 24-May-2007 : Updated for modified method names (DG); * 27-Nov-2007 : Added testClear() method (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.xy.VectorSeries; import org.jfree.data.xy.XYCoordinate; /** * Tests for the {@link VectorSeries} class. */ public class VectorSeriesTests extends TestCase implements SeriesChangeListener { SeriesChangeEvent lastEvent; /** * Records the last event. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(VectorSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public VectorSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { VectorSeries s1 = new VectorSeries("s1"); VectorSeries s2 = new VectorSeries("s1"); assertTrue(s1.equals(s2)); // seriesKey s1 = new VectorSeries("s2"); assertFalse(s1.equals(s2)); s2 = new VectorSeries("s2"); assertTrue(s1.equals(s2)); // autoSort s1 = new VectorSeries("s2", true, true); assertFalse(s1.equals(s2)); s2 = new VectorSeries("s2", true, true); assertTrue(s1.equals(s2)); // allowDuplicateValues s1 = new VectorSeries("s2", false, false); assertFalse(s1.equals(s2)); s2 = new VectorSeries("s2", false, false); assertTrue(s1.equals(s2)); // add a value s1.add(1.0, 0.5, 1.5, 2.0); assertFalse(s1.equals(s2)); s2.add(1.0, 0.5, 1.5, 2.0); assertTrue(s2.equals(s1)); // add another value s1.add(2.0, 0.5, 1.5, 2.0); assertFalse(s1.equals(s2)); s2.add(2.0, 0.5, 1.5, 2.0); assertTrue(s2.equals(s1)); // remove a value s1.remove(new XYCoordinate(1.0, 0.5)); assertFalse(s1.equals(s2)); s2.remove(new XYCoordinate(1.0, 0.5)); assertTrue(s2.equals(s1)); } /** * Confirm that cloning works. */ public void testCloning() { VectorSeries s1 = new VectorSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); VectorSeries s2 = null; try { s2 = (VectorSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { VectorSeries s1 = new VectorSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); VectorSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (VectorSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Simple test for the indexOf() method. */ public void testIndexOf() { VectorSeries s1 = new VectorSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(2.0, 2.0, 2.0, 3.0); s1.add(3.0, 3.0, 3.0, 4.0); assertEquals(0, s1.indexOf(new XYCoordinate(1.0, 1.0))); } /** * A check for the indexOf() method for an unsorted series. */ public void testIndexOf2() { VectorSeries s1 = new VectorSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(3.0, 3.0, 3.0, 3.0); s1.add(2.0, 2.0, 2.0, 2.0); assertEquals(0, s1.indexOf(new XYCoordinate(1.0, 1.0))); assertEquals(1, s1.indexOf(new XYCoordinate(3.0, 3.0))); assertEquals(2, s1.indexOf(new XYCoordinate(2.0, 2.0))); } /** * Simple test for the remove() method. */ public void testRemove() { VectorSeries s1 = new VectorSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(3.0, 3.0, 3.0, 3.0); s1.add(2.0, 2.0, 2.0, 2.0); assertEquals(3, s1.getItemCount()); s1.remove(new XYCoordinate(2.0, 2.0)); assertEquals(3.0, s1.getXValue(1), EPSILON); s1.remove(new XYCoordinate(1.0, 1.0)); assertEquals(3.0, s1.getXValue(0), EPSILON); } private static final double EPSILON = 0.0000000001; /** * When items are added with duplicate x-values, we expect them to remain * in the order they were added. */ public void testAdditionOfDuplicateXValues() { VectorSeries s1 = new VectorSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 1.0); s1.add(2.0, 2.0, 2.0, 2.0); s1.add(2.0, 2.0, 3.0, 3.0); s1.add(2.0, 3.0, 4.0, 4.0); s1.add(3.0, 5.0, 5.0, 5.0); assertEquals(1.0, s1.getVectorXValue(0), EPSILON); assertEquals(2.0, s1.getVectorXValue(1), EPSILON); assertEquals(3.0, s1.getVectorXValue(2), EPSILON); assertEquals(4.0, s1.getVectorXValue(3), EPSILON); assertEquals(5.0, s1.getVectorXValue(4), EPSILON); } /** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { VectorSeries series = new VectorSeries("Series", false, true); series.add(5.0, 5.50, 5.50, 5.50); series.add(5.1, 5.51, 5.51, 5.51); series.add(6.0, 6.6, 6.6, 6.6); series.add(3.0, 3.3, 3.3, 3.3); series.add(4.0, 4.4, 4.4, 4.4); series.add(2.0, 2.2, 2.2, 2.2); series.add(1.0, 1.1, 1.1, 1.1); assertEquals(5.5, series.getVectorXValue(0), EPSILON); assertEquals(5.51, series.getVectorXValue(1), EPSILON); assertEquals(6.6, series.getVectorXValue(2), EPSILON); assertEquals(3.3, series.getVectorXValue(3), EPSILON); assertEquals(4.4, series.getVectorXValue(4), EPSILON); assertEquals(2.2, series.getVectorXValue(5), EPSILON); assertEquals(1.1, series.getVectorXValue(6), EPSILON); } /** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { VectorSeries s1 = new VectorSeries("S1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(1.0, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3); assertEquals(2.0, s1.getXValue(0), EPSILON); assertEquals(3.0, s1.getXValue(1), EPSILON); } /** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { VectorSeries s1 = new VectorSeries("S1"); s1.add(1.0, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getXValue(0), EPSILON); assertEquals(3.0, s1.getXValue(1), EPSILON); } /** * Some checks for the clear() method. */ public void testClear() { VectorSeries s1 = new VectorSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(1.0, 2.0, 3.0, 4.0); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/VectorTests.java0000644000175000017500000001004011173030414027017 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * VectorTests.java * ---------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.Vector; /** * Tests for the {@link Vector} class. */ public class VectorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(VectorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public VectorTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances Vector v1 = new Vector(1.0, 2.0); Vector v2 = new Vector(1.0, 2.0); assertTrue(v1.equals(v2)); assertTrue(v2.equals(v1)); v1 = new Vector(1.1, 2.0); assertFalse(v1.equals(v2)); v2 = new Vector(1.1, 2.0); assertTrue(v1.equals(v2)); v1 = new Vector(1.1, 2.2); assertFalse(v1.equals(v2)); v2 = new Vector(1.1, 2.2); assertTrue(v1.equals(v2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Vector v1 = new Vector(1.0, 2.0); Vector v2 = new Vector(1.0, 2.0); assertTrue(v1.equals(v2)); int h1 = v1.hashCode(); int h2 = v2.hashCode(); assertEquals(h1, h2); } /** * Immutable class is not cloneable. */ public void testCloning() { Vector v1 = new Vector(1.0, 2.0); assertFalse(v1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { Vector v1 = new Vector(1.0, 2.0); Vector v2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); v2 = (Vector) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(v1, v2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XIntervalDataItemTests.java0000644000175000017500000001241611173030414031113 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * XIntervalDataItemTests.java * --------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XIntervalDataItem; /** * Tests for the {@link XIntervalDataItem} class. */ public class XIntervalDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XIntervalDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XIntervalDataItemTests(String name) { super(name); } private static final double EPSILON = 0.00000000001; /** * Some checks for the constructor. */ public void testConstructor1() { XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); assertEquals(new Double(1.0), item1.getX()); assertEquals(2.0, item1.getXLowValue(), EPSILON); assertEquals(3.0, item1.getXHighValue(), EPSILON); assertEquals(4.0, item1.getYValue(), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); XIntervalDataItem item2 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); // x item1 = new XIntervalDataItem(1.1, 2.0, 3.0, 4.0); assertFalse(item1.equals(item2)); item2 = new XIntervalDataItem(1.1, 2.0, 3.0, 4.0); assertTrue(item1.equals(item2)); // xLow item1 = new XIntervalDataItem(1.1, 2.2, 3.0, 4.0); assertFalse(item1.equals(item2)); item2 = new XIntervalDataItem(1.1, 2.2, 3.0, 4.0); assertTrue(item1.equals(item2)); // xHigh item1 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.0); assertFalse(item1.equals(item2)); item2 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.0); assertTrue(item1.equals(item2)); // y item1 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.4); assertFalse(item1.equals(item2)); item2 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.4); assertTrue(item1.equals(item2)); } /** * Some checks for the clone() method. */ public void testCloning() { XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); XIntervalDataItem item2 = null; try { item2 = (XIntervalDataItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); XIntervalDataItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (XIntervalDataItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XIntervalSeriesCollectionTests.java0000644000175000017500000001505211173030414032670 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * XIntervalSeriesCollectionTests.java * ----------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 18-Jan-2008 : Added testRemoveSeries() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XIntervalSeries; import org.jfree.data.xy.XIntervalSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XIntervalSeriesCollection} class. */ public class XIntervalSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XIntervalSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XIntervalSeriesCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); XIntervalSeriesCollection c2 = new XIntervalSeriesCollection(); assertEquals(c1, c2); // add a series XIntervalSeries s1 = new XIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); assertFalse(c1.equals(c2)); XIntervalSeries s2 = new XIntervalSeries("Series"); s2.add(1.0, 1.1, 1.2, 1.3); c2.addSeries(s2); assertTrue(c1.equals(c2)); // add an empty series c1.addSeries(new XIntervalSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new XIntervalSeries("Empty Series")); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); XIntervalSeries s1 = new XIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); XIntervalSeriesCollection c2 = null; try { c2 = (XIntervalSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); assertTrue(c1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); XIntervalSeries s1 = new XIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); XIntervalSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (XIntervalSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Some basic checks for the removeSeries() method. */ public void testRemoveSeries() { XIntervalSeriesCollection c = new XIntervalSeriesCollection(); XIntervalSeries s1 = new XIntervalSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); boolean pass = false; try { c.removeSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.removeSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * A test for bug report 1170825 (originally affected XYSeriesCollection, * this test is just copied over). */ public void test1170825() { XIntervalSeries s1 = new XIntervalSeries("Series1"); XIntervalSeriesCollection dataset = new XIntervalSeriesCollection(); dataset.addSeries(s1); try { /* XYSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XIntervalSeriesTests.java0000644000175000017500000002456011173030414030660 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * XIntervalSeriesTests.java * ------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1, based on XYSeriesTests (DG); * 27-Nov-2007 : Added testClear() method (DG); * 10-Apr-2008 : Added testGetXLowValue() and testGetXHighValue() (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.xy.XIntervalSeries; /** * Tests for the {@link XIntervalSeries} class. */ public class XIntervalSeriesTests extends TestCase implements SeriesChangeListener { SeriesChangeEvent lastEvent; /** * Records the last event. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XIntervalSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XIntervalSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XIntervalSeries s1 = new XIntervalSeries("s1"); XIntervalSeries s2 = new XIntervalSeries("s1"); assertTrue(s1.equals(s2)); // seriesKey s1 = new XIntervalSeries("s2"); assertFalse(s1.equals(s2)); s2 = new XIntervalSeries("s2"); assertTrue(s1.equals(s2)); // autoSort s1 = new XIntervalSeries("s2", false, true); assertFalse(s1.equals(s2)); s2 = new XIntervalSeries("s2", false, true); assertTrue(s1.equals(s2)); // allowDuplicateValues s1 = new XIntervalSeries("s2", false, false); assertFalse(s1.equals(s2)); s2 = new XIntervalSeries("s2", false, false); assertTrue(s1.equals(s2)); // add a value s1.add(1.0, 0.5, 1.5, 2.0); assertFalse(s1.equals(s2)); s2.add(1.0, 0.5, 1.5, 2.0); assertTrue(s2.equals(s1)); // add another value s1.add(2.0, 0.5, 1.5, 2.0); assertFalse(s1.equals(s2)); s2.add(2.0, 0.5, 1.5, 2.0); assertTrue(s2.equals(s1)); // remove a value s1.remove(new Double(1.0)); assertFalse(s1.equals(s2)); s2.remove(new Double(1.0)); assertTrue(s2.equals(s1)); } /** * Confirm that cloning works. */ public void testCloning() { XIntervalSeries s1 = new XIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); XIntervalSeries s2 = null; try { s2 = (XIntervalSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XIntervalSeries s1 = new XIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); XIntervalSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (XIntervalSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Simple test for the indexOf() method. */ public void testIndexOf() { XIntervalSeries s1 = new XIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(2.0, 2.0, 2.0, 3.0); s1.add(3.0, 3.0, 3.0, 4.0); assertEquals(0, s1.indexOf(new Double(1.0))); } /** * A check for the indexOf() method for an unsorted series. */ public void testIndexOf2() { XIntervalSeries s1 = new XIntervalSeries("Series 1", false, true); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(3.0, 3.0, 3.0, 3.0); s1.add(2.0, 2.0, 2.0, 2.0); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(3.0))); assertEquals(2, s1.indexOf(new Double(2.0))); } /** * Simple test for the remove() method. */ public void testRemove() { XIntervalSeries s1 = new XIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(2.0, 2.0, 2.0, 2.0); s1.add(3.0, 3.0, 3.0, 3.0); assertEquals(3, s1.getItemCount()); s1.remove(new Double(2.0)); assertEquals(new Double(3.0), s1.getX(1)); s1.remove(new Double(1.0)); assertEquals(new Double(3.0), s1.getX(0)); } private static final double EPSILON = 0.0000000001; /** * When items are added with duplicate x-values, we expect them to remain * in the order they were added. */ public void testAdditionOfDuplicateXValues() { XIntervalSeries s1 = new XIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 1.0); s1.add(2.0, 2.0, 2.0, 2.0); s1.add(2.0, 3.0, 3.0, 3.0); s1.add(2.0, 4.0, 4.0, 4.0); s1.add(3.0, 5.0, 5.0, 5.0); assertEquals(1.0, s1.getYValue(0), EPSILON); assertEquals(2.0, s1.getYValue(1), EPSILON); assertEquals(3.0, s1.getYValue(2), EPSILON); assertEquals(4.0, s1.getYValue(3), EPSILON); assertEquals(5.0, s1.getYValue(4), EPSILON); } /** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { XIntervalSeries series = new XIntervalSeries("Series", false, true); series.add(5.0, 5.50, 5.50, 5.50); series.add(5.1, 5.51, 5.51, 5.51); series.add(6.0, 6.6, 6.6, 6.6); series.add(3.0, 3.3, 3.3, 3.3); series.add(4.0, 4.4, 4.4, 4.4); series.add(2.0, 2.2, 2.2, 2.2); series.add(1.0, 1.1, 1.1, 1.1); assertEquals(5.5, series.getYValue(0), EPSILON); assertEquals(5.51, series.getYValue(1), EPSILON); assertEquals(6.6, series.getYValue(2), EPSILON); assertEquals(3.3, series.getYValue(3), EPSILON); assertEquals(4.4, series.getYValue(4), EPSILON); assertEquals(2.2, series.getYValue(5), EPSILON); assertEquals(1.1, series.getYValue(6), EPSILON); } /** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { XIntervalSeries s1 = new XIntervalSeries("S1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(1.0, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { XIntervalSeries s1 = new XIntervalSeries("S1"); s1.add(1.0, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Some checks for the clear() method. */ public void testClear() { XIntervalSeries s1 = new XIntervalSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(1.0, 2.0, 3.0, 4.0); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); } /** * A simple check for getXLowValue(). */ public void testGetXLowValue() { XIntervalSeries s1 = new XIntervalSeries("S1"); s1.add(1.0, 2.0, 3.0, 4.0); assertEquals(2.0, s1.getXLowValue(0), EPSILON); s1.add(2.0, 1.0, 4.0, 2.5); assertEquals(1.0, s1.getXLowValue(1), EPSILON); } /** * A simple check for getXHighValue(). */ public void testGetXHighValue() { XIntervalSeries s1 = new XIntervalSeries("S1"); s1.add(1.0, 2.0, 3.0, 4.0); assertEquals(3.0, s1.getXHighValue(0), EPSILON); s1.add(2.0, 1.0, 4.0, 2.5); assertEquals(4.0, s1.getXHighValue(1), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYBarDatasetTests.java0000644000175000017500000001330111173030414030053 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XYBarDatasetTests.java * ---------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Jan-2007 : Version 1 (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.XYBarDataset; import org.jfree.util.PublicCloneable; /** * Some tests for the {@link XYBarDataset} class. */ public class XYBarDatasetTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYBarDatasetTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYBarDatasetTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); DefaultXYDataset d2 = new DefaultXYDataset(); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d2.addSeries("S1", data2); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); XYBarDataset bd2 = new XYBarDataset(d2, 5.0); assertTrue(bd1.equals(bd2)); assertTrue(bd2.equals(bd1)); } /** * Confirm that cloning works. */ public void testCloning() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); XYBarDataset bd2 = null; try { bd2 = (XYBarDataset) bd1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(bd1 != bd2); assertTrue(bd1.getClass() == bd2.getClass()); assertTrue(bd1.equals(bd2)); // check independence d1 = (DefaultXYDataset) bd1.getUnderlyingDataset(); d1.addSeries("S2", new double[][] {{1.0}, {2.0}}); assertFalse(bd1.equals(bd2)); DefaultXYDataset d2 = (DefaultXYDataset) bd2.getUnderlyingDataset(); d2.addSeries("S2", new double[][] {{1.0}, {2.0}}); assertTrue(bd1.equals(bd2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); assertTrue(bd1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); XYBarDataset bd2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(bd1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); bd2 = (XYBarDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(bd1, bd2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYCoordinateTests.java0000644000175000017500000001027411173030414030136 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * XYCoordinateTests.java * ---------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 30-Jan-2007 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XYCoordinate; /** * Tests for the {@link XYCoordinate} class. */ public class XYCoordinateTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYCoordinateTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYCoordinateTests(String name) { super(name); } /** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances XYCoordinate v1 = new XYCoordinate(1.0, 2.0); XYCoordinate v2 = new XYCoordinate(1.0, 2.0); assertTrue(v1.equals(v2)); assertTrue(v2.equals(v1)); v1 = new XYCoordinate(1.1, 2.0); assertFalse(v1.equals(v2)); v2 = new XYCoordinate(1.1, 2.0); assertTrue(v1.equals(v2)); v1 = new XYCoordinate(1.1, 2.2); assertFalse(v1.equals(v2)); v2 = new XYCoordinate(1.1, 2.2); assertTrue(v1.equals(v2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYCoordinate v1 = new XYCoordinate(1.0, 2.0); XYCoordinate v2 = new XYCoordinate(1.0, 2.0); assertTrue(v1.equals(v2)); int h1 = v1.hashCode(); int h2 = v2.hashCode(); assertEquals(h1, h2); } /** * Immutable class is not cloneable. */ public void testCloning() { XYCoordinate v1 = new XYCoordinate(1.0, 2.0); assertFalse(v1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYCoordinate v1 = new XYCoordinate(1.0, 2.0); XYCoordinate v2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); v2 = (XYCoordinate) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(v1, v2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYDataItemTests.java0000644000175000017500000000767011173030414027545 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYDataItemTests.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Dec-2003 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XYDataItem; /** * Tests for the {@link XYDataItem} class. */ public class XYDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYDataItemTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYDataItem i1 = new XYDataItem(1.0, 1.1); XYDataItem i2 = new XYDataItem(1.0, 1.1); assertTrue(i1.equals(i2)); assertTrue(i2.equals(i1)); i1.setY(new Double(9.9)); assertFalse(i1.equals(i2)); i2.setY(new Double(9.9)); assertTrue(i1.equals(i2)); } /** * Confirm that cloning works. */ public void testCloning() { XYDataItem i1 = new XYDataItem(1.0, 1.1); XYDataItem i2 = null; try { i2 = (XYDataItem) i1.clone(); } catch (CloneNotSupportedException e) { System.err.println("XYDataItemTests.testCloning: failed to clone."); } assertTrue(i1 != i2); assertTrue(i1.getClass() == i2.getClass()); assertTrue(i1.equals(i2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYDataItem i1 = new XYDataItem(1.0, 1.1); XYDataItem i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); i2 = (XYDataItem) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(i1, i2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYIntervalDataItemTests.java0000644000175000017500000001415011173030414031241 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * XYIntervalDataItemTests.java * ---------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XYIntervalDataItem; /** * Tests for the {@link XYIntervalDataItem} class. */ public class XYIntervalDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYIntervalDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYIntervalDataItemTests(String name) { super(name); } private static final double EPSILON = 0.000000001; /** * Some checks for the constructor. */ public void testConstructor1() { XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertEquals(new Double(1.0), item1.getX()); assertEquals(0.5, item1.getXLowValue(), EPSILON); assertEquals(1.5, item1.getXHighValue(), EPSILON); assertEquals(2.0, item1.getYValue(), EPSILON); assertEquals(1.9, item1.getYLowValue(), EPSILON); assertEquals(2.1, item1.getYHighValue(), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); XYIntervalDataItem item2 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); // x item1 = new XYIntervalDataItem(1.1, 0.5, 1.5, 2.0, 1.9, 2.1); assertFalse(item1.equals(item2)); item2 = new XYIntervalDataItem(1.1, 0.5, 1.5, 2.0, 1.9, 2.1); assertTrue(item1.equals(item2)); // xLow item1 = new XYIntervalDataItem(1.1, 0.55, 1.5, 2.0, 1.9, 2.1); assertFalse(item1.equals(item2)); item2 = new XYIntervalDataItem(1.1, 0.55, 1.5, 2.0, 1.9, 2.1); assertTrue(item1.equals(item2)); // xHigh item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.0, 1.9, 2.1); assertFalse(item1.equals(item2)); item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.0, 1.9, 2.1); assertTrue(item1.equals(item2)); // y item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.9, 2.1); assertFalse(item1.equals(item2)); item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.9, 2.1); assertTrue(item1.equals(item2)); // yLow item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.1); assertFalse(item1.equals(item2)); item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.1); assertTrue(item1.equals(item2)); // yHigh item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.11); assertFalse(item1.equals(item2)); item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.11); assertTrue(item1.equals(item2)); } /** * Some checks for the clone() method. */ public void testCloning() { XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); XYIntervalDataItem item2 = null; try { item2 = (XYIntervalDataItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); XYIntervalDataItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (XYIntervalDataItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYIntervalSeriesCollectionTests.java0000644000175000017500000001573311173030414033027 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------------ * XYIntervalSeriesCollectionTests.java * ------------------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 13-Feb-2007 : Check for independence in testCloning() (DG); * 18-Jan-2008 : Added testRemoveSeries() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XYIntervalSeries; import org.jfree.data.xy.XYIntervalSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYIntervalSeriesCollection} class. */ public class XYIntervalSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYIntervalSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYIntervalSeriesCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); XYIntervalSeriesCollection c2 = new XYIntervalSeriesCollection(); assertEquals(c1, c2); // add a series XYIntervalSeries s1 = new XYIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); c1.addSeries(s1); assertFalse(c1.equals(c2)); XYIntervalSeries s2 = new XYIntervalSeries("Series"); s2.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); c2.addSeries(s2); assertTrue(c1.equals(c2)); // add an empty series c1.addSeries(new XYIntervalSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new XYIntervalSeries("Empty Series")); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); XYIntervalSeries s1 = new XYIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); XYIntervalSeriesCollection c2 = null; try { c2 = (XYIntervalSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence c1.addSeries(new XYIntervalSeries("Empty")); assertFalse(c1.equals(c2)); c2.addSeries(new XYIntervalSeries("Empty")); assertTrue(c1.equals(c2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); assertTrue(c1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); XYIntervalSeries s1 = new XYIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); XYIntervalSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (XYIntervalSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); // check independence c1.addSeries(new XYIntervalSeries("Empty")); assertFalse(c1.equals(c2)); c2.addSeries(new XYIntervalSeries("Empty")); assertTrue(c1.equals(c2)); } /** * Some basic checks for the removeSeries() method. */ public void testRemoveSeries() { XYIntervalSeriesCollection c = new XYIntervalSeriesCollection(); XYIntervalSeries s1 = new XYIntervalSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); boolean pass = false; try { c.removeSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.removeSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * A test for bug report 1170825 (originally affected XYSeriesCollection, * this test is just copied over). */ public void test1170825() { XYIntervalSeries s1 = new XYIntervalSeries("Series1"); XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); dataset.addSeries(s1); try { /* XYSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java0000644000175000017500000002513111173030414031004 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * XYIntervalSeriesTests.java * -------------------------- * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1, based on XYSeriesTests (DG); * 13-Feb-2007 : Added testValues() (DG); * 27-Nov-2007 : Added testClear() method (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.xy.XYIntervalSeries; /** * Tests for the {@link XYIntervalSeries} class. */ public class XYIntervalSeriesTests extends TestCase implements SeriesChangeListener { SeriesChangeEvent lastEvent; /** * Records the last event. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYIntervalSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYIntervalSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYIntervalSeries s1 = new XYIntervalSeries("s1"); XYIntervalSeries s2 = new XYIntervalSeries("s1"); assertTrue(s1.equals(s2)); // seriesKey s1 = new XYIntervalSeries("s2"); assertFalse(s1.equals(s2)); s2 = new XYIntervalSeries("s2"); assertTrue(s1.equals(s2)); // autoSort s1 = new XYIntervalSeries("s2", false, true); assertFalse(s1.equals(s2)); s2 = new XYIntervalSeries("s2", false, true); assertTrue(s1.equals(s2)); // allowDuplicateValues s1 = new XYIntervalSeries("s2", false, false); assertFalse(s1.equals(s2)); s2 = new XYIntervalSeries("s2", false, false); assertTrue(s1.equals(s2)); // add a value s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertFalse(s1.equals(s2)); s2.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertTrue(s2.equals(s1)); // add another value s1.add(2.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertFalse(s1.equals(s2)); s2.add(2.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertTrue(s2.equals(s1)); // remove a value s1.remove(new Double(1.0)); assertFalse(s1.equals(s2)); s2.remove(new Double(1.0)); assertTrue(s2.equals(s1)); } /** * Confirm that cloning works. */ public void testCloning() { XYIntervalSeries s1 = new XYIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.01); XYIntervalSeries s2 = null; try { s2 = (XYIntervalSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYIntervalSeries s1 = new XYIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); XYIntervalSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (XYIntervalSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Simple test for the indexOf() method. */ public void testIndexOf() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); s1.add(2.0, 2.0, 2.0, 3.0, 2.9, 3.1); s1.add(3.0, 3.0, 3.0, 4.0, 3.9, 4.1); assertEquals(0, s1.indexOf(new Double(1.0))); } /** * A check for the indexOf() method for an unsorted series. */ public void testIndexOf2() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1", false, true); s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); s1.add(3.0, 3.0, 3.0, 3.0, 2.9, 3.1); s1.add(2.0, 2.0, 2.0, 2.0, 1.9, 2.1); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(3.0))); assertEquals(2, s1.indexOf(new Double(2.0))); } /** * Simple test for the remove() method. */ public void testRemove() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); s1.add(2.0, 2.0, 2.0, 2.0, 1.9, 2.1); s1.add(3.0, 3.0, 3.0, 3.0, 2.9, 3.1); assertEquals(3, s1.getItemCount()); s1.remove(new Double(2.0)); assertEquals(new Double(3.0), s1.getX(1)); s1.remove(new Double(1.0)); assertEquals(new Double(3.0), s1.getX(0)); } private static final double EPSILON = 0.0000000001; /** * When items are added with duplicate x-values, we expect them to remain * in the order they were added. */ public void testAdditionOfDuplicateXValues() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 1.0, 1.0, 1.0); s1.add(2.0, 2.0, 2.0, 2.0, 2.0, 2.0); s1.add(2.0, 3.0, 3.0, 3.0, 3.0, 3.0); s1.add(2.0, 4.0, 4.0, 4.0, 4.0, 4.0); s1.add(3.0, 5.0, 5.0, 5.0, 5.0, 5.0); assertEquals(1.0, s1.getYValue(0), EPSILON); assertEquals(2.0, s1.getYValue(1), EPSILON); assertEquals(3.0, s1.getYValue(2), EPSILON); assertEquals(4.0, s1.getYValue(3), EPSILON); assertEquals(5.0, s1.getYValue(4), EPSILON); } /** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { XYIntervalSeries series = new XYIntervalSeries("Series", false, true); series.add(5.0, 5.50, 5.50, 5.50, 5.50, 5.50); series.add(5.1, 5.51, 5.51, 5.51, 5.51, 5.51); series.add(6.0, 6.6, 6.6, 6.6, 6.6, 6.6); series.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); series.add(4.0, 4.4, 4.4, 4.4, 4.4, 4.4); series.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); series.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); assertEquals(5.5, series.getYValue(0), EPSILON); assertEquals(5.51, series.getYValue(1), EPSILON); assertEquals(6.6, series.getYValue(2), EPSILON); assertEquals(3.3, series.getYValue(3), EPSILON); assertEquals(4.4, series.getYValue(4), EPSILON); assertEquals(2.2, series.getYValue(5), EPSILON); assertEquals(1.1, series.getYValue(6), EPSILON); } /** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3, 2.2, 2.2); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Some checks for the new accessor methods added in 1.0.5. */ public void testValues() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.add(2.0, 1.0, 3.0, 5.0, 4.0, 6.0); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(1.0, s1.getXLowValue(0), EPSILON); assertEquals(3.0, s1.getXHighValue(0), EPSILON); assertEquals(5.0, s1.getYValue(0), EPSILON); assertEquals(4.0, s1.getYLowValue(0), EPSILON); assertEquals(6.0, s1.getYHighValue(0), EPSILON); } /** * Some checks for the clear() method. */ public void testClear() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYIntervalTests.java0000644000175000017500000001056511173030414027636 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------- * XYIntervalTests.java * -------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.XYInterval; /** * Tests for the {@link XYInterval} class. */ public class XYIntervalTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYIntervalTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYIntervalTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); XYInterval i2 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); assertEquals(i1, i2); i1 = new XYInterval(1.1, 2.0, 3.0, 2.5, 3.5); assertFalse(i1.equals(i2)); i2 = new XYInterval(1.1, 2.0, 3.0, 2.5, 3.5); assertTrue(i1.equals(i2)); i1 = new XYInterval(1.1, 2.2, 3.0, 2.5, 3.5); assertFalse(i1.equals(i2)); i2 = new XYInterval(1.1, 2.2, 3.0, 2.5, 3.5); assertTrue(i1.equals(i2)); i1 = new XYInterval(1.1, 2.2, 3.3, 2.5, 3.5); assertFalse(i1.equals(i2)); i2 = new XYInterval(1.1, 2.2, 3.3, 2.5, 3.5); assertTrue(i1.equals(i2)); i1 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.5); assertFalse(i1.equals(i2)); i2 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.5); assertTrue(i1.equals(i2)); i1 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.6); assertFalse(i1.equals(i2)); i2 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.6); assertTrue(i1.equals(i2)); } /** * This class is immutable. */ public void testCloning() { XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); assertFalse(i1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); XYInterval i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (XYInterval) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java0000644000175000017500000002616411173030414031322 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * XYSeriesCollectionTests.java * ---------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-May-2003 : Version 1 (DG); * 27-Nov-2006 : Updated testCloning() (DG); * 08-Mar-2007 : Added testGetSeries() and testRemoveSeries() (DG); * 08-May-2007 : Added testIndexOf() (DG); * 03-Dec-2007 : Added testGetSeriesByKey() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * 06-Mar-2009 : Added testGetDomainBounds (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.Range; import org.jfree.data.UnknownKeyException; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link XYSeriesCollection} class. */ public class XYSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYSeriesCollectionTests(String name) { super(name); } private static final double EPSILON = 0.0000000001; /** * Some checks for the constructor. */ public void testConstructor() { XYSeriesCollection xysc = new XYSeriesCollection(); assertEquals(0, xysc.getSeriesCount()); assertEquals(1.0, xysc.getIntervalWidth(), EPSILON); assertEquals(0.5, xysc.getIntervalPositionFactor(), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeries s2 = new XYSeries("Series"); s2.add(1.0, 1.1); XYSeriesCollection c2 = new XYSeriesCollection(); c2.addSeries(s2); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); c1.addSeries(new XYSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new XYSeries("Empty Series")); assertTrue(c1.equals(c2)); c1.setIntervalWidth(5.0); assertFalse(c1.equals(c2)); c2.setIntervalWidth(5.0); assertTrue(c1.equals(c2)); c1.setIntervalPositionFactor(0.75); assertFalse(c1.equals(c2)); c2.setIntervalPositionFactor(0.75); assertTrue(c1.equals(c2)); c1.setAutoWidth(true); assertFalse(c1.equals(c2)); c2.setAutoWidth(true); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = null; try { c2 = (XYSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYSeriesCollection c1 = new XYSeriesCollection(); assertTrue(c1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (XYSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * A test for bug report 1170825. */ public void test1170825() { XYSeries s1 = new XYSeries("Series1"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); try { /* XYSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } } /** * Some basic checks for the getSeries() method. */ public void testGetSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries(0).getKey()); boolean pass = false; try { c.getSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.getSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some checks for the getSeries(Comparable) method. */ public void testGetSeriesByKey() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries("s1").getKey()); boolean pass = false; try { c.getSeries("s2"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { c.getSeries(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some basic checks for the removeSeries() method. */ public void testRemoveSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); boolean pass = false; try { c.removeSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.removeSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * Some tests for the indexOf() method. */ public void testIndexOf() { XYSeries s1 = new XYSeries("S1"); XYSeries s2 = new XYSeries("S2"); XYSeriesCollection dataset = new XYSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); XYSeries s2b = new XYSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); } /** * Some checks for the getDomainBounds() method. */ public void testGetDomainBounds() { XYSeriesCollection dataset = new XYSeriesCollection(); Range r = dataset.getDomainBounds(false); assertNull(r); r = dataset.getDomainBounds(true); assertNull(r); XYSeries series = new XYSeries("S1"); dataset.addSeries(series); r = dataset.getDomainBounds(false); assertNull(r); r = dataset.getDomainBounds(true); assertNull(r); series.add(1.0, 1.1); r = dataset.getDomainBounds(false); assertEquals(new Range(1.0, 1.0), r); r = dataset.getDomainBounds(true); assertEquals(new Range(0.5, 1.5), r); series.add(-1.0, -1.1); r = dataset.getDomainBounds(false); assertEquals(new Range(-1.0, 1.0), r); r = dataset.getDomainBounds(true); assertEquals(new Range(-1.5, 1.5), r); } /** * Some checks for the getRangeBounds() method. */ public void testGetRangeBounds() { XYSeriesCollection dataset = new XYSeriesCollection(); Range r = dataset.getRangeBounds(false); assertNull(r); r = dataset.getRangeBounds(true); assertNull(r); XYSeries series = new XYSeries("S1"); dataset.addSeries(series); r = dataset.getRangeBounds(false); assertNull(r); r = dataset.getRangeBounds(true); assertNull(r); series.add(1.0, 1.1); r = dataset.getRangeBounds(false); assertEquals(new Range(1.1, 1.1), r); r = dataset.getRangeBounds(true); assertEquals(new Range(1.1, 1.1), r); series.add(-1.0, -1.1); r = dataset.getRangeBounds(false); assertEquals(new Range(-1.1, 1.1), r); r = dataset.getRangeBounds(true); assertEquals(new Range(-1.1, 1.1), r); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/XYSeriesTests.java0000644000175000017500000005740511173030414027310 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * XYSeriesTests.java * ------------------ * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Dec-2003 : Version 1 (DG); * 15-Jan-2007 : Added tests for new toArray() method (DG); * 30-Jan-2007 : Fixed some code that won't compile with Java 1.4 (DG); * 31-Oct-2007 : New hashCode() test (DG); * 01-May-2008 : Added testAddOrUpdate3() (DG); * 24-Nov-2008 : Added testBug1955483() (DG); * 06-Mar-2009 : Added tests for cached bounds values (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesException; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.XYDataItem; import org.jfree.data.xy.XYSeries; /** * Tests for the {@link XYSeries} class. */ public class XYSeriesTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(XYSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public XYSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("Series"); s2.add(1.0, 1.1); assertTrue(s1.equals(s2)); assertTrue(s2.equals(s1)); s1.setKey("Series X"); assertFalse(s1.equals(s2)); s2.setKey("Series X"); assertTrue(s1.equals(s2)); s1.add(2.0, 2.2); assertFalse(s1.equals(s2)); s2.add(2.0, 2.2); assertTrue(s1.equals(s2)); } /** * Some simple checks for the hashCode() method. */ public void testHashCode() { XYSeries s1 = new XYSeries("Test"); XYSeries s2 = new XYSeries("Test"); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(1.0, 500.0); s2.add(1.0, 500.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(2.0, null); s2.add(2.0, null); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(5.0, 111.0); s2.add(5.0, 111.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); s1.add(9.0, 1.0); s2.add(9.0, 1.0); assertEquals(s1, s2); assertEquals(s1.hashCode(), s2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = null; try { s2 = (XYSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Another test of the clone() method. */ public void testCloning2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 100.0); s1.add(2.0, null); s1.add(3.0, 200.0); XYSeries s2 = null; try { s2 = (XYSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1.equals(s2)); // check independence s2.add(4.0, 300.0); assertFalse(s1.equals(s2)); s1.add(4.0, 300.0); assertTrue(s1.equals(s2)); } /** * Another test of the clone() method. */ public void testCloning3() { XYSeries s1 = new XYSeries("S1"); XYSeries s2 = null; try { s2 = (XYSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1.equals(s2)); // check independence s2.add(4.0, 300.0); assertFalse(s1.equals(s2)); s1.add(4.0, 300.0); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (XYSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Simple test for the indexOf() method. */ public void testIndexOf() { XYSeries s1 = new XYSeries("Series 1"); s1.add(1.0, 1.0); s1.add(2.0, 2.0); s1.add(3.0, 3.0); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(2.0))); assertEquals(2, s1.indexOf(new Double(3.0))); assertEquals(-4, s1.indexOf(new Double(99.9))); } /** * A check for the indexOf() method for an unsorted series. */ public void testIndexOf2() { XYSeries s1 = new XYSeries("Series 1", false, true); s1.add(1.0, 1.0); s1.add(3.0, 3.0); s1.add(2.0, 2.0); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(3.0))); assertEquals(2, s1.indexOf(new Double(2.0))); } /** * A check for the indexOf(Number) method when the series has duplicate * x-values. */ public void testIndexOf3() { XYSeries s1 = new XYSeries("Series 1"); s1.add(1.0, 1.0); s1.add(2.0, 2.0); s1.add(2.0, 3.0); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(2.0))); } /** * Simple test for the remove() method. */ public void testRemove() { XYSeries s1 = new XYSeries("Series 1"); s1.add(1.0, 1.0); s1.add(2.0, 2.0); s1.add(3.0, 3.0); assertEquals(3, s1.getItemCount()); s1.remove(new Double(2.0)); assertEquals(new Double(3.0), s1.getX(1)); s1.remove(0); assertEquals(new Double(3.0), s1.getX(0)); } /** * Some checks for the remove(int) method. */ public void testRemove2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.add(4.0, 4.4); s1.add(5.0, 5.5); s1.add(6.0, 6.6); assertEquals(6, s1.getItemCount()); assertEquals(1.0, s1.getMinX(), EPSILON); assertEquals(6.0, s1.getMaxX(), EPSILON); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(6.6, s1.getMaxY(), EPSILON); s1.remove(5); assertEquals(5, s1.getItemCount()); assertEquals(1.0, s1.getMinX(), EPSILON); assertEquals(5.0, s1.getMaxX(), EPSILON); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(5.5, s1.getMaxY(), EPSILON); } private static final double EPSILON = 0.0000000001; /** * When items are added with duplicate x-values, we expect them to remain * in the order they were added. */ public void testAdditionOfDuplicateXValues() { XYSeries s1 = new XYSeries("Series 1"); s1.add(1.0, 1.0); s1.add(2.0, 2.0); s1.add(2.0, 3.0); s1.add(2.0, 4.0); s1.add(3.0, 5.0); assertEquals(1.0, s1.getY(0).doubleValue(), EPSILON); assertEquals(2.0, s1.getY(1).doubleValue(), EPSILON); assertEquals(3.0, s1.getY(2).doubleValue(), EPSILON); assertEquals(4.0, s1.getY(3).doubleValue(), EPSILON); assertEquals(5.0, s1.getY(4).doubleValue(), EPSILON); } /** * Some checks for the update(Number, Number) method. */ public void testUpdate() { XYSeries series = new XYSeries("S1"); series.add(new Integer(1), new Integer(2)); assertEquals(new Integer(2), series.getY(0)); series.update(new Integer(1), new Integer(3)); assertEquals(new Integer(3), series.getY(0)); try { series.update(new Integer(2), new Integer(99)); assertTrue(false); } catch (SeriesException e) { // got the required exception } } /** * Some checks for the update() method for an unsorted series. */ public void testUpdate2() { XYSeries series = new XYSeries("Series", false, true); series.add(5.0, 55.0); series.add(4.0, 44.0); series.add(6.0, 66.0); series.update(new Double(4.0), new Double(99.0)); assertEquals(new Double(99.0), series.getY(1)); } /** * Some checks for the addOrUpdate() method. */ public void testAddOrUpdate() { XYSeries series = new XYSeries("S1", true, false); XYDataItem old = series.addOrUpdate(new Long(1), new Long(2)); assertTrue(old == null); assertEquals(1, series.getItemCount()); assertEquals(new Long(2), series.getY(0)); old = series.addOrUpdate(new Long(2), new Long(3)); assertTrue(old == null); assertEquals(2, series.getItemCount()); assertEquals(new Long(3), series.getY(1)); old = series.addOrUpdate(new Long(1), new Long(99)); assertEquals(new XYDataItem(new Long(1), new Long(2)), old); assertEquals(2, series.getItemCount()); assertEquals(new Long(99), series.getY(0)); assertEquals(new Long(3), series.getY(1)); } /** * Some checks for the addOrUpdate() method for an UNSORTED series. */ public void testAddOrUpdate2() { XYSeries series = new XYSeries("Series", false, false); series.add(5.0, 5.5); series.add(6.0, 6.6); series.add(3.0, 3.3); series.add(4.0, 4.4); series.add(2.0, 2.2); series.add(1.0, 1.1); series.addOrUpdate(new Double(3.0), new Double(33.3)); series.addOrUpdate(new Double(2.0), new Double(22.2)); assertEquals(33.3, series.getY(2).doubleValue(), EPSILON); assertEquals(22.2, series.getY(4).doubleValue(), EPSILON); } /** * Another test for the addOrUpdate() method. */ public void testAddOrUpdate3() { XYSeries series = new XYSeries("Series", false, true); series.addOrUpdate(1.0, 1.0); series.addOrUpdate(1.0, 2.0); series.addOrUpdate(1.0, 3.0); assertEquals(new Double(1.0), series.getY(0)); assertEquals(new Double(2.0), series.getY(1)); assertEquals(new Double(3.0), series.getY(2)); assertEquals(3, series.getItemCount()); } /** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { XYSeries series = new XYSeries("Series", false, true); series.add(5.0, 5.50); series.add(5.1, 5.51); series.add(6.0, 6.6); series.add(3.0, 3.3); series.add(4.0, 4.4); series.add(2.0, 2.2); series.add(1.0, 1.1); assertEquals(5.5, series.getY(0).doubleValue(), EPSILON); assertEquals(5.51, series.getY(1).doubleValue(), EPSILON); assertEquals(6.6, series.getY(2).doubleValue(), EPSILON); assertEquals(3.3, series.getY(3).doubleValue(), EPSILON); assertEquals(4.4, series.getY(4).doubleValue(), EPSILON); assertEquals(2.2, series.getY(5).doubleValue(), EPSILON); assertEquals(1.1, series.getY(6).doubleValue(), EPSILON); } /** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { XYSeries s1 = new XYSeries("S1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Check that the item bounds are determined correctly when there is a * maximum item count. */ public void testSetMaximumItemCount3() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.add(4.0, 4.4); s1.add(5.0, 5.5); s1.add(6.0, 6.6); s1.setMaximumItemCount(2); assertEquals(5.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(6.0, s1.getX(1).doubleValue(), EPSILON); assertEquals(5.0, s1.getMinX(), EPSILON); assertEquals(6.0, s1.getMaxX(), EPSILON); assertEquals(5.5, s1.getMinY(), EPSILON); assertEquals(6.6, s1.getMaxY(), EPSILON); } /** * Check that the item bounds are determined correctly when there is a * maximum item count. */ public void testSetMaximumItemCount4() { XYSeries s1 = new XYSeries("S1"); s1.setMaximumItemCount(2); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); assertEquals(2.0, s1.getMinX(), EPSILON); assertEquals(3.0, s1.getMaxX(), EPSILON); assertEquals(2.2, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); } /** * Some checks for the toArray() method. */ public void testToArray() { XYSeries s = new XYSeries("S1"); double[][] array = s.toArray(); assertEquals(2, array.length); assertEquals(0, array[0].length); assertEquals(0, array[1].length); s.add(1.0, 2.0); array = s.toArray(); assertEquals(1, array[0].length); assertEquals(1, array[1].length); assertEquals(2, array.length); assertEquals(1.0, array[0][0], EPSILON); assertEquals(2.0, array[1][0], EPSILON); s.add(2.0, null); array = s.toArray(); assertEquals(2, array.length); assertEquals(2, array[0].length); assertEquals(2, array[1].length); assertEquals(2.0, array[0][1], EPSILON); assertTrue(Double.isNaN(array[1][1])); } /** * Some checks for an example using the toArray() method. */ public void testToArrayExample() { XYSeries s = new XYSeries("S"); s.add(1.0, 11.0); s.add(2.0, 22.0); s.add(3.5, 35.0); s.add(5.0, null); DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("S", s.toArray()); assertEquals(1, dataset.getSeriesCount()); assertEquals(4, dataset.getItemCount(0)); assertEquals("S", dataset.getSeriesKey(0)); assertEquals(1.0, dataset.getXValue(0, 0), EPSILON); assertEquals(2.0, dataset.getXValue(0, 1), EPSILON); assertEquals(3.5, dataset.getXValue(0, 2), EPSILON); assertEquals(5.0, dataset.getXValue(0, 3), EPSILON); assertEquals(11.0, dataset.getYValue(0, 0), EPSILON); assertEquals(22.0, dataset.getYValue(0, 1), EPSILON); assertEquals(35.0, dataset.getYValue(0, 2), EPSILON); assertTrue(Double.isNaN(dataset.getYValue(0, 3))); } /** * Another test for the addOrUpdate() method. */ public void testBug1955483() { XYSeries series = new XYSeries("Series", true, true); series.addOrUpdate(1.0, 1.0); series.addOrUpdate(1.0, 2.0); assertEquals(new Double(1.0), series.getY(0)); assertEquals(new Double(2.0), series.getY(1)); assertEquals(2, series.getItemCount()); } /** * Some checks for the delete(int, int) method. */ public void testDelete() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.add(4.0, 4.4); s1.add(5.0, 5.5); s1.add(6.0, 6.6); s1.delete(2, 5); assertEquals(2, s1.getItemCount()); assertEquals(1.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(2.0, s1.getX(1).doubleValue(), EPSILON); assertEquals(1.0, s1.getMinX(), EPSILON); assertEquals(2.0, s1.getMaxX(), EPSILON); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(2.2, s1.getMaxY(), EPSILON); } /** * Some checks for the getMinX() method. */ public void testGetMinX() { XYSeries s1 = new XYSeries("S1"); assertTrue(Double.isNaN(s1.getMinX())); s1.add(1.0, 1.1); assertEquals(1.0, s1.getMinX(), EPSILON); s1.add(2.0, 2.2); assertEquals(1.0, s1.getMinX(), EPSILON); s1.add(Double.NaN, 99.9); assertEquals(1.0, s1.getMinX(), EPSILON); s1.add(-1.0, -1.1); assertEquals(-1.0, s1.getMinX(), EPSILON); s1.add(0.0, null); assertEquals(-1.0, s1.getMinX(), EPSILON); } /** * Some checks for the getMaxX() method. */ public void testGetMaxX() { XYSeries s1 = new XYSeries("S1"); assertTrue(Double.isNaN(s1.getMaxX())); s1.add(1.0, 1.1); assertEquals(1.0, s1.getMaxX(), EPSILON); s1.add(2.0, 2.2); assertEquals(2.0, s1.getMaxX(), EPSILON); s1.add(Double.NaN, 99.9); assertEquals(2.0, s1.getMaxX(), EPSILON); s1.add(-1.0, -1.1); assertEquals(2.0, s1.getMaxX(), EPSILON); s1.add(0.0, null); assertEquals(2.0, s1.getMaxX(), EPSILON); } /** * Some checks for the getMinY() method. */ public void testGetMinY() { XYSeries s1 = new XYSeries("S1"); assertTrue(Double.isNaN(s1.getMinY())); s1.add(1.0, 1.1); assertEquals(1.1, s1.getMinY(), EPSILON); s1.add(2.0, 2.2); assertEquals(1.1, s1.getMinY(), EPSILON); s1.add(Double.NaN, 99.9); assertEquals(1.1, s1.getMinY(), EPSILON); s1.add(-1.0, -1.1); assertEquals(-1.1, s1.getMinY(), EPSILON); s1.add(0.0, null); assertEquals(-1.1, s1.getMinY(), EPSILON); } /** * Some checks for the getMaxY() method. */ public void testGetMaxY() { XYSeries s1 = new XYSeries("S1"); assertTrue(Double.isNaN(s1.getMaxY())); s1.add(1.0, 1.1); assertEquals(1.1, s1.getMaxY(), EPSILON); s1.add(2.0, 2.2); assertEquals(2.2, s1.getMaxY(), EPSILON); s1.add(Double.NaN, 99.9); assertEquals(99.9, s1.getMaxY(), EPSILON); s1.add(-1.0, -1.1); assertEquals(99.9, s1.getMaxY(), EPSILON); s1.add(0.0, null); assertEquals(99.9, s1.getMaxY(), EPSILON); } /** * A test for the clear method. */ public void testClear() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); assertEquals(3, s1.getItemCount()); s1.clear(); assertEquals(0, s1.getItemCount()); assertTrue(Double.isNaN(s1.getMinX())); assertTrue(Double.isNaN(s1.getMaxX())); assertTrue(Double.isNaN(s1.getMinY())); assertTrue(Double.isNaN(s1.getMaxY())); } /** * Some checks for the updateByIndex() method. */ public void testUpdateByIndex() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); s1.updateByIndex(0, new Double(-5.0)); assertEquals(-5.0, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); s1.updateByIndex(0, null); assertEquals(2.2, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); s1.updateByIndex(2, null); assertEquals(2.2, s1.getMinY(), EPSILON); assertEquals(2.2, s1.getMaxY(), EPSILON); s1.updateByIndex(1, null); assertTrue(Double.isNaN(s1.getMinY())); assertTrue(Double.isNaN(s1.getMaxY())); } /** * Some checks for the updateByIndex() method. */ public void testUpdateByIndex2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, Double.NaN); assertTrue(Double.isNaN(s1.getMinY())); assertTrue(Double.isNaN(s1.getMaxY())); s1.updateByIndex(0, new Double(1.0)); assertEquals(1.0, s1.getMinY(), EPSILON); assertEquals(1.0, s1.getMaxY(), EPSILON); s1.updateByIndex(0, new Double(2.0)); assertEquals(2.0, s1.getMinY(), EPSILON); assertEquals(2.0, s1.getMaxY(), EPSILON); s1.add(-1.0, -1.0); s1.updateByIndex(0, new Double(0.0)); assertEquals(0.0, s1.getMinY(), EPSILON); assertEquals(2.0, s1.getMaxY(), EPSILON); } /** * Some checks for the updateByIndex() method. */ public void testUpdateByIndex3() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.updateByIndex(1, new Double(2.05)); assertEquals(1.1, s1.getMinY(), EPSILON); assertEquals(3.3, s1.getMaxY(), EPSILON); } /** * Some checks for the update(Number, Number) method. */ public void testUpdateXY() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, Double.NaN); assertTrue(Double.isNaN(s1.getMinY())); assertTrue(Double.isNaN(s1.getMaxY())); s1.update(new Double(1.0), new Double(1.0)); assertEquals(1.0, s1.getMinY(), EPSILON); assertEquals(1.0, s1.getMaxY(), EPSILON); s1.update(new Double(1.0), new Double(2.0)); assertEquals(2.0, s1.getMinY(), EPSILON); assertEquals(2.0, s1.getMaxY(), EPSILON); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/YIntervalDataItemTests.java0000644000175000017500000001242311173030414031112 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------------- * YIntervalDataItemTests.java * --------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.YIntervalDataItem; /** * Tests for the {@link YIntervalDataItem} class. */ public class YIntervalDataItemTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YIntervalDataItemTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YIntervalDataItemTests(String name) { super(name); } private static final double EPSILON = 0.00000000001; /** * Some checks for the constructor. */ public void testConstructor1() { YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 3.0, 4.0); assertEquals(new Double(1.0), item1.getX()); assertEquals(2.0, item1.getYValue(), EPSILON); assertEquals(3.0, item1.getYLowValue(), EPSILON); assertEquals(4.0, item1.getYHighValue(), EPSILON); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); YIntervalDataItem item2 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); assertTrue(item1.equals(item2)); assertTrue(item2.equals(item1)); // x item1 = new YIntervalDataItem(1.1, 2.0, 1.5, 2.5); assertFalse(item1.equals(item2)); item2 = new YIntervalDataItem(1.1, 2.0, 1.5, 2.5); assertTrue(item1.equals(item2)); // y item1 = new YIntervalDataItem(1.1, 2.2, 1.5, 2.5); assertFalse(item1.equals(item2)); item2 = new YIntervalDataItem(1.1, 2.2, 1.5, 2.5); assertTrue(item1.equals(item2)); // yLow item1 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.5); assertFalse(item1.equals(item2)); item2 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.5); assertTrue(item1.equals(item2)); // yHigh item1 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.55); assertFalse(item1.equals(item2)); item2 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.55); assertTrue(item1.equals(item2)); } /** * Some checks for the clone() method. */ public void testCloning() { YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); YIntervalDataItem item2 = null; try { item2 = (YIntervalDataItem) item1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(item1 != item2); assertTrue(item1.getClass() == item2.getClass()); assertTrue(item1.equals(item2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); YIntervalDataItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (YIntervalDataItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/YIntervalSeriesCollectionTests.java0000644000175000017500000001505211173030414032671 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------------------- * YIntervalSeriesCollectionTests.java * ----------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * 18-Jan-2008 : Added testRemoveSeries() (DG); * 22-Apr-2008 : Added testPublicCloneable (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.YIntervalSeries; import org.jfree.data.xy.YIntervalSeriesCollection; import org.jfree.util.PublicCloneable; /** * Tests for the {@link YIntervalSeriesCollection} class. */ public class YIntervalSeriesCollectionTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YIntervalSeriesCollectionTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YIntervalSeriesCollectionTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); YIntervalSeriesCollection c2 = new YIntervalSeriesCollection(); assertEquals(c1, c2); // add a series YIntervalSeries s1 = new YIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); assertFalse(c1.equals(c2)); YIntervalSeries s2 = new YIntervalSeries("Series"); s2.add(1.0, 1.1, 1.2, 1.3); c2.addSeries(s2); assertTrue(c1.equals(c2)); // add an empty series c1.addSeries(new YIntervalSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new YIntervalSeries("Empty Series")); assertTrue(c1.equals(c2)); } /** * Confirm that cloning works. */ public void testCloning() { YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); YIntervalSeries s1 = new YIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); YIntervalSeriesCollection c2 = null; try { c2 = (YIntervalSeriesCollection) c1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(c1 != c2); assertTrue(c1.getClass() == c2.getClass()); assertTrue(c1.equals(c2)); // check independence s1.setDescription("XYZ"); assertFalse(c1.equals(c2)); } /** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); assertTrue(c1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); YIntervalSeries s1 = new YIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); YIntervalSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (YIntervalSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); } /** * Some basic checks for the removeSeries() method. */ public void testRemoveSeries() { YIntervalSeriesCollection c = new YIntervalSeriesCollection(); YIntervalSeries s1 = new YIntervalSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); boolean pass = false; try { c.removeSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.removeSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); } /** * A test for bug report 1170825 (originally affected XYSeriesCollection, * this test is just copied over). */ public void test1170825() { YIntervalSeries s1 = new YIntervalSeries("Series1"); YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); dataset.addSeries(s1); try { /* XYSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/YIntervalSeriesTests.java0000644000175000017500000002317111173030414030656 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------- * YIntervalSeriesTests.java * ------------------------- * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1, based on XYSeriesTests (DG); * 27-Nov-2007 : Added testClear() method (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.general.SeriesChangeEvent; import org.jfree.data.general.SeriesChangeListener; import org.jfree.data.xy.YIntervalSeries; /** * Tests for the {@link YIntervalSeries} class. */ public class YIntervalSeriesTests extends TestCase implements SeriesChangeListener { SeriesChangeEvent lastEvent; /** * Records the last event. * * @param event the event. */ public void seriesChanged(SeriesChangeEvent event) { this.lastEvent = event; } /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YIntervalSeriesTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YIntervalSeriesTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { YIntervalSeries s1 = new YIntervalSeries("s1"); YIntervalSeries s2 = new YIntervalSeries("s1"); assertTrue(s1.equals(s2)); // seriesKey s1 = new YIntervalSeries("s2"); assertFalse(s1.equals(s2)); s2 = new YIntervalSeries("s2"); assertTrue(s1.equals(s2)); // autoSort s1 = new YIntervalSeries("s2", false, true); assertFalse(s1.equals(s2)); s2 = new YIntervalSeries("s2", false, true); assertTrue(s1.equals(s2)); // allowDuplicateValues s1 = new YIntervalSeries("s2", false, false); assertFalse(s1.equals(s2)); s2 = new YIntervalSeries("s2", false, false); assertTrue(s1.equals(s2)); // add a value s1.add(1.0, 0.5, 1.5, 2.0); assertFalse(s1.equals(s2)); s2.add(1.0, 0.5, 1.5, 2.0); assertTrue(s2.equals(s1)); // add another value s1.add(2.0, 0.5, 1.5, 2.0); assertFalse(s1.equals(s2)); s2.add(2.0, 0.5, 1.5, 2.0); assertTrue(s2.equals(s1)); // remove a value s1.remove(new Double(1.0)); assertFalse(s1.equals(s2)); s2.remove(new Double(1.0)); assertTrue(s2.equals(s1)); } /** * Confirm that cloning works. */ public void testCloning() { YIntervalSeries s1 = new YIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); YIntervalSeries s2 = null; try { s2 = (YIntervalSeries) s1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YIntervalSeries s1 = new YIntervalSeries("s1"); s1.add(1.0, 0.5, 1.5, 2.0); YIntervalSeries s2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(s1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); s2 = (YIntervalSeries) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(s1, s2); } /** * Simple test for the indexOf() method. */ public void testIndexOf() { YIntervalSeries s1 = new YIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(2.0, 2.0, 2.0, 3.0); s1.add(3.0, 3.0, 3.0, 4.0); assertEquals(0, s1.indexOf(new Double(1.0))); } /** * A check for the indexOf() method for an unsorted series. */ public void testIndexOf2() { YIntervalSeries s1 = new YIntervalSeries("Series 1", false, true); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(3.0, 3.0, 3.0, 3.0); s1.add(2.0, 2.0, 2.0, 2.0); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(3.0))); assertEquals(2, s1.indexOf(new Double(2.0))); } /** * Simple test for the remove() method. */ public void testRemove() { YIntervalSeries s1 = new YIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0); s1.add(2.0, 2.0, 2.0, 2.0); s1.add(3.0, 3.0, 3.0, 3.0); assertEquals(3, s1.getItemCount()); s1.remove(new Double(2.0)); assertEquals(new Double(3.0), s1.getX(1)); s1.remove(new Double(1.0)); assertEquals(new Double(3.0), s1.getX(0)); } private static final double EPSILON = 0.0000000001; /** * When items are added with duplicate x-values, we expect them to remain * in the order they were added. */ public void testAdditionOfDuplicateXValues() { YIntervalSeries s1 = new YIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 1.0); s1.add(2.0, 2.0, 2.0, 2.0); s1.add(2.0, 3.0, 3.0, 3.0); s1.add(2.0, 4.0, 4.0, 4.0); s1.add(3.0, 5.0, 5.0, 5.0); assertEquals(1.0, s1.getYValue(0), EPSILON); assertEquals(2.0, s1.getYValue(1), EPSILON); assertEquals(3.0, s1.getYValue(2), EPSILON); assertEquals(4.0, s1.getYValue(3), EPSILON); assertEquals(5.0, s1.getYValue(4), EPSILON); } /** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { YIntervalSeries series = new YIntervalSeries("Series", false, true); series.add(5.0, 5.50, 5.50, 5.50); series.add(5.1, 5.51, 5.51, 5.51); series.add(6.0, 6.6, 6.6, 6.6); series.add(3.0, 3.3, 3.3, 3.3); series.add(4.0, 4.4, 4.4, 4.4); series.add(2.0, 2.2, 2.2, 2.2); series.add(1.0, 1.1, 1.1, 1.1); assertEquals(5.5, series.getYValue(0), EPSILON); assertEquals(5.51, series.getYValue(1), EPSILON); assertEquals(6.6, series.getYValue(2), EPSILON); assertEquals(3.3, series.getYValue(3), EPSILON); assertEquals(4.4, series.getYValue(4), EPSILON); assertEquals(2.2, series.getYValue(5), EPSILON); assertEquals(1.1, series.getYValue(6), EPSILON); } /** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { YIntervalSeries s1 = new YIntervalSeries("S1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(1.0, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { YIntervalSeries s1 = new YIntervalSeries("S1"); s1.add(1.0, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); } /** * Some checks for the clear() method. */ public void testClear() { YIntervalSeries s1 = new YIntervalSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(1.0, 2.0, 3.0, 4.0); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/YIntervalTests.java0000644000175000017500000000762711173030414027513 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------- * YIntervalTests.java * ------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.YInterval; /** * Tests for the {@link YInterval} class. */ public class YIntervalTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YIntervalTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YIntervalTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { YInterval i1 = new YInterval(1.0, 0.5, 1.5); YInterval i2 = new YInterval(1.0, 0.5, 1.5); assertEquals(i1, i2); i1 = new YInterval(1.1, 0.5, 1.5); assertFalse(i1.equals(i2)); i2 = new YInterval(1.1, 0.5, 1.5); assertTrue(i1.equals(i2)); i1 = new YInterval(1.1, 0.55, 1.5); assertFalse(i1.equals(i2)); i2 = new YInterval(1.1, 0.55, 1.5); assertTrue(i1.equals(i2)); i1 = new YInterval(1.1, 0.55, 1.55); assertFalse(i1.equals(i2)); i2 = new YInterval(1.1, 0.55, 1.55); assertTrue(i1.equals(i2)); } /** * This class is immutable. */ public void testCloning() { YInterval i1 = new YInterval(1.0, 0.5, 1.5); assertFalse(i1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YInterval i1 = new YInterval(1.0, 0.5, 1.5); YInterval i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (YInterval) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/data/xy/junit/YWithXIntervalTests.java0000644000175000017500000001001611173030414030461 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------ * YWithXIntervalTests.java * ------------------------ * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-Oct-2006 : Version 1 (DG); * */ package org.jfree.data.xy.junit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jfree.data.xy.YWithXInterval; /** * Tests for the {@link YWithXInterval} class. */ public class YWithXIntervalTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(YWithXIntervalTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public YWithXIntervalTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); YWithXInterval i2 = new YWithXInterval(1.0, 0.5, 1.5); assertEquals(i1, i2); i1 = new YWithXInterval(1.1, 0.5, 1.5); assertFalse(i1.equals(i2)); i2 = new YWithXInterval(1.1, 0.5, 1.5); assertTrue(i1.equals(i2)); i1 = new YWithXInterval(1.1, 0.55, 1.5); assertFalse(i1.equals(i2)); i2 = new YWithXInterval(1.1, 0.55, 1.5); assertTrue(i1.equals(i2)); i1 = new YWithXInterval(1.1, 0.55, 1.55); assertFalse(i1.equals(i2)); i2 = new YWithXInterval(1.1, 0.55, 1.55); assertTrue(i1.equals(i2)); } /** * This class is immutable. */ public void testCloning() { YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); assertFalse(i1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); YWithXInterval i2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(i1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); i2 = (YWithXInterval) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(i1, i2); } } libjfreechart-java-1.0.13.orig/tests/org/jfree/experimental/0000755000175000017500000000000011173030414023667 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/experimental/chart/0000755000175000017500000000000011173030414024770 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/experimental/chart/renderer/0000755000175000017500000000000011173030414026576 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/experimental/chart/renderer/junit/0000755000175000017500000000000011173030414027727 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/experimental/chart/renderer/xy/0000755000175000017500000000000011173030414027236 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/tests/org/jfree/experimental/chart/renderer/xy/junit/0000755000175000017500000000000011173030414030367 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/ChangeLog0000644000175000017500000143537611173030414017743 0ustar vincentvincent---------- JFREECHART 1.0.13 RELEASED ------------------------ 2009-04-20 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (iterateToFindRangeBounds): Handle BoxAndWhiskerCategoryDataset. 2009-04-16 David Gilbert * source/org/jfree/chart/title/PaintScaleLegend.java (draw): Adjusted fill rectangles. 2009-04-16 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (CategoryAxis): Leave tick marks visible by default, (draw): Call drawTickMarks(), (drawTickMarks): New method, * source/org/jfree/chart/axis/CategoryAxis3D.java (draw): Call drawTickMarks(), * source/org/jfree/chart/axis/NumberAxis3D.java (NumberAxis3D): Leave axis line visible by default. 2009-04-16 David Gilbert Patch 2686872 by Peter Kolb: * source/org/jfree/chart/title/PaintScaleLegend.java: Implemented AxisChangeListener, (PaintScaleLegend): Register as axis change listener, (setAxis): Deregister as change listener on old axis, register as listener on new axis, (axisChanged): New method, (draw): Check isStripOutlineVisible flag. 2009-04-16 David Gilbert * source/org/jfree/chart/StandardChartTheme.java (baselinePaint): New field, (createDarknessTheme): Modify baselinePaint, (StandardChartTheme): Initialise baselinePaint, (getBaselinePaint): New method, (setBaselinePaint): Likewise, (applyToCategoryPlot): Apply baselinePaint, (applyToXYPlot): Likewise, (writeObject): Updated for new field, (readObject): Likewise. 2009-04-10 David Gilbert Bug 2740447: * source/org/jfree/chart/ChartPanel.java (paintComponent): Set chartBuffer background to match panel. 2009-04-09 David Gilbert * source/org/jfree/chart/StandardChartTheme.java (getSmallFont): New method, (setSmallFont): Likewise. 2009-04-09 David Gilbert * source/org/jfree/chart/ChartPanel.java: Implemented OverlayChangeListener, (overlays): New field, (ChartPanel): Initialise new field, (addOverlay): New method, (removeOverlay): New method, (overlayChanged): New method, (paintComponent): Draw overlays, * source/org/jfree/chart/event/OverlayChangeEvent.java: New file, * source/org/jfree/chart/event/OverlayChangeListener.java: New file, * source/org/jfree/chart/panel/AbstractOverlay.java: New file, * source/org/jfree/chart/panel/CrosshairOverlay.java: New file, * source/org/jfree/chart/panel/Overlay.java: New file, * source/org/jfree/chart/labels/CrosshairLabelGenerator.java: New file, * source/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java: New file, * source/org/jfree/chart/jxlayer/CrosshairLayerUI.java: Refactored class locations. 2009-04-08 David Gilbert * source/org/jfree/chart/ChartTransferable.java : New file, * source/org/jfree/chart/ChartPanel.java (COPY_COMMAND): New field, ChartPanel(JFreeChart, int, int, int, int, int, int, boolean, boolean, boolean, boolean, boolean, boolean, boolean)): New constructor, (actionPerformed): Check for copy action, (doCopy): Tranfer chart to clipboard, (createPopupMenu): New method. 2009-04-01 David Gilbert * source/org/jfree/chart/annotation/XYTextAnnotation.java (draw): Set font before calculating hotspot area. 2009-04-01 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (iterateToFindRangeBounds): Handle StatisticalCategoryDataset. 2009-04-01 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (addItemEntity): Check getItemCreateEntity(), (addEntity): New method, * source/org/jfree/chart/renderer/AbstractRenderer.java (defaultEntityRadius): New field, (AbstractRenderer): Initialise new field, (getDefaultEntityRadius): New method, (setDefaultEntityRadius): New method, (equals): Check new field, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (defaultEntityRadius): Moved to superclass, (getDefaultEntityRadius): Likewise, (setDefaultEntityRadius): Likewise, (equals): Moved check for defaultEntityRadius to superclass, * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (findRangeBounds): New method override, (drawItem): Use new addEntity() method. 2009-04-01 David Gilbert * source/org/jfree/chart/ChartPanel.java (panMask): New field, (ChartPanel): Initialise panMask differently on MacOSX, (mousePressed): Use panMask field, (mouseDragged): Fixed signs on drag percents. 2009-03-30 David Gilbert * source/org/jfree/chart/axis/LogAxis.java (pan): New method, * source/org/jfree/chart/axis/ValueAxis.java (pan): Likewise, * source/org/jfree/chart/plot/XYPlot.java (panDomainAxes): Delegate to axes, (panRangeAxes): Delegate to axes. 2009-03-28 David Gilbert * source/org/jfree/renderer/LookupPaintScale.java (PaintItem): Changed to static. 2009-03-28 David Gilbert * source/org/jfree/renderer/xy/AbstractXYItemRenderer.java (findRangeBounds): Handle case where plot is null. 2009-03-27 David Gilbert * source/org/jfree/renderer/xy/YIntervalRenderer.java (findRangeBounds): Use new inherited method. 2009-03-27 David Gilbert * source/org/jfree/renderer/RendererUtilities.java (findLiveItemsLowerBound): Fixed results for unsorted dataset, (findLiveItemsUpperBound): Likewise, (findLiveItems): Check case where upper index is less than lower. 2009-03-27 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (domainPannable): Change default to false, (rangePannable): Likewise, (rendererChanged): If series visibility changes, configure the axes, (panDomainAxes): Reconfigure the range axes, * source/org/jfree/chart/renderer/AbstractRenderer.java (dataBoundsIncludesVisibleSeriesOnly): New field, (setSeriesVisible(Boolean, boolean): Modified generated RendererEvent, (setSeriesVisible(int, Boolean, boolean): Likewise, (setBaseSeriesVisible): Likewise, (getDataBoundsIncludesVisibleSeriesOnly): New method, (setDataBoundsIncludesVisibleSeriesOnly): Likewise, (equals): Updated for new field, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (findRangeBounds(CategoryDataset)): Delegate to new method, (findRangeBounds(CategoryDataset, boolean)): Handle hidden series, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (findDomainBounds(XYDataset)): Delegate to new method, (findDomainBounds(XYDataset, boolean)): Handle hidden series, (findRangeBounds(XYDataset)): Delegate to new method, (findRangeBounds(XYDataset, boolean)): Handle hidden series, * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (findRangeBounds): Call new inherited method, * source/org/jfree/chart/renderer/xy/DeviationRenderer.java (findRangeBounds): Call new inherited method, * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java (findRangeBounds): New method override, * source/org/jfree/data/general/DatasetUtilities.java (findDomainBounds(XYDataset, List, boolean)): New method, (findRangeBounds(CategoryDataset, List, boolean)): Likewise, (findRangeBounds(XYDataset, List, Rangee, boolean)): Likewise, (iterateToFindRangeBounds(CategoryDataset, List, boolean)): Likewise, (iterateToFindDomainBounds(XYDataset, List, boolean)): Likewise, (iterateToFindRangeBounds(XYDataset, List, Range, boolean)): Likewise, * source/org/jfree/data/category/CategoryRangeInfo.java: New interface, * source/org/jfree/data/xy/XYDomainInfo.java: Likewise, * source/org/jfree/data/xy/XYRangeInfo.java: Likewise. 2009-03-26 David Gilbert * source/org/jfree/chart/ChartPanel.java (fillZoomRectangle): Change default to true, (mousePressed): Don't change cursor for panning unless panning is enabled. 2009-03-26 David Gilbert * source/org/jfree/chart/axis/ValueAxis.java (equals): Only check range if autoRange is false. 2009-03-26 David Gilbert * source/org/jfree/chart/event/RendererChangeEvent.java (seriesVisibilityChanged): New field, (RendererChangeEvent(Object)): Delegate to new constructor, (RendererChangeEvent(Object, boolean)): New constructor, (getSeriesVisibilityChanged): New method. 2009-03-26 David Gilbert * source/org/jfree/chart/MouseWheelHandler.java: Implemented Serializable. 2009-03-26 David Gilbert * source/org/jfree/chart/plot/FastScatterPlot.java: Implemented Pannable, (domainPannable): New field, (rangePannable): Likewise, (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): Use new resizeRange2() method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, plus use correct mouse coordinate, (isDomainPannable): New method, (setDomainPannable): Likewise, (isRangePannable): Likewise, (setRangePannable): Likewise, (panDomainAxes): Likewise, (panRangeAxes): Likewise, (equals): Updated for new fields. 2009-03-25 David Gilbert * source/org/jfree/chart/imagemap/ImageMapUtilities.java (javascriptEscape): Reimplemented, * tests/org/jfree/chart/imagemap/junit/ImageMapPackageTests.java (suite): Added new test classes, * tests/org/jfree/chart/imagemap/junit/DynamicDriveToolTipTagFragmentGeneratorTests.java: New file, * tests/org/jfree/chart/imagemap/junit/ImageMapUtilitiesTests.java: New file, * tests/org/jfree/chart/imagemap/junit/OverLIBToolTipTagFragmentGeneratorTests.java: New file. 2009-03-19 David Gilbert * source/org/jfree/chart/entity/AxisEntity.java: New class, * source/org/jfree/chart/entity/JFreeChartEntity.java: New class, * source/org/jfree/chart/entity/PlotEntity.java: New class, * source/org/jfree/chart/entity/TitleEntity.java: New class, * source/org/jfree/chart/axis/Axis.java: (createAndAddEntity): New method, * source/org/jfree/chart/axis/CategoryAxis.java: (draw): Add an entity for the axis, * source/org/jfree/chart/axis/DateAxis.java: (draw): Add an entity for the axis, * source/org/jfree/chart/axis/LogAxis.java: (draw): Add an entity for the axis, * source/org/jfree/chart/axis/NumberAxis.java: (draw): Add an entity for the axis, * source/org/jfree/chart/plot/CategoryPlot.java: (draw): Add an entity for the plot, * source/org/jfree/chart/plot/Plot.java: (createAndAddEntity): New method, * source/org/jfree/chart/plot/XYPlot.java: (draw): Add an entity for the plot, * source/org/jfree/chart/JFreeChart.java: (draw): Add an entity for the chart, * source/org/jfree/chart/title/LegendTitle.java: (draw): Add an entity for the title, * source/org/jfree/chart/title/TextTitle.java: (draw): Likewise. 2009-03-19 David Gilbert Bug 2690293: * source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java (generateToolTipFragment): Use javascriptEscape(), * source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java (generateToolTipFragment): Likewise, * source/org/jfree/chart/imagemap/ImageMapUtilities.java (javascriptEscape): New method. 2009-03-19 David Gilbert * source/org/jfree/chart/ChartPanel.java (panW): New field, (panH): Likewise, (panLast): Likewise, (mousePressed): Check for start of panning, (mouseDragged): Handle panning if it was started in mousePressed(), (mouseReleased): Reset panning, * source/org/jfree/chart/plot/CategoryPlot.java: Implemented Pannable, (rangePannable): New field, (isDomainPannable): New method, (isRangePannable): Likewise, (setRangePannable): Likewise, (panDomainAxes): Likewise, (panRangeAxes): Likewise, * source/org/jfree/chart/plot/Pannable.java: New interface, * source/org/jfree/chart/plot/XYPlot.java: Implemented Pannable, (domainPannable): New field, (rangePannable): Likewise, (isDomainPannable): New method, (setDomainPannable): Likewise, (isRangePannable): Likewise, (setRangePannable): Likewise, (panDomainAxes): Likewise, (panRangeAxes): Likewise. 2009-03-19 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer3D.java (drawRangeLine): New method override. 2009-03-18 David Gilbert * source/org/jfree/chart/ChartPanel.java (mouseWheelHandler): New field, (isMouseWheelEnabled): New method, (setMouseWheelEnabled): Likewise, * source/org/jfree/chart/MouseWheelHandler.java: New class, * source/org/jfree/chart/axis/ValueAxis.java (resizeRange2): New method, * source/org/jfree/chart/demo/BarChartDemo1.java (BarChartDemo1): Enable mouse wheel, * source/org/jfree/chart/demo/TimeSeriesChartDemo1.java (createDemoPanel): Enable mouse wheel, * source/org/jfree/chart/plot/CategoryPlot.java (zoomRangeAxes): Modify anchored zoom behaviour, * source/org/jfree/chart/plot/XYPlot.java (zoomDomainAxes): Likewise, (zoomRangeAxes): Likewise. 2009-03-15 David Gilbert * source/org/jfree/data/category/SlidingCategoryDataset.java (getColumnKeys): Fixed loop index. 2009-03-10 David Gilbert * source/org/jfree/chart/annotations/XYAnnotationBoundsInfo.java: New interface, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getAnnotations): New method, * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: Implemented XYAnnotationBoundsInfo interface, (includeInDataBounds): New field, (XYDataImageAnnotation(Image, double, double, double, double, boolean)): New constructor, (getIncludeInDataBounds): New method, (getXRange): Likewise, (getYRange): Likewise, (equals): Check new field, * source/org/jfree/chart/plot/XYPlot.java (getDataRange): Include annotation bounds. 2009-03-06 David Gilbert * source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java: New class. 2009-03-06 David Gilbert * source/org/jfree/data/xy/IntervalXYDelegate.java (hashCode): Implemented, * source/org/jfree/data/xy/XYSeriesCollection.java (equals): Include interval delegate. 2009-03-06 David Gilbert * source/org/jfree/data/xy/XYSeries.java (minX): New field, (maxX): Likewise, (minY): Likewise, (maxY): Likewise, (XYSeries): Initialise new fields, (getMinX): New method, (getMaxX): Likewise, (getMinY): Likewise, (getMaxY): Likewise, (updateBoundsForAddedItem): Likewise, (updateBoundsForRemovedItem): Likewise, (findBoundsByIteration): Likewise, (setMaximumItemcount): Refresh mins and maxes, (add): Likewise, (delete): Likewise, (remove): Likewise, (clear): Reset mins and maxes, (update): Update minY and maxY, (minIgnoreNaN): New method, (maxIgnoreNaN): Likewise, (update): Delegate to updateByIndex(); (addOrUpdate): Update mins and maxes, * source/org/jfree/data/xy/XYSeriesCollection.java: Implemented RangeInfo, (getDomainLowerBound): Use cached value in underlying series, (getDomainUpperBound): Likewise, (getDomainBounds): Likewise, (getRangeBounds): Implemented, (getRangeLowerBound): Likewise, (getRangeUpperBound): Likewise. 2009-03-02 David Gilbert * source/org/jfree/chart/axis/PeriodAxis.java (draw): Check tickMarksVisible and tickLabelsVisible, (drawTickMarksHorizontal): Removed unnecessary calendar references, (drawTickLabels): Likewise, (valueToJava2D): Likewise, (java2DtoValue): Likewise, * source/org/jfree/chart/axis/PeriodAxisLabelInfo.java (createInstance): Deprecated and added new method with locale argument. 2009-03-02 David Gilbert * source/org/jfree/chart/axis/PeriodAxis.java (locale): New field, (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod)): Delegate to new constructor, (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod, TimeZone)): Deprecated, (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod, TimeZone, Locale)): New constructor, (setFirst): Peg the time period, (setLast): Likewise, (setTimeZone): Peg first and last, (getLocale): New method, (setRange): Use locale, (drawTickMarksHorizontal): Likewise, (autoAdjustRange): Likewise, (equals): Check locale field, (createInstance): Added locale, * source/org/jfree/data/time/Day.java (Day(Date)): Delegate to new constructor, (Day(Date, TimeZone)): Deprecated, (Day(Date, TimeZone, Locale)): New constructor, * source/org/jfree/data/time/Hour.java (Hour(Date)): Delegate to new constructor, (Hour(Date, TimeZone)): Deprecated, (Hour(Date, TimeZone, Locale)): New constructor, * source/org/jfree/data/time/Millisecond.java (Millisecond(Date)): Delegate to new constructor, (Millisecond(Date, TimeZone)): Deprecated, (Millisecond(Date, TimeZone, Locale)): New constructor, * source/org/jfree/data/time/Minute.java (Minute(Date)): Delegate to new constructor, (Minute(Date, TimeZone)): Deprecated, (Minute(Date, TimeZone, Locale)): New constructor, * source/org/jfree/data/time/Second.java (Second(Date)): Delegate to new constructor, (Second(Date, TimeZone)): Deprecated, (Second(Date, TimeZone, Locale)): New constructor. 2009-02-27 David Gilbert * source/org/jfree/data/xy/XYSeriesCollection.java (getDomainOrder): New method override. 2009-02-27 David Gilbert Bug 2583891: * swt/org/jfree/experimental/swt/SWTGraphics2D.java (fillPolygon): Implemented. 2009-02-27 David Gilbert * source/org/jfree/data/general/CombinationDataset.java: Deprecated. 2009-02-27 David Gilbert Bug 2612649: * source/org/jfree/chart/editor/DefaultPlotEditor.java (DefaultPlotEditor): Added null Stroke to available options, (attemptOutlineStrokeSelection): Use current stroke. 2009-02-27 David Gilbert Bug 2617557: * source/org/jfree/chart/plot/dial/StandardDialScale.java (draw): Use tickLabelPaint. 2009-02-27 David Gilbert * source/org/jfree/chart/renderer/RendererUtilities.java (findLiveItemsLowerBound): Added argument checks, (findLiveItemsUpperBound): Correct calculation of mid. 2009-02-22 David Gilbert * source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java (paintBar): Use correct outline paint. 2009-02-13 David Gilbert * source/org/jfree/chart/jxlayer/Crosshair.java: New file, * source/org/jfree/chart/jxlayer/CrosshairLabelGenerator.java: New file, * source/org/jfree/chart/jxlayer/CrosshairLayerUI.java: New file, * source/org/jfree/chart/jxlayer/DefaultCrosshairLabelGenerator.java: New file, * source/org/jfree/chart/jxlayer/package.html: New file, * tests/org/jfree/chart/jxlayer/junit/CrosshairTests.java: New tests, * tests/org/jfree/chart/jxlayer/junit/JXLayerPackageTests.java: Likewise. 2009-02-12 David Gilbert * source/org/jfree/chart/annotations/XYPointerAnnotation.java (draw): Added support for rotated text, plus background paint and outline paint/stroke. 2009-02-12 David Gilbert * source/org/jfree/chart/annotations/XYTextAnnotation.java (backgroundPaint): New field, (outlineVisible): Likewise, (outlinePaint): Likewise, (outlineStroke): Likewise, (XYTextAnnotation): Initialise new fields, (getBackgroundPaint): New method, (setBackgroundPaint): Likewise, (getOutlinePaint): Likewise, (setOutlinePaint): Likewise, (getOutlineStroke): Likewise, (setOutlineStroke): Likewise, (isOutlineVisible): Likewuse, (setOutlineVisible): Likewise, (draw): Draw background and outline, (equals): Check new fields, (writeObject): Handle new fields, (readObject): Likewise. 2009-02-12 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (sampleFunction2D): Delegate to new method, (sampleFunction2DToSeries): New method, * source/org/jfree/data/function/NormalDistributionFunction2D.java (factor): New field, (denominator): Likewise, (NormalDistributionFunction2D): Initialise new fields, (getValue): Use precomputed constants. 2009-02-10 David Gilbert * source/org/jfree/chart/block/LabelBlock.java (contentAlignmentPoint): New field, (textAnchor): Likewise, (LabelBlock): Initialise new fields, (getContentAlignmentPoint): New method, (setContentAlignmentPoint): Likewise, (getTextAnchor): Likewise, (setTextAnchor): Likewise, (equals): Check new fields. 2009-02-05 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (barAlignmentFactor): New field, (XYBarRenderer): Initialise new field, (getBarAlignmentFactor): New method, (setBarAlignmentFactor): Likewise, (drawItem): Shift bar if alignment factor is set, (equals): Check new field. 2009-02-05 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (errorIndicatorStroke): New field, (StatisticalLineAndShapeREnderer): Initialise new field, (getErrorIndicatorStroke): New method, (setErrorIndicatorStroke): Likewise, (drawItem): Use errorIndicatorStroke, (equals): Check new field, (readObject): Handle new field, (writeObject): Likewise. 2009-02-04 David Gilbert * source/org/jfree/data/general/DefaultHeatMapDataset.java: New file, * source/org/jfree/data/general/HeatMapDataset.java: Likewise, * source/org/jfree/data/general/HeatMapUtilities.java: Likewise, * tests/org/jfree/data/general/junit/DefaultHeatMapDatasetTests.java: Likewise. 2009-02-04 David Gilbert * source/org/jfree/data/general/CombinedDataset.java: Deprecated, * source/org/jfree/data/general/SubSeriesDataset.java: Likewise. 2009-02-04 David Gilbert Bug 2564636: * source/org/jfree/data/time/Month.java (Month(Date, TimeZone, Locale)): Use locale. 2009-02-04 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (createStackedValueList): Deprecated, (createStackedValueList(CategoryDataset, Comparable, int[], double, boolean)): New method, (drawItem): Check for hidden series. 2009-02-04 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer.java (drawItem): Check for hidden series. 2009-02-04 David Gilbert * source/org/jfree/chart/renderer/category/CategoryItemRendererState.java (getVisibleSeriesArray()): New method, * source/org/jfree/chart/renderer/StackedAreaRenderer.java (drawItem): Fix handling of renderAsPercentages, (getStackValues): Likewise, * source/org/jfree/data/DataUtilities.java (calculateColumnTotal): New method, (calculateRowTotal): Likewise. 2009-02-04 David Gilbert * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java (drawItem): Generate entities only in first pass, and add call for drawing item labels in second pass. 2009-02-04 David Gilbert * source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java (findRangeBounds): Handle null dataset, * tests/org/jfree/chart/renderer/category/junit/WaterfallBarRendererTests.java (testFindRangeBounds): New tests. 2009-02-04 David Gilbert * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java (findRangeBounds): Check for null dataset, (drawItem): Return early if series is not visible, (getPreviousHeight): Deprecated as it is never used, * tests/org/jfree/chart/renderer/category/junit/StackedAreaRendererTests.java (testFindRangeBounds): New tests. 2009-02-03 David Gilbert * source/org/jfree/renderer/category/BarRenderer.java (defaultShadowsVisible): New field, (getDefaultShadowsVisible): New method, (setShadowsVisible): Likewise, * source/org/jfree/renderer/xy/XYBarRenderer.java (defaultShadowsVisible): New field, (getDefaultShadowsVisible): New method, (setShadowsVisible): Likewise. 2009-02-03 David Gilbert * source/org/jfree/renderer/category/StackedBarRenderer3D.java (findRangeBounds): Check for null dataset, * tests/org/jfree/chart/renderer/category/junit/StackedBarRenderer3DTests.java (testFindRangeBounds): New test. 2009-02-02 David Gilbert * source/org/jfree/chart/renderer/GrayPaintScale.java (alpha): New field, (GrayPaintScale(double, double)): Delegate to new constructor, (GrayPaintScale(double, double, int)): New constructor, (getAlpha): New method, (getPaint): Use alpha setting for returned paint, (equals): Check new field, (hashCode): New method, * tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java (testEquals): Check new field. 2009-01-28 David Gilbert * source/org/jfree/chart/renderer/xy/XYErrorRenderer.java (errorStroke): New field, (XYErrorRenderer): Initialise new field, (getErrorStroke): New method, (setErrorStroke): Likewise, (drawItem): Updated to use new errorStroke or else item outline stroke, (equals): Check new field, (readObject): Handle new field, (writeObject): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYErrorRendererTests.java (testEquals): Added check for errorStroke field, (testCloning2): New test, (testSerialization2): Likewise. 2009-01-28 David Gilbert * source/org/jfree/data/DataUtilities.java (clone(double[][]): New method, * tests/org/jfree/data/junit/DataUtilitiesTests.java (testClone): New method. 2009-01-28 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (equals): Fix shape test, * tests/org/jfree/chart/renderer/junit/AbstractRendererTests.java (testEquals): Modified to cover Shape.equals() bug. 2009-01-28 David Gilbert * source/org/jfree/data/DataUtilities.java (equal(double[][], double[][])): New method, * tests/org/jfree/data/junit/DataUtilitiesTests.java (testEqual): New method, (suite): Likewise, (main): Likewise. 2009-01-23 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): Put drawing code in separate passes. 2009-01-23 David Gilbert Patch 2511330 by Peter Kolb, plus hashCode method by DG: * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): Check useFillPaint and drawOutlines flags separately, (hashCode): New method. 2009-01-23 David Gilbert Patch 2511330 by Peter Kolb: * source/org/jfree/chart/renderer/category/LevelRenderer.java (calculateItemWidth): Take into account seriesVisible flags, (calculateBarW0): Likewise, (drawItem): Likewise. 2009-01-23 David Gilbert * source/org/jfree/chart/renderer/category/LevelRenderer.java (LevelRenderer): Set default legend shape, (hashCode): New method. 2009-01-21 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (medianVisible): New field, (meanVisible): Likewise, (BoxAndWhiskerRenderer): Initialise new fields, (isMeanVisible): New method, (setMeanVisible): Likewise, (isMedianVisible): New method, (setMedianVisible): Likewise, (drawHorizontalItem): Updated to check new flags, (drawVerticalItem): Likewise, (equals): Updated to check new fields, * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testEquals): Check new fields. 2009-01-21 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (drawRangeLine): New method, * source/org/jfree/chart/plot/CategoryPlot.java (rangeZeroBaselineVisible): New field, (rangeZeroBaselineStroke): Likewise, (rangeZeroBaselinePaint): Likewise, (rangeMinorGridlinesVisible): Likewise, (rangeMinorGridlineStroke): Likewise, (rangeMinorGridlinePaint): Likewise, (CategoryPlot): Initialise new fields and removed baseline marker, (isRangeZeroBaselineVisible): New method, (setRangeZeroBaselineVisible): Likewise, (getRangeZeroBaselineStroke): Likewise, (setRangeZeroBaselineStroke): Likewise, (getRangeZeroBaselinePaint): Likewise, (setRangeZeroBaselinePaint): Likewise, (isRangeMinorGridlinesVisible): Likewise, (setRangeMinorGridlinesVisible): Likewise, (getRangeMinorGridlineStroke): Likewise, (setRangeMinorGridlineStroke): Likewise, (getRangeMinorGridlinePaint): Likewise, (setRangeMinorGridlinePaint): Likewise, (draw): Add code to draw new zero range baseline, (drawRangeGridlines): Account for minor gridlines, (drawZeroRangeBaseline): New method, (equals): Updated for new fields, (writeObject): Likewise, (readObject): Likewise, * source/org/jfree/chart/axis/DateAxis.java (refreshTicksHorizontal): Check tick unit for minor tick count, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/LogAxis.java (LogAxis): Remove call to setMinorTickCount(), * source/org/jfree/chart/axis/NumberAxis.java (createStandardTickUnits): Initialise minor tick counts, (createIntegerTickUnits): Likewise, (refreshTicksHorizontal): Check tick unit for minor tick count, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/ValueAxis.java (ValueAxis): Set default minor tick count to zero, (setMinorTickCount): Remove argument check, * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java (testEquals): Check new fields. 2009-01-16 David Gilbert Bug 2490803: * source/org/jfree/chart/axis/PeriodAxis.java (getRange): Removed, rely on superclass implementation, (setRange): Update range with end points of whole periods, (drawTickMarksHorizontal): Include first and last ticks, * tests/org/jfree/chart/axis/junit/PeriodAxisTests.java (test2490803): New test method. 2009-01-16 David Gilbert * source/org/jfree/chart/ChartPanel.java (DEFAULT_BUFFER_USED): Changed default to true, (zoomOutlinePaint): New field, (zoomFillPaint): Likewise, (ChartPanel): Initialise new fields, (getZoomFillPaint): New method, (setZoomFillPaint): Likewise, (getZoomOutlinePaint): Likewise, (setZoomOutlinePaint): Likewise, (paintComponent): Update drawing of zoom rectangle, (mouseDragged): If useBuffer is true, repaint chart rather than using XOR for zoom rectangle, (mouseReleased): Likewise, (drawZoomRectangle): Only use XOR if useBuffer is false, (writeObject): Handle new fields, (readObject): Likewise. 2009-01-14 David Gilbert Patch 2497611 by Peter Kolb: * source/org/jfree/chart/axis/CategoryAxis.java (getCategorySeriesMiddle): New method, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (initialise): Record visible series indices, * source/org/jfree/chart/renderer/category/BarRenderer.java (calculateBarWidth): Look for visible series count in state, (calculateBarW0): Likewise, (drawItem): Use the visible row index, * source/org/jfree/chart/renderer/category/CategoryItemRendererState.java (visibleSeries): New field, (getVisibleSeriesIndex): New method, (getVisibleSeriesCount): Likewise, (setVisibleSeriesArray): Likewise, * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java (drawInterval): Use the visible row index, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/category/ScatterRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java (drawItem): Likewise, (drawHorizontalItem): Changed signature, (drawVerticalItem): Likewise, * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): Use the visible row index. 2009-01-14 David Gilbert * source/org/jfree/chart/axis/LogAxis.java (refreshTicksHorizontal): Read minorTickCount from the tick unit, (refreshTicksVertical): Likewise, (createLogTickUnits): Corrected the tick unit sizes and added minor tick counts, * source/org/jfree/chart/util/LogFormat.java (LogFormat): New constructor, (getExponentFormat): New method, (setExponentFormat): Likewise, (equals): Test formatter field, * tests/org/jfree/chart/util/junit/LogFormatTests.java (testEquals): Check formatter field. 2009-01-13 David Gilbert * source/org/jfree/chart/ChartPanel.java (zoomInDomain): Change notify flag to ensure plot sends only one event, (zoomInRange): Likewise, (zoomOutDomain): Likewise, (zoomOutRange): Likewise, (restoreAutoDomainBounds): Likewise, (restoreAutoRangeBounds): Likewise, * test/org/jfree/chart/junit/ChartPanelTests.java (test2502355_zoomInDomain): New test, (test2502355_zoomInRange): Likewise, (test2502355_zoomOutDomain): Likewise, (test2502355_zoomOutRange): Likewise, (test2502355_restoreAutoDomainBounds): Likewise, (test2502355_restoreAutoRangeBounds): Likewise. 2009-01-13 David Gilbert Bug 2502355: * source/org/jfree/chart/ChartPanel.java (zoomInBoth): Change notify flag to ensure plot sends only one event, (zoomOutBoth): Likewise, (zoom): Likewise, (restoreAutoBounds): Likewise, * source/org/jfree/chart/plot/Plot.java (notify): New field, (Plot): Initialise new field, (isNotify): New method, (setNotify): Likewise, (notifyListeners): Check notify flag, * tests/org/jfree/chart/junit/ChartPanelTests.java (chartChangeEvents): New field, (chartChanged): New method, (test2502355_zoom): New test, (test2502355_zoomInBoth): Likewise, (test2502355_zoomOutBoth): Likewise, (test2502355_restoreAutoBounds): Likewise. 2009-01-13 David Gilbert * source/org/jfree/data/time/TimeSeries.java (TimeSeries(Comparable, Class)): Deprecated, (TimeSeries(Comparable, String, String, Class)): Likewise, (TimeSeries(Comparable)): Delegate to new constructor, (TimeSeries(Comparable, String, String)): New constructor, (add): Update timePeriodClass if necessary, (addAndOrUpdate): Use new constructor, (addOrUpdate): Reset timePeriodClass if necessary, (removeAgedItems): Check for empty series, (clear): Reset timePeriodClass, (delete): Reset timePeriodClass if series is empty, (delete(int, int)): Likewise, (equals): Reorganised, * tests/org/jfree/data/time/junit/TimeSeriesTests.java (testEquals3): New test, (testRemoveAgedItems3): Likewise. 2009-01-09 David Gilbert * source/org/jfree/chart/plot/MultiplePiePlot.java (MultiplePiePlot): Set ignoreNullValues to true. 2009-01-09 David Gilbert * source/org/jfree/chart/axis/DateTickUnit.java (unit): Deprecated, (unitType): New field, (rollUnit): Deprecated, (rollUnitType): New field, (DateTickUnit): Deprecated existing constructors, replaced with new ones, (getUnitType): New method, (getRollUnitType): Likewise, (getCount): Renamed getMultiple(), (getRollCount): Renamed getRollMultiple(), (addToDate): Updated for new fields, (rollDate): Likewise, (getCalendarField): Likewise, (getMillisecondCount): Updated for new type, (intToUnitType): Utility method for deprecated constants, (unitTypeToInt): Likewise, (notNull): Utility method for deprecated constructor, (equals): Updated for new fields, (units): Removed, (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND): Deprecated, (getUnit): Deprecated, (getRollUnit): Likewise, * source/org/jfree/chart/axis/DateTickUnitType.java: New file. ---------- JFREECHART 1.0.12 RELEASED ------------------------ 2008-12-31 David Gilbert Bug 2471906: * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (drawItem): Check for dashed stroke and clip area manually for that case. 2008-12-30 David Gilbert * source/org/jfree/chart/plot/MultiplePiePlot.java (legendItemShape): New field, (MultiplePiePlot(CategoryDataset)): Initialise new field, (getLegendItemShape): New method, (setLegendItemShape): New method, (getLegendItems): Use new field, (equals): Check new field, (clone): Implemented, (readObject): Handle new field, (writeObject): Likewise. 2008-12-20 David Gilbert Bug 2452078: * source/org/jfree/chart/ChartFactory.java (createStackedAreaChart): Set category margin to zero. 2008-12-18 David Gilbert Patch 1607918 by Jess Thrysoee (with modifications): * source/org/jfree/chart/ChartPanel.java (localizationResources): Use ResourceBundleWrapper, * source/org/jfree/chart/JFreeChart.java (JFreeChartInfo()): Likewise, * source/org/jfree/chart/editor/DefaultAxisEditor.java, * source/org/jfree/chart/editor/DefaultChartEditor.java, * source/org/jfree/chart/editor/DefaultColorBarEditor.java, * source/org/jfree/chart/editor/DefaultNumberAxisEditor.java, * source/org/jfree/chart/editor/DefaultPlotEditor.java, * source/org/jfree/chart/editor/DefaultTitleEditor.java (localizationResources): Use ResourceBundleWrapper, * source/org/jfree/chart/plot/CategoryPlot.java, * source/org/jfree/chart/plot/ContourPlot.java, * source/org/jfree/chart/plot/FastScatterPlot.java, * source/org/jfree/chart/plot/MeterPlot.java, * source/org/jfree/chart/plot/PiePlot.java, * source/org/jfree/chart/plot/PolarPlot.java, * source/org/jfree/chart/plot/ThermometerPlot.java, * source/org/jfree/chart/plot/WaferMapPlot.java, * source/org/jfree/chart/plot/XYPlot.java (localizationResources): Use ResourceBundleWrapper, * source/org/jfree/chart/util/ResourceBundleWrapper.java: New class, * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java (DefaultIntervalCategoryDataset): Use ResourceBundleWrapper, * swt/org/jfree/experimental/chart/swt/ChartComposite.java, * swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java, * swt/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java, * swt/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java, * swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java, * swt/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java, * swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java (localizationResources): Use ResourceBundleWrapper. 2008-12-03 David Gilbert * source/org/jfree/chart/block/GridArrangement.java (arrange): Fill in missing constraint combinations, (arrangeNN): Check for null block, (arrangeFF): Likewise, (arrangeRF): New method, (arrangeRN): Likewise, (arrangeNR): Likewise, (arrangeRR): Likewise, (arrangeFN): Check for null block, (arrangeNF): New method, * tests/org/jfree/chart/block/junit/GridArrangementTests.java: Added various new tests. 2008-11-25 David Gilbert Bug fix 2201869 by Fawad Halim (with modifications): * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): Use new Month constructor, (correctTickDateForPosition): New private method, (refreshTicksHorizontal): Moved position correction to top of loop, (refreshTicksVertical): Likewise, * source/org/jfree/data/time/Month.java (Month(Date, TimeZone)): Deprecated, (Month(Date, TimeZone, Locale)): New constructor, * source/org/jfree/data/time/Quarter.java (Quarter(Date, TimeZone)): Deprecated, (Quarter(Date, TimeZone, Locale)): New constructor, * source/org/jfree/data/time/Year.java (Year(Date, TimeZone)): Deprecated, (Year(Date, TimeZone, Locale)): New constructor. 2008-11-25 David Gilbert Based on patch 1868749 by Andrew Mickish: * source/org/jfree/chart/plot/CategoryPlot.java (datasetToDomainAxisMap): Changed from ObjectList to TreeMap, (datasetToRangeAxisMap): Likewise, (CategoryPlot): Updated initialization of modified fields, (mapDatasetToDomainAxis): Delegate to new method, (mapDatasetToDomainAxes): New method, (checkAxisIndices): New private method, (getDomainAxisForDataset): Updated for multiple axis support, (mapDatasetToRangeAxis): Delegate to new method, (mapDatasetToRangeAxes): New method, (getRangeAxisForDataset): Updated for multiple axis support, (datasetsMappedToDomainAxis): Likewise, (datasetsMappedToRangeAxis): Likewise, (equals): Updated for field changes, (clone): Likewise, * source/org/jfree/chart/plot/XYPlot.java (datasetToDomainAxisMap): Renamed, (datasetToRangeAxisMap): Renamed, (XYPlot): Updated for renamed fields, (mapDatasetToDomainAxis): Delegate to new method, (mapDatasetToDomainAxes): New method, (mapDatasetToRangeAxis): Delegate to new method, (mapDatasetToRangeAxes): New method, (checkAxisIndices): New private method, (getDomainAxisForDataset): Updated for multiple axis support, (getRangeAxisForDataset): Likewise, (getDatasetsMappedToDomainAxis): Likewise, (getDatasetsMappedToRangeAxis): Likewise, (equals): Updated for field changes, (clone): Likewise. 2008-11-25 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (findRangeBounds): Check for null argument, * source/org/jfree/chart/renderer/category/BarRenderer.java (findRangeBounds): Likewise, * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java (findRangeBounds): Likewise, * source/org/jfree/chart/renderer/category/StackedBarRenderer.java (findRangeBounds): Likewise. 2008-11-24 David Gilbert Bug 1955483: * source/org/jfree/data/xy/XYSeries.java (addOrUpdate): Check early for duplicates allowed, * tests/org/jfree/data/xy/junit/XYSeriesTests.java (testBug1955483): New test. 2008-11-18 David Gilbert Bug 2216511: * swt/org/jfree/experimental/chart/demo/SWTBarChartDemo1.java (createChart): Reset the bar painter to avoid using gradients, * swt/org/jfree/experimental/swt/SWTGraphics2D.java (setPaint): Don't fail for GradientPaint. 2008-11-13 David Gilbert Bug 2275695: * source/org/jfree/chart/axis/SubCategoryAxis.java (drawSubCategoryLabels): Check for null, * tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java (test2275695): New method. 2008-11-05 David Gilbert Bug 2221495: * source/org/jfree/chart/annotations/XYLineAnnotation.java (draw): Clip line before drawing, * source/org/jfree/chart/util/LineUtilities.java: New file, * tests/org/jfree/chart/util/junit/LineUtilitiesTests.java: Likewise. 2008-10-27 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (refreshTicks): Set correct for for category label. 2008-10-23 David Gilbert * source/org/jfree/chart/ChartFactory.java (setChartTheme): Check if theme is "Legacy" and reset default bar painters. 2008-10-15 David Gilbert * source/org/jfree/chart/LegendItem.java (LegendItem(String, Paint)): New constructor. 2008-10-08 David Gilbert Incorporating patch 2131001: * source/org/jfree/data/general/DatasetUtilities.java (iterateDomainBounds(XYDataset, boolean)): Ignore Double.NaN values, (iterateRangeBounds(CategoryDataset, boolean)): Likewise, (findStackedRangeBounds(CategoryDataset, KeyToGroupMap)): Cleanup, (findMinimumStackedRangeValue(CategoryDataset)): Likewise, (findMaximumStackedRangeValue(CategoryDataset)): Likewise, (findCumulativeRangeBounds(CategoryDataset)): Likewise. 2008-10-08 David Gilbert * source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java (equals): New method override, * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java (equals): New method override. 2008-10-02 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawItem): Check item visibility. 2008-09-26 David Gilbert * source/org/jfree/chart/axis/Axis.java (fireChangeEvent): New method, also updated various other methods to call fireChangeEvent(). 2008-09-26 David Gilbert * source/org/jfree/chart/renderer/category/WaterfallRenderer.java (drawItem): Fixed bar misalignment when maxBarWidth is applied. 2008-09-26 David Gilbert * source/org/jfree/chart/renderer/xy/VectorRenderer.java (drawItem): Add chart entity. 2008-09-25 David Gilbert Patch 1934255 (incorporating 1870189): * source/org/jfree/chart/axis/Axis.java (minorTickMarksVisible): New field, (minorTickMarkInsideLength): New field, (minorTickMarkOutsideLength): New field, (Axis(String)): Initialise new fields, (isMinorTickMarksVisible): New method, (setMinorTickMarksVisible): Likewise, (getMinorTickMarkInsideLength): Likewise, (setMinorTickMarkInsideLength): Likewise, (getMinorTickMarkOutsideLength): Likewise, (setMinorTickMarkOutsideLength): Likewise, * source/org/jfree/chart/axis/DateAxis.java (refreshTicksHorizontal): Add minor ticks, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/DateTick.java (DateTick): New constructor, (equals): Clean up, * source/org/jfree/chart/axis/LogAxis.java (minorTickCount): Removed (now in superclass), (LogAxis(String)): Updated for removed field, (getMinorTickCount): Removed (now in superclass), (setMinorTickCount): Likewise, (refreshTicksHorizontal): Updated for removed field, (refreshTicksVertical): Likewise, (equals): Likewise, (hashCode): Likewise, * source/org/jfree/chart/axis/NumberAxis.java (refreshTicksHorizontal): Add minor ticks, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/ValueAxis.java (minorTickCount): New field, (drawTickMarksAndLabels): Draw minor ticks, (getMinorTickCount): New method, (setMinorTickCount): Likewise, (equals): Updated for new field, * source/org/jfree/chart/plot/XYPlot.java (domainMinorGridlinesVisible): New field, (domainMinorGridlineStroke): Likewise, (domainMinorGridlinePaint): Likewise, (rangeMinorGridlinesVisible): Likewise, (rangeMinorGridlineStroke): Likewise, (rangeMinorGridlinePaint): Likewise, (XYPlot): Initialise new fields, (isDomainMinorGridlinesVisible): New method, (setDomainMinorGridlinesVisible): Likewise, (getDomainMinorGridlineStroke): Likewise, (setDomainMinorGridlineStroke): Likewise, (getDomainMinorGridlinePaint): Likewise, (setDomainMinorGridlinePaint): Likewise, (isRangeMinorGridlinesVisible): Likewise, (setRangeMinorGridlinesVisible): Likewise, (getRangeMinorGridlineStroke): Likewise, (setRangeMinorGridlineStroke): Likewise, (getRangeMinorGridlinePaint): Likewise, (setRangeMinorGridlinePaint): Likewise, (drawDomainGridlines): Draw minor gridlines too, (drawRangeGridlines): Likewise, (equals): Updated for new attributes, (writeObject): Likewise, (readObject): Likewise, * tests/org/jfree/chart/axis/junit/AxisTests.java (testEquals): Updated for new field, * tests/org/jfree/chart/axis/junit/DateTickTests.java (testEquals): Updated for new field, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testEquals): Updated for new fields. 2008-09-25 David Gilbert * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (drawItem): Check for non-null entity collection. 2008-09-24 David Gilbert Bug 2113627 * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Draw item labels in second pass only, add chart entity info in first pass only. 2008-09-23 David Gilbert Bug 2121818 (fix by Christoph Beck): * source/org/jfree/chart/plot/PiePlot.java (getLabelLinkDepth): New method, (drawLeftLabels): Use getLabelLinkDepth(), (drawRightLabels): Likewise, * source/org/jfree/chart/plot/RingPlot.java (getLabelLinkDepth): New method. 2008-09-23 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java (drawItem): Check shadow visibility before drawing shadow. ---------- JFREECHART 1.0.11 RELEASED ------------------------ 2008-09-19 David Gilbert Patch from Greg Darke, slightly modified: * source/org/jfree/chart/renderer/xy/XYItemRendererState.java (firstItemIndex): New field, (lastItemIndex): Likewise, (getFirstItemIndex): New method, (getLastItemIndex): New method, (startSeriesPass): Record first and last item indices, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (State.startSeriesPass): Reset series state, (drawItem): Removed code that is handled in State now, (drawPrimaryLineAsPath): Fix check for last item. 2008-09-19 David Gilbert * source/org/jfree/chart/StandardChartTheme.java (smallFont): New field, (crosshairPaint): New field, (createDarknessTheme): Initialise crosshairPaint, (StandardChartTheme): Initialise new fields, (getCrosshairPaint): New method, (setCrosshairPaint): Likewise, (applyToXYPlot): Apply crosshair paint and process annotations, (applyToXYAnnotation): New method, (equals): Check new fields, (writeObject): Handle crosshairPaint, (readObject): Likewise. 2008-09-19 David Gilbert * source/org/jfree/chart/JFreeChart.java (draw): Check title visibility, * source/org/jfree/chart/title/Title.java (visible): New field, (isVisible): New method, (setVisible): Likewise, (equals): Check visible flag. 2008-08-18 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (locale): New field, (DateAxis(String, TimeZone, Locale)): New constructor, (setTimeZone): Updated to use new locale field, (previousStandardDate): Likewise, (createStandardDateTickUnits(TimeZone)): Deprecated, (createStandardDateTickUnits(TimeZone, Locale)): New method. 2008-09-18 David Gilbert * source/org/jfree/chart/ChartPanel.java (paintComponent): Modified chart buffer creation. 2008-09-18 David Gilbert * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java: New class, * tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java: New tests, * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java (suite): Added XYShapeRendererTests. 2008-09-17 David Gilbert * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: New class. 2008-09-17 David Gilbert * source/org/jfree/chart/title/PaintScaleLegend.java (PaintScaleLegend(PaintScale, ValueAxis)): Change axis range to reflect scale bounds. 2008-09-17 David Gilbert * source/org/jfree/data/gantt/XYTaskDataset.java: New class, * tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java (suite): Added XYTaskDatasetTests, * tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java: New file. 2008-09-16 David Gilbert * source/org/jfree/data/time/Day.java (Day(Date)): Use TimeZone.getDefault(), * source/org/jfree/data/time/Hour.java (Hour(Date)): Likewise, * source/org/jfree/data/time/Millisecond.java (Millisecond(Date)): Likewise, * source/org/jfree/data/time/Minute.java (Minute(Date)): Likewise, * source/org/jfree/data/time/Month.java (Month(Date)): Likewise, (parseMonth): Updated for changes in Year range, * source/org/jfree/data/time/Quarter.java (Quarter(Date)): Use TimeZone.getDefault(), * source/org/jfree/data/time/RegularTimePeriod.java (DEFAULT_TIME_ZONE): Deprecated, * source/org/jfree/data/time/Second.java (Second(Date)): Use TimeZone.getDefault(), * source/org/jfree/data/time/Week.java (Week(Date)): Likewise, * source/org/jfree/data/time/Year.java (MINIMUM_YEAR): New field, (MAXIMUM_YEAR): Likewise, (Year(int)): Updated range check, (Year(Date)): Use TimeZone.getDefault(), (previous): Updated for new range bounds, (next): Likewise, (equals): Cleaned up, * tests/org/jfree/data/time/junit/YearTests.java (testEquals): Extended, (test1900Previous): Modified and enamed testMinus9999Previous, (testParseYear): Updated. 2008-09-10 David Gilbert * source/org/jfree/chart/StandardChartTheme.java (applyToCategoryAxis): Check for SubCategoryAxis and set sublabel font and paint. 2008-09-03 David Gilbert * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: Moved to main, * experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java Likewise, * experimental/org/jfree/experimental/chart/util/XYCoordinateType.java Likewise, * source/org/jfree/chart/annotation/XYTitleAnnotation.java: Transferred from experimental, * source/org/jfree/chart/util/XYCoordinateType.java: Likewise, * tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java (suite): Added tests for XYTitleAnnotation, * tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java: New file. 2008-09-01 David Gilbert Bug 2078057: * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): For month option, peg in case of non-default time zone, * source/org/jfree/data/time/Month.java (previous): Added API doc comments, (next): Likewise. 2008-09-01 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (valueToJava2D): Use DateRange methods that return millis, (java2DToValue): Likewise, * source/org/jfree/data/time/DateRange.java (getLowerMillis): New method, (getUpperMillis): Likewise. 2008-09-01 David Gilbert * source/org/jfree/chart/util/RelativeDateFormat.java (hourFormatter): New field, (minuteFormatter): New field, (RelativeDateFormat(long)): Initialise new fields, (setDayFormatter): New method, (setHourFormatter): Likewise, (setMinuteFormatter): Likewise, (format): Use new fields for formatting, (equals): Updated for new fields. 2008-09-01 David Gilbert * source/org/jfree/chart/renderer/xy/XYDotRenderer.java (drawItem): Check for item visibility. 2008-08-15 David Gilbert Bug 2031407: * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (createStackedValueList): Encode series with negative values using -1 offset, (drawStackHorizontal): Account for -1 offset, (drawStackVertical): Likewise. 2008-08-15 David Gilbert Bug 2033721: * source/org/jfree/chart/renderer/WaferMapRenderer.java (getLegendCollection): Use lookupSeriesPaint. 2008-08-15 David Gilbert Bug 2051168: * source/org/jfree/chart/plot/PiePlot.java (getLegendItems): Populate with series key and index. 2008-08-15 David Gilbert * source/org/jfree/chart/ChartFactory.java: (currentTheme): New field, (getChartTheme): New method, (setChartTheme): Likewise, ...and applied current theme in all chart creation methods, * source/org/jfree/chart/ChartTheme.java: New file, * source/org/jfree/chart/ChartUtilities.java (applyCurrentTheme): New method, * source/org/jfree/chart/StandardChartTheme.java: New file. 2008-08-15 David Gilbert * source/org/jfree/chart/ChartPanel.java (DEFAULT_MAXIMUM_DRAW_WIDTH): Increased to 1024, (DEFAULT_MAXIMUM_DRAW_HEIGHT): Increased to 768. 2008-08-15 David Gilbert * source/org/jfree/chart/renderer/category/GradientBarPainter.java (paintBar): Use outline paint, (paintBarShadow): Use shadow paint, * source/org/jfree/chart/renderer/category/StandardBarPainter.java (paintBarShadow): Use shadow paint. 2008-08-15 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (clearSeriesPaints): New method, (clearSeriesStrokes): Likewise. 2008-08-15 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (clearSectionPaints): New method, (clearSectionOutlinePaints): Likewise, (clearSectionOutlineStrokes): Likewise. 2008-08-15 David Gilbert * source/org/jfree/chart/axis/SymbolAxis.java (drawGridBandsHorizontal): Use gridBandAlternatePaint, (drawGridBandsVertical): Likewise. 2008-08-15 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (getRendererCount): New method, * source/org/jfree/chart/plot/XYPlot.java (getRendererCount): Likewise. 2008-08-15 David Gilbert * source/org/jfree/chart/title/LegendTitle.java (getWrapper): New method. 2008-08-15 David Gilbert * source/org/jfree/chart/plot/Plot.java (setDrawingSupplier(DrawingSupplier, boolean)): New method. 2008-08-11 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (shadowPaint): New field, (getShadowPaint): New method, (setShadowPaint): Likewise, (equals): Updated for new field, (writeObject): For serialization, (readObject): Likewise. 2008-08-11 David Gilbert * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (totalWeight): Removed, (CombinedDomainCategoryPlot(CategoryAxis)): Updated for removed field, (add(CategoryPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (totalWeight): Removed, (add(XYPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java (totalWeight): Removed, (add(CategoryPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (totalWeight): Removed, (add(XYPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly. 2008-07-25 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (drawQuadrants): Check for null axes, (render): Likewise. 2008-07-11 David Gilbert Bug 1994355: * swt/org/jfree/experimental/swt/ChartComposite.java (addSWTListener): Changed argument type. 2008-07-11 David Gilbert Synced from trunk change by Henry Proudhon: * swt/org/jfree/experimental/swt/SWTUtils.java (toSwtFontData): Simplified font style, (toAwtFont): Likewise. 2008-07-10 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (draw): Check outline visibility. 2008-07-10 David Gilbert * source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java (getXPosition): New method, (setXPosition): Likewise, (equals): Updated for xPosition attribute. 2008-07-09 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (render): Call new methods in XYItemRendererState, * source/org/jfree/chart/renderer/xy/XYItemRendererState.java (startSeriesPass): New method, (endSeriesPass): Likewise. 2008-07-09 David Gilbert * source/org/jfree/chart/title/CompositeTitle.java (backgroundPaint): New field, (CompositeTitle): Initialise new field, (getBackgroundPaint): New method, (setBackgroundPaint): Likewise, (draw): Fill background if necessary, (equals): Check backgroundPaint, (writeObject): Added serialization support for backgroundPaint, (readObject): Likewise. 2008-07-02 David Gilbert Patch 2006826: * source/org/jfree/chart/title/CompositeTitle.java (draw(Graphics2D, Rectangle2D)): Delegate to other draw method, (draw(Graphics2D, Rectangle2D, Parameters)): Modified implementation to return result from BlockContainer. 2008-07-02 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (autoPopulateSectionPaint): New field, (autoPopulateSectionOutlinePaint): Likewise, (autoPopulateSectionOutlineStroke): Likewise, (PiePlot(PieDataset)): Initialise new fields, (lookupSectionPaint(Comparable)): Use autoPopulateSectionPaint field, (getAutoPopulateSectionPaint): New method, (setAutoPopulateSectionPaint): Likewise, (lookupSectionOutlinePaint(Comparable)): Use autoPopulateSectionOutlinePaint field, (getAutoPopulateSectionOutlinePaint): New method, (setAutoPopulateSectionOutlinePaint): Likewise, (lookupSectionOutlineStroke(Comparable)): Use autoPopulateSectionOutlineStroke field, (getAutoPopulateSectionOutlineStroke): New method, (setAutoPopulateSectionOutlineStroke): Likewise, (drawItem): Updated lookup methods, (getLegendItems): Likewise, (equals): Updated for new fields, * source/org/jfree/chart/plot/PiePlot3D.java (draw): Updated lookup methods, * source/org/jfree/chart/plot/RingPlot.java (draw): Likewise. 2008-06-26 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (getCategoryMiddle(Comparable, List, Rectangle2D, RectangleEdge)): New method, * source/org/jfree/chart/plot/CategoryCrosshairState.java: New file, * source/org/jfree/chart/plot/CategoryPlot.java (crosshairDatasetIndex): New field, (domainCrosshairVisible): Likewise, (domainCrosshairRowKey): Likewise, (domainCrosshairColumnKey): Likewise, (domainCrosshairStroke): Likewise, (domainCrosshairPaint): Likewise, (CategoryPlot): Initialise new fields, (indexOf): New method, (isDomainCrosshairVisible): Likewise, (setDomainCrosshairVisible): Likewise, (getDomainCrosshairRowKey): Likewise, (setDomainCrosshairRowKey): Likewise, (getDomainCrosshairColumnKey): Likewise, (setDomainCrosshairColumnKey): Likewise, (getCrosshairDatasetIndex): Likewise, (setCrosshairDatasetIndex): Likewise, (getDomainCrosshairPaint): Likewise, (setDomainCrosshairPaint): Likewise, (getDomainCrosshairStroke): Likewise, (setDomainCrosshairStroke): Likewise, (draw): Handle crosshairs, (render): Modified method signature to incorporate crosshair state, (drawDomainCrosshair): New method, (equals): Updated for new fields, (writeObject): Likewise, (readObject): Likewise, * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (draw): Fixed crosshair support, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java (draw): Likewise, * source/org/jfree/chart/plot/CrosshairState.java (datasetIndex): New field, (getDatasetIndex): New method, (setDatasetIndex): New method, (getDomainAxisIndex): Deprecated, (getRangeAxisIndex): Deprecated, * source/org/jfree/chart/plot/XYCrosshairState.java: New subclass, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (getItemMiddle): New method, (updateCrosshairValues): Likewise, * source/org/jfree/chart/renderer/category/AreaRenderer.java (drawItem): Update crosshair state, * source/org/jfree/chart/renderer/category/BarRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (getItemMiddle): New method, * source/org/jfree/chart/renderer/category/CategoryItemRendererState.java (crosshairState): New field, (getCrosshairState): New method, (setCrosshairState): Likewise, * source/org/jfree/chart/renderer/category/GanttRenderer.java (drawTasks): Update crosshair state, (drawTask): Likewise, (getItemMiddle): New method override, * source/org/jfree/chart/renderer/category/LevelRenderer.java (drawItem): Update crosshair state, (getItemMiddle): New method override, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (drawItem): Update crosshair state, * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java (testEquals): Updated for new fields. 2008-06-24 David Gilbert * source/org/jfree/chart/renderer/category/BarPainter.java: New file, * source/org/jfree/chart/renderer/category/BarRenderer.java: (defaultBarPainter): New field, (getDefaultBarPainter): New method, (setDefaultBarPainter): Likewise, (barPainter): New field, (shadowsVisible): Likewise, (shadowXOffset): Likewise, (shadowYOffset): Likewise, (BarRenderer): Initialise new fields, (getBarPainter): New method, (setBarPainter): Likewise, (getShadowsVisible): Likewise, (setShadowsVisible): Likewise, (getShadowXOffset): Likewise, (setShadowXOffset): Likewise, (getShadowYOffset): Likewise, (setShadowYOffset): Likewise, (drawItem): Use new barPainter, (equals): Check new fields, * source/org/jfree/chart/renderer/category/GanttRenderer.java (drawTask): Use new barPainter, (drawTasks): Likewise, * source/org/jfree/chart/renderer/category/GradientBarPainter.java: New file, * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java (drawItem): Use new barPainter, * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java (drawItem): Use new barPainter, * source/org/jfree/chart/renderer/category/StackedBarRenderer.java (getPassCount): Now returns 3, (drawItem): Use new barPainter, * source/org/jfree/chart/renderer/category/StandardBarPainter.java: New file, * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java (getPassCount): Now returns 2, (drawItem): Use new barPainter, * source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java: New file, * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java (getPassCount): Now returns 3, (drawItem): Use new barPainter, * source/org/jfree/chart/renderer/xy/StandardXYBarPainter.java: New file, * source/org/jfree/chart/renderer/xy/XYBarPainter.java: New file, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (defaultBarPainter): New field, (getDefaultBarPainter): New method, (setDefaultBarPainter): Likewise, (barPainter): New field, (shadowsVisible): Likewise, (shadowXOffset): Likewise, (shadowYOffset): Likewise, (XYBarRenderer(double)): Initialise new fields, (getBarPainter): New method, (setBarPainter): Likewise, (getShadowsVisible): Likewise, (setShadowsVisible): Likewise, (getShadowXOffset): Likewise, (setShadowXOffset): Likewise, (getShadowYOffset): Likewise, (setShadowYOffset): Likewise, (drawItem): Use new barPainter, (equals): Check new fields, * tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java (testEquals): Updated for new fields, * tests/org/jfree/chart/renderer/category/junit/GradientBarPainterTests.java: New file, * tests/org/jfree/chart/renderer/category/junit/RendererCategoryPackageTests.java (suite): Included new test classes, * tests/org/jfree/chart/renderer/category/junit/StandardBarPainterTests.java: New file, * tests/org/jfree/chart/renderer/xy/junit/GradientXYBarPainterTests.java: New file, * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java (suite): Included new test classes, * tests/org/jfree/chart/renderer/xy/junit/StandardXYBarPainterTests.java: New file, * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java (testEquals): Updated for new fields. 2008-06-19 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (findRangeBounds): New method override, * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java (testFindRangeBounds): New test method. 2008-06-18 David Gilbert * source/org/jfree/chart/title/PaintScaleLegend.java (subdivisions): New field, (PaintScaleLegend): Initialise new field, (getSubdivisionCount): New method, (setSubdivisionCount): Likewise, (SUBDIVISIONS): Removed private field, (draw): Modified segment calculations, (equals): Updated for new field. 2008-06-18 David Gilbert * source/org/jfree/chart/annotations/XYDrawableAnnotation.java (drawScaleFactor): New field, (width): Renamed displayWidth, (height): Renamed displayHeight, (XYDrawableAnnotation(double, double, double, double, double, Drawable)): New constructor, (draw): Apply scaling transform, (equals): Check drawScaleFactor field, (hashCode): Updated for renamed fields. 2008-06-17 David Gilbert * source/org/jfree/chart/LegendItem.java (labelFont): New field, (labelPaint): Likewise, (getLabelFont): New method, (setLabelFont): Likewise, (getLabelPaint): Likewise, (setLabelPaint): Likewise, (setFillPaint): Likewise, (setLinePaint): Likewise, (setOutlinePaint): Likewise, (equals): Test new fields, (writeObject): Handle new field, (readObject): Likewise, * source/org/jfree/chart/renderer/AbstractRenderer.java (legendShape): New field, (baseLegendShape): Likewise, (legendTextFont): Likewise, (baseLegendTextFont): Likewise, (legendTextPaint): Likewise, (baseLegendTextPaint): Likewise, (AbstractRenderer): Initialise new fields, (lookupLegendShape): New method, (getLegendShape): Likewise, (setLegendShape): Likewise, (getBaseLegendShape): Likewise, (setBaseLegendShape): Likewise, (lookupLegendTextFont): Likewise, (getLegendTextFont): Likewise, (setLegendTextFont): Likewise, (getBaseLegendTextFont): Likewise, (setBaseLegendTextFont): Likewise, (lookupLegendTextPaint): Likewise, (getLegendTextPaint): Likewise, (setLegendTextPaint): Likewise, (getBaseLegendTextPaint): Likewise, (setBaseLegendTextPaint): Likewise, (equals): Handle new fields, (clone): Likewise, (writeObject): Likewise, (readObject): Likewise, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java, * source/org/jfree/chart/renderer/category/AreaRenderer.java, * source/org/jfree/chart/renderer/category/BarRenderer.java, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java, * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java, * source/org/jfree/chart/renderer/category/ScatterRenderer.java, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java, * source/org/jfree/chart/renderer/xy/XYDotRenderer.java, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java, (getLegendItem): Use new legend attributes, * source/org/jfree/chart/title/LegendTitle.java (createLegendItemBlock): Pass new attributes to text block. 2008-06-16 David Gilbert * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (drawItem): Call addEntity() method, * source/org/jfree/chart/renderer/xy/YIntervalRenderer.java (drawItem): Likewise. ---------- JFREECHART 1.0.10 RELEASED ------------------------ 2008-06-09 David Gilbert * source/org/jfree/chart/axis/DateTickUnit.java (addToDate(Date)): Deprecated. 2008-06-06 David Gilbert * source/org/jfree/data/time/Millisecond.java (compareTo): Added handling for general RegularTimePeriod. 2008-06-06 David Gilbert * source/org/jfree/chart/axis/Axis.java (setTickLabelInsets(RectangleInsets)): Delegate to new method, (setTickLabelInsets(RectangleInsets, boolean)): New method. 2008-06-02 David Gilbert * source/org/jfree/data/time/SimpleTimePeriod.java (start): Changed from Date to long, (end): Likewise, (getStartMillis): New method, (getEndMillis): Likewise, (getStart): Returns new date instance, (getEnd): Likewise. 2008-06-02 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java (drawItem): Handle PlotOrientation.HORIZONTAL. 2008-06-02 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (getLegendItems): Return early if dataset is null. 2008-06-02 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (drawRadarPoly): Check dataExtractOrder when generating chart entities. 2008-06-02 David Gilbert Patches by Henry Proudhon: * swt/org/jfree/experimental/chart/swt/ChartComposite.java (ChartComposite): Removed duplicate listener registration, (paintControl): Switched horizontalAxisTrace and verticalAxisTrace, (dispose): New method, * swt/org/jfree/experimental/swt/SWTGraphics2D.java (transformsPool): New field, (setBackground): Use color pool, (setTransform): Use transform pool, (transform): Likewise, (disposeResourcePool): Clear the fontsPool and transformsPool, (getSwtTransformFromPool): New method, (toSwtTransform): Removed. 2008-06-02 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (isPointInRect): New utility method, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (drawItem): Modified bounds check for inclusion of chart entity, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (drawSecondaryPass): Modified bounds check for inclusion of chart entity. 2008-05-28 David Gilbert * source/org/jfree/data/time/DateRange.java (lowerDate): Changed from Date to long, (upperDate): Likewise, (DateRange(Date, Date)): Updated for field type change, (DateRange(long, long)): Likewise, (getLowerDate): Likewise, (getUpperDate): Likewise, (toString): Likewise, * source/org/jfree/data/time/FixedMillisecond.java (time): Changed from Date to long. 2008-05-26 David Gilbert * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java (getNullYString): New method, (equals): Check nullYString, * source/org/jfree/chart/labels/IntervalXYItemLabelGenerator.java: New file, * source/org/jfree/chart/renderer/xy/YIntervalRenderer.java (additionalItemLabelGenerator): New field, (YIntervalRenderer): Initialise new field, (getAdditionalItemLabelGenerator): New method, (setAdditionalItemLabelGenerator): Likewise, (drawItem): Added item label support, (drawAdditionalItemLabel): New method, (equals): New method override. 2008-05-22 David Gilbert * source/org/jfree/data/statistics/HistogramDataset.java (clone): Reimplemented. 2008-05-22 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (calculateAxisSpace): Calculate space for range axes first, adjust the plotArea then calculate the space for the domain axes. 2008-05-14 David Gilbert * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (drawItem): Use addEntity(). 2008-05-14 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (addEntity): If area is null, take into account the plot orientation for the generated hotspot, * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Use addEntity(). 2008-05-13 David Gilbert Bugs 1962467 and 1962472: * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (drawItem): Use hotspot that includes high and low values, and use addEntity() to add the chart entity. 2008-05-12 David Gilbert * source/org/jfree/data/category/SlidingCategoryDataset.java: New class, * source/org/jfree/data/gantt/SlidingGanttCategoryDatsaet.java: Likewise, * tests/org/jfree/data/category/SlidingCategoryDatasetTests.java: New tests, * tests/org/jfree/data/gantt/SlidingGanttCategoryDatasetTests.java: Likewise. 2008-05-12 David Gilbert * source/org/jfree/data/gantt/TaskSeries.java (clone): New method override, * source/org/jfree/data/gantt/TaskSeriesCollection.java (clone): Likewise. 2008-05-11 David Gilbert * source/org/jfree/chart/block/EmptyBlock.java (arrange): Use constraint. 2008-05-09 David Gilbert * source/org/jfree/data/category/DefaultCategoryDataset.java: Implemented PublicCloneable. 2008-05-08 David Gilbert * source/org/jfree/chart/ChartPanel.java (chartMouseListeners): Marked this field transient, (chartBuffer): Likewise, (writeObject): New method, (readObject): Likewise. 2008-05-08 David Gilbert * source/org/jfree/chart/ChartPanel.java (zoomPoint): Changed from Point to Point2D, (getPointInRectangle): Changed return type to Point2D, and no longer round the coordinates in the returned point, (mouseReleased): Tidied up for readability, (restoreAutoDomainBounds): Updated for modified zoomPoint type, (restoreAutoRangeBounds): Likewise. 2008-05-07 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (drawItem): Ensure that minimumBarLength, if used, extends the non-base end of the bar. 2008-05-05 David Gilbert Patch 1924543 by Richard West: * experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDemo1.java: New file, * experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.java: Likewise, * experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.java: Likewise, * experimental/org/jfree/experimental/chart/plot/CombinedXYPlot.java: Likewise. 2008-05-05 David Gilbert * source/org/jfree/chart/title/ShortTextTitle.java: New file, * tests/org/jfree/chart/title/junit/ShortTextTitleTests.java: Likewise. 2008-05-01 David Gilbert Bug 1955483: * source/org/jfree/data/xy/XYSeries.java (addOrUpdate(Number, Number)): Add a new item if duplicates are allows, (addOrUpdate(double, double)): New method. 2008-04-29 David Gilbert * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (tickLength): New field, (HighLowRenderer): Initialise new field, (getTickLength): New method, (setTickLength): Likewise, (equals): Added check for new field. 2008-04-28 David Gilbert * source/org/jfree/chart/title/TextTitle.java (maximumLinesToDisplay): New field, (getMaximumLinesToDisplay): New method, (setMaximumLinesToDisplay): Likewise, (arrangeFN): Pass maximumLinesToDisplay, (arrangeRR): Likewise, (equals): Added tests for additional fields. 2008-04-28 David Gilbert Bug 1950037: * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): New method override, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): New method override, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method override. 2008-04-23 David Gilbert Bug 1942059: * source/org/jfree/chart/axis/CategoryAxis.java (calculateTextBlockWidth): Use correct insets. 2008-04-23 David Gilbert * source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java, * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java: Implemented PublicCloneable. 2008-04-23 David Gilbert * source/org/jfree/chart/LegendItemCollection.java (clone): Reimplemented, * source/org/jfree/chart/plot/CategoryPlot.java (equals): Check additional fields, (clone): Clone some internal structures. 2008-04-23 David Gilbert * source/org/jfree/chart/LegendItem.java (LegendItem(String)): New constructor, (clone): Implemented. 2008-04-23 David Gilbert * source/org/jfree/chart/annotations/CategoryLineAnnotation.java, * source/org/jfree/chart/annotations/CategoryTextAnnotation.java: Implemented PublicCloneable. 2008-04-23 David Gilbert * source/org/jfree/chart/JFreeChart.java: Added new contributor Diego Pierangeli, * source/org/jfree/chart/urls/CustomCategoryURLGenerator.java: New class, * source/org/jfree/chart/urls/CustomXYURLGenerator.java (addURLSeries): Copy the incoming list. 2008-04-22 David Gilbert * source/org/jfree/chart/renderer/xy/VectorRenderer.java, * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java: Implemented PublicCloneable. 2008-04-22 David Gilbert * source/org/jfree/data/xy/DefaultHighLowDataset.java, * source/org/jfree/data/xy/DefaultIntervalXYDataset.java, * source/org/jfree/data/xy/DefaultWindDataset.java, * source/org/jfree/data/xy/DefaultXYZDataset.java, * source/org/jfree/data/xy/MatrixSeriesCollection.java, * source/org/jfree/data/xy/VectorSeriesCollection.java, * source/org/jfree/data/xy/XIntervalSeriesCollection.java, * source/org/jfree/data/xy/XYBarDataset.java, * source/org/jfree/data/xy/XYIntervalSeriesCollection.java, * source/org/jfree/data/xy/XYSeriesCollection.java, * source/org/jfree/data/xy/YIntervalSeriesCollection.java: Implemented PublicCloneable. 2008-04-22 David Gilbert * source/org/jfree/data/xy/DefaultTableXYDataset.java: Implemented PublicCloneable, plus (clone): New method override. 2008-04-22 David Gilbert * source/org/jfree/data/xy/DefaultOHLCDataset.java: Implemented PublicCloneable, plus (clone): New method override. 2008-04-22 David Gilbert * source/org/jfree/data/xy/CategoryTableXYDataset.java: Implemented PublicCloneable, plus (clone): New method override. 2008-04-21 David Gilbert * source/org/jfree/chart/title/ImageTitle.java (equals): New method override. 2008-04-18 David Gilbert Patch 1943021 (Brian Cabana): * source/org/jfree/chart/plot/MultiplePiePlot.java (MultiplePiePlot(CategoryDataset)): Call setDataset() to ensure that plot registers as a dataset listener, * tests/org/jfree/chart/plot/junit/MultiplePiePlotTests.java (testConstructors): New test method. 2008-04-11 David Gilbert * source/org/jfree/chart/title/ImageTitle.java (arrange): New method override to handle margin, border and padding, * test/org/jfree/chart/title/junit/ImageTitleTests.java (testArrangeNN): New test method. 2008-04-11 David Gilbert * source/org/jfree/chart/urls/CustomXYURLGenerator.java (clone): Implemented, * tests/org/jfree/chart/urls/junit/CustomPieURLGeneratorTests.java: New file, * tests/org/jfree/chart/urls/junit/CustomXYURLGeneratorTests.java (testEquals): New test method, (testCloning): Likewise, * tests/org/jfree/chart/urls/junit/UrlsPackageTests.java (suite): Added CustomPieURLGeneratorTests. 2008-04-11 David Gilbert * source/org/jfree/chart/renderer/xy/DeviationRenderer.java (findRangeBounds): New method override, * source/org/jfree/chart/renderer/xy/YIntervalRenderer.java (findRangeBounds): Likewise. 2008-04-10 David Gilbert * source/org/jfree/data/xy/XIntervalSeriesCollection.java (getStartXValue): New method override, (getEndXValue): Likewise. 2008-04-10 David Gilbert * source/org/jfree/data/xy/XIntervalSeries.java (getXLowValue): New method, (getXHighValue): Likewise. 2008-04-08 David Gilbert Bug 1932146: * source/org/jfree/chart/axis/PeriodAxis.java (setRange): Notify listeners, * tests/org/jfree/chart/axis/junit/PeriodAxisTests.java (lastEvent): New field, (axisChanged): New method, (test1932146): New test method. 2008-04-08 David Gilbert * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (findRangeBounds): New method override. 2008-04-08 David Gilbert * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (findRangeBounds): New method override, * source/org/jfree/data/general/DatasetUtilities.java (iterateRangeBounds(XYDataset)): Fixed typo for OHLCDataset. 2008-04-08 David Gilbert * source/org/jfree/chart/block/BorderArrangement.java (arrangeFF): Check for negative width remaining. 2008-04-08 David Gilbert * source/org/jfree/chart/block/ColorBlock.java (arrange): New method override, (draw): Add code for margin, border and padding, * source/org/jfree/chart/block/EmptyBlock.java (arrange): New method override, (draw(Graphics2D, Rectangle2D)): Delegate, (draw(Graphics2D, Rectangle2D, Object)): New method override. 2008-04-07 David Gilbert * source/org/jfree/data/time/TimePeriodValue.java (toString): New method override, * source/org/jfree/data/time/TimePeriodValues.java (updateBounds): Update maxMiddleIndex correctly, * tests/org/jfree/data/time/junit/TimePeriodValues.java (testGetMinStartIndex): New test method, (testGetMaxStartIndex): Likewise, (testGetMinMiddleIndex): Likewise, (testGetMaxMiddleIndex): Likewise, (testGetMinEndIndex): Likewise, (testGetMaxEndIndex): Likewise. 2008-04-07 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (removeDomainMarker): Check for null collection, (removeRangeMarker): Likewise, * source/org/jfree/chart/plot/XYPlot.java (removeDomainMarker): Check for null collection, (removeRangeMarker): Likewise. 2008-04-07 David Gilbert * source/org/jfree/data/DefaultKeyedValue.java (equals): Simplified to reflect that this.key is never null. 2008-04-07 David Gilbert * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java (drawItem): Inserted code to add entities. 2008-03-31 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (equals): Updated for labelLinkStyle field. 2008-03-31 David Gilbert Patch 1891849 by Martin Hilpert: * source/org/jfree/chart/plot/PieLabelLinkStyle.java: New file, * source/org/jfree/chart/plot/PiePlot.java (labelLinkStyle): New field, (getLabelLinkStyle): New method, (setLabelLinkStyle): Likewise, (drawLeftLabel): Added support for labelLinkStyle field, (drawRightLabel): Likewise. 2008-03-31 David Gilbert * source/org/jfree/chart/plot/PieLabelDistributor.java (distributeLabels): Comment out adjustInwards() until it is working, (adjustDownwards): Fix check for lower bound, (adjustUpwards): Fix check for upper bound, (distributeEvenly): Allow overlapping rather than exceeding bounds. 2008-03-31 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (drawLeftLabels): Adjust label area for interiorGap, (drawRightLabels): Likewise. 2008-03-31 David Gilbert * source/org/jfree/chart/labels/HighLowItemLabelGenerator.java: (hashCode): Implemented, * source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java: Likewise, * source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java: Likewise, * source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java: Likewise, * source/org/jfree/chart/labels/SymbolicXYItemLabelGenerator.java: Likewise. 2008-03-31 David Gilbert * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (getSubplots): Return null if this.subplots is null, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java: Likewise, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java: Likewise, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java: Likewise. 2008-03-28 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (iterateRangeBounds(CategoryDataset, boolean)): Modified implementation, (iterateRangeBounds(XYDataset, boolean)): Likewise, * tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java (testFindRangeBounds3): New test, (testIterateCategoryRangeBounds): Renamed testIterateRangeBounds_CategoryDataset(), (testIterateRangeBounds2_CategoryDataset): New method, (testIterateRangeBounds3_CategoryDataset): Likewise, (testIterateXYRangeBounds): Renamed testIterateRangeBounds(), (testIterateXYRangeBounds2): Renamed testIterateRangeBounds2(), (testIterateRangeBounds3): New method, (testIterateRangeBounds4): Likewise, (testCumulativeRange3): Likewise, (testSampleFunction2D): Likewise. 2008-03-28 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (iterateCategoryRangeBounds): Deprecated, (iterateRangeBounds(CategoryDataset)): New method, (iterateRangeBounds(CategoryDataset, boolean)): Likewise. 2008-03-28 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (findRangeBounds(XYDataset, boolean)): Use boolean argument for call to iterateRangeBounds(), (iterateXYRangeBounds): Deprecated, (iterateRangeBounds(XYDataset)): New method, (iterateRangeBounds(XYDataset, boolean)): Likewise. 2008-03-28 David Gilbert * source/org/jfree/data/general/DatasetUtilities.java (sampleFunction2D): Fixed sample count bug. 2008-03-27 David Gilbert Bug 1927239: * source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java (findRangeBounds): Reimplemented to account for the special treatment of the value in the final category, * source/org/jfree/data/general/DatasetUtilities.java (findCumulativeRangeBounds): Include final category. 2008-03-27 David Gilbert Bug 1926517: * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java: (getDataRange): Override just to document, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (getDataRange): Added javadoc comment, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java (getDataRange): Likewise, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (getDataRange): Likewise. 2008-03-27 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawHorizontalItem): Draw box outline using itemOutlinePaint/Stroke, (drawVerticalItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java (lookupBoxPaint): New method, (drawHorizontalItem): Do lookup for box fill paint, (drawVerticalItem): Likewise. 2008-03-26 David Gilbert Patch 1918209: * source/org/jfree/chart/axis/LogAxis.java (createTickLabel): Changed from private to protected. 2008-03-25 David Gilbert * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java * source/org/jfree/chart/plot/CombinedDomainXYPlot.java * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java * source/org/jfree/chart/plot/CombinedRangeXYPlot.java * source/org/jfree/chart/plot/CompassPlot.java * source/org/jfree/chart/plot/ContourPlot.java * source/org/jfree/chart/plot/MeterPlot.java * source/org/jfree/chart/plot/MultiplePiePlot.java * source/org/jfree/chart/plot/PiePlot.java * source/org/jfree/chart/plot/PiePlot3D.java * source/org/jfree/chart/plot/PolarPlot.java * source/org/jfree/chart/plot/RingPlot.java * source/org/jfree/chart/plot/SpiderWebPlot.java * source/org/jfree/chart/plot/ThermometerPlot.java * source/org/jfree/chart/plot/WaferMapPlot.java Use fireChangeEvent() method all over. 2008-03-25 David Gilbert Patch 1914411: * source/org/jfree/chart/plot/Plot.java (fireChangeEvent): New method, * source/org/jfree/chart/plot/CategoryPlot.java * source/org/jfree/chart/plot/FastScatterPlot.java * source/org/jfree/chart/plot/XYPlot.java: Use fireChangeEvent() method all over. 2008-03-25 David Gilbert Patch 1913751: * source/org/jfree/chart/plot/CategoryPlot.java (addDomainMarker(int, CategoryMarker, Layer, boolean)): New method, (removeDomainMarker(int, Marker, Layer, boolean)): Likewise, (addRangeMarker(int, CategoryMarker, Layer, boolean)): Likewise, (removeRangeMarker(int, Marker, Layer, boolean)): Likewise, (addAnnotation(CategoryAnnotation, boolean)): Likewise, (removeAnnotation(CategoryAnnotation, boolean)): Likewise. 2008-03-25 David Gilbert Patch 1913751: * source/org/jfree/chart/plot/XYPlot.java (addDomainMarker(int, Marker, Layer, boolean)): New method, (removeDomainMarker(int, Marker, Layer, boolean)): Likewise, (addRangeMarker(int, Marker, Layer, boolean)): Likewise, (removeRangeMarker(int, Marker, Layer, boolean)): Likewise, (addAnnotation(XYAnnotation, boolean)): Likewise, (removeAnnotation(XYAnnotation, boolean)): Likewise. 2008-03-20 David Gilbert Bug 1920854: * source/org/jfree/chart/plot/PiePlot3D.java (draw): Move label drawing outside section loop. 2008-03-19 David Gilbert Patch 1902418: * source/org/jfree/chart/axis/LogAxis.java (refreshTicksVertical): Change tick type for major tick labels. 2008-03-19 David Gilbert * source/org/jfree/chart/plot/PiePlot3D.java (getMaximumExplodePercent): Check for null dataset, (initialise): Likewise, * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java (testDrawWithNullDataset): New test method. 2008-02-26 David Gilbert Patch 1901599: * experimental/org/jfree/chart/annotations/XYTitleAnnotation.java (draw): Check for null 'info' argument before adding entities, (hashCode): Reimplemented, * experimental/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java (testDrawWithNullInfo): New test. 2008-02-26 David Gilbert Bug 1897580: * source/org/jfree/data/DefaultIntervalCategoryDataset.java (DefaultIntervalCategoryDataset(Comparable[], Comparable[], Number[][], Number[][]): Initialise seriesKeys and categoryKeys to empty arrays instead of null for empty dataset, (setCategoryKeys): Fixed argument check to handle empty dataset. 2008-02-19 David Gilbert * org/jfree/chart/util/LogFormat.java (powerLabel): New field, (LogFormat(double, String, boolean)): Delegate to new constructor, (LogFormat(double, String, String, boolean)): New constructor, (format): Use new powerLabel, (equals): New method override, (clone): Likewise. 2008-02-18 David Gilbert Bug 1880114: * org/jfree/chart/renderer/xy/VectorRenderer.java (drawItem): Modify arrow-head for plot orientation. 2008-02-18 David Gilbert Patch 1871902 by Martin Hoeller: * org/jfree/chart/plot/PolarPlot.java (DEFAULT_ANGLE_TICK_UNIT_SIZE): New field, (angleTickUnit): Likewise, (PolarPlot(XYDataset, ValueAxis, PolarItemRenderer)): Initialise angleTickUnit, (getAngleTickUnit): New method, (setAngleTickUnit): Likewise, (refreshAngleTicks): Likewise, (draw): Refresh angle tick list before drawing. 2008-02-15 David Gilbert * org/jfree/data/DefaultKeyedValue.java (DefaultKeyedValue(Comparable, Number)): Check for null key. 2008-02-15 David Gilbert Patch 1868745: * source/org/jfree/chart/axis/LogAxis.java (refreshTicksHorizontal): Adjust label anchor according to axis position, (refreshTicksVertical): Likewise. 2008-02-15 David Gilbert Patch 1873328: * source/org/jfree/chart/util/RelativeDateFormat.java (showZeroHours): New field, (positivePrefix): Likewise, (RelativeDateFormat(long)): Initialise new fields, (getShowZeroHours): New method, (setShowZeroHours): Likewise, (getPositivePrefix): Likewise, (setPositivePrefix): Likewise, (format): Apply positive prefix, and fix formatting for negative values, (equals): Handle new fields, (hashCode): Use positivePrefix. 2008-02-15 David Gilbert Bug 1873160: * source/org/jfree/chart/plot/DialPlot.java (draw): Fix clipping issues. 2008-02-14 David Gilbert Bug 1892419: * source/org/jfree/chart/axis/LogAxis.java (LogAxis(String)): Change default number of minor ticks. 2008-02-14 David Gilbert Patch 1874890 (Ulrich Voigt with contributions from Martin Hoeller): * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (stepPoint): New field, (getStepPoint): New method, (setStepPoint): Likewise, (drawItem): Calculate step point using new field, (drawLine): New private method, (equals): New method override, (hashCode): Likewise. 2008-02-14 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawHorizontalItem): Call addEntity() to handle entity generation, (drawVerticalItem): Likewise. 2008-02-14 David Gilbert Patch 1888422 (Rob Van der Sanden): * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawHorizontalItem): Use correct data area dimension for series gap calculation. 2008-01-28 David Gilbert * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (draw): Reset fixed range axis space for subplots. 2008-01-18 David Gilbert * source/org/jfree/data/xy/XIntervalSeriesCollection.java (removeSeries(int)): New method, (removeSeries(XIntervalSeries)): Likewise, (removeAllSeries): Likewise, * source/org/jfree/data/xy/XYIntervalSeriesCollection.java (removeSeries(int)): New method, (removeSeries(XYIntervalSeries)): Likewise, (removeAllSeries): Likewise, * source/org/jfree/data/xy/YIntervalSeriesCollection.java (removeSeries(int)): New method, (removeSeries(YIntervalSeries)): Likewise, (removeAllSeries): Likewise. 2008-01-18 David Gilbert * source/org/jfree/data/time/TimeSeriesCollection.java (getSeries): Changed argument from String to Comparable. 2008-01-15 David Gilbert Patch 1866446 (Rob Van der Sanden): * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (maximumBarWidth): New field, (BoxAndWhiskerRenderer): Initialise new field, (getMaximumBarWidth): New method, (setMaximumBarWidth): Likewise, (equals): Updated for new field, * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testEquals): Updated to check new field. 2008-01-10 David Gilbert Bug 1864222: * source/org/jfree/data/time/TimeSeries.java (createCopy(RegularTimePeriod, RegularTimePeriod)): Handle empty range, * tests/org/jfree/data/time/junit/TimeSeriesTests.java (testBug1864222): New test method. 2008-01-10 David Gilbert Bug 1868521: * source/org/jfree/chart/ChartUtilities.java (writeChartAsJPEG): Create RGB image rather than ARGB. ---------- JFREECHART 1.0.9 RELEASED ------------------------ 2008-01-04 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (drawQuadrants): Fix painting error when quadrant origin is outside plot area. 2008-01-03 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawHorizontalItem): Check visibility of average marker, (drawVerticalItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java (drawHorizontalItem): Check visibility of average marker, (drawVerticalItem): Likewise. 2007-12-20 David Gilbert Fixes bug 1848961: * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java (calculateBarW0): Use correct dataset index. 2007-12-19 David Gilbert * source/org/jfree/data/time/Week.java (Week(Date, TimeZone)): Hand on the zone, * tests/org/jfree/data/time/junit/WeekTests.java (testBug1448828): Control the default locale, (testBug1498805): Likewise, (testGetFirstMillisecondWithTimeZone): Control the default locale, and modify expected result accordingly, (testGetLastMillisecondWithTimeZone): Likewise. 2007-12-19 David Gilbert * source/org/jfree/chart/title/TextTitle.java (arrange): Implement additional options, (arrangeNN): New method, (arrangeFN): Likewise, (arrangeRN): Likewise. 2007-12-18 David Gilbert Committing for Sergei Ivanov: * source/org/jfree/data/Range.java (intersects(Range)): New method, (expand): Handle special case for negative margins, (shift): Added argument check, (scale): New method, * tests/org/jfree/data/junit/RangeTests.java (testConstructor): New test, (testHashCode): Likewise, (testExpand): Additional checks, (testShift): New test, (testScale): Likewise. 2007-12-18 David Gilbert * source/org/jfree/chart/plot/IntervalMarker.java (IntervalMarker(double, double, Paint)): New constructor. 2007-12-05 David Gilbert * source/org/jfree/chart/HashUtilities.java (hashCode(int, BooleanList)): New method, (hashCode(int, PaintList)): Likewise, (hashCode(int, StrokeList)): Likewise. 2007-12-05 David Gilbert * source/org/jfree/chart/entity/ChartEntity.java (getImageMapAreaTag): Don't escape tooltips and urls, delegate that to the tag generators, * source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java (generateURLFragment): Encode the url text, * tests/org/jfree/chart/imagemap/junit/ImageMapPackageTests.java: New file, * tests/org/jfree/chart/imagemap/junit/StandardToolTipTagFragmentGeneratorTests.java: Likewise, * tests/org/jfree/chart/imagemap/junit/StandardURLTagFragmentGeneratorTests.java: Likewise. 2007-12-05 David Gilbert * source/org/jfree/chart/JFreeChart.java (setTitle): Handle listener registration, * tests/org/jfree/chart/junit/JFreeChartTests.java (testTitleChangeEvents): New test method. 2007-12-04 David Gilbert * source/org/jfree/chart/imagemap/DynamicDriveToolTipFragmentGenerator.java (generateToolTipFragment): Escape text, * source/org/jfree/chart/imagemap/OverLIBToolTipFragmentGenerator.java (generateToolTipFragment): Likewise, * source/org/jfree/chart/imagemap/StandardToolTipFragmentGenerator.java (generateToolTipFragment): Likewise, * source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java (generateURLFragment): Likewise. 2007-12-04 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (hashCode): Compute using more fields. 2007-12-04 David Gilbert * source/org/jfree/chart/JFreeChart.java (createBufferedImage(int, int, ChartRenderingInfo)): Change image type, (createBufferedImage(int, int, double, double, ChartRenderingInfo)): Likewise. 2007-12-04 David Gilbert Bugs 1363043 and 1840139: * source/org/jfree/chart/entity/ChartEntity.java (getImageMapAreaTag): Escape toolTipText and urlText, * source/org/jfree/chart/imagemap/ImageMapUtilities.java (getImageMap): Escape name, (htmlEscape): New method. 2007-12-04 David Gilbert Bug 1460195: * source/org/jfree/chart/entity/ChartEntity.java (getImageMapAreaTag): Add 'nohref' attribute when there is no URL. 2007-12-03 David Gilbert * source/org/jfree/data/xy/XYSeriesCollection.java (getSeries(Comparable)): New method, * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java (testGetSeriesByKey): New test method. 2007-11-30 David Gilbert * source/org/jfree/data/xy/XYDataItem.java (getXValue): New method, (getYValue): Likewise, (toString): Likewise. 2007-11-30 David Gilbert * source/org/jfree/chart/LocalizationBundle_it.properties: Fixed errors. 2007-11-29 David Gilbert * source/org/jfree/chart/plot/MeterPlot.java (writeObject): Handle dialOutlinePaint, (readObject): Likewise, * tests/org/jfree/chart/plot/junit/MeterPlotTests.java (testEquals): Updated to test dialOutlinePaint, (testSerialization1): Likewise. 2007-11-27 David Gilbert * source/org/jfree/data/ComparableObjectSeries.java (clear): Changed from protected to public, * source/org/jfree/data/xy/VectorSeries.java (clear): Removed, * tests/org/jfree/data/time/ohlc/junit/OHLCSeriesTests.java (testClear): New test method, * tests/org/jfree/data/xy/junit/VectorSeriesTests.java (testClear): Likewise, * tests/org/jfree/data/xy/junit/XIntervalSeriesTests.java (testClear): Likewise, * tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java (testClear): Likewise, * tests/org/jfree/data/xy/junit/YIntervalSeriesTests.java (testClear): Likewise. 2007-11-27 David Gilbert * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (setFixedRangeAxisSpaceForSubplots): Call new method in XYPlot, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (setFixedDomainAxisSpaceForSubplots): Likewise, * source/org/jfree/chart/plot/XYPlot.java (setFixedDomainAxisSpace(AxisSpace)): Delegate to new method, (setFixedDomainAxisSpace(AxisSpace, boolean)): New method, (setFixedRangeAxisSpace(AxisSpace)): Delegate to new method, (setFixedRangeAxisSpace(AxisSpace, boolean)): New method. 2007-11-27 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java: (drawImage(BufferedImage, BufferedImageOp, int, int)): Updated for method moved to SWTUtils, (drawImage(Image, int, int, ImageObserver)): Implemented, (drawImage(Image, int, int, int, int, ImageObserver)): Likewise, (drawImage(Image, int, int, Color, ImageObserver)): Likewise, (drawImage(Image, int, int, int, int, Color, ImageObserver)): Likewise, (convertToSWT(BufferedImage)): Moved to SWTUtils.java, * swt/org/jfree/experimental/swt/SWTUtils.java: (convertAWTImageToSWT): New method, (convertToSWT(BufferedImage)): Moved from SWTGraphics2D.java. ---------- JFREECHART 1.0.8 RELEASED ------------------------ 2007-11-23 David Gilbert * source/org/jfree/chart/plot/dial/DialPointer.java (Pointer.fillPaint): New attribute, (Pointer.outlinePaint): Likewise, (Pointer(int)): Initialize new fields, (getFillPaint): New method, (setFillPaint): Likewise, (getOutlinePaint): Likewise, (setOutlinePaint): Likewise, (draw): Use new attributes, (equals): Check new fields, (hashCode): Likewise, (writeObject): Handle serialization for new fields, (readObject): Likewise, * tests/org/jfree/chart/plot/dial/junit/DialPointerTests.java (testEqualsPointer): New test method, (testSerialization2): Likewise. 2007-11-22 David Gilbert * source/org/jfree/chart/HashUtilities.java (hashCode(int, int)): New method, * source/org/jfree/chart/needle/ArrowNeedle.java * source/org/jfree/chart/needle/LineNeedle.java * source/org/jfree/chart/needle/LongNeedle.java * source/org/jfree/chart/needle/MeterNeedle.java * source/org/jfree/chart/needle/MiddlePinNeedle.java * source/org/jfree/chart/needle/PinNeedle.java * source/org/jfree/chart/needle/PlumNeedle.java * source/org/jfree/chart/needle/PointerNeedle.java * source/org/jfree/chart/needle/ShipNeedle.java * source/org/jfree/chart/needle/WindNeedle.java: Implemented hashCode() method. 2007-11-22 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java * source/org/jfree/chart/renderer/xy/DeviationRenderer.java * source/org/jfree/chart/renderer/xy/HighLowRenderer.java * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java * source/org/jfree/chart/renderer/xy/XYBarRenderer.java * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java * source/org/jfree/chart/renderer/xy/XYDotRenderer.java * source/org/jfree/chart/renderer/xy/XYErrormRenderer.java * source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java * source/org/jfree/chart/renderer/xy/XYSplineRenderer.java * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java: Replaced calls to notifyListeners() with fireChangeEvent(). 2007-11-22 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java * source/org/jfree/chart/renderer/category/AreaRenderer.java * source/org/jfree/chart/renderer/category/BarRenderer.java * source/org/jfree/chart/renderer/category/BarRenderer3D.java * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java * source/org/jfree/chart/renderer/category/GanttRenderer.java * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java * source/org/jfree/chart/renderer/category/LevelRenderer.java * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java * source/org/jfree/chart/renderer/category/LineRenderer3D.java * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java * source/org/jfree/chart/renderer/category/ScatterRenderer.java * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java * source/org/jfree/chart/renderer/category/StackedBarRenderer.java * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java: Replaced calls to notifyListeners() with fireChangeEvent(). 2007-11-22 David Gilbert * source/org/jfree/data/xy/XYSeries.java (clone): Reimplemented, * tests/org/jfree/data/xy/junit/XYSeriesTests.java (testCloning2): New method, (testCloning3): Likewise. 2007-11-21 David Gilbert * source/org/jfree/data/DefaultKeyedValues.java (removeValue): Always rebuild index, * source/org/jfree/data/DefaultKeyedValues2D.java (removeColumn(Comparable)): Added argument checks, and protect against rows not containing the specified key, * tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java (testBug1835955): New method, * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java (testRemoveColumnByKey): New method, * tests/org/jfree/data/junit/DefaultKeyedValuesTests.java (testGetIndex2): New method. 2007-11-21 David Gilbert Fix for bug 1832432: * source/org/jfree/data/time/TimeSeries.java (clone): Reimplemented. 2007-11-21 David Gilbert * source/org/jfree/chart/plot/DatasetRenderingOrder.java (hashCode): Implemented, * source/org/jfree/chart/plot/DialShape.java (hashCode): Likewise, * source/org/jfree/chart/plot/PlotOrientation.java (hashCode): Likewise, * source/org/jfree/chart/plot/SeriesRenderingOrder.java (hashCode): Likewise. 2007-11-21 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): Return dates already fetched. 2007-11-21 David Gilbert * source/org/jfree/chart/renderer/CategoryAxis.java (equalPaintMaps): Use entrySet rather than keySet. 2007-11-21 David Gilbert * source/org/jfree/chart/renderer/PieLabelRecord.java (equals): Implemented. 2007-11-21 David Gilbert * source/org/jfree/chart/renderer/Outlier.java (equals): Implemented. 2007-11-21 David Gilbert * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (shapesFilled): Deprecated, (getShapesFilled): Likewise, (setShapesFilled): Likewise, (setBaseShapesVisible): Call fireChangeEvent() instead of notifyListeners(), (setPlotLines): Likewise, (setGapThresholdType): Likewise, (setGapThreshold): Likewise, (setPlotImages): Likewise, (setLegendLine): Likewise. 2007-11-21 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (DEFAULT_INTERIOR_GAP): Modified default value, (maximumLabelWidth): Likewise, (labelGap): Likewise, (labelLinkMargin): Likewise, (DEBUG_DRAW_INTERIOR): New debug flag, (DEBUG_DRAW_LINK_AREA): Likewise, (DEBUG_DRAW_PIE_AREA): Likewise, (PiePlot(PieDataset)): Removed background paint setting, (drawPie): Modified label position calculations and added debug code, (drawLabels): Modified label width calculation, * source/org/jfree/chart/plot/PiePlot3D.java (depthFactor): Changed default value, (draw): Modified chart dimension calculations and added debug code, in line with changes made to the PiePlot class. 2007-11-19 David Gilbert * source/org/jfree/chart/plot/dial/StandardDialScale.java (getLowerBound): New method, (setLowerBound): Likewise, (getUpperBound): Likewise, (setUpperBound): Likewise, (getMinorTickStroke): Likewise, (setMinorTickStroke): Likewise. 2007-11-14 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java (errorIndicatorStroke): New field, (StatisticalBarRenderer): Initialise new field, (getErrorIndicatorStroke): New method, (setErrorIndicatorStroke): Likewise, (drawHorizontalItem): Fix drawBarOutline and gradientPaintTransformer omissions, and use new errorIndicatorStroke field, (drawVerticalItem): Likewise, (equals): Updated for new field, (writeObject): Likewise, (readObject): Likewise. ---------- JFREECHART 1.0.7 RELEASED ------------------------ 2007-11-14 David Gilbert * swt/org/jfree/experimental/chart/swt/ChartComposite.java (ChartComposite): Create canvas with SWT.DOUBLE_BUFFERED, (getChartRenderingInfo): New method, (isDomainZoomable): Likewise, (setDomainZoomable): Likewise, (isRangeZoomable): Likewise, (setRangeZoomable): Likewise. 2007-11-14 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (setWeight): Fire change event, (setFixedDomainAxisSpace(AxisSpace)): Delegate to new method, (setFixedDomainAxisSpace(AxisSpace, boolean)): New method, (setFixedRangeAxisSpace(AxisSpace)): Delegate to new method, (setFixedRangeAxisSpace(AxisSpace, boolean)): New method, * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (setFixedRangeAxisSpaceForSubplots): Updated, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java (setFixedDomainAxisSpaceForSubplots): Updated. 2007-11-13 David Gilbert * source/org/jfere/chart/HashUtilities.java (hashCode(int, Comparable)): New method, * source/org/jfree/chart/entity/CategoryLabelEntity.java (equals): New method, (hashCode): Likewise. 2007-11-13 David Gilbert * source/org/jfree/chart/axis/ModuloAxis.java (equals): Implemented. 2007-11-13 David Gilbert * source/org/jfree/chart/entity/ChartEntity.java (hashCode): Implemented, * source/org/jfree/chart/entity/PieSectionEntity.java (equals): Implemented, (hashCode): Likewise. 2007-11-13 David Gilbert * source/org/jfree/chart/HashUtilities.java (hashCode(int, boolean)): New method, (hashCode(int, double)): Likewise, (hashCode(int, Paint)): Likewise, (hashCode(int, Stroke)): Likewise, (hashCode(int, String)): Likewise. 2007-11-13 David Gilbert * source/org/jfree/chart/plot/dial/AbstractDialLayer.java (hashCode): Implemented. 2007-11-12 David Gilbert * source/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDataset.java (add): Fire dataset change event, (getY): Removed redundant constructor call, (equals): New method override, (clone): Likewise. 2007-11-12 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (equals): Added check for domain/rangeTickBandPaint, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (fillDomainGridBand): Handle plot orientation properly, (fillRangeGridBand): Likewise. 2007-11-12 David Gilbert Patch 1827829 from Richard West: * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItemLabel): Fixed NPE. 2007-11-12 David Gilbert * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (drawItem): Simplified entity generation, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItem): Likewise. 2007-11-09 David Gilbert * source/org/jfree/chart/renderer/xy/XYDotRenderer.java (legendShape): New field, (XYDotRenderer): Initialise new field, (getLegendShape): New method, (setLegendShape): Likewise, (getLegendItem): New method override, (equals): Updated for new field, (readObject): New method, (writeObject): New method. 2007-11-07 David Gilbert * source/org/jfree/chart/ChartPanel.java (paintComponent): Clear refreshBuffer flag before drawing chart. 2007-11-06 David Gilbert * source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java (getValues): Return EMPTY_LIST rather than null. 2007-11-05 David Gilbert * source/org/jfree/data/time/TimeSeries.java (TimeSeries(String)): Changed first argument to Comparable, (TimeSeries(String, Class)): Likewise, (TimeSeries(String, String, String, Class)): Likewise. 2007-11-05 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (setFixedDomainAxisSpace): Fire change event, (setFixedRangeAxisSpace): Likewise. 2007-11-05 David Gilbert Patch 1823724 by Richard West: * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (drawItemPass1): Add code to draw item labels. 2007-11-05 David Gilbert Patch 1823697 by Richard West: * source/org/jfree/chart/plot/XYPlot.java (removeDomainMarker(Marker)): New method, (removeDomainMarker(Marker, Layer)): Likewise, (removeDomainMarker(int, Marker, Layer)): Likewise, (removeRangeMarker(Marker)): New method, (removeRangeMarker(Marker, Layer)): Likewise, (removeRangeMarker(int, Marker, Layer)): Likewise. 2007-11-05 David Gilbert Patch 1823697 by Richard West: * source/org/jfree/chart/plot/CategoryPlot.java (removeDomainMarker(Marker)): New method, (removeDomainMarker(Marker, Layer)): Likewise, (removeDomainMarker(int, Marker, Layer)): Likewise, (removeRangeMarker(Marker)): New method, (removeRangeMarker(Marker, Layer)): Likewise, (removeRangeMarker(int, Marker, Layer)): Likewise. 2007-10-31 David Gilbert * source/org/jfree/data/DefaultKeyedValues.java (data): Removed, (keys): New field, (values): Likewise, (indexMap): New field, (DefaultKeyedValues): Initialise new fields, (getItemCount): Use new data fields, (getValue(int)): Likewise, (getKey(int)): Likewise, (getIndex(Comparable)): Likewise, (getKeys): Likewise, (setValue(Comparable, Number)): Likewise, (insertValue): Likewise, (rebuildIndex): Likewise, (removeValue): Likewise, (clear): Likewise, (sortByKeys): Likewise, (sortByValue): Likewise, (hashCode): Likewise, (clone): Likewise. 2007-10-31 David Gilbert * source/org/jfree/data/ComparableObjectSeries.java (hashCode): Faster implementation, * source/org/jfree/data/time/TimeSeries.java (hashCode): Likewise, * source/org/jfree/data/xy/XYSeriesTests.java (hashCode): Likewise. 2007-10-29 David Gilbert * source/org/jfree/chart/plot/dial/SimpleDialFrame.java: Renamed StandardDialFrame.java. 2007-10-26 David Gilbert * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (linesVisible): Deprecated, (shapesVisible): Likewise, (shapesFilled): Likewise, (getLinesVisible): Likewise, (setLinesVisible): Likewise, (getShapesVisible): Likewise, (setShapesVisible): Likewise, (setShapesFilled): Likewise. 2007-10-25 David Gilbert * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java: Renamed XYSplineRenderer. 2007-10-25 David Gilbert * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java (drawPrimaryLineAsPath): Check for duplicated control points, (ControlPoint.equals): New method override. 2007-10-25 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (getDomainAxisIndex): Added argument check, (getRangeAxisIndex): Likewise. 2007-10-25 David Gilbert * source/org/jfree/chart/axis/StandardTickUnitSource.java: Implemented Serializable, (StandardTickUnitSource): Added explicit constructor, (equals): New method override, (hashCode): Likewise. 2007-10-25 David Gilbert * source/org/jfree/chart/ChartPanel.java (defaultDirectoryForSaveAs): New field, (ChartPanel(JFreeChart, int, int, int, int, int, int, boolean, boolean, boolean, boolean, boolean, boolean)): Initialise new field, (getDefaultDirectoryForSaveAs): New method, (setDefaultDirectoryForSaveAs): Likewise, (doSaveAs): Apply default directory. 2007-10-24 David Gilbert * experimenta/org/jfree/experimental/chart/plot/dial/*.java: Moved this package to org.jfree.chart.plot.dial.*, * experimenta/org/jfree/experimental/chart/plot/dial/junit/*.java: Moved this package to org.jfree.chart.plot.dial.junit.*. 2007-10-24 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java: Removed and renamed ArcDialFrame.java, * experimental/org/jfree/experimental/chart/plot/dial/ArcDialFrame.java: New file. 2007-10-24 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java (pointers): New field, (DialPlot): Delegate to new constructor, (DialPlot(ValueDataset)): New constructor, (addPointer): New method, (getPointerIndex): Likewise, (removePointer(int)): Likewise, (removePointer(DialPointer)): Likewise, (getPointerForDataset): Likewise, (draw): Draw pointers in their own layer, (equals): Check new pointers field, * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java: Implemented PublicCloneable, (DialPointer): Changed to protected, (DialPointer(int)): Likewise, and changed default radius, (Pin.setPaint): Added argument check, (Pin.setStroke): Likewise, (Pointer(int)): Removed radius setting, * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java (getAnchor): New method, (setAnchor): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java (DialValueIndicator): New constructor, (DialValueIndicator(int, String)): Removed string argument, (setDatasetIndex): Fire change event, (setTemplateValue): Check for null argument, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java (setInnerRadius): Added argument check, (setOuterRadius): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java (scaleIndex): New field, (StandardDialRange(double, double)): Added field initialisations, (getScaleIndex): New method, (setScaleIndex): Likewise, (draw): Get the correct scale, (equals): Updated for new field, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java (minorTickPaint): New field, (minorTickStroke): Likewise, (tickLabelFormatter): Likewise, (StandardDialScale): Updated for modified constructor signature, (StandardDialScale(double, double, double, double)): Added two new arguments to signature, (setMajorTickLength): Added argument check, (setMinorTickCount): Likewise, (setMinorTickLength): Likewise, (getMinorTickPaint): New method, (setMinorTickPaint): Likewise, (getTickLabelFormatter): Likewise, (setTickLabelFormatter): Likewise, (draw): Fix major tick length, format labels with new formatter, (equals): Updated for new fields, (hashCode): Implemented, (writeObject): Handle new fields, (readObject): Likewise. 2007-10-23 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (drawRoundRect): Implemented, (fillRoundRect): Likewise, (clearRect): Implemented. 2007-10-23 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (drawArc): Implemented, (fillArc): Likewise. 2007-10-23 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (drawOval): Implemented, (fillOval): Likewise. 2007-10-23 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (drawPolyline): Implemented. 2007-10-23 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (drawPolygon): Implemented. 2007-10-23 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (hints): New field, (SWTGraphics2D): Initialise new field, (getRenderingHint): Implemented, (setRenderingHint): Likewise, (getRenderingHints): Likewise, (addRenderingHints): Likewise, (setRenderingHints): Likewise. 2007-10-23 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (lookupSeriesPaint): Call accessor methods for per-series paint, (lookupSeriesFillPaint): Likewise, (lookupSeriesOutlinePaint): Likewise, (lookupSeriesStroke): Likewise, (lookupSeriesOutlineStroke): Likewise, (lookupSeriesStroke): Likewise. 2007-10-22 Henry Proudhon * source/swt/org/jfree/experimental/chart/swt/ChartComposite.java: (chart): Made the chart field be private again, (ChartComposite): Refactored class, now implements PaintListener, MouseListener and MouseMovedListener, (zoom): Fixed bug with multiple plots, (addChartMouseListener): Implemented, (removeChartMouseListener): Likewise, (restoreAutoDomainBounds): Fixed NPE, (restoreAutoRangeBounds): Likewise, (widgetDefaultSelected): Implemented, (addSWTListener): New method, (mouseDoubleClick): Likewise, (mouseDown): Likewise, (mouseUp): Likewise, (mouseMove): Likewise, (paintControl): Likewise, * source/swt/org/jfree/experimental/swt/SWTUtils.java (toAwtMouseEvent): changed method signature. 2007-10-22 Henry Proudhon * source/swt/org/jfree/experimental/swt/SWTUtils.java (toAwtMouseEvent): Improved mouse event conversion. 2007-10-22 Henry Proudhon * swt/org/jfree/experimental/swt/SWTGraphics2D.java (composite): New field, (setComposite): Implemented, (getComposite): Return from field. 2007-10-22 Henry Proudhon * swt/org/jfree/experimental/swt/SWTGraphics2D.java (getClip): Implemented. 2007-10-17 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/AbstractDialLayer.java (equals): New method override, (clone): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/DialBackground.java (equals): Added call to super.equals(); * experimental/org/jfree/experimental/chart/plot/dial/DialCap.java (equals): Added call to super.equals(); * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java (setBackground): Fix listener registration, (setCap): Likewise, (setDialFrame): Likewise, (addLayer): Likewise, (getLayerIndex(DialLayer)): New method, (removeLayer(int)): Likewise, (removeLayer(DialLayer)): Likewise, (addScale): Fix listener registration, * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java (equals): New method override, (Pin.equals): Likewise, (Pin.readObject): New method, (Pin.writeObject): Likewise, (Pointer.equals): New method override, * experimental/org/jfree/experimental/chart/plot/dial/DialScale.java: Now extends DialLayer, * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java (equals): Added call to super.equals(); * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java (equals): Added call to super.equals(); * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java (equals): Added call to super.equals(); * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java (equals): Added call to super.equals(); * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java (increment): Removed field, (setLowerBound): Added argument check, (setUpperBound): Likewise, (setBounds): New method, (equals): Updated, (hashCode): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java (setTickRadius): Added argument check, (setMajorTickIncrement): Likewise, (setTickLabelPaint): Likewise, (equals): Updated. 2007-10-16 David Gilbert * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java: (nullXString): Removed, (createItemArray): Removed check for null x-value. 2007-10-16 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer3D.java (drawRangeMarker): Use adjusted data area; * source/org/jfree/chart/renderer/category/LineRenderer3D.java (drawRangeMarker): Use adjusted data area, and call super to handle IntervalMarker (DG); 2007-10-11 David Gilbert * source/org/jfree/chart/renderer/category/MultiValueRenderer.java: Renamed ScatterRenderer.java; * tests/org/jfree/chart/renderer/category/junit/MultiValueRendererTests.java: Renamed ScatterRendererTests.java. 2007-10-11 David Gilbert * source/org/jfree/chart/plot/ThermometerPlot.java (DEFAULT_GAP_RADIUS): Renamed DEFAULT_GAP, (gapRadius): Renamed gap, (getGapRadius): Renamed getGap(), (setGapRadius): Renamed setGap(), (getGapDiameter): Removed, (draw): Updated for method name changes, (equals): Likewise. 2007-10-08 David Gilbert Based on Patch 1769088: * source/org/jfree/chart/plot/ThermometerPlot.java (BULB_RADIUS): Deprecated, (BULB_DIAMETER): Likewise, (COLUMN_RADIUS): Likewise, (COLUMN_DIAMETER): Likewise, (GAP_RADIUS): Likewise, (GAP_DIAMETER): Likewise, (bulbRadius): New field, (columnRadius): Likewise, (gapRadius): Likewise, (getBulbRadius): New method, (setBulbRadius): Likewise, (getBulbDiameter): Likewise, (getColumnRadius): Likewise, (setColumnRadius): Likewise, (getColumnDiameter): Likewise, (getGapRadius): Likewise, (setGapRadius): Likewise, (getGapDiameter): Likewise, (draw): Use attributes rather than constants, (equals): Updated for new fields, * tests/org/jfree/chart/plot/junit/ThermometerPlotTests.java (testEquals): Updated for new fields. 2007-10-08 David Gilbert * source/org/jfree/chart/renderer/category/MultiShapeRenderer.java: New file, * source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java: Likewise, * source/org/jfree/data/statistics/MultiValueCategoryDataset.java: Likewise, * tests/org/jfree/chart/renderer/category/junit/MultiShapeRendererTests.java: Likewise, * tests/org/jfree/chart/renderer/category/junit/RendererCategoryPackageTests.java (suite): Added MultiShapeRendererTests, * tests/org/jfree/data/statistics/junit/DataStatisticsPackageTests.java (suite): Added DefaultMultiValueCategoryDatasetTests, * tests/org/jfree/data/statistics/junit/DefaultMultiValueCategoryDatasetTests.java: New file. 2007-10-08 David Gilbert * source/org/jfree/chart/plot/ValueMarker.java (ValueMarker(double, Paint, Stroke, Paint, Stroke, float)): Fixed call to super, * tests/org/jfree/chart/plot/junit/ValueMarkerTests.java (test1808376): New test method. 2007-10-08 David Gilbert * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (volumePaint): New field, (CandlestickRenderer(double, boolean, XYToolTipGenerator)): Initialise new field, (getVolumePaint): New method, (setVolumePaint): Likewise, (drawItem): Use new paint attribute, (equals): Add check for new field, (writeObject): Handle serialization for new field, (readObject): Likewise, * tests/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java (EPSILON): New field, (testConstructor): New method, (testEquals): Added check for new field. 2007-10-05 David Gilbert Based on patch 1805262 by Alex Moots: * source/org/jfree/chart/plot/PiePlot3D.java (darkerSides): New field, (getDarkerSides): New method, (setDarkerSides): Likewise, (drawSide): Make side colour darker if necessary, (equals): Updated for new field, * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java (testEquals): Updated for new field. 2007-10-03 David Gilbert * source/org/jfree/data/KeyedObjects2D.java (getRowIndex): Check for null argument, (getColumnIndex): Likewise, (removeObject): Check for unknown keys, (clear): New method, * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java (rangeBounds): Removed, (DefaultBoxAndWhiskerCategoryDataset()): Updated for removed field, (add(BoxAndWhiskerItem, Comparable, Comparable)): Likewise, (remove(Comparable, Comparable)): New method, (removeRow(int)): Likewise, (removeRow(Comparable)): Likewise, (removeColumn(int)): Likewise, (removeColumn(Comparable)): Likewise, (clear): Likewise, (getRangeBounds): Return new instance every time, * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java (remove(Comparable, Comparable)): New method, (removeRow(int)): Likewise, (removeRow(Comparable)): Likewise, (removeColumn(int)): Likewise, (removeColumn(Comparable)): Likewise, (clear): Likewise, (getRangeBounds): Return new instance every time, * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java (testRemove): New method, * tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java (testRemove): New method. 2007-10-03 David Gilbert * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java (add(BoxAndWhiskerItem, Comparable, Comparable)): Update cached bounds by iteration if necessary, (updateBounds): New private method, * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java (testGetRangeBounds): New test method. 2007-10-03 David Gilbert * source/org/jfree/data/KeyedObjects2D.java (getObject(Comparable, Comparable)): Check arguments for null or unrecognised keys, (setObject(Object, Comparable, Comparable): Check for null arguments, (removeObject): Check if row or column needs removing, (removeRow(Comparable)): Check for unrecognised key, (removeColumn(Comparable)): Likewise, * tests/org/jfree/data/junit/KeyedObjects2DTests.java (testGetValueByIndex): New test method, (testGetValueByKey): Likewise, (testSetObject): Likewise, (testRemoveRowByIndex): Likewise, (testRemoveColumnByIndex): Likewise, (testRemoveRowByKey): Likewise, (testRemoveColumnByKey): Likewise, (testRemoveValue): Likewise. 2007-10-03 David Gilbert * source/org/jfree/data/DefaultKeyedValues.java (removeValue(Comparable)): Throw UnknownKeyException for unrecognised key, * source/org/jfree/data/KeyedObjects.java (getObject(int)): Allow IndexOutOfBoundsException to be thrown, (getKey(int)): Likewise, (getIndex): Check for null argument, (getObject): Throw UnknownKeyException for unrecognised key, (insertValue): New method, (removeValue): Throw UnknownKeyException for unrecognised key, (clear): New method, (hashCode): Likewise, * source/org/jfree/data/KeyedObjects2D.java (getObject): Check for missing key in underlying data structure, * tests/org/jfree/data/junit/DefaultKeyedValuesTests.java (testRemoveValue): Updated checks for consistency with KeyedObjects, * tests/org/jfree/data/junit/KeyedObjectsTests.java (testInsertAndRetrieve): Updated checks, (testGetObject): New test method, (testGetKey): Likewise, (testGetIndex): Likewise, (testSetObject): Likewise, (testRemoveValue): Likewise, (testRemoveValueInt): Likewise. 2007-10-02 David Gilbert * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java (minimumRangeValueRow): New field, (minimumRangeValueColumn): Likewise, (minimumRangeValueIncStdDevRow): Likewise, (minimumRangeValueIncStdDevColumn): Likewise, (maximumRangeValueRow): Likewise, (maximumRangeValueColumn): Likewise, (maximumRangeValueIncStdDevRow): Likewise, (maximumRangeValueIncStdDevColumn): Likewise, (DefaultStatisticalCategoryDataset()): Initialise new fields, (add(Number, Number, Comparable, Comparable)): Fixed calculation of bounds, (updateBounds): New method, (getRangeLowerBound): Observe includeInterval flag, (getRangeUpperBound): Likewise, * source/org/jfree/data/statistics/MeanAndStandardDeviation.java (getMeanValue): New method, (getStandardDeviationValue): Likewise, (toString): Likewise, * tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java (testGetRangeBounds): Fixed broken test, (EPSILON): New field, (testAdd): New test method, (testGetRangeLowerBound): Likewise, (testGetRangeUpperBound): Likewise, (testGetRangeBounds2): Likewise. 2007-10-02 David Gilbert * source/org/jfree/data/statistics/BoxAndWhiskerItem.java (BoxAndWhiskerItem(double, double, double, double, double, double, double, double, List)): New constructor, * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java (minimumRangeValue): Changed from Number to double, (minimumRangeValueRow): New field, (minimumRangeValueColumn): Likewise, (maximumRangeValue): Changed from Number to double, (maximumRangeValueRow): New field, (maximumRangeValueColumn): Likewise, (DefaultBoxAndWhiskerCategoryDataset): Updated for changed field types, (add): Fix updating of cached range values, (getRangeLowerBound): Update for changed field type, (getRangeUpperBound): Likewise, * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDataset.java (testAdd): New test method, (testAddUpdatesCachedRange): Likewise, (testConstructor): Likewise. 2007-09-28 David Gilbert * source/org/jfree/data/KeyedObjects.java (equals): Cleaned up, * source/org/jfree/data/KeyedObjects2D.java (equals): Likewise, (clone): Clone data storage, * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java (clone): New method override, * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java (clone): Likewise, * tests/org/jfree/data/junit/KeyedObjects2DTests.java (testEquals): New test, (testCloning): Check independence, * tests/org/jfree/data/junit/KeyedObjectsTests.java (testCloning2): New test, * tests/org/jfree/data/junit/KeyedObjectTests.java (testCloning2): New test, * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java (testCloning): Check independence, * tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java (testCloning): Check independence. 2007-09-28 David Gilbert * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java (drawItem): Simplified entity generation code. 2007-09-28 David Gilbert * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java (setGroupStroke): Check for null argument, add event notification, (equals): New method override, * tests/org/jfree/chart/renderer/category/junit/MinMaxCategoryRendererTests.java (testEquals): Extended to cover additional fields. 2007-09-27 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): Apply new offset option to x-coordinates. 2007-09-27 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (getCategorySeriesMiddle): New method, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (useSeriesOffset): New field, (itemMargin): Likewise, (LineAndShapeRenderer(boolean, boolean)): Initialise new fields, (getUseSeriesOffset): New method, (setUseSeriesOffset): Likewise, (getItemMargin): Likewise, (setItemMargin): Likewise, (drawItem): Apply new offset option to x-coordinates, (equals): Check new fields, * tests/org/jfree/chart/renderer/category/junit/LineAndShapeRendererTests.java (testEquals): Updated for new fields. 2007-09-26 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): Simplified entity generation code. 2007-09-26 David Gilbert * source/org/jfree/chart/renderer/GrayPaintScale.java (getPaint): Use constrained value to calculate gray scale value, * tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java (testConstructor): New test method, (testGetPaint): Likewise. 2007-09-26 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItem): Apply margin in a way that works for inverted axes. 2007-09-26 David Gilbert * source/org/jfree/chart/plot/PlotUtilities.java: New class, * source/org/jfree/data/general/DatasetUtilities.java (isEmptyOrNull(XYDataset)): Return early if not empty, * tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java (testIsEmptyOrNullXYDataset): New test method. 2007-09-26 David Gilbert * source/org/jfree/data/general/Series.java (getItemCount): New abstract method, (isEmpty): New method. 2007-09-26 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (getQuadrantPaint): Improve exception text, (setQuadrantPaint): Likewise, (getDomainAxisForDataset): Likewise, (getRangeAxisForDataset): Likewise. 2007-09-26 David Gilbert * source/org/jfree/chart/plot/Marker.java (readObject): Initialise listener list, * tests/org/jfree/chart/plot/junit/ValueMarkerTests.java (test1802195): New test method. 2007-09-24 David Gilbert * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (linesVisible): Deprecated, (shapesVisible): Likewise, (shapesFilled): Likewise, (getLinesVisible): Likewise, (setLinesVisible(Boolean)): Likewise, (setLinesVisible(boolean)): Likewise, (getShapesVisible): Likewise, (setShapesVisible(Boolean)): Likewise, (setShapesVisible(boolean)): Likewise, (setUseOutlinePaint): Fire change event, (getShapesFilled): Deprecated, (setShapesFilled(Boolean)): Likewise, (setShapesFilled(boolean)): Likewise, (setSeriesShapesFilled): Fire change event, (setBaseShapesFilled): Likewise, (equals): Minor tidy up. 2007-09-24 David Gilbert * source/org/jfree/chart/ChartPanel.java (paintComponent): Clear chart buffer before refreshing. 2007-09-24 David Gilbert * source/org/jfree/chart/ChartPanel.java (zoomAroundAnchor): New field, (getZoomAroundAnchor): New method, (setZoomAroundAnchor): Likewise, (zoomInDomain): Use zoomAroundAnchor flag, (zoomInRange): Likewise, (zoomOutDomain): Likewise, (zoomOutRange): Likewise, * source/org/jfree/chart/plot/CategoryPlot.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): Delegate to new method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, * source/org/jfree/chart/plot/FastScatterPlot.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, * source/org/jfree/chart/PolarPlot.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, * source/org/jfree/chart/ThermometerPlot.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, * source/org/jfree/chart/XYPlot.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomDomainAxes(double, PlotRenderingInfo, Point2D)): Delegate to new method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): Delegate to new method, * source/org/jfree/chart/plot/Zoomable.java (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise. 2007-09-21 David Gilbert * source/org/jfree/data/statistics/SimpleHistogramDataset.java: API doc updates. 2007-08-28 David Gilbert * source/org/jfree/data/time/Week.java (Week(Date, TimeZone)): Deprecated, (Week(Date, TimeZone, Locale)): New constructor, * tests/org/jfree/data/time/junit/WeekTests.java (testConstructor): New test. 2007-08-28 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java (drawHorizontalItem): Check for null data items, (drawVerticalItem): Likewise, * tests/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.java (testDrawWithNullMeanVertical): New test method, (testDrawWithNullMeanHorizontal): Likewise, (testDrawWithNullDeviationVertical): Likewise, (testDrawWithNullDeviationHorizontal): Likewise. 2007-08-03 David Gilbert * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java (precision): Initialise in constructor, (XYSplineAndShapeRenderer()): Change default precision to 5, (XYSplineAndShapeRenderer(int)): New constructor. 2007-08-03 David Gilbert Fix for bug 1766646: * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java (findDomainBounds): Check for null, (findRangeBounds): Likewise. 2007-08-03 David Gilbert * source/org/jfree/chart/LegendItem.java (LegendItem): Initialise GradientPaintTransformer. 2007-08-02 David Gilbert * experimental/org/jfree/experimental/chart/axis/LogAxis.java (LogAxis(String)): Leave tick marks visible, (autoAdjustRange): Apply margins to log scale, and don't allow auto-range to go below minimum value, (refreshTicksHorizontal): Improved handling of ticks and labels, (refreshTicksVertical): Likewise, (selectAutoTickUnit): New method, (selectHorizontalAutoTickUnit): Likewise, (selectVerticalAutoTickUnit): Likewise, (exponentLengthToJava2D): Likewise, (estimateMaximumTickLabelHeight): Likewise, (estimateMaximumTickLabelWidth): Likewise, (equals): New method override, (hashCode): Likewise, (createLogTickUnits): New method, and moved to source/org/jfree/chart/axis/, * source/org/jfree/chart/axis/NumberTick.java (NumberTick(TickType, double, String, TextAnchor, TextAnchor, double)): New constructor, * source/org/jfree/chart/axis/NumberTickUnit.java (NumberTickUnit(double, NumberFormat, int)): New constructor, (toString): New method override, * source/org/jfree/chart/axis/TickType.java: New file, * source/org/jfree/chart/axis/TickUnit.java (minorTickCount): New field, (TickUnit(double, int)): New constructor, (getMinorTickCount): New method, (equals): Updated for new field, * source/org/jfree/chart/axis/TickUnits.java: Reformatting only, * source/org/jfree/chart/axis/ValueAxis.java (drawTickMarksAndLabels): Check for major tick before writing label, * source/org/jfree/chart/axis/ValueTick.java: (tickType): New field, (ValueTick(TickType, double, String, TextAnchor, TextAnchor, double)): New constructor, (getTickType): New method, (equals): Updated for new field, * source/org/jfree/chart/util/LogFormat.java: New file, * tests/org/jfree/chart/axis/junit/AxisPackageTests.java (suite): Added LogAxisTests and TickUnitsTests, * tests/org/jfree/chart/axis/junit/LogAxisTests.java: New file, * tests/org/jfree/chart/axis/junit/TickUnitsTests.java: Likewise. 2007-07-31 David Gilbert Bug 1763413: * source/org/jfree/chart/axis/PeriodAxis.java (drawTickLabels): Calculate tick label width correctly for inverted axis. 2007-07-25 David Gilbert Patch 1752205: * source/org/jfree/data/time/TimeTableXYDataset.java (clear): New method, * tests/org/jfree/data/time/junit/TimeTableXYDatasetTests.java (testClear): New method. 2007-07-25 David Gilbert * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java: New file, contributed by Klaus Rheinwald. 2007-07-25 David Gilbert * source/org/jfree/chart/axis/SymbolAxis.java (DEFAULT_GRID_BAND_ALTERNATE_PAINT): New field, (gridBandAlternatePaint): New field, (SymbolAxis): Initialise new field, (getGridBandAlternatePaint): New method, (setGridBandAlternatePaint): Likewise, (equals): Test new field, (writeObject): Handle new field, (readObject): Likewise, * tests/org/jfree/chart/axis/junit/SymbolAxisTests.java (testEquals): Added check for new field. 2007-07-18 David Gilbert * source/org/jfree/chart/demo/PieChartDemo1.java (createChart): Modified settings, * source/org/jfree/chart/plot/PiePlot.java (DEFAULT_INTERIOR_GAP): Modified default, (DEFAULT_LABEL_SHADOW_PAINT): Likewise, (simpleLabels): New field, (labelPadding): Likewise, (simpleLabelOffset): Likewise, (PiePlot(PieDataset)): Initialise new fields, (getLabelPadding): New method, (setLabelPadding): Likewise, (getSimpleLabels): Likewise, (setSimpleLabels): Likewise, (getSimpleLabelOffset): Likewise, (setSimpleLabelOffset): Likewise, (drawPie): Added simple label handling, (drawSimpleLabels): New method, (drawLabels): Reformatting, (drawLeftLabels): Set label padding, (drawRightLabels): Likewise, (equals): Updated for new fields, * source/org/jfree/chart/plot/PiePlot3D.java (draw): Updated for simple labels. 2007-07-18 David Gilbert * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (remove): Actually remove the subplot. 2007-07-11 David Gilbert * experimental/org/jfree/experimental/chart/axis/LogAxis.java (setSmallestValue): Added event notification, (zoomRange): New method override. 2007-07-11 David Gilbert * source/org/jfree/chart/axis/SegmentedTimeline.java (FIRST_MONDAY_AFTER_1900): Deprecated, (NO_DST_TIME_ZONE): Likewise, (DEFAULT_TIME_ZONE): Likewise, (workingCalendarNoDST): Initialise in constructor, (SegmentedTimeline): Initialise workingCalendarNoDST, (firstMondayAfter1900): New method, (newMondayThroughFridayTimeline): Use new method for first monday, (newFifteenMinuteTimeline): Likewise, * tests/org/jfree/chart/axis/junit/SegmentedTimelineTests2.java: Save and restore time zone in all tests. 2007-07-11 David Gilbert * tests/org/jfree/data/time/junit/DayTests.java (testGetFirstMillisecond): Set/restore time zone, (testGetFirstMillisecondWithCalendar): Set time zone, (testGetLastMillisecond): Set/restore time zone, (testGetLastMillisecondWithCalendar): Set time zone, * tests/org/jfree/data/time/junit/HourTests.java: Likewise, * tests/org/jfree/data/time/junit/MillisecondTests.java: Likewise, * tests/org/jfree/data/time/junit/MinuteTests.java: (testGetFirstMillisecond): Set/restore time zone, (testGetFirstMillisecondWithCalendar): Set time zone, (testGetLastMillisecond): Set/restore time zone, (testGetLastMillisecondWithCalendar): Set time zone, (testGetStart): Set/restore time zone, (testGetEnd): Likewise, * tests/org/jfree/data/time/junit/MonthTests.java (testGetFirstMillisecond): Set/restore time zone, (testGetFirstMillisecondWithCalendar): Set time zone, (testGetLastMillisecond): Set/restore time zone, (testGetLastMillisecondWithCalendar): Set time zone, * tests/org/jfree/data/time/junit/QuarterTests.java: Likewise, * tests/org/jfree/data/time/junit/SecondTests.java: Likewise, * tests/org/jfree/data/time/junit/WeekTests.java: Likewise, * tests/org/jfree/data/time/junit/YearTests.java: Likewise. 2007-07-10 David Gilbert * source/org/jfree/chart/ChartFactory.java (createPieChart(String, PieDataset, boolean, boolean, Locale)): New method, (createPieChart(String, PieDataset, PieDataset, int, boolean, boolean, boolean, Locale, boolean, boolean)) : Likewise, (createRingChart(String, PieDataset, boolean, boolean, Locale)): Likewise, (createPieChart3D(String, PieDataset, boolean, boolean, Locale)): Likewise, * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java (StandardPieSectionLabelGenerator(Locale)): New constructor, (StandardPieSectionLabelGenerator(String labelFormat, Locale)): Likewise, * source/org/jfree/chart/labels/StandardPieToolTipGenerator.java (StandardPieToolTipGenerator): Delegate, (StandardPieToolTipGenerator(Locale)): New constructor, (StandardPieToolTipGenerator(String)): Delegate, (StandardPieToolTipGenerator(String labelFormat, Locale)): New constructor. 2007-07-10 David Gilbert * tests/org/jfree/chart/renderer/xy/junit/ClusteredXYBarRendererTests.java (EPSILON): New field, (testFindDomainBounds): Fixed compile errors, * tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java (EPSILON): New field, (testGetDomainBoundsWithoutInterval): Fixed compile errors, (testGetDomainBoundsWithInterval): Likewise. 2007-07-10 David Gilbert * source/org/jfree/data/statistics/SimpleHistogramDataset.java (SimpleHistogramDataset): Check for null argument. 2007-07-10 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (getRangeAxisIndex): New method. ---------- JFREECHART 1.0.6 RELEASED ------------------------ 2007-06-15 David Gilbert * swt/org/jfree/experimental/swt/SWTGraphics2D.java (getSwtColorFromPool): Removed JDK 1.5 specific code. 2007-06-15 David Gilbert * ant/build.xml: Updated version number to 1.0.6, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (XYBarRenderer): Changed default value for drawBarOutline. 2007-06-14 David Gilbert * source/org/jfree/chart/plot/AbstractPieLabelDistributor.java: New file, * source/org/jfree/chart/plot/PieLabelDistributor.java: Now extends AbstractPieLabelDistributor, * source/org/jfree/chart/plot/PieLabelRecord: Implemented Serializable, * source/org/jfree/chart/plot/PiePlot.java (labelDistributor): New field, (PiePlot(PieDataset)): Initialise new field, (getLabelDistributor): New method, (setLabelDistributor): New method. 2007-06-14 David Gilbert * source/org/jfree/chart/renderer/LookupPaintScale.java (PaintItem.value): Changed from Number to double, (PaintItem(Number, Paint)): Changed first parameter to double, (compareTo): Updated for change in value type, (equals): Likewise, (add(Number, Paint)): Deprecated, (add(double, Paint)): New method, (getPaint): Updated. 2007-06-14 David Gilbert * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java (XYBoxAndWhiskerRenderer(double)): Replaced deprecated method call, (drawHorizontalItem): Call addEntity(), (drawVerticalDataItem): Likewise. 2007-06-14 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): If dataset is not a StatisticalCategoryDataset, revert to the super class drawing behaviour. 2007-06-14 David Gilbert * experimental/org/jfree/chart/renderer/xy/XYSmoothLineAndShapeRenderer.java: New class. 2007-06-14 David Gilbert * source/org/jfree/chart/block/LineBorder.java (draw): Don't draw if area doesn't have positive dimensions, * source/org/jfree/chart/util/HexNumberFormat.java: New class. 2007-06-13 David Gilbert * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java (add): Assign max outlier value to maxValue. 2007-06-13 David Gilbert * source/org/jfree/chart/plot/DefaultDrawingSupplier.java (DEFAULT_FILL_PAINT_SEQUENCE): New field, (fillPaintSequence): Likewise, (fillPaintIndex): Likewise, (DefaultDrawingSupplier): Constructors updated for new field, (getNextFillPaint): New method, * source/org/jfree/chart/plot/DrawingSupplier.kava (getNextFillPaint): New method, * source/org/jfree/chart/renderer/AbstractRenderer.java (autoPopulateSeriesPaint): New field, (autoPopulateSeriesFillPaint): Likewise, (autoPopulateSeriesOutlinePaint): Likewise, (autoPopulateSeriesStroke): Likewise, (autoPopulateSeriesOutlineStroke): Likewise, (autoPopulateSeriesShape): Likewise, (AbstractRenderer): Initialise new fields, (lookupSeriesPaint): Check autoPopulateField, (getAutoPopulateSeriesPaint): New method, (setAutoPopulateSeriesPaint): New method, (lookupSeriesFillPaint): New method, (getAutoPopulateSeriesFillPaint): New method, (setAutoPopulateSeriesFillPaint): New method, (lookupSeriesOutlinePaint): New method, (getAutoPopulateSeriesOutlinePaint): New method, (setAutoPopulateSeriesOutlinePaint): New method, (lookupSeriesStroke): New method, (getAutoPopulateSeriesStroke): New method, (setAutoPopulateSeriesStroke): New method, (lookupSeriesOutlineStroke): New method, (getAutoPopulateSeriesOutlineStroke): New method, (setAutoPopulateSeriesOutlineStroke): New method, (lookupSeriesShape): New method, (getAutoPopulateSeriesShape): New method, (setAutoPopulateSeriesShape): New method. 2007-06-13 David Gilbert * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (drawItem): Check item visibility flag, and check that entity hotspot is contained in dataArea before adding an entity, (getLegendItem): Reduced indentation. 2007-06-12 David Gilbert * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java (findDomainBounds): New method override, (findDomainBoundsWithOffset): New utility method, (drawItem): Fixed to handle inverted axes, * tests/org/jfree/chart/renderer/xy/junit/ClusteredXYBarRendererTests.java (testFindDomainBounds): New test, (createSampleDataset1): New helper method. 2007-06-12 David Gilbert * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java (drawItem): Simplified chart entity generation, (equals): Reorganised. 2007-06-11 David Gilbert * source/org/jfree/chart/ChartFactory.java (createBarChart): Replaced deprecated method calls, (createWaterfallChart): Likewise, (createBoxAndWhiskerChart): Likewise. 2007-06-11 David Gilbert * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (CandlestickRenderer(double, boolean, XYToolTipGenerator)): Replaced call to deprecated setToolTipGenerator() method. 2007-06-11 David Gilbert * source/org/jfree/data/time/TimePeriodValuesCollection.java (TimePeriodValuesCollection(TimePeriodValues)): Changed default value for this.domainIsPointsInTime, (getDomainBounds): Use includeInterval parameter correctly, * tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java (testGetDomainBoundsWithoutInterval): New method, (testGetDomainBoundsWithInterval): Likewise. 2007-06-08 David Gilbert * source/org/jfree/chart/axis/QuarterDateFormat.java (GREEK_QUARTERS): New field, (quarterFirst): Likewise, (QuarterFormat(TimeZone, String[], boolean)): New constructor, (equals): Updated for new field, * tests/org/jfree/chart/axis/junit/QuarterDateFormatTests.java (testEquals): Added check for new field. 2007-06-08 David Gilbert * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (drawItem): Take orientation into account when passing coordinates to addEntity(), * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (drawSecondaryPass): Likewise, * tests/org/jfree/chart/junit/TestUtilities.java: New file, * tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.java (testNoDisplayedItem): New method. 2007-06-08 David Gilbert * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (drawSecondaryPass): Only add entity if data point is within the visible data area. 2007-06-07 David Gilbert * source/org/jfree/chart/plot/Plot.java (fillBackground(Graphics2D, Rectangle2D)): Delegate to new method, (fillBackground(Graphics2D, Rectangle2D, PlotOrientation)): New method, * source/org/jfree/chart/plot/CategoryPlot.java (drawBackground): New method override, * source/org/jfree/chart/plot/XYPlot.java (drawBackground): Call new fillBackground() method. 2007-06-06 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (getToolTipText): Fixed minor issues with tooltips. bug reported and fix proposed by Christoph Beck, bug 1726404 (HP); 2007-06-06 David Gilbert * source/org/jfree/chart/ChartPanel.java (paintComponent): Fixed coordinates for drawing buffer image (DG); 2007-06-05 David Gilbert * source/org/jfree/chart/JFreeChart.java (JFreeChart(String, Font, Plot, boolean)): Add change listener to legend, if created, * tests/org/jfree/chart/junit/JFreeChartTests.java (testLegendEvents): New test, (chartChanged): New method, (lastChartChangeEvent): New field. 2007-06-01 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (addItemEntity): Fixed deprecation warning, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawHorizontalItem): Likewise, (drawVerticalItem): Likewise, * source/org/jfree/chart/renderer/category/GanttRenderer.java (drawTasks): Likewise, (drawTask): Likewise, * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java (drawInterval): Likewise, * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java (drawHorizontalItem): Likewise, (drawVerticalItem): Likewise, * source/org/jfree/chart/renderer/category/LevelRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java (drawItem): Likewise. 2007-06-01 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java (drawItem): Return early for non-visible items, (equals): Call super.equals() last. 2007-05-30 David Gilbert * source/org/jfree/chart/axis/SubCategoryAxis.java (addSubCategory): Added argument check and event notification. 2007-05-25 David Gilbert * experimental/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java: Moved to source/org/jfree/chart/renderer/xy/VectorRenderer.java * experimental/org/jfree/experimental/data/xy/Vector.java: Moved to source/org/jfree/data/xy/Vector.java, * experimental/org/jfree/experimental/data/xy/VectorDataItem.java: Moved to source/org/jfree/data/xy/VectorDataItem.java, * experimental/org/jfree/experimental/data/xy/VectorSeries.java: Moved to source/org/jfree/data/xy/VectorSeries.java, * experimental/org/jfree/experimental/data/xy/VectorSeriesCollection.java: Moved to source/org/jfree/data/xy/VectorSeriesCollection.java, * experimental/org/jfree/experimental/data/xy/VectorXYDataset.java: Moved to source/org/jfree/data/xy/VectorXYDataset.java, * experimental/org/jfree/experimental/data/xy/XYCoordinate.java: Moved to source/org/jfree/data/xy/XYCoordinate.java. 2007-05-25 David Gilbert * ant/build.xml: Added '-cvs' to version number, removed gjdoc, * experimental/org/jfree/experimental/data/xy/VectorSeries.java (remove): New method, (clear): Likewise. 2007-05-25 David Gilbert Translations provided by Leonardo Alves Machado: * source/org/jfree/chart/LocalizationBundle_pt_BR.properties: New file, * source/org/jfree/chart/editor/LocalizationBundle_pt_BR.properties: Likewise. 2007-05-24 David Gilbert * experimental/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java (findDomainBounds): Updated for method name changes, (findRangeBounds): Likewise, (drawItem): Likewise, * experimental/org/jfree/experimental/data/xy/Vector.java (getLength): New method, (getAngle): Likewise, * experimental/org/jfree/experimental/data/xy/VectorDataItem.java (getVector): New method, (getDeltaX): Renamed getVectorX(), (getDeltaY): Renamed getVectorY(), * experimental/org/jfree/experimental/data/xy/VectorSeries.java (getDeltaXValue): Renamed getVectorXValue(), (getDeltaYValue): Renamed getVectorYValue(), * experimental/org/jfree/experimental/data/xy/VectorSeriesCollection.java (removeSeries): New method, (removeAllSeries): Likewise, (indexOf): Likewise, (getVector): Likewise, (getDeltaXValue): Renamed getVectorXValue(), (getDeltaYValue): Renamed getVectorYValue(), * experimental/org/jfree/experimental/data/xy/VectorXYDataset.java (getDeltaXValue): Renamed getVectorXValue(), (getDeltaYValue): Renamed getVectorYValue(), (getDeltaX): Removed, (getDeltaY): Removed, (getVector): New method. 2007-05-24 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (render): Fixed bug for a series with zero items, * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (initialise): Disable visible items optimisation, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testDrawSeriesWithZeroItems): New test. 2007-05-24 David Gilbert * source/org/jfree/chart/ChartPanel.java (updateUI): Update UI for popup menu if there is one. 2007-05-24 David Gilbert * source/org/jfree/chart/ChartMouseEvent.java: API doc updates, * source/org/jfree/chart/ChartMouseListener.java: Likewise. 2007-05-19 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java Integrated a patch by Cédric Chabanois to remove resources leaks. * swt/org/jfree/experimental/swt/SWTGraphics2D.java Removed resource leaks by adding a resource pool thanks to a patch sent by Cédric Chabanois. 2007-05-21 David Gilbert * source/org/jfree/data/statistics/SimpleHistogramDataset.java (clearObservations): New method, (removeAllBins): Likewise, * tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.java (testClearObservations): New method, (testRemoveAllBins): Likewise. 2007-05-19 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (paintControl): corrected bug with scaling when the drawing region is larger than maximum draw width/height. 2007-05-19 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (paintControl): check for null chart 2007-05-18 David Gilbert * source/org/jfree/chart/LegendItem.java (dataset): New field, (seriesKey): Likewise, (getDataset): New method, (setDataset): Likewise, (getSeriesKey): Likewise, (setSeriesKey): Likewise, * source/org/jfree/chart/entity/CategoryItemEntity.java (dataset): No longer transient, (series): Deprecated, (category): Deprecated, (categoryIndex): Deprecated, (rowKey): New field, (columnKey): Likewise, (CategoryItemEntity(Shape, String, String, CategoryDataset, int, Object, int)): Deprecated, (CategoryItemEntity(Shape, String, String, CategoryDataset, Comparable, Comparable)): New constructor, (setDataset): Added argument check, (getRowKey): New method, (setRowKey): New method, (getColumnKey): New method, (setColumnKey): New method, (getSeries): Deprecated, (setSeries): Deprecated, (getCategory): Deprecated, (setCategory): Deprecated, (getCategoryIndex): Likewise, (setCategoryIndex): Likewise, (toString): Include new fields, (equals): Updated for new fields, * source/org/jfree/chart/entity/LegendItemEntity.java (dataset): New field, (seriesKey): New field, (getDataset): New method, (setDataset): New method, (getSeriesKey): New method, (setSeriesKey): New method, (getSeriesIndex): Deprecated, (setSeriesIndex): Deprecated, (equals): Updated for new fields, (toString): Likewise, * source/org/jfree/chart/plot/MeterPlot.java (getLegendItems): Set dataset for legend item, * source/org/jfree/chart/plot/MultiplePiePlot.java (getLegendItems): Likewise, * source/org/jfree/chart/plot/PiePlot.java (getLegendItems): Likewise, * source/org/jfree/chart/plot/SpiderWebPlot.java (getLegendItems): Likewise, * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (getLegendItem): Set dataset and series key, * source/org/jfree/chart/renderer/category/AreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/title/LegendItemBlockContainer.java (dataset): New field, (seriesKey): Likewise, (LegendItemBlockContainer(Arrangement, int, int)): Deprecated, (LegendItemBlockContainer(Arrangement, Dataset, Comparable)): New constructor, (getDataset): New method, (getSeriesKey): Likewise, (draw): Updated for new fields, * source/org/jfree/chart/title/LegendTitle.java (createLegendItemBlock): Replaced deprecated constructor, * tests/org/jfree/chart/entity/junit/CategoryItemEntityTests.java (testEquals): Updated, (testCloning): Reformatted, (testSerialization): Likewise, * tests/org/jfree/chart/entity/junit/LegendItemEntityTests.java (testEquals): Added checks for new fields, (testCloning): Reformatted, (testSerialization): Likewise. 2007-05-17 David Gilbert * source/org/jfree/chart/plot/MultiplePiePlot.java (setPieChart(JFreeChart)): Added argument checks. 2007-05-17 David Gilbert * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (getLegendItem): Set datasetIndex and seriesIndex, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (getLegendItem): Likewise, * tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.java (testGetLegendItemSeriesIndex): New test, * tests/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYBubbleRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYDifferenceRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYDotRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/XYLineAndShapeRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/xy/junit/YIntervalRendererTests.java (testGetLegendItemSeriesIndex): Likewise. 2007-05-17 David Gilbert * source/org/jfree/chart/renderer/category/AreaRenderer.java (getLegendItem): Set datasetIndex and seriesIndex, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (getLegendItem): Likewise, * tests/org/jfree/chart/renderer/category/junit/AreaRendererTests.java (testGetLegendItemSeriesIndex): New test, * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testGetLegendItemSeriesIndex): Likewise, * tests/org/jfree/chart/renderer/category/junit/LevelRendererTests.java (testGetLegendItemSeriesIndex): Likewise. 2007-05-17 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Set datasetIndex and seriesIndex, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (getLegendItem): Likewise, * tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java (testGetLegendItemSeriesIndex): New test, * tests/org/jfree/chart/renderer/category/junit/LineAndShapeRendererTests.java (testGetLegendItemSeriesIndex): Likewise. 2007-05-16 David Gilbert * source/org/jfree/chart/JFreeChart.java (getSubtitles): Copy list, (setSubtitles): Likewise, (addSubtitle(int, Title)): New method, * tests/org/jfree/chart/junit/JFreeChartTests.java (testAddSubtitle): New test method, (testGetSubtitles): Likewise. 2007-05-16 David Gilbert * source/org/jfree/chart/JFreeChart.java (getSubtitle): Fixed argument check, * tests/org/jfree/chart/junit/JFreeChartTests.java (testGetSubtitle): New test method. 2007-05-15 David Gilbert * source/org/jfree/chart/plot/Plot.java (outlineVisible): New field, (Plot): Initialise new field, (isOutlineVisible): New method, (setOutlineVisible): Likewise, (drawOutline): Check outlineVisible flag, (equals): Likewise. 2007-05-11 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Check for visibility, * tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java (testGetLegendItem): New test method. 2007-05-11 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (getLegendItem): Check for visibility, * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testGetLegendItem): New test method. 2007-05-08 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (drawStackHorizontal): Check drawBarOutlines flag, and add shading to bar sides, (drawStackVertical): Likewise. 2007-05-08 David Gilbert * source/org/jfree/data/time/TimeSeriesCollection.java (indexOf): New method, * source/org/jfree/data/xy/XYSeriesCollection.java (indexOf): Likewise, * tests/org/jfree/data/junit/time/TimeSeriesCollectionTests.java (testIndexOf): New method, * tests/org/jfree/data/junit/xy/XYSeriesCollectionTests.java (testIndexOf): Likewise. 2007-05-04 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (render): Only process visible data items, if possible, * source/org/jfree/chart/renderer/RendererUtilities.java: New file, * source/org/jfree/chart/renderer/xy/DeviationRenderer.java: (initialise): Disable visible items optimisation, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (initialise): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java: (initialise): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRendererState.java (processVisibleItemsOnly): New field, (XYItemRendererState): Initialise new field, (getProcessVisibleItemsOnly): New method, (setProcessVisibleItemsOnly): Likewise, * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (initialise): Disable visible items optimisation, * tests/org/jfree/chart/renderer/junit/RendererUtilitiesTests.java: New file. 2007-05-04 David Gilbert * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (drawSeries): Fixed lookup for series paint and stroke, (getLegendItem): Likewise. 2007-05-04 David Gilbert * source/org/jfree/data/time/TimeSeriesCollection.java (getDomainOrder): New method override. 2007-05-03 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): Fixed boundary cases for MILLISECOND, SECOND and MONTH units, * tests/org/jfree/chart/axis/junit/DateAxisTests.java (testPreviousStandardDateYear): Removed, (testPreviousStandardDateMonth): Removed, (testPreviousStandardDateDay): Removed, (testPreviousStandardDateHour): Removed, (testPreviousStandardDateMinute): Removed, (testPreviousStandardDateSecond): Removed, (testPreviousStandardDateMillisecond): Removed, (testPreviousStandardDateYearA): New method, (testPreviousStandardDateYearB): Likewise, (testPreviousStandardDateMonthA): Likewise, (testPreviousStandardDateMonthB): Likewise, (testPreviousStandardDateDayA): Likewise, (testPreviousStandardDateDayB): Likewise, (testPreviousStandardDateHourA): Likewise, (testPreviousStandardDateHourB): Likewise, (testPreviousStandardDateMinuteA): Likewise, (testPreviousStandardDateMinuteB): Likewise, (testPreviousStandardDateSecondA): Likewise, (testPreviousStandardDateSecondB): Likewise, (testPreviousStandardDateMillisecondA): Likewise, (testPreviousStandardDateMillisecondB): Likewise. 2007-05-03 David Gilbert * source/org/jfree/chart/plot/ThermometerPlot.java (subrangePaint): Made transient, (ThermometerPlot(ValueDataset)): Set axis field directly, (setRangeAxis): Added null argument check, and event notification, (setPadding): Added null argument check, (setUnits(String)): Deprecated, (setValueFont): Added null argument check, (setValuePaint): Likewise, (setValueFormat): Likewise, (setMercuryPaint): Likewise, (getShowValueLines): Deprecated, (setShowValueLines): Likewise, (datasetChanged): Check for null dataset, (writeObject): Handle subrange paint, (readObject): Likewise. 2007-05-01 David Gilbert * source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java (equals): New method override, (readObject): New method, (writeObject): New method. 2007-04-30 David Gilbert * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java (equals): Fixed incorrect cast, * experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java: New file. 2007-04-30 David Gilbert * source/org/jfree/data/general/DefaultPieDataset.java (insertValue(int, Comparable, double)): New method, (insertValue(int, Comparable, Double)): Likewise. 2007-04-30 David Gilbert * source/org/jfree/data/DefaultKeyedValues.java (insertValues(int, Comparable, double)): New method, (insertValues(int, Comparable, Double)): Likewise, * tests/org/jfree/data/junit/DefaultKeyedValuesTests.java (testConstructor): New test method, (testGetItemCount): Likewise, (testGetKeys): Likewise, (testGetValue): Extended, (testAddValue): New test method, (testInsertValue): Likewise. 2007-04-23 David Gilbert Patch from Richard West: * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (drawItemPass0): Reimplemented, (drawItemPass1): Likewise, (getPositiveArea): Removed, (getNegativeArea): Removed, (getIntersection): Removed, (isEitherSeriesDegenerate): New method, (areSeriesDisjoint): New method, (createPolygon): New method. 2007-04-20 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (positiveItemLabelPosition): Deprecated, (negativeItemLabelPosition): Likewise, (createEntities): Likewise, (getPositiveItemLabelPosition): Deprecated, (setPositiveItemLabelPosition(ItemLabelPosition)): Likewise, (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (getNegativeItemLabelPosition): Deprecated, (setNegativeItemLabelPosition(ItemLabelPosition)): Likewise, (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (getCreateEntities): Deprecated, (setCreateEntities(Boolean): Likewise, (setCreateEntities(Boolean, boolean)): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (getPositiveItemLabelPosition): Deprecated, (setPositiveItemLabelPosition(ItemLabelPosition)): Likewise, (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (getNegativeItemLabelPosition): Deprecated, (setNegativeItemLabelPosition(ItemLabelPosition)): Likewise, (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (getPositiveItemLabelPosition): Deprecated, (setPositiveItemLabelPosition(ItemLabelPosition)): Likewise, (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (getNegativeItemLabelPosition): Deprecated, (setNegativeItemLabelPosition(ItemLabelPosition)): Likewise, (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise. 2007-04-20 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (itemLabelsVisible): Deprecated, (itemLabelFont): Likewise, (itemLabelPaint): Likewise, (setItemLabelsVisible(boolean)): Likewise, (setItemLabelsVisible(Boolean)): Likewise, (setItemLabelsVisible(Boolean, boolean)): Likewise, (getItemLabelFont): Likewise, (setItemLabelFont(Font)): Likewise, (setItemLabelFont(Font, boolean)): Likewise, (getItemLabelPaint): Likewise, (setItemLabelPaint(Paint)): Likewise, (setItemLabelPaint(Paint, boolean)): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (setItemLabelsVisible(boolean)): Deprecated, (setItemLabelsVisible(Boolean)): Likewise, (setItemLabelsVisible(Boolean, boolean)): Likewise, (getItemLabelFont): Likewise, (setItemLabelFont(Font)): Likewise, (getItemLabelPaint): Likewise, (setItemLabelPaint(Paint)): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (setItemLabelsVisible(boolean)): Deprecated, (setItemLabelsVisible(Boolean)): Likewise, (setItemLabelsVisible(Boolean, boolean)): Likewise, (getItemLabelFont): Likewise, (setItemLabelFont(Font)): Likewise, (getItemLabelPaint): Likewise, (setItemLabelPaint(Paint)): Likewise. 2007-04-20 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (itemLabelGenerator): Deprecated, (toolTipGenerator): Likewise, (itemURLGenerator): Likewise, (setItemLabelGenerator): Likewise, (getToolTipGenerator): Likewise, (setToolTipGenerator): Likewise, (setItemURLGenerator): Deprecated and added event notification, (setSeriesItemURLGenerator): Added event notification, (setBaseItemURLGenerator): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (setItemLabelGenerator): Deprecated, (getToolTipGenerator): Likewise, (setToolTipGenerator): Likewise, (setItemURLGenerator): Likewise. 2007-04-20 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (itemLabelGenerator): Deprecated, (toolTipGenerator): Likewise, (getItemLabelGenerator): Likewise, (setItemLabelGenerator): Likewise, (getToolTipGenerator): Likewise, (setToolTipGenerator): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (setItemLabelGenerator): Deprecated, (setToolTipGenerator): Likewise. 2007-04-20 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (paint): Deprecated, (fillPaint): Likewise, (outlinePaint): Likewise, (stroke): Likewise, (outlineStroke): Likewise, (shape): Likewise, (getItemPaint): Call new lookupSeriesPaint() method, (lookupSeriesPaint): New method, (setPaint(Paint)): Deprecated, (setPaint(Paint, boolean)): Likewise, (getSeriesPaint(int)): Reimplemented to return series paint only, not a lookup, (getItemFillPaint): Call new lookupSeriesFillPaint() method, (lookupSeriesFillPaint): New method, (getSeriesFillPaint(int)): Reimplemented to return series fill paint only, not a lookup, (setFillPaint(Paint)): Deprecated, (setFillPaint(Paint, boolean)): Likewise, (getItemOutlinePaint): Call new lookupSeriesOutlinePaint() method, (lookupSeriesOutlinePaint): New method, (getSeriesOutlinePaint(int)): Reimplemented to return series outline paint only, not a lookup, (setOutlinePaint(Paint)): Deprecated, (setOutlinePaint(Paint, boolean)): Likewise, (getItemStroke): Call new lookupSeriesOutlineStroke() method, (lookupSeriesStroke): New method, (setStroke(Stroke)): Deprecated, (setStroke(Stroke, boolean)): Deprecated, (getSeriesStroke(int)): Reimplemented to return series stroke only, not a lookup, (getItemOutlineStroke): Call new lookupSeriesOutlineStroke() method, (lookupSeriesOutlineStroke): New method, (setOutlineStroke(Stroke)): Deprecated, (setOutlineStroke(Stroke, boolean)): Deprecated, (getSeriesOutlineStroke(int)): Reimplemented to return series outline stroke, not a lookup, (getItemShape): Call new lookupSeriesShape() method, (lookupSeriesShape): New method, (setShape(Shape)): Deprecated, (setShape(Shape, notify)): Deprecated, (getSeriesShape(int)): Reimplemented to return series shape, not a lookup, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (getLegendItem): Updated for renderer changes, * source/org/jfree/chart/renderer/category/AreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (setPaint): Deprecated, (setOutlinePaint): Deprecated, (setStroke): Deprecated, (setOutlineStroke): Deprecated, (setShape): Deprecated, * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java (getLegendItem): Updated for renderer changes, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (getLegendItem): Likewise, (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (getLegendItem): Likewise, (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (setPaint): Deprecated, (setOutlinePaint): Deprecated, (setStroke): Deprecated, (setOutlineStroke): Deprecated, (setShape): Deprecated, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (getLegendItem): Likewise. 2007-04-19 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (sectionPaint): Deprecated, (sectionOutlinePaint): Likewise, (sectionOutlineStroke): Likewise, (getSectionPaint): Likewise, (setSectionPaint(Paint)): Likewise, (getSectionOutlinePaint): Likewise, (setSectionOutlinePaint(Paint)): Likewise, (getSectionOutlineStroke): Likewise, (setSectionOutlineStroke(Stroke)): Likewise, (zoom): Removed. 2007-04-19 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (seriesVisibleInLegend): Deprecated, (getSeriesVisibleInLegend): Likewise, (setSeriesVisibleInLegend(Boolean)): Likewise, (setSeriesVisibleInLegend(Boolean, boolean)): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (getSeriesVisibleInLegend): Likewise, (setSeriesVisibleInLegend(Boolean)): Likewise, (setSeriesVisibleInLegend(Boolean, boolean)): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (getSeriesVisibleInLegend): Likewise, (setSeriesVisibleInLegend(Boolean)): Likewise, (setSeriesVisibleInLegend(Boolean, boolean)): Likewise. 2007-04-19 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (seriesVisible): Deprecated, (getSeriesVisible): Likewise, (setSeriesVisible(Boolean)): Likewise, (setSeriesVisible(Boolean, boolean)): Likewise, * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java (getSeriesVisible): Likewise, (setSeriesVisible(Boolean)): Likewise, (setSeriesVisible(Boolean, boolean)): Likewise, * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (getSeriesVisible): Likewise, (setSeriesVisible(Boolean)): Likewise, (setSeriesVisible(Boolean, boolean)): Likewise. 2007-04-19 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (setMinimumDate): Handle case where new minimum date is on or after the existing maximum date, (setMaximumDate): Handle case where new maximum date is on or before the existing minimum date, * tests/org/jfree/chart/axis/junit/DateAxisTests.java (testSetMaximumDate): Added new check, (testSetMinimumDate): Likewise. 2007-04-17 David Gilbert * source/org/jfree/chart/urls/StandardCategoryURLGenerator.java (generateURL): Use new URLUtilities class for encoding, * source/org/jfree/chart/urls/StandardPieURLGenerator.java (generateURL): Likewise, * source/org/jfree/chart/urls/TimeSeriesURLGenerator.java (generateURL): Likewise, * source/org/jfree/chart/urls/URLUtilities.java: New file, * tests/org/jfree/chart/urls/junit/StandardPieURLGeneratorTests.java (testURL): Added new check, * tests/org/jfree/chart/urls/junit/TimeSeriesURLGeneratorTests.java (testGenerateURL): New test method. 2007-04-17 David Gilbert * source/org/jfree/chart/urls/TimeSeriesURLGenerator.java (TimeSeriesURLGenerator(DateFormat, String, String, String)): Added null argument checks, (getDateFormat): New method, (getPrefix): New method, (getSeriesParameterName): New method, (getItemParameterName): New method, (equals): New method, * tests/org/jfree/chart/urls/junit/TimeSeriesURLGeneratorTests.java: New file, * tests/org/jfree/chart/urls/junit/UrlsPackageTests.java (suite): Added TimeSeriesURLGeneratorTests. 2007-04-17 David Gilbert * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java (add): Check for null values, * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java (testCloning): New test method, (test1701822): Likewise. 2007-04-17 David Gilbert * source/org/jfree/chart/ChartPanel.java (actionPerformed): Check for null zoomPoint, (restoreAutoDomainBounds): Likewise, (restoreAutoRangeBounds): Likewise, * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (findSubplot): Added null argument checks, (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): If not in subplot, zoom for all subplots, (zoomRangeAxes(double, double, PlotRenderingInfo, Point2D)): Likewise, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (findSubplot): Added null argument checks, (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): If not in subplot, zoom for all subplots, (zoomRangeAxes(double, double, PlotRenderingInfo, Point2D)): Likewise, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (findSubplot): Added null argument checks, (zoomDomainAxes(double, PlotRenderingInfo, Point2D)): If not in subplot, zoom for all subplots, (zoomDomainAxes(double, double, PlotRenderingInfo, Point2D)): Likewise, * source/org/jfree/chart/plot/PlotRenderingInfo.java (getSubplotIndex): Added null argument check. 2007-04-17 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (getLegendItems): Check for null legend item label, * tests/org/jfree/chart/plot/junit/PiePlotTests.java (NullLegendLabelGenerator): New support class, (testDrawWithNullLegendLabels): New test method. 2007-04-07 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java: Fixed redraw problem (no need to call forceRedraw() anymore). * swt/org/jfree/experimental/swt/SWTGraphics2D.java: Fixed some issues with disposing SWT ressources. Thanks to silent for pointing this out. 2007-04-04 Chris Boek * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): Use time zone for Month, (refreshTicksHorizontal): Use time zone, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/DateTickUnit.java (addToDate(Date, TimeZone)): New method, (rollDate(Date, TimeZone)): New method, * source/org/jfree/data/time/Hour.java (Hour(Date, TimeZone)): Peg to zone, * source/org/jfree/data/time/Millisecond.java (Millisecond(Date, TimeZone)): Peg to zone, * source/org/jfree/data/time/Month.java (Month(Date, TimeZone)): Peg to zone. 2007-04-03 David Gilbert * source/org/jfree/chart/plot/Plot.java (drawBackgroundImage): Changed from protected to public. 2007-04-03 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer3D.java (drawBackground): Use background alpha, and delegate background image drawing to the plot, * source/org/jfree/chart/renderer/category/LineRenderer3D.java (drawBackground): Likewise. 2007-03-30 David Gilbert * source/org/jfree/data/DefaultKeyedValues2D.java (removeValue): Remove column values by key not index, * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java (testRemoveValueBug1690654): New test method. ---------- JFREECHART 1.0.5 RELEASED ------------------------ 2007-03-23 David Gilbert * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (draw): Draw shared axis last, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (draw): Likewise. 2007-03-23 David Gilbert * source/org/jfree/chart/renderer/xy/XYErrorRenderer.java (drawItem): Check item visibility. 2007-03-23 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (drawDomainLine): New method, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (getItemShapeFilled): Do full lookup, (getShapesFilled): New method, (setShapesFilled): Fire change event, (getSeriesShapesFilled): Only look up per-series settings, (setSeriesShapesFilled): Fire change event, (getLegendItem): Call getItemShapeFilled for shape fill status. 2007-03-23 David Gilbert * ant/build.xml: Updated library version numbers, * source/org/jfree/chart/plot/XYPlot.java (domainZeroBaselineVisible): New field, (domainZeroBaselineStroke): Likewise, (domainZeroBaselinePaint): Likewise, (XYPlot): Initialise new field, (isDomainZeroBaselineVisible): New method, (setDomainZeroBaselineVisible): Likewise, (getDomainZeroBaselineStroke): Likewise, (setDomainZeroBaselineStroke): Likewise, (getDomainZeroBaselinePaint): Likewise, (setDomainZeroBaselinePaint): Likewise, (draw): Added drawing code for domain zero baseline, (render): Added check for null renderer, (drawZeroDomainBaseline): New method, (equals): Test new fields, (writeObject): Handle new fields, (readObject): Likewise. 2007-03-22 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (setShapePaint): Fire change event, (setShapeStroke): Likewise. 2007-03-22 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getItemLabelGenerator(int, int)): Do lookup, (getSeriesItemLabelGenerator(int)): Lookup only the series generator, (getItemLabelGenerator): New method, (getToolTipGenerator(int, int)): Do lookup, (getToolTipGenerator): New method, (getSeriesToolTipGenerator): Lookup only the series generator. 2007-03-22 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (fireChangeEvent): Fire new event every time. 2007-03-22 David Gilbert * source/org/jfree/chart/plot/PiePlot3D.java (setDepthFactor): Fire PlotChangeEvent, (equals): New method override, * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java (testEquals): New test. 2007-03-22 David Gilbert * source/org/jfree/chart/axis/LogarithmicAxis.java (autoAdjustRange): Use new defaultAutoRange attribute, * source/org/jfree/chart/axis/NumberAxis.java (autoAdjustRange): Likewise, * source/org/jfree/chart/axis/PeriodAxis.java (autoAdjustRange): Likewise, * source/org/jfree/chart/axis/ValueAxis.java (DEFAULT_LOWER_BOUND): Deprecated, (DEFAULT_UPPER_BOUND): Likewise, (defaultAutoRange): New field, (ValueAxis(String, TickUnitSource)): Initialise new field, (getDefaultAutoRange): New method, (setDefaultAutoRange): New method, (equals): Check new defaultAutoRange field. 2007-03-22 David Gilbert * source/org/jfree/chart/axis/AxisLocation.java (getOpposite): New method. 2007-03-22 David Gilbert * source/org/jfree/chart/JFreeChart.java (getAntiAlias): Simplified, (getTextAntiAlias): New method, (setTextAntiAlias(boolean)): New method, (setTextAntiAlias(Object)): New method. 2007-03-22 David Gilbert * source/org/jfree/data/time/TimeSeries.java (getDataItem(RegularTimePeriod)): Simplified. 2007-03-21 David Gilbert * source/org/jfree/chart/axis/ExtendedCategoryAxis.java (sublabelPaint): Marked as transient, (setSubLabelFont): Check for null argument, fire change event, (setSubLabelPaint): Likewise, (equals): New method override, (clone): Likewise, (writeObject): New method, (readObject): New method, * tests/org/jfree/chart/axis/junit/AxisPackageTests.java (suite): Added ExtendedCategoryAxisTests, * tests/org/jfree/chart/axis/junit/ExtendedCategoryAxisTests.java: New file. 2007-03-21 David Gilbert * source/org/jfree/chart/plot/PolarPlot.java (angleLabelPaint): Marked as transient, (writeObject): Handle angleLabelPaint field, (readObject): Likewise, * tests/org/jfree/chart/plot/junit/PolarPlotTests.java (testSerialization): Added checks for paint fields. 2007-03-21 David Gilbert * source/org/jfree/chart/plot/MeterPlot.java (tickPaint): Marked as transient, (tickLabelPaint): Likewise, (writeObject): Handle new transient fields, (readObject): Likewise, * tests/org/jfree/chart/plot/junit/MeterPlotTests.java (testSerialization): Added checks for paint fields. 2007-03-21 David Gilbert * source/org/jfree/chart/axis/DateTickUnit.java (units): New private field, (toString): New method override. 2007-03-20 David Gilbert * source/org/jfree/chart/plot/CompassPlot.java (roseHighlightPaint): Marked transient, (rosePaint): Likewise, (roseCenterPaint): Likewise, (setDrawBorder): Notify listeners, (writeObject): New method, (readObject): New method, * tests/org/jfree/chart/plot/junit/CompassPlotTests.java (testSerialization): Check paint fields with GradientPaint. 2007-03-20 David Gilbert * source/org/jfree/chart/renderer/category/GanttRenderer.java (completePaint): Marked transient, (incompletePaint): Likewise, (equals): Implemented, (writeObject): New method, (readObject): Likewise, * tests/org/jfree/chart/renderer/category/junit/GanttRendererTests.java (testEquals): Extended, (testSerialization): Updated to check gradient paint. 2007-03-20 David Gilbert * source/org/jfree/chart/JFreeChart.java (JFreeChart(String, Font, Plot, boolean)): Update for renamed method, * source/org/jfree/chart/block/AbstractBlock.java (border): Renamed frame, (AbstractBlock): Updated for renamed field, (getBorder): Likewise, (setBorder(BlockBorder)): Updated for renamed method, (setBorder(double, double, double, double)): Likewise, (getBlockFrame): Renamed getFrame(), (setBlockFrame): Renamed setFrame(), (getContentXOffset): Updated for renamed field, (getContentYOffset): Likewise, (trimToContentWidth): Likewise, (trimToContentHeight): Likewise, (calculateTotalWidth): Likewise, (calculateTotalHeight): Likewise, (trimBorder): Likewise, (drawBorder): Likewise, (equals): Likewise, (clone): Likewise, * source/org/jfree/chart/title/LegendTitle.java (draw): Updated for renamed method. 2007-03-19 David Gilbert * source/org/jfree/chart/ChartUtilities.java (saveChartAsPNG(File, JFreeChart, int, int, ChartRenderingInfo)): Wrap writeChartAsPNG in try-finally, (saveChartAsPNG(File, JFreeChart, int, int, ChartRenderingInfo, boolean, int)): Likewise, (saveChartAsJPEG(File, JFreeChart, int, int, ChartRenderingInfo)): Likewise, (saveChartAsJPEG(File, float, JFreeChart, int, int, ChartRenderingInfo)): Likewise. 2007-03-16 David Gilbert * source/org/jfree/chart/JFreeChart.java (JFreeChart(String, Plot, Font, boolean)): Changed initial legend border, * source/org/jfree/chart/block/AbstractBlock.java: implemented Cloneable, (border): Changed type to BlockFrame, (getBorder): Deprecated, (setBorder): Deprecated, (getBlockFrame): New method, (setBlockFrame): New method, (equals): Check id field, (clone): Implemented, * source/org/jfree/chart/block/BlockBorder.java: Implemented BlockFrame interface, * source/org/jfree/chart/block/BlockFrame.java: New file, * source/org/jfree/chart/block/ColorBlock.java (paint): Marked transient, (ColorBlock): Added null argument check, (getPaint): New method, (equals): New method, (writeObject): New method, (readObject): New method, * source/org/jfree/chart/block/LineBorder.java: New file, * source/org/jfree/chart/title/LegendTitle.java (draw): Updated for changes to AbstractBlock border, * tests/org/jfree/chart/block/junit/AbstractBlockTests.java: New file, * tests/org/jfree/chart/block/junit/BlockBorderTests.java: Reformatted, * tests/org/jfree/chart/block/junit/BlockPackageTests.java: Added new tests, * tests/org/jfree/chart/block/junit/ColorBlockTests.java: New file, * tests/org/jfree/chart/block/junit/EmptyBlockTests.java: Reformatted, * tests/org/jfree/chart/block/junit/LineBorderTests.java: New file. 2007-03-16 David Gilbert * source/org/jfree/chart/block/LabelBlock.java (paint): Mark as transient, (equals): Minor simplification, (readObject): New method, (writeObject): Likewise, * tests/org/jfree/chart/block/junit/LabelBlockTests.java (testSerialization): Test with GradientPaint. 2007-03-15 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java (renderAsPercentages): New field, (StackedXYBarRenderer()): Delegate to another constructor, (StackedXYBarRenderer(double)): Initialise item label settings, (getRenderAsPercentages): New method, (setRenderAsPercetanges): Likewise, (getPassCount): New method override, (findRangeBounds): Handle renderAsPercentages, (drawItem): Divide into two passes, handle renderAsPercentages and item label drawing, (equals): Check renderAsPercentages, (hashCode): New method override, * source/org/jfree/data/general/DatasetUtilities.java (calculateStackTotal): New method, * tests/org/jfree/chart/renderer/xy/junit/StackedXYBarRendererTests.java (testEquals): Check new field, (testHashCode): Likewise. 2007-03-15 David Gilbert * source/org/jfree/chart/renderer/xy/DeviationRenderer.java (drawItem): Removed calls to Java 1.6 methods. 2007-03-15 David Gilbert * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (clone): Reimplemented, * tests/org/jfree/chart/renderer/junit/DefaultPolarItemRendererTests.java (testCloning): Added independence check. 2007-03-14 David Gilbert * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (setPlotDiscontinuous): New method, (equals): Check additional fields, (clone): Reimplemented, * tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.java (testEquals): Check additional fields, (testCloning): Check independence. 2007-03-13 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (draw): Moved annotation drawing up to point where clipping still applies. 2007-03-13 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (DEFAULT_CROSSHAIR_VISIBLE): New field, (DEFAULT_CROSSHAIR_STROKE): Likewise, (DEFAULT_CROSSHAIR_PAINT): Likewise, (CategoryPlot(CategoryDataset, CategoryAxis, ValueAxis, CategoryItemRenderer)): Initialise crosshair fields, (setRangeCrosshairStroke): Check for null stroke, (setRangeCrosshairPaint): Check for null paint, (draw): Call new drawRangeCrosshair() method, (drawRangeCrosshair): New method, * source/org/jfree/chart/plot/XYPlot.java (setRangeCrosshairStroke): Added null argument check, (setRangeCrosshairPaint): Likewise. 2007-03-09 David Gilbert * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java (drawItem): Handle horizontal plot orientation. 2007-03-09 David Gilbert * source/org/jfree/chart/renderer/LookupPaintScale.java (clone): Clone the lookup table, * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java (clone): Clone the paint scale, * tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java (testCloning): Check independence, * tests/org/jfree/chart/renderer/xy/junit/XYBlockRendererTests.java (testCloning): Check independence. 2007-03-09 David Gilbert * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java (getSeriesIndex): Reimplemented, (getColumnIndex): Reimplemented, (getRowIndex): Delegate to getSeriesIndex(), (getColumnCount): Reimplemented, (getRowCount): Likewise, (getSeries): Deprecated, (getCategories): Deprecated, (getItemCount): Deprecated. 2007-03-08 David Gilbert * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (drawItemPass1): Fix entity generation. 2007-03-08 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java (hashCode): Fixed, * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java (hashCode): Fixed, * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java (hashCode): Fixed, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java (hashCode): Fixed, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java (hashCode): Fixed. 2007-03-08 David Gilbert * source/org/jfree/data/gantt/TaskSeriesCollection.java (remove): Fix argument check, * source/org/jfree/data/time/TimePeriodValuesCollection.java (getSeries): Likewise, * source/org/jfree/data/xy/DefaultTableXYDataset.java (getSeries): Likewise, * source/org/jfree/data/xy/XYSeriesCollection.java (removeSeries): Likewise, * tests/org/jfree/data/gantt/junit/TaskSeriesCollectionTests.java (testRemove): New test method, * tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java (testGetSeries): Likewise, * tests/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java (testGetSeries): Likewise, * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java (testGetSeries): Likewise, (testRemoveSeries): Likewise. 2007-03-08 David Gilbert * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java (getValue(Comparable, Comparable)): Check keys, (getStartValue(Comparable, Comparable)): Likewise, (getEndValue(Comparable, Comparable)): Likewise, (setStartValue): Correct index range check, (setEndValue): Likewise, (equals): New method override, (clone): Likewise, (equal): New private method, (clone(Number[][])): Likewise, * tests/org/jfree/data/category/junit/DefaultIntervalCategoryDatasetTests.java: New file, * tests/org/jfree/data/category/junit/DataCategoryPackageTests.java: (suite): Added DefaultIntervalCategoryDatasetTests. 2007-03-08 David Gilbert * source/org/jfree/data/category/DefaultCategoryDataset.java (clone): New method override, * tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java (testCloning): New method. 2007-03-07 David Gilbert * source/org/jfree/chart/renderer/LookupPaintScale.java (PaintItem): Implements Comparable, (PaintItem.compareTo): New method, (LookupPaintScale(double, double, Paint)): Initialise bounds, (add): Reimplemented to ensure ordered list, (getPaint): Check bounds and return default paint if value is outside, * tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java (EPSILON): New field, (testConstructor1): New method, (testConstructor2): Likewise, (testGeneral): Likewise. 2007-03-07 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (drawCategoryLabels): Fix offset. 2007-03-06 David Gilbert * source/org/jfree/chart/annotations/AbstractXYAnnotation.java (hashCode): Implemented, * source/org/jfree/chart/annotations/CategoryLineAnnotation.java (hashCode): Reimplemented, * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java (hashCode): Likewise, * source/org/jfree/chart/annotations/CategoryTextAnnotation.java (hashCode): Implemented, * source/org/jfree/chart/annotations/XYPointerAnnotation.java (hashCode): Likewise, * source/org/jfree/chart/annotations/XYShapeAnnotation.java (hashCode): Likewise. 2007-03-06 David Gilbert * source/org/jfree/chart/HashUtilities.java (hashCodeForDoubleArray): Accumulate result, * tests/org/jfree/chart/junit/ChartPackageTests.java (suite): Add HashUtilitiesTests, * tests/org/jfree/chart/junit/HashUtilitiesTests.java: New file. 2007-03-06 David Gilbert * source/org/jfree/chart/annotations/XYTextAnnotation.java (setText): Added null argument check, (setFont): Likewise, (setPaint): Likewise, (setTextAnchor): Likewise, (setRotationAnchor): Likewise, (hashCode): Reimplemented. 2007-03-05 Sergei Ivanov * source/org/jfree/chart/ChartPanel.java (paintComponent): Redraw the zoom rectangle and dispose the Graphics2D instance, (mouseDragged): Factor out zoom rectangle drawing, (mouseReleased): Likewise, (mouseMoved): Pass Graphics2D to drawAxisTrace methods, (drawZoomRectangle): New method, (drawHorizontalAxisTrace): Added Graphics2D parameter, (drawVerticalAxisTrace): Likewise, (displayPopupMenu): Fixed logical AND typo. 2007-03-05 Sergei Ivanov * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItem): Reworked bar calculation to fix bug when rendering against LogarithmicAxis. 2007-03-05 David Gilbert * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (useOutlinePaint): New field, (CandlestickRenderer(double, boolean, XYToolTipGenerator)): Initialise new field, (drawVolume): Deprecated, (getDrawVolume): New method, (getUseOutlinePaint): Likewise, (setUseOutlinePaint): Likewise, (drawItem): Use outline paint if flag is set, (equals): Test useOutlinePaint flag, * tests/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java (testEquals): Added check for useOutlinePaint flag. 2007-03-05 David Gilbert * source/org/jfree/chart/plot/MeterPlot.java (draw): Restore clip correctly, * source/org/jfree/chart/plot/SpiderWebPlot.java (draw): Likewise. 2007-03-05 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (drawRangeGridlines): Check for null renderer, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testDrawRangeGridlines): New test method. 2007-03-02 Sergei Ivanov * source/org/jfree/chart/axis/LogarithmicAxis.java (switchedPow10): New method, (adjustedLog10): Modified for clarity, (adjustedPow10): New method, (autoAdjustRange): Reformatting only, (valueToJava2D): Likewise, (java2dToValue): Use new methods, (zoomRange): New method override, * tests/org/jfree/chart/axis/junit/LogarithmicAxisTests.java (MyLogarithmicAxis): New inner class, (EPSILON): New constant, (axis): New field, (setUp): New method, (testAdjustedLog10): Likewise, (checkLogPowRoundTrip): Likewise, (testSwitchedLog10): Likewise, (checkSwitchedLogPowRoundTrip): Likewise, (testJava2DToValue): Likewise, (testValueToJava2D): Likewise, (checkPointsToJava2D): Likewise, (checkPointsToValue): Likewise, (main): Likewise. 2007-03-02 Sergei Ivanov * source/org/jfree/chart/plot/XYPlot.java (draw): Updated crosshair drawing to take account of orientation correctly (see bug 1671645). 2007-03-01 Sergei Ivanov * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (drawRangeMarker): Fixed drawing of interval markers, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (drawDomainMarker): Likewise, (drawRangeMarker): Likewise. 2007-02-28 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (event): New field, (setSeriesVisible(Boolean, boolean)): Call fireChangeEvent() to notify, (setSeriesVisible(int, Boolean, boolean)): Likewise, (setBaseSeriesVisible(boolean, boolean)): Likewise, (setSeriesVisibleInLegend(Boolean, boolean)): Likewise, (setSeriesVisibleInLegend(int, Boolean, boolean)): Likewise, (setBaseSeriesVisibleInLegend(boolean, boolean)): Likewise, (setPaint(Paint, boolean)): Likewise, (setSeriesPaint(int, Paint, boolean)): Likewise, (setBasePaint(Paint, boolean)): Likewise, (setFillPaint(Paint, boolean)): Likewise, (setSeriesFillPaint(int, Paint, boolean)): Likewise, (setBaseFillPaint(Paint, boolean)): Likewise, (setOutlinePaint(Paint, boolean)): Likewise, (setSeriesOutlinePaint(int, Paint, boolean)): Likewise, (setBaseOutlinePaint(Paint, boolean)): Likewise, (setStroke(Stroke, boolean)): Likewise, (setSeriesStroke(int, Stroke, boolean)): Likewise, (setBaseStroke(Stroke, boolean)): Likewise, (setOutlineStroke(Stroke, boolean)): Likewise, (setSeriesOutlineStroke(int, Stroke, boolean)): Likewise, (setBaseOutlineStroke(Stroke, boolean)): Likewise, (setShape(Shape, boolean)): Likewise, (setSeriesShape(int, Shape, boolean)): Likewise, (setBaseShape(Shape, boolean)): Likewise, (setItemLabelsVisible(Boolean, boolean)): Likewise, (setSeriesItemLabelsVisible(int, Boolean, boolean)): Likewise, (setBaseItemLabelsVisible(Boolean, boolean)): Likewise, (setItemLabelFont(Font, boolean)): Likewise, (setSeriesItemLabelFont(int, Font, boolean)): Likewise, (setBaseItemLabelFont(Font, boolean)): Likewise, (setItemLabelPaint(Paint, boolean)): Likewise, (setSeriesItemLabelPaint(int, Paint, boolean)): Likewise, (setBaseItemLabelPaint(Paint, boolean)): Likewise, (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, boolean)): Likewise, (setBasePositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, boolean)): Likewise, (setBaseNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, (setItemLabelAnchorOffset): Likewise, (setCreateEntities(Boolean, boolean)): Likewise, (setSeriesCreateEntities(int, Boolean, boolean)): Likewise, (setBaseSeriesCreateEntities(Boolean, boolean)): Likewise, (fireChangeEvent): New method, (clone): Initialise event listener list and set event to null. 2007-02-28 David Gilbert * source/org/jfree/chart/axis/SymbolAxis.java (refreshTicksVertical): Pull check for tickLabelsOverlapping outside first check. 2007-02-28 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (setRangeAxisLocation(int, AxisLocation, boolean)): Fixed copy-and-paste error. 2007-02-27 David Gilbert * source/org/jfree/chart/renderer/xy/DeviationRenderer.java: New file, * tests/org/jfree/chart/renderer/xy/junit/DeviationRendererTests.java: New file, * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java (suite): Add new tests. 2007-02-27 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (setDomainAxisLocation(AxisLocation)): Delegate, (setDomainAxisLocation(AxisLocation, boolean)): Likewise, (setDomainAxisLocation(int, AxisLocation)): Likewise, (setDomainAxisLocation(int, AxisLocation, boolean)): New method, (setRangeAxisLocation(AxisLocation)): Delegate, (setRangeAxisLocation(AxisLocation, boolean)): Likewise, (setRangeAxisLocation(int, AxisLocation)): Likewise, (setRangeAxisLocation(int, AxisLocation, boolean)): New method. 2007-02-26 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (setDomainAxisLocation(AxisLocation, boolean)): Delegate argument check, (setDomainAxisLocation(int, AxisLocation)): Delegate to new method, (setDomainAxisLocation(int, AxisLocation, boolean)): New method, (setRangeAxisLocation(int, AxisLocation, boolean)): Added argument check, (draw): Removed redundant code. 2007-02-26 David Gilbert * source/org/jfree/data/DefaultKeyedValues2D.java: Updated API docs, * source/org/jfree/data/category/DefaultCategoryDataset.java: Likewise, * tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java: (testGetValue2): New method, (testAddValue): Likewise, (testRemoveValue): Likewise, * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java (testRowCount): New method, (testColumnCount): Likewise, (testGetValue2): Likewise, (testGetRowKey): Likewise, (testGetColumnKey): Likewise, (testRemoveValue): Likewise, (testRemoveRow): Likewise. 2007-02-22 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (createState): New method, (initialise): Call createState(), * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java (State): New class, (line): Removed field, (getLegendItem): New method override, (createState): Likewise, (drawLine): Added State parameter, (drawItem): Updated calls to drawLine(), added entities, (equals): Minor rearrangement, * tests/org/jfree/chart/renderer/category/junit/CategoryStepRendererTests.java (testCloning): Minor updates, (testSerialization): Likewise. 2007-02-21 David Gilbert * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (clone): Reimplemented, (equals): Added checks for useFillPaint and drawSeriesLineAsPath, * tests/org/jfree/chart/renderer/xy/junit/XYLineAndShapeRendererTests.java (testEquals): Check additional fields, (testCloning): Check for independence. 2007-02-20 David Gilbert * source/org/jfree/data/xy/YIntervalSeries.java (getYHighValue): New method, (getYLowValue): Likewise, * source/org/jfree/data/xy/YIntervalSeriesCollection.java (getX): Call method in YIntervalSeries to get result, (getYValue): New method override, (getStartYValue): Likewise, (getEndYValue): Likewise, (getY): Call method in YIntervalSeries to get result, (getStartY): Likewise, (getEndY): Likewise. 2007-02-20 David Gilbert * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (clone): Fix cloning of a number of fields, (equals): Check additional fields, * tests/org/jfree/chart/renderer/xy/junit/YIntervalRendererTests.java (testEquals): Extended, (testCloning): Check independence of clone. 2007-02-20 David Gilbert * source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java (clone): Reimplemented, (equals): Likewise, * tests/org/jfree/chart/labels/junit/LabelsPackageTests.java (suite): Added MultipleXYSeriesLabelGeneratorTests, * tests/org/jfree/chart/labels/junit/MultipleXYSeriesLabelGeneratorTests.java: New file. 2007-02-19 David Gilbert * source/org/jfree/chart/renderer/AbstractRenderer.java (clone): handle some more fields correctly, * tests/org/jfree/chart/renderer/junit/AbstractRendererTests.java (testCloning): New method. 2007-02-14 David Gilbert * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (clone): Make a copy of legendArea; * tests/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java (testCloning): Check independence. 2007-02-14 David Gilbert * source/org/jfree/chart/plot/RingPlot.java (setSectionDepth): Added event notification. 2007-02-14 David Gilbert * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (equals): New method override, * tests/org/jfree/chart/renderer/xy/junit/XYStepAreaRendererTests.java (testEquals): Added more checks. 2007-02-13 David Gilbert * source/org/jfree/data/xy/XYIntervalSeriesCollection.java (clone): Implemented, * tests/org/jfree/data/xy/junit/XYIntervalSeriesCollectionTests.java (testCloning): Check independence, (testSerializable): Likewise, * tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java (testValues): New test. 2007-02-13 David Gilbert * source/org/jfree/data/xy/XYIntervalSeries.java (getXLowValue): New method, (getXHighValue): Likewise, (getYLowValue): Likewise, (getYHighValue): Likewise, * source/org/jfree/data/xy/XYIntervalSeriesCollection.java (getX): Simplified, (getStartXValue): New method override, (getEndXValue): Likewise, (getYValue): Likewise, (getStartYValue): Likewise, (getEndYValue): Likewise, (getY): Simplified, (getStartX): Likewise, (getEndX): Likewise, (getStartY): Likewise, (getEndY): Likewise. ---------- JFREECHART 1.0.4 RELEASED ------------------------ 2007-02-09 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Check drawBarOutline flag, (clone): Make a copy of the legendBar shape, * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java (testCloning): Added independence check. 2007-02-07 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (draw): Check renderer index against dataset count, (drawDomainMarkers): Likewise, (drawRangeMarkers): Likewise, * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java (test1654215): New test, * tests/org/jfree/chart/plot/junit/XYPlotTests.java: (test1654215): New test. 2007-02-07 David Gilbert * swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java (main): Set offscreen buffer flag to true. 2007-02-07 David Gilbert * source/org/jfree/chart/plot/PolarPlot.java (setAngleLabelPaint): Check for null argument, (equals): Check cornerTextItems list, (clone): Clone the cornerTextItems list, (translateValueThetaRadiusToJava2D): Don't let value go below axis minimum, * tests/org/jfree/chart/plot/junit/PolarPlotTests.java (testEquals): Added check for corner text items, (testCloning): Added independence checks. 2007-02-07 David Gilbert * swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java (SWTAxisEditor(Composite, Axis, int)): Check for null axis label. 2007-02-06 David Gilbert * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (draw): Draw shared axis after subplots, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (draw): Likewise. 2007-02-06 David Gilbert * source/org/jfree/chart/plot/CrosshairState.java (domainAxisIndex): New field, (rangeAxisIndex): New fields, (updateCrosshairPoint(double, double, double, double, PlotOrientation)): Deprecated, (updateCrosshairPoint(double, double, int, int, double, double, PlotOrientation)): New method, (updateCrosshairX(double)): Deprecated, (updateCrosshairX(double, int)): New method, (updateCrosshairY(double)): Deprecated, (updateCrosshairY(double, int)): New method, (getDomainAxisIndex): New method, (getRangeAxisIndex): New method, * source/org/jfree/chart/plot/XYPlot.java (draw): Updated to store axis indices in CrosshairState, then draw crosshairs using new methods, (drawDomainCrosshair): New method, (drawRangeCrosshair): New method, (getDomainAxisIndex): Changed from protected to public, (getRangeAxisIndex): Likewise, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (updateCrosshairValues(CrosshairState, double, double, double, double, PlotOrientation): Deprecated, (updateCrosshairValues(CrosshairState, double, double, int, int, double, double, PlotOrientation): New method, * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (drawItem): Call revised updateCrosshairValues() method, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDotRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Likewise. 2007-02-06 David Gilbert * source/org/jfree/chart/ChartUtilities.java: API doc updates, * source/org/jfree/chart/entity/ChartEntity.java: Likewise, * source/org/jfree/chart/imagemap/ImageMapUtilities.java: Likewise. 2007-02-06 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (getPlotValue): Changed to protected. 2007-02-05 David Gilbert * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (drawItemPass1): Added extra call to updateCrosshairValues(). 2007-02-05 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (addRangeMarker): Register plot as a listener with the marker, * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java (testAddDomainMarker): New test, (testAddRangeMarker): Likewise, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testAddDomainMarker): New test, (testAddRangeMarker): Likewise. 2007-02-05 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (draw): Draw axes before first polygon, (drawRadarPoly): Remove axis drawing code. 2007-02-05 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (axisLinePaint): New field, (axisLineStroke): New field, (SpiderWebPlot(CategoryDataset, TableOrder)): Initialise new fields, (getAxisLinePaint): New method, (setAxisLinePaint): Likewise, (getAxisLineStroke): Likewise, (setAxisLineStroke): Likewise, (drawRadarPoly): Fixed problems with paint and stroke on axis lines, (equals): Updated for new fields, (clone): New method override, (writeObject): Updated for new fields, (readObject): Likewise, * tests/org/jfree/chart/plot/junit/SpiderWebPlotTests.java (testEquals): Added checks for new fields, (testCloning): Added independence checks. 2007-02-05 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (setArtifactPaint): Check for null, generate event, (setItemMargin): Generate event, * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java (setArtifactPaint): Check for null, generate event, (drawHorizontalItem): Partially implemented (no outliers yet). 2007-02-02 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (drawItem): Fixed crosshair y-value. 2007-02-02 David Gilbert * experiments/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java (drawItem): Fixed calls to JDK 1.6-only methods; (equals): Check additional fields. 2007-02-02 David Gilbert * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: New file, * experimental/org/jfree/experimental/chart/demo/XYTitleAnnotationDemo1.java: New file, * experimental/org/jfree/experimental/chart/util/XYCoordinateType.java: New file. 2007-02-02 David Gilbert * ant/build.xml: Updated version numbers, * ant/build-swt.xml: Likewise. 2007-02-02 David Gilbert * NEWS: updated, * source/org/jfree/chart/resources/JFreeChartResources.java (CONTENTS): Updated version number and date. 2007-02-02 David Gilbert * source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java: (StandardXYItemLabelGenerator(String, NumberFormat, DateFormat)): Made public, * source/org/jfree/chart/labels/StandardXYToolTipGenerator.java: (StandardXYToolTIpGenerator(String, NumberFormat, DateFormat)): Likewise. 2007-02-02 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (setUseYInterval): Only notify if flag changes, * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java (getPaintScale): New method. 2007-01-31 David Gilbert * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: Removed and added to JFreeChart demo collection, * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: Likewise, * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: Likewise. 2007-01-31 David Gilbert * source/org/jfree/chart/ClipPath.java: Deprecated, * source/org/jfree/chart/axis/ColorBar.java: Likewise, * source/org/jfree/chart/editor/PaletteChooserPanel.java: Likewise, * source/org/jfree/chart/editor/PaletteSample.java: Likewise, * source/org/jfree/chart/plot/ColorPalette.java: Likewise, * source/org/jfree/chart/plot/ContourPlot.java: Likewise, * source/org/jfree/chart/plot/ContourPlotUtilities.java: Likewise, * source/org/jfree/chart/plot/ContourValuePlot.java: Likewise, * source/org/jfree/chart/plot/GreyPalette.java: Likewise, * source/org/jfree/chart/plot/RainbowPalette.java: Likewise, * source/org/jfree/data/contour/ContourDataset.java: Likewise, * source/org/jfree/data/contour/DefaultContourDataset.java: Likewise, * source/org/jfree/data/contour/NonGridContourDataset.java: Likewise, * source/org/jfree/data/contour/package.html: Updated. 2007-01-31 David Gilbert * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java: Moved from experimental, * experimental/org/jfree/experimental/chart/renderer/xy/XYBlockRenderer.java: Moved to main API, * experimental/org/jfree/experimental/chart/renderer/xy/junit/XYBlockRendererTests.java: Likewise, * tests/org/jfree/chart/renderer/junit/RendererPackageTests.java (suite): Added new tests, * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java (suite): Added XYBlockRendererTests, * tests/org/jfree/chart/renderer/xy/junit/XYBlockRendererTests.java: New file, * tests/org/jfree/chart/title/junit/TitlePackageTests.java (suite): Added new tests. 2007-01-31 David Gilbert * org/jfree/chart/renderer/GrayPaintScale.java: Moved from experimental, * org/jfree/chart/renderer/LookupPaintScale.java: Likewise, * org/jfree/chart/renderer/PaintScale.java: Likewise, * org/jfree/chart/title/PaintScaleLegend.java: Likewise, * experimental/org/jfree/experimental/chart/renderer/GrayPaintScale.java: Moved to main API, * experimental/org/jfree/experimental/chart/renderer/LookupPaintScale.java: Likewise, * experimental/org/jfree/experimental/chart/renderer/PaintScale.java: Likewise, * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java: Likewise, * experimental/org/jfree/experimental/chart/renderer/junit/GrayPaintScaleTests.java: Likewise, * experimental/org/jfree/experimental/chart/renderer/junit/LookupPaintScaleTests.java: Likewise, * experimental/org/jfree/experimental/chart/title/junit/PaintScaleLegendTests.java: Likewise, * tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java: Moved from experimental, * tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java: Moved from experimental, * tests/org/jfree/chart/title/junit/PaintScaleLegendTests.java: Moved from experimental. 2007-01-31 David Gilbert * experimental/org/jfree/experimental/chart/renderer/GrayPaintScale.java: (min): Renamed lowerBound; (max): Renamed upperBound; (GrayPaintScale): Updated for renamed fields, (getLowerBound): New method, (getUpperBound): New method, (getPaint): Updated for renamed fields, (equals): Likewise, * experimental/org/jfree/experimental/chart/renderer/LookupPaintScale.java: (PaintItem): Implemented Serializable, (PaintItem.paint): Marked transient, (PaintItem.equals): New method, (PaintItem.writeObject): Likewise, (PaintItem.readObject): Likewise, (lowerBound): New field, (upperBound): New field, (defaultPaint): Marked transient, (LookupPaintScale()): Delegate to other constructor, (LookupPaintScale(double, double, Paint): New constructor, (getDefaultPaint): New method, (getLowerBound): New method, (getUpperBound): New method, (equals): Check new fields, (writeObject): New method, (readObject): New method, * experimental/org/jfree/experimental/chart/renderer/PaintScale.java: (getLowerBound): New method, (getUpperBound): Likewise, * experimental/org/jfree/experimental/chart/renderer/junit/LookupPaintScaleTests.java (testEquals): Check more fields, (testCloning): Added new check, (testSerialization): Likewise. 2007-01-31 David Gilbert * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java (arrange): Implemented arrangement for no constraints. 2007-01-31 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java: Fixed some issues with the trace lines, fixed cross hair not being drawn, added getter and setter methods for the trace lines. * swt/org/jfree/experimental/chart/swt/demo/SWTTimeSeries.java: New class to test the cross hair. * swt/org/jfree/experimental/swt/SWTGraphics2D.java: Moved the dummy JPanel to SWTUtils.java, implemented the drawLine method. * swt/org/jfree/experimental/swt/SWTUtils.java: Moved the dummy JPanel from SWTGraphics2D.java, added a new convert method for mouse events. 2007-01-30 David Gilbert * experimental/org/jfree/experimental/chart/demo/VectorPlotDemo1.java: New file, * experimental/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java: New file, * experimental/org/jfree/experimental/chart/renderer/xy/junit/VectorRendererTests.java: New file. 2007-01-30 David Gilbert * experimental/org/jfree/experimental/data/xy/Vector.java: New file, * experimental/org/jfree/experimental/data/xy/VectorDataItem.java: New file, * experimental/org/jfree/experimental/data/xy/VectorSeries.java: New file, * experimental/org/jfree/experimental/data/xy/VectorSeriesCollection.java: New file, * experimental/org/jfree/experimental/data/xy/VectorXYDataset.java: New file, * experimental/org/jfree/experimental/data/xy/XYCoordinate.java: New file, * experimental/org/jfree/experimental/data/xy/junit/VectorDataItemTests.java: New file, * experimental/org/jfree/experimental/data/xy/junit/VectorSeriesCollectionTests.java: New file, * experimental/org/jfree/experimental/data/xy/junit/VectorSeriesTests.java: New file, * experimental/org/jfree/experimental/data/xy/junit/VectorTests.java: New file, * experimental/org/jfree/experimental/data/xy/junit/XYCoordinateTests.java: New file. 2007-01-30 David Gilbert * source/org/jfree/data/general/DefaultValueDataset.java (DefaultValueDataset(Number)): Call super() explicitly, (equals): Tidied up. 2007-01-30 David Gilbert * source/org/jfree/data/xy/XYBarDataset.java (getXValue): New method override, (getYValue): Likewise, (getStartXValue): Likewise, (getEndXValue): Likewise, (getStartYValue): Likewise, (getEndYValue): Likewise. 2007-01-30 David Gilbert * tests/org/jfree/data/xy/junit/XYSeriesTests.java (testToArray): Fixed code that won't compile with Java 1.4, (testToArrayExample): Likewise. 2007-01-29 Henry Proudhon * swt/org/jfree/experimental/swt/SWTGraphics2D.java (fillRect): switch between foregroung and background colors to correct bug in FastScatterPlotDemo. 2007-01-26 David Gilbert * tests/org/jfree/chart/JFreeChartTestSuite.java (suite): Added OHLCPackageTests. 2007-01-25 David Gilbert * source/org/jfree/data/xy/DefaultXYDataset.java: Implemented PublicCloneable, * source/org/jfree/data/xy/XYBarDataset.java (getUnderlyingDataset): New method, (getBarWidth): Likewise, (setBarWidth): Likewise, (equals): New method override, (clone): Likewise, * tests/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): Added new XYBarDatasetTests, * tests/org/jfree/data/xy/junit/XYBarDatasetTests.java: New class. 2007-01-25 David Gilbert * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java (AbstractXYItemLabelGenerator(String, NumberFormat, DateFormat)): New constructor, (clone): Clone date formatters, * source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java (StandardXYItemLabelGenerator(String, NumberFormat, DateFormat)): New constructor, * source/org/jfree/chart/labels/StandardXYToolTipGenerator.java (StandardXYToolTipGenerator(String, NumberFormat, DateFormat)): New constructor, * tests/org/jfree/chart/labels/junit/StandardXYItemLabelGeneratorTests.java: (testCloning): Added independence checks. 2007-01-24 David Gilbert * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (equals): New method override, * tests/org/jfree/chart/renderer/xy/junit/XYBubbleRendererTests.java (testEquals): Strengthened test. 2007-01-24 David Gilbert * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (roundXCoordinates): New field, (XYDifferenceRenderer()): Initialise roundXCoordinates, (getRoundXCoordinates): New method, (setRoundXCoordinates): Likewise, (drawItemPass0): Perform optional rounding of x-coordinates in Java2D space, (equals): Check roundXCoordinates field, (clone): Clone the legendLine shape, * tests/org/jfree/chart/renderer/xy/junit/XYDifferenceRendererTests.java (testEquals): Added check for roundXCoordinates field, (testCloning): Check for clone independence. 2007-01-23 David Gilbert * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: (createChart): Tweak settings on chart, * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: (createChart): Likewise, * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: (createChart): Likewise, * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java: (stripOutlineVisible): New field, (backgroundPaint): Don't initialise here, (PaintScaleLegend): Update initialisation, (isStripOutlineVisible): New method, (setStripOutlineVisible): Likewise, (getBackgroundPaint): Likewise, (setBackgroundPaint): Likewise, (SUBDIVISIONS): New private field, (draw): Use SUBDIVISIONS, (equals): Updated for new fields, * experimental/org/jfree/experimental/chart/title/junit/PaintScaleLegendTests.java: (testEquals): Test new fields. 2007-01-22 David Gilbert * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: (createChart): Added PaintScaleLegend, * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: (createChart): Likewise, * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: (createChart): Likewise, * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java: New class, * experimental/org/jfree/experimental/chart/title/junit/PaintScaleLegendTests.java: New test class. 2007-01-18 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (nextStandardDate): Use time zone for calendar. 2007-01-18 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (drawStackHorizontal): Handle inverted axis, (createHorizontalBlock): New method, (drawStackVertical): Handle inverted axis, (createVerticalBlock): New method. 2007-01-18 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (createStackedValueList): On null value, continue don't break, * tests/org/jfree/chart/renderer/category/junit/StackedBarRenderer3DTests.java: Added new test methods. 2007-01-18 David Gilbert * source/org/jfree/data/DefaultKeyedValues2D.java (getValue(Comparable, Comparable)): Handle case where row doesn't explicitly define a value for a valid column key, * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java (testSparsePopulation): New test method. 2007-01-17 David Gilbert * source/org/jfree/chart/ChartFactory.java (createBoxAndWhiskerChart(String, String, String, BoxAndWhiskerCategoryDataset, boolean): New method, * source/org/jfree/chart/JFreeChart.java (JFreeChartInfo()): Added new contributor. 2007-01-17 David Gilbert * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java: Removed @author tag and reformatted source code, * source/org/jfree/data/category/IntervalCategoryDataset.java: Likewise, * source/org/jfree/data/contour/ContourDataset.java: Likewise, * source/org/jfree/data/contour/DefaultContourDataset.java: Likewise. 2007-01-17 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer3D.java (drawDomainGridline): Use correct value for x2, * source/org/jfree/chart/renderer/category/LineRenderer3D.java (setWallPaint): Check for null argument, (drawDomainGridline): Use correct value for x2. 2007-01-17 David Gilbert * source/org/jfree/chart/plot/ColorPalette.java: Removed @author tag and reformatted source code, * source/org/jfree/chart/plot/CompassPlot.java: Likewise, * source/org/jfree/chart/plot/ContourPlot.java: Likewise, * source/org/jfree/chart/plot/ContourPlotUtilities.java: Likewise, * source/org/jfree/chart/plot/ContourValuePlot.java: Likewise, * source/org/jfree/chart/plot/GreyPalette.java: Likewise, * source/org/jfree/chart/plot/JThermometer.java: Likewise, * source/org/jfree/chart/plot/PolarPlot.java: Likewise, * source/org/jfree/chart/plot/RainbowPalette.java: Likewise, * source/org/jfree/chart/plot/ThermometerPlot.java: Likewise. 2007-01-17 David Gilbert * source/org/jfree/chart/plot/MultiplePiePlot.java (prefetchSectionPaints): Check for paint settings in underlying PiePlot. 2007-01-17 David Gilbert * source/org/jfree/chart/PaintMap.java (PaintMap()): Use HashMap instead of TreeMap, (readObject): Likewise, * tests/org/jfree/chart/junit/PaintMapTests.java (testKeysOfDifferentClasses): New test method. 2007-01-16 David Gilbert * swt/org/jfree/experimental/swt/SWTUtils.java (toAwtFont): Call getHeight() rather than accessing height field directly. 2007-01-16 David Gilbert * source/org/jfree/chart/plot/CompassPlot.java: Updated API docs. 2007-01-16 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (createStackedValueList): New method, (drawItem): Reimplemented, (drawStackHorizontal): New method, (drawStackVertical): New method. 2007-01-16 David Gilbert * source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java: Removed @author tag from API docs, * source/org/jfree/chart/imagemap/ImageMapUtilities: Likewise, * source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java: Likewise, * source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java: Likewise, * source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java: Likewise, * source/org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.java: Likewise. 2007-01-16 David Gilbert * source/org/jfree/chart/annotations/TextAnnotation.java (setText): Added argument check, (setFont): Likewise, (setPaint): Likewise, (setTextAnchor): Likewise, (hashCode): Reimplemented. 2007-01-15 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (getTimeZone): New method, (setTimeZone): Likewise. 2007-01-15 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (setWeight): Notify listeners, (setRangeZeroBaselinePaint): Check for null argument, (drawRangeMarkers): Use axis for dataset/renderer. 2007-01-15 David Gilbert * source/org/jfree/data/xy/XYSeries.java (toArray): New method, * tests/org/jfree/data/xy/junit/XYSeriesTests.java (testToArray): New test, (testToArrayExample): Likewise. 2007-01-11 David Gilbert * source/org/jfree/chart/plot/Plot.java (setNoDataMessage): Notify listeners, (setNoDataMessageFont): Check for null, and notify listeners, (setNoDataMessagePaint): Likewise, plus lots of small API doc updates. 2007-01-10 David Gilbert * ant/build.xml (compile-tests): New target, (test): Likewise, * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java (equals): Include attributedLabels in the test, * tests/org/jfree/chart/axis/junit/NumberAxisTests.java (testSetRangeType): Comment out temporarily. 2007-01-10 David Gilbert * source/org/jfree/data/time/Week.java (next): Don't go past maximum week in year. 2007-01-10 David Gilbert * tests/org/jfree/chart/annotations/junit/XYImageAnnotationTests.java (testSerialization): Commented out failing test, * tests/org/jfree/chart/axis/junit/NumberAxisTests.java (testCloning): Print stack trace, (testSerialization): Likewise, (testSetRangeType): New test, (testSetLowerBound): New test, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testGetDatasetCount): Commented out failing test. 2006-12-27 Thomas Morgner * source/org/jfree/chart/servlet/ChartDeleter.java: Implemented Serializable. 2006-12-19 David Gilbert * source/org/jfree/chart/ChartUtilities.java: API doc updates and source reformatting. 2006-12-13 David Gilbert * source/org/jfree/chart/LegendItem.java (fillPaintTransformer): New field, (LegendItem): Initialise fillPaintTransformer field, (getFillPaintTransformer): New method, (setFillPaintTransformer): Likewise, (equals): Check fillPaintTransformer attribute, * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Use gradientPaintTransformer if available, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/title/LegendGraphic.java (fillPaintTransformer): New field, (LegendGraphic): Initialise fillPaintTransformer, (getFillPaintTransformer): New method, (setFillPaintTransformer): Likewise, (draw): Added support for GradientPaint, (equals): Check fillPaintTransformer field, (hashCode): Implemented, (clone): Clone mutable fields, * source/org/jfree/chart/title/LegendTitle.java (createLegendItemBlock): Set gradientPaintTransformer, * tests/org/jfree/chart/junit/LegendItemTests.java (testEquals): Extended for new field, * tests/org/jfree/chart/title/junit/LegendGraphicTests.java (testEquals): Extended for new field, (testCloning): Added check for independence, (testCloning2): New method. 2006-12-11 David Gilbert * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java (drawItem): Add support for GradientPaint. 2006-12-11 David Gilbert * source/org/jfree/chart/axis/NumberAxis.java (estimateMaximumTickLabelWidth): Use format override if set. 2006-12-11 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (MouseUp event) fix popup menu location, patch sent by Fabrizio Giustina. 2006-12-11 David Gilbert * source/org/jfree/data/time/Minute.java (previous): Fix bug for first minute in hour, * tests/org/jfree/data/time/junit/MinuteTests.java (test1611872): New method. 2006-12-07 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (equals): Check additional fields, * tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRendererTests.java (testEquals): New test. 2006-12-07 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer3D.java (equals): New method override, * tests/org/jfree/chart/renderer/category/junit/BarRenderer3DTests.java (testEquals): Check all fields. 2006-12-06 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (displayToolTips): New field, (ChartComposite): modified event listener accordingly, (setDisplayToolTips): New method, (getToolTipText): New method (more or less copied from ChartPanel). 2006-12-06 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java (drawItem): Handle GradientPaint, * tests/org/jfree/chart/renderer/xy/junit/StackedXYBarRendererTests.java (testSerialization): Check handling of GradientPaint. 2006-12-04 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (initialise): Calculate clip bounds from correct axis. 2006-12-04 David Gilbert * source/org/jfree/data/time/ohlc/OHLC.java: New file, * source/org/jfree/data/time/ohlc/OHLCItem.java: New file, * source/org/jfree/data/time/ohlc/OHLCSeries.java: New file, * source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java: New file, * source/org/jfree/data/time/ohlc/package.html: New file, * tests/org/jfree/data/time/ohlc/junit/OHLCItemTests.java: New file, * tests/org/jfree/data/time/ohlc/junit/OHLCPackageTests.java: New file, * tests/org/jfree/data/time/ohlc/junit/OHLCSeriesCollectionTests.java: New tests, * tests/org/jfree/data/time/ohlc/junit/OHLCSeriesTests.java: New file, * tests/org/jfree/data/time/ohlc/junit/OHLCTests.java: New file. 2006-12-01 David Gilbert * source/org/jfree/chart/renderer/category/LineRenderer3D.java (equals): New method override, (writeObject): New method, (readObject): New method, * tests/org/jfree/chart/renderer/category/junit/LineRenderer3DTests.java (suite): Use correct class name, (testEquals): Extended. 2006-12-01 David Gilbert * source/org/jfree/chart/annotation/XYImageAnnotation.java (anchor): New field, (XYImageAnnotation(double, double, Image)): Delegated, (XYImageAnnotation(double, double, Image, RectangleAnchor)): New constructor, (getX): New method, (getY): New method, (getImage): New method, (getImageAnchor): New method, (draw): Adjust image position, (equals): Check anchor field, * tests/org/jfree/chart/annotation/junit/XYImageAnnotationTests.java (testEquals): Extended, (testHashCode): Simplified, (testCloning): Reformatted, (testSerialization): Likewise. 2006-12-01 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java: (getLegendItem): Check that series is visible, * source/org/jfree/chart/renderer/category/AreaRenderer.java (getLegendItem): Check that series is visible, (drawItem): Return early if the item is not visible, * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java (drawItem): Return early if the item is not visible. 2006-12-01 David Gilbert * source/org/jfree/chart/plot/PlotRenderingInfo.java (clone): Implemented properly, * tests/org/jfree/chart/plot/junit/PlotRenderingInfoTests.java (testEquals): Extended, (testCloning): Likewise. 2006-12-01 David Gilbert * source/org/jfree/chart/ChartRenderingInfo.java (equals): Test entities, (clone): Implemented properly, * tests/org/jfree/chart/junit/ChartRenderingInfoTests.java (testEquals): Extended, (testClone): Check for independence. 2006-12-01 David Gilbert * source/org/jfree/chart/entity/StandardEntityCollection.java (clone): Implemented properly, * tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java (testEquals): Extended, (testCloning): Likewise. 2006-11-30 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (ChartComposite): Modified mouse and paint listener to improve zoom handling, (getPointInRectangle, zoom, scale, getScreenDataArea): Signature methods have been modified (Rectangle2D -> Rectangle). 2006-11-30 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java (getRoundXCoordinates): New method, (setRoundXCoordinates): New method, (equals): New method override, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (plotLines): Removed field, (setOutline): Notify listeners, (getPlotLines): Deprecated redundant method, (equals): New method override, (clone): Clone the legend shape, * tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRenderer2Tests.java (testEquals): Extended, * tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java (testEquals): Extended, (testCloning): Likewise. 2006-11-29 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (draw): Set clip earlier to stop markers exceeding plot bounds. 2006-11-29 David Gilbert * source/org/jfree/chart/ChartFactory.java (createXYBarChart): Use time based tool tips if DateAxis is requested. 2006-11-28 Henry Proudhon * swt/org/jfree/experimental/chart/swt/ChartComposite.java (horizontalAxisTrace): New field, (verticalAxisTrace): New field, (verticalTraceLineX): New field, (horizontalTraceLineY): New field, (ChartComposite): Implemented trace line painting. 2006-11-28 David Gilbert * source/org/jfree/data/xy/DefaultIntervalXYDataset.java (hashCode): New method override, (clone): Likewise, * source/org/jfree/data/xy/DefaultXYDataset.java (hashCode): Likewise, * source/org/jfree/data/xy/DefaultXYZDataset.java (hashCode): Likewise, * tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java (testCloning2): New method, * tests/org/jfree/data/xy/junit/DefaultOHLCDatasetTests.java (testEquals): Added more checks. 2006-11-28 David Gilbert * source/org/jfree/data/xy/DefaultHighLowDataset.java (DefaultHighLowDataset): Added argument checks, (equals): New method override, * tests/org/jfree/data/xy/junit/DefaultHighLowDatasetTests.java: New file, * tests/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): Added DefaultHighLowDatasetTests. 2006-11-27 David Gilbert * source/org/jfree/data/xy/MatrixSeriesCollection.java (clone): New method override, * source/org/jfree/data/xy/XIntervalSeriesCollection.java (clone): New method override, * source/org/jfree/data/xy/XYSeriesCollection.java (clone): New method override, * source/org/jfree/data/xy/YIntervalSeriesCollection.java (clone): New method override, * tests/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): Added new MatrixSeriesCollectionTests, * tests/org/jfree/data/xy/junit/MatrixSeriesCollectionTests.java: New file, * tests/org/jfree/data/xy/junit/XIntervalSeriesCollectionTests.java (testCloning): Check independence, * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java (testCloning): Check independence, * tests/org/jfree/data/xy/junit/YIntervalSeriesCollectionTests.java (testCloning): Check independence. 2006-11-27 David Gilbert * source/org/jfree/data/xy/MatrixSeries.java (equals): Test values, * tests/org/jfree/data/xy/junit/MatrixSeriesTests.java: (testEquals): Added more checks. 2006-11-24 David Gilbert * source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java (equals): Fixed, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (setLegendItemLabelGenerator): Notify listeners, (setLegendItemToolTipGenerator): Likewise, (setLegendITemURLGenerator): Likewise, (clone): Clone generators, * tests/org/jfree/chart/labels/junit/LabelsPackageTests.java (suite): Added new test, * tests/org/jfree/chart/labels/junit /StandardXYSeriesLabelGeneratorTests.java: New file, * tests/org/jfree/chart/renderer/xy/junit /AbstractXYItemRendererTests.java (testCloning_LegendItemLabelGenerator): New test method, (testCloning_LegendItemToolTipGenerator): New test method, (testCloning_LegendItemURLGenerator): New test method. 2006-11-24 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (clone): Clone the legend label generators, (setLegendItemLabelGenerator): Notify listeners, (setLegendItemToolTipGenerator): Notify listeners, (setLegendItemURLGenerator): Notify listeners, * tests/org/jfree/chart/renderer/category/junit/AbstractCategoryITemRendererTests.java (testCloning_LegendItemLabelGenerator): New test method, (testCloning_LegendItemToolTipGenerator): New test method, (testCloning_LegendItemURLGenerator): New test method. 2006-11-24 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (clone): Fix URL generator cloning, * source/org/jfree/chart/urls/PieURLGenerator.java: Updated API docs, * source/org/jfree/chart/urls/StandardPieURLGenerator.java (StandardPieURLGenerator()): Delegated, (StandardPieURLGenerator(String)): Likewise, (StandardPieURLGenerator(String, String)): Likewise, (StandardPieURLGenerator(String, String, String)): Added argument checks, (equals): Reimplemented, * tests/org/jfree/chart/plot/junit/PiePlotTests.java (testCloning_URLGenerator): New test method, (testCloning_LegendLabelURLGenerator): Fixed test, * tests/org/jfree/chart/urls/junit/StandardPieURLGeneratorTests.java (testEquals): New test method. 2006-11-23 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (legendLabelURLGenerator): New field, (PiePlot(PieDataset)): Initialise new field, (getLegendLabelURLGenerator): New method, (setLegendLabelURLGenerator): New method, (getLegendItems): Populate URL if generator is available, (equals): Added tests for new/missing fields, (clone): Added cloning for new/missing fields, * tests/org/jfree/chart/plot/junit/PiePlotTests.java (testEquals): Extended for additional fields, (testCloning_LegendItemShape): New test method, (testCloning_LegendLabelGenerator): New test method, (testCloning_LegendLabelToolTipGenerator): New test method, (testCloning_LegendLabelURLGenerator): New test method. 2006-11-23 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (setDomainGridlineStroke): Check for null argument, (setDomainGridlinePaint): Likewise, (setRangeGridlinePaint): Likewise. 2006-11-23 David Gilbert * source/org/jfree/chart/util/RelativeDateFormat.java (RelativeDateFormat(long)): Initialise fields needed by equals(), (setDaySuffix): Check for null argument, (setHourSuffix): Likewise, (setMinuteSuffix): Likewise, (setSecondSuffix): Likewise, (equals): Check additional fields, (hashCode): Overridden, * tests/org/jfree/chart/util/junit/RelativeDateFormatTests.java: New file, * tests/org/jfree/chart/util/junit/UtilPackageTests.java: New file. 2006-11-22 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (equals): Check quadrant fields, (clone): Clone quadrant field, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testEquals): Added checks for quadrant fields, (testCloning_QuadrantOrigin): New test method, (testCloning_QuadrantPaint): New test method. 2006-11-22 David Gilbert * source/org/jfree/chart/plot/XYPlot.java: Added API doc cross references. 2006-11-22 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (setColumnRenderingOrder): Added argument check, event notification, and updated API docs, (setRowRenderingOrder): Likewise. 2006-11-20 David Gilbert * ant/build.xml (initialise): Updated JFreeChart version, restructured iText definitions, (fill-distribution): Updated iText reference, simplified copy for build.xml and added copy for build-swt.xml file. ---------- JFREECHART 1.0.3 RELEASED ------------------------ 2006-11-17 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/AbstractDialLayer.java (visible): New field, (AbstractDialLayer): Initialise new field, (isVisible): New method, (setVisible): New method, * experimental/org/jfree/experimental/chart/plot/dial/DialLayer.java (isVisible): New method, * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java (draw): Check layer visibility before drawing, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java (getOuterWindow): Adjust margins, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java (tickLabelsVisible): New field, (firstTickLabelVisible): New field, (StandardDialScale): Initialise new fields, (getTickLabelsVisible): New method, (setTickLabelsVisible): New method, (getFirstTickLabelVisible): New method, (setFirstTickLabelVisible): New method, (draw): Check tick label visibility, * experimental/org/jfree/experimental/chart/demo/DialDemo1.java (DialDemo1): Updated JSlider, * experimental/org/jfree/experimental/chart/demo/DialDemo2.java (DialDemo2): Updated chart title, * experimental/org/jfree/experimental/chart/demo/DialDemo3.java: Reimplemented, * experimental/org/jfree/experimental/chart/demo/DialDemo4.java: Reimplemented, * experimental/org/jfree/experimental/chart/demo/DialDemo5.java: New file. 2006-11-17 David Gilbert * source/org/jfree/chart/util/RelativeDateFormat.java: New file, * source/org/jfree/chart/util/package.html: New file. 2006-11-16 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java (roundXCoordinates): New field, (drawItem): Add optional rounding of x-coordinates. 2006-11-16 David Gilbert * source/org/jfree/data/statistics/BoxAndWhiskerCalculator.java (calculateBoxAndWhiskerStatistics(List)): Delegate to new method, (calculateBoxAndWhiskerStatistics(List, boolean)): New method, (calculateQ1): Check null argument, (calculateQ3): Likewise, * source/org/jfree/data/statistics/BoxAndWhiskerItem.java (toString): New method override, * source/org/jfree/data/statistics/Statistics.java (calculateMean(Number[])): Delegate to new method, (calculateMean(Number[], boolean)): New method, (calculateMean(Collection): Delegate to new method, (calculateMean(Collection, boolean): New method, (getStdDev): Added null argument checks, (getLinearFit): Likewise, (getSlope): Likewise, * tests/org/jfree/data/statistics/junit/BoxAndWhiskerCalculatorTests.java (testCalculateBoxAndWhiskerStatistics): New test method, (testCalculateQ1): Add check for null argument, (testCalculateQ3): Likewise, (test1593149): New test method, * tests/org/jfree/data/statistics/junit/StatisticsTests.java (testCalculateMean_Array): New test method, (testCalculateMean_Collection): New test method, (EPSILON): New constant, (testCalculateMedian): New test method, (testGetStdDev): New test method. 2006-11-14 Henry Proudhon * swt/README: New file, * ant/build-swt.xml: New file. 2006-11-14 David Gilbert * source/org/jfree/chart/plot/ThermometerPlot.java (draw): Use margin. 2006-11-14 David Gilbert * source/org/jfree/chart/axis/SegmentedTimeline.java (toTimelineValue): Iterate through exception segments to avoid potential stack overflow. 2006-11-10 David Gilbert * source/org/jfree/chart/plot/FastScatterPlot.java (FastScatterPlot()): Use default axes, (FastScatterPlot(double[][], ValueAxis, ValueAxis)): Throw IllegalArgumentException if domainAxis or rangeAxis is null, (setDomainAxis): New method, (setRangeAxis): New method, (setDomainGridlineStroke): Don't allow null argument, (setDomainGridlinePaint): Likewise, (setRangeGridlineStroke): Likewise, (setRangeGridlinePaint): Likewise, (draw): Removed unnecessary null checks, (drawDomainGridlines): Likewise, (drawRangeGridlines): Likewise, * source/org/jfree/chart/plot/FastScatterPlot.java (testDrawWithNullInfo): New test method. 2006-11-10 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (StackedXYAreaRendererState): Initialise line attribute, * tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.java (testBug1593156): New test method. 2006-11-07 David Gilbert * experimental/org/jfree/experimental/chart/demo/DialDemo1.java (DialDemo1): Updated for API change, * experimental/org/jfree/experimental/chart/demo/DialDemo2.java: New file replaces old one (which is renamed DialDemo3.java), * experimental/org/jfree/experimental/chart/demo/DialDemo3.java: Replaced with former DialDemo2.java, * experimental/org/jfree/experimental/chart/demo/DialDemo4.java: Renamed DialDemo3 --> DialDemo4, * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java (datasetToScaleMap): New field, (DialPlot): Initialise new field, (addScale): Added index parameter, (getScale): New method, (mapDatasetToScale): New method, (getScaleForDataset): Reimplemented, * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java (DialPointer(int)): New constructor, (getDatasetIndex): New method, (setDatasetIndex): New method, (Pin(int)): New constructor, (Pointer(int)): New constructor, * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java (datasetIndex): New field, (paint): Made transient to fix serialization, (backgroundPaint): Likewise, (outlineStroke): Likewise, (outlinePaint): Likewise, (DialValueIndicator): Modified constructor arguments, (getDatasetIndex): New method, (setDatasetIndex): Likewise, (getAngle): Likewise, (setAngle): Likewise, (getFrameAnchor): Likewise, (setFrameAnchor): Likewise, (getTemplateValue): Likewise, (setTemplateValue): Likewise, (getNumberFormat): Likewise, (setNumberFormat): Likewise, (getFont): Likewise, (setFont): Likewise, (getPaint): Likewise, (setPaint): Likewise, (getBackgroundPaint): Likewise, (setBackgroundPaint): Likewise, (getOutlineStroke): Likewise, (setOutlineStroke): Likewise, (getOutlinePaint): Likewise, (setOutlinePaint): Likewise, (getInsets): Likewise, (setInsets): Likewise, (getValueAnchor): Likewise, (setValueAnchor): Likewise, (getTextAnchor): Likewise, (setTextAnchor): Likewise, (draw): Fetch value from the appropriate dataset, (equals): Implemented properly, (hashCode): New method, (writeObject): New method, (readObject): New method, * experimental/org/jfree/experimental/chart/plot/dial/junit/DialValueIndicatorTests.java (testEquals): Check all fields, (testHashcode): Updated for new constructor API, (testCloning): Likewise, (testSerialization): Likewise. 2006-11-06 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/AbstractDialLayer.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialBackground.java: Now extends AbstractDialLayer, (setPaint): Notify listeners, (setGradientPaintTransformer): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/DialCap.java: Now extends AbstractDialLayer, (setRadius): Notify listeners, (setFillPaint): Likewise, (setOutlinePaint): Likewise, (setOutlineStroke): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/DialLayer.java: (addChangeListener): New method, (removeChangeListener): New method, (hasListener): New method, * experimental/org/jfree/experimental/chart/plot/dial/DialLayerChangeEvent.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialLayerChangeListener.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java: Implemented DialLayerChangeListener, * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java: Now extends AbstractDialLayer, (setRadius): Notify listeners, (setPaint): Likewise, (setStroke): Likewise, (setWidthRadius): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java: Now extends AbstractDialLayer, (setAngle): Notify listeners, (setRadius): Likewise, (setFont): Likewise, (setPaint): Likewise, (setLabel): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java: Now extends AbstractDialLayer, (setRadius): Notify listeners, * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java: (setRadius): Notify listeners, (setBackgroundPaint): Likewise, (setForegroundPaint): Likewise, (setStroke): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java: (setBackgroundPaint): Notify listeners, (setForegroundPaint): Likewise, (setStroke): Likewise, (setInnerRadius): Likewise, (setOuterRadius): Likewise, (setStartAngle): Likewise, (setExtent): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java: (setLowerBound): Notify listeners, (setUpperBound): Likewise, (setIncrement): Likewise, (setPaint): Likewise, (setInnerRadius): Likewise, (setOuterRadius): Likewise, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java: (setStartAngle): Notify listeners, (setExtent): Likewise, (setTickRadius): Likewise, (setMajorTickIncrement): Likewise, (setMajorTickLength): Likewise, (setMajorTickPaint): Likewise, (setMajorTickStroke): Likewise, (setMinorTickCount): Likewise, (setMinorTickLength): Likewise, (setTickLabelOffset): Likewise, (setTickLabelFont): Likewise, (setTickLabelPaint): Likewise. 2006-11-06 David Gilbert * ant/build.xml: Updated for reorganised source directories. 2006-11-03 David Gilbert * experimental/org/jfree/experimental/chart/plot/dial/DialBackground.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialCap.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialFrame.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialLayer.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialScale.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java: New file, * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/DialBackgroundTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/DialCapTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/DialPackageTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/DialPlotTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/DialTextAnnotationTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/DialValueIndicatorTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/SimpleDialFrameTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/StandardDialFrameTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/StandardDialRangeTests.java: New file, * tests/org/jfree/experimental/chart/plot/dial/junit/StandardDialScaleTests.java: New file. 2006-11-03 David Gilbert * source/org/jfree/chart/HashcodeUtilities.java: New file, * source/org/jfree/chart/annotation/XYPolygonAnnotation.java (hashCode): Use new utility class, (hashCodeForPaint): Removed, (hashCodeForDoubleArray): Likewise. 2006-11-02 David Gilbert * source/org/jfree/data/xy/DefaultIntervalXYDataset.java (addSeries): Remove old series if there is one with the same key as the new series, * source/org/jfree/data/xy/DefaultXYDataset.java (addSeries): Likewise, * source/org/jfree/data/xy/DefaultXYZDataset.java (addSeries): Likewise, * tests/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): Added DefaultIntervalXYDatasetTests, * tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java (testAddSeries): New test, * tests/org/jfree/data/xy/junit/DefaultXYDatasetTests.java (testAddSeries): Likewise, * tests/org/jfree/data/xy/junit/DefaultXYZDatasetTests.java (testAddSeries): Likewise. 2006-10-30 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (refreshTicks): Fetch categories for all datasets that map to this axis; * source/org/jfree/chart/plot/CategoryPlot.java (getDomainAxisIndex): New method, (datasetsMappedToDomainIndex): New method, (getCategoriesForAxis): New method, * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (getCategoriesForAxis): New method. 2006-10-25 David Gilbert * source/org/jfree/chart/renderer/xy/XYErrorRenderer.java: New file, * tests/org/jfree/chart/renderer/xy/junit/XYErrorRendererTests.java: New file, * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java (suite): Added XYErrorRendererTests. 2006-10-24 David Gilbert * source/org/jfree/chart/plot/CategoryMarker.java (CategoryMarker(Comparable, Paint, Stroke)): Set default alpha to 1.0f, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (drawDomainMarker): Draw marker outlines, (drawRangeMarker): Likewise. 2006-10-24 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java: (drawDomainMarker): Use marker alpha setting, (drawRangeMarker): Likewise, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java: (drawDomainMarker): Use marker alpha setting, (drawRangeMarker): Likewise. 2006-10-24 David Gilbert * source/org/jfree/chart/annotations/XYShapeAnnotation.java (draw): Calculate transform on shape bounds. 2006-10-23 David Gilbert * source/org/jfree/chart/plot/XYPlot.java: (setDomainCrosshairStroke): Check null argument, (setDomainCrosshairPaint): Likewise, plus various API doc updates. 2006-10-23 David Gilbert * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java: (drawRangeMarker): Added code to draw outlines. 2006-10-23 David Gilbert * source/org/jfree/chart/resources/JFreeChartResources.java (CONTENTS): Updated version number to 1.0.3. 2006-10-23 David Gilbert * ant/build.xml: Updated version number to 1.0.3, * source/org/jfree/data/xy/DefaultIntervalXYDataset.java: New file, * tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java: New file. 2006-10-20 David Gilbert * source/org/jfree/data/xy/XIntervalSeries.java (getX): Added cast; (getYValue): Likewise, (getDataItem): Changed return value, * source/org/jfree/data/xy/XIntervalSeriesCollection.java (getX): Added cast, (getY): Likewise, (getStartX): Likewise, (getEndX): Likewise, * source/org/jfree/data/xy/XYIntervalSeries.java (getX): Added cast; (getYValue): Likewise, (getDataItem): Changed return value, * source/org/jfree/data/xy/XYIntervalSeriesCollection.java (getX): Added cast, (getY): Likewise, (getStartX): Likewise, (getEndX): Likewise, * source/org/jfree/data/xy/YIntervalSeries.java (getX): Added cast; (getYValue): Likewise, (getDataItem): Changed return value, * source/org/jfree/data/xy/YIntervalSeriesCollection.java (getX): Added cast, (getY): Likewise, (getStartX): Likewise, (getEndX): Likewise, * tests/org/jfree/data/DataPackageTests.java (suite): Added new tests, * tests/org/jfree/data/xy/DataXYPackageTests.java (suite): Added new tests. 2006-10-20 David Gilbert * source/org/jfree/data/ComparableObjectItem.java: New file, * source/org/jfree/data/ComparableObjectSeries.java: Likewise, * source/org/jfree/data/xy/XIntervalDataItem.java: Likewise, * source/org/jfree/data/xy/XIntervalSeries.java: Likewise, * source/org/jfree/data/xy/XIntervalSeriesCollection.java: Likewise, * source/org/jfree/data/xy/XYInterval.java: Likewise, * source/org/jfree/data/xy/XYIntervalDataItem.java: Likewise, * source/org/jfree/data/xy/XYIntervalSeries.java: Likewise, * source/org/jfree/data/xy/XYIntervalSeriesCollection.java: Likewise, * source/org/jfree/data/xy/YInterval.java: Likewise, * source/org/jfree/data/xy/YIntervalDataItem.java: Likewise, * source/org/jfree/data/xy/YIntervalSeries.java: Likewise, * source/org/jfree/data/xy/YIntervalSeriesCollection.java: Likewise, * source/org/jfree/data/xy/YWithXInterval: Likewise, * tests/org/jfree/data/junit/ComparableObjectItemTests.java: New file, * tests/org/jfree/data/junit/ComparableObjectSeriesTests.java: New file, * tests/org/jfree/data/xy/junit/XIntervalDataItemTests.java: New file, * tests/org/jfree/data/xy/junit/XIntervalSeriesCollectionTests.java: New file, * tests/org/jfree/data/xy/junit/XIntervalSeriesTests.java: New file, * tests/org/jfree/data/xy/junit/XYIntervalDataItemTests.java: New file, * tests/org/jfree/data/xy/junit/XYIntervalSeriesCollectionTests.java: New file, * tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java: New file, * tests/org/jfree/data/xy/junit/XYIntervalTests.java: New file, * tests/org/jfree/data/xy/junit/YIntervalDataItemTests.java: New file, * tests/org/jfree/data/xy/junit/YIntervalSeriesCollectionTests.java: New file, * tests/org/jfree/data/xy/junit/YIntervalSeriesTests.java: New file, * tests/org/jfree/data/xy/junit/YIntervalTests.java: New file, * tests/org/jfree/data/xy/junit/YWithXIntervalTests.java: New file. 2006-10-17 David Gilbert * source/org/jfree/data/jdbc/JDBCXYDataset.java: (getLegendItemCount): Deprecated, (getLegendItemLabels): Deprecated. 2006-10-13 David Gilbert * source/org/jfree/chart/plot/CrosshairState.java (getCrosshairDistance): New method, (getAnchor): New method, (getAnchorX): New method, (setAnchorX): New method, (getAnchorY): New method, (setAnchorY): New method, * source/org/jfree/chart/plot/XYPlot.java (draw): Initialise the anchor coordinates. 2006-10-12 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java: (drawHorizontalItem): Check for null box, (drawVerticalItem): Likewise, * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testBug1572478Vertical): New method, (testBug1572478Horizontal): Likewise. 2006-10-12 David Gilbert * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java: Source reformatting and API doc updates. 2006-10-12 David Gilbert * source/org/jfree/chart/plot/RingPlot.java (sectionDepth): New field, (RingPlot(PieDataset)): Initialise sectionDepth field, (getSectionDepth): New method, (setSectionDepth): Likewise, (initialise): New method override to specify three passes, (drawItem): Use sectionDepth, draw separators in pass 3, (equals): Include sectionDepth in test, * tests/org/jfree/chart/plot/junit/RingPlotTests.java (testEquals): Updated, (testCloning): Likewise, (testSerialization): Likewise. 2006-10-12 David Gilbert * source/org/jfree/experimental/**: Removed, files transferred to a new source directory, * experimental/org/jfree/experimental/**: Added, see previous item. 2006-10-11 David Gilbert * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java (renderAsPercentages): New field, (StackedAreaRenderer(boolean)): New constructor, (getRenderAsPercentages): New method, (setRenderAsPercentages): Likewise, (getPassCount): New method override, (findRangeBounds): Handle renderAsPercentages, (drawItem): Add support for renderAsPercentages and item labels, (getPreviousHeight): Handle renderAsPercentages, (equals): New method override, * tests/org/jfree/chart/renderer/category/junit/StackedAreaRendererTests.java (testEquals): Updated for renderAsPercentages flag. 2006-10-11 David Gilbert * source/org/jfree/chart/renderer/category/AreaRenderer.java (equals): New method override, * tests/org/jfree/chart/renderer/category/junit/AreaRendererTests.java (testEquals): Added new checks. 2006-10-11 David Gilbert * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Fixed step for horizontal orientation. 2006-10-06 David Gilbert * source/org/jfree/chart/title/LegendItemBlockContainer.java (toolTipText): New field, (urlText): Likewise, (getToolTipText): New method, (setToolTipText): Likewise, (getURLText): Likewise, (setURLText): Likewise, (draw): Add tool tip text and URL text to the legend item entity, * source/org/jfree/chart/title/LegendTitle.java (createLegendItemBlock): Set the tool tip and URL text in the block. 2006-10-06 David Gilbert * source/org/jfree/chart/axis/PeriodAxis.java (calendar): New field, (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod, TimeZone)): Initialize calendar, (setTimeZone) Reset calendar, (getRange): Replaced deprecated method calls, (drawTickMarksHorizontal): Likewise, (drawTickLabels): Likewise, (valueToJava2D): Likewise, (java2DToValue): Likewise, * source/org/jfree/data/time/Day.java (firstMillisecond): New field, (lastMillisecond): New field, (Day(int, int, int)): Peg milliseconds to default time zone, (Day(SerialDate)): Likewise, (Day(Date, TimeZone)): Peg milliseconds to specified milliseconds, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, * source/org/jfree/data/time/FixedMillisecond.java (peg): New method, * source/org/jfree/data/time/Hour.java (hour): Changed type, (firstMillisecond): New field, (lastMillisecond): New field, (Hour(int, Day)): Peg milliseconds to default time zone, (Hour(Date, TimeZone)): Peg milliseconds to specified time zone, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, * source/org/jfree/data/time/Millisecond.java (day): New field, (hour): New field, (minute): New field, (second): Changed type, (firstMillisecond): New field, (Millisecond(int, Second)): Reimplemented, (Millisecond(Date, TimeZone)): Likewise, (getSecond): Likewise, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (next): Updated for modified fields, (getSerialIndex): Reimplemented, (equals): Likewise, (hashCode): Updated for new fields, (getFirstMillisecond(Calendar)): Reimplemented, (getLastMillisecond(Calendar)): Likewise, * source/org/jfree/data/time/Minute.java (day): New field, (hour): Changed type, (minute): Likewise, (firstMillisecond): New field, (lastMillisecond): New field, (Minute(int, Hour)): Reimplemented, (Minute(Date, TimeZone)): Likewise, (getDay): New method, (getHour): Reimplemented, (getHourValue): New method, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (previous): Updated for changed field types, (next): Likewise, (getSerialIndex): Reimplemented, (getFirstMillisecond(Calendar)): Updated for changed field types, (getLastMillisecond(Calendar)): Likewise, (equals): Likewise, (hashCode): Likewise, * source/org/jfree/data/time/Month.java (year): Changed type, (firstMillisecond): New field, (lastMillisecond): New field, (Month(int, int)): Reimplemented, (Month(int, Year)): Likewise, (Month(Date, TimeZone)): Likewise, (getYear): Updated for changed field type, (getYearValue): Likewise, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (previous): Updated for changed field types, (next): Likewise, (getSerialIndex): Likewise, (equals): Likewise, (hashCode): Likewise, (compareTo): Likewise, (getFirstMillisecond(Calendar)): Reimplemented, (getLastMillisecond(Calendar)): Likewise, * source/org/jfree/data/time/Quarter.java (year): Changed type, (quarter): Likewise, (firstMillisecond): New field, (lastMillisecond): New field, (Quarter(int, int)): Reimplemented, (Quarter(int, Year)): Likewise, (Quarter(Date, TimeZone)): Likewise, (getYear): Reimplemented, (getYearValue): New method, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (previous): Updated for changed field types, (next): Likewise, (getSerialIndex): Likewise, (equals): Likewise, (hashCode): Likewise, (compareTo): Likewise, (getFirstMillisecond(Calendar)): Reimplemented, (getLastMillisecond(Calendar)): Likewise, * source/org/jfree/data/time/RegularTimePeriod.java (WORKING_CALENDAR): Deprecated, (peg): New method, (getFirstMillisecond()): Made abstract, (getFirstMillisecond(TimeZone)): Deprecated, (getLastMillisecond()): Made abstract, (getLastMillisecond(TimeZone)): Deprecated, (getMiddleMillisecond(TimeZone)): Likewise, * source/org/jfree/data/time/Second.java (day): New field, (hour): New field, (minute): Changed type, (second): Changed type, (firstMillisecond): New field, (Second(int, Minute)): Reimplemented, (Second(Date, TimeZone)): Reimplemented, (getMinute): Updated for field type changes, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (previous): Updated for changed field types, (next): Likewise, (getSerialIndex): Likewise, (getFirstMillisecond(Calendar)): Reimplemented, (getLastMillisecond(Calendar)): Likewise, (equals): Likewise, (hashCode): Likewise, (compareTo): Updated for field type changes, * source/org/jfree/data/time/Week.java (year): Changed type, (week): Likewise, (firstMillisecond): New field, (lastMillisecond): New field, (Week(int, int)): Reimplemented, (Week(int, Year)): Likewise, (Week(Date, TimeZone)): Likewise, (getYear): Updated for field type changes, (getYearValue): Likewise, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (previous): Updated for changed field types, (next): Likewise, (getSerialIndex): Likewise, (getFirstMillisecond(Calendar)): Reimplemented, (getLastMillisecond(Calendar)): Likewise, (equals): Likewise, (hashCode): Likewise, (compareTo): Updated for field type changes, * source/org/jfree/data/time/Year.java (year): Changed field type, (firstMillisecond): New field, (lastMillisecond): New field, (Year(int)): Peg to default time zone, (Year(Date, TimeZone)): Peg to specified time zone, (getFirstMillisecond): New method override, (getLastMillisecond): Likewise, (peg): New method, (getFirstMillisecond(Calendar)): Reimplemented, (getLastMillisecond(Calendar)): Likewise. 2006-10-06 David Gilbert * source/org/jfree/data/xy/DefaultXYZDataset.java: Fixed API doc warnings. 2006-10-05 David Gilbert * source/org/jfree/data/time/Day.java: API doc updates, * source/org/jfree/data/time/Hour.java: Likewise, * source/org/jfree/data/time/Millisecond.java: Likewise, * source/org/jfree/data/time/Minute.java: Likewise, * source/org/jfree/data/time/Month.java: Likewise, * source/org/jfree/data/time/Quarter.java: Likewise, * source/org/jfree/data/time/Second.java: Likewise, * source/org/jfree/data/time/Week.java: Likewise, * source/org/jfree/data/time/Year.java: Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/MillisecondTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/SecondTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/MinuteTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/HourTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/DayTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/WeekTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/MonthTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/QuarterTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * tests/org/jfree/data/time/junit/YearTests.java (testGetFirstMillisecond): New test, (testGetFirstMillisecondWithTimeZone): Likewise, (testGetFirstMillisecondWithCalendar): Likewise, (testGetLastMillisecond): Likewise, (testGetLastMillisecondWithTimeZone): Likewise, (testGetLastMillisecondWithCalendar): Likewise, (testGetSerialIndex): Likewise, (testNext): Likewise, (testGetStart): Likewise, (testGetEnd): Likewise. 2006-10-05 David Gilbert * source/org/jfree/data/xy/DefaultXYDataset.java: Fixed API doc warnings. 2006-10-03 David Gilbert * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java: Fixed Javadoc warnings, * source/org/jfree/chart/entity/CategoryLabelEntity.java: Likewise, * source/org/jfree/chart/event/MarkerChangeListener.java: Likewise, * source/org/jfree/chart/plot/PiePlot.java: Likewise. 2006-10-03 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (getSectionKey): Replace call to JRE 1.5 method. 2006-10-03 David Gilbert * source/org/jfree/data/time/DayTests.java (testGetSerialIndex): New method. 2006-10-03 David Gilbert * source/org/jfree/data/time/TimePeriodValue.java (TimePeriodValue(TimePeriod, Number)): Added null argument check, (clone): Print stack trace in event of exception, * source/org/jfree/data/time/TimePeriodValues.java (add(TimePeriodValue)): Fire series change event, (equals): Guard against null pointer exceptions, * source/org/jfree/data/time/TimePeriodValuesCollection.java (getDomainIsPointsInTime): Deprecated, (setDomainIsPointsInTime): Likewise, * source/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java: (testEquals): Check for domain and range description fields, (testAdd): New method, (MySeriesChangeListener): New test support class. 2006-10-02 David Gilbert * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java: New file, * source/org/jfree/chart/annotations/XYPointerAnnotation.java (setArrowPaint): Check for null argument, * source/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java (suite): Added CategoryPointerAnnotationTests, * source/org/jfree/chart/annotations/junit/CategoryPointerAnnotationTests.java: New file. 2006-10-02 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (drawCategoryLabels): Updated label entity generation, * source/org/jfree/chart/entity/CategoryLabelEntity.java: New class. 2006-09-28 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (draw): Replaced call to deprecated method. 2006-09-28 David Gilbert * source/org/jfree/data/general/DefaultPieDataset.java (sortByKeys): New method, (sortByValues): New method. 2006-09-27 David Gilbert * source/org/jfree/chart/ChartFactory.java (createPieChart): Updated for deprecated code, * source/org/jfree/chart/PaintMap.java: New class, * source/org/jfree/chart/StrokeMap.java: Likewise, * source/org/jfree/chart/junit/PaintMapTests.java: Likewise, * source/org/jfree/chart/junit/StrokeMapTests.java: Likewise, * source/org/jfree/chart/plot/MultiplePiePlot.java (draw): Updated for deprecated code, * source/org/jfree/chart/plot/PiePlot.java (sectionPaintMap): Changed name and type from PaintList to PaintMap, (sectionOutlinePaintMap): Likewise, (sectionOutlineStrokeMap): Likewise, (explodePercentages): Changed type from ObjectList to Map, (PiePlot(PieDataset)): Update initialisation for field name changes, (lookupSectionPaint): Changed argument type, (getSectionKey): New method, (getSectionPaint(Comparable)): Likewise, (setSectionPaint(Comparable, Paint)): Likewise, (getSectionPaint(int)): Deprecated, (setSectionPaint(int, Paint)): Likewise, (lookupSectionOutlinePaint): Changed argument type, (getSectionOutlinePaint(Comparable)): Likewise, (setSectionOutlinePaint(Comparable, Paint)): Likewise, (getSectionOutlinePaint(int)): Deprecated, (setSectionOutlinePaint(int, Paint)): Likewise, (lookupSectionOutlineStroke): Changed argument type, (getSectionOutlineStroke(Comparable)): Likewise, (setSectionOutlineStroke(Comparable, Stroke)): Likewise, (getSectionOutlineStroke(int)): Deprecated, (setSectionOutlineStroke(int, Stroke)): Likewise, (getExplodePercent(Comparable)): New method, (setExplodePercent(Comparable, double)): Likewise, (getExplodePercent(int)): Deprecated, (setExplodePercent(int, double)): Deprecated, (getMaximumExplodePercent): Modified to only check visible sections, (drawItem): Updated for deprecated code, (getLegendItems): Likewise, (equals): Updated for renamed fields, * source/org/jfree/chart/plot/PiePlot3D.java (draw): Updated for deprecated code, * source/org/jfree/chart/plot/RingPlot.java (drawItem): Likewise. 2006-09-27 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (PiePlot(PieDataset)): Initialise baseSectionPaint to a non-null value, (lookupSectionPaint(int)): New method, (lookupSectionPaint(int, boolean)): Likewise, (getSectionPaint(int)): Reimplemented without lookup, (lookupSectionOutlinePaint(int)): New method, (lookupSectionOutlinePaint(int, boolean)): Likewise, (getSectionOutlinePaint(int)): Reimplemented without lookup, (lookupSectionOutlineStroke(int)): New method, (lookupSectionOutlineStroke(int, boolean)): Likewise, (getSectionOutlineStroke(int)): Reimplemented without lookup, (drawItem): Use new lookup methods, (getLegendItems): Likewise, * source/org/jfree/chart/plot/PiePlot3D.java (draw): Use new lookup methods, * source/org/jfree/chart/plot/RingPlot.java (drawItem): Use new lookup methods, * source/org/jfree/chart/plot/junit/PiePlotTests.java (testGetBaseSectionPaint): New method. 2006-09-25 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): Handle tick mark position properly, * source/org/jfree/chart/axis/junit/DateAxisTests.java (MyDateAxis): New class, (testPreviousStandardDateYear): New method, (testPreviousStandardDateMonth): New method, (testPreviousStandardDateDay): New method, (testPreviousStandardDateHour): New method, (testPreviousStandardDateMinute): New method. 2006-09-25 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java: (StatisticalLineAndShapeRenderer(boolean, boolean)): Use arguments, * source/org/jfree/chart/renderer/category/junit/StatisticalLineAndShapeRendererTests.java: (test1562759): New method. 2006-09-21 David Gilbert * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (drawItem): Don't use hard-coded outline paint and stroke. 2006-09-13 David Gilbert * source/org/jfree/chart/servlet/ServletUtilities.java (sendTempFile(File, HttpServletResponse, String)): Specify English locale for response header date format. 2006-09-13 David Gilbert * source/org/jfree/chart/ChartPanel.java (mouseClicked): Return early if chart is null, (mouseMoved): Check for null chart. 2006-09-13 David Gilbert * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java: Updated API docs and reformatted some source code, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java: Likewise, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java: Likewise, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java: Likewise, * source/org/jfree/chart/plot/XYPlot.java: Likewise. 2006-09-07 David Gilbert * source/org/jfree/data/statistics/HistogramDataset.java (addSeries): Check for binIndex that is too large, * source/org/jfree/data/statistics/junit/HistogramDatasetTests.java (test1553088): New method. 2006-09-05 David Gilbert * source/org/jfree/chart/event/MarkerChangeEvent.java: New file, * source/org/jfree/chart/event/MarkerChangeListener.java: New file, * source/org/jfree/chart/plot/CategoryMarker.java (setKey): New method, (setDrawAsLine): Notify listeners, * source/org/jfree/chart/plot/CategoryPlot.java (addDomainMarker): Register plot as a listener with the new marker, (clearDomainMarkers()): Deregister plot as a listener with each marker, (clearDomainMarkers(int)): Likewise, (addRangeMarker): Register plot as a listener with the new marker, (clearRangeMarkers()): Deregister plot as a listener with each marker, (clearRangeMarkers(int)): Likewise, * source/org/jfree/chart/plot/IntervalMarker.java (setStartValue): New method, (setEndValue): New method, (setGradientPaintTransformer): Notify listeners, * source/org/jfree/chart/plot/Marker.java (listeners): New field, (Marker): Initialise listeners field, (setPaint): Notify listeners, (setStroke): Likewise, (setOutlinePaint): Likewise, (setOutlineStroke): Likewise, (setAlpha): Likewise, (setLabel): Likewise, (setLabelFont): Likewise, (setLabelPaint): Likewise, (setLabelAnchor): Likewise, (setLabelOffset): Likewise, (setLabelOffsetType): Likewise, (setLabelTextAnchor): Likewise, (addChangeListener): New method, (removeChangeListener): New method, (notifyListeners): New method, (getListeners): New method, * source/org/jfree/chart/plot/Plot.java (markerChanged): New method, * source/org/jfree/chart/plot/ValueMarker.java (setValue): New method, * source/org/jfree/chart/plot/XYPlot.java (addDomainMarker): Register plot as a listener with the new marker, (clearDomainMarkers()): Deregister plot as a listener with each marker, (clearDomainMarkers(int)): Likewise, (addRangeMarker): Register plot as a listener with the new marker, (clearRangeMarkers()): Deregister plot as a listener with each marker, (clearRangeMarkers(int)): Likewise, * source/org/jfree/chart/plot/junit/CategoryMarkerTests.java: (lastEvent): New field, (markerChanged): New method, (testGetSetKey): Likewise, (testGetSetDrawAsLine): Likewise, * source/org/jfree/chart/plot/junit/IntervalMarkerTests.java: (lastEvent): New field, (markerChanged): New method, (testGetSetStartValue): New method, (testGetSetEndValue): New method, * source/org/jfree/chart/plot/junit/MarkerTests.java: New file, * source/org/jfree/chart/plot/junit/PlotPackageTests.java (suite): Added MarkerTests.class, * source/org/jfree/chart/plot/junit/ValueMarkerTests.java: (lastEvent): New field, (markerChanged): New method, (testGetSetValue): Likewise. 2006-09-04 David Gilbert * source/org/jfree/chart/ChartPanel.java (actionPerformed): Updated for method name change, (attemptEditChartProperties): Renamed doEditChartProperties() and made public. 2006-09-04 David Gilbert * source/org/jfree/chart/axis/NumberAxis.java (autoAdjustRange): Check for lower == upper after applying auto range minimum size and adjust if necessary. 2006-09-01 David Gilbert * source/org/jfree/data/time/TimeSeries.java (removeAgedItems(boolean)): Check for greater than maxItemAge, (removeAgedItems(long, boolean): Reimplemented, * source/org/jfree/data/time/junit/TimeSeriesTests.java (testRemoveAgedItems): New method, (testRemoveAgedItems2): New method. 2006-08-29 Henry Proudhon * source/org/jfree/experiment/swt/SWTUtils.java (Az): New field, (toSwtFontData): Refined font size calculation, (toAwtFont): Likewise. ---------- JFREECHART 1.0.2 RELEASED ------------------------ 2006-08-25 David Gilbert * source/org/jfree/chart/JFreeChart.java (JFreeChartInfo.getLogo): Load image from jar file in a way that works for Java Web Start also. 2006-08-25 David Gilbert * README.txt: Provide link to iText, * ant/build.xml: Restore 'compile-experimental' to 'all', but exclude SWT classes. 2006-08-25 David Gilbert * NEWS: Updated for release, * README.txt: Likewise, * ant/build.xml: Removed 'compile-experimental' from 'all'. 2006-08-24 David Gilbert * source/org/jfree/experimental/chart/axis/LogAxis.java: New file, * source/org/jfree/experimental/chart/demo/LogAxisDemo1.java: New file. 2006-08-24 David Gilbert * source/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java: Made package private, * source/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java: Likewise, * source/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java: Likewise, * source/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java: Likewise, * source/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java: Likewise, * source/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java: Likewise, * source/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java: Likewise. 2006-08-24 David Gilbert * source/org/jfree/experimental/chart/swt/ChartComposite.java (attemptEditChartProperties): Implemented, * source/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java: New file, * source/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java: New file, * source/org/jfree/experimental/swt/SWTPaintCanvas.java: New file. 2006-08-24 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItem): Added crosshair support, and modified dataset calls to use only double primitives. 2006-08-24 David Gilbert * source/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java (createDataset): Rewritten to fix compile errors, * source/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java (setValue): New method, (createDataset): Rewritten to fix compile errors. 2006-08-23 David Gilbert * source/org/jfree/experimental/chart/swt/ChartComposite.java: New file, * source/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java: New file, * source/org/jfree/experimental/chart/swt/demo/SWTMultipleAxisDemo1.java: New file, * source/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java: New file, * source/org/jfree/experimental/swt/SWTGraphics2D.java: New file, * source/org/jfree/experimental/swt/SWTUtils.java: New file. 2006-08-23 David Gilbert * ant/build.xml: Added 'compile-experimental' target, * source/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: New file, * source/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: New file, * source/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: New file, * source/org/jfree/experimental/chart/renderer/GrayPaintScale.java: New file, * source/org/jfree/experimental/chart/renderer/LookupPaintScale.java: New file, * source/org/jfree/experimental/chart/renderer/PaintScale.java: New file, * source/org/jfree/experimental/chart/renderer/junit/GrayPaintScaleTests.java: New file, * source/org/jfree/experimental/chart/renderer/junit/LookupPaintScaleTests.java: New file, * source/org/jfree/experimental/chart/renderer/xy/XYBlockRenderer.java: New file, * source/org/jfree/experimental/chart/renderer/xy/junit/XYBlockRendererTests.java: New file. 2006-08-23 David Gilbert * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (setFixedRangeAxisSpace): New method override. 2006-08-23 David Gilbert * source/org/jfree/chart/ChartFactory.java (createStackedXYAreaChart): Use StackedXYAreaRenderer2 instead of StackedXYAreaRenderer, for better handling of negative values, * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java: Updated API docs. 2006-08-22 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java (findRangeBounds): Handle null and empty datasets correctly, * source/org/jfree/chart/renderer/xy/junit/StackedXYAreaRenderer2Tests.java: (testDrawWithEmptyDataset): New test, (testFindRangeBounds): Added checks for null and empty datasets. 2006-08-18 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (drawCategoryLabels(Graphics2D, Rectangle2D, RectangleEdge, AxisState, PlotRenderingInfo)): Deprecated, (drawCategoryLabels(Graphics2D, Rectangle2D, Rectangle2D, RectangleEdge, AxisState, PlotRenderingInfo)): New method, * source/org/jfree/chart/axis/CategoryAxis3D.java (draw): Call new drawCategoryLabels() method, * source/org/jfree/chart/axis/SubCategoryAxis.java (draw): Likewise, * source/org/jfree/chart/plot/CategoryPlot.java (getDatasetCount): New method. 2006-08-18 David Gilbert * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java (calculateBarWidth): Respect maximumBarWidth setting. 2006-08-17 David Gilbert * source/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java (testFindRangeBounds): New method, * source/org/jfree/chart/renderer/xy/junit/HighLowRendererTests.java (testFindRangeBounds): New method. 2006-08-17 David Gilbert * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (equals): Check additional fields, * source/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java (testEquals): Extended to check all fields. 2006-08-04 David Gilbert * ant/build.xml: Added source="1.3" target="1.3" to compile. 2006-08-04 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (calculateBarL0L1}: Changed clipping slightly. 2006-08-04 David Gilbert * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (clone): New method, (equals): Likewise, * source/org/jfree/chart/renderer/junit/DefaultPolarItemRendererTests.java: New test class, * source/org/jfree/chart/renderer/junit/RendererPackageTests.java (suite): Added DefaultPolarItemRendererTests. 2006-08-04 David Gilbert * source/org/jfree/chart/block/AbstractBlock.java (getContentXOffset): Added API docs, (getContentYOffset): Likewise. 2006-08-04 David Gilbert * source/org/jfree/chart/annotation/CategoryLineAnnotation.java (CategoryLineAnnotation): Fixed API doc warnings. 2006-08-03 David Gilbert * source/org/jfree/data/xy/XYBarDataset.java: API doc updates, * source/org/jfree/data/xy/XYDataset.java: Likewise, * source/org/jfree/data/xy/XYSeriesCollection.java: Likewise. 2006-08-03 David Gilbert * source/org/jfree/data/category/junit/CategoryToPieDatasetTests.java (testGetIndex): New test method. 2006-08-03 David Gilbert * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java (getRangeBounds): Minor fix to previous patch. 2006-08-03 David Gilbert * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java (minimumRangeValueIncStdDev): New field, (maximumRangeValueIncStdDev): Likewise, (DefaultStatisticalCategoryDataset): Updated initialization code, (add): Modified code to update ranges, (getRangeBounds): Create the range as required, * source/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java (testGetRangeBounds): New test method. 2006-08-03 David Gilbert * source/org/jfree/data/statistics/HistogramDataset.java (addSeries): Improved precision of bin boundary calculation, * source/org/jfree/data/statistics/junit/HistogramDatasetTests.java (testAddSeries): New method, (testBinBoundaries): New method. 2006-08-03 David Gilbert * source/org/jfree/data/statistics/HistogramDataset.java: API doc updates. 2006-08-02 David Gilbert * source/org/jfree/chart/annotations/XYBoxAnnotation.java: API doc correction and source code reformatting. 2006-08-02 David Gilbert * source/org/jfree/chart/needle/ArrowNeedle.java: Minor API doc updates, * source/org/jfree/chart/needle/LineNeedle.java: Likewise, * source/org/jfree/chart/needle/LongNeedle.java: Likewise, * source/org/jfree/chart/needle/MiddlePinNeedle.java: Likewise, * source/org/jfree/chart/needle/PinNeedle.java: Likewise, * source/org/jfree/chart/needle/PlumNeedle.java: Likewise, * source/org/jfree/chart/needle/PointerNeedle.java: Likewise, * source/org/jfree/chart/needle/ShipNeedle.java: Likewise, * source/org/jfree/chart/needle/WindNeedle.java: Likewise. 2006-08-01 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (equals): Handle null tool tip and URL generators, * source/org/jfree/chart/plot/junit/SpiderWebPlot.java (testEquals): Extended to check tooltip and URL generators. 2006-08-01 David Gilbert * source/org/jfree/chart/DrawableLegendItem.java: Deprecated class. 2006-08-01 David Gilbert * source/org/jfree/chart/ChartPanel.java (restoreAutoRangeBounds): Check for instance of Zoomable rather than ValueAxisPlot. 2006-08-01 David Gilbert * source/org/jfree/chart/plot/DefaultDrawingSupplier.java: Reformatted and updated API docs. 2006-08-01 David Gilbert * source/org/jfree/data/DefaultKeyedValues.java (getIndex): Check for null argument, * source/org/jfree/data/general/DefaultPieDataset.java (getKey(int)): Throw IndexOutOfBounds if key exceeds getItemCount() - 1, * source/org/jfree/data/general/junit/DefaultPieDatasetTests.java (testGetKey): New method, (testGetIndex): New method, * source/org/jfree/data/junit/DefaultKeyedValuesTests.java (testGetIndex): Added check for null argument. 2006-07-31 David Gilbert * source/org/jfree/data/DefaultKeyedValues.java (clear): New method, * source/org/jfree/data/general/DefaultPieDataset.java (clear): Likewise, * source/org/jfree/data/general/junit/DefaultPieDatasetTests.java (lastEvent): New field, (datasetChanged): New method, (testClear): New method, * source/org/jfree/data/junit/DefaultKeyedValuesTests.java (testClear): New method. 2006-07-27 David Gilbert * source/org/jfree/data/xy/XYSeries.java (add(Number, Number, boolean)): Removed redundant argument check. 2006-07-26 David Gilbert * source/org/jfree/chart/axis/junit/NumberAxisTests.java (testAutoRange4): New method. 2006-07-26 David Gilbert * source/org/jfree/data/category/CategoryToPieDataset.java (serialVersionUID): New field, (CategoryToPieDataset): Handle null source, (getUnderlyingDataset): New method, (getExtractType): New method, (getExtractIndex): New method, (getValue): Check index bounds, (getKey): Check index bounds, (getIndex): Handle null source, (getKeys): Likewise, (getValue): Handle unrecognised key, (equals): New method override, * source/org/jfree/data/category/junit/CategoryToPieDatasetTests.java: New file, * source/org/jfree/data/category/junit/DataCategoryPackageTests.java (suite): Added new test. 2006-07-25 David Gilbert * ant/build.xml: Use JCommon 1.0.5, * source/org/jfree/chart/axis/DateAxis.java: Fixed API doc warning, * source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java: Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java: Likewise, * source/org/jfree/data/general/Series.java: Likewise, * source/org/jfree/data/time/TimeSeries.java: Likewise. 2006-07-25 David Gilbert * source/org/jfree/chart/resources/JFreeChartResources.java (CONTENTS): Updated version number, * source/overview.html: Updated link, * ant/build.xml: Updated version number. 2006-07-25 David Gilbert * source/org/jfree/chart/demo/TimeSeriesDemo1.java (createDataset): Removed call to deprecated method. 2006-07-20 David Gilbert * source/org/jfree/chart/LegendItem.java (datasetIndex): New field, (series): Likewise, (getDatasetIndex): New method, (setDatasetIndex): Likewise, (getSeriesIndex): Likewise, (setSeriesIndex): Likewise, (equals): Updated for new fields, * source/org/jfree/chart/block/BlockContainer.java (draw): Transform drawing area directly, * source/org/jfree/chart/block/CenterArrangement.java (arrangeNN): Set bounds for contained block, * source/org/jfree/chart/block/LabelBlock.java (arrange): Removed unused code, (draw): Correct entity area calculation, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (getLegendItem): Set dataset and series indices, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/title/LegendItemBlockContainer.java: New file, * source/org/jfree/chart/title/LegendTitle.java (createLegendItemBlock): Use new LegendItemBlockContainer class. 2006-07-20 David Gilbert * source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java (quality): Changed default to 0.95f, (setQuality): Added argument check, (encode(BufferedImage, OutputStream)): Set quality before writing image to output stream. 2006-07-12 David Gilbert * source/org/jfree/chart/annotations/XYPointerAnnotation.java (draw): Swap coordinates for PlotOrientation.HORIZONTAL. 2006-07-12 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java (drawHorizontalItem): Added item label drawing, (drawVerticalItem): Likewise. 2006-07-12 David Gilbert * source/org/jfree/data/xy/DefaultWindDataset.java (DefaultWindDataset(List, Object[][][]): Added argument checks, (getItemCount): Likewise, (getSeriesKey): Likewise, (equals): New method override, (WindDataItem): Implements Serializable, (WindDateItem.equals): New method override, * source/org/jfree/data/xy/WindDataset.java: API doc updates, * source/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): Added DefaultWindDatasetTests, * source/org/jfree/data/xy/junit/DefaultWindDatasetTests.java: New file. 2006-07-12 David Gilbert * source/org/jfree/data/xy/DefaultXYZDataset.java: New file, * source/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): Add new test class, * source/org/jfree/data/xy/junit/DefaultXYZDatasetTests.java: New file. 2006-07-10 David Gilbert * source/org/jfree/chart/renderer/xy/XYDotRenderer.java (dotWidth): New field, (dotHeight): New field, (XYDotRenderer): Initialize new fields, (getDotWidth): New method, (setDotWidth): Likewise, (getDotHeight): New method, (setDotHeight): New method, (drawItem): Use variable dot size, (equals): Check new field values, * source/org/jfree/chart/renderer/xy/junit/XYDotRendererTests.java (testEquals): Extended test to cover new fields, (testHashCode): Likewise. 2006-07-10 David Gilbert * source/org/jfree/chart/annotations/XYPolygonAnnotation.java (XYPolygonAnnotation(double[], Stroke, Paint, Paint)): Added argument checks, and cloned incoming array, (getPolygonCoordinates): New method, (getFillPaint): New method, (getOutlinePaint): New method, (getOutlineStroke): New method, (draw): Return if the polygon has less than two vertices, (equals): Fixed bug with GradientPaint, (hashCode): Implemented, (hashCodeForPaint): New utility method, (hashCodeForDoubleArray): Likewise, * source/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java: (suite): Added XYPolygonAnnotationTests, * source/org/jfree/chart/annotations/junit/XYPolygonAnnotationTest.java: New file. 2006-07-10 David Gilbert * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java: Source reformatting. 2006-07-06 David Gilbert * source/org/jfree/data/general/AbstractSeriesDataset.java: API doc updates, * source/org/jfree/data/general/SeriesDataset.java: Likewise. 2006-07-06 David Gilbert * source/org/jfree/data/xy/DefaultXYDataset.java: New file, * source/org/jfree/data/xy/junit/DataXYPackageTests.java: (suite): Included new class DefaultXYDatasetTests, * source/org/jfree/data/xy/junit/DefaultXYDatasetTests.java: New file. 2006-07-06 David Gilbert * source/org/jfree/chart/renderer/xy/CyclicXYItemRenderer.java (drawItem): Swapped all calls to dataset methods returning Number instances, to corresponding methods that return doubles. 2006-07-06 David Gilbert * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (drawItem): Swapped all calls to dataset methods returning Number instances, to corresponding methods that return doubles. 2006-07-06 David Gilbert * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (drawItem): Swapped all calls to dataset methods returning Number instances, to corresponding methods that return doubles. 2006-07-06 David Gilbert * source/org/jfree/chart/urls/TimeSeriesURLGenerator.java: (generateURL): Swapped getX() --> getXValue() (DG); 2006-07-06 David Gilbert * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java: Reformatted. 2006-07-06 David Gilbert * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java (drawItem): Swapped all calls to dataset methods returning Number instances, to corresponding methods that return doubles. 2006-07-03 David Gilbert * source/org/jfree/chart/plot/Marker.java: Reformatting and API doc updates. 2006-06-30 David Gilbert * source/org/jfree/chart/plot/Plot.java (backgroundImageAlpha): New field, (getBackgroundImageAlpha): New method, (setBackgroundImageAlpha): New method, (drawBackgroundImage): Use new alpha field, * source/org/jfree/chart/plot/junit/PlotTests.java (testEquals): Added check for new field. 2006-06-21 David Gilbert * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java (drawItem): Check orientation when adjusting for margin, call new drawItemLabel() method in superclass. 2006-06-21 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (positiveItemLabelPositionFallback): New field, (negativeItemLabelPositionFallback): Likewise, (getPositiveItemLabelPositionFallback): New method, (setPositiveItemLabelPositionFallback): Likewise, (getNegativeItemLabelPositionFallback): Likewise, (setNegativeItemLabelPositionFallback): Likewise, (drawItem): Call new drawItemLabel() method, (drawItemLabel): New method, (calculateLabelAnchorPoint): New method, (isInternalAnchor): New method, (equals): Updated for new fields, * source/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java (testEquals): Extended to cover new fields, (testSerialization2): New test. 2006-06-15 David Gilbert * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Handle item labels. 2006-06-15 David Gilbert * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (State.seriesIndex): New field, (State.getSeriesIndex): New method, (State.setSeriesIndex): New method, (initialise): Set seriesIndex field, (drawItem): Don't return until seriesPath has a chance to be updated and/or drawn, if it is being used. 2006-06-01 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (drawRadarPoly): Check for null info, * source/org/jfree/chart/plot/junit/SpiderWebPlotTests.java (testDrawWithNullInfo): New method. 2006-06-01 David Gilbert * source/org/jfree/data/junit/WeekTests.java (testBug1498805): New method. 2006-05-25 David Gilbert * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (drawItem): Check for both line and shape not visible, and do nothing in that case (fix for bug 1494936). 2006-05-24 David Gilbert * source/org/jfree/data/time/TimeSeries.java: (delete(RegularTimePeriod)): Do nothing for unknown time period, (delete(int, int)): Added argument check, (createCopy(int, int)): Added argument checks, (createCopy(RegularTimePeriod, RegularTimePeriod)): Added argument checks, and special handling for range containing no observations, * source/org/jfree/data/time/junit/TimeSeriesTests.java: (testDelete2): Added new cases, (testCreateCopy1): Reformatted, (testCreateCopy2): New test, (testGetIndex): Likewise, (testGetDataItem1): Likewise, (testGetDataItem2): Likewise. 2006-05-24 David Gilbert * source/org/jfree/data/general/Series.java: Updated API docs. 2006-05-19 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java (drawHorizontalItem): Add entity for bar, (drawVerticalItem): Add entity for bar. 2006-05-03 David Gilbert * source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java (AbstractCategoryItemLabelGenerator(String, NumberFormat, NumberFormat)): New constructor, * source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java (StandardCategoryItemLabelGenerator(String, NumberFormat, NumberFormat)): New constructor, (equals): New method, * source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java (equals): Added check for formatPattern, * source/org/jfree/chart/labels/StandardCategoryToolTipGenerator.java (StandardCategoryToolTipGenerator(String, NumberFormat, NumberFormat)): New constructor, (equals): New method, * source/org/jfree/chart/labels/junit/StandardCategoryItemLabelGeneratorTests.java (testEquals1481087): New test, * source/org/jfree/chart/labels/junit/StandardCategorySeriesLabelGeneratorTests.java: New file, * source/org/jfree/chart/labels/junit/StandardCategoryToolTipGeneratorTests.java (testEquals1481087): New test. 2006-05-03 David Gilbert * source/org/jfree/chart/labels/junit/LabelsPackageTests.java (suite): Updated test class name, * source/org/jfree/chart/labels/junit/StandardPieItemLabelGeneratorTests.java: Removed, * source/org/jfree/chart/labels/junit/StandardPieToolTipGeneratorTests.java: Added (renamed file). 2006-05-03 David Gilbert * source/org/jfree/chart/labels/AbstractPieItemLabelGenerator.java (clone): Clone the percentFormat field, fixes bug 1480978, * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java (DEFAULT_SECTION_LABEL_FORMAT): Changed to "{0}", (StandardPieSectionLabelGenerator()): Use DEFAULT_SECTION_LABEL_FORMAT, * source/org/jfree/chart/labels/StandardPieToolTipGenerator.java: Reformatted, * source/org/jfree/chart/labels/junit/StandardPieItemLabelGeneratorTests.java (testCloning): Extended test to cover bug 1480978. 2006-04-19 David Gilbert * source/org/jfree/chart/axis/DateAxis.java (equals): Call super.equals(); * source/org/jfree/chart/axis/junit/DateAxisTests.java (testEquals): Added more checks, (test1472942): New test method. 2006-04-11 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java: (drawItem): Handle horizontal orientation correctly. 2006-04-06 David Gilbert * source/org/jfree/chart/plot/MultiplePiePlot.java (aggregatedItemsKey): New field, (aggregatedItemsPaint): Likewise, (sectionPaints): Likewise, (MultiplePiePlot(CategoryDataset)): Initialise new fields, (getAggregatedItemsKey): New method, (setAggregatedItemsKey): Likewise, (getAggregatedItemsPaint): Likewise, (setAggregatedItemsPaint): Likewise, (draw): Call prefetchSectionPaints(), use new field for aggregatedItemsKey, and update section colors in pie plot before drawing, (prefetchSectionPaints): New utility method, (getLegendItems): Call prefetchSectionPaints(), and add item for aggregatedItems if these are being used, (equals): Added tests for new fields, (writeObject): Added serialization support for new fields, (readObject): Likewise, * source/org/jfree/chart/plot/junit/MultiplePiePlotTests.java (testEquals): Extended to cover new fields, (testSerialization): Modified to cover a failing case. 2006-04-06 David Gilbert * source/org/jfree/data/time/Week.java (Week(Date, TimeZone)): Handle the case where the first few days of the year are part of the last week of the preceding year - see bug report 1448828, * source/org/jfree/data/time/junit/WeekTests.java (testBug1448828): New test method. 2006-04-05 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (toolTipGenerator): New field, (urlGenerator): Likewise, (getToolTipGenerator): New method, (setToolTipGenerator): Likewise, (getURLGenerator): Likewise, (setURLGenerator): Likewise, (drawRadarPoly): Populate entity collection, if not null, (equals): Updated for new fields. 2006-04-05 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (drawRadarPoly): Check for value >= to zero, not > zero (see patch 1462727). 2006-04-05 David Gilbert Patch 1459313 by Max Herfort: * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (renderAsPercentages): New field, (StackedBarRenderer3D()): Delegate to new constructor, (StackedBarRenderer3D(boolean)): New constructor, (StackedBarRenderer3D(double, double, boolean)): Likewise, (getRenderAsPercentages): New method, (setRenderAsPercentages): Likewise, (findRangeBounds): Check renderAsPercentages flag and return an appropriate range, (drawItem): Check renderAsPercentages flag and draw items accordingly, (equals): Overridden to account for renderAsPercentages flag, * NEWS: Added notes about this patch. 2006-03-08 David Gilbert * source/org/jfree/data/jdbc/JDBCCategoryDataset.java (executeQuery(Connection, String)): Fixed update loop (bug 1445748). 2006-03-02 David Gilbert * source/org/jfree/chart/renderer/AbstractCategoryItemRenderer.java (getLegendItems): Check seriesVisibleInLegend flag before creating each legend item. 2006-02-28 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (drawRightLabels): Fixed distribution of labels, * NEWS: Added bug fix entry for 1440415. 2006-02-28 David Gilbert * ant/build.xml (compile): Remove manifest specification; * NEWS: Added bug fix entry. 2006-02-20 David Gilbert * source/org/jfree/chart/annotations/XYPointerAnnotation.java (equals): Reimplemented, * source/org/jfree/chart/annotations/junit/XYPointerAnnotationTests.java (testEquals): Updated to cover bug report 1415160. 2006-02-20 David Gilbert * source/org/jfree/chart/axis/NumberAxis.java (equals): Added check for rangeType field, * source/org/jfree/chart/axis/junit/NumberAxisTests.java (testEquals()): Extended to check rangeType field, * NEWS: Added note of bug fix for 1435461. 2006-02-10 David Gilbert * source/org/jfree/chart/axis/DateAxis.java: Updated API docs, * source/org/jfree/chart/axis/NumberAxis.java: Likewise. ---------- JFREECHART 1.0.1 RELEASED ------------------------ 2006-01-27 David Gilbert * NEWS: Updated for 1.0.1 release, * ant/build.xml: Updated version number, * source/org/jfree/chart/JFreeChart.java: Reformatted, * source/org/jfree/chart/resources/JFreeChartResources.java: (CONTENTS): Updated version number. 2006-01-27 David Gilbert * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java (createItemArray): Updated API docs, * source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java: New file, * source/org/jfree/chart/labels/StandardXYZItemLabelGenerator.java: Removed, * source/org/jfree/chart/labels/XYZItemLabelGenerator.java: Likewise, * source/org/jfree/chart/labels/junit/BubbleXYItemLabelGeneratorTests.java: New tests, * source/org/jfree/chart/labels/junit/LabelsPackageTests.java (suite): Renamed test, * source/org/jfree/chart/labels/junit/StandardXYItemLabelGeneratorTests.java: New file, * source/org/jfree/chart/labels/junit/StandardXYLabelGeneratorTests.java: Removed. 2006-01-27 David Gilbert * source/org/jfree/chart/plot/CategoryPlot.java (getDomainGridlinePosition): Updated API docs, (setDomainGridlinePosition): Check for null argument, (getDomainGridlineStroke): Updated API docs, (setDomainGridlineStroke): Check for null argument, (getDomainGridlinePaint): Updated API docs, (setDomainGridlinePaint): Check for null argument, (getRangeGridlineStroke): Updated API docs, (setRangeGridlineStroke): Check for null argument, (getRangeGridlinePaint): Updated API docs, (setRangeGridlinePaint): Check for null argument. 2006-01-26 David Gilbert * source/org/jfree/chart/plot/XYPlot.java (getAnnotations): New method, * source/org/jfree/chart/plot/junit/XYPlotTests.java (testRemoveAnnotation): New test. 2006-01-26 David Gilbert * source/org/jfree/chart/annotations/XYTextAnnotation.java (equals): Check x and y attributes (fixes bug 1415480). 2006-01-26 David Gilbert * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (drawItem): Check item label visible flag. 2006-01-26 David Gilbert * source/org/jfree/chart/ChartFactory.java (createScatterPlot): Corrected API documentation. 2006-01-23 David Gilbert * source/org/jfree/chart/renderer/category/LevelRenderer.java (getMaxItemWidth): Deprecated, (setMaxItemWidth): Likewise, (getMaximumItemWidth): New method, (setMaximumItemWidth): Likewise. 2006-01-18 David Gilbert * source/org/jfree/chart/renderer/category/GanttRenderer.java (GanttRenderer()): Set includeBaseInRange to false, * source/org/jfree/data/gantt/TaskSeriesCollection.java (getSeries(Comparable)): New method, (getSeries(int)): Likewise, * source/org/jfree/data/gantt/junit/TaskSeriesCollectionTests.java (testGetSeries): New tests. 2006-01-18 David Gilbert * source/org/jfree/chart/axis/NumberAxis3D.java (draw): Check plot is a CategoryPlot before casting (fixes bug 1408904). 2006-01-11 David Gilbert * source/org/jfree/chart/axis/CategoryAxis.java (drawCategoryLabels): Fixed null pointer exception (see bug report 1403043). 2006-01-11 David Gilbert * source/org/jfree/data/xy/XYSeries.java (update(int, Number)): Deprecated (renamed updateByIndex), (updateByIndex): New method, * NEWS: Updated API changes. 2006-01-11 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (includeBaseInRange): New flag, (BarRenderer): Initialise new flag, (getIncludeBaseInRange): New accessor method, (setIncludeBaseInRange): Likewise, (calculateBarL0L1): Simplified code to fix bug 1401856, (findRangeBounds): New override method, * source/org/jfree/chart/plot/CategoryPlot.java (rendererChanged): Call configureRangeAxes(), because the renderer can affect the axis range, * source/org/jfree/data/Range.java (combine): Reformatted, (expandToInclude): New method, (expand): Reformatted, (shift): Likewise, (shiftWithNoZeroCrossing): Added API docs. * source/org/jfree/chart/axis/junit/NumberAxisTests.java (testAutoRange2): Fixed failing test, (testAutoRange3): Likewise, * NEWS: Added recent updates. 2006-01-10 David Gilbert * source/org/jfree/chart/servlet/ServletUtilities.java: Updated API docs and reformatted source code. 2006-01-09 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (drawLabels): Changed code that checks ignoreNullValues and ignoreZeroValues flags, (getLegendItems): Increment section count even when section is ignored. Fixes bug 1400442. 2005-12-21 David Gilbert * source/org/jfree/chart/plot/SpiderWebPlot.java (SpiderWebPlot(CategoryDataset)): Delegate to another constructor, (SpiderWebPlot(CategoryDataset, TableOrder)): Copied code from previous constructor, (getPlotType): Updated description, (setInteriorGap): Reformatted, (draw): Likewise, (drawRadarPoly): Likewise, (drawLabel): Likewise. 2005-12-20 David Gilbert * source/org/jfree/chart/plot/RingPlot.java (drawItem): fix entity shape (bug 1386328). 2005-12-13 David Gilbert * source/org/jfree/data/time/TimeSeriesCollection.java (domainIsPointsInTime): Deprecated, no longer required, (getDomainIsPointsInTime): Likewise, (setDomainIsPointsInTime): Likewise, (getSeries): Reformatted, (removeAllSeries): Likewise, (getX): Likewise, (getStartX): Likewise, (getEndX): Likewise, (getDomainBounds): Don't use domainIsPointsInTime. 2005-12-13 David Gilbert * source/org/jfree/chart/labels/StandardXYZItemLabelGenerator.java: New class, * source/org/jfree/chart/labels/XYZItemLabelGenerator.java: New interface, * source/org/jfree/chart/renderer/AbstractRenderer.java: Reformatting, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java: Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (XYBubbleRenderer(int)): Check argument, (getScaleType): API docs, (drawItem): Added code to draw item labels, (getLegendItem): Reformatted. 2005-12-13 David Gilbert * source/org/jfree/chart/title/TextTitle.java (TextTitle(String)): Reformatted, (TextTitle(String, Font)): Reformatted, (arrange): Reformatted, (arrangeRR): Account for rotated title in left or right positions, fixes bug 1379331, (hashCode): Reformatted. 2005-12-10 David Gilbert * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java: Reformatted. 2005-12-10 David Gilbert * source/org/jfree/chart/LegendItem.java (attributedLabel): Made transient, (writeObject): Write out attributedLabel, (readObject): Read in attributedLabel, * source/org/jfree/chart/junit/LegendItemTests.java (testSerialization2): New test, * NEWS: Noted bug fix. 2005-12-10 David Gilbert * source/org/jfree/data/time/Quarter.java (Quarter(int, Year)): Fix bug (1377239) in argument checking, * source/org/jfree/data/time/junit/QuarterTests.java (testConstructor): New test, * NEWS: Noted bug fix. 2005-12-06 David Gilbert * NEWS: New file, * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Changed Color.BLACK to Color.black (fixes bug report 1374222). 2005-12-05 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java: Reformatted. ---------- JFREECHART 1.0.0 RELEASED ------------------------ 2005-12-02 David Gilbert * README.txt: Update for 1.0.0 release, * source/org/jfree/chart/resources/JFreeChartResources.java (CONTENTS): Updated version number. 2005-12-02 David Gilbert * source/org/jfree/chart/ChartPanel.java (chartChanged): Don't update domainZoomable and rangeZoomable. 2005-12-02 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java (drawItem): Access entity collection via convenience method, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java (drawItem): Likewise, * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Likewise. 2005-12-02 David Gilbert * source/org/jfree/chart/plot/PiePlot.java (drawItem): Access entity collection via convenience method, * source/org/jfree/chart/plot/RingPlot.java (drawItem): Likewise. 2005-12-02 David Gilbert * source/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.java (drawWithNullInfo): New test, * source/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java (drawWithNullInfo): New test, * source/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java (drawWithNullInfo): New test, * source/org/jfree/chart/renderer/xy/junit/XYStepAreaRendererTests.java (drawWithNullInfo): New test, * source/org/jfree/chart/renderer/xy/junit/XYStepRendererTests.java (drawWithNullInfo): New test. 2005-12-02 David Gilbert * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java: Reformatting, * source/org/jfree/chart/renderer/category/StatisticalLineAndShaperenderer.java (drawItem): Fixed null pointer exception, * source/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.java (testDrawWithNullInfo): New test, * source/org/jfree/chart/renderer/category/junit/StatisticalLineAndShapeRenderer.java (testDrawWithNullInfo): New test. 2005-12-02 David Gilbert * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java (drawItem): Fixed null pointer exception. 2005-12-02 David Gilbert * source/org/jfree/chart/renderer/category/LevelRenderer.java (drawItem): Fixed null pointer exception, * source/org/jfree/chart/renderer/category/junit/LevelRendererTests.java (testDrawWithNullInfo): New test. 2005-12-02 David Gilbert * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java (drawHorizontalItem): Fixed null pointer exception, (drawVerticalItem): Fixed null pointer exception, * source/org/jfree/chart/renderer/category/junit/LayeredBarRendererTests.java (testDrawWithNullInfo): New test. 2005-12-01 David Gilbert * source/org/jfree/data/time/TimeSeries.java (add(TimeSeriesDataItem)): Delegate to new method, (add(TimeSeriesDataItem, boolean)): New method, (add(RegularTimePeriod, double)): Delegate to new method, (add(RegularTimePeriod, double, boolean)): New method, (add(RegularTimePeriod, Double)): Delegate to new method, (add(RegularTimePeriod, Double, boolean)): New method. 2005-12-01 David Gilbert * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java (drawItem): Call getEntityCollection directly on 'state', * source/org/jfree/chart/renderer/category/junit/IntervalBarRendererTests.java (testDrawWithNullInfo): New test. 2005-12-01 David Gilbert * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java (drawItem): Call getEntityCollection directly on 'state', * source/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testDrawWithNullInfo): Construct chart properly, * source/org/jfree/chart/renderer/category/junit/GroupedStackedBarRendererTests.java (testDrawWithNullInfo): New test, * source/org/jfree/data/statistics/BoxAndWhiskerItem.java (getOutliers): Check for null list. 2005-12-01 David Gilbert * gjdoc/run-gjdoc: Updated version number, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawHorizontalItem): Fixed null pointer exception, (drawVerticalItem): Likewise, * source/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java (testDrawWithNullInfo): New test. 2005-12-01 David Gilbert * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Use drawBarOutline flag for legend graphic, * source/org/jfree/chart/renderer/category/GanttRenderer.java (drawTasks): Check drawBarOutline flag, (drawTask): Likewise. 2005-12-01 David Gilbert * ant/build.xml (initialise): Updated version number, * gjdoc/run-gjdoc: Updated package list, * source/org/jfree/chart/junit/GanttChartTests.java (testDrawWithNullInfo): Reformatted, (testDrawWithNullInfo2): New test, * source/org/jfree/chart/renderer/category/GanttRenderer.java (drawTasks): Fix NullPointerException, (drawTask): Likewise. 2005-11-30 David Gilbert * source/org/jfree/chart/renderer/xy/XYItemRenderer.java (getLegendItemLabelGenerator): Added method to interface, (setLegendItemLabelGenerator): Likewise. 2005-11-30 David Gilbert * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java (getAttributedLabel): Change argument name to 'section', (setAttributedLabel): Likewise. 2005-11-30 David Gilbert * source/org/jfree/chart/ChartFactory.java (createSignalChart): Removed, * source/org/jfree/chart/renderer/xy/SignalRenderer.java: Removed, * source/org/jfree/chart/renderer/xy/junit/SignalRendererTests.java: Removed, * source/org/jfree/data/general/SubSeriesDataset.java (getType): Removed, (getLevel): Removed, * source/org/jfree/data/xy/SignalsDataset.java: Removed. 2005-11-30 David Gilbert * source/org/jfree/chart/ChartRenderingInfo.java (plotArea): Removed, (ChartRenderingInfo(EntityCollection)): Updated for removed field, (getPlotArea): Removed, (setPlotArea): Removed, (clear): Updated for removed field, (equals): Likewise, (writeObject): Likewise, (readObject): Likewise, * source/org/jfree/chart/junit/ChartRenderingInfoTests.java (testEquals): Updated for removed field, (testSerialization): Likewise. 2005-11-28 David Gilbert * README.txt: Updated for 1.0.0-rc3 release, * ant/build.xml: Copy across Maven file. 2005-11-28 David Gilbert * source/org/jfree/chart/editor/ChartEditorFactory.java: New file, * source/org/jfree/chart/editor/ChartEditorManager.java (factory): New field, (getChartEditorFactory): New method, (setChartEditorFactory): New method, (getChartEditor): Updated to use factory. 2005-11-28 David Gilbert * source/org/jfree/data/time/TimeSeries.java (maximumItemAge): Changed type from int to long, (TimeSeries(String, String, String, Class)): Change initialisation of maximumItemAge field, (getMaximumItemAge): Changed return type to long, (setMaximumItemAge): Changed argument type to long. 2005-11-28 David Gilbert * source/org/jfree/chart/LegendItem.java: (LegendItem(String, AttributedString, String, String, String, Shape, Paint)): Removed AttributedString argument, (LegendItem(String, AttributedString, String, String, String, Shape, Paint, Stroke, Paint)): Likewise, (LegendItem(String, AttributedString, String, String, String, Shape, Stroke, Paint)): Likewise, (LegendItem(String, AttributedString, String, String, String, boolean, Shape, boolean, Paint, boolean, Paint, Stroke, boolean, Shape, Stroke, Paint)): Likewise, (LegendItem(AttributedString, String, String, String, Shape, Paint)): New constructor, (LegendItem(AttributedString, String, String, String, Shape, Paint, Stroke, Paint)): Likewise, (LegendItem(AttributedString, String, String, String, Shape, Stroke, Paint)): Likewise, (LegendItem(AttributedString, String, String, String, boolean, Shape, boolean, Paint, boolean, Paint, Stroke, boolean, Shape, Stroke, Paint)): Likewise, (characterIteratorToString): New method, * source/org/jfree/chart/junit/LegendItemCollectionTests.java (testEquals): Updated for change to LegendItem constructor, (testSerialization): Likewise, (testCloning): Likewise, * source/org/jfree/chart/junit/LegendItemTests.java (testEquals): Updated for change to LegendItem constructor, (testSerialization): Likewise, (testCloning): Likewise, * source/org/jfree/chart/plot/MeterPlot.java (getLegendItems): Update for change to LegendItem constructor, * source/org/jfree/chart/plot/MultiplePiePlot.java (getLegendItems): Likewise, * source/org/jfree/chart/plot/PiePlot.java (getLegendItems): Likewise, * source/org/jfree/chart/plot/SpiderWebPlot.java (getLegendItems): Likewise, * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/WaferMapRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/AreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (getLegendItem): Likewise. 2005-11-28 David Gilbert * ant/build.xml (initialise): Update JFreeChart version number, (compile): Copy over property files in org.jfree.chart.editor, * source/org/jfree/chart/resources/JFreeChartResources.java (CONTENTS): Updated JFreeChart version number. 2005-11-25 David Gilbert * source/org/jfree/chart/ChartMouseListener.java: Now extends EventListener, * source/org/jfree/chart/ChartPanel.java (chartMouseListeners): Use EventListenerList, (ChartPanel(JFreeChart, int, int, int, int, int, int, boolean, boolean, boolean, boolean, boolean, boolean)): Initialise chartMouseListeners, (mouseClicked): Use EventListenerList, (mouseMoved): Likewise, (addChartMouseListener): Likewise, (removeChartMouseListener): Likewise, (getListeners): New override, * source/org/jfree/chart/junit/ChartPanelTests.java: (testGetListeners): New test, (chartMouseClicked): New method, (chartMouseMoved): New method. 2005-11-24 David Gilbert * source/org/jfree/chart/ChartPanel.java (attemptEditChartProperties): Use ChartEditorManager to get ChartEditor, * source/org/jfree/chart/axis/ColorBar.java: Update imports for moved classes, * source/org/jfree/chart/axis/junit/ColorBarTests.java: Likewise, * source/org/jfree/chart/editor/ChartEditor.java: New file, * source/org/jfree/chart/editor/ChartEditorManager.java: New file, * source/org/jfree/chart/editor/DefaultAxisEditor.java: New file, * source/org/jfree/chart/editor/DefaultChartEditor.java: New file, * source/org/jfree/chart/editor/DefaultColorBarEditor.java: New file, * source/org/jfree/chart/editor/DefaultNumberAxisEditor.java: New file, * source/org/jfree/chart/editor/DefaultPlotEditor.java: New file, * source/org/jfree/chart/editor/DefaultTitleEditor.java: New file, * source/org/jfree/chart/editor/PaletteChooserPanel.java: New file, * source/org/jfree/chart/editor/PaletteSample.java: New file, * source/org/jfree/chart/editor/LocalizationBundle_de.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_es.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_fr.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_nl.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_pl.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_pt_PT.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_ru.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle_zh_CN.properties: Moved, * source/org/jfree/chart/editor/LocalizationBundle.properties: Moved, * source/org/jfree/chart/editor/package.html: New file, * source/org/jfree/chart/junit/JFreeChartTestSuite.java: (suite): Removed ChartUIPackageTests, * source/org/jfree/chart/plot/ColorPalette.java: Moved, * source/org/jfree/chart/plot/GreyPalette.java: Moved, * source/org/jfree/chart/plot/RainbowPalette.java: Moved, * source/org/jfree/chart/plot/junit/ColorPaletteTests.java: Moved, * source/org/jfree/chart/plot/junit/PlotPackageTests.java (suite): Added ColorPaletteTests, * source/org/jfree/chart/ui/*: Removed package, most classes moved to org.jfree.chart.editor and renamed, * source/org/jfree/chart/ui/junit/*: Removed package. 2005-11-24 David Gilbert * source/org/jfree/chart/encoders/KeypointPNGEncoderAdapter.java: Updated API docs. 2005-11-24 David Gilbert * source/org/jfree/chart/ChartFactory.java (createHistogram): Set autoRangeIncludesZero to false on domain axis. 2005-11-24 David Gilbert * ant/build.xml: Updated version numbers. 2005-11-24 David Gilbert * source/org/jfree/chart/DefaultOldLegend.java: Removed, * source/org/jfree/chart/JFreeChart.java (oldLegend): Removed, (getOldLegend): Removed, (setOldLegend): Removed, (draw(Graphics2D, Rectangle2D, Point2D, ChartRenderingInfo)): Removed old legend drawing code, (legendChanged): Removed, (equals): Removed old legend check, (readObject): Removed code to add listener to old legend, (clone): Removed code to clone old legend, * source/org/jfree/chart/OldLegend.java: Removed, * source/org/jfree/chart/event/LegendChangeEvent.java: Removed, * source/org/jfree/chart/event/LegendChangeListener.java: Removed, * source/org/jfree/chart/junit/JFreeChartTests.java (testEquals): Removed old legend check, * source/org/jfree/chart/ui/ChartPropertyEditPanel.java (legendPropertiesPanel): Removed, (ChartPropertyEditPanel(JFreeChart)): Removed old legend setup, (getLegendPropertyEditPanel): Removed, (updateChartProperties): Removed old legend update, * source/org/jfree/chart/ui/LegendPropertyEditPanel.java: Removed. 2005-11-23 David Gilbert * source/org/jfree/chart/JFreeChart.java (JFreeChartInfo): Added Pady Srinivasan to contributors, * source/org/jfree/chart/axis/CategoryAxis.java: Added Pady Srinivasan as Contributor. 2005-11-23 David Gilbert These changes are based on patch 1217634 by Pady Srinivasan (with significant modifications). * source/org/jfree/chart/axis/CategoryAxis.java (tickLabelFontMap): New field, (tickLabelPaintMap): New field, (CategoryAxis(String)): Initialise new fields, (getTickLabelFont(Comparable)): New method, (setTickLabelFont(Comparable, Font)): New method, (getTickLabelPaint(Comparable)): New method, (setTickLabelPaint(Comparable, Paint)): New method, (getCategoryLabelToolTip): New method, (drawCategoryLabels): Use new methods to get label font and paint, and also tooltip, (refreshTicks): Reformatted, (createLabel): Use new methods to get label font and paint, (clone): Handle new fields, (equals): Likewise, (readObject): Likewise, (writeObject): Likewise, (readPaintMap): New method, (writePaintMap): New method, (equalPaintMaps): New method, * source/org/jfree/chart/axis/junit/CategoryAxisTests.java (testEquals): Add tests for new fields, (testCloning2): New test, (testSerialization): Strengthened test. 2005-11-22 David Gilbert * source/org/jfree/chart/LocalisationBundle_de.properties: Minor correction (see patch 1315259), * source/org/jfree/chart/ui/LocalisationBundle_de.properties: Corrections and additions (see patch 1315258). 2005-11-22 David Gilbert * source/org/jfree/data/statistics/HistogramDataset.java (getSeriesKey): Cast return value to Comparable. 2005-11-21 David Gilbert * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java (calculateBarWidth): Remove itemMargin from calculation, (drawItem): Reformatted, (drawHorizontalItem): Added support for GradientPaint, (drawVerticalItem): Likewise. 2005-11-21 David Gilbert * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (setDrawSeriesLineAsPath): Send RendererChangeEvent if flag changes. 2005-11-21 David Gilbert * source/org/jfree/data/function/NormalDistributionFunction2D.java (getMean): New method, (getStandardDeviation): New method, (getValue): Reformatted. 2005-11-17 David Gilbert * source/org/jfree/data/time/TimeSeries.java (historyCount): Renamed maximumItemAge, (TimeSeries(String, String, String, Class)): Update for renamed field, (getMaximumItemCount): API doc update, (setMaximumItemCount): Added argument check, and remove surplus items in a way that fires a SeriesChangeEvent, (getHistoryCount): Renamed getMaximumItemAge(), (setHistoryCount): Renamed setMaximumItemAge() and reimplemented, (add(TimeSeriesDataItem)): Update for refactored method, (addOrUpdate(RegularTimePeriod, Number)): Likewise, (ageHistoryCountItems): Renamed removeAgedItems and amended to generate change notification if requested, (ageHistoryCountItems(long)): Likewise, (equals): Updates for renamed method, (hashCode): Likewise. * source/org/jfree/data/time/junit/TimeSeriesTests.java (testEquals): Updated for renamed field. 2005-11-17 David Gilbert * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java (minValue): Removed, (maxValue): Removed, (isDrawLines): Updated API docs, (setDrawLines): Send RendererChangeEvent, (getGroupPaint): Updated API docs, (setGroupPaint): Check for null argument, send change event, (setGroupStroke): Likewise, (getObjectIcon): Updated API docs, (setObjectIcon): Check for null argument, send change event, (getMaxIcon): Updated API docs, (setMaxIcon): Check for null argument, send change event, (getMinIcon): Updated API docs, (setMinIcon): Check for null argument, send change event, (drawItem): Refactored (for removed fields). 2005-11-16 David Gilbert * source/org/jfree/data/statistics/HistogramDataset.java (addSeries): Handle case where data value is smaller than the lower bound of the bin range. 2005-11-15 David Gilbert * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java: Reformatted and reordered methods. 2005-11-10 David Gilbert * source/org/jfree/chart/plot/MeterPlot.java (tickSize): New field, (tickPaint): New field, (tickLabelPaint): New field, (MeterPlot(ValueDataset)): Initialise new fields, (getTickSize): New method, (setTickSize): New method, (getTickPaint): New method, (setTickPaint): New method, (getTickLabelPaint): New method, (setTickLabelPaint): New method, (getLegendItems): Use background color for each interval, (draw): Call new drawValueLabel() method, (drawArcForInterval): Updated for refactored methods, (fillArc): Changed from private to protected, (drawTicks): Make use of new tickSize field, (drawTick(Graphics2D, Rectangle2D, double)): Updated for refactored methods, (drawTick(Graphics2D, Rectangle2D, double, boolean, Paint, boolean, String)): Removed special case code for drawing the value label, and the now redundant parameters, replaced with drawValueLabel(), (drawValueLabel): New method, (equals): Updated for new fields. 2005-11-03 David Gilbert * source/org/jfree/chart/ChartColor.java (createDefaultPaintArray): removed orange color, fix for bug 1328408). 2005-11-02 David Gilbert * source/org/jfree/data/time/Month.java (Month(int, Year)): changed '&&' to '||' in argument check, fixes bug 1345383. 2005-11-02 David Gilbert * source/org/jfree/chart/ChartRenderingInfo.java (equals): updated to include plotArea and plotInfo, * source/org/jfree/chart/junit/ChartRenderingInfoTests.java (testEquals): expanded to test all fields, (testSerialization): changed initialisation of object to be serialized, (testSerialization2): new test, * source/org/jfree/chart/plot/PlotRenderingInfo.java (owner): removed transient keyword. 2005-11-01 David Gilbert * source/org/jfree/chart/title/ImageTitle.java (height): removed field, (width): removed field, (ImageTitle(Image, int, int, RectangleEdge, HorizontalAlignment, VerticalAlignment, RectangleInsets)): set width and height for block, (drawHorizontal): use block width and height, (drawVertical): use block width and height, * source/org/jfree/chart/title/junit/ImageTitleTests.java (testWidthAndHeight): new method. 2005-11-01 David Gilbert * ant/build.xml: exclude SunJPEGEncoderAdapter.java from the build if ImageIO is not present, * source/org/jfree/chart/encoders/ImageEncoderFactory.java (init): only add 'jpeg' encoder if JFreeChart was compiled, and is being run, with JDK 1.4 or later, * source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java (encode): use ImageIO, not com.sun.* classes. 2005-11-01 David Gilbert * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (openTickPaint): new field, (closeTickPaint): new field, (getOpenTickPaint): new method, (setOpenTickPaint): new method, (getCloseTickPaint): new method, (setCloseTickPaint): new method, (drawItem): use openTickPaint and closeTickPaint if non-null, (equals): implemented, (readObject): new method to support serialization, (writeObject): new method to support serialization, * source/org/jfree/chart/renderer/xy/junit/HighLowRendererTests.java (testEquals): add checks for all fields, (testCloning): updated for new fields, (testSerialization): updated for new fields. 2005-11-01 David Gilbert * source/org/jfree/chart/renderer/xy/HighLow.java: Removed unused class. 2005-10-27 David Gilbert * source/org/jfree/data/general/junit/DatasetUtilities.java (testIterateXYRangeBounds2): added API doc comment. 2005-10-25 David Gilbert * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java (getCategory): removed, (getItem): removed, (getSeries(Object)): changed signature to accept Comparable, (getSeries(int): removed, (getValue(Comparable, Comparable)): call getColumnIndex() instead of getItem(), (getStartValue(Comparable, Comparable)): likewise, (getEndValue(Comparable, Comparable)): likewise, (setStartValue(int, Object, Number)): changed signature to (int, Comparable, Number), (setEndValue(int, Object, Number)): likewise, (getCategoryIndex(Object)): changed signature to (Comparable), (getColumnKey(int)): changed argument name, (getRowKey(int)): likewise. 2005-10-25 David Gilbert * source/org/jfree/chart/resources/JFreeChartResources.java (CONTENTS): updated 'project.version'. 2005-10-25 David Gilbert * source/org/jfree/chart/plot/Marker.java (Marker(Paint, Stroke, Paint, Stroke, float)): changed from public to protected. 2005-10-25 David Gilbert * source/org/jfree/chart/plot/PolarPlot.java: now implements Zoomable interface, (PolarPlot(XYDataset, ValueAxis, PolarItemRenderer)): reformatted, (addCornerTextItem): check for null argument, generate PlotChangeEvent, (removeCornerTextItem): generate PlotChangeEvent if necessary, (clearCornerTextItem): renamed clearCornerTextItems(), and generates PlotChangeEvent if necessary, (setAngleLabelsVisible): only send PlotChangeEvent if flag changes, (drawCornerTextItems): changed from public to protected, (render): likewise, (zoomDomainAxes(double, double, double)): changed signature and now implementation does nothing, (zoomDomainAxes(double, double, double, double)): likewise, (zoomRangeAxes(double, double, double)): changed signature to match Zoomable interface, (zoomRangeAxes(double, double, double, double)): likewise, (isDomainZoomable): now returns false, (getOrientation): new method, * source/org/jfree/chart/renderer/PolarItemRenderer.java (drawRadialGridLines): removed commented out code. 2005-10-25 David Gilbert * source/org/jfree/chart/axis/TickUnits.java (getCeilingTickUnit): don't pass null to other method. 2005-10-14 David Gilbert * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (drawItem): fixed bar coordinates to work with inverted axes. 2005-10-14 David Gilbert * source/org/jfree/chart/ChartPanel.java (chartChanged): update plot orientation, it may have changed. 2005-10-07 David Gilbert * source/org/jfree/chart/title/TextTitle.java (textAlignment): new field, (TextTitle): initialise new field, (getTextAlignment): new method, (setTextAlignment): new method, (equals): include textAlignment in test, * source/org/jfree/chart/title/junit/TextTitleTests.java (testEquals): updated to include textAlignment. 2005-10-06 David Gilbert * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java (drawItem): removed setPaint() call. 2005-10-06 David Gilbert * source/org/jfree/data/junit/DefaultKeyedValues2DTests.java (testEquals): New method, * source/org/jfree/data/xy/CategoryTableXYDataset.java (CategoryTableXYDataset): register interval delegate as a listener, (add(Number, Number, String, boolean)): remove call to itemAdded, (remove(Number, String, boolean)): remove call to itemRemoved, (getDomainBounds): only pass to delegate if the interval is included, (setIntervalWidth): update for renamed method, (equals): implemented, * source/org/jfree/data/xy/DefaultTableXYDataset.java (DefaultTableXYDataset(boolean)): register interval delegate as a listener, (removeAllSeries): remove class to seriesRemoved, (removeSeries(XYSeries)): likewise, (removeSeries(int)): likewise, (removeAllValuesForX): likewise, (getDomainBounds): only pass to delegate if the interval is included, (setIntervalWidth): update for renamed method, * source/org/jfree/data/xy/IntervalXYDelegate.java: now implements DatasetChangeListener, (intervalWidth): renamed fixedIntervalWidth, (lowerBound): removed, (upperBound): removed, (IntervalXYDelegate(XYDataset, boolean)): added check for null dataset, updated for renamed field, (setAutoWidth): if true, recalculate interval width, (getFixedIntervalWidth): new method, (setIntervalWidth): renamed setFixedIntervalWidth(), now sets autoWidth to false, (getIntervalWidth): updated for renamed field, (getEndXValue): new method, (getDomainBounds): reimplemented, (datasetChanged): new method, recalculates auto interval width, (itemAdded): removed, (itemRemoved): removed, (recalculateIntervalWidth): new implementation, renamed recalculateInterval(), (calculateSeries): renamed calculateIntervalForSeries(), new implementation, (seriesAdded): removed, (seriesRemoved): removed, (equals): updated for renamed field, * source/org/jfree/data/xy/XYSeriesCollection.java (XYSeriesCollection(XYSeries)): register interval delegate as a listener, (addSeries): removed call to seriesAdded(), (removeSeries(int)): removed call to seriesRemoved(), (removeSeries(XYSeries)): likewise, (removeAllSeries): likewise, (getDomainBounds): only pass to delegate if the interval is included, (setIntervalWidth): updated for renamed method, * source/org/jfree/data/xy/junit/CategoryTableXYDatasetTests.java: new tests, * source/org/jfree/data/xy/junit/DataXYPackageTests.java (suite): added CategoryTableXYDatsaetTests.class), * source/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java (testAddSeries): new test method, * source/org/jfree/data/xy/junit/IntervalXYDelegateTests.java (testEquals): updated for method name change. 2005-10-03 David Gilbert * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java (drawItem): add an entity to the collection if supplied. 2005-10-03 David Gilbert * source/org/jfree/chart/JFreeChart.java (drawTitle): check for positive area width and height, otherwise return null (fixes bug 1306022). 2005-09-30 David Gilbert * source/org/jfree/chart/renderer/category/StackedBarRenderer.java (drawItem): use item outline stroke, not regular stroke. For changes prior to 30-Sep-2005, please refer to the file CHANGELOG.txt. libjfreechart-java-1.0.13.orig/NEWS0000644000175000017500000007315511173030414016660 0ustar vincentvincentJFreeChart 1.0.13 ----------------- 20 April 2009 ****************************************************************************** * SPECIAL NOTICE: There will be a birds-of-a-feather session for JFreeChart * * at this year's JavaOne conference in San Francisco. The session is * * scheduled for 6.45pm to 7.35pm on Wednesday 3 June. * ****************************************************************************** This release contains: - updates to the ChartPanel class to support copying charts to the clipboard, panning and mouse-wheel zooming, and an overlay mechanism that supports crosshairs; - enhancements to the auto-range calculation for axes, providing the ability to use subranges only and also to skip hidden series; - updates for many of the CategoryItemRenderer implementations to ensure that they respect the 'seriesVisible' flags; - an improvement to the TimeSeries class so that it is no longer necessary to specify the time period type in the constructor; - a new SamplingXYLineRenderer for improving the performance of time series charts with large datasets; - the XYSeries/XYSeriesCollection classes now cache the minimum and maximum data values to improve the performance of charts with large datasets; - entities are now created for the chart, data area and axes, allowing mouse clicks to be detected for these regions; - added a bar alignment factor to the XYBarRenderer class; - a new 'errorIndicatorStroke' field for the StatisticalLineAndShapeRenderer and XYErrorRenderer classes; - added a new HeatMapDataset interface, DefaultHeatMapDataset implementation, and a HeatMapUtilities class to make it easier to create heat map charts; - there is a new flag to allow an XYDataImageAnnotation to be included in the automatic range calculation for the axes; - additional attributes in the XYTextAnnotation class; - added a sampleFunction2DToSeries() method to the DatasetUtilities class; - some changes to the ChartPanel class that help to work around a regression in JRE 1.6.0_10 relating to drawing in XOR mode. Regarding this final point: * the default value for the useBuffer flag has changed to true, which means that all charts will, by default, be rendered into an off-screen image before being displayed in the ChartPanel; * the zoom rectangle is drawn using XOR mode *only* when the useBuffer flag has been set to false. For most usage, this should improve performance (but at the cost of using more memory for each ChartPanel used in your application); Bug Fixes: 2690293 : Problem with Javascript escape characters; 2617557 : StandardDialScale ignored tickLabelPaint; 2612649 : Stroke selection in plot property editor; 2583891 : SWTGraphics2D.fillPolygon() not implemented; 2564636 : Month constructor ignores Locale; 2502355 : ChartPanel sending multiple events; 2490803 : PeriodAxis.setRange() method doesn't take into account that the axis displays whole periods; In addition, a bug in the SlidingCategoryDataset class has been fixed, the correct outline paint is now used by GradientXYBarPainter, a new method has been added to the ImageMapUtilities class to escape special characters in Javascript strings to avoid problems with the OverLIB and DynamicDrive tooltips, and there are some important fixes in the LogAxis class. This release passes 2110 JUnit tests (0 failures) on JRE 1.6.0_12. JFreeChart 1.0.12 ----------------- 31 December 2008 This release adds support for minor tick marks, mapping datasets to more than one axis, an important fix for the XYSeries class (relating to the addOrUpdate() method) plus numerous other bug fixes. This release passes 1996 JUnit test (0 failures) on JRE 1.6.0_10. API Adjustments: - CategoryPlot : added mapDatasetToDomainAxes() and mapDatasetToRangeAxes() methods; - Month : added a new constructor Month(Date, TimeZone, Locale) and deprecated Month(Date, TimeZone); - Quarter : added a new constructor Quarter(Date, TimeZone, Locale) and deprecated Quarter(Date, TimeZone); - XYPlot : added mapDatasetToDomainAxes() and mapDatasetToRangeAxes() methods; - Year : added a new constructor Year(Date, TimeZone, Locale) and deprecated Year(Date, TimeZone); Bug Fixes: 2471906 : XYAreaRenderer with dashed outline - performance problem; 2452078 : StackedAreaChart has gaps; 2275695 : NullPointerException for SubCategoryAxis on plot with null dataset; 2221495 : XYLineAnnotation with dashed stroke; 2216511 : SWTBarChartDemo1 throws RuntimeException; 2201869 : DateAxis tick label position error; 2121818 : Label link lines for very thin RingPlot; 2113627 : XYStepRenderer item labels; 1955483 : XYSeries.addOrUpdate() problem. Also fixed StackedXYBarRenderer which was ignoring the shadowsVisible attribute. JFreeChart 1.0.11 ----------------- 19 September 2008 This release features a new chart theming mechanism to allow charts to be restyled conveniently, a new BarPainter mechanism to enhance the appearance of bar charts, a new XYShapeRenderer class, a scaling facility for the XYDrawableAnnotation for drawing images within specific data coordinates, some new classes (XYTaskDataset, XYDataImageAnnotation and XYTitleAnnotation), a modification to the Year class to support an extended range, and various bug fixes and API improvements. There is an important bug fix for the StackedBarRenderer3D class (see bug 2031407). This release passes 1,961 JUnit tests (0 failures) on JRE 1.6.0_07. API Adjustments: - AbstractRenderer - added clearSeriesPaints() and clearSeriesStrokes() methods; - BarRenderer - added shadowPaint attribute; - CategoryAxis - added getCategoryMiddle() method; - CategoryPlot - added getRendererCount() method; - ChartFactory - added get/setChartTheme() methods; - ChartPanel - increased default maximum drawing width and height; - ChartTheme - new interface; - ChartUtilities - added applyCurrentTheme() method; - CompositeTitle - added backgroundPaint attribute; - GradientBarPainter - new class; - LegendTitle - added getWrapper() method; - OHLCSeriesCollection - added xPosition attribute; - PaintScaleLegend - new subdivisions field; - PiePlot - added autoPopulate flags, and methods to clear section attributes; - Plot - added setDrawingSupplier() method; - RegularTimePeriod - the DEFAULT_TIME_ZONE field has been deprecated in this release; - RelativeDateFormat - added methods to control formatting of hours and minutes - see patch 2033092; - StandardChartTheme - new class; - XYItemRendererState - new methods; - XYPlot - added getRendererCount() method; - XYShapeRenderer - new class; - XYTaskDataset - new class. Patches: 1997549 : Status calls to XYItemRendererState [Ulrich Voigt]; 2006826 : CompositeTitle drawing fix; 2033092 : Additional formatters for RelativeDateFormat [Cole Markham]; Bug Fixes: 1994355 : ChartComposite listener type; 2031407 : Incorrect rendering in StackedBarRenderer3D; 2033721 : WaferMapRenderer; 2051168 : No key in LegendItemEntity for pie charts; Also fixed drawing of alternate grid bands in SymbolAxis, the totalWeight calculation in the CombinedXXXPlot classes, a NullPointerException in the XYPlot class when drawing quadrants, outline visibility in the CategoryPlot class, and auto-range calculations with XYBarRenderer. JFreeChart 1.0.10 ----------------- 9 June 2008 This release contains various bug fixes and minor enhancements to JFreeChart. PiePlot labelling has been enhanced (new curve options, and more robust bounds checking). The BoxAndWhiskerRenderer now has a maximumBarWidth attribute, the XYStepRenderer has a new stepPoint attribute. The RelativeDateFormat class has new options. There are new dataset classes (SlidingCategoryDataset and SlidingGanttDataset) that permit a subset of categories to be plotted, and allow charts based on these datasets to simulate scrolling. There is a new ShortTextTitle class. This release passes 1,929 JUnit tests (0 failures) on JRE 1.6.0_03. API Adjustments: - BoxAndWhiskerRenderer - added maximumBarWidth attribute (see patch 1866446); - ChartPanel - the zoomPoint attribute has been changed from Point to Point2D; - DatasetUtilities - iterateCategoryRangeBounds() is deprecated, the method has been renamed iterateRangeBounds(CategoryDataset) for consistency; - DefaultKeyedValue - the constructor now prevents a null key; - LogFormat - now has a 'powerLabel' attribute; - ShortTextTitle - a new title class; - SlidingCategoryDataset - new class; - SlidingGanttDataset - new class; - TimeSeriesCollection - getSeries(String) changed to getSeries(Comparable); - XIntervalSeriesCollection - added series removal methods; - YIntervalSeriesCollection - added series removal methods; - XYIntervalSeriesCollection - added series removal methods; PublicCloneable is now implemented by a number of classes that didn't previously implement the interface - this should improve the reliability of chart cloning. Patches: 1943021 : Fix for MultiplePiePlot [Brian Cabana]; 1925366 : Speed improvement for DatasetUtilities [Rafal Skalny]; 1918209 : LogAxis createTickLabel() changed from private to protected [Andrew Mickish]; 1914411 : Simplification of plot event notification [Richard West]; 1913751 : XYPlot and CategoryPlot addMarker() methods with optional notification [Richard West]; 1902418 : Bug fix for LogAxis vertical labels [Andrew Mickish]; 1901599 : Fixes for XYTitleAnnotation [Andrew Mickish]; 1891849 : New curve option for pie chart label links [Martin Hilpert]; 1874890 : Added step point to XYStepRenderer [Ulrich Voigt]; 1873328 : Enhancements to RelativeDateFormat [Michael Siemer]; 1871902 : PolarPlot now has angleTickUnit attribute [Martin Hoeller]; 1868745 : Fix label anchor points on LogAxis [Andrew Mickish]; 1866446 : Added maximumBarWidth to BoxAndWhiskerRenderer [Rob Van der Sanden]; Bug Fixes: 1932146 - PeriodAxis.setRange() doesn't notify listeners; 1927239 - Fix calculation of cumulative range; 1926517 - Bugs in data range calculation for combined plots; 1920854 - PiePlot3D labels drawn multiple times; 1897580 - Fix for DefaultIntervalCategoryDataset; 1892419 - Wrong default for minor tick count in LogAxis; 1880114 - VectorRenderer doesn't work for horizontal plot orientation; 1873160 - DialPlot clipping issues; 1868521 - Problem saving charts to JPEG format; 1864222 - Error on TimeSeries createCopy() method; The DatasetUtilities.sampleFunction2D() has been changed to sample the correct number of points - you should check any code that calls this method. The XYBlockRenderer class now generates entities. Bugs in the removeDomainMarker() and removeRangeMarker() methods in the CategoryPlot and XYPlot classes have been fixed. A bug in the TimePeriodValues range calculation has been fixed. Fixes were applied to the clone() methods in the TaskSeries and TaskSeriesCollection classes. New Experimental Features: Two new classes CombinedCategoryPlot and CombinedXYPlot have been added to the 'experimental' source tree - these were contributed by Richard West (see patch 1924543). JFreeChart 1.0.9 ---------------- 4 January 2008 This release contains an important security patch as well as various bug fixes and minor enhancements. Regarding the security patch, please see the following advisory: http://www.rapid7.com/advisories/R7-0031.jsp Note that the fix incorporated in the special JFreeChart 1.0.8a release was flawed in that it broke the URLs in the HTML image maps generated by JFreeChart. Further amendments have been made in this release to fix this problem. API Adjustments: A number of classes have new methods. Nothing has been removed or deprecated: - HashUtilities - added hashCode() methods for BooleanList, PaintList and StrokeList; - ImageMapUtilities - added htmlEscape(String); - IntervalMarker - added new constructor; - Range - added intersects(Range) and scale(Range, double); - TextTitle - added protected methods arrangeNN(), arrangeFN() and arrangeRN(); - XYDataItem - added getXValue() and getYValue() methods; - XYPlot - added setFixedDomainAxisSpace(AxisSpace, boolean) and setFixedRangeAxisSpace(AxisSpace, boolean); - XYSeriesCollection - added getSeries(Comparable) method. Bug Fixes: 1852525 - CandlestickChart.getCategoryPlot() - ClassCastException; 1851416 - testGetFirstMillisecondWithTimeZone fails in 1.0.8a; 1849333 - 1.0.8a breaks URLs in HTML image maps; 1848961 - GroupedStackedBarRenderer works only for primary dataset; 1846063 - Endless loop in paint of XYPlot; 1840139 - Cross-site scripting vulnerabilities in image map code; 1837979 - Background image not shown with SWT; 1460195 - ChartEntity.getImageMapAreaTag() needs nohref; 1400917 - OverLIBToolTipTagFragmentGenerator not escaping single quote; 1363043 - Escape Image Map Data; 1178601 - AbstractRenderer.hashcode() method returns the same value; In addition, a bug in the constructor for the Week class has been fixed. JFreeChart 1.0.8 ---------------- 23 November 2007 This release is primarily a bug fix release, correcting a problem with pie chart labelling, a regression in the DefaultCategoryDataset class (and underlying KeyedValues2D class), and a cloning bug in the TimeSeries class. In addition, the StatisticalBarRenderer class has a new 'errorIndicatorStroke' field and has been updated to support gradients, the StandardDialScale has had some missing accessor methods implemented, and an override field in the StandardXYItemRenderer class has been deprecated. Plus some warnings reported by FindBugs 1.3.0 have been addressed. JFreeChart 1.0.7 ---------------- 14 November 2007 This release features new classes DialPlot and LogAxis (previously in experimental), initial support for minor tick units, a new anchored zooming option for the ChartPanel class, optional simple labelling on pie charts, improvements to the "statistical" datasets and underlying data structures, and numerous bug fixes. API Adjustments: - CategoryAxis - added getCategorySeriesMiddle() method; - CategoryPlot - added methods to remove markers; - ChartPanel - added defaultDirectorForSaveAs attribute; - DialPlot - new class, an alternative to MeterPlot; - LogAxis - new class, an alternative to LogarithmicAxis; - NumberTick - new constructor that allows specification of the tick type; - NumberTickUnit - new constructor to specify the minor tick count; - SymbolAxis - new methods get/setGridBandAlternatePaint(); - TickType - new class; - TickUnit - added minorTickCount attribute; - ValueTick - added tickType attribute; - StandardPieSectionLabelGenerator - new constructors accepting a Locale; - StandardPieToolTipGenerator - likewise; - CategoryPlot - added getRangeAxisIndex(), zoomDomainAxes() and zoomRangeAxes() methods; - FastScatterPlot - added new zooming methods; - PiePlot - new attributes to support simple labelling; - PlotUtilities - new class; - PolarPlot - added new zooming methods; - ThermometerPlot - likewise; - XYPlot - added methods to remove markers (patch 1823697--same as for CategoryPlot), and added new zooming methods; - Zoomable - added new zooming methods to this interface; - LineAndShapeRenderer - added useSeriesOffset and itemMargin attributes; - MinMaxCategoryRenderer - implemented equals(); - XYSplineAndShapeRenderer - new class; - LogFormat - new class; - ChartFactory - new pie and ring chart creation methods that accept a Locale; - ChartPanel - added zoomAroundAnchor attribute; - Series - added isEmpty() method; - BoxAndWhiskerItem - new convenience constructor; - DefaultBoxAndWhiskerCategoryDataset - new remove methods; - DefaultStatisticalCategoryDataset - likewise; - MeanAndStandardDeviation - added new value accessor methods; - TimeTableXYDataset - added clear() method; - Week - added new constructor; - KeyedObjects - added insertValue() and clear() methods; - KeyedObjects2D - added clear() method. Patches: 1823724 - updated XYDifferenceRenderer to support item labels; 1827829 - fixed possible NullPointerException in XYBarRenderer; Bug Fixes: 1767315 - GrayPaintScale.getPaint() uses wrong value; 1775452 - Inverted XYBarRenderer does not render margins correctly; 1802195 - Marker.listenerList serializable; 1779941 - StatisticalBarRenderer NPE; 1766646 - XYBlockRenderer can't handle empty datasets; 1763413 - PeriodAxis labels fail to display with setInverted 1737953 - Zoom doesn't work on LogAxis(Demo1) 1749124 - JFreeChart not added as TitleChangeListener JFreeChart 1.0.6 ---------------- 15 June 2007 This release features a new VectorRenderer (previously in experimental), a generalised XYDifferenceRenderer, better support for hotspots on legend items, improved performance for time series charts displaying subsets of data, support for GradientPaint in plot backgrounds, plus the usual slew of bug fixes and minor feature additions. API Adjustments: - CategoryItemEntity - replaced row and column index attributes with row and column key attributes; - CategoryItemRenderer - numerous series override settings have been deprecated; - DefaultPieDataset - added insertValues() method; - HexNumberFormat - new class; - LegendItem - added dataset and seriesKey attributes; - Plot - added new fillBackground() method to support GradientPaint, and added is/setOutlineVisible() methods; - QuarterDateFormat - added GREEK_QUARTERS field plus a new constructor; - SimpleHistogramDataset - added clearObservations() and removeAllBins() methods; - TimeSeriesCollection - added indexOf() method; - URLUtilities - new class; - XYItemRenderer - numerous series override settings have been deprecated; - XYSeriesCollection - added indexOf() method. Bug Fixes: 1735508 - ClusteredXYBarRenderer fails with inverted x-axis; 1726404 - ChartComposite tooltips; 1713474 - StackedBarRenderer3D doesn't fill shadows; 1713401 - StackedBarRenderer3D doesn't check drawBarOutline flag; 1701822 - DefaultBoxAndWhiskerCategoryDataset doesn't follow contracts; 1698965 - NPE in CombinedDomainXYPlot; 1690994 - HideSeriesDemo1 does not work; 1690654 - Bug in removeValue() of DefaultKeyedValues2D; 1562701 - LegendItemEntity needs dataset index; 1486299 - Use URLEncoder.encode() for URL generators; Plus the following bugs that didn't have entries in the database: - BarRenderer - check for series visibility in getLegendItem(); - ChartPanel - use correct insets for painting chart buffer to screen, update UI for popup menu if LookAndFeel changes; - DateAxis - fixed boundary cases for previousStandardDate() method; - LineBorder - only draw border if area has positive dimensions; - JFreeChart - should register as a listener with the default legend; - StandardXYItemRenderer - fixed a problem where chart entities are created for non-visible items; - TimePeriodValuesCollection.getDomainBounds() now computes the bounds correctly; - XYLineAndShapeRenderer - fixed a problem where chart entities are created for non-visible items; - XYLine3DRenderer - equals() implemented, and serialization fixed; - XYTitleAnnotation - fixed equals() method; - various resource usage bugs in the experimental ChartComposite class; JFreeChart 1.0.5 ---------------- 23 March 2007 This release features a new DeviationRenderer class, support for item labels in StackedXYBarRenderer, tooltips and URLs in the CategoryStepRenderer, and many bug fixes. API Adjustments: - AbstractCategoryItemRenderer - added createState() method; - StackedXYBarRenderer - added get/setRenderAsPercentages() methods; - XYIntervalSeries - added getXLowValue(), getXHighValue(), getYLowValue() and getYHighValue(); - YIntervalSeries - added getYLowValue() and getYHighValue() methods; Bug Fixes: 1681777 - DefaultCategoryDataset does not clone data; 1672552 - Zoom rectangle is lost when the chart is repainted; 1671645 - Crosshair incorrectly positioned in horizontal orientation; 1669302 - Tick labels in vertical symbol axis; 1669218 - CategoryPlot.setDomainAxisLocation() ignores parameter; 1667750 - Clip region not restored in Spider and MeterPlot; 1663380 - OutputStream not closed; 1659627 - IntervalMarker with Double.POSITIVE_INFINITY bound; 1647269 - IntervalMarker with Double.MAX_VALUE as upper bound; 1594477 - XYBarRenderer does not render bars on LogarithmicAxis; 1459958 - Log axis zoom function problem; 880597 - Zooming ChartPanel with log axes; 764561 - Dynamic chart zoom buggy. Also fixed numerous bugs in equals(), cloning and serialization implementations. JFreeChart 1.0.4 ---------------- 9 February 2007 This release features a new XYBlockRenderer class, URLs for pie chart labels in HTML image maps, a new dataset implementation for open-high-low-close charts, support for gradient paint in ClusteredXYBarRenderer, StackedXYBarRenderer and legend graphics, a new anchor attribute for XYImageAnnotation, improvements to the experimental SWT support, plus a number of additions to the API for usability, and many bug fixes. API Adjustments: - DateAxis - added get/setTimeZone() methods; - DefaultXYDataset - now implements PublicCloneable; - StackedXYAreaRenderer2 - added get/setRoundXValues() methods; - StandardXYItemLabelGenerator - added new constructor; - StandardXYToolTipGenerator - added new constructor; - XYBarDataset - added getUnderlyingDataset() and get/setBarWidth() methods; - XYDifferenceRenderer - added roundXCoordinates attribute; - XYImageAnnotation - added an image anchor attribute, a new constructor, and several accessor methods; - XYSeries - added toArray() method; Bug Fixes: 1654215 - XYPlot renderer with no corresponding dataset; 1652640 - RangeMarkers do not update properly; 1649686 - Crosshairs for StackedXYAreaRenderer; 1647749 - IllegalArgumentException in SWTAxisEditor; 1644877 - Replacing series data in DefaultXYDataset; 1644010 - DateAxis.nextStandardDate() ignores timezone; 1638678 - DateAxis code uses the default calendar; 1629382 - Tests fail for jfreechart-1.0.3; 1624067 - StandardXYToolTipGenerator missing constructor; 1616583 - Serialize ChartDeleter; 1612770 - Popup menu in wrong position for SWT ChartComposite; 1611872 - Minute.previous() returns null for minute == 0; 1608371 - Tick labels overlap with custom NumberFormat; 1606205 - Draw shared axis last on combined plots; 1605207 - IntervalMarker exceeds bounds of data area; 1605202 - SpiderWebPlot method access; 1599652 - Inverted StackedBar3D problem; 1598394 - XYBarDataset hiding its proxied object; 1564967 - Crosshairs on XYDifferenceRenderer; 1245305 - NullPointerException in writeImageMap(); 1086307 - Crosshairs on plots with multiple axes. Also fixed numerous bugs in equals() and clone() methods throughout the API. JFreeChart 1.0.3: ----------------- 17 November 2006 This release features several new IntervalXYDataset implementations, some significant refactoring of the time period classes (to improve performance and correctness), modifications to the PiePlot class to support reordering of dataset items, a new event mechanism to allow updating of markers, plus many other enhancements, bug fixes and documentation updates. A new DialPlot implementation has been added to the 'experimental' sources. We are looking for people to test this code and provide feedback, so that we can stabilize the API and add this code to the main JFreeChart API. API adjustments: The following adjustments have been made to the API: - CategoryLabelEntity - new class; - CategoryPointerAnnotation - new class; - ChartPanel: added new public method doEditChartProperties(); - ComparableObjectItem, ComparableObjectSeries - new classes; - CrosshairState: added several new accessor methods; - DefaultPieDataset: added sortByKeys() and sortByValues() methods; - Markers: a change event mechanism has been added to the Marker class and its subclasses; - StackedAreaRenderer: added get/setRenderAsPercentages() methods; - XIntervalDataItem, XIntervalSeries and XIntervalSeriesCollection - new classes; - XYErrorRenderer: new class; - XYInterval, XYIntervalDataItem, XYIntervalSeries and XYIntervalSeriesCollection - new classes; - YInterval, YIntervalDataItem, YIntervalSeries, YIntervalSeriesCollection and YWithXInterval - new classes. Bug Fixes: 1578293 - Unused methods in JDBCXYDataset; 1572478 - BoxAndWhiskerRenderer potential NullPointerException; 1569094 - XYStepRenderer with horizontal orientation; 1565168 - Crosshair position incorrect; 1564977 - DateAxis missing initial tick label; 1562759 - StatisticalLineAndShapeRenderer constructor ignores arguments; 1557141 - Bad locale in ServletUtilities; 1550045 - TimeSeries.removeAgedItems() method problems; 1549218 - Chart not displaying when all data values are the same and large; 1450447 - Marker.setAlpha() ignored; Also fixed URL generation for legend items, tick mark positioning on the DateAxis, the equals() method in the AreaRenderer class, hardcoded outline attributes in the XYBubbleRenderer, and potential NullPointerExceptions in the ChartPanel class. JFreeChart 1.0.2: ----------------- Released on 25 August 2006. API adjustments: The following adjustments have been made to the API (there should be no breakage of applications coded to the 1.0.0 or 1.0.1 API): - CategoryToPieDataset: added accessor methods for underlying dataset, extract type and index (feature request 1477915); - DefaultXYDataset: New dataset implementation that uses double[] arrays; - DefaultXYZDataset: New dataset implementation that uses double[] arrays; - LegendItemBlockContainer: New container used in legends (enables legend item entities again); - MultiplePiePlot: Added new fields aggregatedItemsKey and aggregatedItemsPaint, plus accessor methods - see bug 1190647; - SpiderWebPlot: Added new fields toolTipGenerator and urlGenerator, plus accessor methods (see patch 1463455); - StackedBarRenderer3D: Added new flag (renderAsPercentages), plus accessor methods, that controls whether the data items are displayed as values or percentages. Two new constructors are also added (see patch 1459313); - XYPolygonAnnotation: Added new accessor methods. Patches: 1459313 - Add renderAsPercentages option to StackedBarRenderer3D; 1462727 - Modify SpiderWebPlot to support zero values; 1463455 - Modify SpiderWebPlot to support mouse clicks, tool tips and URLs; Bug Fixes: 1514904 - Background image alpha in Plot class; 1499140 - ClusteredXYBarRenderer with margin not drawing correctly; 1494936 - LineAndShapeRenderer generates entity for non-visible item; 1493199 - NPE drawing SpiderWebPlot with null info; 1480978 - AbstractPieItemLabelGenerator.clone() doesn't clone percentFormat; 1472942 - DateAxis.equals() broken; 1468794 - StatisticalLineAndShapeRenderer doesn't draw error bars correctly when the plot has a horizontal orientation; - AbstractCategoryItemRenderer doesn't check seriesVisibleInLegend flag before creating new item; 1440415 - Bad distribution of pie chart section labels; 1440346 - Bad manifest entry for JCommon in JFreeChart jar file; 1435461 - NumberAxis.equals() ignores rangeType field; 1435160 - XYPointerAnnotation.equals() ignores x and y fields; 1398672 - LegendItemEntities not working; 1380480 - StandardXYItemRenderer problems with Double.NaN; 1190647 - Legend and section color mismatch for MultiplePiePlot. Miscellaneous Changes: - Updated CandlestickRenderer, CyclicXYItemRenderer, HighLowRenderer, XYStepAreaRenderer and TimeSeriesURLGenerator to call dataset methods that return double primitive only; - Updated XYPolygonAnnotation, adding new accessor methods and fixing problems in the equals()/hashCode() methods; - ChartFactory.createStackedXYAreaChart() now uses StackedXYAreaRenderer2, for better handling of negative values; - Added crosshair support for XYBarRenderer. Experimental Code: In this release, some new (incomplete) classes have been included in the org.jfree.experimental.* namespace. These classes are not part of the standard API, but are included for developers to experiment with and provide feedback on. Hopefully in the future, refined versions of these classes will be incorporated into the main library. PLEASE NOTE THAT THE API FOR THESE CLASSES IS SUBJECT TO CHANGE. JFreeChart 1.0.1: ---------------- Released 27 January 2006. This is primarily a bug fix release. In addition, there are some API adjustments (there should be no breakage of applications coded to the 1.0.0 API). API adjustments: - BarRenderer: added a new flag (includeBaseInRange), plus accessor methods, that controls whether or not the base value for the bar is included in the range calculated by the findRangeBounds() method; - BubbleXYItemLabelGenerator: new class; - Range: added a new method expandToInclude(Range, double), this is used by the BarRenderer class; - TaskSeriesCollection: added two new methods, getSeries(int) and getSeries(Comparable). - TimeSeriesCollection: the domainIsPointsInTime flag has been deprecated. The flag serves no function now that renderers are used to calculate the domain bounds, so you can safely delete any calls to the setDomainIsPointsInTime() method; - XYPlot: added a new getAnnotations() method; - XYSeries: the update(int, Number) method has been deprecated and a new method updateByIndex(int, Number) has been added; Bug fixes: 1243050 - XYBarRenderer doesn't show entire range of values for a TimeSeriesCollection; 1373371 - XYBubbleRenderer doesn't support item labels; 1374222 - BarRenderer contains JDK 1.4 specific code; 1374328 - LegendItem serialization problem; 1377239 - Bad argument checking in Quarter constructor; 1379331 - Incorrect drawing of TextTitle at LEFT or RIGHT position; 1386328 - RingPlot entity incorrect; 1400442 - Inconsistent treatment of null and zero values in PiePlot; 1401856 - Bad rendering for non-zero base values in BarRenderer; 1403043 - NullPointerException in CategoryAxis; 1408904 - NumberAxis3D assumes CategoryPlot; 1415480 - XYTextAnnotation equals() method doesn't check (x, y); JFreeChart 1.0.0: ---------------- Released on 2 December 2005. libjfreechart-java-1.0.13.orig/README.txt0000644000175000017500000010513711173030414017653 0ustar vincentvincent******************************** * JFREECHART: Version 1.0.13 * ******************************** 20 April 2009 (C)opyright 2000-2009, by Object Refinery Limited and Contributors. ----------------- 1. INTRODUCTION ----------------- JFreeChart is a free chart library for the Java(tm) platform. It runs on the Java 2 Platform (JDK 1.3 or later) and uses the Java 2D API for drawing. JFreeChart is licensed under the terms of the GNU Lesser General Public Licence (LGPL). A copy of the licence is included in the distribution. Please note that JFreeChart is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer to the licence for details. We are grateful to the many developers that have contributed to JFreeChart. The contributors are listed below in section 10. ------------------- 2. LATEST VERSION ------------------- The latest version of this class library can be obtained from: http://www.jfree.org/jfreechart/ If you have an comments, suggestions or bugs to report, please post a message in the JFreeChart forum. ----------------- 3. DOCUMENTATION ----------------- You can download installation instructions (jfreechart-1.0.13-install.pdf) from the JFreeChart home page or the project page on SourceForge. Further documentation for JFreeChart (the JFreeChart Developer Guide) is available to purchase from by Object Refinery Limited, a company owned and operated by David Gilbert (the original author of JFreeChart). For more information, please see: http://www.object-refinery.com/jfreechart/guide.html Sales of the JFreeChart Developer Guide are an important source of funding for the project. Please help us to continue developing free software. API documentation files in HTML format are available on-line. If you wish to keep a local copy of the API files, you can regenerate them directly from the source code. You can do this using the 'javadoc' or 'gjdoc' utilities directly, or with the Ant script (build.xml) included in the distribution. ----------------- 4. DEPENDENCIES ----------------- JFreeChart has the following dependencies: (a) JDK 1.3.1 or higher - JFreeChart requires the Java2D and Collections APIs, so it definitely won't work with JDK 1.1 (with a small amount of effort you can probably get it to compile and run with JDK 1.2). If you are using JFreeChart to create applets, this means that you cannot rely on the JVM integrated with Microsoft's Internet Explorer - your users will need to have the Java 2 plug-in installed. Most other browsers (e.g. Firefox, Mozilla, Netscape, Konqueror) support JRE 1.4, 1.5 or 1.6. (b) JCommon - version 1.0.0 or later. The runtime jar file (version 1.0.16) is included in the JFreeChart distribution. You can obtain the complete source code for JCommon from: http://www.jfree.org/jcommon/ JCommon is licensed under the terms of the GNU Lesser General Public Licence. (c) GNU JAXP (JDK 1.3 only) - a free implementation of the standard XML processing APIs for Java. http://www.gnu.org/software/classpathx/jaxp/ Classes in the org.jfree.data.xml package require this library, or another JAXP v1.1 compliant parser. The gnujaxp.jar file (from the gnujaxp-1.0beta1.zip distribution) is included with JFreeChart. GNU JAXP is licensed under the terms of the GNU General Public License with an additional library exception. THIS LIBRARY IS ONLY REQUIRED BY JFREECHART IF YOU ARE USING JDK 1.3. (d) servlet.jar - classes in the org.jfree.chart.servlet package require this file. The JFreeChart distribution includes the servlet.jar file distributed with Tomcat 4.1.31. Applicable license terms are published at: http://java.sun.com/products/servlet/LICENSE (e) JUnit - a unit testing framework (the junit.jar runtime file is included in the distribution). JUnit is licensed under the terms of the IBM Common Public License. You can find out more about JUnit and/or download the latest version from: http://www.junit.org The JUnit tests included with JFreeChart have been created using JUnit 4.3.1. ----------- 5. SUPPORT ----------- Support questions can be posted in the free support forum at http://www.jfree.org/phpBB2/viewforum.php?f=3 We read all questions posted in the forum, and respond to as many as we can in the time available. Unfortunately, there are too many questions to answer them all. Priority support is offered (in a separate forum at www.object-refinery.com) to companies and institutions that have purchased a site licence for the JFreeChart Developer Guide. -------------------- 6. ANT BUILD SCRIPT -------------------- An Ant build script (build.xml) is included in the distribution. This is the same script that is used to create the JFreeChart distribution. For more information about Ant: http://ant.apache.org/ If you want to rebuild the JFreeChart jar file, we highly recommend that you use this script as it includes certain files (for example, .properties files) that you MUST have in the jar file for JFreeChart to function correctly. ------------------------ 7. THE DEMO APPLICATION ------------------------ A demo application that shows a selection of the charts that can be generated is included in the JFreeChart distribution. To run the demo (using JDK 1.3.1 or later), use the following command: java -jar jfreechart-1.0.13-demo.jar The complete source code for the demo application is available for download when you purchase the JFreeChart Developer Guide. The demo application uses iText, a library for creating PDF documents. iText is licensed under the terms of the GNU Lesser General Public Licence and is available to download from: http://www.lowagie.com/iText/ --------------- 8. LIMITATIONS --------------- JFreeChart has some known limitations that will hopefully be addressed in the future: - some renderers do not respect the series visibility flags yet; - the chart property editors (accessible by right-clicking on the chart panel) are horribly out of date and probably shouldn't be used; - item labels (if displayed) are not taken into account for the automatically calculated axis range. As a workaround, you can increase the axis margins; - tick labels on a DateAxis that uses a SegmentedTimeline can be problematic; - there is no support for writing charts to JPEG format on JDK 1.3. JPEG is not a good format for charts in any case, and it is usually better to use PNG format; - copying charts to the clipboard (supported by the ChartPanel class) will not work if you are running on a very old version of the Java runtime (version 1.3.1). If there are other items that you think should be listed here, please post a bug report. -------------- 9. WHAT's NEW -------------- A list of changes in recent versions: 1.0.13 : (17-Apr-2009) - there are some significant new features in this release, as well as performance enhancements and bug fixes - see the NEWS and ChangeLog files for details. 1.0.12 : (31-Dec-2008) - added support for minor tick marks, mapping datasets to more than one axis, and numerous bug fixes - see the NEWS and ChangeLog files for details. 1.0.11 : (18-Sep-2008) - this release includes a new chart theming mechanism, and numerous other feature enhancements and bug fixes - see the NEWS and ChangeLog files for details. 1.0.10 : (8-Jun-2008) - another general maintenance release - see the NEWS and ChangeLog files for more details. 1.0.9 : (4-Jan-2008) - this release fixes a security advisory with respect to the HTML image maps generated by JFreeChart - see the NEWS file for more information. In addition, a number of bugs have been fixed. 1.0.8 : (23-Nov-2007) - primarily a bug fix release. See the NEWS and ChangeLog files for a more detailed description of the changes in this release. 1.0.7 : (14-Nov-2007) - See the NEWS and ChangeLog files for a more detailed description of the changes in this release. 1.0.6 : (15-Jun-2007) - the VectorRenderer and associated dataset classes have been promoted to the standard API from the 'experimental' source tree. See the NEWS and ChangeLog files for a more detailed description of the changes in this release. 1.0.5 : (23-Mar-2007) - this release contains a new DeviationRenderer, enhancements to a number of existing classes and numerous bug fixes, see the NEWS and ChangeLog files for details. 1.0.4 : (9-Feb-2007) - this release contains both new features and bug fixes, see the NEWS and ChangeLog files for details. 1.0.3 : (17-Nov-2006) - this release contains a new DialPlot class (in 'experimental') that will hopefully replace the MeterPlot class, once the API has been polished a little, plus many other new features and bug fixes. See the NEWS and ChangeLog files for details. 1.0.2 : (25-Aug-2006) - this release contains both new features and bug fixes, see the NEWS and ChangeLog files for details. 1.0.1 : (27-Jan-2006) - primarily a bug fix release, see the NEWS and ChangeLog files for details. 1.0.0 : (2-Dec-2005) - the first stable release of the JFreeChart class library, all future releases in the 1.0.x series will aim to maintain backward compatibility with this release; - see the ChangeLog file for a detailed list of changes. 1.0.0-rc3 : (28-Nov-2005) - the third "release candidate" for version 1.0.0, this release fixes some issues with the 1.0.0-rc2 release (mainly concerning packaging of resource bundles for localisation). - if no significant problems are reported in the next few days, the 1.0.0 "final" release will be posted on 2-Dec-2005. 1.0.0-rc2 : (25-Nov-2005) - the second "release candidate" for version 1.0.0. If no problems are reported, 1.0.0 "final" will be released on 2-Dec-2005. - see the ChangeLog file for a detailed list of changes in this release. 1.0.0-rc1 : (2-Jun-2005) - this is a "release candidate" for version 1.0.0. If no significant API problems are reported, this release will be re-released as version 1.0.0. - see CHANGELOG.txt for further details. 1.0.0-pre2 : (10-Mar-2005) - see CHANGELOG.txt for further details. 1.0.0-pre1 : (29-Nov-2004) - see CHANGELOG.txt for further details. 0.9.21 : (9-Sep-2004) - added new axes: PeriodAxis and ModuloAxis. - split org.jfree.data and org.jfree.chart.renderer into subpackages for 'category' and 'xy' charts. - Sun PNG encoder is now used, if available. - a new demo application makes it easier to preview the chart types that JFreeChart can create. - added a new series visibility flag to the AbstractRenderer class. - added support for GradientPaint in interval markers. - see CHANGELOG.txt for further details. 0.9.20 : (7-Jun-2004) - primarily bug fixes, see CHANGELOG.txt for further details. 0.9.19 : (28-May-2004) - added methods to XYDataset that return double primitives; - removed distinction between "primary" and "secondary" datasets, renderers and axes; - added fixed legend item options to CategoryPlot and XYPlot; - legend changes by Barek Naveh; - removed Log4j dependency; - many, many bug fixes; - see CHANGELOG.txt for further details. 0.9.18 : (15-Apr-2004) - new legend anchor options; - fixed broken JPEG export; - fixed title size problems; - various other bug fixes; 0.9.17 : (26-Mar-2004) - pie chart enhancements for labelling, shading and multiple pie charts (2D or 3D) on a single plot; - new PolarPlot class added; - XYSeries can now be sorted or unsorted; - createBufferedImage() method can now scale charts; - domain and range markers now support intervals; - item labels are now supported by some XYItemRenderers; - tooltip and item label generators now use MessageFormat class; - added new XYBarDataset class; - added transparency support to PNG export; - numerous other small enhancements and bug fixes, see the CHANGELOG.txt file for more details; 0.9.16 : (09-Jan-2004) - this release contains bug fixes and some minor feature enhancements (title and category label wrapping, legend shape scaling, enhanced performance for the DefaultTableXYDataset class); - added Spanish localisation files; 0.9.15 : (28-Nov-2003) - the focus of this release is bug fixes - quite a number of issues have been resolved, please check the bug database for details; - added a new Wafer Map chart type; - added a cyclic axis; - added localisation files for _ru; 0.9.14 : (17-Nov-2003) - implemented zooming for the FastScatterPlot class; - added item label support for stacked bar charts, and new fall back options for item labels that don't fit within bars; - modified the CategoryAxis class to allow additional options for the alignment and rotation of category labels; - addition of the AxisState class, used in the drawing of axes to eliminate a bug when multiple threads draw the same axis simultaneously; - provided additional attributes in the DateTickUnit class to improve labelling on a segmented DateAxis; - added support for GradientPaint in bar charts; - updated the PNGEncoder; - fixes for tick label positioning on axes; - various Javadoc updates; - numerous bug fixes; 0.9.13 : (26-Sep-2003) - various enhancements to the stacked area XY charts; - added a completion indicator for the Gantt chart; - range and domain markers can now be placed in the foreground or the background; - more fixes for cloning and serialization; - fixed mouse event bug for combined charts; - fixed bugs in the PngEncoder class; - incorporated .properties files that were missing from the 0.9.12 distribution; 0.9.12 : (11-Sep-2003) - extended box-and-whisker plots to work with the CategoryPlot class as well as the XYPlot class (based on work by David Browning); - added a new LayeredBarRenderer (by Arnaud Lelievre); - added support for stacked area charts with the XYPlot class (thanks to Richard Atkinson); - improved HTML image map support (thanks to Richard Atkinson); - added localized resources for the chart property editors (thanks to Arnaud Lelievre). Current translations include French and Portugese (thanks to Eduardo Ramalho); - added facility for setting all rendering hints; - improved support for cloning and serialization; - fixed a bug in the XYSeries class that prevented the TableXYDataset from functioning correctly; - improved date axis labelling with segmented time lines; - fixed several bugs in the secondary dataset/axis/renderer code; - fixed bugs in the JDBCCategoryDataset class; - numerous other bug fixes; 0.9.11 : (8-Aug-2003) - added support for box-and-whisker plots, thanks to David Browning; - lots of bug fixes; API changes in this release are minimal and have been implemented using deprecation, so code written against 0.9.10 should recompile. 0.9.10 : (25-Jul-2003) - added support for multiple secondary axes, datasets and renderers; - minor feature enhancements and bug fixes; 0.9.9 : (10-Jul-2003) PLEASE NOTE THAT MAJOR CHANGES HAVE BEEN MADE IN THIS RELEASE AND ONE OR TWO FEATURES MAY BE BROKEN. PLEASE REPORT BUGS SO THEY CAN BE FIXED FOR THE NEXT RELEASE. - merged the HorizontalCategoryPlot and VerticalCategoryPlot classes, into the CategoryPlot class; - merged the horizontal and vertical axis classes; - merged the horizontal and vertical renderer classes; - CategoryPlot and XYPlot now support both horizontal and vertical orientation via the setOrientation(...) method; - merged horizontal and vertical methods in the ChartFactory class; - created new combined plot classes: CombinedDomainCategoryPlot, CombinedRangeCategoryPlot, CombinedDomainXYPlot and CombinedRangeXYPlot (these can all be drawn with a horizontal or vertical orientation); - Bill Kelemen has enhanced the DateAxis class to handle segmented timelines. This can be used, for example, to skip weekends for daily stock price charts; - Richard Atkinson has updated the ServletUtilities class; - Bryan Scott has added an XYDatasetTableModel class for presenting datasets in a JTable; - modified XYPlot to allow renderers to use multiple passes through the dataset; - added new XYDifferenceRenderer; - added support for colored bands between gridlines in XYPlot; - added new XYDrawableAnnotation class; - added a new attribute to control the order of dataset rendering in a CategoryPlot; - extended the value label mechanism for the renderers, to allow better (per series) control over label generation, positioning and visibility; - CategoryItemTooltipGenerator has been renamed CategoryItemLabelGenerator, since it is now being used to generated item labels as well as tooltips; - there is now support for horizontal stacked 3D bar charts; - added support for range markers against secondary axis in a CategoryPlot; - added labels to domain and range markers; - added a new HistogramDataset class (contributed by Jelai Wang) to make it easier to create histograms with JFreeChart; - moved the DrawingSupplier into the plot class, renderers now reference the supplier from the plot (parent plot for combined and overlaid charts). This means that renderers now share a single DrawingSupplier by default, which simplifies the creation of combined charts; - changed the ColorBarAxis classes that extended the NumberAxis class, to a single ColorBar class that wraps a ValueAxis (may have broken one or two things in the process); - Barak Naveh has contributed new classes MatrixSeries and MatrixSeriesCollection, along with demos: BubblyBubblesDemo.java and BubblyBubblesDemo2.java; - the TextTitle class now has a background paint attribute; - the StandardLegend class now generates LegendEntity objects if a ChartRenderingInfo instance is supplied to the draw(...) method; - extended the CategoryTextAnnotation class to take into account a category anchor point. See the SurveyResultsDemo.java application for an example; - included numerous bug fixes; 0.9.8 : (24-Apr-2003) - changed package naming from com.jrefinery.* to org.jfree.*; - added new TimePeriodValuesCollection class; - added MIME type code to ServletUtilities class; - reversed the order of PieDataset and KeyedValuesDataset in the class hierarchy; - reversed the order of CategoryDataset and KeyedValues2DDataset in the class hierarchy; - minor bug fixes; 0.9.7 : (11-Apr-2003) - added a new ValueDataset interface and DefaultValueDataset class, and changed the CompassPlot class to use this instead of MeterDataset; - added DataUtilities class, to support creation of Pareto charts (new demo included); - updated writeImageMap method as suggested by Xavier Poinsard (see Feature Request 688079); - implemented Serializable for most classes (this is likely to require further testing); - incorporated contour plot updates from David M. O'Donnell; - added new CategoryTextAnnotation and XYLineAnnotation classes; - added new HorizontalCategoryAxis3D class contributed by Klaus Rheinwald; Bug fixes: - added a workaround for JVM crash (a JDK bug) in pie charts with small sections (see bug report 620031); - fixed minor bug in HorizontalCategoryPlot constructor (see bug report 702248); - added code to ensure HorizontalNumberAxis3D is not drawn if it is not visible (see bug report 702466); - added small fix for suppressed chart change events (see bug report 690865); - added pieIndex parameter to tooltip and URL generators for pie charts; - fixed bug in getLastMillisecond() method for the Second class and the getFirstMillisecond() method for the Year class (picked up in JUnit tests); - in TextTitle, changed width used for relative spacing to fix bug 703050; 0.9.6 : (17-Feb-2003) Bug fixes: - fixed null pointer exception in DefaultCategoryDataset; - fixed update problem for PaintTable, StrokeTable and ShapeTable objects; - added methods to control colors in PiePlot (these were inadvertantly removed in the changes made for 0.9.5); - fixed auto-range update problem for secondary axis; - fixed missing category labels in the overlaid category plot; - fixed constructors for symbolic axes; - corrected error in Javadoc generation (Ant script); 0.9.5 : (6-Feb-2003) PLEASE NOTE THAT MAJOR CHANGES TO THE JFREECHART API HAVE BEEN MADE IN THIS RELEASE! - added support for secondary axes, datasets and renderers; - added new data interfaces (Value, Values, Values2D, KeyedValues and KeyedValues2D) and incorporated these into the existing PieDataset and CategoryDataset interfaces. - modified the CategoryDataset interface to be more symmetrical, data is organised in rows and columns (as before) but can now be accessed by row/column index or row/column key. - added support for reading PieDatasets and CategoryDatasets from XML files. - created separate packages for the axes (com.jrefinery.chart.axis), plots (com.jrefinery.chart.plot) and renderers (com.jrefinery.chart.renderer). - series attributes (paint, outline paint, stroke and shape) are now controlled by the renderer classes using lookup tables. Introduced the DrawingSupplier interface (and DefaultDrawingSupplier class) which is used to populate the lookup tables from a common source (necessary to coordinate complex combined charts). - the chart legend can now display shapes corresponding to series. - moved responsibility for category distribution to the CategoryAxis class, which tidies up the code in the CategoryPlot classes. - gridlines are now controlled by the CategoryPlot and XYPlot classes, not the axes (included in this change is the addition of gridlines for the CategoryPlot domain values). - changed the list of titles in the JFreeChart class to a title and a list of subtitles. - added new renderers for XYPlot (XYBubbleRenderer and YIntervalRenderer). - modified Gantt chart to display sub-tasks. - added ContourPlot class (still experimental) by David M. O'Donnell. - introduced new MovingAverage class. - ChartMouseEvent now includes source chart. - numerous bug fixes. - lots of Javadoc updates. 0.9.4 : (18-Oct-2002) Added a new stacked area chart (contributed by Dan Rivett) and a compass plot (contributed by Bryan Scott). Updated the ThermometerPlot class. Added a new XYDotRenderer for scatter plots. Modified combined and overlaid plots to use the series colors specified in the sub plot rather than the parent plot (this makes it easier to align the colors in the legend). Added Regression class for linear and power regressions. BasicTimeSeries can now automatically drop "old" data. Some clean-up work in the code for tooltips and the event listener mechanism. Richard Atkinson has incorporated some useful extensions for servlets/JSP developers. Ran Checkstyle and corrected issues reported for most classes. Checkstyle is a free utility that you can download from: http://checkstyle.sourceforge.net Fixed bugs and updated documentation. API changes include: - added tickMarkPaint to Axis constructor (also affects subclasses); - added getLegendItems() to Plot, and deprecated getLegendItemLabels(); - added getLegendItem(int) to XYItemRenderer and CategoryItemRenderer. - most 'protected' member variables have been changed to 'private'. 0.9.3 : (4-Sep-2002) Added multiple pie charts based on CategoryDataset. Updated logarithmic axes. Improved URL support for image map generation. Moved the com.jrefinery.data package from JCommon to JFreeChart. Added simple framework for chart annotations. Improved control over renderers. Duplicate x-values now allowed in XYSeries. Optional category label skipping in category axes. Added CategoriesPaint attribute to AbstractCategoryItemRenderer. Added new attributes to MeterPlot class. Updated 3D pie chart to observe start angle and direction, and also foreground alpha < 1.0. Improved Javadoc comments. New demo applications, including: AnnotationDemo1, EventFrequencyDemo, JDBCCategoryChartDemo, JDBCPieChartDemo, JDBCXYChartDemo and MinMaxCategoryPlotDemo. Bug fixes: - negative percentages on PiePlot. - added listener notification to setXXXAxis(...) methods. - fixed DomainInfo method name clash. - added DomainIsPointsInTime flag to TimeSeriesCollection to give better control over auto range on axis for time series charts. - axis margins for date axes are no longer hard-coded. - fix for ordering of categories in JdbcCategoryDataset. - added check for null axis in mouse click handler. The CVS repository at SourceForge has also been restructured to match the distribution directory layout. 0.9.2 : (28-Jun-2002) PiePlot now has startAngle and direction attributes. Added support for image map generation. Added a new Pie3DPlot class. Added label drawing code to bar renderers. Added optional range markers to horizontal number axis. Added bar clipping to avoid PRExceptions in bar charts. JFreeChartDemo has been modified and now includes examples of the dial and thermometer plots. Bug fixes: - auto range for VerticalNumberAxis when zero is forced to be included in the range. - fixed null pointer exception in StackedVerticalBarRenderer3D; - Added get/set methods for min/max chart drawing dimensions in ChartPanel; - HorizontalIntervalBarRenderer now handles single category; - verticalTickLabels now possible in HorizontalNumberAxis3D; - removed unnecessary imports; 0.9.1 : (14-Jun-2002) Bug fixes and Javadoc updates. - fixed auto range calculation for category plots; - fixed event notification for XYPlot; - fixed auto axis range for Gantt charts; - check for null popup menu in ChartPanel.mouseDragged; - new checks for null info in renderers; - range markers now drawn only if in visible axis range; 0.9.0 : (7-Jun-2002) New plots including an area chart, a horizontal 3D bar chart, a Gantt chart and a thermometer chart. Combination plots have been reworked to provide a simpler framework, and extends to allow category plots to be combined. There is now a facility to add a ChartMouseListener to the ChartPanel (formerly JFreeChartPanel). An interactive zooming feature (experimental at this point) is now available for XYPlots. A new Polish translation has been added. Several fixes have been applied to the default tool tip generators. A workaround has been added to fix the alignment between time series charts and the date axis. There are some improvements to the VerticalLogarithmicAxis class, and now a corresponding HorizontalLogarithmicAxis class. Additional demonstration applications have been added. Fixed the popup menu bug. 0.8.1 : (5-Apr-2002) Localised resource bundles for French, German and Spanish languages (thanks to Anthony Boulestreau, Thomas Meier and Hans-Jurgen Greiner for the translations). An area XY plot and meter chart contributed by Hari. Symbol charts contributed by Anthony Boulestreau. An improved CandleStickRenderer class from Sylvain Vieujot. Updated servlet code from Bryan Scott. XYItemRenderers now have a change listener mechanism and therefore do not have to be immutable. Additional demonstration applications for individual chart types. Minor bug fixes. 0.8.0 : (22-Mar-2002) All the category plots are now controlled through the one class (CategoryPlot) with plug-in renderers. Added a ResourceBundle for user interface items that require localisation. Added a logarithmic axis class contributed by Mike Duffy and some new JDBC and servlet code contributed by Bryan Scott. Updated the JCommon class library to improve handling of time periods in different time zones. 0.7.4 : (6-Mar-2002) Bug fixes in the JCommon Class Library. Various Javadoc comment updates. Some minor changes to the code. Added new domain name (http://www.object-refinery.com) in the source headers. 0.7.3 : (14-Feb-2002) Bug fixes. 0.7.2 : (8-Feb-2002) Integrated the WindPlot code from Achilleus Mantzios. Added an optional background image for the JFreeChart class, and another optional background image for the Plot class. Added alpha-transparency for the plot foreground and background. Added new pie chart label types that show values. Fixed a bug with the legend that results in a loop at small chart sizes. Added some tooltip methods that were missing from the previous version. Changed the Insets class on chart titles to a new Spacer class that will allow for relative or absolute insets (the plan is to eventually replace all Insets in the JFreeChart classes). Fixed a bug in the setAutoRangeIncludesZero method of the NumberAxis class. Added the instructions that were missing from the copies of the GNU Lesser General Public Licence included with JFreeChart. 0.7.1 : (25-Jan-2002) Added tooltips, crosshairs and zooming functions, thanks to Jonathan Nash and Hans-Jurgen Greiner for contributing the code that these features are based on. Moved the combination charts into the package com.jrefinery.chart.combination, made a number of other small API changes and fixed some bugs. Removed the Javadoc HTML from the download to save space (you can regenerate it from the source code if you need it). 0.7.0 : (11-Dec-2001) New combination plots developed by Bill Kelemen. Added Wolfgang Irler's servlet demo to the standard download. The About window in the demo application now includes a list of developers that have contributed to the project. 0.6.0 : (27-Nov-2001) New plots including scatter plot, stacked bar charts and 3D bar charts. Improved pie chart. Data interfaces and classes moved to the JCommon class library. New properties to control spacing on bar charts. New auto-tick mechanism. JFreeChartPanel now incorporates buffering, and popup menu. Javadocs revised. Fixed numerous bugs from version 0.5.6. Demo application updated. ---------------- 10. CONTRIBUTORS ---------------- JFreeChart wouldn't be half the library that it is today without the contributions (large and small) that have been made by the developers listed below: - Eric Alexander - Richard Atkinson - David Basten - David Berry - Chris Boek - Zoheb Borbora - Anthony Boulestreau - Jeremy Bowman - Nicolas Brodu - Jody Brownell - David Browning - Soren Caspersen - Chuanhao Chiu - Brian Cole - Pascal Collet - Martin Cordova - Paolo Cova - Greg Darke - Mike Duffy - Don Elliott - Rune Fauske - Jonathan Gabbai - Serge V. Grachov - Daniel Gredler - Joao Guilherme Del Valle - Hans-Jurgen Greiner - Nick Guenther - Aiman Han - Cameron Hayne - Jon Iles - Wolfgang Irler - Sergei Ivanov - Adriaan Joubert - Darren Jung - Xun Kang - Bill Kelemen - Norbert Kiesel - Gideon Krause - Pierre-Marie Le Biot - Arnaud Lelievre - Wolfgang Lenhard - David Li - Yan Liu - Tin Luu - Craig MacFarlane - Achilleus Mantzios - Thomas Meier - Jim Moore - Jonathan Nash - Barak Naveh - David M. O'Donnell - Krzysztof Paz - Eric Penfold - Tomer Peretz - Xavier Poinsard - Andrzej Porebski - Viktor Rajewski - Eduardo Ramalho - Michael Rauch - Cameron Riley - Klaus Rheinwald - Dan Rivett - Scott Sams - Michel Santos - Thierry Saura - Andreas Schneider - Jean-Luc SCHWAB - Bryan Scott - Tobias Selb - Darshan Shah - Mofeed Shahin - Michael Siemer - Pady Srinivasan - Greg Steckman - Roger Studner - Gerald Struck - Irv Thomae - Eric Thomas - Rich Unger - Daniel van Enckevort - Laurence Vanhelsuwe - Sylvain Vieujot - Jelai Wang - Mark Watson - Alex Weber - Richard West - Matthew Wright - Benoit Xhenseval - Christian W. Zuckschwerdt - Hari - Sam (oldman) It is possible that I have missed someone on this list, if that applies to you, please e-mail me. Dave Gilbert (david.gilbert@object-refinery.com) JFreeChart Project Leader libjfreechart-java-1.0.13.orig/licence-LGPL.txt0000644000175000017500000006347611173030414021065 0ustar vincentvincent GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libjfreechart-java-1.0.13.orig/maven-jfreechart-project.xml0000644000175000017500000000531611173030414023562 0ustar vincentvincent 3 jfreechart JFreechart jfree @VERSION@ JFree.org http://www.jfree.org/ 2001 JFreeChart is a class library, written in Java, for generating charts. Utilising the Java2D APIs, it currently supports bar charts, pie charts, line charts, XY-plots and time series plots. A free Java class library for generating charts. http://www.jfree.org/jfreechart/ http://sourceforge.net/tracker/?group_id=15494 scm:cvs:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jfreechart:jfreechart http://cvs.sourceforge.net/viewcvs.py/jfreechart/jfreechart JFreeChart Developer List jfreechart-dev-request@lists.sourceforge.net?subject=subscribe jfreechart-dev-request@lists.sourceforge.net?subject=unsubscribe http://sourceforge.net/mailarchive/forum.php?forum=jfreechart-dev GNU Lesser General Public Licence http://www.gnu.org/licenses/lgpl.txt repo jfree jcommon @JCOMMON.VERSION@ http://www.jfree.org/jcommon/ junit junit 3.7 http://www.junit.org/ xml-apis xml-apis 1.3.02 xml-apis-1.3.02.jar http://xml.apache.org/commons/#external

http://www.object-refinery.com/jfreechart/guide.html libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/0000755000175000017500000000000011216245561023730 5ustar vincentvincentlibjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/ChartEditor.java0000644000175000017500000000374011173030414026776 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------- * ChartEditor.java * ---------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 24-Nov-2005 : Version 1 (DG); * */ package org.jfree.chart.editor; import javax.swing.JComponent; import org.jfree.chart.JFreeChart; /** * A chart editor is typically a {@link JComponent} containing a user interface * for modifying the properties of a chart. * * @see ChartEditorManager#getChartEditor(JFreeChart) */ public interface ChartEditor { /** * Applies the changes to the specified chart. * * @param chart the chart. */ public void updateChart(JFreeChart chart); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/ChartEditorFactory.java0000644000175000017500000000361211173030414030324 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * ChartEditorFactory.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 28-Nov-2005 : Version 1 (DG); * */ package org.jfree.chart.editor; import org.jfree.chart.JFreeChart; /** * A factory for creating new {@link ChartEditor} instances. */ public interface ChartEditorFactory { /** * Creates an editor for the given chart. * * @param chart the chart. * * @return A chart editor. */ public ChartEditor createEditor(JFreeChart chart); } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/ChartEditorManager.java0000644000175000017500000000600511173030414030266 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * ChartEditorManager.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 24-Nov-2005 : Version 1 (DG); * */ package org.jfree.chart.editor; import org.jfree.chart.JFreeChart; /** * The central point for obtaining {@link ChartEditor} instances for editing * charts. Right now, the API is minimal - the plan is to extend this class * to provide customisation options for chart editors (for example, make some * editor items read-only). */ public class ChartEditorManager { /** This factory creates new {@link ChartEditor} instances as required. */ static ChartEditorFactory factory = new DefaultChartEditorFactory(); /** * Private constructor prevents instantiation. */ private ChartEditorManager() { // nothing to do } /** * Returns the current factory. * * @return The current factory (never null). */ public static ChartEditorFactory getChartEditorFactory() { return factory; } /** * Sets the chart editor factory. * * @param f the new factory (null not permitted). */ public static void setChartEditorFactory(ChartEditorFactory f) { if (f == null) { throw new IllegalArgumentException("Null 'f' argument."); } factory = f; } /** * Returns a component that can be used to edit the given chart. * * @param chart the chart. * * @return The chart editor. */ public static ChartEditor getChartEditor(JFreeChart chart) { return factory.createEditor(chart); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultAxisEditor.java0000644000175000017500000004200711173030414030145 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DefaultAxisEditor.java * ---------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert; * Contributor(s): Andrzej Porebski; * Arnaud Lelievre; * * Changes * ------- * 24-Nov-2005 : Version 1, based on AxisPropertyEditPanel.java (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.editor; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.Paint; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.layout.LCBLayout; import org.jfree.ui.FontChooserPanel; import org.jfree.ui.FontDisplayField; import org.jfree.ui.PaintSample; import org.jfree.ui.RectangleInsets; /** * A panel for editing the properties of an axis. */ class DefaultAxisEditor extends JPanel implements ActionListener { /** The axis label. */ private JTextField label; /** The label font. */ private Font labelFont; /** The label paint. */ private PaintSample labelPaintSample; /** A field showing a description of the label font. */ private JTextField labelFontField; /** The font for displaying tick labels on the axis. */ private Font tickLabelFont; /** * A field containing a description of the font for displaying tick labels * on the axis. */ private JTextField tickLabelFontField; /** The paint (color) for the tick labels. */ private PaintSample tickLabelPaintSample; /** * An empty sub-panel for extending the user interface to handle more * complex axes. */ private JPanel slot1; /** * An empty sub-panel for extending the user interface to handle more * complex axes. */ private JPanel slot2; /** A flag that indicates whether or not the tick labels are visible. */ private JCheckBox showTickLabelsCheckBox; /** A flag that indicates whether or not the tick marks are visible. */ private JCheckBox showTickMarksCheckBox; // /** Insets text field. */ // private InsetsTextField tickLabelInsetsTextField; // // /** Label insets text field. */ // private InsetsTextField labelInsetsTextField; /** The tick label insets. */ private RectangleInsets tickLabelInsets; /** The label insets. */ private RectangleInsets labelInsets; /** A tabbed pane for... */ private JTabbedPane otherTabs; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * A static method that returns a panel that is appropriate for the axis * type. * * @param axis the axis whose properties are to be displayed/edited in * the panel. * * @return A panel or nullnull. */ public static DefaultAxisEditor getInstance(Axis axis) { if (axis != null) { // figure out what type of axis we have and instantiate the // appropriate panel if (axis instanceof NumberAxis) { return new DefaultNumberAxisEditor((NumberAxis) axis); } else { return new DefaultAxisEditor(axis); } } else { return null; } } /** * Standard constructor: builds a panel for displaying/editing the * properties of the specified axis. * * @param axis the axis whose properties are to be displayed/edited in * the panel. */ public DefaultAxisEditor(Axis axis) { this.labelFont = axis.getLabelFont(); this.labelPaintSample = new PaintSample(axis.getLabelPaint()); this.tickLabelFont = axis.getTickLabelFont(); this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint()); // Insets values this.tickLabelInsets = axis.getTickLabelInsets(); this.labelInsets = axis.getLabelInsets(); setLayout(new BorderLayout()); JPanel general = new JPanel(new BorderLayout()); general.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), localizationResources.getString("General") ) ); JPanel interior = new JPanel(new LCBLayout(5)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Label"))); this.label = new JTextField(axis.getLabel()); interior.add(this.label); interior.add(new JPanel()); interior.add(new JLabel(localizationResources.getString("Font"))); this.labelFontField = new FontDisplayField(this.labelFont); interior.add(this.labelFontField); JButton b = new JButton(localizationResources.getString("Select...")); b.setActionCommand("SelectLabelFont"); b.addActionListener(this); interior.add(b); interior.add(new JLabel(localizationResources.getString("Paint"))); interior.add(this.labelPaintSample); b = new JButton(localizationResources.getString("Select...")); b.setActionCommand("SelectLabelPaint"); b.addActionListener(this); interior.add(b); // interior.add( // new JLabel(localizationResources.getString("Label_Insets")) // ); // b = new JButton(localizationResources.getString("Edit...")); // b.setActionCommand("LabelInsets"); // b.addActionListener(this); // this.labelInsetsTextField = new InsetsTextField(this.labelInsets); // interior.add(this.labelInsetsTextField); // interior.add(b); // // interior.add( // new JLabel(localizationResources.getString("Tick_Label_Insets")) // ); // b = new JButton(localizationResources.getString("Edit...")); // b.setActionCommand("TickLabelInsets"); // b.addActionListener(this); // this.tickLabelInsetsTextField // = new InsetsTextField(this.tickLabelInsets); // interior.add(this.tickLabelInsetsTextField); // interior.add(b); general.add(interior); add(general, BorderLayout.NORTH); this.slot1 = new JPanel(new BorderLayout()); JPanel other = new JPanel(new BorderLayout()); other.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), localizationResources.getString("Other"))); this.otherTabs = new JTabbedPane(); this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); JPanel ticks = new JPanel(new LCBLayout(3)); ticks.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.showTickLabelsCheckBox = new JCheckBox( localizationResources.getString("Show_tick_labels"), axis.isTickLabelsVisible() ); ticks.add(this.showTickLabelsCheckBox); ticks.add(new JPanel()); ticks.add(new JPanel()); ticks.add( new JLabel(localizationResources.getString("Tick_label_font")) ); this.tickLabelFontField = new FontDisplayField(this.tickLabelFont); ticks.add(this.tickLabelFontField); b = new JButton(localizationResources.getString("Select...")); b.setActionCommand("SelectTickLabelFont"); b.addActionListener(this); ticks.add(b); this.showTickMarksCheckBox = new JCheckBox( localizationResources.getString("Show_tick_marks"), axis.isTickMarksVisible() ); ticks.add(this.showTickMarksCheckBox); ticks.add(new JPanel()); ticks.add(new JPanel()); this.otherTabs.add(localizationResources.getString("Ticks"), ticks); other.add(this.otherTabs); this.slot1.add(other); this.slot2 = new JPanel(new BorderLayout()); this.slot2.add(this.slot1, BorderLayout.NORTH); add(this.slot2); } /** * Returns the current axis label. * * @return The current axis label. */ public String getLabel() { return this.label.getText(); } /** * Returns the current label font. * * @return The current label font. */ public Font getLabelFont() { return this.labelFont; } /** * Returns the current label paint. * * @return The current label paint. */ public Paint getLabelPaint() { return this.labelPaintSample.getPaint(); } /** * Returns a flag that indicates whether or not the tick labels are visible. * * @return true if ick mark labels are visible. */ public boolean isTickLabelsVisible() { return this.showTickLabelsCheckBox.isSelected(); } /** * Returns the font used to draw the tick labels (if they are showing). * * @return The font used to draw the tick labels. */ public Font getTickLabelFont() { return this.tickLabelFont; } /** * Returns the current tick label paint. * * @return The current tick label paint. */ public Paint getTickLabelPaint() { return this.tickLabelPaintSample.getPaint(); } /** * Returns the current value of the flag that determines whether or not * tick marks are visible. * * @return true if tick marks are visible. */ public boolean isTickMarksVisible() { return this.showTickMarksCheckBox.isSelected(); } /** * Returns the current tick label insets value * * @return The current tick label insets value. */ public RectangleInsets getTickLabelInsets() { return (this.tickLabelInsets == null) ? new RectangleInsets(0, 0, 0, 0) : this.tickLabelInsets; } /** * Returns the current label insets value * * @return The current label insets value. */ public RectangleInsets getLabelInsets() { return (this.labelInsets == null) ? new RectangleInsets(0, 0, 0, 0) : this.labelInsets; } /** * Returns a reference to the tabbed pane. * * @return A reference to the tabbed pane. */ public JTabbedPane getOtherTabs() { return this.otherTabs; } /** * Handles user interaction with the property panel. * * @param event information about the event that triggered the call to * this method. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("SelectLabelFont")) { attemptLabelFontSelection(); } else if (command.equals("SelectLabelPaint")) { attemptModifyLabelPaint(); } else if (command.equals("SelectTickLabelFont")) { attemptTickLabelFontSelection(); } // else if (command.equals("LabelInsets")) { // editLabelInsets(); // } // else if (command.equals("TickLabelInsets")) { // editTickLabelInsets(); // } } /** * Presents a font selection dialog to the user. */ private void attemptLabelFontSelection() { FontChooserPanel panel = new FontChooserPanel(this.labelFont); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Font_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.labelFont = panel.getSelectedFont(); this.labelFontField.setText( this.labelFont.getFontName() + " " + this.labelFont.getSize() ); } } /** * Allows the user the opportunity to change the outline paint. */ private void attemptModifyLabelPaint() { Color c; c = JColorChooser.showDialog( this, localizationResources.getString("Label_Color"), Color.blue ); if (c != null) { this.labelPaintSample.setPaint(c); } } /** * Presents a tick label font selection dialog to the user. */ public void attemptTickLabelFontSelection() { FontChooserPanel panel = new FontChooserPanel(this.tickLabelFont); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Font_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.tickLabelFont = panel.getSelectedFont(); this.tickLabelFontField.setText( this.tickLabelFont.getFontName() + " " + this.tickLabelFont.getSize() ); } } // /** // * Presents insets chooser panel allowing user to modify tick label's // * individual insets values. Updates the current insets text field if // * edit is accepted. // */ // private void editTickLabelInsets() { // InsetsChooserPanel panel = new InsetsChooserPanel( // this.tickLabelInsets); // int result = JOptionPane.showConfirmDialog( // this, panel, localizationResources.getString("Edit_Insets"), // JOptionPane.PLAIN_MESSAGE // ); // // if (result == JOptionPane.OK_OPTION) { // this.tickLabelInsets = panel.getInsets(); // this.tickLabelInsetsTextField.setInsets(this.tickLabelInsets); // } // } // // /** // * Presents insets chooser panel allowing user to modify label's // * individual insets values. Updates the current insets text field if edit // * is accepted. // */ // private void editLabelInsets() { // InsetsChooserPanel panel = new InsetsChooserPanel(this.labelInsets); // int result = JOptionPane.showConfirmDialog( // this, panel, localizationResources.getString("Edit_Insets"), // JOptionPane.PLAIN_MESSAGE // ); // // if (result == JOptionPane.OK_OPTION) { // this.labelInsets = panel.getInsets(); // this.labelInsetsTextField.setInsets(this.labelInsets); // } // } /** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { axis.setLabel(getLabel()); axis.setLabelFont(getLabelFont()); axis.setLabelPaint(getLabelPaint()); axis.setTickMarksVisible(isTickMarksVisible()); // axis.setTickMarkStroke(getTickMarkStroke()); axis.setTickLabelsVisible(isTickLabelsVisible()); axis.setTickLabelFont(getTickLabelFont()); axis.setTickLabelPaint(getTickLabelPaint()); axis.setTickLabelInsets(getTickLabelInsets()); axis.setLabelInsets(getLabelInsets()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultChartEditor.java0000644000175000017500000002262511173030414030306 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ----------------------- * DefaultChartEditor.java * ----------------------- * (C) Copyright 2000-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Arnaud Lelievre; * Daniel Gredler; * * Changes * ------- * 24-Nov-2005 : New class, based on ChartPropertyEditPanel.java (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.editor; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Paint; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.Plot; import org.jfree.chart.title.Title; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.layout.LCBLayout; import org.jfree.ui.PaintSample; /** * A panel for editing chart properties (includes subpanels for the title, * legend and plot). */ class DefaultChartEditor extends JPanel implements ActionListener, ChartEditor { /** A panel for displaying/editing the properties of the title. */ private DefaultTitleEditor titleEditor; /** A panel for displaying/editing the properties of the plot. */ private DefaultPlotEditor plotEditor; /** * A checkbox indicating whether or not the chart is drawn with * anti-aliasing. */ private JCheckBox antialias; /** The chart background color. */ private PaintSample background; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Standard constructor - the property panel is made up of a number of * sub-panels that are displayed in the tabbed pane. * * @param chart the chart, whichs properties should be changed. */ public DefaultChartEditor(JFreeChart chart) { setLayout(new BorderLayout()); JPanel other = new JPanel(new BorderLayout()); other.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(6)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); this.antialias = new JCheckBox(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setSelected(chart.getAntiAlias()); interior.add(this.antialias); interior.add(new JLabel("")); interior.add(new JLabel("")); interior.add(new JLabel(localizationResources.getString( "Background_paint"))); this.background = new PaintSample(chart.getBackgroundPaint()); interior.add(this.background); JButton button = new JButton(localizationResources.getString( "Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(button); interior.add(new JLabel(localizationResources.getString( "Series_Paint"))); JTextField info = new JTextField(localizationResources.getString( "No_editor_implemented")); info.setEnabled(false); interior.add(info); button = new JButton(localizationResources.getString("Edit...")); button.setEnabled(false); interior.add(button); interior.add(new JLabel(localizationResources.getString( "Series_Stroke"))); info = new JTextField(localizationResources.getString( "No_editor_implemented")); info.setEnabled(false); interior.add(info); button = new JButton(localizationResources.getString("Edit...")); button.setEnabled(false); interior.add(button); interior.add(new JLabel(localizationResources.getString( "Series_Outline_Paint"))); info = new JTextField(localizationResources.getString( "No_editor_implemented")); info.setEnabled(false); interior.add(info); button = new JButton(localizationResources.getString("Edit...")); button.setEnabled(false); interior.add(button); interior.add(new JLabel(localizationResources.getString( "Series_Outline_Stroke"))); info = new JTextField(localizationResources.getString( "No_editor_implemented")); info.setEnabled(false); interior.add(info); button = new JButton(localizationResources.getString("Edit...")); button.setEnabled(false); interior.add(button); general.add(interior, BorderLayout.NORTH); other.add(general, BorderLayout.NORTH); JPanel parts = new JPanel(new BorderLayout()); Title title = chart.getTitle(); Plot plot = chart.getPlot(); JTabbedPane tabs = new JTabbedPane(); this.titleEditor = new DefaultTitleEditor(title); this.titleEditor.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.addTab(localizationResources.getString("Title"), this.titleEditor); this.plotEditor = new DefaultPlotEditor(plot); this.plotEditor.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.addTab(localizationResources.getString("Plot"), this.plotEditor); tabs.add(localizationResources.getString("Other"), other); parts.add(tabs, BorderLayout.NORTH); add(parts); } /** * Returns a reference to the title editor. * * @return A panel for editing the title. */ public DefaultTitleEditor getTitleEditor() { return this.titleEditor; } /** * Returns a reference to the plot property sub-panel. * * @return A panel for editing the plot properties. */ public DefaultPlotEditor getPlotEditor() { return this.plotEditor; } /** * Returns the current setting of the anti-alias flag. * * @return true if anti-aliasing is enabled. */ public boolean getAntiAlias() { return this.antialias.isSelected(); } /** * Returns the current background paint. * * @return The current background paint. */ public Paint getBackgroundPaint() { return this.background.getPaint(); } /** * Handles user interactions with the panel. * * @param event a BackgroundPaint action. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("BackgroundPaint")) { attemptModifyBackgroundPaint(); } } /** * Allows the user the opportunity to select a new background paint. Uses * JColorChooser, so we are only allowing a subset of all Paint objects to * be selected (fix later). */ private void attemptModifyBackgroundPaint() { Color c; c = JColorChooser.showDialog(this, localizationResources.getString( "Background_Color"), Color.blue); if (c != null) { this.background.setPaint(c); } } /** * Updates the properties of a chart to match the properties defined on the * panel. * * @param chart the chart. */ public void updateChart(JFreeChart chart) { this.titleEditor.setTitleProperties(chart); this.plotEditor.updatePlotProperties(chart.getPlot()); chart.setAntiAlias(getAntiAlias()); chart.setBackgroundPaint(getBackgroundPaint()); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultChartEditorFactory.java0000644000175000017500000000420611173030414031631 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------------------ * DefaultChartEditorFactory.java * ------------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; * * Changes * ------- * 28-Nov-2005 : Version 1 (DG); * */ package org.jfree.chart.editor; import org.jfree.chart.JFreeChart; /** * A default implementation of the {@link ChartEditorFactory} interface. */ public class DefaultChartEditorFactory implements ChartEditorFactory { /** * Creates a new instance. */ public DefaultChartEditorFactory() { } /** * Returns a new instance of a {@link ChartEditor}. * * @param chart the chart. * * @return A chart editor for the given chart. */ public ChartEditor createEditor(JFreeChart chart) { return new DefaultChartEditor(chart); } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultColorBarEditor.java0000644000175000017500000002046411173030414030747 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * -------------------------- * DefaultColorBarEditor.java * -------------------------- * (C) Copyright 2002-2008, by David M. O'Donnell and Contributors. * * Original Author: David M. O'Donnell; * Contributor(s): David Gilbert (for Object Refinery Limited); * Arnaud Lelievre; * * Changes * ------- * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); * 08-Sep-2003 : Added internationalization via use of properties * resourceBundle (RFE 690236) (AL); * 24-Nov-2005 : Moved and renamed: org.jfree.chart.ui.ColorBarPropertyEditPanel * --> DefaultColorBarEditor (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * */ package org.jfree.chart.editor; import java.awt.event.ActionEvent; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import org.jfree.chart.axis.ColorBar; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.GreyPalette; import org.jfree.chart.plot.RainbowPalette; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.layout.LCBLayout; /** * A DefaultColorBarEditor. Extends DefaultNumberAxisEditor to allow * change general axis type parameters. */ class DefaultColorBarEditor extends DefaultNumberAxisEditor { /** * A checkbox that indicates whether or not the color indices should run * high to low. */ private JCheckBox invertPaletteCheckBox; /** Flag set by invertPaletteCheckBox. */ private boolean invertPalette = false; /** A checkbox that indicates whether the palette is stepped. */ private JCheckBox stepPaletteCheckBox; /** Flag set by stepPaletteCheckBox. */ private boolean stepPalette = false; /** The Palette Sample displaying the current Palette. */ private PaletteSample currentPalette; /** An array of availiable sample palettes. */ private PaletteSample[] availablePaletteSamples; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Creates a new edit panel for a color bar. * * @param colorBar the color bar. */ public DefaultColorBarEditor(ColorBar colorBar) { super((NumberAxis) colorBar.getAxis()); this.invertPalette = colorBar.getColorPalette().isInverse(); this.stepPalette = colorBar.getColorPalette().isStepped(); this.currentPalette = new PaletteSample(colorBar.getColorPalette()); this.availablePaletteSamples = new PaletteSample[2]; this.availablePaletteSamples[0] = new PaletteSample(new RainbowPalette()); this.availablePaletteSamples[1] = new PaletteSample(new GreyPalette()); JTabbedPane other = getOtherTabs(); JPanel palettePanel = new JPanel(new LCBLayout(4)); palettePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); palettePanel.add(new JPanel()); this.invertPaletteCheckBox = new JCheckBox( localizationResources.getString("Invert_Palette"), this.invertPalette ); this.invertPaletteCheckBox.setActionCommand("invertPalette"); this.invertPaletteCheckBox.addActionListener(this); palettePanel.add(this.invertPaletteCheckBox); palettePanel.add(new JPanel()); palettePanel.add(new JPanel()); this.stepPaletteCheckBox = new JCheckBox( localizationResources.getString("Step_Palette"), this.stepPalette ); this.stepPaletteCheckBox.setActionCommand("stepPalette"); this.stepPaletteCheckBox.addActionListener(this); palettePanel.add(this.stepPaletteCheckBox); palettePanel.add(new JPanel()); palettePanel.add( new JLabel(localizationResources.getString("Palette")) ); JButton button = new JButton(localizationResources.getString("Set_palette...")); button.setActionCommand("PaletteChoice"); button.addActionListener(this); palettePanel.add(this.currentPalette); palettePanel.add(button); other.add(localizationResources.getString("Palette"), palettePanel); } /** * Handles actions from within the property panel. * * @param event the event. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("PaletteChoice")) { attemptPaletteSelection(); } else if (command.equals("invertPalette")) { this.invertPalette = this.invertPaletteCheckBox.isSelected(); } else if (command.equals("stepPalette")) { this.stepPalette = this.stepPaletteCheckBox.isSelected(); } else { super.actionPerformed(event); // pass to super-class for handling } } /** * Handle a palette selection. */ private void attemptPaletteSelection() { PaletteChooserPanel panel = new PaletteChooserPanel(null, this.availablePaletteSamples); int result = JOptionPane.showConfirmDialog( this, panel, localizationResources.getString("Palette_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE ); if (result == JOptionPane.OK_OPTION) { double zmin = this.currentPalette.getPalette().getMinZ(); double zmax = this.currentPalette.getPalette().getMaxZ(); this.currentPalette.setPalette(panel.getSelectedPalette()); this.currentPalette.getPalette().setMinZ(zmin); this.currentPalette.getPalette().setMaxZ(zmax); } } /** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param colorBar the color bar. */ public void setAxisProperties(ColorBar colorBar) { super.setAxisProperties(colorBar.getAxis()); colorBar.setColorPalette(this.currentPalette.getPalette()); colorBar.getColorPalette().setInverse(this.invertPalette); //dmo added colorBar.getColorPalette().setStepped(this.stepPalette); //dmo added } /** * A static method that returns a panel that is appropriate for the axis * type. * * @param colorBar the color bar. * * @return A panel or nullnull. */ public static DefaultColorBarEditor getInstance(ColorBar colorBar) { if (colorBar != null) { return new DefaultColorBarEditor(colorBar); } else { return null; } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultNumberAxisEditor.java0000644000175000017500000002713411173030414031322 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------------- * DefaultNumberAxisEditor.java * ---------------------------- * (C) Copyright 2005-2009, Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Arnaud Lelievre; * * Changes: * -------- * 24-Nov-2005 : Version 1, based on NumberAxisPropertyEditor (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 27-Feb-2009 : Fixed bug 2612649, NullPointerException (DG); * */ package org.jfree.chart.editor; import java.awt.BasicStroke; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.JTextField; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.layout.LCBLayout; import org.jfree.ui.PaintSample; import org.jfree.ui.StrokeChooserPanel; import org.jfree.ui.StrokeSample; /** * A panel for editing the properties of a value axis. */ class DefaultNumberAxisEditor extends DefaultAxisEditor implements FocusListener { /** A flag that indicates whether or not the axis range is determined * automatically. */ private boolean autoRange; /** The lowest value in the axis range. */ private double minimumValue; /** The highest value in the axis range. */ private double maximumValue; /** A checkbox that indicates whether or not the axis range is determined * automatically. */ private JCheckBox autoRangeCheckBox; /** A text field for entering the minimum value in the axis range. */ private JTextField minimumRangeValue; /** A text field for entering the maximum value in the axis range. */ private JTextField maximumRangeValue; /** The paint selected for drawing the gridlines. */ private PaintSample gridPaintSample; /** The stroke selected for drawing the gridlines. */ private StrokeSample gridStrokeSample; /** An array of stroke samples to choose from (since I haven't written a * decent StrokeChooser component yet). */ private StrokeSample[] availableStrokeSamples; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Standard constructor: builds a property panel for the specified axis. * * @param axis the axis, which should be changed. */ public DefaultNumberAxisEditor(NumberAxis axis) { super(axis); this.autoRange = axis.isAutoRange(); this.minimumValue = axis.getLowerBound(); this.maximumValue = axis.getUpperBound(); this.gridPaintSample = new PaintSample(Color.blue); this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples = new StrokeSample[3]; this.availableStrokeSamples[0] = new StrokeSample( new BasicStroke(1.0f)); this.availableStrokeSamples[1] = new StrokeSample( new BasicStroke(2.0f)); this.availableStrokeSamples[2] = new StrokeSample( new BasicStroke(3.0f)); JTabbedPane other = getOtherTabs(); JPanel range = new JPanel(new LCBLayout(3)); range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); range.add(new JPanel()); this.autoRangeCheckBox = new JCheckBox(localizationResources.getString( "Auto-adjust_range"), this.autoRange); this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff"); this.autoRangeCheckBox.addActionListener(this); range.add(this.autoRangeCheckBox); range.add(new JPanel()); range.add(new JLabel(localizationResources.getString( "Minimum_range_value"))); this.minimumRangeValue = new JTextField(Double.toString( this.minimumValue)); this.minimumRangeValue.setEnabled(!this.autoRange); this.minimumRangeValue.setActionCommand("MinimumRange"); this.minimumRangeValue.addActionListener(this); this.minimumRangeValue.addFocusListener(this); range.add(this.minimumRangeValue); range.add(new JPanel()); range.add(new JLabel(localizationResources.getString( "Maximum_range_value"))); this.maximumRangeValue = new JTextField(Double.toString( this.maximumValue)); this.maximumRangeValue.setEnabled(!this.autoRange); this.maximumRangeValue.setActionCommand("MaximumRange"); this.maximumRangeValue.addActionListener(this); this.maximumRangeValue.addFocusListener(this); range.add(this.maximumRangeValue); range.add(new JPanel()); other.add(localizationResources.getString("Range"), range); } /** * Returns the current setting of the auto-range property. * * @return true if auto range is enabled. */ public boolean isAutoRange() { return this.autoRange; } /** * Returns the current setting of the minimum value in the axis range. * * @return The current setting of the minimum value in the axis range. */ public double getMinimumValue() { return this.minimumValue; } /** * Returns the current setting of the maximum value in the axis range. * * @return The current setting of the maximum value in the axis range. */ public double getMaximumValue() { return this.maximumValue; } /** * Handles actions from within the property panel. * @param event an event. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (command.equals("GridStroke")) { attemptGridStrokeSelection(); } else if (command.equals("GridPaint")) { attemptGridPaintSelection(); } else if (command.equals("AutoRangeOnOff")) { toggleAutoRange(); } else if (command.equals("MinimumRange")) { validateMinimum(); } else if (command.equals("MaximumRange")) { validateMaximum(); } else { // pass to the super-class for handling super.actionPerformed(event); } } /** * Handle a grid stroke selection. */ private void attemptGridStrokeSelection() { StrokeChooserPanel panel = new StrokeChooserPanel(this.gridStrokeSample, this.availableStrokeSamples); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Stroke_Selection"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { this.gridStrokeSample.setStroke(panel.getSelectedStroke()); } } /** * Handle a grid paint selection. */ private void attemptGridPaintSelection() { Color c; c = JColorChooser.showDialog(this, localizationResources.getString( "Grid_Color"), Color.blue); if (c != null) { this.gridPaintSample.setPaint(c); } } /** * Does nothing. * * @param event the event. */ public void focusGained(FocusEvent event) { // don't need to do anything } /** * Revalidates minimum/maximum range. * * @param event the event. */ public void focusLost(FocusEvent event) { if (event.getSource() == this.minimumRangeValue) { validateMinimum(); } else if (event.getSource() == this.maximumRangeValue) { validateMaximum(); } } /** * Toggle the auto range setting. */ public void toggleAutoRange() { this.autoRange = this.autoRangeCheckBox.isSelected(); if (this.autoRange) { this.minimumRangeValue.setText(Double.toString(this.minimumValue)); this.minimumRangeValue.setEnabled(false); this.maximumRangeValue.setText(Double.toString(this.maximumValue)); this.maximumRangeValue.setEnabled(false); } else { this.minimumRangeValue.setEnabled(true); this.maximumRangeValue.setEnabled(true); } } /** * Revalidate the range minimum. */ public void validateMinimum() { double newMin; try { newMin = Double.parseDouble(this.minimumRangeValue.getText()); if (newMin >= this.maximumValue) { newMin = this.minimumValue; } } catch (NumberFormatException e) { newMin = this.minimumValue; } this.minimumValue = newMin; this.minimumRangeValue.setText(Double.toString(this.minimumValue)); } /** * Revalidate the range maximum. */ public void validateMaximum() { double newMax; try { newMax = Double.parseDouble(this.maximumRangeValue.getText()); if (newMax <= this.minimumValue) { newMax = this.maximumValue; } } catch (NumberFormatException e) { newMax = this.maximumValue; } this.maximumValue = newMax; this.maximumRangeValue.setText(Double.toString(this.maximumValue)); } /** * Sets the properties of the specified axis to match the properties * defined on this panel. * * @param axis the axis. */ public void setAxisProperties(Axis axis) { super.setAxisProperties(axis); NumberAxis numberAxis = (NumberAxis) axis; numberAxis.setAutoRange(this.autoRange); if (!this.autoRange) { numberAxis.setRange(this.minimumValue, this.maximumValue); } } } libjfreechart-java-1.0.13.orig/source/org/jfree/chart/editor/DefaultPlotEditor.java0000644000175000017500000006003511173030414030160 0ustar vincentvincent/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ---------------------- * DefaultPlotEditor.java * ---------------------- * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrzej Porebski; * Arnaud Lelievre; * Daniel Gredler; * * Changes: * -------- * 24-Nov-2005 : Version 1, based on PlotPropertyEditPanel.java (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by * Jess Thrysoee (DG); * 27-Feb-2009 : Fixed bug 2612649, NullPointerException (DG); * */ package org.jfree.chart.editor; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Paint; import java.awt.Stroke; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JColorChooser; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import org.jfree.chart.axis.Axis; import org.jfree.chart.axis.ColorBar; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.ContourPlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.util.ResourceBundleWrapper; import org.jfree.layout.LCBLayout; import org.jfree.ui.PaintSample; import org.jfree.ui.RectangleInsets; import org.jfree.ui.StrokeChooserPanel; import org.jfree.ui.StrokeSample; import org.jfree.util.BooleanUtilities; /** * A panel for editing the properties of a {@link Plot}. */ class DefaultPlotEditor extends JPanel implements ActionListener { /** Orientation constants. */ private final static String[] orientationNames = {"Vertical", "Horizontal"}; private final static int ORIENTATION_VERTICAL = 0; private final static int ORIENTATION_HORIZONTAL = 1; /** The paint (color) used to fill the background of the plot. */ private PaintSample backgroundPaintSample; /** The stroke used to draw the outline of the plot. */ private StrokeSample outlineStrokeSample; /** The paint (color) used to draw the outline of the plot. */ private PaintSample outlinePaintSample; /** * A panel used to display/edit the properties of the domain axis (if any). */ private DefaultAxisEditor domainAxisPropertyPanel; /** * A panel used to display/edit the properties of the range axis (if any). */ private DefaultAxisEditor rangeAxisPropertyPanel; /** * A panel used to display/edit the properties of the colorbar axis (if * any). */ private DefaultColorBarEditor colorBarAxisPropertyPanel; /** An array of stroke samples to choose from. */ private StrokeSample[] availableStrokeSamples; /** The insets for the plot. */ private RectangleInsets plotInsets; /** * The orientation for the plot (for CategoryPlots and * XYPlots). */ private PlotOrientation plotOrientation; /** * The orientation combo box (for CategoryPlots and * XYPlots). */ private JComboBox orientationCombo; /** Whether or not to draw lines between each data point (for * LineAndShapeRenderers and StandardXYItemRenderers). */ private Boolean drawLines; /** * The checkbox for whether or not to draw lines between each data point. */ private JCheckBox drawLinesCheckBox; /** Whether or not to draw shapes at each data point (for * LineAndShapeRenderers and StandardXYItemRenderers). */ private Boolean drawShapes; /** * The checkbox for whether or not to draw shapes at each data point. */ private JCheckBox drawShapesCheckBox; /** The resourceBundle for the localization. */ protected static ResourceBundle localizationResources = ResourceBundleWrapper.getBundle( "org.jfree.chart.editor.LocalizationBundle"); /** * Standard constructor - constructs a panel for editing the properties of * the specified plot. *